protected $items;
/**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->items = array();
+ }
+
+ /**
+ * Class constructor.
+ */
+ public function __destruct() {
+ unset($this->items);
+
+ parent::__destruct();
+ }
+
+ /**
* @see: t_base_return_value::p_s_new()
*/
public static function s_new($value) {
public function do_execute(&$http, &$database, &$session, $settings = array()) {
$executed = new c_base_path_executed();
+ if ($this->is_redirect) {
+ $http->set_response_location($this->field_destination);
+ $http->set_response_status($this->field_response_code);
+ }
+
+ $result = $this->set_parameters($http, $database, $session, $settings);
+ if (c_base_return::s_has_error($result)) {
+ $executed->set_error($result->get_errors());
+ }
+ unset($result);
+
+ return $executed;
+ }
+
+ /**
+ * Assign default variables used by this class.
+ *
+ * This is normally done automatically, but in certain cases, this may need to be explicitly called.
+ *
+ * Calling this will trigger default settings to be regernated, including the breadcrumbs.
+ *
+ * @param c_base_http &$http
+ * The entire HTTP information to allow for the execution to access anything that is necessary.
+ * @param c_base_database &$database
+ * The database object, which is usually used by form and ajax paths.
+ * @param c_base_session &$session
+ * The current session.
+ * @param array $settings
+ * (optional) An array of additional settings that are usually site-specific.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ *
+ * @see: self::do_execute()
+ */
+ protected function set_parameters(&$http, &$database, &$session, $settings) {
if (!($http instanceof c_base_http)) {
$error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- $executed->set_error($error);
- unset($error);
+ return c_base_return_error::s_false($error);
}
- elseif (!($database instanceof c_base_database)) {
+
+ if (!($database instanceof c_base_database)) {
$error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- $executed->set_error($error);
- unset($error);
+ return c_base_return_error::s_false($error);
}
- elseif (!($session instanceof c_base_session)) {
+
+ if (!($session instanceof c_base_session)) {
$error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- $executed->set_error($error);
- unset($error);
+ return c_base_return_error::s_false($error);
}
- elseif (!is_array($settings)) {
+
+ if (!is_array($settings)) {
$error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- $executed->set_error($error);
- unset($error);
+ return c_base_return_error::s_false($error);
}
- if ($this->is_redirect) {
- $http->set_response_location($this->field_destination);
- $http->set_response_status($this->field_response_code);
+ $this->http = $http;
+ $this->database = $database;
+ $this->session = $session;
+ $this->settings = $settings;
+
+ $request_uri = $this->http->get_request(c_base_http::REQUEST_URI)->get_value_exact();
+ if (isset($request_uri['data']) && is_string($request_uri['data'])) {
+ $request_uri = $request_uri['data'];
+ unset($request_uri['current']);
+ unset($request_uri['invalid']);
+
+ $this->request_uri = $request_uri;
+ }
+ else {
+ $this->request_uri = array(
+ 'scheme' => $this->settings['base_scheme'],
+ 'authority' => $this->settings['base_host'],
+ 'path' => $this->settings['base_path'],
+ 'query' => NULL,
+ 'fragment' => NULL,
+ 'url' => TRUE,
+ );
}
+ unset($request_uri);
- return $executed;
+ return new c_base_return_true();
}
/**
* @see: self::s_value()
*/
public static function s_return($class, $error = NULL) {
- if (!class_exists($class) || !($class instanceof c_base_return)) {
+ if (!class_exists($class) && !($class instanceof c_base_return)) {
return self::s_false($error);
}
require_once('common/base/classes/base_error.php');
require_once('common/base/classes/base_return.php');
require_once('common/base/classes/base_form.php');
+require_once('common/base/classes/base_users.php');
/**
* A class for managing sessions.
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides a class for managing view objects.
+ *
+ * This is for providing a common api for loading views from the database.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_database.php');
+require_once('common/base/classes/base_array.php');
+
+/**
+ * A generic class for providing classes that support a loading and processing specific view results.
+ *
+ * @require class c_base_array
+ */
+class c_base_view extends c_base_array {
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, '');
+ }
+
+ /**
+ * Provides basic database load access for whose data is to be stored in this class.
+ *
+ * @param c_base_database &$database
+ * The database object to load from.
+ * @param string|null $query
+ * (optional) The query string to execute.
+ * If NULL, then the class default will be used.
+ * @param array $arguments
+ * (optional) An array containing arguments to be passed along with the query string.
+ * @param string|null $conditions
+ * (optional) This can be a string of additional conditions to append to the default query string.
+ * This is appended to the query string along with ' where '.
+ * If a where condition is already specified in the query string then this will result in a query error.
+ * @param int|null $limit
+ * (optional) This can be an integer to append to the default query string as a query limit.
+ * This is appended to the query string along with ' limit '.
+ * If a limit condition is already specified in the query string then this will result in a query error.
+ * @param int|null $offset
+ * (optional) This can be an integer to append to the default query string as a query offset.
+ * This is appended to the query string along with ' offset '.
+ * If a offset condition is already specified in the query string then this will result in a query error.
+ * @param int|null $group_by
+ * (optional) This can be an integer to append to the default query string as a query group by.
+ * This is appended to the query string along with ' group by '.
+ * If a group by condition is already specified in the query string then this will result in a query error.
+ * @param int|null $order_by
+ * (optional) This can be an integer to append to the default query string as a query order by.
+ * This is appended to the query string along with ' order by '.
+ * If a order by condition is already specified in the query string then this will result in a query error.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE without error bit set is returned if nothing was done.
+ * FALSE with error bit set is returned on error.
+ */
+ public function pull(&$database, $query = NULL, $arguments = array(), $conditions = NULL, $limit = NULL, $offset = NULL, $group_by = NULL, $order_by = NULL) {
+ if (!($database instanceof c_base_database)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($query) && !is_string($query)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'query', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_array($arguments)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'arguments', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($conditions) && !is_string($conditions)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'conditions', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($limit) && !is_string($limit)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'limit', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($offset) && !is_string($offset)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'offset', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($group_by) && !is_string($group_by)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'group_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ if (!is_null($order_by) && !is_string($order_by)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'order_by', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ // return FALSE because this is a stub function and it does nothing.
+ return new c_base_return_false();
+ }
+}
if ($user_current->do_load($this->database) instanceof c_base_return_true) {
$this->session->set_user_current($user_current);
}
+ else {
+ // @todo: hanle errors.
+ }
unset($user_current);
$user_session = new c_standard_users_user();
if ($user_session->do_load($this->database, TRUE) instanceof c_base_return_true) {
$this->session->set_user_current($user_session);
}
+ else {
+ // @todo: hanle errors.
+ }
unset($user_session);
return new c_base_return_true();
}
/**
- * Assign default variables used by this class.
- *
- * This is normally done automatically, but in certain cases, this may need to be explicitly called.
- *
- * Calling this will trigger default settings to be regernated, including the breadcrumbs.
- *
- * @param c_base_http &$http
- * The entire HTTP information to allow for the execution to access anything that is necessary.
- * @param c_base_database &$database
- * The database object, which is usually used by form and ajax paths.
- * @param c_base_session &$session
- * The current session.
- * @param array $settings
- * (optional) An array of additional settings that are usually site-specific.
- *
- * @return c_base_return_status
- * TRUE on success.
- * FALSE with error bit set is returned on error.
- *
- * @see: self::do_execute()
+ * Implements do_execute().
*/
- protected function set_parameters(&$http, &$database, &$session, $settings) {
- if (!($http instanceof c_base_http)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ public function do_execute(&$http, &$database, &$session, $settings = array()) {
+ $executed = parent::do_execute($http, $database, $session, $settings);
+ if (c_base_return::s_has_error($executed)) {
+ return $executed;
}
- if (!($database instanceof c_base_database)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ // to avoid recursion, breadcrumbs are initialized here instead of in set_parameters().
+ $this->pr_build_breadcrumbs();
+
+ return $executed;
+ }
+
+ /**
+ * Implements set_parameters().
+ */
+ protected function set_parameters(&$http, &$database, &$session, $settings) {
+ $result = parent::set_parameters($http, $database, $session, $settings);
+ if (c_base_return::s_has_error($result)) {
+ return $result;
}
+ unset($result);
- if (!($session instanceof c_base_session)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $this->text_type = c_base_markup_tag::TYPE_SPAN;
+ if (isset($this->settings['standards_issue-use_p_tags']) && $this->settings['standards_issue-use_p_tags']) {
+ $this->text_type = c_base_markup_tag::TYPE_PARAGRAPH;
}
- if (!is_array($settings)) {
- $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
- return c_base_return_error::s_false($error);
+ $this->languages = $this->http->get_response_content_language()->get_value_exact();
+ if (!is_array($this->languages)) {
+ $this->languages = array();
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
+ $this->pr_get_language_alias();
return new c_base_return_true();
}
return $path_parts;
}
- /**
- * Load any default settings.
- *
- * @param c_base_http &$http
- * The entire HTTP information to allow for the execution to access anything that is necessary.
- * @param c_base_database &$database
- * The database object, which is usually used by form and ajax paths.
- * @param c_base_session &$session
- * The current session.
- * @param array $settings
- * (optional) An array of additional settings that are usually site-specific.
- */
- protected function pr_assign_defaults(&$http, &$database, &$session, &$settings) {
- $this->http = $http;
- $this->database = $database;
- $this->session = $session;
- $this->settings = $settings;
-
- $this->text_type = c_base_markup_tag::TYPE_SPAN;
- if (isset($this->settings['standards_issue-use_p_tags']) && $this->settings['standards_issue-use_p_tags']) {
- $this->text_type = c_base_markup_tag::TYPE_PARAGRAPH;
- }
-
- $request_uri = $this->http->get_request(c_base_http::REQUEST_URI)->get_value_exact();
- if (isset($request_uri['data']) && is_string($request_uri['data'])) {
- $request_uri = $request_uri['data'];
- unset($request_uri['current']);
- unset($request_uri['invalid']);
-
- $this->request_uri = $request_uri;
- }
- else {
- $this->request_uri = array(
- 'scheme' => $this->settings['base_scheme'],
- 'authority' => $this->settings['base_host'],
- 'path' => $this->settings['base_path'],
- 'query' => NULL,
- 'fragment' => NULL,
- 'url' => TRUE,
- );
- }
- unset($request_uri);
-
- $this->languages = $this->http->get_response_content_language()->get_value_exact();
- if (!is_array($this->languages)) {
- $this->languages = array();
- }
-
- $this->pr_get_language_alias();
-
- $this->pr_build_breadcrumbs();
- }
/**
* Build the breadcrumb.
$false = c_base_return_error::s_false($query_result->get_error());
$last_error = $database->get_last_error()->get_value_exact();
- var_dump($last_error);
+
if (!empty($last_error)) {
$error = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR);
$false->set_error($error);
+ unset($error);
}
unset($last_error);
return $executed;
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
$wrapper->set_tag($this->pr_create_tag_text_block(1));
return $executed;
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
$wrapper->set_tag($this->pr_create_tag_text_block(1));
return $executed;
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
$wrapper->set_tag($this->pr_create_tag_text_block(1));
return $executed;
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
$wrapper->set_tag($this->pr_create_tag_text_block(1));
return $executed;
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
$wrapper->set_tag($this->pr_create_tag_text_block(1));
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
$wrapper->set_tag($this->pr_create_tag_text_block(1));
return $executed;
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
// initialize the content as HTML.
$this->pr_create_html();
return $executed;
}
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$this->pr_do_logout($http, $database, $session, $settings);
$wrapper = $this->pr_create_tag_section(array(1 => 0));
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
// initialize the content as HTML.
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
// initialize the content as HTML.
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
// initialize the content as HTML.
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$arguments = $this->pr_get_path_arguments(self::PATH_SELF);
if (!empty($arguments)) {
// @todo: return $this->p_do_execute_X($executed);
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
$wrapper = $this->pr_create_tag_section(array(1 => 0));
// initialize the content as HTML.
return $executed;
};
- $this->pr_assign_defaults($http, $database, $session, $settings);
-
// @todo: this function needs to check to see if the user has administer (or manager?) roles (c_base_roles::MANAGER, c_base_roles::ADMINISTER) and if they do, set administrative to TRUE when calling do_load().
- $roles_current = $this->session->get_user_current()->get_roles()->get_value_exact();
+ $user = $this->session->get_user_current();
+ $roles_current = $user->get_roles()->get_value_exact();
$id_user = NULL;
$arguments = $this->pr_get_path_arguments(self::PATH_SELF);
// do not allow view access to reserved/special accounts.
if ($id_user < self::ID_USER_MINIMUM) {
- $id_user = NULL;
+ $id_user = FALSE;
}
}
else {
unset($arguments_total);
unset($argument);
unset($id_user);
+ unset($user);
$error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => self::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH);
$executed->set_error($error);
# $id_user = NULL;
#}
else {
- $id_user = NULL;
+ $id_user = FALSE;
}
}
unset($arguments_total);
unset($argument);
- if (is_null($id_user)) {
+ if ($id_user === FALSE) {
+ unset($user);
+ unset($id_user);
+
$error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => self::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH);
$executed->set_error($error);
}
}
+ $user = NULL;
if (is_null($id_user)) {
- // load current user.
- if ($this->session->get_user_current()->get_id()->get_value_exact() > 0) {
- $user = $this->session->get_user_current();
+ $user = $this->session->get_user_current();
+ $id_user = $user->get_id()->get_value_exact();
+
+ // do not allow view access to reserved/special accounts.
+ if ($id_user < self::ID_USER_MINIMUM) {
+ $id_user = FALSE;
}
}
else {
// @todo: handle database errors.
$loaded = $user->do_load($this->database, $id_user);
if ($loaded instanceof c_base_return_false) {
- $user = NULL;
+ $id_user = FALSE;
}
unset($loaded);
}
- unset($id_user);
- // user is set to NULL on error.
- if (is_null($user)) {
+ if ($id_user === FALSE) {
+ unset($id_user);
+
$error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => self::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH);
$executed->set_error($error);
return $executed;
}
unset($arguments);
+ unset($id_user);
$this->p_do_execute_view($executed, $user);
unset($user);
* The execution results to be returned.
* @param c_base_users_user $user_id
* An object representing the user to view.
+ *
+ * @return null|c_base_return_error
+ * NULL is returned if no errors are found.
+ * Errors are returned if found.
*/
- private function p_do_execute_view(&$executed, $user) {
+ protected function p_do_execute_view(&$executed, $user) {
+ $errors = NULL;
+
$arguments = array();
$arguments[':{user_name}'] = $user->get_name_human()->get_first()->get_value_exact() . ' ' . $user->get_name_human()->get_last()->get_value_exact();
if (mb_strlen($arguments[':{user_name}']) == 0) {
// @todo: implement code for processing and generating a table/list of history, with the ability to navigate additional entries.
+ $query_result = $this->database->do_query('select id, id_user, log_title, log_type, log_type_sub, log_severity, log_facility, log_details, log_date, request_client, response_code from v_log_users_self limit 10');
+
+ if (c_base_return::s_has_error($query_result)) {
+ if (is_null($errors)) {
+ $errors = $query_result->get_error();
+ }
+ else {
+ c_base_return::s_copy_errors($query_result->get_error(), $errors);
+ }
+
+ $last_error = $this->database->get_last_error()->get_value_exact();
+
+ if (!empty($last_error)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR);
+ $errors->set_error($error);
+ unset($error);
+ }
+ unset($last_error);
+ }
+ else {
+ $columns = $query_result->fetch_row()->get_value();
+ while (is_array($columns) && !empty($columns)) {
+ $this->id = (int) $columns[0];
+ $this->id_user = (int) $columns[1];
+
+ $this->log_title = (string) $columns[2];
+ $this->log_type = (int) $columns[3];
+ $this->log_type_sub = (int) $columns[4];
+ $this->log_severity = (int) $columns[5];
+ $this->log_facility = (int) $columns[6];
+ $this->log_details = json_decode($columns[7], TRUE);
+ $this->log_date = c_base_defaults_global::s_get_timestamp($columns[8])->get_value_exact();
+ $this->request_client = (string) $columns[9];
+ $this->response_code = (int) $columns[10];
+
+ $columns = $query_result->fetch_row()->get_value();
+ }
+ unset($columns);
+ }
+
$fieldset->set_tag($content);
unset($content);
--- /dev/null
+<?php
+/**
+ * @file
+ * Provides a classes for managing the view: v_log_users_self.
+ *
+ * This is for providing a common api for loading views from the database.
+ */
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+require_once('common/base/classes/base_view.php');
+
+/**
+ * A specific class for processing view results: v_log_users_self.
+ *
+ * @require class c_base_rfc_string
+ */
+class c_view_log_users_self extends c_base_view {
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->id = NULL;
+ }
+
+ /**
+ * Class constructor.
+ */
+ public function __destruct() {
+ unset($this->id);
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, '');
+ }
+
+ /**
+ * Provides basic database load access for whose data is to be stored in this class.
+ *
+ * @param c_base_database &$database
+ * The database object to load from.
+ * @param string|null $query
+ * (optional) The query string to execute.
+ * If NULL, then the class default will be used.
+ * @param array $arguments
+ * (optional) An array containing arguments to be passed along with the query string.
+ * @param string|null $conditions
+ * (optional) This can be a string of additional conditions to append to the default query string.
+ * This is appended to the query string along with ' where '.
+ * If a where condition is already specified in the query string then this will result in a query error.
+ * @param int|null $limit
+ * (optional) This can be an integer to append to the default query string as a query limit.
+ * This is appended to the query string along with ' limit '.
+ * If a limit condition is already specified in the query string then this will result in a query error.
+ * @param int|null $offset
+ * (optional) This can be an integer to append to the default query string as a query offset.
+ * This is appended to the query string along with ' offset '.
+ * If a offset condition is already specified in the query string then this will result in a query error.
+ * @param int|null $group_by
+ * (optional) This can be an integer to append to the default query string as a query group by.
+ * This is appended to the query string along with ' group by '.
+ * If a group by condition is already specified in the query string then this will result in a query error.
+ * @param int|null $order_by
+ * (optional) This can be an integer to append to the default query string as a query order by.
+ * This is appended to the query string along with ' order by '.
+ * If a order by condition is already specified in the query string then this will result in a query error.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE without error bit set is returned if nothing was done.
+ * FALSE with error bit set is returned on error.
+ */
+ public function pull(&$database, $query = NULL, $arguments = array(), $conditions = NULL, $limit = NULL, $offset = NULL, $group_by = NULL, $order_by = NULL) {
+ $result = parent::pull($database, $query, $arguments, $conditions, $limit, $offset, $group_by, $order_by);
+ if (c_base_return::s_has_error($result)) {
+ return $result;
+ }
+ unset($result);
+
+ $query_string = '';
+ if (is_null($query)) {
+ }
+ else {
+ $query_string = $query;
+ }
+
+ }
+}
+
+/**
+ * A specific class for storing view results: v_log_users_self.
+ */
+class c_view_log_users_self extends c_base_return {
+ protected $id;
+ protected $id_user;
+
+ protected $log_title;
+ protected $log_type;
+ protected $log_type_sub;
+ protected $log_severity;
+ protected $log_facility;
+ protected $log_details;
+ protected $log_date;
+
+ protected $request_client;
+ protected $response_code;
+
+ /**
+ * Class constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ $this->id = NULL;
+ $this->id_user = NULL;
+
+ $this->log_title = NULL;
+ $this->log_type = NULL;
+ $this->log_type_sub = NULL;
+ $this->log_severity = NULL;
+ $this->log_facility = NULL;
+ $this->log_details = NULL;
+ $this->log_date = NULL;
+
+ $this->request_client = NULL;
+ $this->response_code = NULL;
+ }
+
+ /**
+ * Class constructor.
+ */
+ public function __destruct() {
+ unset($this->id);
+ unset($this->id_user);
+
+ unset($this->log_title);
+ unset($this->log_type);
+ unset($this->log_type_sub);
+ unset($this->log_severity);
+ unset($this->log_facility);
+ unset($this->log_details);
+ unset($this->log_date);
+
+ unset($this->request_client);
+ unset($this->response_code);
+
+ parent::__destruct();
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_new()
+ */
+ public static function s_new($value) {
+ return self::p_s_new($value, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value::p_s_value()
+ */
+ public static function s_value($return) {
+ return self::p_s_value($return, __CLASS__);
+ }
+
+ /**
+ * @see: t_base_return_value_exact::p_s_value_exact()
+ */
+ public static function s_value_exact($return) {
+ return self::p_s_value_exact($return, __CLASS__, '');
+ }
+
+ /**
+ * Set the log id.
+ *
+ * @param int $id
+ * The log id.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_id($id) {
+ if (!is_int($id)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->id = $id;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the user id.
+ *
+ * @param int $id_user
+ * The user id.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_id_user($id_user) {
+ if (!is_int($id_user)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id_user', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->id_user = $id_user;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log title.
+ *
+ * @param string $title
+ * The log title.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_title($title) {
+ if (!is_string($title)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'title', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->title = $title;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log type.
+ *
+ * @param string $type
+ * The log type.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_type($type) {
+ if (!is_string($type)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->type = $type;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log type sub.
+ *
+ * @param string $type_sub
+ * The log sub-type.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_type_sub($type_sub) {
+ if (!is_string($type_sub)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'type_sub', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->type_sub = $type_sub;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log severity.
+ *
+ * @param string $log_severity
+ * The log severity.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_log_severity($log_severity) {
+ if (!is_int($log_severity)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'log_severity', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->log_severity = $log_severity;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log facility.
+ *
+ * @param string $log_facility
+ * The log facility.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_log_facility($log_facility) {
+ if (!is_string($log_facility)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'log_facility', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->log_facility = $log_facility;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log details.
+ *
+ * @param array|string $log_details
+ * The log details.
+ * If a string, then this is a json encoded string to be converted into an array.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_log_details($log_details) {
+ if (is_string($log_details)) {
+ $log_details_decoded = json_decode($log_details, TRUE);
+
+ if (!is_array($log_details_decoded)) {
+ unset($log_details_decoded);
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'log_details', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->log_details = $log_details_decoded;
+ unset($log_details_decoded);
+
+ return new c_base_return_true();
+ }
+
+ if (!is_array($log_details)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'log_details', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->log_details = $log_details;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log date.
+ *
+ * @param int|float|string $date
+ * The log date.
+ * If this is a string, then it is a date string to be converted into a timestamp.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_date($date) {
+ if (is_string($date)) {
+ $this->date = c_base_defaults_global::s_get_timestamp($date)->get_value_exact();;
+ return new c_base_return_true();
+ }
+
+ if (!is_int($date) && !is_float($date)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->date = $date;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log request_client.
+ *
+ * @param string $request_client
+ * The log request_client.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_request_client($request_client) {
+ if (!is_string($request_client)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'request_client', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->request_client = $request_client;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Set the log response_code.
+ *
+ * @param string $response_code
+ * The log response_code.
+ *
+ * @return c_base_return_status
+ * TRUE on success.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_response_code($response_code) {
+ if (!is_string($response_code)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'response_code', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->response_code = $response_code;
+ return new c_base_return_true();
+ }
+
+ /**
+ * Get the log id.
+ *
+ * @return c_base_return_int
+ * The unique numeric id assigned to this object.
+ * 0 with error bit set is returned on error.
+ */
+ public function get_id() {
+ if (!is_int($this->id)) {
+ $this->id = 0;
+ }
+
+ return c_base_return_int::s_new($this->id);
+ }
+
+ /**
+ * Get the user id.
+ *
+ * @return c_base_return_int
+ * The numeric id assigned to this object.
+ * 0 with error bit set is returned on error.
+ */
+ public function get_id_user() {
+ if (!is_int($this->id_user)) {
+ $this->id_user = 0;
+ }
+
+ return c_base_return_int::s_new($this->id_user);
+ }
+
+ /**
+ * Get the log title.
+ *
+ * @return c_base_return_string
+ * The unique log title assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_log_title() {
+ if (!is_string($this->log_title)) {
+ $this->log_title = '';
+ }
+
+ return c_base_return_string::s_new($this->log_title);
+ }
+
+ /**
+ * Get the log type.
+ *
+ * @return c_base_return_int
+ * The log type assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_log_type() {
+ if (!is_int($this->log_type)) {
+ $this->log_type = 0;
+ }
+
+ return c_base_return_int::s_new($this->log_type);
+ }
+
+ /**
+ * Get the log type_sub.
+ *
+ * @return c_base_return_int
+ * The log sub-type assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_log_type_sub() {
+ if (!is_int($this->log_type_sub)) {
+ $this->log_type_sub = 0;
+ }
+
+ return c_base_return_int::s_new($this->log_type_sub);
+ }
+
+ /**
+ * Get the log severity.
+ *
+ * @return c_base_return_int
+ * The log severity assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_log_severity() {
+ if (!is_int($this->log_severity)) {
+ $this->log_severity = 0;
+ }
+
+ return c_base_return_int::s_new($this->log_severity);
+ }
+
+ /**
+ * Get the log facility.
+ *
+ * @return c_base_return_int
+ * The log facility assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_log_facility() {
+ if (!is_int($this->log_facility)) {
+ $this->log_facility = 0;
+ }
+
+ return c_base_return_int::s_new($this->log_facility);
+ }
+
+ /**
+ * Get the log details.
+ *
+ * @return c_base_return_array
+ * The log details assigned to this object.
+ * An empty array with error bit set is returned on error.
+ */
+ public function get_log_details() {
+ if (!is_array($this->log_details)) {
+ $this->log_details = array();
+ }
+
+ return c_base_return_array::s_new($this->log_details);
+ }
+
+ /**
+ * Get the log date.
+ *
+ * @return c_base_return_int|c_base_return_float
+ * The log date assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_log_date() {
+ if (!is_int($this->log_date) && !is_float($this->log_date)) {
+ $this->log_date = 0;
+ }
+
+ if (is_float($this->log_date)) {
+ return c_base_return_float::s_new($this->log_date);
+ }
+
+ return c_base_return_int::s_new($this->log_date);
+ }
+
+ /**
+ * Get the log request_client.
+ *
+ * @return c_base_return_string
+ * The request client assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_request_client() {
+ if (!is_string($this->request_client)) {
+ $this->request_client = '';
+ }
+
+ return c_base_return_string::s_new($this->request_client);
+ }
+
+ /**
+ * Get the log response_code.
+ *
+ * @return c_base_return_int
+ * The response code assigned to this object.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_response_code() {
+ if (!is_int($this->response_code)) {
+ $this->response_code = 0;
+ }
+
+ return c_base_return_int::s_new($this->response_code);
+ }
+}