From: Kevin Day Date: Thu, 31 Aug 2017 21:16:44 +0000 (-0500) Subject: Progress: continued work on user settings X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=da46b213f038a94aba33f984fdf11daccfd553ac;p=koopa Progress: continued work on user settings Remove meaningless trailing semicolon. Organize user page handler constants in alphabetic order. Add missing user page handler constants, classes, and files. Use static:: in place of self:: (more to come on why in a follow up commit). Move the user_view.php contents into user_settings.php and have the user_view class extend the user_settings class. --- diff --git a/common/standard/classes/standard_paths.php b/common/standard/classes/standard_paths.php index eed5aca..d337be8 100644 --- a/common/standard/classes/standard_paths.php +++ b/common/standard/classes/standard_paths.php @@ -16,20 +16,21 @@ class c_standard_paths extends c_base_return { const URI_HOME = ''; const URI_DASHBOARD_MANAGEMENT = 'm/dashboard'; const URI_DASHBOARD_ADMINISTER = 'a/dashboard'; + const URI_USER_CHECK = 'u/check'; const URI_USER_CREATE = 'u/create'; const URI_USER_DASHBOARD = 'u/dashboard'; - const URI_USER_VIEW = 'u/view'; + const URI_USER_DELETE = 'u/delete'; const URI_USER_EDIT = 'u/edit'; const URI_USER_LOCK = 'u/lock'; const URI_USER_LOGIN = 'u/login'; const URI_USER_LOGOUT = 'u/logout'; - const URI_USER_UNLOCK = 'u/unlock'; - const URI_USER_DELETE = 'u/create'; - const URI_USER_CHECK = 'u/check'; - const URI_USER_REFRESH = 'u/refresh'; - const URI_USER_PRINT = 'u/print'; const URI_USER_PDF = 'u/pdf'; + const URI_USER_PRINT = 'u/print'; const URI_USER_PS = 'u/ps'; + const URI_USER_REFRESH = 'u/refresh'; + const URI_USER_SETTINGS = 'u/settings'; + const URI_USER_UNLOCK = 'u/unlock'; + const URI_USER_VIEW = 'u/view'; protected const PATH_INTERNAL = 'common/standard/internal/'; protected const PATH_USER = 'common/standard/paths/u/'; @@ -44,18 +45,21 @@ class c_standard_paths extends c_base_return { protected const NAME_DASHBOARD_MANAGEMENT = 'dashboard'; protected const NAME_DASHBOARD_ADMINISTER = 'dashboard'; protected const NAME_INDEX = 'index'; + protected const NAME_USER_CHECK = 'user_check'; protected const NAME_USER_CREATE = 'user_create'; protected const NAME_USER_DASHBOARD = 'user_dashboard'; - protected const NAME_USER_VIEW = 'user_view'; + protected const NAME_USER_DELETE = 'user_delete'; protected const NAME_USER_EDIT = 'user_edit'; protected const NAME_USER_LOCK = 'user_lock'; protected const NAME_USER_LOGIN = 'user_login'; protected const NAME_USER_LOGOUT = 'user_logout'; - protected const NAME_USER_UNLOCK = 'user_unlock'; - protected const NAME_USER_DELETE = 'user_delete'; - protected const NAME_USER_PRINT = 'user_print'; protected const NAME_USER_PDF = 'user_pdf'; + protected const NAME_USER_PRINT = 'user_print'; protected const NAME_USER_PS = 'user_ps'; + protected const NAME_USER_REFRESH = 'user_refresh'; + protected const NAME_USER_SETTINGS = 'user_settings'; + protected const NAME_USER_UNLOCK = 'user_unlock'; + protected const NAME_USER_VIEW = 'user_view'; protected const HANDLER_NOT_FOUND = 'c_standard_path_not_found'; protected const HANDLER_ACCESS_DENIED = 'c_standard_path_access_denied'; @@ -65,18 +69,21 @@ class c_standard_paths extends c_base_return { protected const HANDLER_MANAGEMENT_DASHBOARD = 'c_standard_path_management_dashboard'; protected const HANDLER_ADMINISTER_DASHBOARD = 'c_standard_path_administer_dashboard'; protected const HANDLER_INDEX = 'c_standard_path_index'; + protected const HANDLER_USER_CHECK = 'c_standard_path_user_check'; protected const HANDLER_USER_CREATE = 'c_standard_path_user_create'; protected const HANDLER_USER_DASHBOARD = 'c_standard_path_user_dashboard'; - protected const HANDLER_USER_VIEW = 'c_standard_path_user_view'; + protected const HANDLER_USER_DELETE = 'c_standard_path_user_delete'; protected const HANDLER_USER_EDIT = 'c_standard_path_user_edit'; protected const HANDLER_USER_LOCK = 'c_standard_path_user_lock'; protected const HANDLER_USER_LOGIN = 'c_standard_path_user_login'; protected const HANDLER_USER_LOGOUT = 'c_standard_path_user_logout'; - protected const HANDLER_USER_UNLOCK = 'c_standard_path_user_unlock'; - protected const HANDLER_USER_DELETE = 'c_standard_path_user_delete'; - protected const HANDLER_USER_PRINT = 'c_standard_path_user_print'; protected const HANDLER_USER_PDF = 'c_standard_path_user_pdf'; + protected const HANDLER_USER_PRINT = 'c_standard_path_user_print'; protected const HANDLER_USER_PS = 'c_standard_path_user_ps'; + protected const HANDLER_USER_REFRESH = 'c_standard_path_user_refresh'; + protected const HANDLER_USER_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'; protected const SCRIPT_EXTENSION = '.php'; protected const WILDCARD_PATH = '/%'; @@ -673,24 +680,30 @@ class c_standard_paths extends c_base_return { $this->paths->add_path(self::URI_USER_DASHBOARD, self::HANDLER_USER_DASHBOARD, self::PATH_USER, self::NAME_USER_DASHBOARD); // user paths + $this->paths->add_path(self::URI_USER_CHECK, self::HANDLER_USER_CHECK, self::PATH_USER, self::NAME_USER_CHECK); + $this->paths->add_path(self::URI_USER_CHECK . self::WILDCARD_PATH, self::HANDLER_USER_CHECK, self::PATH_USER, self::NAME_USER_CHECK); $this->paths->add_path(self::URI_USER_CREATE, self::HANDLER_USER_CREATE, self::PATH_USER, self::NAME_USER_CREATE); $this->paths->add_path(self::URI_USER_CREATE . self::WILDCARD_PATH, self::HANDLER_USER_CREATE, self::PATH_USER, self::NAME_USER_CREATE); - $this->paths->add_path(self::URI_USER_VIEW, self::HANDLER_USER_VIEW, self::PATH_USER, self::NAME_USER_VIEW); - $this->paths->add_path(self::URI_USER_VIEW . self::WILDCARD_PATH, self::HANDLER_USER_VIEW, self::PATH_USER, self::NAME_USER_VIEW); + $this->paths->add_path(self::URI_USER_DELETE, self::HANDLER_USER_DELETE, self::PATH_USER, self::NAME_USER_DELETE); + $this->paths->add_path(self::URI_USER_DELETE . self::WILDCARD_PATH, self::HANDLER_USER_DELETE, self::PATH_USER, self::NAME_USER_DELETE); $this->paths->add_path(self::URI_USER_EDIT, self::HANDLER_USER_EDIT, self::PATH_USER, self::NAME_USER_EDIT); $this->paths->add_path(self::URI_USER_EDIT . self::WILDCARD_PATH, self::HANDLER_USER_EDIT, self::PATH_USER, self::NAME_USER_EDIT); $this->paths->add_path(self::URI_USER_LOCK, self::HANDLER_USER_LOCK, self::PATH_USER, self::NAME_USER_LOCK); $this->paths->add_path(self::URI_USER_LOCK . self::WILDCARD_PATH, self::HANDLER_USER_LOCK, self::PATH_USER, self::NAME_USER_LOCK); - $this->paths->add_path(self::URI_USER_UNLOCK, self::HANDLER_USER_UNLOCK, self::PATH_USER, self::NAME_USER_UNLOCK); - $this->paths->add_path(self::URI_USER_UNLOCK . self::WILDCARD_PATH, self::HANDLER_USER_UNLOCK, self::PATH_USER, self::NAME_USER_UNLOCK); - $this->paths->add_path(self::URI_USER_DELETE, self::HANDLER_USER_DELETE, self::PATH_USER, self::NAME_USER_DELETE); - $this->paths->add_path(self::URI_USER_DELETE . self::WILDCARD_PATH, self::HANDLER_USER_DELETE, self::PATH_USER, self::NAME_USER_DELETE); - $this->paths->add_path(self::URI_USER_PRINT, self::HANDLER_USER_PRINT, self::PATH_USER, self::NAME_USER_PRINT); - $this->paths->add_path(self::URI_USER_PRINT . self::WILDCARD_PATH, self::HANDLER_USER_PRINT, self::PATH_USER, self::NAME_USER_PRINT); $this->paths->add_path(self::URI_USER_PDF, self::HANDLER_USER_PDF, self::PATH_USER, self::NAME_USER_PDF); $this->paths->add_path(self::URI_USER_PDF . self::WILDCARD_PATH, self::HANDLER_USER_PDF, self::PATH_USER, self::NAME_USER_PDF); + $this->paths->add_path(self::URI_USER_PRINT, self::HANDLER_USER_PRINT, self::PATH_USER, self::NAME_USER_PRINT); + $this->paths->add_path(self::URI_USER_PRINT . self::WILDCARD_PATH, self::HANDLER_USER_PRINT, self::PATH_USER, self::NAME_USER_PRINT); $this->paths->add_path(self::URI_USER_PS, self::HANDLER_USER_PS, self::PATH_USER, self::NAME_USER_PS); $this->paths->add_path(self::URI_USER_PS . self::WILDCARD_PATH, self::HANDLER_USER_PS, self::PATH_USER, self::NAME_USER_PS); + $this->paths->add_path(self::URI_USER_REFRESH, self::HANDLER_USER_REFRESH, self::PATH_USER, self::NAME_USER_REFRESH); + $this->paths->add_path(self::URI_USER_REFRESH . self::WILDCARD_PATH, self::HANDLER_USER_REFRESH, self::PATH_USER, self::NAME_USER_REFRESH); + $this->paths->add_path(self::URI_USER_SETTINGS, self::HANDLER_USER_SETTINGS, self::PATH_USER, self::NAME_USER_SETTINGS); + $this->paths->add_path(self::URI_USER_SETTINGS . self::WILDCARD_PATH, self::HANDLER_USER_SETTINGS, self::PATH_USER, self::NAME_USER_SETTINGS); + $this->paths->add_path(self::URI_USER_UNLOCK, self::HANDLER_USER_UNLOCK, self::PATH_USER, self::NAME_USER_UNLOCK); + $this->paths->add_path(self::URI_USER_UNLOCK . self::WILDCARD_PATH, self::HANDLER_USER_UNLOCK, self::PATH_USER, self::NAME_USER_UNLOCK); + $this->paths->add_path(self::URI_USER_VIEW, self::HANDLER_USER_VIEW, self::PATH_USER, self::NAME_USER_VIEW); + $this->paths->add_path(self::URI_USER_VIEW . self::WILDCARD_PATH, self::HANDLER_USER_VIEW, self::PATH_USER, self::NAME_USER_VIEW); } /** diff --git a/common/standard/paths/a/dashboard.php b/common/standard/paths/a/dashboard.php index a03fbca..7d28ced 100644 --- a/common/standard/paths/a/dashboard.php +++ b/common/standard/paths/a/dashboard.php @@ -23,7 +23,7 @@ class c_standard_path_administer_dashboard extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $wrapper = $this->pr_create_tag_section(array(1 => 0)); @@ -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'] . self::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'] . static::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 ac3c46e..cdd0d5f 100644 --- a/common/standard/paths/m/dashboard.php +++ b/common/standard/paths/m/dashboard.php @@ -23,7 +23,7 @@ class c_standard_path_management_dashboard extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $wrapper = $this->pr_create_tag_section(array(1 => 0)); @@ -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'] . self::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'] . static::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 new file mode 100644 index 0000000..b2f5483 --- /dev/null +++ b/common/standard/paths/u/ja/user_check.php @@ -0,0 +1,33 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_refresh.php b/common/standard/paths/u/ja/user_refresh.php new file mode 100644 index 0000000..325c522 --- /dev/null +++ b/common/standard/paths/u/ja/user_refresh.php @@ -0,0 +1,33 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_check.php b/common/standard/paths/u/user_check.php new file mode 100644 index 0000000..15a5aae --- /dev/null +++ b/common/standard/paths/u/user_check.php @@ -0,0 +1,114 @@ +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), static::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . static::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: + if (array_key_exists(':{user_name}', $arguments)) { + $string = 'Check User: :{user_name}'; + } + else { + $string = 'Check User'; + } + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_create.php b/common/standard/paths/u/user_create.php index faffa09..4ad9db7 100644 --- a/common/standard/paths/u/user_create.php +++ b/common/standard/paths/u/user_create.php @@ -28,7 +28,7 @@ class c_standard_path_user_create extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $wrapper = $this->pr_create_tag_section(array(1 => 0)); @@ -60,7 +60,7 @@ class c_standard_path_user_create extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,7 +73,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_dashboard.php b/common/standard/paths/u/user_dashboard.php index 5392637..e6e287f 100644 --- a/common/standard/paths/u/user_dashboard.php +++ b/common/standard/paths/u/user_dashboard.php @@ -35,7 +35,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), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -50,7 +50,7 @@ class c_standard_path_user_dashboard extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); @@ -136,7 +136,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_delete.php b/common/standard/paths/u/user_delete.php index 33bfb90..559e2e7 100644 --- a/common/standard/paths/u/user_delete.php +++ b/common/standard/paths/u/user_delete.php @@ -28,7 +28,7 @@ class c_standard_path_user_delete extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $wrapper = $this->pr_create_tag_section(array(1 => 0)); @@ -60,7 +60,7 @@ class c_standard_path_user_delete extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,7 +73,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_edit.php b/common/standard/paths/u/user_edit.php index fe42382..2bef7ce 100644 --- a/common/standard/paths/u/user_edit.php +++ b/common/standard/paths/u/user_edit.php @@ -31,7 +31,7 @@ class c_standard_path_user_edit extends c_standard_path { protected function pr_build_breadcrumbs() { parent::pr_build_breadcrumbs(); - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(1), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(1), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -46,7 +46,7 @@ class c_standard_path_user_edit extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $this->pr_assign_defaults($http, $database, $session, $settings); @@ -71,7 +71,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_lock.php b/common/standard/paths/u/user_lock.php index b6c9613..49d7c3b 100644 --- a/common/standard/paths/u/user_lock.php +++ b/common/standard/paths/u/user_lock.php @@ -28,7 +28,7 @@ class c_standard_path_user_lock extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $wrapper = $this->pr_create_tag_section(array(1 => 0)); @@ -60,7 +60,7 @@ class c_standard_path_user_lock extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,7 +73,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_login.php b/common/standard/paths/u/user_login.php index a7f4815..64c391e 100644 --- a/common/standard/paths/u/user_login.php +++ b/common/standard/paths/u/user_login.php @@ -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), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(12), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); diff --git a/common/standard/paths/u/user_logout.php b/common/standard/paths/u/user_logout.php index 4a775a5..8ab1d4c 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), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::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 aaa097b..05bad00 100644 --- a/common/standard/paths/u/user_pdf.php +++ b/common/standard/paths/u/user_pdf.php @@ -28,7 +28,7 @@ class c_standard_path_user_pdf extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $this->pr_assign_defaults($http, $database, $session, $settings); @@ -51,7 +51,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_print.php b/common/standard/paths/u/user_print.php index 85edeec..4bea27f 100644 --- a/common/standard/paths/u/user_print.php +++ b/common/standard/paths/u/user_print.php @@ -28,7 +28,7 @@ class c_standard_path_user_print extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $this->pr_assign_defaults($http, $database, $session, $settings); @@ -51,7 +51,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_ps.php b/common/standard/paths/u/user_ps.php index 9e80875..a77cdad 100644 --- a/common/standard/paths/u/user_ps.php +++ b/common/standard/paths/u/user_ps.php @@ -28,7 +28,7 @@ class c_standard_path_user_ps extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $this->pr_assign_defaults($http, $database, $session, $settings); @@ -51,7 +51,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_refresh.php b/common/standard/paths/u/user_refresh.php new file mode 100644 index 0000000..951186d --- /dev/null +++ b/common/standard/paths/u/user_refresh.php @@ -0,0 +1,114 @@ +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), static::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . static::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: + if (array_key_exists(':{user_name}', $arguments)) { + $string = 'Refresh User: :{user_name}'; + } + else { + $string = 'Refresh User'; + } + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_settings.php b/common/standard/paths/u/user_settings.php index 2d2dc05..00e3665 100644 --- a/common/standard/paths/u/user_settings.php +++ b/common/standard/paths/u/user_settings.php @@ -1,29 +1,35 @@ pr_get_path_arguments(self::PATH_SELF); + // @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)) { - // @todo: return $this->p_do_execute_X($executed); + $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 < self::ID_USER_MINIMUM) { + $id_user = FALSE; + } + } + else { + unset($arguments_total); + unset($argument); + unset($id_user); + unset($user); + + $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => 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; + } } - $this->p_do_execute($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 < self::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); + + $this->p_do_execute_settings($executed, $user); + unset($user); return $executed; } @@ -60,7 +165,7 @@ class c_standard_path_user_settings extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,7 +178,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); @@ -93,64 +198,201 @@ class c_standard_path_user_settings extends c_standard_path { $string = ''; switch ($code) { case 0: - $string = 'User Settings'; + if (array_key_exists(':{user_name}', $arguments)) { + $string = 'User Settings: :{user_name}'; + } + else { + $string = 'User Settings'; + } break; case 1: - $string = ''; + $string = 'Public'; break; case 2: - $string = ''; + $string = 'User'; break; case 3: - $string = ''; + $string = 'System'; break; case 4: - $string = 'Public'; + $string = 'Requester'; break; case 5: - $string = 'User'; + $string = 'Drafter'; break; case 6: - $string = 'Requester'; + $string = 'Editor'; break; case 7: - $string = 'Drafter'; + $string = 'Reviewer'; break; case 8: - $string = 'Editor'; + $string = 'Financer'; break; case 9: - $string = 'Reviewer'; + $string = 'Insurer'; break; case 10: - $string = 'Financer'; + $string = 'Publisher'; break; case 11: - $string = 'Insurer'; + $string = 'Auditor'; break; case 12: - $string = 'Publisher'; + $string = 'Manager'; break; case 13: - $string = 'Auditor'; + $string = 'Administer'; break; case 14: - $string = 'Manager'; + $string = 'Account Information'; break; case 15: - $string = 'Administer'; + $string = 'Personal Information'; break; case 16: - $string = 'Account Information'; + $string = 'Access Information'; break; case 17: - $string = 'Personal Information'; + $string = 'History Information'; break; case 18: - $string = 'Access Information'; + $string = 'ID'; break; case 19: - $string = 'History Information'; + $string = 'External ID'; + break; + case 20: + $string = 'Name'; + break; + case 21: + $string = 'E-mail'; + break; + case 22: + $string = 'Roles'; + break; + case 23: + $string = 'Role Manager'; + break; + case 24: + $string = 'Is Locked'; + break; + case 25: + $string = 'Is Deleted'; + break; + case 26: + $string = 'Is Public'; + break; + case 27: + $string = 'Is Private'; + break; + case 28: + $string = 'Date Created'; + break; + case 29: + $string = 'Date Changed'; + break; + case 30: + $string = 'Date Synced'; + break; + case 31: + $string = 'Date Locked'; + break; + case 32: + $string = 'Date Deleted'; + break; + case 33: + $string = 'Yes'; + break; + case 34: + $string = 'No'; + break; + case 35: + $string = 'Enabled'; + break; + case 36: + $string = 'Disabled'; + break; + case 37: + $string = 'Prefix'; + break; + case 38: + $string = 'First'; + break; + case 39: + $string = 'Middle'; + break; + case 40: + $string = 'Last'; + break; + case 41: + $string = 'Suffix'; + break; + case 42: + $string = 'Full'; + break; + case 43: + $string = 'Undisclosed'; + break; + case 44: + $string = 'User ID'; + break; + case 45: + $string = 'Title'; + break; + case 46: + $string = 'Type'; + break; + case 47: + $string = 'Sub-Type'; + break; + case 48: + $string = 'Severity'; + break; + case 49: + $string = 'Facility'; + break; + case 50: + $string = 'Details'; + break; + case 51: + $string = 'Date'; + break; + case 52: + $string = 'Client'; + break; + case 53: + $string = 'Response Code'; + break; + case 54: + $string = 'Session User ID'; + break; + case 55: + $string = 'Request Path'; + break; + case 56: + $string = 'Request Arguments'; + break; + case 57: + $string = 'Request Client'; + break; + case 58: + $string = 'Request Date'; + break; + case 59: + $string = 'Request Headers'; + break; + case 60: + $string = 'Response Headers'; + break; + case 61: + $string = 'Response Code'; + break; + case 62: + $string = 'User History'; + break; + case 63: + $string = 'Access History'; break; } @@ -162,68 +404,391 @@ class c_standard_path_user_settings extends c_standard_path { } /** - * Execution of the main path, without arguments. + * Execution of the view path. * * @param c_base_path_executed &$executed * The execution results to be returned. + * @param c_base_users_user $user_id + * An object representing the user to view. + * + * @return null|array + * NULL is returned if no errors are found. + * An array of errors are returned if found. */ - private function p_do_execute(&$executed) { - $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); - + protected function p_do_execute_settings(&$executed, $user) { + $errors = NULL; - // account information - $fieldset = $this->pr_create_tag_fieldset(16, array(), self::CLASS_USER_SETTINGS_ACCOUNT, self::CLASS_USER_SETTINGS_ACCOUNT); - $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); - - $fieldset->set_tag($content); - unset($content); + $arguments = array(); + $arguments[':{user_name}'] = $user->get_name_human()->get_first()->get_value_exact() . ' ' . $user->get_name_human()->get_last()->get_value_exact(); + if (mb_strlen($arguments[':{user_name}']) == 0) { + unset($arguments[':{user_name}']); + } - $this->html->set_tag($fieldset); - unset($fieldset); + $id_user = $user->get_id()->get_value(); + if (is_int($id_user)) { + $text_id_user = $this->pr_create_tag_text('[id: ' . $id_user . ']', array(), NULL, self::CLASS_ID_USER); + $wrapper = $this->pr_create_tag_section(array(1 => array('text' => 0, 'append-inside' => $text_id_user)), $arguments); + unset($text_id_user); + } + else { + $wrapper = $this->pr_create_tag_section(array(1 => 0), $arguments); + } + $roles_current = $this->session->get_user_current()->get_roles()->get_value_exact(); + $roles = $user->get_roles()->get_value_exact(); - // personal information - $fieldset = $this->pr_create_tag_fieldset(17, array(), self::CLASS_USER_SETTINGS_PERSONAL, self::CLASS_USER_SETTINGS_PERSONAL); - $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); + $full_view_access = FALSE; + if ($id_user === $this->session->get_user_current()->get_id()->get_value_exact()) { + $full_view_access = TRUE; + } + elseif (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) { + $full_view_access = TRUE; + } - $fieldset->set_tag($content); - unset($content); - $this->html->set_tag($fieldset); - unset($fieldset); + // initialize the content as HTML. + $this->pr_create_html(TRUE, $arguments); + $this->html->set_tag($wrapper); + unset($wrapper); + unset($arguments); - // access information - $fieldset = $this->pr_create_tag_fieldset(18, array(), self::CLASS_USER_SETTINGS_ACCESS, self::CLASS_USER_SETTINGS_ACCESS); + // account information + $fieldset = $this->pr_create_tag_fieldset(14, array(), self::CLASS_USER_SETTINGS_ACCOUNT, self::CLASS_USER_SETTINGS_ACCOUNT); $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); - $fieldset->set_tag($content); - unset($content); - - $this->html->set_tag($fieldset); - unset($fieldset); - - - // history information - $fieldset = $this->pr_create_tag_fieldset(18, array(), self::CLASS_USER_SETTINGS_HISTORY, self::CLASS_USER_SETTINGS_HISTORY); - $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); + $content->set_tag($this->pr_create_tag_field_row(18, '' . $id_user, array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); + + if ($full_view_access || !$user->get_address_email()->is_private()->get_value()) { + $count = 1; + + if ($full_view_access) { + $content->set_tag($this->pr_create_tag_field_row(19, '' . $user->get_id_external()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + } + + $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + $content->set_tag($this->pr_create_tag_field_row(21, '' . $user->get_address_email()->get_address()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + if ($user->is_locked()->get_value_exact()) { + $tag_text = $this->pr_get_text(33); + } + else { + $tag_text = $this->pr_get_text(34); + } + $content->set_tag($this->pr_create_tag_field_row(24, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + if ($user->is_private()->get_value_exact()) { + $tag_text = $this->pr_get_text(33); + } + else { + $tag_text = $this->pr_get_text(34); + } + $content->set_tag($this->pr_create_tag_field_row(27, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + if ($user->is_roler()->get_value_exact()) { + $tag_text = $this->pr_get_text(33); + } + else { + $tag_text = $this->pr_get_text(34); + } + $content->set_tag($this->pr_create_tag_field_row(23, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + if (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) { + if ($user->is_deleted()->get_value_exact()) { + $tag_text = $this->pr_get_text(33); + } + else { + $tag_text = $this->pr_get_text(34); + } + $content->set_tag($this->pr_create_tag_field_row(25, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + + $count++; + } + + if ($full_view_access) { + + // date created + $date = NULL; + if (!is_null($user->get_date_created()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_created()->get_value())->get_value_exact(); + } + + $content->set_tag($this->pr_create_tag_field_row(28, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + + // date changed + $date = NULL; + if (!is_null($user->get_date_changed()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_changed()->get_value())->get_value_exact(); + } + + $content->set_tag($this->pr_create_tag_field_row(29, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + + // date synced + $date = NULL; + if (!is_null($user->get_date_synced()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_synced()->get_value())->get_value_exact(); + } + + $content->set_tag($this->pr_create_tag_field_row(30, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + + // date locked + $date = NULL; + if (!is_null($user->get_date_locked()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_locked()->get_value())->get_value_exact(); + } + + $content->set_tag($this->pr_create_tag_field_row(31, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + + + // date deleted + $date = NULL; + if (!is_null($user->get_date_deleted()->get_value())) { + $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_deleted()->get_value())->get_value_exact(); + } + + $content->set_tag($this->pr_create_tag_field_row(32, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + $count++; + } + + unset($count); + unset($date); + } + else { + $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(21, $this->pr_get_text(43), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE)); + } $fieldset->set_tag($content); unset($content); $this->html->set_tag($fieldset); unset($fieldset); + unset($id_user); + + + if ($full_view_access || !$user->is_private()->get_value()) { + // personal information + $fieldset = $this->pr_create_tag_fieldset(15, array(), self::CLASS_USER_SETTINGS_PERSONAL, self::CLASS_USER_SETTINGS_PERSONAL); + $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); + + $content->set_tag($this->pr_create_tag_field_row(37, '' . $user->get_name_human()->get_prefix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(38, '' . $user->get_name_human()->get_first()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(39, '' . $user->get_name_human()->get_middle()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(40, '' . $user->get_name_human()->get_last()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 3, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(41, '' . $user->get_name_human()->get_suffix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 4, TRUE)); + $content->set_tag($this->pr_create_tag_field_row(42, '' . $user->get_name_human()->get_complete()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 5, TRUE)); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // access information + $fieldset = $this->pr_create_tag_fieldset(16, array(), self::CLASS_USER_SETTINGS_ACCESS, self::CLASS_USER_SETTINGS_ACCESS); + $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); + + $access_to_text_mapping = array( + c_base_roles::PUBLIC => 1, + c_base_roles::SYSTEM => 2, + c_base_roles::USER => 3, + c_base_roles::REQUESTER => 4, + c_base_roles::DRAFTER => 5, + c_base_roles::EDITOR => 6, + c_base_roles::REVIEWER => 7, + c_base_roles::FINANCER => 8, + c_base_roles::INSURER => 9, + c_base_roles::PUBLISHER => 10, + c_base_roles::AUDITOR => 11, + c_base_roles::MANAGER => 12, + c_base_roles::ADMINISTER => 13, + ); + + $id_text = NULL; + $count = 0; + foreach ($roles as $role) { + if (!isset($access_to_text_mapping[$role])) { + continue; + } + + $content->set_tag($this->pr_create_tag_field_row($access_to_text_mapping[$role], array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); + + $count++; + } + unset($role); + unset($id_text); + unset($count); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + unset($roles); + + + // history information + $fieldset = $this->pr_create_tag_fieldset(17, array(), self::CLASS_USER_SETTINGS_HISTORY, self::CLASS_USER_SETTINGS_HISTORY); + $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); + + // user history + // @todo: implement code for processing and generating a table/list of history, with the ability to navigate additional entries. + $query_result = $this->database->do_query('select id, log_title, log_type, log_type_sub, log_severity, log_facility, log_date, request_client, response_code from v_log_users_self order by id desc limit 10'); + + if (c_base_return::s_has_error($query_result)) { + if (is_null($errors)) { + $errors = array(); + } + + c_base_return::s_copy_errors($query_result->get_error(), $errors); + + $last_error = $this->database->get_last_error()->get_value_exact(); + if (!empty($last_error)) { + $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR); + } + unset($last_error); + } + else { + $tag_table = $this->pr_create_tag_table(62); + + $tag_table_header = $this->pr_create_tag_table_header(); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(18)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(45)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(46)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(47)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(48)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(49)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(51)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(52)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(53)); + + $tag_table->set_tag($tag_table_header); + unset($tag_table_header); + + $tag_table_body = $this->pr_create_tag_table_body(); + + $columns = $query_result->fetch_row()->get_value(); + while (is_array($columns) && !empty($columns)) { + $row_timestamp = c_base_defaults_global::s_get_timestamp($columns[6], c_base_database::STANDARD_TIMESTAMP_FORMAT)->get_value_exact(); + $row_date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $row_timestamp)->get_value_exact(); + unset($row_timestamp); + + $tag_table_row = $this->pr_create_tag_table_row(); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[0])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[1])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[2])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[3])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[4])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[5])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $row_date)); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[7])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[8])); + unset($row_date); + + $tag_table_body->set_tag($tag_table_row); + unset($tag_table_row); + + $columns = $query_result->fetch_row()->get_value(); + } + unset($columns); + + $tag_table->set_tag($tag_table_body); + unset($tag_table_body); + + $content->set_tag($tag_table); + unset($tag_table); + } + + + // access history + // @todo: implement code for processing and generating a table/list of history, with the ability to navigate additional entries. + $query_result = $this->database->do_query('select id, request_path, request_arguments, request_date, request_client, response_code from v_log_user_activity_self order by id desc limit 10'); + + if (c_base_return::s_has_error($query_result)) { + if (is_null($errors)) { + $errors = array(); + } + + c_base_return::s_copy_errors($query_result->get_error(), $errors); + + $last_error = $this->database->get_last_error()->get_value_exact(); + if (!empty($last_error)) { + $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR); + } + unset($last_error); + } + else { + $tag_table = $this->pr_create_tag_table(62); + + $tag_table_header = $this->pr_create_tag_table_header(); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(18)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(55)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(56)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(58)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(57)); + $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(61)); + + $tag_table->set_tag($tag_table_header); + unset($tag_table_header); + + $tag_table_body = $this->pr_create_tag_table_body(); + + // @fixme: below is just an example/test. Rewrite this, cleaning up the code and adding more appropriate sanitizers and structure. + $columns = $query_result->fetch_row()->get_value(); + while (is_array($columns) && !empty($columns)) { + $tag_table_row = $this->pr_create_tag_table_row(); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[0])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[1])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[2])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[3])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[4])); + $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[5])); + + $tag_table_body->set_tag($tag_table_row); + unset($tag_table_row); + + $columns = $query_result->fetch_row()->get_value(); + } + unset($columns); + + $tag_table->set_tag($tag_table_body); + unset($tag_table_body); + + $content->set_tag($tag_table); + unset($tag_table); + } + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + } // @todo add edit, cancel, etc.. links. + $this->pr_add_menus(); + $executed->set_output($this->html); unset($this->html); + + return $errors; } } diff --git a/common/standard/paths/u/user_unlock.php b/common/standard/paths/u/user_unlock.php index 0e56062..405fd4d 100644 --- a/common/standard/paths/u/user_unlock.php +++ b/common/standard/paths/u/user_unlock.php @@ -28,7 +28,7 @@ class c_standard_path_user_unlock extends c_standard_path { $executed = parent::do_execute($http, $database, $session, $settings); if (c_base_return::s_has_error($executed)) { return $executed; - }; + } $wrapper = $this->pr_create_tag_section(array(1 => 0)); @@ -60,7 +60,7 @@ class c_standard_path_user_unlock extends c_standard_path { $this->breadcrumbs = new c_base_menu_item(); } - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), static::PATH_SELF); $this->breadcrumbs->set_item($item); unset($item); @@ -73,7 +73,7 @@ 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'] . self::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'] . static::PATH_SELF); $this->html->set_header($tag); unset($tag); diff --git a/common/standard/paths/u/user_view.php b/common/standard/paths/u/user_view.php index 5e8d8bc..8e16583 100644 --- a/common/standard/paths/u/user_view.php +++ b/common/standard/paths/u/user_view.php @@ -10,6 +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/theme/classes/theme_html.php'); @@ -18,179 +19,9 @@ require_once('common/theme/classes/theme_html.php'); * * This listens on: /u/view */ -class c_standard_path_user_view extends c_standard_path { +class c_standard_path_user_view extends c_standard_path_user_settings { protected const PATH_SELF = 'u/view'; - protected const ID_USER_MINIMUM = 1000; - - protected const CLASS_USER_VIEW_ACCOUNT = 'user_settings-account'; - protected const CLASS_USER_VIEW_PERSONAL = 'user_settings-personal'; - protected const CLASS_USER_VIEW_ACCESS = 'user_settings-access'; - protected const CLASS_USER_VIEW_HISTORY = 'user_settings-history'; - - protected const CLASS_ID_USER = 'id-user'; - protected const CLASS_ID_USER_EXTERNAL = 'id-user-external'; - - /** - * 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(self::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 < self::ID_USER_MINIMUM) { - $id_user = FALSE; - } - } - else { - unset($arguments_total); - unset($argument); - unset($id_user); - unset($user); - - $error = c_base_error::s_log(NULL, array('arguments' => array(':{path_name}' => self::PATH_SELF . '/' . implode('/', $arguments), ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_FOUND_PATH); - $executed->set_error($error); - - 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}' => self::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 < self::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}' => self::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); - - $this->p_do_execute_view($executed, $user); - unset($user); - - 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(); - } - - /** - * Implementation of pr_create_html_add_header_link_canonical(). - */ - protected function pr_create_html_add_header_link_canonical() { - $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); - $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); - $this->html->set_header($tag); - - unset($tag); - } - - /** - * Implements pr_get_text_title(). - */ - protected function pr_get_text_title($arguments = array()) { - return $this->pr_get_text(0, $arguments); - } - /** * Implements pr_get_text(). */ @@ -205,195 +36,9 @@ class c_standard_path_user_view extends c_standard_path { $string = 'View User'; } break; - case 1: - $string = 'Public'; - break; - case 2: - $string = 'User'; - break; - case 3: - $string = 'System'; - break; - case 4: - $string = 'Requester'; - break; - case 5: - $string = 'Drafter'; - break; - case 6: - $string = 'Editor'; - break; - case 7: - $string = 'Reviewer'; - break; - case 8: - $string = 'Financer'; - break; - case 9: - $string = 'Insurer'; - break; - case 10: - $string = 'Publisher'; - break; - case 11: - $string = 'Auditor'; - break; - case 12: - $string = 'Manager'; - break; - case 13: - $string = 'Administer'; - break; - case 14: - $string = 'Account Information'; - break; - case 15: - $string = 'Personal Information'; - break; - case 16: - $string = 'Access Information'; - break; - case 17: - $string = 'History Information'; - break; - case 18: - $string = 'ID'; - break; - case 19: - $string = 'External ID'; - break; - case 20: - $string = 'Name'; - break; - case 21: - $string = 'E-mail'; - break; - case 22: - $string = 'Roles'; - break; - case 23: - $string = 'Role Manager'; - break; - case 24: - $string = 'Is Locked'; - break; - case 25: - $string = 'Is Deleted'; - break; - case 26: - $string = 'Is Public'; - break; - case 27: - $string = 'Is Private'; - break; - case 28: - $string = 'Date Created'; - break; - case 29: - $string = 'Date Changed'; - break; - case 30: - $string = 'Date Synced'; - break; - case 31: - $string = 'Date Locked'; - break; - case 32: - $string = 'Date Deleted'; - break; - case 33: - $string = 'Yes'; - break; - case 34: - $string = 'No'; - break; - case 35: - $string = 'Enabled'; - break; - case 36: - $string = 'Disabled'; - break; - case 37: - $string = 'Prefix'; - break; - case 38: - $string = 'First'; - break; - case 39: - $string = 'Middle'; - break; - case 40: - $string = 'Last'; - break; - case 41: - $string = 'Suffix'; - break; - case 42: - $string = 'Full'; - break; - case 43: - $string = 'Undisclosed'; - break; - case 44: - $string = 'User ID'; - break; - case 45: - $string = 'Title'; - break; - case 46: - $string = 'Type'; - break; - case 47: - $string = 'Sub-Type'; - break; - case 48: - $string = 'Severity'; - break; - case 49: - $string = 'Facility'; - break; - case 50: - $string = 'Details'; - break; - case 51: - $string = 'Date'; - break; - case 52: - $string = 'Client'; - break; - case 53: - $string = 'Response Code'; - break; - case 54: - $string = 'Session User ID'; - break; - case 55: - $string = 'Request Path'; - break; - case 56: - $string = 'Request Arguments'; - break; - case 57: - $string = 'Request Client'; - break; - case 58: - $string = 'Request Date'; - break; - case 59: - $string = 'Request Headers'; - break; - case 60: - $string = 'Response Headers'; - break; - case 61: - $string = 'Response Code'; - break; - case 62: - $string = 'User History'; - break; - case 63: - $string = 'Access History'; - break; + default: + // otherwise + return parent::pr_get_text($code, $arguments); } if (!empty($arguments)) { @@ -402,393 +47,4 @@ class c_standard_path_user_view extends c_standard_path { return $string; } - - /** - * Execution of the view path. - * - * @param c_base_path_executed &$executed - * The execution results to be returned. - * @param c_base_users_user $user_id - * An object representing the user to view. - * - * @return null|array - * NULL is returned if no errors are found. - * An array of errors are returned if found. - */ - protected function p_do_execute_view(&$executed, $user) { - $errors = NULL; - - $arguments = array(); - $arguments[':{user_name}'] = $user->get_name_human()->get_first()->get_value_exact() . ' ' . $user->get_name_human()->get_last()->get_value_exact(); - if (mb_strlen($arguments[':{user_name}']) == 0) { - unset($arguments[':{user_name}']); - } - - $id_user = $user->get_id()->get_value(); - if (is_int($id_user)) { - $text_id_user = $this->pr_create_tag_text('[id: ' . $id_user . ']', array(), NULL, self::CLASS_ID_USER); - $wrapper = $this->pr_create_tag_section(array(1 => array('text' => 0, 'append-inside' => $text_id_user)), $arguments); - unset($text_id_user); - } - else { - $wrapper = $this->pr_create_tag_section(array(1 => 0), $arguments); - } - - $roles_current = $this->session->get_user_current()->get_roles()->get_value_exact(); - $roles = $user->get_roles()->get_value_exact(); - - $full_view_access = FALSE; - if ($id_user === $this->session->get_user_current()->get_id()->get_value_exact()) { - $full_view_access = TRUE; - } - elseif (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) { - $full_view_access = TRUE; - } - - - // initialize the content as HTML. - $this->pr_create_html(TRUE, $arguments); - $this->html->set_tag($wrapper); - unset($wrapper); - unset($arguments); - - - // account information - $fieldset = $this->pr_create_tag_fieldset(14, array(), self::CLASS_USER_VIEW_ACCOUNT, self::CLASS_USER_VIEW_ACCOUNT); - $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); - - $content->set_tag($this->pr_create_tag_field_row(18, '' . $id_user, array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); - - if ($full_view_access || !$user->get_address_email()->is_private()->get_value()) { - $count = 1; - - if ($full_view_access) { - $content->set_tag($this->pr_create_tag_field_row(19, '' . $user->get_id_external()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - } - - $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - $content->set_tag($this->pr_create_tag_field_row(21, '' . $user->get_address_email()->get_address()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - if ($user->is_locked()->get_value_exact()) { - $tag_text = $this->pr_get_text(33); - } - else { - $tag_text = $this->pr_get_text(34); - } - $content->set_tag($this->pr_create_tag_field_row(24, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - if ($user->is_private()->get_value_exact()) { - $tag_text = $this->pr_get_text(33); - } - else { - $tag_text = $this->pr_get_text(34); - } - $content->set_tag($this->pr_create_tag_field_row(27, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - if ($user->is_roler()->get_value_exact()) { - $tag_text = $this->pr_get_text(33); - } - else { - $tag_text = $this->pr_get_text(34); - } - $content->set_tag($this->pr_create_tag_field_row(23, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - if (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) { - if ($user->is_deleted()->get_value_exact()) { - $tag_text = $this->pr_get_text(33); - } - else { - $tag_text = $this->pr_get_text(34); - } - $content->set_tag($this->pr_create_tag_field_row(25, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - - $count++; - } - - if ($full_view_access) { - - // date created - $date = NULL; - if (!is_null($user->get_date_created()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_created()->get_value())->get_value_exact(); - } - - $content->set_tag($this->pr_create_tag_field_row(28, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - - // date changed - $date = NULL; - if (!is_null($user->get_date_changed()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_changed()->get_value())->get_value_exact(); - } - - $content->set_tag($this->pr_create_tag_field_row(29, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - - // date synced - $date = NULL; - if (!is_null($user->get_date_synced()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_synced()->get_value())->get_value_exact(); - } - - $content->set_tag($this->pr_create_tag_field_row(30, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - - // date locked - $date = NULL; - if (!is_null($user->get_date_locked()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_locked()->get_value())->get_value_exact(); - } - - $content->set_tag($this->pr_create_tag_field_row(31, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - - - // date deleted - $date = NULL; - if (!is_null($user->get_date_deleted()->get_value())) { - $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_deleted()->get_value())->get_value_exact(); - } - - $content->set_tag($this->pr_create_tag_field_row(32, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - $count++; - } - - unset($count); - unset($date); - } - else { - $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(21, $this->pr_get_text(43), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE)); - } - - $fieldset->set_tag($content); - unset($content); - - $this->html->set_tag($fieldset); - unset($fieldset); - unset($id_user); - - - if ($full_view_access || !$user->is_private()->get_value()) { - // personal information - $fieldset = $this->pr_create_tag_fieldset(15, array(), self::CLASS_USER_VIEW_PERSONAL, self::CLASS_USER_VIEW_PERSONAL); - $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); - - $content->set_tag($this->pr_create_tag_field_row(37, '' . $user->get_name_human()->get_prefix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(38, '' . $user->get_name_human()->get_first()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(39, '' . $user->get_name_human()->get_middle()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(40, '' . $user->get_name_human()->get_last()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 3, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(41, '' . $user->get_name_human()->get_suffix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 4, TRUE)); - $content->set_tag($this->pr_create_tag_field_row(42, '' . $user->get_name_human()->get_complete()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 5, TRUE)); - - $fieldset->set_tag($content); - unset($content); - - $this->html->set_tag($fieldset); - unset($fieldset); - - - // access information - $fieldset = $this->pr_create_tag_fieldset(16, array(), self::CLASS_USER_VIEW_ACCESS, self::CLASS_USER_VIEW_ACCESS); - $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); - - $access_to_text_mapping = array( - c_base_roles::PUBLIC => 1, - c_base_roles::SYSTEM => 2, - c_base_roles::USER => 3, - c_base_roles::REQUESTER => 4, - c_base_roles::DRAFTER => 5, - c_base_roles::EDITOR => 6, - c_base_roles::REVIEWER => 7, - c_base_roles::FINANCER => 8, - c_base_roles::INSURER => 9, - c_base_roles::PUBLISHER => 10, - c_base_roles::AUDITOR => 11, - c_base_roles::MANAGER => 12, - c_base_roles::ADMINISTER => 13, - ); - - $id_text = NULL; - $count = 0; - foreach ($roles as $role) { - if (!isset($access_to_text_mapping[$role])) { - continue; - } - - $content->set_tag($this->pr_create_tag_field_row($access_to_text_mapping[$role], array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE)); - - $count++; - } - unset($role); - unset($id_text); - unset($count); - - $fieldset->set_tag($content); - unset($content); - - $this->html->set_tag($fieldset); - unset($fieldset); - unset($roles); - - - // history information - $fieldset = $this->pr_create_tag_fieldset(17, array(), self::CLASS_USER_VIEW_HISTORY, self::CLASS_USER_VIEW_HISTORY); - $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT)); - - // user history - // @todo: implement code for processing and generating a table/list of history, with the ability to navigate additional entries. - $query_result = $this->database->do_query('select id, log_title, log_type, log_type_sub, log_severity, log_facility, log_date, request_client, response_code from v_log_users_self order by id desc limit 10'); - - if (c_base_return::s_has_error($query_result)) { - if (is_null($errors)) { - $errors = array(); - } - - c_base_return::s_copy_errors($query_result->get_error(), $errors); - - $last_error = $this->database->get_last_error()->get_value_exact(); - if (!empty($last_error)) { - $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR); - } - unset($last_error); - } - else { - $tag_table = $this->pr_create_tag_table(62); - - $tag_table_header = $this->pr_create_tag_table_header(); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(18)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(45)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(46)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(47)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(48)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(49)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(51)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(52)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(53)); - - $tag_table->set_tag($tag_table_header); - unset($tag_table_header); - - $tag_table_body = $this->pr_create_tag_table_body(); - - $columns = $query_result->fetch_row()->get_value(); - while (is_array($columns) && !empty($columns)) { - $row_timestamp = c_base_defaults_global::s_get_timestamp($columns[6], c_base_database::STANDARD_TIMESTAMP_FORMAT)->get_value_exact(); - $row_date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $row_timestamp)->get_value_exact(); - unset($row_timestamp); - - $tag_table_row = $this->pr_create_tag_table_row(); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[0])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[1])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[2])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[3])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[4])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[5])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $row_date)); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[7])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[8])); - unset($row_date); - - $tag_table_body->set_tag($tag_table_row); - unset($tag_table_row); - - $columns = $query_result->fetch_row()->get_value(); - } - unset($columns); - - $tag_table->set_tag($tag_table_body); - unset($tag_table_body); - - $content->set_tag($tag_table); - unset($tag_table); - } - - - // access history - // @todo: implement code for processing and generating a table/list of history, with the ability to navigate additional entries. - $query_result = $this->database->do_query('select id, request_path, request_arguments, request_date, request_client, response_code from v_log_user_activity_self order by id desc limit 10'); - - if (c_base_return::s_has_error($query_result)) { - if (is_null($errors)) { - $errors = array(); - } - - c_base_return::s_copy_errors($query_result->get_error(), $errors); - - $last_error = $this->database->get_last_error()->get_value_exact(); - if (!empty($last_error)) { - $errors[] = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR); - } - unset($last_error); - } - else { - $tag_table = $this->pr_create_tag_table(62); - - $tag_table_header = $this->pr_create_tag_table_header(); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(18)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(55)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(56)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(58)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(57)); - $tag_table_header->set_tag($this->pr_create_tag_table_header_cell(61)); - - $tag_table->set_tag($tag_table_header); - unset($tag_table_header); - - $tag_table_body = $this->pr_create_tag_table_body(); - - // @fixme: below is just an example/test. Rewrite this, cleaning up the code and adding more appropriate sanitizers and structure. - $columns = $query_result->fetch_row()->get_value(); - while (is_array($columns) && !empty($columns)) { - $tag_table_row = $this->pr_create_tag_table_row(); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[0])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[1])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[2])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[3])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[4])); - $tag_table_row->set_tag($this->pr_create_tag_table_cell((string) $columns[5])); - - $tag_table_body->set_tag($tag_table_row); - unset($tag_table_row); - - $columns = $query_result->fetch_row()->get_value(); - } - unset($columns); - - $tag_table->set_tag($tag_table_body); - unset($tag_table_body); - - $content->set_tag($tag_table); - unset($tag_table); - } - - $fieldset->set_tag($content); - unset($content); - - $this->html->set_tag($fieldset); - unset($fieldset); - } - - - // @todo add edit, cancel, etc.. links. - - - $this->pr_add_menus(); - - $executed->set_output($this->html); - unset($this->html); - - return $errors; - } }