From 4c8610828ddd5a11be3a193372ffec28fb971a9c Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 2 Sep 2017 22:38:27 -0500 Subject: [PATCH] Progress: work on user pages This makes the PATH_SELF constant for c_standard_path public. Add new user session handling class. Add a generic user-specific version of the c_standard_path and have most user path classes extend it. Populate a basic version of the content menu for user paths. User paths should accept user ids, handle the arguments. The print, pdf, and ps paths are also in the url arguments as well as in a separate class path (I need to review the possibilities and pick only 1 method). Just about all of the user paths, in their current form, are stubs and need to be implemented. --- common/base/classes/base_path.php | 4 +- common/standard/classes/standard_path.php | 9 +- common/standard/classes/standard_path_user.php | 31 ++++ common/standard/classes/standard_paths.php | 32 ++-- .../standard/menus/ja/menu_content_user_view.php | 63 ++++++++ common/standard/menus/menu_content_user_view.php | 162 ++++++++++++++++++++ common/standard/menus/menu_utility.php | 2 +- common/standard/paths/a/dashboard.php | 4 +- common/standard/paths/m/dashboard.php | 4 +- common/standard/paths/u/ja/user_check.php | 4 + common/standard/paths/u/ja/user_create.php | 4 + common/standard/paths/u/ja/user_delete.php | 3 + common/standard/paths/u/ja/user_edit.php | 4 + common/standard/paths/u/ja/user_lock.php | 3 + common/standard/paths/u/ja/user_pdf.php | 3 + common/standard/paths/u/ja/user_print.php | 3 + common/standard/paths/u/ja/user_ps.php | 3 + common/standard/paths/u/ja/user_refresh.php | 4 + common/standard/paths/u/ja/user_session.php | 18 +++ common/standard/paths/u/ja/user_settings.php | 3 + common/standard/paths/u/ja/user_unlock.php | 3 + common/standard/paths/u/ja/user_view.php | 3 + common/standard/paths/u/user_check.php | 142 ++++++++++++++++-- common/standard/paths/u/user_create.php | 143 ++++++++++++++++-- common/standard/paths/u/user_dashboard.php | 122 +++++++++++++-- common/standard/paths/u/user_delete.php | 142 ++++++++++++++++-- common/standard/paths/u/user_edit.php | 145 ++++++++++++++++-- common/standard/paths/u/user_lock.php | 142 ++++++++++++++++-- common/standard/paths/u/user_login.php | 6 +- common/standard/paths/u/user_logout.php | 2 +- common/standard/paths/u/user_pdf.php | 36 +---- common/standard/paths/u/user_print.php | 36 +---- common/standard/paths/u/user_ps.php | 36 +---- common/standard/paths/u/user_refresh.php | 142 ++++++++++++++++-- common/standard/paths/u/user_session.php | 163 ++++++++++++++++++++ common/standard/paths/u/user_settings.php | 43 +++--- common/standard/paths/u/user_unlock.php | 144 ++++++++++++++++-- common/standard/paths/u/user_view.php | 165 ++++++++++++++++++++- database/sql/standard/standard-users.sql | 30 ++-- 39 files changed, 1737 insertions(+), 271 deletions(-) create mode 100644 common/standard/classes/standard_path_user.php create mode 100644 common/standard/menus/ja/menu_content_user_view.php create mode 100644 common/standard/menus/menu_content_user_view.php create mode 100644 common/standard/paths/u/ja/user_session.php create mode 100644 common/standard/paths/u/user_session.php diff --git a/common/base/classes/base_path.php b/common/base/classes/base_path.php index fc0bacf..da4d864 100644 --- a/common/base/classes/base_path.php +++ b/common/base/classes/base_path.php @@ -1217,7 +1217,7 @@ class c_base_path extends c_base_rfc_string { * * 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. + * Calling this will trigger default settings to be regenerated, including the breadcrumbs. * * @param c_base_http &$http * The entire HTTP information to allow for the execution to access anything that is necessary. @@ -1234,7 +1234,7 @@ class c_base_path extends c_base_rfc_string { * * @see: self::do_execute() */ - protected function set_parameters(&$http, &$database, &$session, $settings) { + public 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); diff --git a/common/standard/classes/standard_path.php b/common/standard/classes/standard_path.php index 20856c6..583e19d 100644 --- a/common/standard/classes/standard_path.php +++ b/common/standard/classes/standard_path.php @@ -14,6 +14,8 @@ require_once('common/base/classes/base_markup.php'); * This is used primarily for generating HTML5 pages. */ class c_standard_path extends c_base_path { + public const PATH_SELF = ''; + protected const CSS_AS_SECTION = 'as-section'; protected const CSS_AS_SECTION_HEADERS = 'as-section-headers'; protected const CSS_AS_WRAPPER = 'as-wrapper'; @@ -69,8 +71,6 @@ class c_standard_path extends c_base_path { protected const CSS_PATH_PART = 'path-part-'; protected const CSS_PATH_FULL = 'path-full-'; - protected const PATH_SELF = ''; - protected const PATH_MENU_HEADER = 'common/standard/menus/'; protected const PATH_MENU_UTILITY = 'common/standard/menus/'; protected const PATH_MENU_BREADCRUMBS = 'common/standard/menus/'; @@ -163,7 +163,7 @@ class c_standard_path extends c_base_path { /** * Implements set_parameters(). */ - protected function set_parameters(&$http, &$database, &$session, $settings) { + public 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; @@ -1976,6 +1976,9 @@ class c_standard_path extends c_base_path { * A number representing which block of text to return. * @param array $arguments * (optional) An array of arguments to convert into text. + * + * @return string + * A string is returned as the custom text. */ protected function pr_get_text($code, $arguments = array()) { return ''; diff --git a/common/standard/classes/standard_path_user.php b/common/standard/classes/standard_path_user.php new file mode 100644 index 0000000..4223616 --- /dev/null +++ b/common/standard/classes/standard_path_user.php @@ -0,0 +1,31 @@ +pr_get_text(0, $arguments); + } +} diff --git a/common/standard/classes/standard_paths.php b/common/standard/classes/standard_paths.php index c5b57df..e7ee9d3 100644 --- a/common/standard/classes/standard_paths.php +++ b/common/standard/classes/standard_paths.php @@ -28,6 +28,7 @@ class c_standard_paths extends c_base_return { 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'; const URI_USER_UNLOCK = 'u/unlock'; const URI_USER_VIEW = 'u/view'; @@ -57,6 +58,7 @@ class c_standard_paths extends c_base_return { 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'; protected const NAME_USER_UNLOCK = 'user_unlock'; protected const NAME_USER_VIEW = 'user_view'; @@ -81,6 +83,7 @@ class c_standard_paths extends c_base_return { 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'; protected const HANDLER_USER_UNLOCK = 'c_standard_path_user_unlock'; protected const HANDLER_USER_VIEW = 'c_standard_path_user_view'; @@ -678,32 +681,39 @@ class c_standard_paths extends c_base_return { protected function pr_paths_create_user() { // dashboards $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); - // user paths - $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); + // 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_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_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_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_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); + + // 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_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_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_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_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_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_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_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); - $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); } /** diff --git a/common/standard/menus/ja/menu_content_user_view.php b/common/standard/menus/ja/menu_content_user_view.php new file mode 100644 index 0000000..dcd4da6 --- /dev/null +++ b/common/standard/menus/ja/menu_content_user_view.php @@ -0,0 +1,63 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/menu_content_user_view.php b/common/standard/menus/menu_content_user_view.php new file mode 100644 index 0000000..b2997a7 --- /dev/null +++ b/common/standard/menus/menu_content_user_view.php @@ -0,0 +1,162 @@ +is_logged_in() instanceof c_base_return_false) { + return new c_base_return_false(); + } + + // @todo: this path should either have no trailing id if current user is viewing their own profile or it should have the user id appended for all urls below. + $path_id_user = ''; + + $menu = $this->pr_create_html_create_menu($settings['base_css'] . static::CLASS_NAME, $this->pr_get_text(0)); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(1), $settings['base_path'] . c_standard_paths::URI_USER_VIEW . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_VIEW); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(2), $settings['base_path'] . c_standard_paths::URI_USER_DASHBOARD . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_DASHBOARD); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(3), $settings['base_path'] . c_standard_paths::URI_USER_SETTINGS . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_SETTINGS); + $menu->set_tag($item); + unset($item); + + // @todo: add access check to this menu item and only make it appear to authorized users. + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(4), $settings['base_path'] . c_standard_paths::URI_USER_EDIT . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_EDIT); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(5), $settings['base_path'] . c_standard_paths::URI_USER_CHECK . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_CHECK); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(6), $settings['base_path'] . c_standard_paths::URI_USER_REFRESH . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_REFRESH); + $menu->set_tag($item); + unset($item); + + $roles = $session->get_user_current()->get_roles()->get_value_exact(); + if (array_key_exists(c_base_roles::MANAGER, $roles) || array_key_exists(c_base_roles::ADMINISTER, $roles)) { + // @todo: only show lock user if account is unlocked. + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(7), $settings['base_path'] . c_standard_paths::URI_USER_LOCK . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_LOCK); + $menu->set_tag($item); + unset($item); + + // @todo: only show unlock user if account is locked. + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(8), $settings['base_path'] . c_standard_paths::URI_USER_UNLOCK . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_UNLOCK); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(9), $settings['base_path'] . c_standard_paths::URI_USER_DELETE . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_DELETE); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(10), $settings['base_path'] . c_standard_paths::URI_USER_COPY . $path_id_user); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_COPY); + $menu->set_tag($item); + unset($item); + + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(11), $settings['base_path'] . c_standard_paths::URI_USER_CREATE); + $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, static::CLASS_USER_CREATE); + $menu->set_tag($item); + unset($item); + } + unset($roles); + + return $menu; + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'User Menu'; + break; + case 1: + $string = 'Profile'; + break; + case 2: + $string = 'Dashboard'; + break; + case 3: + $string = 'Settings'; + break; + case 4: + $string = 'Edit'; + break; + case 5: + $string = 'Check'; + break; + case 6: + $string = 'Refresh'; + break; + case 7: + $string = 'Lock'; + break; + case 8: + $string = 'Unlock'; + break; + case 9: + $string = 'Delete'; + break; + case 10: + $string = 'Copy'; // @todo: implement this in the project. + break; + case 11: + $string = 'Create New User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/menus/menu_utility.php b/common/standard/menus/menu_utility.php index 836f1ed..0bc4f8e 100644 --- a/common/standard/menus/menu_utility.php +++ b/common/standard/menus/menu_utility.php @@ -111,7 +111,7 @@ class c_standard_menu_utility extends c_standard_menu { $string = 'Administration'; break; case 6: - $string = 'Settings'; + $string = 'Profile'; break; case 7: $string = 'Logout'; diff --git a/common/standard/paths/a/dashboard.php b/common/standard/paths/a/dashboard.php index 7d28ced..a84f491 100644 --- a/common/standard/paths/a/dashboard.php +++ b/common/standard/paths/a/dashboard.php @@ -13,7 +13,7 @@ require_once('common/standard/classes/standard_path.php'); require_once('common/theme/classes/theme_html.php'); class c_standard_path_administer_dashboard extends c_standard_path { - protected const PATH_SELF = 'a/dashboard'; + public const PATH_SELF = 'a/dashboard'; /** * Implements do_execute(). @@ -46,7 +46,7 @@ class c_standard_path_administer_dashboard extends c_standard_path { 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'] . static::PATH_SELF); + $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/m/dashboard.php b/common/standard/paths/m/dashboard.php index cdd0d5f..e3cb862 100644 --- a/common/standard/paths/m/dashboard.php +++ b/common/standard/paths/m/dashboard.php @@ -13,7 +13,7 @@ require_once('common/standard/classes/standard_path.php'); require_once('common/theme/classes/theme_html.php'); class c_standard_path_management_dashboard extends c_standard_path { - protected const PATH_SELF = 'm/dashboard'; + public const PATH_SELF = 'm/dashboard'; /** * Implements do_execute(). @@ -46,7 +46,7 @@ class c_standard_path_management_dashboard extends c_standard_path { 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'] . static::PATH_SELF); + $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/ja/user_check.php b/common/standard/paths/u/ja/user_check.php index b2f5483..d3d6643 100644 --- a/common/standard/paths/u/ja/user_check.php +++ b/common/standard/paths/u/ja/user_check.php @@ -15,6 +15,7 @@ class c_standard_path_user_check_ja extends c_standard_path_user_check { protected function pr_get_text($code, $arguments = array()) { $string = ''; switch ($code) { + case 0: if (array_key_exists(':{user_name}', $arguments)) { $string = '照合:{user_name}'; } @@ -22,6 +23,9 @@ class c_standard_path_user_check_ja extends c_standard_path_user_check { $string = '照合'; } break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_create.php b/common/standard/paths/u/ja/user_create.php index 6012cd2..ccab400 100644 --- a/common/standard/paths/u/ja/user_create.php +++ b/common/standard/paths/u/ja/user_create.php @@ -15,6 +15,7 @@ class c_standard_path_user_create_ja extends c_standard_path_user_create { protected function pr_get_text($code, $arguments = array()) { $string = ''; switch ($code) { + case 0: if (array_key_exists(':{user_name}', $arguments)) { $string = 'ユーザーをコピー:{user_name}'; } @@ -22,6 +23,9 @@ class c_standard_path_user_create_ja extends c_standard_path_user_create { $string = 'ユーザーを作成する'; } break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_delete.php b/common/standard/paths/u/ja/user_delete.php index 01b6023..15c135f 100644 --- a/common/standard/paths/u/ja/user_delete.php +++ b/common/standard/paths/u/ja/user_delete.php @@ -23,6 +23,9 @@ class c_standard_path_user_delete_ja extends c_standard_path_user_delete { $string = 'ユーザーを削除する'; } break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_edit.php b/common/standard/paths/u/ja/user_edit.php index a8edae3..0866841 100644 --- a/common/standard/paths/u/ja/user_edit.php +++ b/common/standard/paths/u/ja/user_edit.php @@ -15,6 +15,7 @@ class c_standard_path_user_edit_ja extends c_standard_path_user_edit { protected function pr_get_text($code, $arguments = array()) { $string = ''; switch ($code) { + case 0: if (array_key_exists(':{user_name}', $arguments)) { $string = 'ユーザーを編集:{user_name}'; } @@ -22,6 +23,9 @@ class c_standard_path_user_edit_ja extends c_standard_path_user_edit { $string = 'ユーザーを編集する'; } break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_lock.php b/common/standard/paths/u/ja/user_lock.php index 77b552b..a8a36f5 100644 --- a/common/standard/paths/u/ja/user_lock.php +++ b/common/standard/paths/u/ja/user_lock.php @@ -23,6 +23,9 @@ class c_standard_path_user_lock_ja extends c_standard_path_user_lock { $string = 'ユーザーをロックする'; } break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_pdf.php b/common/standard/paths/u/ja/user_pdf.php index 49866f3..b5becad 100644 --- a/common/standard/paths/u/ja/user_pdf.php +++ b/common/standard/paths/u/ja/user_pdf.php @@ -18,6 +18,9 @@ class c_standard_path_user_pdf_ja extends c_standard_path_user_pdf { case 0: $string = ''; break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_print.php b/common/standard/paths/u/ja/user_print.php index 49b5728..03428e0 100644 --- a/common/standard/paths/u/ja/user_print.php +++ b/common/standard/paths/u/ja/user_print.php @@ -18,6 +18,9 @@ class c_standard_path_user_print_ja extends c_standard_path_user_print { case 0: $string = ''; break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_ps.php b/common/standard/paths/u/ja/user_ps.php index cd675c6..d626e1d 100644 --- a/common/standard/paths/u/ja/user_ps.php +++ b/common/standard/paths/u/ja/user_ps.php @@ -18,6 +18,9 @@ class c_standard_path_user_ps_ja extends c_standard_path_user_ps { case 0: $string = ''; break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_refresh.php b/common/standard/paths/u/ja/user_refresh.php index 325c522..e0b7ced 100644 --- a/common/standard/paths/u/ja/user_refresh.php +++ b/common/standard/paths/u/ja/user_refresh.php @@ -15,6 +15,7 @@ class c_standard_path_user_refresh_ja extends c_standard_path_user_refresh { protected function pr_get_text($code, $arguments = array()) { $string = ''; switch ($code) { + case 0: if (array_key_exists(':{user_name}', $arguments)) { $string = '晴らす:{user_name}'; } @@ -22,6 +23,9 @@ class c_standard_path_user_refresh_ja extends c_standard_path_user_refresh { $string = '晴らす'; } break; + default: + unset($string); + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/common/standard/paths/u/ja/user_session.php b/common/standard/paths/u/ja/user_session.php new file mode 100644 index 0000000..c45cfb9 --- /dev/null +++ b/common/standard/paths/u/ja/user_session.php @@ -0,0 +1,18 @@ +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 ($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); + $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. @@ -52,18 +163,26 @@ class c_standard_path_user_check extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $result = parent::pr_build_breadcrumbs(); - if ($result instanceof c_base_return_false) { + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } unset($result); - return new c_base_return_false(); } - unset($result); if (!($this->breadcrumbs instanceof c_base_menu_item)) { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -76,20 +195,13 @@ class c_standard_path_user_check extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_create.php b/common/standard/paths/u/user_create.php index 4ad9db7..742b939 100644 --- a/common/standard/paths/u/user_create.php +++ b/common/standard/paths/u/user_create.php @@ -1,7 +1,7 @@ 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 ($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); + $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. @@ -49,18 +159,26 @@ class c_standard_path_user_create extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $result = parent::pr_build_breadcrumbs(); - if ($result instanceof c_base_return_false) { + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } unset($result); - return new c_base_return_false(); } - unset($result); if (!($this->breadcrumbs instanceof c_base_menu_item)) { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,20 +191,13 @@ class c_standard_path_user_create extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_dashboard.php b/common/standard/paths/u/user_dashboard.php index e6e287f..c3f0bed 100644 --- a/common/standard/paths/u/user_dashboard.php +++ b/common/standard/paths/u/user_dashboard.php @@ -9,6 +9,7 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); require_once('common/theme/classes/theme_html.php'); @@ -17,8 +18,8 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/dashboard */ -class c_standard_path_user_dashboard extends c_standard_path { - protected const PATH_SELF = 'u/dashboard'; +class c_standard_path_user_dashboard extends c_standard_path_user { + public const PATH_SELF = 'u/dashboard'; /** * Implementation of pr_build_breadcrumbs(). @@ -35,7 +36,7 @@ class c_standard_path_user_dashboard extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -52,6 +53,112 @@ class c_standard_path_user_dashboard extends c_standard_path { 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 ($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); + $executed->set_error($error); + + unset($error); + + return $executed; + } + unset($arguments); + unset($id_user); + $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); @@ -136,20 +243,13 @@ class c_standard_path_user_dashboard extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_delete.php b/common/standard/paths/u/user_delete.php index 559e2e7..a9bf731 100644 --- a/common/standard/paths/u/user_delete.php +++ b/common/standard/paths/u/user_delete.php @@ -9,6 +9,8 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); +require_once('common/standard/paths/u/user_view.php'); require_once('common/theme/classes/theme_html.php'); @@ -17,8 +19,11 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/delete */ -class c_standard_path_user_delete extends c_standard_path { - protected const PATH_SELF = 'u/delete'; +class c_standard_path_user_delete extends c_standard_path_user { + public const PATH_SELF = 'u/delete'; + + protected const NAME_MENU_CONTENT = 'menu_content_user_view'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content_user_view'; /** * Implements do_execute(). @@ -30,6 +35,112 @@ class c_standard_path_user_delete extends c_standard_path { 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 ($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); + $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. @@ -49,18 +160,26 @@ class c_standard_path_user_delete extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $result = parent::pr_build_breadcrumbs(); - if ($result instanceof c_base_return_false) { + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } unset($result); - return new c_base_return_false(); } - unset($result); if (!($this->breadcrumbs instanceof c_base_menu_item)) { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,20 +192,13 @@ class c_standard_path_user_delete extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_edit.php b/common/standard/paths/u/user_edit.php index 2bef7ce..3ee9c3b 100644 --- a/common/standard/paths/u/user_edit.php +++ b/common/standard/paths/u/user_edit.php @@ -9,6 +9,8 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); +require_once('common/standard/paths/u/user_view.php'); require_once('common/theme/classes/theme_html.php'); @@ -17,8 +19,11 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/edit */ -class c_standard_path_user_edit extends c_standard_path { - protected const PATH_SELF = 'u/edit'; +class c_standard_path_user_edit extends c_standard_path_user { + public const PATH_SELF = 'u/edit'; + + protected const NAME_MENU_CONTENT = 'menu_content_user_view'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content_user_view'; protected const CLASS_USER_EDIT_ACCOUNT = 'user_settings-account'; protected const CLASS_USER_EDIT_PERSONAL = 'user_settings-personal'; @@ -29,9 +34,26 @@ class c_standard_path_user_edit extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - parent::pr_build_breadcrumbs(); + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(1), static::PATH_SELF); + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -48,7 +70,111 @@ class c_standard_path_user_edit extends c_standard_path { 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(). + $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 ($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); + $executed->set_error($error); + + unset($error); + + return $executed; + } + unset($arguments); + unset($id_user); $wrapper = $this->pr_create_tag_section(array(1 => 0)); @@ -71,20 +197,13 @@ class c_standard_path_user_edit extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_lock.php b/common/standard/paths/u/user_lock.php index 49d7c3b..e0d8571 100644 --- a/common/standard/paths/u/user_lock.php +++ b/common/standard/paths/u/user_lock.php @@ -9,6 +9,8 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); +require_once('common/standard/paths/u/user_view.php'); require_once('common/theme/classes/theme_html.php'); @@ -17,8 +19,11 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/lock */ -class c_standard_path_user_lock extends c_standard_path { - protected const PATH_SELF = 'u/lock'; +class c_standard_path_user_lock extends c_standard_path_user { + public const PATH_SELF = 'u/lock'; + + protected const NAME_MENU_CONTENT = 'menu_content_user_view'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content_user_view'; /** * Implements do_execute(). @@ -30,6 +35,112 @@ class c_standard_path_user_lock extends c_standard_path { 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 ($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); + $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. @@ -49,18 +160,26 @@ class c_standard_path_user_lock extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $result = parent::pr_build_breadcrumbs(); - if ($result instanceof c_base_return_false) { + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } unset($result); - return new c_base_return_false(); } - unset($result); if (!($this->breadcrumbs instanceof c_base_menu_item)) { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,20 +192,13 @@ class c_standard_path_user_lock extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_login.php b/common/standard/paths/u/user_login.php index d8a8a92..ca6603b 100644 --- a/common/standard/paths/u/user_login.php +++ b/common/standard/paths/u/user_login.php @@ -27,8 +27,8 @@ require_once('common/theme/classes/theme_html.php'); */ class c_standard_path_user_login extends c_standard_path { public const SESSION_DATE_FORMAT = 'D, d-M-Y H:i:s T'; + public const PATH_SELF = 'u/login'; - protected const PATH_SELF = 'u/login'; protected const USER_PUBLIC = 'u_standard_public'; /** @@ -299,7 +299,7 @@ class c_standard_path_user_login extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(12), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(12), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -955,7 +955,7 @@ class c_standard_path_user_login extends c_standard_path { * Implements pr_get_text_title(). */ protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); + return self::pr_get_text(0, $arguments); } /** diff --git a/common/standard/paths/u/user_logout.php b/common/standard/paths/u/user_logout.php index 8ab1d4c..4a775a5 100644 --- a/common/standard/paths/u/user_logout.php +++ b/common/standard/paths/u/user_logout.php @@ -67,7 +67,7 @@ class c_standard_path_user_logout extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); diff --git a/common/standard/paths/u/user_pdf.php b/common/standard/paths/u/user_pdf.php index 05bad00..3fac852 100644 --- a/common/standard/paths/u/user_pdf.php +++ b/common/standard/paths/u/user_pdf.php @@ -9,16 +9,19 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); require_once('common/theme/classes/theme_html.php'); /** * Provides a path handler for user in pdf format. * + * @fixme: this should probably be renamed to c_standard_path_user_view_pdf. + * * This listens on: /u/pdf */ -class c_standard_path_user_pdf extends c_standard_path { - protected const PATH_SELF = 'u/pdf'; +class c_standard_path_user_pdf extends c_standard_path_user_view { + public const PATH_SELF = 'u/pdf'; // @fixme: make path 'u/pdf/view'. /** * Implements do_execute(). @@ -30,8 +33,6 @@ class c_standard_path_user_pdf extends c_standard_path { return $executed; } - $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_section(array(1 => 0)); // initialize the content as HTML. @@ -51,34 +52,9 @@ class c_standard_path_user_pdf extends c_standard_path { 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'] . static::PATH_SELF); + $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); } - - /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** - * Implements pr_get_text(). - */ - protected function pr_get_text($code, $arguments = array()) { - $string = ''; - switch ($code) { - case 0: - $string = 'Lock User'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } } diff --git a/common/standard/paths/u/user_print.php b/common/standard/paths/u/user_print.php index 4bea27f..ff38f6d 100644 --- a/common/standard/paths/u/user_print.php +++ b/common/standard/paths/u/user_print.php @@ -9,16 +9,19 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); require_once('common/theme/classes/theme_html.php'); /** * Provides a path handler for user print format (printer-friendly). * + * @fixme: this should probably be renamed to c_standard_path_user_view_print. + * * This listens on: /u/print */ -class c_standard_path_user_print extends c_standard_path { - protected const PATH_SELF = 'u/print'; +class c_standard_path_user_print extends c_standard_path_user_view { + public const PATH_SELF = 'u/print'; // @fixme: make path 'u/print/view'. /** * Implements do_execute(). @@ -30,8 +33,6 @@ class c_standard_path_user_print extends c_standard_path { return $executed; } - $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_section(array(1 => 0)); // initialize the content as HTML. @@ -51,34 +52,9 @@ class c_standard_path_user_print extends c_standard_path { 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'] . static::PATH_SELF); + $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); } - - /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** - * Implements pr_get_text(). - */ - protected function pr_get_text($code, $arguments = array()) { - $string = ''; - switch ($code) { - case 0: - $string = 'Lock User'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } } diff --git a/common/standard/paths/u/user_ps.php b/common/standard/paths/u/user_ps.php index a77cdad..5602670 100644 --- a/common/standard/paths/u/user_ps.php +++ b/common/standard/paths/u/user_ps.php @@ -9,16 +9,19 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); require_once('common/theme/classes/theme_html.php'); /** * Provides a path handler for user postcript (postcript format). * + * @fixme: this should probably be renamed to c_standard_path_user_view_ps. + * * This listens on: /u/ps */ -class c_standard_path_user_ps extends c_standard_path { - protected const PATH_SELF = 'u/ps'; +class c_standard_path_user_ps extends c_standard_path_user_view { + public const PATH_SELF = 'u/ps'; // @fixme: make path 'u/ps/view'. /** * Implements do_execute(). @@ -30,8 +33,6 @@ class c_standard_path_user_ps extends c_standard_path { return $executed; } - $this->pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_section(array(1 => 0)); // initialize the content as HTML. @@ -51,34 +52,9 @@ class c_standard_path_user_ps extends c_standard_path { 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'] . static::PATH_SELF); + $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); } - - /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** - * Implements pr_get_text(). - */ - protected function pr_get_text($code, $arguments = array()) { - $string = ''; - switch ($code) { - case 0: - $string = 'Lock User'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } } diff --git a/common/standard/paths/u/user_refresh.php b/common/standard/paths/u/user_refresh.php index 951186d..e117965 100644 --- a/common/standard/paths/u/user_refresh.php +++ b/common/standard/paths/u/user_refresh.php @@ -12,6 +12,8 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); +require_once('common/standard/paths/u/user_view.php'); require_once('common/theme/classes/theme_html.php'); @@ -20,8 +22,11 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/refresh */ -class c_standard_path_user_refresh extends c_standard_path { - protected const PATH_SELF = 'u/refresh'; +class c_standard_path_user_refresh extends c_standard_path_user { + public const PATH_SELF = 'u/refresh'; + + protected const NAME_MENU_CONTENT = 'menu_content_user_view'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content_user_view'; /** * Implements do_execute(). @@ -33,6 +38,112 @@ class c_standard_path_user_refresh extends c_standard_path { 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 ($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); + $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. @@ -52,18 +163,26 @@ class c_standard_path_user_refresh extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $result = parent::pr_build_breadcrumbs(); - if ($result instanceof c_base_return_false) { + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } unset($result); - return new c_base_return_false(); } - unset($result); if (!($this->breadcrumbs instanceof c_base_menu_item)) { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -76,20 +195,13 @@ class c_standard_path_user_refresh extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_session.php b/common/standard/paths/u/user_session.php new file mode 100644 index 0000000..0d79af9 --- /dev/null +++ b/common/standard/paths/u/user_session.php @@ -0,0 +1,163 @@ +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 ($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); + $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. + + return $executed; + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return ''; + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + return ''; + } +} diff --git a/common/standard/paths/u/user_settings.php b/common/standard/paths/u/user_settings.php index 30b67d2..9c233a0 100644 --- a/common/standard/paths/u/user_settings.php +++ b/common/standard/paths/u/user_settings.php @@ -10,6 +10,8 @@ require_once('common/base/classes/base_path.php'); require_once('common/base/classes/base_database.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); +require_once('common/standard/paths/u/user_view.php'); require_once('common/theme/classes/theme_html.php'); @@ -18,19 +20,16 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/settings */ -class c_standard_path_user_settings extends c_standard_path { - protected const PATH_SELF = 'u/settings'; - - protected const ID_USER_MINIMUM = 1000; +class c_standard_path_user_settings extends c_standard_path_user { + public const PATH_SELF = 'u/settings'; + protected const NAME_MENU_CONTENT = 'menu_content_user_view'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content_user_view'; protected const CLASS_USER_SETTINGS_ACCOUNT = 'user_settings-account'; protected const CLASS_USER_SETTINGS_PERSONAL = 'user_settings-personal'; protected const CLASS_USER_SETTINGS_ACCESS = 'user_settings-access'; protected const CLASS_USER_SETTINGS_HISTORY = 'user_settings-history'; - protected const CLASS_ID_USER = 'id-user'; - protected const CLASS_ID_USER_EXTERNAL = 'id-user-external'; - /** * Implements do_execute(). */ @@ -58,6 +57,9 @@ class c_standard_path_user_settings extends c_standard_path { 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); @@ -154,18 +156,26 @@ class c_standard_path_user_settings extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $result = parent::pr_build_breadcrumbs(); - if ($result instanceof c_base_return_false) { + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } unset($result); - return new c_base_return_false(); } - unset($result); if (!($this->breadcrumbs instanceof c_base_menu_item)) { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -178,20 +188,13 @@ class c_standard_path_user_settings extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_unlock.php b/common/standard/paths/u/user_unlock.php index 405fd4d..29d6d28 100644 --- a/common/standard/paths/u/user_unlock.php +++ b/common/standard/paths/u/user_unlock.php @@ -9,6 +9,8 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_path.php'); require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_user.php'); +require_once('common/standard/paths/u/user_view.php'); require_once('common/theme/classes/theme_html.php'); @@ -17,8 +19,11 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/unlock */ -class c_standard_path_user_unlock extends c_standard_path { - protected const PATH_SELF = 'u/unlock'; +class c_standard_path_user_unlock extends c_standard_path_user { + public const PATH_SELF = 'u/unlock'; + + protected const NAME_MENU_CONTENT = 'menu_content_user_view'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content_user_view'; /** * Implements do_execute(). @@ -30,7 +35,113 @@ class c_standard_path_user_unlock extends c_standard_path { return $executed; } - $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(); + + $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 ($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); + $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(); @@ -49,18 +160,26 @@ class c_standard_path_user_unlock extends c_standard_path { * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $result = parent::pr_build_breadcrumbs(); - if ($result instanceof c_base_return_false) { + $path_user_view = new c_standard_path_user_view(); + $path_user_view->set_parameters($this->http, $this->database, $this->session, $this->settings); + $path_user_view->set_path_tree($this->get_path_tree($this->path_tree)); + $this->breadcrumbs = $path_user_view->get_breadcrumbs(); + unset($path_user_view); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } unset($result); - return new c_base_return_false(); } - unset($result); if (!($this->breadcrumbs instanceof c_base_menu_item)) { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,20 +192,13 @@ class c_standard_path_user_unlock extends c_standard_path { 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'] . static::PATH_SELF); + $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); } /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/paths/u/user_view.php b/common/standard/paths/u/user_view.php index 8e16583..b8b9777 100644 --- a/common/standard/paths/u/user_view.php +++ b/common/standard/paths/u/user_view.php @@ -10,7 +10,7 @@ require_once('common/base/classes/base_path.php'); require_once('common/base/classes/base_database.php'); require_once('common/standard/classes/standard_path.php'); -require_once('common/standard/paths/u/user_settings.php'); +require_once('common/standard/classes/standard_path_user.php'); require_once('common/theme/classes/theme_html.php'); @@ -19,8 +19,164 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/view */ -class c_standard_path_user_view extends c_standard_path_user_settings { - protected const PATH_SELF = 'u/view'; +class c_standard_path_user_view extends c_standard_path_user { + public const PATH_SELF = 'u/view'; + + protected const NAME_MENU_CONTENT = 'menu_content_user_view'; + protected const HANDLER_MENU_CONTENT = 'c_standard_menu_content_user_view'; + + /** + * Implements do_execute(). + */ + public function do_execute(&$http, &$database, &$session, $settings = array()) { + // the parent function performs validation on the parameters. + $executed = parent::do_execute($http, $database, $session, $settings); + if (c_base_return::s_has_error($executed)) { + 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 ($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); + $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(); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } /** * Implements pr_get_text(). @@ -36,9 +192,6 @@ class c_standard_path_user_view extends c_standard_path_user_settings { $string = 'View User'; } break; - default: - // otherwise - return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { diff --git a/database/sql/standard/standard-users.sql b/database/sql/standard/standard-users.sql index 8c87f96..d1ed751 100644 --- a/database/sql/standard/standard-users.sql +++ b/database/sql/standard/standard-users.sql @@ -48,6 +48,10 @@ create table s_tables.t_users ( date_locked timestamp with time zone, date_deleted timestamp with time zone, + image_original bytea, + image_cropped bytea, + image_icon bytea, + settings json, constraint cp_users primary key (id), @@ -103,51 +107,49 @@ create index i_users_id_sort_x on s_tables.t_users (id_sort) with (fillfactor = create index i_users_id_sort_y on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 121; create index i_users_id_sort_z on s_tables.t_users (id_sort) with (fillfactor = 100) where id_sort = 122; - - /*** provide current user access to their own information (system users are not allowed to update their account) ***/ create view s_users.v_users_self with (security_barrier=true) as - select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users + select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, image_original, image_cropped, image_icon, settings from s_tables.t_users where not is_deleted and (name_machine)::text = (current_user)::text; create view public.v_users_self_session with (security_barrier=true) as - select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users + select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, image_original, image_cropped, image_icon, settings from s_tables.t_users where not is_deleted and (name_machine)::text = (session_user)::text; create view public.v_users_self_locked_not with (security_barrier=true) as - select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users + select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, image_original, image_cropped, image_icon, settings from s_tables.t_users where not is_deleted and not is_locked and (name_machine)::text = (current_user)::text; create view public.v_users_self_exists with (security_barrier=true) as - select id, name_machine, is_system, is_public, is_locked, is_deleted from s_tables.t_users + select id, name_machine, is_system, is_public, is_locked, is_deleted, image_original, image_cropped, image_icon from s_tables.t_users where (name_machine)::text = (current_user)::text; create view s_users.v_users_self_insert with (security_barrier=true) as - select id_external, name_human, address_email, is_private, settings from s_tables.t_users + select id_external, name_human, address_email, is_private, image_original, image_cropped, image_icon, settings from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public and (name_machine)::text = (current_user)::text with check option; create view s_users.v_users_self_update with (security_barrier=true) as - select address_email, is_private, settings from s_tables.t_users + select address_email, is_private, image_original, image_cropped, image_icon, settings from s_tables.t_users where not is_deleted and not is_locked and not is_system and not is_public and (name_machine)::text = (current_user)::text with check option; /**** anonymous user has uid = 1 ****/ create view public.v_users_self with (security_barrier=true) as - select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, settings from s_tables.t_users + select id, id_external, id_sort, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_system, is_public, is_locked, is_private, is_deleted, is_roler, date_created, date_changed, date_synced, date_locked, null::timestamp as date_deleted, image_original, image_cropped, image_icon, settings from s_tables.t_users where not is_deleted and id = 1; /*** provide public user information ***/ create view public.v_users with (security_barrier=true) as - select id, null::bigint as id_external, id_sort, name_machine, name_human, null::public.ct_email as address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as is_roler, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, null::json as settings from s_tables.t_users + select id, null::bigint as id_external, id_sort, name_machine, name_human, null::public.ct_email as address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as is_roler, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, image_original, image_cropped, image_icon, null::json as settings from s_tables.t_users where (not is_deleted and not is_private) or (not is_deleted and (name_machine)::text = (current_user)::text); /*** provide e-mail address as public information only if it is explicitly allowed ***/ create view public.v_users_email with (security_barrier=true) as - select id, null::bigint as id_external, id_sort, name_machine, name_human, address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as is_roler, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, null::json as settings from s_tables.t_users + select id, null::bigint as id_external, id_sort, name_machine, name_human, address_email, null::bool as is_administer, null::bool as is_manager, null::bool as is_auditor, null::bool as is_publisher, null::bool as is_insurer, null::bool as is_financer, null::bool as is_reviewer, null::bool as is_editor, null::bool as is_drafter, null::bool as is_requester, is_system, is_public, null::bool as is_locked, is_private, is_deleted, null::bool as is_roler, null::timestamp as date_created, null::timestamp as date_changed, null::timestamp as date_synced, null::timestamp as date_locked, null::timestamp as date_deleted, image_original, image_cropped, image_icon, null::json as settings from s_tables.t_users where (not is_deleted and not is_private and not (address_email).private) or (not is_deleted and (name_machine)::text = (current_user)::text); @@ -157,16 +159,16 @@ create view s_managers.v_users with (security_barrier=true) as where not is_deleted; create view s_managers.v_users_insert with (security_barrier=true) as - select id, id_external, name_machine, name_human, address_email, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, is_roler, settings from s_tables.t_users + select id, id_external, name_machine, name_human, address_email, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, is_roler, image_original, image_cropped, image_icon, settings from s_tables.t_users with check option; create view s_managers.v_users_update with (security_barrier=true) as - select id, id_external, name_machine, name_human, address_email, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, is_roler, settings from s_tables.t_users + select id, id_external, name_machine, name_human, address_email, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, is_roler, image_original, image_cropped, image_icon, settings from s_tables.t_users where not is_deleted with check option; create view s_managers.v_users_deleted with (security_barrier=true) as - select id, id_external, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, is_roler, date_created, date_changed, date_synced, date_locked, settings from s_tables.t_users + select id, id_external, name_machine, name_human, address_email, is_administer, is_manager, is_auditor, is_publisher, is_insurer, is_financer, is_reviewer, is_editor, is_drafter, is_requester, is_locked, is_private, is_roler, date_created, date_changed, date_synced, date_locked, image_original, image_cropped, image_icon, settings from s_tables.t_users where is_deleted; -- 1.8.3.1