From a3c188c7f2fec463e465abf52dcf0339865e696a Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 26 May 2017 21:05:41 -0500 Subject: [PATCH] Progress: further work on user view page, documentation changes, more global constants, try to get more consistent return types One of the downsides of my design is the complex return type handling. The code because easier when tests do not have to be performed. I want to provide a way to return a class as a default but provide a way to say that there was no value stored. Instead of returning the NULL return type class, return the preferred class with an error flag set to "not defined". This simplifies the code, especially some of the code used on the user view page. --- common/base/classes/base_address.php | 35 ++- common/base/classes/base_database.php | 5 +- common/base/classes/base_defaults_global.php | 30 ++ common/base/classes/base_error.php | 27 +- .../base/classes/base_error_messages_english.php | 8 + .../base/classes/base_error_messages_japanese.php | 8 + common/base/classes/base_http.php | 2 +- common/base/classes/base_menu.php | 9 +- common/base/classes/base_path.php | 78 +++++ common/base/classes/base_return.php | 2 +- common/base/classes/base_session.php | 37 ++- common/standard/classes/standard_path.php | 52 ++++ common/standard/menus/menu_utility.php | 7 +- common/standard/paths/u/dashboard.php | 12 +- common/standard/paths/u/ja/user_view.php | 52 ++-- common/standard/paths/u/user_view.php | 317 ++++++++++++++++----- common/theme/classes/theme_html.php | 8 +- .../reservation/reservation_defaults_global.php | 30 ++ 18 files changed, 557 insertions(+), 162 deletions(-) diff --git a/common/base/classes/base_address.php b/common/base/classes/base_address.php index 62806f3..291fea3 100644 --- a/common/base/classes/base_address.php +++ b/common/base/classes/base_address.php @@ -103,9 +103,9 @@ class c_base_address_email extends c_base_return { /** * Get the name. * - * @return c_base_return_status - * TRUE on success. - * FALSE with error bit set is returned on error. + * @return c_base_return_string + * The name string on success. + * An empty string with error bit set is returned on error. */ public function get_name() { if (!is_string($this->name)) { @@ -118,9 +118,9 @@ class c_base_address_email extends c_base_return { /** * Get the domain name. * - * @return c_base_return_status - * TRUE on success. - * FALSE with error bit set is returned on error. + * @return c_base_return_string + * The domain name string on success. + * An empty string with error bit set is returned on error. */ public function get_domain() { if (!is_string($this->domain)) { @@ -131,6 +131,29 @@ class c_base_address_email extends c_base_return { } /** + * Get the combined name and domain name. + * + * @return c_base_return_string + * The name and domain name string on success. + * An empty string with error bit set is returned on error. + */ + public function get_address() { + if (!is_string($this->name)) { + $this->name = ''; + } + + if (!is_string($this->domain)) { + $this->domain = ''; + } + + if (empty($this->name) || empty($this->domain)) { + return c_base_return_string::s_new(''); + } + + return c_base_return_string::s_new($this->name . '@' . $this->domain); + } + + /** * Get the is private setting. * * @param bool|null $is_private diff --git a/common/base/classes/base_database.php b/common/base/classes/base_database.php index bbec2ba..5193ada 100644 --- a/common/base/classes/base_database.php +++ b/common/base/classes/base_database.php @@ -713,7 +713,7 @@ class c_base_database extends c_base_return { * * @param c_base_database_connection_string $connection_string * An already processed and configured connection string object. - * This does perform clone(). + * This object is cloned. * * @return c_base_return_status * TRUE on success, FALSE otherwise. @@ -735,9 +735,8 @@ class c_base_database extends c_base_return { * Returns the connection string. * * @return c_base_database_connection_string - * A connection string object on success. + * A (cloned) connection string object on success. * The error bit set is on error. - * This does perform clone(). */ public function get_connection_string() { if (!is_object($this->connection_string) || !($this->connection_string instanceof c_base_database_connection_string)) { diff --git a/common/base/classes/base_defaults_global.php b/common/base/classes/base_defaults_global.php index 642da35..671cb27 100644 --- a/common/base/classes/base_defaults_global.php +++ b/common/base/classes/base_defaults_global.php @@ -45,6 +45,36 @@ class c_base_defaults_global { // default backtrace setting (TRUE = perform backtrace on error, FALSE do not perform backtrace on error). const BACKTRACE_PERFORM = TRUE; + // a machine-friendly date and time format string. + const FORMAT_DATE_MACHINE = 'Y/m/d'; + + // a machine-friendly date and time format string. + const FORMAT_DATE_TIME_MACHINE = 'Y/m/d h:i a'; + + // a machine-friendly date and time format string, with seconds. + const FORMAT_DATE_TIME_SECONDS_MACHINE = 'Y/m/d h:i:s a'; + + // a human-friendly date and time format string. + const FORMAT_DATE_HUMAN = 'l, F jS Y'; + + // a human-friendly date and time format string. + const FORMAT_DATE_TIME_HUMAN = 'l, F jS Y h:ia'; + + // a human-friendly date and time format string, with seconds. + const FORMAT_DATE_TIME_SECONDS_HUMAN = 'l, F jS Y h:i:sa'; + + // a machine-friendly time format string. + const FORMAT_TIME_MACHINE = 'h:i a'; + + // a machine-friendly time format string, with seconds. + const FORMAT_TIME_SECONDS_MACHINE = 'h:i:s a'; + + // a human-friendly time format string. + const FORMAT_TIME_HUMAN = 'h:i a'; + + // a human-friendly time format string, with seconds. + const FORMAT_TIME_SECONDS_HUMAN = 'h:i:s a'; + // Represents the current timestamp of this PHP process/session, see: self::s_get_timestamp_session(). private static $s_timestamp_session = NULL; diff --git a/common/base/classes/base_error.php b/common/base/classes/base_error.php index 7e67221..b2057ad 100644 --- a/common/base/classes/base_error.php +++ b/common/base/classes/base_error.php @@ -588,19 +588,20 @@ interface i_base_error_messages { const NOT_FOUND_DIRECTORY = 10; const NOT_FOUND_FILE = 11; const NOT_FOUND_PATH = 12; - const NO_CONNECTION = 13; - const NO_SESSION = 14; - const NO_SUPPORT = 15; - const POSTGRESQL_CONNECTION_FAILURE = 16; - const POSTGRESQL_NO_CONNECTION = 17; - const POSTGRESQL_NO_RESOURCE = 18; - const POSTGRESQL_ERROR = 19; - const SOCKET_FAILURE = 20; - const ACCESS_DENIED = 21; - const ACCESS_DENIED_UNAVAILABLE = 22; - const ACCESS_DENIED_USER = 23; - const ACCESS_DENIED_ADMINISTRATION = 24; - const SERVER_ERROR = 25; + const NOT_DEFINED = 13; + const NO_CONNECTION = 14; + const NO_SESSION = 15; + const NO_SUPPORT = 16; + const POSTGRESQL_CONNECTION_FAILURE = 17; + const POSTGRESQL_NO_CONNECTION = 18; + const POSTGRESQL_NO_RESOURCE = 19; + const POSTGRESQL_ERROR = 20; + const SOCKET_FAILURE = 21; + const ACCESS_DENIED = 22; + const ACCESS_DENIED_UNAVAILABLE = 23; + const ACCESS_DENIED_USER = 24; + const ACCESS_DENIED_ADMINISTRATION = 25; + const SERVER_ERROR = 26; /** diff --git a/common/base/classes/base_error_messages_english.php b/common/base/classes/base_error_messages_english.php index 9538ffa..14d64a2 100644 --- a/common/base/classes/base_error_messages_english.php +++ b/common/base/classes/base_error_messages_english.php @@ -221,6 +221,14 @@ final class c_base_error_messages_english implements i_base_error_messages { return c_base_return_string::s_new('Path not found or cannot be accessed.'); } } + elseif ($code === self::NOT_DEFINED) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('The requested data, :{data_name}, is not defined' . $function_name_string . '.'); + } + else { + return c_base_return_string::s_new('The requested data is not defined.'); + } + } elseif ($code === self::NO_CONNECTION) { if ($arguments === TRUE) { return c_base_return_string::s_new('The resource, :{resource_name}, is not connected' . $function_name_string . '.'); diff --git a/common/base/classes/base_error_messages_japanese.php b/common/base/classes/base_error_messages_japanese.php index 35fbaf0..28be0c3 100644 --- a/common/base/classes/base_error_messages_japanese.php +++ b/common/base/classes/base_error_messages_japanese.php @@ -226,6 +226,14 @@ final class c_base_error_messages_japanese implements i_base_error_messages { return c_base_return_string::s_new('パスが見つかりません。'); } } + elseif ($code === self::NOT_DEFINED) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('要求されたデータ:{data_name}は定義されていません' . $function_name_string . '.'); + } + else { + return c_base_return_string::s_new('要求されたデータは定義されていません。'); + } + } elseif ($code === self::NO_CONNECTION) { if ($arguments === TRUE) { return c_base_return_string::s_new('リソース :{resource_name} は接続されていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); diff --git a/common/base/classes/base_http.php b/common/base/classes/base_http.php index bd5eff9..bcc0605 100644 --- a/common/base/classes/base_http.php +++ b/common/base/classes/base_http.php @@ -2868,10 +2868,10 @@ class c_base_http extends c_base_rfc_string { * * @param c_base_cookie $cookie * The cookie object to assign as a cookie. + * This object is cloned. * These header fields apply only to the immediate client. * The header name format is: * - 1*(tchar) - * This does perform clone(). * @param bool $append * (optional) If TRUE, then append the header name. * If FALSE, then assign the header name. diff --git a/common/base/classes/base_menu.php b/common/base/classes/base_menu.php index 764234f..099c3ac 100644 --- a/common/base/classes/base_menu.php +++ b/common/base/classes/base_menu.php @@ -233,7 +233,7 @@ class c_base_menu_item extends c_base_array { * * @param c_base_menu_item $item * An instance of c_base_menu_item to assign. - * This does perform clone(). + * This object is cloned. * @param int|string|NULL $index * An index to assign a specific value to. * Set to NULL to append item. @@ -271,9 +271,9 @@ class c_base_menu_item extends c_base_array { * Assign the items array. * * @param c_base_array $items - * Replace the current array with this value. + * Replace the current array object with this object. + * This object is cloned. * If NULL, then a new array is created. - * This does perform clone(). * * @return c_base_return_status * TRUE on success, FALSE otherwise. @@ -375,10 +375,9 @@ class c_base_menu_item extends c_base_array { * An index to assign a specific value to. * * @return c_base_return_status|c_base_menu_item - * Value on success, FALSE otherwise. + * The (cloned) value object. * FALSE without error bit set is returned if $index us not defined. * FALSE with the error bit set is returned on error. - * This does perform clone(). */ public function get_item($index) { if (!is_string($index) || empty($index)) { diff --git a/common/base/classes/base_path.php b/common/base/classes/base_path.php index d22a13d..4e0bcdd 100644 --- a/common/base/classes/base_path.php +++ b/common/base/classes/base_path.php @@ -89,7 +89,9 @@ class c_base_path extends c_base_rfc_string { protected $date_created; protected $date_changed; + protected $date_synced; protected $date_locked; + protected $date_deleted; protected $include_directory; protected $include_name; @@ -120,7 +122,9 @@ class c_base_path extends c_base_rfc_string { $this->date_created = NULL; $this->date_changed = NULL; + $this->date_synced = NULL; $this->date_locked = NULL; + $this->date_deleted = NULL; $this->include_directory = NULL; $this->include_name = NULL; @@ -149,7 +153,9 @@ class c_base_path extends c_base_rfc_string { unset($this->date_created); unset($this->date_changed); + unset($this->date_synced); unset($this->date_locked); + unset($this->date_deleted); unset($this->include_directory); unset($this->include_name); @@ -494,6 +500,26 @@ class c_base_path extends c_base_rfc_string { } /** + * Assigns the date synced setting. + * + * @param float $date_synced + * The date synced associated with the path. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with error bit set is returned on error. + */ + public function set_date_synced($date_synced) { + if (!is_float($date_synced) && !is_int($date_synced)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_synced', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->date_synced = (float) $date_synced; + return new c_base_return_true(); + } + + /** * Assigns the date locked setting. * * @param float $date_locked @@ -514,6 +540,26 @@ class c_base_path extends c_base_rfc_string { } /** + * Assigns the date deleted setting. + * + * @param float $date_deleted + * The date deleted associated with the path. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with error bit set is returned on error. + */ + public function set_date_deleted($date_deleted) { + if (!is_float($date_deleted) && !is_int($date_deleted)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_deleted', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->date_deleted = (float) $date_deleted; + return new c_base_return_true(); + } + + /** * Assign an include path directory needed to process this path. * * This is the prefix part of the path. @@ -799,6 +845,22 @@ class c_base_path extends c_base_rfc_string { } /** + * Gets the date synced setting. + * + * @return c_base_return_float|c_base_return_null + * Date synced on success. + * FALSE is returned if the date is not assigned. + * Error bit is set on error. + */ + public function get_date_synced() { + if (!is_float($this->date_synced)) { + return new c_base_return_false(); + } + + return c_base_return_float::s_new($this->date_synced); + } + + /** * Gets the date locked setting. * * @return c_base_return_float|c_base_return_null @@ -815,6 +877,22 @@ class c_base_path extends c_base_rfc_string { } /** + * Gets the date deleted setting. + * + * @return c_base_return_float|c_base_return_null + * Date deleted on success. + * FALSE is returned if the date is not assigned. + * Error bit is set on error. + */ + public function get_date_deleted() { + if (!is_float($this->date_deleted)) { + return new c_base_return_false(); + } + + return c_base_return_float::s_new($this->date_deleted); + } + + /** * Get the assigned include path directory. * * This is the prefix part of the path. diff --git a/common/base/classes/base_return.php b/common/base/classes/base_return.php index e42c82f..d911b92 100644 --- a/common/base/classes/base_return.php +++ b/common/base/classes/base_return.php @@ -1580,8 +1580,8 @@ class c_base_return_object extends c_base_return_value { * * @param object $value * Any value so long as it is an object. + * This object is cloned. * NULL is not allowed. - * This does perform clone(). * * @return bool * TRUE on success, FALSE otherwise. diff --git a/common/base/classes/base_session.php b/common/base/classes/base_session.php index 1a9e2b6..1f34055 100644 --- a/common/base/classes/base_session.php +++ b/common/base/classes/base_session.php @@ -198,13 +198,13 @@ class c_base_session extends c_base_return { * Assigns the cookie associated with this session. * * @param c_base_cookie|null $cookie - * The session cookie. + * The session cookie object. + * This object is cloned. * Set to NULL to remove any existing values. * * @return c_base_return_status * TRUE on success, FALSE otherwise. * FALSE with the error bit set is returned on error. - * This does perform clone(). */ public function set_cookie($cookie) { if (!is_null($cookie) && !($cookie instanceof c_base_cookie)) { @@ -593,8 +593,8 @@ class c_base_session extends c_base_return { * * @param c_base_users_user|null $user * The current user object (generally populated from the database). + * This object is cloned. * If NULL, then the user object is removed. - * This does perform clone(). * * @return c_base_return_status * TRUE on success, FALSE otherwise. @@ -621,8 +621,8 @@ class c_base_session extends c_base_return { * * @param c_base_users_user|null $user * The current user object (generally populated from the database). + * This object is cloned. * If NULL, then the user object is removed. - * This does perform clone(). * * @return c_base_return_status * TRUE on success, FALSE otherwise. @@ -678,9 +678,8 @@ class c_base_session extends c_base_return { * Returns the cookie associated with this session. * * @return c_base_cookie|c_base_return_null - * The session cookie or NULL if undefined. + * The (cloned) session cookie or NULL if undefined. * FALSE with the error bit set is returned on error. - * This does perform clone(). */ public function get_cookie() { if (is_null($this->cookie)) { @@ -895,37 +894,35 @@ class c_base_session extends c_base_return { } /** - * Get the current user object + * Get the current user object. * - * @return c_base_users_user|c_base_return_null - * The user object is returned on success. - * NULL is returned if there is no user object assigned. - * The error bit set is returned on error. - * This does perform clone(). + * @return c_base_users_user + * The user object (cloned) is returned on success. + * A user object with the error bit set is returned on error. */ public function get_user_current() { if ($this->user_current instanceof c_base_users_user) { return clone($this->user_current); } - return new c_base_return_null(); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{data_name}' => 'user_current', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_DEFINED); + return c_base_return_error::s_return('c_base_users_user', $error); } /** - * Get the session user object + * Get the session user object. * - * @return c_base_users_user|c_base_return_null - * The user object is returned on success. - * NULL is returned if there is no user object assigned. - * The error bit set is returned on error. - * This does perform clone(). + * @return c_base_users_user + * The user object (cloned) is returned on success. + * A user object with the error bit set is returned on error. */ public function get_user_session() { if ($this->user_session instanceof c_base_users_user) { return clone($this->user_session); } - return new c_base_return_null(); + $error = c_base_error::s_log(NULL, array('arguments' => array(':{data_name}' => 'user_session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_DEFINED); + return c_base_return_error::s_return('c_base_users_user', $error); } /** diff --git a/common/standard/classes/standard_path.php b/common/standard/classes/standard_path.php index f911b1c..62b4e21 100644 --- a/common/standard/classes/standard_path.php +++ b/common/standard/classes/standard_path.php @@ -39,6 +39,7 @@ class c_standard_path extends c_base_path { protected const CSS_AS_ROW = 'as-row'; protected const CSS_AS_ROW_EVEN = 'as-row-even'; protected const CSS_AS_ROW_ODD = 'as-row-odd'; + protected const CSS_AS_ROW_VALUE = 'as-row-value'; protected const CSS_AS_SPACER = 'as-spacer'; protected const CSS_IS_JAVASCRIPT_ENABLED = 'javascript-enabled'; @@ -1045,8 +1046,58 @@ class c_standard_path extends c_base_path { } /** + * Creates the standard "row". + * + * A row only has a single tag within it, generally called the value. + * + * @param string|null $value + * If not NULL, then is text used to be displayed as the field value or description. + * @param array $arguments + * (optional) An array of arguments to convert into text. + * @param string|null $id + * (optional) An ID attribute to assign. + * If NULL, then this is not assigned. + * @param string|null $extra_class + * (optional) An additional css class to append to the wrapping block. + * May be an array of classes to append. + * If NULL, then this is not assigned. + * @param int|null $row + * (optional) If not NULL, then is a row number to append as an additional class. + * + * @return c_base_markup_tag + * The generated markup tag. + */ + protected function pr_create_tag_row($value = NULL, $arguments = array(), $id = NULL, $extra_class = NULL, $row = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_ROW, self::CSS_AS_ROW); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + elseif (is_array($extra_class)) { + foreach ($extra_class as $class) { + $classes[] = $class; + } + unset($class); + } + + if (is_int($row)) { + $classes[] = self::CSS_AS_ROW . '-' . $row; + } + + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, $id, $classes); + unset($classes); + + $tag_text = $this->pr_create_tag_text($value, $arguments, $id, self::CSS_AS_ROW_VALUE); + $tag->set_tag($tag_text); + unset($tag_text); + + return $tag; + } + + /** * Creates the standard "field row". * + * A field row has a field name tag and a field value tag. + * * @param string|null $field_name * If not NULL, then is text used to be displayed as the field name or label. * @param string|null $field_value @@ -1067,6 +1118,7 @@ class c_standard_path extends c_base_path { * This is intended to provide a way to have spacing if CSS is not used (unthemed/raw page). * If a theme is then used, it can then set the spacer tab to be not displayed. * If FALSE, this spacer tag is omitted. + * @fixme: spacer was added experimentally and may or may not be used in the future depending on how practical it is. * * @return c_base_markup_tag * The generated markup tag. diff --git a/common/standard/menus/menu_utility.php b/common/standard/menus/menu_utility.php index 3d0e1f6..c8d0706 100644 --- a/common/standard/menus/menu_utility.php +++ b/common/standard/menus/menu_utility.php @@ -36,12 +36,7 @@ class c_standard_menu_utility extends c_standard_menu { } unset($result); - $roles = array(); - $session_user = $session->get_user_current(); - if ($session_user instanceof c_base_session) { - $roles = $session_user->get_roles()->get_value_exact(); - } - unset($session_user); + $roles = $session->get_user_current()->get_roles()->get_value_exact(); $menu = $this->pr_create_html_create_menu($settings['base_css'] . self::CLASS_NAME, $this->pr_get_text(0)); diff --git a/common/standard/paths/u/dashboard.php b/common/standard/paths/u/dashboard.php index 1513ae2..0b9231b 100644 --- a/common/standard/paths/u/dashboard.php +++ b/common/standard/paths/u/dashboard.php @@ -52,17 +52,7 @@ class c_standard_path_user_dashboard extends c_standard_path { $wrapper = $this->pr_create_tag_section(array(1 => 0)); $wrapper->set_tag($this->pr_create_tag_text_block(1)); - $roles = array(); - $current_user = $session->get_user_current(); - #$session_user = $session->get_user_session(); - - - $roles = array(); - if ($current_user instanceof c_base_users_user) { - $roles = $current_user->get_roles()->get_value_exact(); - } - unset($current_user); - #unset($session_user); + $roles = $session->get_user_current()->get_roles()->get_value_exact(); $wrapper->set_tag($this->pr_create_tag_text_block($this->pr_get_text(2, array('@{user}' => $session->get_name()->get_value_exact())))); diff --git a/common/standard/paths/u/ja/user_view.php b/common/standard/paths/u/ja/user_view.php index 3ed6ec8..2220011 100644 --- a/common/standard/paths/u/ja/user_view.php +++ b/common/standard/paths/u/ja/user_view.php @@ -33,82 +33,82 @@ class c_standard_path_user_view_ja extends c_standard_path_user_view { $string = 'パブリック'; break; case 2: - $string = 'ユーザー'; + $string = 'システム'; break; case 3: - $string = 'リクエスタ'; + $string = 'ユーザー'; break; case 4: - $string = 'ドレイター'; + $string = 'リクエスタ'; break; case 5: - $string = '編集者'; + $string = 'ドレイター'; break; case 6: - $string = 'レビューア'; + $string = '編集者'; break; case 7: - $string = 'ファイナンサー'; + $string = 'レビューア'; break; case 8: - $string = '保険会社'; + $string = 'ファイナンサー'; break; case 9: - $string = '出版社'; + $string = '保険会社'; break; case 10: - $string = '審査員'; + $string = '出版社'; break; case 11: - $string = 'マネージャー'; + $string = '審査員'; break; case 12: - $string = '管理者'; + $string = 'マネージャー'; break; case 13: - $string = '口座情報'; + $string = '管理者'; break; case 14: - $string = '個人情報'; + $string = '口座情報'; break; case 15: - $string = 'アクセス情報'; + $string = '個人情報'; break; case 16: - $string = '履歴情報'; + $string = 'アクセス情報'; break; case 17: - $string = '身元'; + $string = '履歴情報'; break; case 18: - $string = '外部身元'; + $string = '身元'; break; case 19: - $string = '名'; + $string = '外部身元'; break; case 20: - $string = 'Eメール'; + $string = '名'; break; case 21: - $string = 'ロール'; + $string = 'Eメール'; break; case 22: - $string = 'ロール管理'; + $string = 'ロール'; break; case 23: - $string = 'ロックされている'; + $string = 'ロールマネージャ'; break; case 24: - $string = '削除されました'; + $string = 'ロックされている'; break; case 25: - $string = 'パブリックです'; + $string = '削除されました'; break; case 26: - $string = 'プライベートです'; + $string = 'パブリックです'; break; case 27: - $string = 'システム'; + $string = 'プライベートです'; break; case 28: $string = '作成日'; diff --git a/common/standard/paths/u/user_view.php b/common/standard/paths/u/user_view.php index 7f5362e..a2d6d5b 100644 --- a/common/standard/paths/u/user_view.php +++ b/common/standard/paths/u/user_view.php @@ -37,7 +37,8 @@ class c_standard_path_user_view extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - // @todo: this function needs to check to see if the user has administer (or manager?) roles and if they do, set administrative to TRUE when calling do_load(). + // @todo: this function needs to check to see if the user has administer (or manager?) roles (c_base_roles::MANAGER, c_base_roles::ADMINISTER) and if they do, set administrative to TRUE when calling do_load(). + $roles_current = $this->session->get_user_current()->get_roles()->get_value_exact(); $id_user = NULL; $arguments = $this->pr_get_path_arguments(self::PATH_SELF); @@ -74,14 +75,14 @@ class c_standard_path_user_view extends c_standard_path { // @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; - } + #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 = NULL; } @@ -102,11 +103,9 @@ class c_standard_path_user_view extends c_standard_path { if (is_null($id_user)) { // load current user. - $user_current = $this->session->get_user_current(); - if ($user_current instanceof c_base_users_user && $user_current->get_id()->get_value_exact() > 0) { - $user = $user_current; + if ($this->session->get_user_current()->get_id()->get_value_exact() > 0) { + $user = $this->session->get_user_current(); } - unset($user_current); } else { $user = new c_standard_users_user(); @@ -177,79 +176,79 @@ class c_standard_path_user_view extends c_standard_path { $string = 'User'; break; case 3: - $string = 'Requester'; + $string = 'System'; break; case 4: - $string = 'Drafter'; + $string = 'Requester'; break; case 5: - $string = 'Editor'; + $string = 'Drafter'; break; case 6: - $string = 'Reviewer'; + $string = 'Editor'; break; case 7: - $string = 'Financer'; + $string = 'Reviewer'; break; case 8: - $string = 'Insurer'; + $string = 'Financer'; break; case 9: - $string = 'Publisher'; + $string = 'Insurer'; break; case 10: - $string = 'Auditor'; + $string = 'Publisher'; break; case 11: - $string = 'Manager'; + $string = 'Auditor'; break; case 12: - $string = 'Administer'; + $string = 'Manager'; break; case 13: - $string = 'Account Information'; + $string = 'Administer'; break; case 14: - $string = 'Personal Information'; + $string = 'Account Information'; break; case 15: - $string = 'Access Information'; + $string = 'Personal Information'; break; case 16: - $string = 'History Information'; + $string = 'Access Information'; break; case 17: - $string = 'ID'; + $string = 'History Information'; break; case 18: - $string = 'External ID'; + $string = 'ID'; break; case 19: - $string = 'Name'; + $string = 'External ID'; break; case 20: - $string = 'E-mail'; + $string = 'Name'; break; case 21: - $string = 'Roles'; + $string = 'E-mail'; break; case 22: - $string = 'Role Management'; + $string = 'Roles'; break; case 23: - $string = 'Is Locked'; + $string = 'Role Manager'; break; case 24: - $string = 'Is Deleted'; + $string = 'Is Locked'; break; case 25: - $string = 'Is Public'; + $string = 'Is Deleted'; break; case 26: - $string = 'Is Private'; + $string = 'Is Public'; break; case 27: - $string = 'Is System'; + $string = 'Is Private'; break; case 28: $string = 'Date Created'; @@ -258,7 +257,7 @@ class c_standard_path_user_view extends c_standard_path { $string = 'Date Changed'; break; case 30: - $string = 'Date Synchronized'; + $string = 'Date Synced'; break; case 31: $string = 'Date Locked'; @@ -278,6 +277,27 @@ class c_standard_path_user_view extends c_standard_path { 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; } if (!empty($arguments)) { @@ -312,6 +332,17 @@ class c_standard_path_user_view extends c_standard_path { $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); @@ -321,52 +352,208 @@ class c_standard_path_user_view extends c_standard_path { // account information - $fieldset = $this->pr_create_tag_fieldset(13, array(), self::CLASS_USER_VIEW_ACCOUNT, self::CLASS_USER_VIEW_ACCOUNT); + $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)); - $row = $this->pr_create_tag_field_row(17, '' . $id_user, array(), NULL, NULL, 0, TRUE); - $content->set_tag($row); - unset($row); + $content->set_tag($this->pr_create_tag_field_row(18, '' . $id_user, array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE)); - $fieldset->set_tag($content); - unset($content); + if ($full_view_access || !$user->get_address_email()->is_private()->get_value()) { + $count = 1; - $this->html->set_tag($fieldset); - unset($fieldset); - unset($id_user); + 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++; - // personal information - $fieldset = $this->pr_create_tag_fieldset(14, 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(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++; - $fieldset->set_tag($content); - unset($content); + 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++; - $this->html->set_tag($fieldset); - unset($fieldset); + 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->can_manage_roles()->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)); - // access information - $fieldset = $this->pr_create_tag_fieldset(15, 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)); + $count++; + } - $fieldset->set_tag($content); - unset($content); + if ($full_view_access) { - $this->html->set_tag($fieldset); - unset($fieldset); + // 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++; - // history information - $fieldset = $this->pr_create_tag_fieldset(16, 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)); + + // 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)); + + #($count & 2 == 0) ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD) + + $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)); + + // @todo: implement code for processing and generating a table/list of history, with the ability to navigate additional entries. + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + } // @todo add edit, cancel, etc.. links. diff --git a/common/theme/classes/theme_html.php b/common/theme/classes/theme_html.php index d7f5cb3..9652c3f 100644 --- a/common/theme/classes/theme_html.php +++ b/common/theme/classes/theme_html.php @@ -164,11 +164,11 @@ class c_theme_html extends c_base_return { * * @param c_base_html $html * The markup html to apply the theme to. + * This object is cloned. * * @return c_base_return_status * TRUE on success, FALSE otherwise. * FALSE with error bit set is returned on error. - * This does perform clone(). */ public function set_html($html) { if (!($html instanceof c_base_html)) { @@ -184,10 +184,9 @@ class c_theme_html extends c_base_return { * Get the markup html assigned to this object. * * @return c_base_html|c_base_return_status - * The markup html object. + * The (cloned) markup html object. * FALSE is returned if no id is assigned. * FALSE with error bit set is returned on error. - * This does perform clone(). */ public function get_html() { if (!($this->html instanceof c_base_html)) { @@ -258,10 +257,9 @@ class c_theme_html extends c_base_return { * Get the HTTP information * * @return c_base_http|c_base_return_status - * The markup tags object. + * The (cloned) markup tags object. * FALSE is returned if no id is assigned. * FALSE with error bit set is returned on error. - * This does perform clone(). */ public function get_http() { if (!($this->http instanceof c_base_http)) { diff --git a/program/reservation/reservation_defaults_global.php b/program/reservation/reservation_defaults_global.php index 1e6302c..1810843 100644 --- a/program/reservation/reservation_defaults_global.php +++ b/program/reservation/reservation_defaults_global.php @@ -45,6 +45,36 @@ class c_base_defaults_global { // default backtrace setting (TRUE = perform backtrace on error, FALSE do not perform backtrace on error). const BACKTRACE_PERFORM = TRUE; + // a machine-friendly date and time format string. + const FORMAT_DATE_MACHINE = 'Y/m/d'; + + // a machine-friendly date and time format string. + const FORMAT_DATE_TIME_MACHINE = 'Y/m/d h:i a'; + + // a machine-friendly date and time format string, with seconds. + const FORMAT_DATE_TIME_SECONDS_MACHINE = 'Y/m/d h:i:s a'; + + // a human-friendly date and time format string. + const FORMAT_DATE_HUMAN = 'l, F jS Y'; + + // a human-friendly date and time format string. + const FORMAT_DATE_TIME_HUMAN = 'l, F jS Y h:ia'; + + // a human-friendly date and time format string, with seconds. + const FORMAT_DATE_TIME_SECONDS_HUMAN = 'l, F jS Y h:i:sa'; + + // a machine-friendly time format string. + const FORMAT_TIME_MACHINE = 'h:i a'; + + // a machine-friendly time format string, with seconds. + const FORMAT_TIME_SECONDS_MACHINE = 'h:i:s a'; + + // a human-friendly time format string. + const FORMAT_TIME_HUMAN = 'h:i a'; + + // a human-friendly time format string, with seconds. + const FORMAT_TIME_SECONDS_HUMAN = 'h:i:s a'; + // Represents the current timestamp of this PHP process/session, see: self::s_get_timestamp_session(). private static $s_timestamp_session = NULL; -- 1.8.3.1