From: Kevin Day Date: Mon, 4 Sep 2017 03:57:35 +0000 (-0500) Subject: Progress: user page settings X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=4b26bb7f0746469fcf735c9f0f5997c1369d8fee;p=koopa Progress: user page settings Fix a logic flaw in the regular expression handling of wildcard paths. - paths with multiple '/%' where not being properly stripped and such paths (like 'u/view/%/%' where being incorrectly stripped into 'u/view%'). - This resulted in incorrect 'path not found' issues. Move repeated user content into the core path, adding new class variables as necessary. Make the default behavior in 'c_standard_path' to include $output_format as well as $arguments. - $output_format represents the requested output format, the standard being 'html'. - mime type integers are used, but strings are supported for non-mimetype presentations, such as 'print' for printer-friendly html. - This will allow for every single path to potentially be presented in other formats. - The most common formats being 'html', 'print', and 'pdf'. - More advanced usage can be used via 'json', which is essentially for AJAX. - Because all content may be represented in 'json', it also makes it possible for 3rd-party clients to render a complete page following a standard format without having to parse HTML. - This allows for incredibly advanced functionality which can be later utilized by custom clients such as phone-apps that wish to present the data to the user. - Furthermore, more advanced accessibility (in the context of ADA) can be used so that HTML does not need to be parsed and more content-specific material may be used with less overhead. - This includes allowing for a client, such as a screen-reader, to make explicit content requests. - I may, in the near future, implement a raspberry pi screen reader that utilizes this as a proof of concept. - $arguments represents the processed arguments. --- diff --git a/common/base/classes/base_path.php b/common/base/classes/base_path.php index da4d864..a9cb781 100644 --- a/common/base/classes/base_path.php +++ b/common/base/classes/base_path.php @@ -366,7 +366,7 @@ class c_base_path extends c_base_rfc_string { // the path wildcard is intentionally non-standard. // remove it so that it does not cause the validator to fail. - $without_wildcard = preg_replace('@(^%/|^%$|/%/|/%$)@', '', $sanitized); + $without_wildcard = preg_replace('@(^%/|^%$|(/%)+|/%/$|/%$)@', '', $sanitized); if (!is_string($without_wildcard)) { return FALSE; } diff --git a/common/base/classes/base_paths.php b/common/base/classes/base_paths.php index 8aaf942..80b930b 100644 --- a/common/base/classes/base_paths.php +++ b/common/base/classes/base_paths.php @@ -181,6 +181,7 @@ class c_base_paths extends c_base_return { $depth_total = count($path_parts); // make sure the first path exists. + // note that 'paths' is not populated here, but is later used when being processed by self::find_path(). $path_part = array_shift($path_parts); if (!array_key_exists($path_part, $path_tree)) { $path_tree[$path_part] = array( @@ -352,7 +353,7 @@ class c_base_paths extends c_base_return { 'methods' => isset($path_tree['methods']) ? $path_tree['methods'] : NULL, ); - if ($depth_current == $depth_total) { + if ($depth_current == $depth_total) { $found = array( 'include_directory' => $path_tree['include_directory'], 'include_name' => $path_tree['include_name'], diff --git a/common/standard/classes/standard_path.php b/common/standard/classes/standard_path.php index 583e19d..4e90102 100644 --- a/common/standard/classes/standard_path.php +++ b/common/standard/classes/standard_path.php @@ -7,6 +7,7 @@ require_once('common/base/classes/base_error.php'); require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_menu.php'); require_once('common/base/classes/base_markup.php'); +require_once('common/base/classes/base_mime.php'); /** * Provides standard extensions to base paths. @@ -103,6 +104,8 @@ class c_standard_path extends c_base_path { protected $text_type; protected $request_uri; protected $breadcrumbs; + protected $arguments; + protected $output_format; /** @@ -120,9 +123,11 @@ class c_standard_path extends c_base_path { $this->languages = array(); $this->language_alias = NULL; - $this->text_type = NULL; - $this->request_uri = NULL; - $this->breadcrumbs = NULL; + $this->text_type = NULL; + $this->request_uri = NULL; + $this->breadcrumbs = NULL; + $this->arguments = array(); + $this->output_format = c_base_mime::TYPE_TEXT_HTML; } /** @@ -141,6 +146,8 @@ class c_standard_path extends c_base_path { unset($this->text_type); unset($this->request_uri); unset($this->breadcrumbs); + unset($this->arguments); + unset($this->output_format); parent::__destruct(); } @@ -211,29 +218,31 @@ class c_standard_path extends c_base_path { * Return the current path parts after the specified path. * * This is intended for handling the path parts as arguments. + * Processed path arguments are stored on the classes arguments variable. * * No sanitization is performed on these arguments. * * @param string $path_after * The string to parse. * - * @return c_base_return_array - * An array of url path parts. - * An empty array with error bit set on error. + * @return bool + * TRUE on success, FALSE otherwise. + * On error, arguments is assigned to an empty array. */ - protected function pr_get_path_arguments($path_after) { + protected function pr_process_path_arguments($path_after) { $path = $this->http->get_request_uri_relative($this->settings['base_path'])->get_value_exact(); $path = preg_replace('@^' . $path_after . '(/|$)@i', '', $path); if (mb_strlen($path) == 0) { unset($path); - return array(); + $this->arguments = array(); + return FALSE; } - $path_parts = explode('/', $path); + $this->arguments = explode('/', $path); unset($path); - return $path_parts; + return TRUE; } /** diff --git a/common/standard/classes/standard_path_user.php b/common/standard/classes/standard_path_user.php index 4223616..4598ef5 100644 --- a/common/standard/classes/standard_path_user.php +++ b/common/standard/classes/standard_path_user.php @@ -15,6 +15,9 @@ require_once('common/theme/classes/theme_html.php'); /** * Provides user-specific extensions to standard paths. + * + * This extension specifically provides a user id and a user object that the path is expected to present the content of. + * This is not to be confused with the currently logged in user. */ class c_standard_path_user extends c_standard_path { protected const ID_USER_MINIMUM = 1000; @@ -22,10 +25,173 @@ class c_standard_path_user extends c_standard_path { protected const CLASS_ID_USER = 'id-user'; protected const CLASS_ID_USER_EXTERNAL = 'id-user-external'; + protected $path_user; + protected $path_user_id; + + /** + * Class constructor. + */ + public function __construct() { + parent::__construct(); + + $this->path_user = NULL; + $this->path_user_id = NULL; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->path_user); + unset($this->path_user_id); + + parent::__destruct(); + } + /** * Implements pr_get_text_title(). */ protected function pr_get_text_title($arguments = array()) { return $this->pr_get_text(0, $arguments); } + + /** + * Provides a standard argument handler function. + * + * This is generally intended to be called by do_execute(). + * + * This will load and then validate the standard argument structure. + * The standard user path argument structure is as follows: + * - No Arguments: default user account and settings. + * - Argument 0 (optional): The user ID argument to present the content of (may also be non-numeric values of 'Argument 1' for current user). + * - Argument 1 (optional): Action argument, at the very least supports the following values 'html', 'rss', 'ical', 'pdf', 'ps', 'print', 'json', and 'text'. + * + * This alters the path_user and path_user_id class variables. + * - path_user is set to either the current user or the user specified by the url arguments. + * - path_user_id is either assigned to the id of the user represented by path_user or FALSE. + * - If FALSE, then the user ID is either invalid or is somehow unavailable. + * + * This alters the format_output class variable as follows: + * - provides output mime-type integer code for expected output format. + * - special case formats (non-integer/string values), such as 'print', are stored in this variable to represent print-friendly output. + * + * This will alter the current position of the arguments array as per PHP array functions. + * - This allows for child classes to process further arguments after calling this function without re-processing. + * - reset() should be called on the array argument to bypass this behavior. + * + * @param c_base_path_executed &$executed + * The execution array for making changes to. + * Any detected errors are assigned to this. + * + * @return bool + * TRUE on success, FALSE otherwise. + */ + protected function pr_process_arguments(&$executed) { + $this->path_user = $this->session->get_user_current(); + $this->path_user_id = NULL; + $this->output_format = c_base_mime::TYPE_TEXT_HTML; + + if ($this->pr_process_path_arguments(static::PATH_SELF)) { + $argument = reset($this->arguments); + + if (is_numeric($argument)) { + $this->path_user_id = (int) $argument; + + // do not allow view access to reserved/special accounts. + if ($this->path_user_id < static::ID_USER_MINIMUM) { + $this->path_user_id = FALSE; + unset($argument); + + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); + + return FALSE; + } + } + else { + $argument = NULL; + } + + $arguments_total = count($this->arguments); + if (is_null($argument) || $arguments_total > 1) { + if (is_null($argument)) { + $argument = current($this->arguments); + } + else { + $argument = next($this->arguments); + } + + if ($argument == 'print') { + $this->output_format = 'print'; + } + elseif ($argument == 'html') { + $this->output_format = c_base_mime::TYPE_TEXT_HTML; + } + elseif ($argument == 'pdf') { + $this->output_format = c_base_mime::TYPE_DOCUMENT_PDF; + } + elseif ($argument == 'ps') { + $this->output_format = c_base_mime::TYPE_TEXT_PS; + } + elseif ($argument == 'rss') { + $this->output_format = c_base_mime::TYPE_TEXT_RSS; + } + elseif ($argument == 'ical') { + $this->output_format = c_base_mime::TYPE_TEXT_ICAL; + } + elseif ($argument == 'text') { + $this->output_format = c_base_mime::TYPE_TEXT_PLAIN; + } + elseif ($argument == 'json') { + $this->output_format = c_base_mime::TYPE_TEXT_JSON; + } + else { + unset($argument); + unset($arguments_total); + + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); + + return FALSE; + } + } + unset($argument); + unset($arguments_total); + } + + if (is_null($this->path_user_id)) { + $this->path_user = $this->session->get_user_current(); + $this->path_user_id = $this->path_user->get_id()->get_value_exact(); + + // do not allow view access to reserved/special accounts. + if ($this->path_user_id < static::ID_USER_MINIMUM) { + $this->path_user_id = FALSE; + } + } + else { + $this->path_user = new c_standard_users_user(); + + // @todo: handle database errors. + $loaded = $this->path_user->do_load($this->database, $this->path_user_id); + if ($loaded instanceof c_base_return_false) { + $this->path_user_id = FALSE; + } + else { + // @todo: check to see if user id is accessible. + } + unset($loaded); + } + + if ($this->path_user_id === FALSE) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); + + return FALSE; + } + + return TRUE; + } } diff --git a/common/standard/classes/standard_paths.php b/common/standard/classes/standard_paths.php index e7ee9d3..6808bdb 100644 --- a/common/standard/classes/standard_paths.php +++ b/common/standard/classes/standard_paths.php @@ -24,9 +24,6 @@ class c_standard_paths extends c_base_return { const URI_USER_LOCK = 'u/lock'; const URI_USER_LOGIN = 'u/login'; const URI_USER_LOGOUT = 'u/logout'; - const URI_USER_PDF = 'u/pdf'; - const URI_USER_PRINT = 'u/print'; - const URI_USER_PS = 'u/ps'; const URI_USER_REFRESH = 'u/refresh'; const URI_USER_SESSION = 'u/session'; const URI_USER_SETTINGS = 'u/settings'; @@ -54,9 +51,6 @@ class c_standard_paths extends c_base_return { protected const NAME_USER_LOCK = 'user_lock'; protected const NAME_USER_LOGIN = 'user_login'; protected const NAME_USER_LOGOUT = 'user_logout'; - protected const NAME_USER_PDF = 'user_pdf'; - protected const NAME_USER_PRINT = 'user_print'; - protected const NAME_USER_PS = 'user_ps'; protected const NAME_USER_REFRESH = 'user_refresh'; protected const NAME_USER_SESSION = 'user_session'; protected const NAME_USER_SETTINGS = 'user_settings'; @@ -79,9 +73,6 @@ class c_standard_paths extends c_base_return { protected const HANDLER_USER_LOCK = 'c_standard_path_user_lock'; protected const HANDLER_USER_LOGIN = 'c_standard_path_user_login'; protected const HANDLER_USER_LOGOUT = 'c_standard_path_user_logout'; - protected const HANDLER_USER_PDF = 'c_standard_path_user_pdf'; - protected const HANDLER_USER_PRINT = 'c_standard_path_user_print'; - protected const HANDLER_USER_PS = 'c_standard_path_user_ps'; protected const HANDLER_USER_REFRESH = 'c_standard_path_user_refresh'; protected const HANDLER_USER_SESSION = 'c_standard_path_user_session'; protected const HANDLER_USER_SETTINGS = 'c_standard_path_user_settings'; @@ -683,37 +674,49 @@ class c_standard_paths extends c_base_return { $this->paths->add_path(static::URI_USER_DASHBOARD, static::HANDLER_USER_DASHBOARD, static::PATH_USER, static::NAME_USER_DASHBOARD); $this->paths->add_path(static::URI_USER_DASHBOARD . static::WILDCARD_PATH, static::HANDLER_USER_DASHBOARD, static::PATH_USER, static::NAME_USER_DASHBOARD); + // pages / forms $this->paths->add_path(static::URI_USER_CREATE, static::HANDLER_USER_CREATE, static::PATH_USER, static::NAME_USER_CREATE); $this->paths->add_path(static::URI_USER_CREATE . static::WILDCARD_PATH, static::HANDLER_USER_CREATE, static::PATH_USER, static::NAME_USER_CREATE); + $this->paths->add_path(static::URI_USER_CREATE . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_CREATE, static::PATH_USER, static::NAME_USER_CREATE); + $this->paths->add_path(static::URI_USER_DELETE, static::HANDLER_USER_DELETE, static::PATH_USER, static::NAME_USER_DELETE); $this->paths->add_path(static::URI_USER_DELETE . static::WILDCARD_PATH, static::HANDLER_USER_DELETE, static::PATH_USER, static::NAME_USER_DELETE); + $this->paths->add_path(static::URI_USER_DELETE . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_DELETE, static::PATH_USER, static::NAME_USER_DELETE); + $this->paths->add_path(static::URI_USER_EDIT, static::HANDLER_USER_EDIT, static::PATH_USER, static::NAME_USER_EDIT); $this->paths->add_path(static::URI_USER_EDIT . static::WILDCARD_PATH, static::HANDLER_USER_EDIT, static::PATH_USER, static::NAME_USER_EDIT); + $this->paths->add_path(static::URI_USER_EDIT . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_EDIT, static::PATH_USER, static::NAME_USER_EDIT); + $this->paths->add_path(static::URI_USER_SETTINGS, static::HANDLER_USER_SETTINGS, static::PATH_USER, static::NAME_USER_SETTINGS); $this->paths->add_path(static::URI_USER_SETTINGS . static::WILDCARD_PATH, static::HANDLER_USER_SETTINGS, static::PATH_USER, static::NAME_USER_SETTINGS); + $this->paths->add_path(static::URI_USER_SETTINGS . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_SETTINGS, static::PATH_USER, static::NAME_USER_SETTINGS); + $this->paths->add_path(static::URI_USER_VIEW, static::HANDLER_USER_VIEW, static::PATH_USER, static::NAME_USER_VIEW); $this->paths->add_path(static::URI_USER_VIEW . static::WILDCARD_PATH, static::HANDLER_USER_VIEW, static::PATH_USER, static::NAME_USER_VIEW); + $this->paths->add_path(static::URI_USER_VIEW . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_VIEW, static::PATH_USER, static::NAME_USER_VIEW); + // actions / triggers $this->paths->add_path(static::URI_USER_CHECK, static::HANDLER_USER_CHECK, static::PATH_USER, static::NAME_USER_CHECK); $this->paths->add_path(static::URI_USER_CHECK . static::WILDCARD_PATH, static::HANDLER_USER_CHECK, static::PATH_USER, static::NAME_USER_CHECK); + $this->paths->add_path(static::URI_USER_CHECK . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_CHECK, static::PATH_USER, static::NAME_USER_CHECK); + $this->paths->add_path(static::URI_USER_LOCK, static::HANDLER_USER_LOCK, static::PATH_USER, static::NAME_USER_LOCK); $this->paths->add_path(static::URI_USER_LOCK . static::WILDCARD_PATH, static::HANDLER_USER_LOCK, static::PATH_USER, static::NAME_USER_LOCK); + $this->paths->add_path(static::URI_USER_LOCK . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_LOCK, static::PATH_USER, static::NAME_USER_LOCK); + $this->paths->add_path(static::URI_USER_REFRESH, static::HANDLER_USER_REFRESH, static::PATH_USER, static::NAME_USER_REFRESH); $this->paths->add_path(static::URI_USER_REFRESH . static::WILDCARD_PATH, static::HANDLER_USER_REFRESH, static::PATH_USER, static::NAME_USER_REFRESH); + $this->paths->add_path(static::URI_USER_REFRESH . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_REFRESH, static::PATH_USER, static::NAME_USER_REFRESH); + $this->paths->add_path(static::URI_USER_SESSION, static::HANDLER_USER_SESSION, static::PATH_USER, static::NAME_USER_SESSION); $this->paths->add_path(static::URI_USER_SESSION . static::WILDCARD_PATH, static::HANDLER_USER_SESSION, static::PATH_USER, static::NAME_USER_SESSION); + $this->paths->add_path(static::URI_USER_SESSION . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_SESSION, static::PATH_USER, static::NAME_USER_SESSION); + $this->paths->add_path(static::URI_USER_UNLOCK, static::HANDLER_USER_UNLOCK, static::PATH_USER, static::NAME_USER_UNLOCK); $this->paths->add_path(static::URI_USER_UNLOCK . static::WILDCARD_PATH, static::HANDLER_USER_UNLOCK, static::PATH_USER, static::NAME_USER_UNLOCK); - - // presentation / formats - $this->paths->add_path(static::URI_USER_PDF, static::HANDLER_USER_PDF, static::PATH_USER, static::NAME_USER_PDF); - $this->paths->add_path(static::URI_USER_PDF . static::WILDCARD_PATH, static::HANDLER_USER_PDF, static::PATH_USER, static::NAME_USER_PDF); - $this->paths->add_path(static::URI_USER_PRINT, static::HANDLER_USER_PRINT, static::PATH_USER, static::NAME_USER_PRINT); - $this->paths->add_path(static::URI_USER_PRINT . static::WILDCARD_PATH, static::HANDLER_USER_PRINT, static::PATH_USER, static::NAME_USER_PRINT); - $this->paths->add_path(static::URI_USER_PS, static::HANDLER_USER_PS, static::PATH_USER, static::NAME_USER_PS); - $this->paths->add_path(static::URI_USER_PS . static::WILDCARD_PATH, static::HANDLER_USER_PS, static::PATH_USER, static::NAME_USER_PS); + $this->paths->add_path(static::URI_USER_UNLOCK . static::WILDCARD_PATH . static::WILDCARD_PATH, static::HANDLER_USER_UNLOCK, static::PATH_USER, static::NAME_USER_UNLOCK); } /** diff --git a/common/standard/classes/standard_users.php b/common/standard/classes/standard_users.php index de854f4..39aea64 100644 --- a/common/standard/classes/standard_users.php +++ b/common/standard/classes/standard_users.php @@ -279,6 +279,9 @@ class c_standard_users_user extends c_base_users_user { $this->settings = array(); } } + else { + return new c_base_return_false(); + } unset($columns); return new c_base_return_true(); diff --git a/common/standard/menus/menu_content_user_view.php b/common/standard/menus/menu_content_user_view.php index b2997a7..43cd847 100644 --- a/common/standard/menus/menu_content_user_view.php +++ b/common/standard/menus/menu_content_user_view.php @@ -26,7 +26,7 @@ class c_standard_menu_content_user_view extends c_standard_menu_content { protected const CLASS_USER_VIEW = 'user-view'; /** - * Implements do_prepare(). + * Implements do_build(). */ public function do_build(&$http, &$database, &$session, $settings, $items = NULL) { $result = parent::do_build($http, $database, $session, $settings); diff --git a/common/standard/paths/u/ja/user_pdf.php b/common/standard/paths/u/ja/user_pdf.php deleted file mode 100644 index b5becad..0000000 --- a/common/standard/paths/u/ja/user_pdf.php +++ /dev/null @@ -1,32 +0,0 @@ -pr_process_replacements($string, $arguments); - } - - return $string; - } -} diff --git a/common/standard/paths/u/ja/user_print.php b/common/standard/paths/u/ja/user_print.php deleted file mode 100644 index 03428e0..0000000 --- a/common/standard/paths/u/ja/user_print.php +++ /dev/null @@ -1,32 +0,0 @@ -pr_process_replacements($string, $arguments); - } - - return $string; - } -} diff --git a/common/standard/paths/u/ja/user_ps.php b/common/standard/paths/u/ja/user_ps.php deleted file mode 100644 index d626e1d..0000000 --- a/common/standard/paths/u/ja/user_ps.php +++ /dev/null @@ -1,32 +0,0 @@ -pr_process_replacements($string, $arguments); - } - - return $string; - } -} diff --git a/common/standard/paths/u/user_check.php b/common/standard/paths/u/user_check.php index 25e0d1e..1936783 100644 --- a/common/standard/paths/u/user_check.php +++ b/common/standard/paths/u/user_check.php @@ -38,123 +38,28 @@ class c_standard_path_user_check extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); - - $wrapper = $this->pr_create_tag_section(array(1 => 0)); - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); - - $this->pr_add_menus(); + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); - $executed->set_output($this->html); - unset($this->html); + // @todo: this function is currently disabled, so return a path not found. + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); return $executed; } diff --git a/common/standard/paths/u/user_create.php b/common/standard/paths/u/user_create.php index 742b939..0852d9b 100644 --- a/common/standard/paths/u/user_create.php +++ b/common/standard/paths/u/user_create.php @@ -34,111 +34,23 @@ class c_standard_path_user_create extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); + + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); $wrapper = $this->pr_create_tag_section(array(1 => 0)); diff --git a/common/standard/paths/u/user_dashboard.php b/common/standard/paths/u/user_dashboard.php index c3f0bed..ec71568 100644 --- a/common/standard/paths/u/user_dashboard.php +++ b/common/standard/paths/u/user_dashboard.php @@ -53,111 +53,23 @@ class c_standard_path_user_dashboard extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); + + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); diff --git a/common/standard/paths/u/user_delete.php b/common/standard/paths/u/user_delete.php index a9bf731..6c561b8 100644 --- a/common/standard/paths/u/user_delete.php +++ b/common/standard/paths/u/user_delete.php @@ -35,113 +35,23 @@ class c_standard_path_user_delete extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); - $wrapper = $this->pr_create_tag_section(array(1 => 0)); + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); // initialize the content as HTML. $this->pr_create_html(); diff --git a/common/standard/paths/u/user_edit.php b/common/standard/paths/u/user_edit.php index 3ee9c3b..0955f28 100644 --- a/common/standard/paths/u/user_edit.php +++ b/common/standard/paths/u/user_edit.php @@ -70,111 +70,23 @@ class c_standard_path_user_edit extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); + + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); $wrapper = $this->pr_create_tag_section(array(1 => 0)); diff --git a/common/standard/paths/u/user_lock.php b/common/standard/paths/u/user_lock.php index e0d8571..d0b5095 100644 --- a/common/standard/paths/u/user_lock.php +++ b/common/standard/paths/u/user_lock.php @@ -35,123 +35,28 @@ class c_standard_path_user_lock extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); - - $wrapper = $this->pr_create_tag_section(array(1 => 0)); - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); - - $this->pr_add_menus(); + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); - $executed->set_output($this->html); - unset($this->html); + // @todo: this function is currently disabled, so return a path not found. + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); return $executed; } diff --git a/common/standard/paths/u/user_pdf.php b/common/standard/paths/u/user_pdf.php deleted file mode 100644 index 3fac852..0000000 --- a/common/standard/paths/u/user_pdf.php +++ /dev/null @@ -1,60 +0,0 @@ -pr_create_tag_section(array(1 => 0)); - - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); - - $executed->set_output($this->html); - unset($this->html); - - return $executed; - } - - /** - * Implementation of pr_create_html_add_header_link_canonical(). - */ - protected function pr_create_html_add_header_link_canonical() { - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); - $this->html->set_header($tag); - - unset($tag); - } -} diff --git a/common/standard/paths/u/user_print.php b/common/standard/paths/u/user_print.php deleted file mode 100644 index ff38f6d..0000000 --- a/common/standard/paths/u/user_print.php +++ /dev/null @@ -1,60 +0,0 @@ -pr_create_tag_section(array(1 => 0)); - - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); - - $executed->set_output($this->html); - unset($this->html); - - return $executed; - } - - /** - * Implementation of pr_create_html_add_header_link_canonical(). - */ - protected function pr_create_html_add_header_link_canonical() { - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); - $this->html->set_header($tag); - - unset($tag); - } -} diff --git a/common/standard/paths/u/user_ps.php b/common/standard/paths/u/user_ps.php deleted file mode 100644 index 5602670..0000000 --- a/common/standard/paths/u/user_ps.php +++ /dev/null @@ -1,60 +0,0 @@ -pr_create_tag_section(array(1 => 0)); - - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); - - $executed->set_output($this->html); - unset($this->html); - - return $executed; - } - - /** - * Implementation of pr_create_html_add_header_link_canonical(). - */ - protected function pr_create_html_add_header_link_canonical() { - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); - $this->html->set_header($tag); - - unset($tag); - } -} diff --git a/common/standard/paths/u/user_refresh.php b/common/standard/paths/u/user_refresh.php index e117965..d2d9d33 100644 --- a/common/standard/paths/u/user_refresh.php +++ b/common/standard/paths/u/user_refresh.php @@ -38,123 +38,28 @@ class c_standard_path_user_refresh extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); - - $wrapper = $this->pr_create_tag_section(array(1 => 0)); - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); - - $this->pr_add_menus(); + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); - $executed->set_output($this->html); - unset($this->html); + // @todo: this function is currently disabled, so return a path not found. + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); return $executed; } diff --git a/common/standard/paths/u/user_session.php b/common/standard/paths/u/user_session.php index 0d79af9..7a0760b 100644 --- a/common/standard/paths/u/user_session.php +++ b/common/standard/paths/u/user_session.php @@ -35,114 +35,28 @@ class c_standard_path_user_session extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); - // @todo: json responses are expected to be returned for ajax purposes. - // this will very likely support u/session/(ajax_action_name) such as u/session/ping for keeping the session and therefore session cookie alive. + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); + + // @todo: this function is currently disabled, so return a path not found. + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); return $executed; } diff --git a/common/standard/paths/u/user_settings.php b/common/standard/paths/u/user_settings.php index 9c233a0..96e7db9 100644 --- a/common/standard/paths/u/user_settings.php +++ b/common/standard/paths/u/user_settings.php @@ -40,113 +40,25 @@ class c_standard_path_user_settings extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); - $this->p_do_execute_settings($executed, $user); + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); + + $this->pr_do_execute_settings($executed); unset($user); return $executed; @@ -411,25 +323,22 @@ class c_standard_path_user_settings extends c_standard_path_user { * * @param c_base_path_executed &$executed * The execution results to be returned. - * @param c_base_users_user $user_id - * An object representing the user to view. * * @return null|array * NULL is returned if no errors are found. * An array of errors are returned if found. */ - protected function p_do_execute_settings(&$executed, $user) { + protected function pr_do_execute_settings(&$executed) { $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(); + $arguments[':{user_name}'] = $this->path_user->get_name_human()->get_first()->get_value_exact() . ' ' . $this->path_user->get_name_human()->get_last()->get_value_exact(); if (mb_strlen($arguments[':{user_name}']) == 0) { unset($arguments[':{user_name}']); } - $id_user = $user->get_id()->get_value(); - if (is_int($id_user)) { - $text_id_user = $this->pr_create_tag_text('[id: ' . $id_user . ']', array(), NULL, static::CLASS_ID_USER); + if (is_int($this->path_user_id)) { + $text_id_user = $this->pr_create_tag_text('[id: ' . $this->path_user_id . ']', array(), NULL, static::CLASS_ID_USER); $wrapper = $this->pr_create_tag_section(array(1 => array('text' => 0, 'append-inside' => $text_id_user)), $arguments); unset($text_id_user); } @@ -438,10 +347,10 @@ class c_standard_path_user_settings extends c_standard_path_user { } $roles_current = $this->session->get_user_current()->get_roles()->get_value_exact(); - $roles = $user->get_roles()->get_value_exact(); + $roles = $this->path_user->get_roles()->get_value_exact(); $full_view_access = FALSE; - if ($id_user === $this->session->get_user_current()->get_id()->get_value_exact()) { + if ($this->path_user_id === $this->session->get_user_current()->get_id()->get_value_exact()) { $full_view_access = TRUE; } elseif (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) { @@ -460,23 +369,23 @@ class c_standard_path_user_settings extends c_standard_path_user { $fieldset = $this->pr_create_tag_fieldset(14, array(), static::CLASS_USER_SETTINGS_ACCOUNT, static::CLASS_USER_SETTINGS_ACCOUNT); $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, static::CSS_AS_FIELD_SET_CONTENT, array(static::CSS_AS_FIELD_SET_CONTENT)); - $content->set_tag($this->pr_create_tag_field_row(18, '' . $id_user, array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(18, '' . $this->path_user_id, array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); - if ($full_view_access || !$user->get_address_email()->is_private()->get_value()) { + if ($full_view_access || !$this->path_user->get_address_email()->is_private()->get_value()) { $count = 1; if ($full_view_access) { - $content->set_tag($this->pr_create_tag_field_row(19, '' . $user->get_id_external()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(19, '' . $this->path_user->get_id_external()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); $count++; } - $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(20, '' . $this->path_user->get_name_machine()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); $count++; - $content->set_tag($this->pr_create_tag_field_row(21, '' . $user->get_address_email()->get_address()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(21, '' . $this->path_user->get_address_email()->get_address()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); $count++; - if ($user->is_locked()->get_value_exact()) { + if ($this->path_user->is_locked()->get_value_exact()) { $tag_text = $this->pr_get_text(33); } else { @@ -485,7 +394,7 @@ class c_standard_path_user_settings extends c_standard_path_user { $content->set_tag($this->pr_create_tag_field_row(24, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); $count++; - if ($user->is_private()->get_value_exact()) { + if ($this->path_user->is_private()->get_value_exact()) { $tag_text = $this->pr_get_text(33); } else { @@ -494,7 +403,7 @@ class c_standard_path_user_settings extends c_standard_path_user { $content->set_tag($this->pr_create_tag_field_row(27, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); $count++; - if ($user->is_roler()->get_value_exact()) { + if ($this->path_user->is_roler()->get_value_exact()) { $tag_text = $this->pr_get_text(33); } else { @@ -504,7 +413,7 @@ class c_standard_path_user_settings extends c_standard_path_user { $count++; if (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) { - if ($user->is_deleted()->get_value_exact()) { + if ($this->path_user->is_deleted()->get_value_exact()) { $tag_text = $this->pr_get_text(33); } else { @@ -519,8 +428,8 @@ class c_standard_path_user_settings extends c_standard_path_user { // date created $date = NULL; - if (!is_null($user->get_date_created()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_created()->get_value())->get_value_exact(); + if (!is_null($this->path_user->get_date_created()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $this->path_user->get_date_created()->get_value())->get_value_exact(); } $content->set_tag($this->pr_create_tag_field_row(28, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); @@ -529,8 +438,8 @@ class c_standard_path_user_settings extends c_standard_path_user { // date changed $date = NULL; - if (!is_null($user->get_date_changed()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_changed()->get_value())->get_value_exact(); + if (!is_null($this->path_user->get_date_changed()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $this->path_user->get_date_changed()->get_value())->get_value_exact(); } $content->set_tag($this->pr_create_tag_field_row(29, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); @@ -539,8 +448,8 @@ class c_standard_path_user_settings extends c_standard_path_user { // date synced $date = NULL; - if (!is_null($user->get_date_synced()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_synced()->get_value())->get_value_exact(); + if (!is_null($this->path_user->get_date_synced()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $this->path_user->get_date_synced()->get_value())->get_value_exact(); } $content->set_tag($this->pr_create_tag_field_row(30, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); @@ -549,8 +458,8 @@ class c_standard_path_user_settings extends c_standard_path_user { // date locked $date = NULL; - if (!is_null($user->get_date_locked()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_locked()->get_value())->get_value_exact(); + if (!is_null($this->path_user->get_date_locked()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $this->path_user->get_date_locked()->get_value())->get_value_exact(); } $content->set_tag($this->pr_create_tag_field_row(31, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); @@ -559,8 +468,8 @@ class c_standard_path_user_settings extends c_standard_path_user { // date deleted $date = NULL; - if (!is_null($user->get_date_deleted()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_deleted()->get_value())->get_value_exact(); + if (!is_null($this->path_user->get_date_deleted()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $this->path_user->get_date_deleted()->get_value())->get_value_exact(); } $content->set_tag($this->pr_create_tag_field_row(32, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); @@ -571,7 +480,7 @@ class c_standard_path_user_settings extends c_standard_path_user { unset($date); } else { - $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(20, '' . $this->path_user->get_name_machine()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); $content->set_tag($this->pr_create_tag_field_row(21, $this->pr_get_text(43), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE)); } @@ -580,20 +489,19 @@ class c_standard_path_user_settings extends c_standard_path_user { $this->html->set_tag($fieldset); unset($fieldset); - unset($id_user); - if ($full_view_access || !$user->is_private()->get_value()) { + if ($full_view_access || !$this->path_user->is_private()->get_value()) { // personal information $fieldset = $this->pr_create_tag_fieldset(15, array(), static::CLASS_USER_SETTINGS_PERSONAL, static::CLASS_USER_SETTINGS_PERSONAL); $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, static::CSS_AS_FIELD_SET_CONTENT, array(static::CSS_AS_FIELD_SET_CONTENT)); - $content->set_tag($this->pr_create_tag_field_row(37, '' . $user->get_name_human()->get_prefix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(38, '' . $user->get_name_human()->get_first()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(39, '' . $user->get_name_human()->get_middle()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(40, '' . $user->get_name_human()->get_last()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 3, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(41, '' . $user->get_name_human()->get_suffix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 4, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(42, '' . $user->get_name_human()->get_complete()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 5, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(37, '' . $this->path_user->get_name_human()->get_prefix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(38, '' . $this->path_user->get_name_human()->get_first()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(39, '' . $this->path_user->get_name_human()->get_middle()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(40, '' . $this->path_user->get_name_human()->get_last()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 3, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(41, '' . $this->path_user->get_name_human()->get_suffix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 4, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(42, '' . $this->path_user->get_name_human()->get_complete()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 5, TRUE)); $fieldset->set_tag($content); unset($content); diff --git a/common/standard/paths/u/user_unlock.php b/common/standard/paths/u/user_unlock.php index 29d6d28..56c9d9f 100644 --- a/common/standard/paths/u/user_unlock.php +++ b/common/standard/paths/u/user_unlock.php @@ -35,123 +35,28 @@ class c_standard_path_user_unlock extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); - - $wrapper = $this->pr_create_tag_section(array(1 => 1000)); - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); - - $this->pr_add_menus(); + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); - $executed->set_output($this->html); - unset($this->html); + // @todo: this function is currently disabled, so return a path not found. + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + $executed->set_error($error); + unset($error); return $executed; } diff --git a/common/standard/paths/u/user_view.php b/common/standard/paths/u/user_view.php index b8b9777..a17dea8 100644 --- a/common/standard/paths/u/user_view.php +++ b/common/standard/paths/u/user_view.php @@ -35,111 +35,23 @@ class c_standard_path_user_view extends c_standard_path_user { return $executed; } - // @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(). - $user = $this->session->get_user_current(); - $roles_current = $user->get_roles()->get_value_exact(); - - $id_user = NULL; - $arguments = $this->pr_get_path_arguments(static::PATH_SELF); - if (!empty($arguments)) { - $arguments_total = count($arguments); - $argument = reset($arguments); - - if (is_numeric($argument)) { - $id_user = (int) $argument; - - // do not allow view access to reserved/special accounts. - if ($id_user < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - - // @todo: check to see if user id is valid and accessible. - // If the current viewer cannot access the user, then deny access to this page as appropriate. - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - - if ($arguments_total > 1) { - $argument = next($arguments); - - if ($argument == 'print') { - // @todo: execute custom print function and then return. - $id_user = NULL; - } - #elseif ($argument == 'pdf') { - # // @todo: execute custom pdf function and then return. - # $id_user = NULL; - #} - #elseif ($argument == 'ps') { - # // @todo: execute custom postscript function and then return. - # $id_user = NULL; - #} - else { - $id_user = FALSE; - } - } - unset($arguments_total); - unset($argument); - - if ($id_user === FALSE) { - unset($user); - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - unset($error); - unset($arguments); - - return $executed; - } - } - - $user = NULL; - if (is_null($id_user)) { - $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 < static::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - $user = new c_standard_users_user(); - - // @todo: handle database errors. - $loaded = $user->do_load($this->database, $id_user); - if ($loaded instanceof c_base_return_false) { - $id_user = FALSE; - } - unset($loaded); + if (!$this->pr_process_arguments($executed)) { + return $executed; } - if ($id_user === FALSE) { - unset($id_user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); + // only support HTML output unless otherwise needed. + // @todo: eventually all HTML output will be expected to support at least print and PDF formats (with print being the string 'print'). + if ($this->output_format !== c_base_mime::TYPE_TEXT_HTML) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => static::PATH_SELF . '/' . implode('/', $this->arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); $executed->set_error($error); - unset($error); return $executed; } - unset($arguments); - unset($id_user); + + // @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(). + #$user = $this->session->get_user_current(); + #$roles_current = $user->get_roles()->get_value_exact(); $wrapper = $this->pr_create_tag_section(array(1 => 0));