From: Kevin Day Date: Tue, 23 May 2017 02:12:34 +0000 (-0500) Subject: Progress: finish implementing basic breadcrumb functionality, add initial user settin... X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=9ad72a6345d72e8285be0504482dfa77f73b67e8;p=koopa Progress: finish implementing basic breadcrumb functionality, add initial user settings pages I ended up creating a new class called c_base_array when implementing the breadcrumb functionality. I plan to eventually convert all related/similar types into this class. User setting pages have some initial work completed. --- diff --git a/common/base/classes/base_address.php b/common/base/classes/base_address.php new file mode 100644 index 0000000..62806f3 --- /dev/null +++ b/common/base/classes/base_address.php @@ -0,0 +1,161 @@ +name = NULL; + $this->domain = NULL; + + $this->is_private = TRUE; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->name); + unset($this->domain); + + unset($this->is_private); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, array()); + } + + /** + * Set the name. + * + * @param string $name + * The user name of the e-mail address. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_name($name) { + if (!is_string($name)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->name = $name; + return new c_base_return_true(); + } + + /** + * Set the domain name. + * + * @param string $domain + * The domain name of the e-mail address. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_domain($domain) { + if (!is_string($domain)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'domain', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->domain = $domain; + return new c_base_return_true(); + } + + /** + * Get the name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function get_name() { + if (!is_string($this->name)) { + $this->name = ''; + } + + return c_base_return_string::s_new($this->name); + } + + /** + * Get the domain name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function get_domain() { + if (!is_string($this->domain)) { + $this->domain = ''; + } + + return c_base_return_string::s_new($this->domain); + } + + /** + * Get the is private setting. + * + * @param bool|null $is_private + * When a boolean, this is assigned as the current is private setting. + * When NULL, the private setting is returned. + * + * @return c_base_return_bool|c_base_return_status + * When $is_private is NULL, is content boolean setting on success. + * FALSE with error bit is set on error. + */ + public function is_private($is_private = NULL) { + if (!is_null($is_private) && !is_bool($is_private)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_private', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (is_null($is_private)) { + if (!is_bool($this->is_private)) { + $this->is_private = FALSE; + } + + return c_base_return_bool::s_new($this->is_private); + } + + $this->is_private = $is_private; + return new c_base_return_true(); + } +} diff --git a/common/base/classes/base_database.php b/common/base/classes/base_database.php index f4596be..bbec2ba 100644 --- a/common/base/classes/base_database.php +++ b/common/base/classes/base_database.php @@ -646,6 +646,34 @@ class c_base_database extends c_base_return { } /** + * This breaks a postgresql array string into an array. + * + * @param string $array_string + * A string representing a postgresql array. + * + * @return c_base_return_array + * An array containing the exploded string. + * An empty array with the error bit set is returned on error. + */ + public static function s_explode_array($array_string) { + if (!is_string($array_string)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'array_string', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_value(array(), 'c_base_return_array', $error); + } + + if (mb_strlen($array_string) < 2) { + return c_base_return_array::s_new(array()); + } + + $processed_string = mb_substr($array_string, 1); + $processed_string = mb_substr($processed_string, 0, mb_strlen($processed_string) - 1); + $exploded = explode(',', $processed_string); + unset($processed_string); + + return c_base_return_array::s_new($exploded); + } + + /** * Assign a session to the database. * * @param c_base_session $session diff --git a/common/base/classes/base_error.php b/common/base/classes/base_error.php index 60f5aa0..7e67221 100644 --- a/common/base/classes/base_error.php +++ b/common/base/classes/base_error.php @@ -583,21 +583,24 @@ interface i_base_error_messages { const OPERATION_FAILURE = 5; const OPERATION_UNECESSARY = 6; const FUNCTION_FAILURE = 7; - const NOT_FOUND_ARRAY_INDEX = 8; - const NOT_FOUND_DIRECTORY = 9; - const NOT_FOUND_FILE = 10; - const NO_CONNECTION = 11; - const NO_SESSION = 12; - const NO_SUPPORT = 13; - const POSTGRESQL_CONNECTION_FAILURE = 14; - const POSTGRESQL_NO_CONNECTION = 15; - const POSTGRESQL_NO_RESOURCE = 16; - const POSTGRESQL_ERROR = 17; - const SOCKET_FAILURE = 18; - const ACCESS_DENIED = 19; - const ACCESS_DENIED_UNAVAILABLE = 20; - const ACCESS_DENIED_USER = 21; - const ACCESS_DENIED_ADMINISTRATION = 22; + const NOT_FOUND = 8; + const NOT_FOUND_ARRAY_INDEX = 9; + 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; /** diff --git a/common/base/classes/base_error_messages_english.php b/common/base/classes/base_error_messages_english.php index c022f9a..9538ffa 100644 --- a/common/base/classes/base_error_messages_english.php +++ b/common/base/classes/base_error_messages_english.php @@ -181,6 +181,14 @@ final class c_base_error_messages_english implements i_base_error_messages { return c_base_return_string::s_new('A function has failed execution.'); } } + elseif ($code === self::NOT_FOUND) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('Not found' . $function_name_string . '.'); + } + else { + return c_base_return_string::s_new('Not found.'); + } + } elseif ($code === self::NOT_FOUND_ARRAY_INDEX) { if ($arguments === TRUE) { return c_base_return_string::s_new('The index, :{index_name}, was not found in the array, :{array_name}' . $function_name_string . '.'); @@ -205,6 +213,14 @@ final class c_base_error_messages_english implements i_base_error_messages { return c_base_return_string::s_new('File not found or cannot be accessed.'); } } + elseif ($code === self::NOT_FOUND_PATH) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('The path, :{path_name}, was not found or cannot be accessed' . $function_name_string . '.'); + } + else { + return c_base_return_string::s_new('Path not found or cannot be accessed.'); + } + } 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 . '.'); @@ -293,6 +309,14 @@ final class c_base_error_messages_english implements i_base_error_messages { return c_base_return_string::s_new('Access is denied for administrative reasons.'); } } + elseif ($code === self::SERVER_ERROR) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('A server error has occurred, :{operation_name} ' . (is_null($function_name_string) ? '' : ',') . $function_name_string . '.'); + } + else { + return c_base_return_string::s_new('A server error has occurred.'); + } + } return c_base_return_string::s_new(''); } diff --git a/common/base/classes/base_error_messages_japanese.php b/common/base/classes/base_error_messages_japanese.php index 28f22e0..35fbaf0 100644 --- a/common/base/classes/base_error_messages_japanese.php +++ b/common/base/classes/base_error_messages_japanese.php @@ -132,15 +132,15 @@ final class c_base_error_messages_japanese implements i_base_error_messages { if ($code === self::INVALID_ARGUMENT) { if ($arguments === TRUE) { - return c_base_return_string::s_new('無効な引数 :{argument_name} が指定されています' . $function_name_string . '。'); + return c_base_return_string::s_new('無効な引数 :{argument_name} が指定されています' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { - return c_base_return_string::s_new('無効な引数が指定されています' . $function_name_string . '。'); + return c_base_return_string::s_new('無効な引数が指定されています' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } } elseif ($code === self::INVALID_FORMAT) { if ($arguments === TRUE) { - return c_base_return_string::s_new('引数 :{format_name} の形式が無効です' . $function_name_string . '。:{expected_format}'); + return c_base_return_string::s_new('引数 :{format_name} の形式が無効です' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。:{expected_format}'); } else { return c_base_return_string::s_new('無効な形式が指定されています。'); @@ -148,7 +148,7 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::INVALID_SESSION) { if ($arguments === TRUE) { - return c_base_return_string::s_new('要求されたセッションは無効です' . $function_name_string . '.:'); + return c_base_return_string::s_new('要求されたセッションは無効です' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('要求されたセッションは無効です。'); @@ -156,7 +156,7 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::INVALID_VARIABLE) { if ($arguments === TRUE) { - return c_base_return_string::s_new('変数 :{variable_name} は無効です' . $function_name_string . '。'); + return c_base_return_string::s_new('変数 :{variable_name} は無効です' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('無効な変数が指定されています。'); @@ -180,15 +180,23 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::FUNCTION_FAILURE) { if ($arguments === TRUE) { - return c_base_return_string::s_new('関数 :{function_name} は実行に失敗しました。'); + return c_base_return_string::s_new('関数 :{function_name} は実行に失敗しました' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('関数の実行に失敗しました。'); } } + elseif ($code === self::NOT_FOUND) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('見つかりません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); + } + else { + return c_base_return_string::s_new('見つかりません。'); + } + } elseif ($code === self::NOT_FOUND_ARRAY_INDEX) { if ($arguments === TRUE) { - return c_base_return_string::s_new('配列 :{index_name} に索引 :{array_name} が見つかりませんでした。' . $function_name_string . '。'); + return c_base_return_string::s_new('配列 :{index_name} に索引 :{array_name} が見つかりませんでした' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('指定された配列内のインデックスの検索に失敗しました。'); @@ -196,7 +204,7 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::NOT_FOUND_FILE) { if ($arguments === TRUE) { - return c_base_return_string::s_new('ファイル :{file_name} が見つかりませんでした、またはアクセスできません' . $function_name_string . '。'); + return c_base_return_string::s_new('ファイル :{file_name} が見つかりませんでした、またはアクセスできません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません。'); @@ -204,15 +212,23 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::NOT_FOUND_DIRECTORY) { if ($arguments === TRUE) { - return c_base_return_string::s_new('ディレクトリ :{directory_name} が見つかりませんでした、またはアクセスできません' . $function_name_string . '。'); + return c_base_return_string::s_new('ディレクトリ :{directory_name} が見つかりませんでした、またはアクセスできません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('ファイルが見つからないか、アクセスできません。'); } } + elseif ($code === self::NOT_FOUND_FILE) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('パス :{path_name} が見つかりませんでした' . (is_null($function_name_string) ? '' : '、') . $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} は接続されていません' . $function_name_string . '。'); + return c_base_return_string::s_new('リソース :{resource_name} は接続されていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('リソースが接続されていません。'); @@ -220,7 +236,7 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::NO_SUPPORT) { if ($arguments === TRUE) { - return c_base_return_string::s_new('機能 :{functionality_name} は現在サポートされていません。' . $function_name_string . '。'); + return c_base_return_string::s_new('機能 :{functionality_name} は現在サポートされていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('要求された機能はサポートされていません。'); @@ -236,7 +252,7 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::POSTGRESQL_NO_CONNECTION) { if ($arguments === TRUE) { - return c_base_return_string::s_new('データベース :{database_name} は接続されていません' . $function_name_string . '。'); + return c_base_return_string::s_new('データベース :{database_name} は接続されていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('データベースが接続されていません。'); @@ -244,7 +260,7 @@ final class c_base_error_messages_japanese implements i_base_error_messages { } elseif ($code === self::POSTGRESQL_NO_RESOURCE) { if ($arguments === TRUE) { - return c_base_return_string::s_new('データベースリソースがありません' . $function_name_string . '。'); + return c_base_return_string::s_new('データベースリソースがありません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); } else { return c_base_return_string::s_new('データベースリソースは使用できません。.'); @@ -290,6 +306,14 @@ final class c_base_error_messages_japanese implements i_base_error_messages { return c_base_return_string::s_new('管理上の理由からアクセスが拒否されました。'); } } + elseif ($code === self::SERVER_ERROR) { + if ($arguments === TRUE) { + return c_base_return_string::s_new('サーバーエラーが発生しました, :{operation_name} ' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。'); + } + else { + return c_base_return_string::s_new('サーバーエラーが発生しました。'); + } + } return c_base_return_string::s_new(''); } diff --git a/common/base/classes/base_http.php b/common/base/classes/base_http.php index d090835..bd5eff9 100644 --- a/common/base/classes/base_http.php +++ b/common/base/classes/base_http.php @@ -4901,10 +4901,10 @@ class c_base_http extends c_base_rfc_string { */ public function is_response_content_file() { if ($this->content_is_file) { - return new c_base_return_true(); + return c_base_return_bool::s_new(TRUE); } - return new c_base_return_false(); + return c_base_return_bool::s_new(FALSE); } /** diff --git a/common/base/classes/base_log.php b/common/base/classes/base_log.php index e2d3420..d14bbef 100644 --- a/common/base/classes/base_log.php +++ b/common/base/classes/base_log.php @@ -205,7 +205,7 @@ class c_base_log extends c_base_return_array { * * @return c_base_return_status|c_base_return_int * The type integer on success. - * FALSE with error bit set on error. + * FALSE with error bit set is returned on error. */ public function get_type() { if (!is_int($this->type)) { @@ -220,7 +220,7 @@ class c_base_log extends c_base_return_array { * * @return c_base_return_status|c_base_return_int * The type integer on success. - * FALSE with error bit set on error. + * FALSE with error bit set is returned on error. */ public function get_type_sub() { if (!is_int($this->type_sub)) { @@ -235,7 +235,7 @@ class c_base_log extends c_base_return_array { * * @return c_base_return_status|c_base_return_int * The severity integer on success. - * FALSE with error bit set on error. + * FALSE with error bit set is returned on error. */ public function get_severity() { if (!is_int($this->severity)) { @@ -252,7 +252,7 @@ class c_base_log extends c_base_return_array { * * @return c_base_return_status|c_base_return_int * The facility integer on success. - * FALSE with error bit set on error. + * FALSE with error bit set is returned on error. */ public function get_facility() { if (!is_int($this->facility)) { diff --git a/common/base/classes/base_path.php b/common/base/classes/base_path.php index 0dbf429..d22a13d 100644 --- a/common/base/classes/base_path.php +++ b/common/base/classes/base_path.php @@ -1113,7 +1113,7 @@ class c_base_path extends c_base_rfc_string { * @param array $settings * (optional) An array of additional settings that are usually site-specific. * - * @return c_base_path_executed + * @return c_base_path_executed|int * An executed array object is returned on success. * An executed array object with error bit set is returned on error. */ diff --git a/common/base/classes/base_session.php b/common/base/classes/base_session.php index 994cc0a..1a9e2b6 100644 --- a/common/base/classes/base_session.php +++ b/common/base/classes/base_session.php @@ -63,24 +63,24 @@ class c_base_session extends c_base_return { public function __construct() { parent::__construct(); - $this->socket = NULL; + $this->socket = NULL; $this->socket_directory = NULL; - $this->socket_path = NULL; - $this->socket_timeout = NULL; - $this->socket_error = NULL; + $this->socket_path = NULL; + $this->socket_timeout = NULL; + $this->socket_error = NULL; $this->cookie = NULL; $this->system_name = NULL; - $this->name = NULL; - $this->host = NULL; - $this->password = NULL; + $this->name = NULL; + $this->host = NULL; + $this->password = NULL; $this->session_id = NULL; - $this->settings = NULL; + $this->settings = NULL; $this->timeout_expire = NULL; - $this->timeout_max = NULL; + $this->timeout_max = NULL; $this->problems = NULL; diff --git a/common/base/classes/base_users.php b/common/base/classes/base_users.php index 4591632..5835b3d 100644 --- a/common/base/classes/base_users.php +++ b/common/base/classes/base_users.php @@ -3,7 +3,9 @@ * @file * Provides a class for managing system roles. */ +require_once('common/base/classes/base_error.php'); require_once('common/base/classes/base_return.php'); +require_once('common/base/classes/base_address.php'); /** * A class for managing user accounts. @@ -40,22 +42,22 @@ class c_base_users_user extends c_base_return_array { public function __construct() { parent::__construct(); - $this->id = NULL; - $this->id_external = NULL; - $this->id_sort = NULL; + $this->id = 0; + $this->id_external = 0; + $this->id_sort = 0; - $this->name_machine = NULL; - $this->name_human = NULL; + $this->name_machine = ''; + $this->name_human = new c_base_users_user_name(); - $this->address_email = NULL; + $this->address_email = new c_base_address_email(); $this->roles = new c_base_roles(); - $this->is_private = NULL; - $this->is_locked = NULL; - $this->is_deleted = NULL; + $this->is_private = TRUE; + $this->is_locked = FALSE; + $this->is_deleted = FALSE; - $this->can_manage_roles = NULL; + $this->can_manage_roles = FALSE; $this->date_created = NULL; $this->date_changed = NULL; @@ -116,6 +118,126 @@ class c_base_users_user extends c_base_return_array { } /** + * Set the user id. + * + * @param int $id + * The user id. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_id($id) { + if (!is_int($id)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->id = $id; + return new c_base_return_true(); + } + + /** + * Set the external user id. + * + * @param int $id_external + * The external user id. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_id_external($id_external) { + if (!is_int($id_external)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id_external', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->id_external = $id_external; + return new c_base_return_true(); + } + + /** + * Set the sort id. + * + * @param int $id_sort + * The sort id. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_id_sort($id_sort) { + if (!is_int($id_sort)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'id_sort', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->id_sort = $id_sort; + return new c_base_return_true(); + } + + /** + * Set the user machine name. + * + * @param int $name_machine + * The user machine name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_name_machine($name_machine) { + if (!is_string($name_machine)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name_machine', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->name_machine = $name_machine; + return new c_base_return_true(); + } + + /** + * Set the user human name. + * + * @param c_base_users_user_name $name_machine + * The user human name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_name_human($name_human) { + if (!($name_human instanceof c_base_users_user_name)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'name_human', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->name_human = clone($name_human); + return new c_base_return_true(); + } + + /** + * Get the currently assigned email address. + * + * @param c_base_address_email $address_email + * The e-mail address associated with this account. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_address_email($address_email) { + if (!($address_email instanceof c_base_address_email)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'address_email', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->address_email = clone($address_email); + return new c_base_return_true(); + } + + /** * Wrapper to c_base_roles::set_role() * * @see: c_base_roles::set_role() @@ -125,6 +247,196 @@ class c_base_users_user extends c_base_return_array { } /** + * Set the created date. + * + * @param int|float $date_created + * The created date. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_date_created($date_created) { + if (!is_int($date_created) && !is_float($date_created)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_created', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->date_created = $date_created; + return new c_base_return_true(); + } + + /** + * Set the changed date. + * + * @param int|float $date_changed + * The changed date. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_date_changed($date_changed) { + if (!is_int($date_changed) && !is_float($date_changed)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_changed', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->date_changed = $date_changed; + return new c_base_return_true(); + } + + /** + * Set the synced date. + * + * @param int|float $date_synced + * The synced date. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_date_synced($date_synced) { + if (!is_int($date_synced) && !is_float($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 = $date_synced; + return new c_base_return_true(); + } + + /** + * Set the locked date. + * + * @param int|float $date_locked + * The locked date. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_date_locked($date_locked) { + if (!is_int($date_locked) && !is_float($date_locked)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_locked', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->date_locked = $date_locked; + return new c_base_return_true(); + } + + /** + * Set the deleted date. + * + * @param int|float $date_deleted + * The deleted date. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_date_deleted($date_deleted) { + if (!is_int($date_deleted) && !is_float($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 = $date_deleted; + return new c_base_return_true(); + } + + /** + * Get the currently assigned user id. + * + * @return c_base_return_int + * User ID integer on success. + * 0 with error bit set is returned on error. + */ + public function get_id() { + if (!is_int($this->id)) { + $this->id = 0; + } + + return c_base_return_int::s_new($this->id); + } + + /** + * Get the currently assigned external user id. + * + * @return c_base_return_int + * External User ID integer on success. + * 0 with error bit set is returned on error. + */ + public function get_id_external() { + if (!is_int($this->id_external)) { + $this->id_external = 0; + } + + return c_base_return_int::s_new($this->id_external); + } + + /** + * Get the currently assigned sort id. + * + * @return c_base_return_int + * Sort integer on success. + * 0 with error bit set is returned on error. + */ + public function get_id_sort() { + if (!is_int($this->id_sort)) { + $this->id_sort = 0; + } + + return c_base_return_int::s_new($this->id_sort); + } + + /** + * Get the currently assigned machine name. + * + * @return c_base_return_string + * Machine name on success. + * An empty string with error bit set is returned on error. + */ + public function get_name_machine() { + if (!is_string($this->name_machine)) { + $this->name_machine = ''; + } + + return c_base_return_string::s_new($this->name_machine); + } + + /** + * Get the currently assigned human name. + * + * @return c_base_users_user_name + * Human name on success. + * Error bit is set is on error. + */ + public function get_name_human() { + if (!($this->name_human instanceof c_base_users_user_name)) { + $this->name_human = new c_base_users_user_name(); + } + + return clone($this->name_human); + } + + /** + * Get the currently assigned email address. + * + * @return c_base_return_null|c_base_return_array + * E-mail address array on success. + * Error bit is set is on error. + */ + public function get_address_email() { + if (is_null($this->address_email)) { + $this->address_email = new c_base_address_email(); + } + + return clone($this->address_email); + } + + /** * Wrapper to c_base_roles::get_role() * * @see: c_base_roles::get_role() @@ -143,6 +455,223 @@ class c_base_users_user extends c_base_return_array { } /** + * Get the currently assigned created date. + * + * @return c_base_return_null|c_base_return_int|c_base_return_float + * Date created on success. + * NULL without error bit is returned if not defined. + * NULL with error bit set is returned on error. + */ + public function get_date_created() { + if (is_null($this->date_created)) { + return new c_base_return_null(); + } + + if (is_float($this->date_created)) { + return c_base_return_float::s_new($this->date_created); + } + + return c_base_return_int::s_new($this->date_created); + } + + /** + * Get the currently assigned changed date. + * + * @return c_base_return_null|c_base_return_int|c_base_return_float + * Date changed on success. + * NULL without error bit is returned if not defined. + * NULL with error bit set is returned on error. + */ + public function get_date_changed() { + if (is_null($this->date_changed)) { + return new c_base_return_null(); + } + + if (is_float($this->date_changed)) { + return c_base_return_float::s_new($this->date_changed); + } + + return c_base_return_int::s_new($this->date_changed); + } + + /** + * Get the currently assigned synced date. + * + * @return c_base_return_null|c_base_return_int|c_base_return_float + * Date synced on success. + * NULL without error bit is returned if not defined. + * NULL with error bit set is returned on error. + */ + public function get_date_synced() { + if (is_null($this->date_synced)) { + return new c_base_return_null(); + } + + if (is_float($this->date_synced)) { + return c_base_return_float::s_new($this->date_synced); + } + + return c_base_return_int::s_new($this->date_synced); + } + + /** + * Get the currently assigned locked date. + * + * @return c_base_return_null|c_base_return_int|c_base_return_float + * Date locked on success. + * NULL without error bit is returned if not defined. + * NULL with error bit set is returned on error. + */ + public function get_date_locked() { + if (is_null($this->date_locked)) { + return new c_base_return_null(); + } + + if (is_float($this->date_locked)) { + return c_base_return_float::s_new($this->date_locked); + } + + return c_base_return_int::s_new($this->date_locked); + } + + /** + * Get the currently assigned deleted date. + * + * @return c_base_return_null|c_base_return_int|c_base_return_float + * Date deleted on success. + * NULL without error bit is returned if not defined. + * NULL with error bit set is returned on error. + */ + public function get_date_deleted() { + if (is_null($this->date_deleted)) { + return new c_base_return_null(); + } + + if (is_float($this->date_deleted)) { + return c_base_return_float::s_new($this->date_deleted); + } + + return c_base_return_int::s_new($this->date_deleted); + } + + /** + * Get the is private setting. + * + * @param bool|null $is_private + * When a boolean, this is assigned as the current is private setting. + * When NULL, the private setting is returned. + * + * @return c_base_return_bool|c_base_return_status + * When $is_private is NULL, is content boolean setting on success. + * FALSE with error bit is set on error. + */ + public function is_private($is_private = NULL) { + if (!is_null($is_private) && !is_bool($is_private)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_private', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (is_null($is_private)) { + if (!is_bool($this->is_private)) { + $this->is_private = TRUE; + } + + return c_base_return_bool::s_new($this->is_private); + } + + $this->is_private = $is_private; + return new c_base_return_true(); + } + + /** + * Get the is locked setting. + * + * @param bool|null $is_locked + * When a boolean, this is assigned as the current is locked setting. + * When NULL, the locked setting is returned. + * + * @return c_base_return_bool|c_base_return_status + * When $is_locked is NULL, is content boolean setting on success. + * FALSE with error bit is set on error. + */ + public function is_locked($is_locked = NULL) { + if (!is_null($is_locked) && !is_bool($is_locked)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_locked', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (is_null($is_locked)) { + if (!is_bool($this->is_locked)) { + $this->is_locked = FALSE; + } + + return c_base_return_bool::s_new($this->is_locked); + } + + $this->is_locked = $is_locked; + return new c_base_return_true(); + } + + /** + * Get the is deleted setting. + * + * @param bool|null $is_deleted + * When a boolean, this is assigned as the current is deleted setting. + * When NULL, the deleted setting is returned. + * + * @return c_base_return_bool|c_base_return_status + * When $is_deleted is NULL, is content boolean setting on success. + * FALSE with error bit is set on error. + */ + public function is_deleted($is_deleted = NULL) { + if (!is_null($is_deleted) && !is_bool($is_deleted)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'is_deleted', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (is_null($is_deleted)) { + if (!is_bool($this->is_deleted)) { + $this->is_deleted = FALSE; + } + + return c_base_return_bool::s_new($this->is_deleted); + } + + $this->is_deleted = $is_deleted; + return new c_base_return_true(); + } + + + /** + * Get the is can manage roles setting. + * + * @param bool|null $can_manage_roles + * When a boolean, this is assigned as the current can manage roles setting. + * When NULL, the can manage roles setting is returned. + * + * @return c_base_return_bool|c_base_return_status + * When $can_manage_roles is NULL, is content boolean setting on success. + * FALSE with error bit is set on error. + */ + public function can_manage_roles($can_manage_roles = NULL) { + if (!is_null($can_manage_roles) && !is_bool($can_manage_roles)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'can_manage_roles', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (is_null($can_manage_roles)) { + if (!is_bool($this->can_manage_roles)) { + $this->can_manage_roles = FALSE; + } + + return c_base_return_bool::s_new($this->can_manage_roles); + } + + $this->can_manage_roles = $can_manage_roles; + return new c_base_return_true(); + } + + /** * Load user account from the specified database. * * @param c_base_database &$databae @@ -159,9 +688,262 @@ class c_base_users_user extends c_base_return_array { * @return c_base_return_status * TRUE on success. * FALSE if unable to find roles. - * FALSE with error bit set on error. + * FALSE with error bit set is returned on error. */ public function do_load(&$database, $user_name_or_id = NULL, $administrative = FALSE) { return new c_base_return_false(); } } + +/** + * A class for managing human name of a user. + */ +class c_base_users_user_name extends c_base_return { + private $prefix; + private $first; + private $middle; + private $last; + private $suffix; + private $complete; + + /** + * Class constructor. + */ + public function __construct() { + parent::__construct(); + + $this->prefix = NULL; + $this->first = NULL; + $this->middle = NULL; + $this->last = NULL; + $this->suffix = NULL; + $this->complete = NULL; + } + + /** + * Class destructor. + */ + public function __destruct() { + unset($this->prefix); + unset($this->first); + unset($this->middle); + unset($this->last); + unset($this->suffix); + unset($this->complete); + + parent::__destruct(); + } + + /** + * @see: t_base_return_value::p_s_new() + */ + public static function s_new($value) { + return self::p_s_new($value, __CLASS__); + } + + /** + * @see: t_base_return_value::p_s_value() + */ + public static function s_value($return) { + return self::p_s_value($return, __CLASS__); + } + + /** + * @see: t_base_return_value_exact::p_s_value_exact() + */ + public static function s_value_exact($return) { + return self::p_s_value_exact($return, __CLASS__, array()); + } + + /** + * Set the prefix name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_prefix($prefix) { + if (!is_string($prefix)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'prefix', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->prefix = $prefix; + return new c_base_return_true(); + } + + /** + * Set the first name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_first($first) { + if (!is_string($first)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'first', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->first = $first; + return new c_base_return_true(); + } + + /** + * Set the middle name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_middle($middle) { + if (!is_string($middle)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'middle', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->middle = $middle; + return new c_base_return_true(); + } + + /** + * Set the last name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_last($last) { + if (!is_string($last)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'last', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->last = $last; + return new c_base_return_true(); + } + + /** + * Set the suffix name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_suffix($suffix) { + if (!is_string($suffix)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'suffix', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->suffix = $suffix; + return new c_base_return_true(); + } + + /** + * Set the complete name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function set_complete($complete) { + if (!is_string($complete)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'complete', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->complete = $complete; + return new c_base_return_true(); + } + + /** + * Set the prefix name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function get_prefix() { + if (!is_string($this->prefix)) { + $this->prefix = ''; + } + + return c_base_return_string::s_new($this->prefix); + } + + /** + * Set the first name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function get_first() { + if (!is_string($this->first)) { + $this->first = ''; + } + + return c_base_return_string::s_new($this->first); + } + + /** + * Set the middle name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function get_middle() { + if (!is_string($this->middle)) { + $this->middle = ''; + } + + return c_base_return_string::s_new($this->middle); + } + + /** + * Set the last name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function get_last() { + if (!is_string($this->last)) { + $this->last = ''; + } + + return c_base_return_string::s_new($this->last); + } + + /** + * Set the suffix name. + * + * @return c_base_return_status + * TRUE on success. + * FALSE with error bit set is returned on error. + */ + public function get_suffix() { + if (!is_string($this->suffix)) { + $this->suffix = ''; + } + + return c_base_return_string::s_new($this->suffix); + } + + /** + * Set the complete name. + * + * @return c_base_return_string + * String on success. + * An empty string with error bit set is returned on error. + */ + public function get_complete() { + if (!is_string($this->complete)) { + $this->complete = ''; + } + + return c_base_return_string::s_new($this->complete); + } +} diff --git a/common/standard/classes/standard_index.php b/common/standard/classes/standard_index.php index 2ef1a56..28e9edd 100644 --- a/common/standard/classes/standard_index.php +++ b/common/standard/classes/standard_index.php @@ -79,10 +79,11 @@ class c_standard_index extends c_base_return { $this->settings['ldap_fields'] = array(); // base settings - $this->settings['base_scheme'] = 'https'; - $this->settings['base_host'] = 'localhost'; - $this->settings['base_port'] = ''; // @todo: implement support for thus such that base_port is something like: ':8080' (as opposed to '8080'). - $this->settings['base_path'] = $this->settings['cookie_path']; // must end in a trailing slash. + $this->settings['base_scheme'] = 'https'; + $this->settings['base_host'] = 'localhost'; + $this->settings['base_port'] = ''; // @todo: implement support for thus such that base_port is something like: ':8080' (as opposed to '8080'). + $this->settings['base_path'] = '/'; // must end in a trailing slash. + $this->settings['base_path_prefix'] = ''; // identical to base_path, except there is no trailing slash. if (!isset($_SERVER["HTTPS"])) { $this->settings['base_scheme'] = 'http'; @@ -628,7 +629,6 @@ class c_standard_index extends c_base_return { - // send the session cookie if a session id is specified. $session_id = $this->session->get_session_id()->get_value_exact(); if (!empty($session_id)) { @@ -662,7 +662,7 @@ class c_standard_index extends c_base_return { } // process any unexpected, but captured, output (if the content is a file, silently ignore output). - if (ob_get_length() > 0 && $this->http->is_response_content_file() instanceof c_base_return_false) { + if (ob_get_length() > 0 && $this->http->is_response_content_file()->get_value() === FALSE) { $response_content = $this->http->get_response_content()->get_value_exact(); $this->http->set_response_content(ob_get_contents(), FALSE); $this->http->set_response_content($response_content); diff --git a/common/standard/classes/standard_path.php b/common/standard/classes/standard_path.php index 030d908..c93d20f 100644 --- a/common/standard/classes/standard_path.php +++ b/common/standard/classes/standard_path.php @@ -1,7 +1,7 @@ array(':{argument_name}' => 'http', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!($database instanceof c_base_database)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'database', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!($session instanceof c_base_session)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + if (!is_array($settings)) { + $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'settings', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT); + return c_base_return_error::s_false($error); + } + + $this->pr_assign_defaults($http, $database, $session, $settings); + + return new c_base_return_true(); + } + + /** * Get the breadcrumb for this path. * * The breadcrumb will be built by this function if it is not already built. @@ -145,6 +196,35 @@ class c_standard_path extends c_base_path { } /** + * Return the current path parts after the specified path. + * + * This is intended for handling the path parts as arguments. + * + * No sanitization is performed on these arguments. + * + * @param string $path_after + * The string to parse. + * + * @return c_base_return_array + * An array of url path parts. + * An empty array with error bit set on error. + */ + protected function pr_get_path_arguments($path_after) { + $path = $this->http->get_request_uri_relative($this->settings['base_path'])->get_value_exact(); + $path = preg_replace('@^' . $path_after . '(/|$)@i', '', $path); + + if (mb_strlen($path) == 0) { + unset($path); + return array(); + } + + $path_parts = explode('/', $path); + unset($path); + + return $path_parts; + } + + /** * Load any default settings. * * @param c_base_http &$http @@ -205,26 +285,87 @@ class c_standard_path extends c_base_path { * FALSE with error bit set is returned on error. */ protected function pr_build_breadcrumbs() { + if (!is_object($this->path_tree)) { + return new c_base_return_false(); + } + + $handler_settings = $this->path_tree->get_item_reset(); + if ($handler_settings instanceof c_base_return_false) { + unset($handler_settings); + return new c_base_return_false(); + } + $this->breadcrumbs = new c_base_menu_item(); - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); - $this->breadcrumbs->set_item($item); - unset($item); + // render the breadcrumbs for all appropriate paths as the default behavior. + // this does not include the last path tree item because that item should be this class. + $count = 0; + $total = $this->path_tree->get_items_count() - 1; + for (; $count < $total; $count++) { + if ($handler_settings instanceof c_base_return_false) { + $handler_settings = $this->path_tree->get_item_next(); + continue; + } - // @todo: implement a standard breadcrumb handler, that loads parents paths and any language-specific text. - // this may also need to use and load langauge-specific global path text. + $handler_settings = $handler_settings->get_value(); - // build breadcrumbs based on current uri path. - #if ($this->path_tree instanceof c_base_path_tree) { - # $id_group = $this->path_tree->get_id_group()->get_value_exact(); - # $items = $this->path_tree->get_items()->get_value_exact(); - #} - #else { - # $id_group = 0; - # $items = array(); - #} + if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { + $handler_settings = $this->path_tree->get_item_next(); + continue; + } + + if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) { + $handler_settings = $this->path_tree->get_item_next(); + continue; + } + + if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) { + $handler_settings = $this->path_tree->get_item_next(); + continue; + } + + require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); + + + $handler = NULL; + if (is_string($this->language_alias)) { + @include_once($handler_settings['include_directory'] . $this->language_alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); + + $handler_class = $handler_settings['handler'] . '_' . $this->language_alias; + if (class_exists($handler_class)) { + $handler = new $handler_class(); + } + unset($handler_class); + } - #$this->get_breadcrumbs(); + if (is_null($handler)) { + if (class_exists($handler_settings['handler'])) { + $handler = new $handler_settings['handler'](); + } + else { + unset($handler); + $handler_settings = $this->path_tree->get_item_next(); + continue; + } + } + + $handler->set_parameters($this->http, $this->database, $this->session, $this->settings); + $breadcrumbs = $handler->get_breadcrumbs(); + if ($breadcrumbs instanceof c_base_menu_item) { + $breadcrumbs = $breadcrumbs->get_items()->get_value_exact(); + foreach ($breadcrumbs as $breadcrumb) { + $this->breadcrumbs->set_item($breadcrumb); + } + unset($breadcrumb); + } + unset($breadcrumbs); + unset($handler); + unset($handler_settings); + + $handler_settings = $this->path_tree->get_item_next(); + } + unset($count); + unset($total); return new c_base_return_true(); } @@ -720,6 +861,51 @@ class c_standard_path extends c_base_path { } /** + * Creates the standard fieldset block, with an optional fieldset legend. + * + * This does not define the fieldset body, which is left to be defined by the caller. + * The fieldset body is generally assumed to be defined wih self::CSS_AS_FIELD_SET_CONTENT. + * + * @param int|string|null $text + * The text or the text code to use as the fieldset legend. + * If NULL, then no legend is generated.. + * @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. + * If NULL, then this is not assigned. + * + * @return c_base_markup_tag + * The generated markup tag. + */ + protected function pr_create_tag_fieldset($text, $arguments = array(), $id = NULL, $extra_class = NULL) { + $classes = array($this->settings['base_css'] . self::CSS_AS_PARAGRAPH_BLOCK, self::CSS_AS_PARAGRAPH_BLOCK); + if (is_string($extra_class)) { + $classes[] = $extra_class; + } + + $block = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_FIELD_SET, $id, $classes); + unset($classes); + + if (!is_null($text)) { + if (is_int($text)) { + $tag = c_theme_html::s_create_tag($this->text_type, NULL, array(self::CSS_AS_FIELD_SET_LEGEND), $this->pr_get_text($text, $arguments)); + } + else { + $tag = c_theme_html::s_create_tag($this->text_type, NULL, array(self::CSS_AS_FIELD_SET_LEGEND), $text); + } + + $block->set_tag($tag); + unset($tag); + } + + return $block; + } + + /** * Create a new HTML markup class with default settings populated. * * @param bool $real_page @@ -729,7 +915,7 @@ class c_standard_path extends c_base_path { * * @return c_base_return_status * TRUE on success. - * FALSE with error bit set on error. + * FALSE with error bit set is returned on error. * * @see: self::pr_create_html_add_primary_ids() * @see: self::pr_create_html_add_primary_classes() @@ -1173,6 +1359,10 @@ class c_standard_path extends c_base_path { * @param string|array|null $uri * (optional) The URI string or array the breadcrumb points to. * If NULL, then the uri is not assigned. + * + * @return c_base_menu_item + * The generated breadcrumb menu item. + * A generated menu item with the error bit set is returned on error. */ protected function pr_create_breadcrumbs_item($text, $uri = NULL) { $item = new c_base_menu_item(); @@ -1202,18 +1392,6 @@ class c_standard_path extends c_base_path { } /** - * Load breadcrumbs text for a supported language. - * - * @param int $index - * A number representing which block of text to return. - * @param array $arguments - * (optional) An array of arguments to convert into text. - */ - protected function pr_get_text_breadcrumbs($code, $arguments = array()) { - return ''; - } - - /** * Load text for a supported language. * * @param int $index diff --git a/common/standard/classes/standard_path_exception.php b/common/standard/classes/standard_path_exception.php new file mode 100644 index 0000000..6fbe40a --- /dev/null +++ b/common/standard/classes/standard_path_exception.php @@ -0,0 +1,99 @@ +path_tree)) { + return new c_base_return_false(); + } + + $this->breadcrumbs = new c_base_menu_item(); + + // exceptional pages do not exist at any path, so call the last item at the specified path and use its breadcrumb. + $handler_settings = $this->path_tree->get_item_end(); + $count = 0; + $total = $this->path_tree->get_items_count(); + for (; $count < $total; $count++) { + if ($handler_settings instanceof c_base_return_false) { + unset($handler_settings); + $handler_settings = $this->path_tree->get_item_prev(); + continue; + } + + $handler_settings = $handler_settings->get_value(); + + if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { + unset($handler_settings); + $handler_settings = $this->path_tree->get_item_prev(); + continue; + } + + if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) { + unset($handler_settings); + $handler_settings = $this->path_tree->get_item_prev(); + continue; + } + + if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) { + unset($handler_settings); + $handler_settings = $this->path_tree->get_item_prev(); + continue; + } + + require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); + + + $handler = NULL; + if (is_string($this->language_alias)) { + @include_once($handler_settings['include_directory'] . $this->language_alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); + + $handler_class = $handler_settings['handler'] . '_' . $this->language_alias; + if (class_exists($handler_class)) { + $handler = new $handler_class(); + } + unset($handler_class); + } + + if (is_null($handler)) { + if (class_exists($handler_settings['handler'])) { + $handler = new $handler_settings['handler'](); + } + else { + unset($handler); + unset($handler_settings); + $handler_settings = $this->path_tree->get_item_prev(); + continue; + } + } + + $handler->set_parameters($this->http, $this->database, $this->session, $this->settings); + $handler->set_path_tree($this->path_tree); + $breadcrumbs = $handler->get_breadcrumbs(); + if ($breadcrumbs instanceof c_base_menu_item) { + $breadcrumbs = $breadcrumbs->get_items()->get_value_exact(); + foreach ($breadcrumbs as $breadcrumb) { + $this->breadcrumbs->set_item($breadcrumb); + } + unset($breadcrumb); + } + unset($breadcrumbs); + unset($handler); + unset($handler_settings); + + break; + } + + return new c_base_return_true(); + } +} diff --git a/common/standard/classes/standard_paths.php b/common/standard/classes/standard_paths.php index 5d6d532..1c489af 100644 --- a/common/standard/classes/standard_paths.php +++ b/common/standard/classes/standard_paths.php @@ -21,10 +21,15 @@ class c_standard_paths extends c_base_return { const URI_DASHBOARD_ADMINISTER = 'a/dashboard'; const URI_USER_CREATE = 'u/create'; const URI_USER_VIEW = 'u/view'; - const URI_USER_SETTINGS = 'u/settings'; + const URI_USER_EDIT = 'u/edit'; const URI_USER_LOCK = 'u/lock'; 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_PS = 'u/ps'; protected const PATH_INTERNAL = 'common/standard/internal/'; protected const PATH_USER = 'common/standard/paths/u/'; @@ -44,10 +49,13 @@ class c_standard_paths extends c_base_return { protected const NAME_INDEX = 'index'; protected const NAME_USER_CREATE = 'user_create'; protected const NAME_USER_VIEW = 'user_view'; - protected const NAME_USER_SETTINGS = 'user_settings'; + protected const NAME_USER_EDIT = 'user_edit'; protected const NAME_USER_LOCK = 'user_lock'; 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_PS = 'user_ps'; protected const HANDLER_LOGIN = 'c_standard_path_user_login'; protected const HANDLER_LOGOUT = 'c_standard_path_user_logout'; @@ -62,10 +70,13 @@ class c_standard_paths extends c_base_return { protected const HANDLER_INDEX = 'c_standard_path_index'; protected const HANDLER_USER_CREATE = 'c_standard_path_user_create'; protected const HANDLER_USER_VIEW = 'c_standard_path_user_view'; - protected const HANDLER_USER_SETTINGS = 'c_standard_path_user_settings'; + protected const HANDLER_USER_EDIT = 'c_standard_path_user_edit'; protected const HANDLER_USER_LOCK = 'c_standard_path_user_lock'; 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_PS = 'c_standard_path_user_ps'; protected const SCRIPT_EXTENSION = '.php'; protected const WILDCARD_PATH = '/%'; @@ -291,10 +302,65 @@ class c_standard_paths extends c_base_return { } - // load all available paths. + // load always available paths. $this->pr_paths_create(); + // load the remaining paths based on the relative path to avoid generating and processing unnecessary paths. + $path = $this->http->get_request_uri_relative($settings['base_path'])->get_value_exact(); + + $id_group = 0; + $path_object = new c_base_path(); + if ($path_object->set_value($path)) { + $sanitized = $path_object->get_value_exact(); + unset($path_object); + + $path_parts = explode('/', $sanitized); + unset($sanitized); + + if (mb_strlen($path_parts[0]) == 1) { + $ordinal = ord($path_parts[0]); + if (in_array($ordinal, c_base_defaults_global::RESERVED_PATH_GROUP)) { + $id_group = $ordinal; + } + unset($ordinal); + } + unset($path_parts); + } + + if ($id_group === c_base_ascii::LOWER_A) { + $this->pr_paths_create_administer(); + } + elseif ($id_group === c_base_ascii::LOWER_C) { + $this->pr_paths_create_cache(); + } + elseif ($id_group === c_base_ascii::LOWER_D) { + $this->pr_paths_create_data(); + } + elseif ($id_group === c_base_ascii::LOWER_F) { + $this->pr_paths_create_file(); + } + elseif ($id_group === c_base_ascii::LOWER_M) { + $this->pr_paths_create_management(); + } + elseif ($id_group === c_base_ascii::LOWER_S) { + $this->pr_paths_create_submit(); + } + elseif ($id_group === c_base_ascii::LOWER_T) { + $this->pr_paths_create_theme(); + } + elseif ($id_group === c_base_ascii::LOWER_U) { + $this->pr_paths_create_user(); + } + elseif ($id_group === c_base_ascii::LOWER_X) { + $this->pr_paths_create_ajax(); + } + else { + $this->pr_paths_create_ungrouped(); + } + unset($id_group); + + // load the http method. $method = $this->http->get_request(c_base_http::REQUEST_METHOD)->get_value_exact(); if (isset($method['data']) && is_int($method['data'])) { @@ -306,7 +372,6 @@ class c_standard_paths extends c_base_return { // find the path - $path = $this->http->get_request_uri_relative($settings['base_path'])->get_value_exact(); $handler_settings = $this->paths->find_path($path)->get_value(); unset($path); @@ -515,12 +580,9 @@ class c_standard_paths extends c_base_return { } /** - * Creates and returns a list of all available paths. + * Creates a list of always available paths. * * Add/modify paths here as desired. - * - * @return c_base_paths - * The generated paths object. */ protected function pr_paths_create() { $this->paths = new c_base_paths(); @@ -531,25 +593,114 @@ class c_standard_paths extends c_base_return { // create login/logout paths $this->paths->add_path(self::URI_LOGIN, self::HANDLER_LOGIN, self::PATH_USER, self::NAME_LOGIN); $this->paths->add_path(self::URI_LOGOUT, self::HANDLER_LOGOUT, self::PATH_USER, self::NAME_LOGOUT); + } + /** + * Creates a list of available administer paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_administer() { // dashboards - $this->paths->add_path(self::URI_DASHBOARD_USER, self::HANDLER_USER_DASHBOARD, self::PATH_USER, self::NAME_DASHBOARD_USER); - $this->paths->add_path(self::URI_DASHBOARD_MANAGEMENT, self::HANDLER_MANAGEMENT_DASHBOARD, self::PATH_MANAGEMENT, self::NAME_DASHBOARD_MANAGEMENT); $this->paths->add_path(self::URI_DASHBOARD_ADMINISTER, self::HANDLER_ADMINISTER_DASHBOARD, self::PATH_ADMINISTER, self::NAME_DASHBOARD_ADMINISTER); + } + + /** + * Creates a list of available cache paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_cache() { + } + + /** + * Creates a list of available data paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_data() { + } + + /** + * Creates a list of available file paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_file() { + } + + /** + * Creates a list of available submit paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_submit() { + } + + /** + * Creates a list of available management paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_management() { + // dashboards + $this->paths->add_path(self::URI_DASHBOARD_MANAGEMENT, self::HANDLER_MANAGEMENT_DASHBOARD, self::PATH_MANAGEMENT, self::NAME_DASHBOARD_MANAGEMENT); + } + + /** + * Creates a list of available theme paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_theme() { + } + + /** + * Creates a list of available ajax paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_ajax() { + } + + /** + * Creates a list of available user paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_user() { + // dashboards + $this->paths->add_path(self::URI_DASHBOARD_USER, self::HANDLER_USER_DASHBOARD, self::PATH_USER, self::NAME_DASHBOARD_USER); // user paths $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_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_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_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); + } + + /** + * Creates a list of available paths that are not assigned to any groups. + * + * These are generally user-defined paths. + * + * Add/modify paths here as desired. + */ + protected function pr_paths_create_ungrouped() { } /** @@ -575,7 +726,7 @@ class c_standard_paths extends c_base_return { if ($this->handler->is_private()->get_value_exact()) { if ($this->session->is_logged_in()->get_value_exact()) { unset($id_group); - return $this->handler->do_execute($this->http, $this->database, $this->session, $this->settings); + return $this->p_handle_execution_errors($this->handler->do_execute($this->http, $this->database, $this->session, $this->settings)); } elseif ($this->handler->is_root()->get_value_exact()) { unset($id_group); @@ -587,7 +738,7 @@ class c_standard_paths extends c_base_return { $path_login->set_path_tree($this->handler->get_path_tree()); } - return $path_login->do_execute($this->http, $this->database, $this->session, $this->settings); + return $this->p_handle_execution_errors($path_login->do_execute($this->http, $this->database, $this->session, $this->settings)); } else { if ($id_group === c_base_ascii::LOWER_U) { @@ -613,7 +764,7 @@ class c_standard_paths extends c_base_return { $path_login->set_path_tree($this->handler->get_path_tree()); } - return $path_login->do_execute($this->http, $this->database, $this->session, $this->settings); + return $this->p_handle_execution_errors($path_login->do_execute($this->http, $this->database, $this->session, $this->settings)); } // some special case paths always provide login prompt along with access denied. @@ -627,13 +778,13 @@ class c_standard_paths extends c_base_return { $path_login->set_path_tree($this->handler->get_path_tree()); } - return $path_login->do_execute($this->http, $this->database, $this->session, $this->settings); + return $this->p_handle_execution_errors($path_login->do_execute($this->http, $this->database, $this->session, $this->settings)); } } } else { unset($id_group); - return $this->handler->do_execute($this->http, $this->database, $this->session, $this->settings); + return $this->p_handle_execution_errors($this->handler->do_execute($this->http, $this->database, $this->session, $this->settings)); } // return access denied or page not found depending on path and privacy settings. @@ -775,4 +926,47 @@ class c_standard_paths extends c_base_return { // if unable to find, fallback to original class return new $class(); } + + /** + * Check to see if errors occured and change the return execution object accordingly. + * + * This will usually either return path not found, access denied, or server error, on such errors. + * Do not call this on the error handling paths. + * + * @param c_base_path_executed $executed + * The already executed path handler result. + * + * @return c_base_path_executed + * The already executed path handler result. + */ + private function p_handle_execution_errors($executed) { + if (!c_base_return::s_has_error($executed)) { + return $executed; + } + + // handle errors here. + $error = $executed->get_error(0); + $error_code = $error->get_code(); + unset($error); + + if ($error_code === i_base_error_messages::NOT_FOUND_PATH || $error_code === i_base_error_messages::INVALID_ARGUMENT) { + $handler_error = $this->get_handler_not_found(); + } + elseif ($error_code === i_base_error_messages::ACCESS_DENIED) { + $handler_error = $this->get_handler_access_denied(); + } + else { + $handler_error = $this->get_handler_server_error(); + } + unset($error_code); + + if ($this->handler->get_path_tree() instanceof c_base_path_tree) { + $handler_error->set_path_tree($this->handler->get_path_tree()); + } + + $executed_error = $handler_error->do_execute($this->http, $this->database, $this->session, $this->settings); + unset($handler_error); + + return $executed_error; + } } diff --git a/common/standard/classes/standard_users.php b/common/standard/classes/standard_users.php index 9f9124e..46d6cb3 100644 --- a/common/standard/classes/standard_users.php +++ b/common/standard/classes/standard_users.php @@ -79,7 +79,7 @@ class c_standard_users_user extends c_base_users_user { $query_string .= 'from v_users_self_session'; } else { - if ($use_table) { + if ($administrative) { $query_string .= 'from s_tables.t_users '; } else { @@ -89,12 +89,12 @@ class c_standard_users_user extends c_base_users_user { $query_string .= 'where '; if (is_int($user_name_or_id)) { - $query_string .= 'id = :{id} '; - $query_arguments[':{id}'] = $user_name_or_id; + $query_string .= 'id = $1 '; + $query_arguments[] = $user_name_or_id; } else { - $query_string .= 'name_machine = :{name_machine} '; - $query_arguments[':{name_machine}'] = $user_name_or_id; + $query_string .= 'name_machine = $1 '; + $query_arguments[] = $user_name_or_id; } } @@ -106,6 +106,7 @@ class c_standard_users_user extends c_base_users_user { $false = c_base_return_error::s_false($query_result->get_error()); $last_error = $database->get_last_error()->get_value_exact(); + var_dump($last_error); if (!empty($last_error)) { $error = c_base_error::s_log(NULL, array('arguments' => array(':{database_error_message}' => $last_error, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::POSTGRESQL_ERROR); $false->set_error($error); @@ -115,8 +116,6 @@ class c_standard_users_user extends c_base_users_user { return $false; } - // @todo: this processes special postgresql datatypes. - // write custom handling functions and classes to handle things such as the 't' and 'f' for boolean types. $columns = $query_result->fetch_row()->get_value(); if (is_array($columns) && !empty($columns)) { @@ -127,35 +126,32 @@ class c_standard_users_user extends c_base_users_user { $this->id_sort = (int) $columns[2]; $this->name_machine = (string) $columns[3]; - $this->name_human = (string) $columns[4]; - - // @todo: write functions for managing special postgresql types, such as this (possibly using special class types). - $this->address_email = array( - 'name' => NULL, - 'domain' => NULL, - 'private' => TRUE, - ); - - $address_email = (string) $columns[5]; - if (!empty($address_email)) { - $address_email = mb_substr($address_email, 1); - $address_email = mb_substr($address_email, 0, mb_strlen($address_email) - 1); - $address_email_parts = explode(',', $address_email); - unset($address_email); - - if (count($address_email_parts) == 3) { - $this->address_email = array( - 'name' => $address_email_parts[0], - 'domain' => $address_email_parts[1], - 'private' => TRUE, - ); - - if ($address_email_parts[2] == 'f') { - $this->address_email['private'] = FALSE; - } + + $this->name_human = new c_base_users_user_name(); + $name_human_parts = c_base_database::s_explode_array((string) $columns[4])->get_value_exact(); + if (count($name_human_parts) == 6) { + $this->name_human->set_prefix($name_human_parts[0]); + $this->name_human->set_first($name_human_parts[1]); + $this->name_human->set_middle($name_human_parts[2]); + $this->name_human->set_last($name_human_parts[3]); + $this->name_human->set_suffix($name_human_parts[4]); + $this->name_human->set_complete($name_human_parts[5]); + } + + $this->address_email = new c_base_address_email(); + $address_email_parts = c_base_database::s_explode_array((string) $columns[5])->get_value_exact(); + if (count($address_email_parts) == 3) { + $this->address_email->set_name($address_email_parts[0]); + $this->address_email->set_domain($address_email_parts[1]); + + if ($address_email_parts[2] == 'f') { + $this->address_email->is_private(FALSE); + } + else { + $this->address_email->is_private(TRUE); } - unset($address_email_parts); } + unset($address_email_parts); if ($columns[6] == 't') { $this->roles->set_role(c_base_roles::PUBLIC, TRUE); diff --git a/common/standard/internal/access_denied.php b/common/standard/internal/access_denied.php index c299ef0..582a8ee 100644 --- a/common/standard/internal/access_denied.php +++ b/common/standard/internal/access_denied.php @@ -7,69 +7,11 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_http_status.php'); -require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_exception.php'); require_once('common/theme/classes/theme_html.php'); -class c_standard_path_access_denied extends c_standard_path { - - /** - * Implementation of pr_build_breadcrumbs(). - */ - protected function pr_build_breadcrumbs() { - if (!is_object($this->path_tree)) { - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $this->path_tree->get_item_reset(); - if ($handler_settings instanceof c_base_return_false) { - unset($handler_settings); - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $handler_settings->get_value(); - - if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) { - return parent::pr_build_breadcrumbs(); - } - - require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - - $handler = NULL; - if (is_string($this->language_alias)) { - @include_once($handler_settings['include_directory'] . $this->language_alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - $handler_class = $handler_settings['handler'] . '_' . $this->language_alias; - if (class_exists($handler_class)) { - $handler = new $handler_class(); - } - unset($handler_class); - } - - if (is_null($handler)) { - if (class_exists($handler_settings['handler'])) { - $handler = new $handler_settings['handler'](); - } - else { - unset($handler); - return parent::pr_build_breadcrumbs(); - } - } - - $this->breadcrumbs = $handler->get_breadcrumbs(); - unset($handler); - - return new c_base_return_true(); - } +class c_standard_path_access_denied extends c_standard_path_exception { /** * Implements do_execute(). diff --git a/common/standard/internal/bad_method.php b/common/standard/internal/bad_method.php index 9bef3e0..085333f 100644 --- a/common/standard/internal/bad_method.php +++ b/common/standard/internal/bad_method.php @@ -7,69 +7,11 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_http_status.php'); -require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_exception.php'); require_once('common/theme/classes/theme_html.php'); -class c_standard_path_bad_method extends c_standard_path { - - /** - * Implementation of pr_build_breadcrumbs(). - */ - protected function pr_build_breadcrumbs() { - if (!is_object($this->path_tree)) { - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $this->path_tree->get_item_reset(); - if ($handler_settings instanceof c_base_return_false) { - unset($handler_settings); - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $handler_settings->get_value(); - - if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) { - return parent::pr_build_breadcrumbs(); - } - - require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - - $handler = NULL; - if (is_string($this->language_alias)) { - @include_once($handler_settings['include_directory'] . $this->language_alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - $handler_class = $handler_settings['handler'] . '_' . $this->language_alias; - if (class_exists($handler_class)) { - $handler = new $handler_class(); - } - unset($handler_class); - } - - if (is_null($handler)) { - if (class_exists($handler_settings['handler'])) { - $handler = new $handler_settings['handler'](); - } - else { - unset($handler); - return parent::pr_build_breadcrumbs(); - } - } - - $this->breadcrumbs = $handler->get_breadcrumbs(); - unset($handler); - - return new c_base_return_true(); - } +class c_standard_path_bad_method extends c_standard_path_exception { /** * Implements do_execute(). diff --git a/common/standard/internal/index.php b/common/standard/internal/index.php index 587f94d..a15169e 100644 --- a/common/standard/internal/index.php +++ b/common/standard/internal/index.php @@ -20,7 +20,7 @@ class c_standard_path_index extends c_standard_path { protected function pr_build_breadcrumbs() { $this->breadcrumbs = new c_base_menu_item(); - $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(2), ''); $this->breadcrumbs->set_item($item); unset($item); @@ -64,24 +64,6 @@ class c_standard_path_index extends c_standard_path { } /** - * Implements pr_get_text_breadcrumbs(). - */ - protected function pr_get_text_breadcrumbs($code, $arguments = array()) { - $string = ''; - switch ($code) { - case 0: - $string = 'Home'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { @@ -93,6 +75,9 @@ class c_standard_path_index extends c_standard_path { case 1: $string = 'This is the standard system index page.'; break; + case 2: + $string = 'Home'; + break; } if (!empty($arguments)) { diff --git a/common/standard/internal/ja/access_denied.php b/common/standard/internal/ja/access_denied.php index 8abe4a9..c8b3eb9 100644 --- a/common/standard/internal/ja/access_denied.php +++ b/common/standard/internal/ja/access_denied.php @@ -10,23 +10,6 @@ final class c_standard_path_access_denied_ja extends c_standard_path_access_denied { /** - * Implements pr_get_text_breadcrumbs(). - */ - protected function pr_get_text_breadcrumbs($code, $arguments = array()) { - switch ($code) { - case 0: - $string = 'ホームページ'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/bad_method.php b/common/standard/internal/ja/bad_method.php index 3f2ce15..3cb3abb 100644 --- a/common/standard/internal/ja/bad_method.php +++ b/common/standard/internal/ja/bad_method.php @@ -10,23 +10,6 @@ final class c_standard_path_bad_method_ja extends c_standard_path_bad_method { /** - * Implements pr_get_text_breadcrumbs(). - */ - protected function pr_get_text_breadcrumbs($code, $arguments = array()) { - switch ($code) { - case 0: - $string = 'ホームページ'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/index.php b/common/standard/internal/ja/index.php index 24ac131..4f50656 100644 --- a/common/standard/internal/ja/index.php +++ b/common/standard/internal/ja/index.php @@ -10,23 +10,6 @@ final class c_standard_path_index_ja extends c_standard_path_index { /** - * Implements pr_get_text_breadcrumbs(). - */ - protected function pr_get_text_breadcrumbs($code, $arguments = array()) { - switch ($code) { - case 0: - $string = 'ホームページ'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { @@ -38,6 +21,9 @@ final class c_standard_path_index_ja extends c_standard_path_index { case 1: $string = 'これは標準のシステムインデックスページです。'; break; + case 2: + $string = 'ホームページ'; + break; } if (!empty($arguments)) { diff --git a/common/standard/internal/ja/not_found.php b/common/standard/internal/ja/not_found.php index 1edf33a..b3a776c 100644 --- a/common/standard/internal/ja/not_found.php +++ b/common/standard/internal/ja/not_found.php @@ -10,23 +10,6 @@ final class c_standard_path_not_found_ja extends c_standard_path_not_found { /** - * Implements pr_get_text_breadcrumbs(). - */ - protected function pr_get_text_breadcrumbs($code, $arguments = array()) { - switch ($code) { - case 0: - $string = 'ホームページ'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/ja/server_error.php b/common/standard/internal/ja/server_error.php index 8e9cf5f..97f5fe9 100644 --- a/common/standard/internal/ja/server_error.php +++ b/common/standard/internal/ja/server_error.php @@ -10,23 +10,6 @@ final class c_standard_path_server_error_ja extends c_standard_path_server_error { /** - * Implements pr_get_text_breadcrumbs(). - */ - protected function pr_get_text_breadcrumbs($code, $arguments = array()) { - switch ($code) { - case 0: - $string = 'ホームページ'; - break; - } - - if (!empty($arguments)) { - $this->pr_process_replacements($string, $arguments); - } - - return $string; - } - - /** * Implements pr_get_text(). */ protected function pr_get_text($code, $arguments = array()) { diff --git a/common/standard/internal/not_found.php b/common/standard/internal/not_found.php index 621dc50..5f691f9 100644 --- a/common/standard/internal/not_found.php +++ b/common/standard/internal/not_found.php @@ -7,69 +7,11 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_http_status.php'); -require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_exception.php'); require_once('common/theme/classes/theme_html.php'); -class c_standard_path_not_found extends c_standard_path { - - /** - * Implementation of pr_build_breadcrumbs(). - */ - protected function pr_build_breadcrumbs() { - if (!is_object($this->path_tree)) { - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $this->path_tree->get_item_reset(); - if ($handler_settings instanceof c_base_return_false) { - unset($handler_settings); - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $handler_settings->get_value(); - - if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) { - return parent::pr_build_breadcrumbs(); - } - - require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - - $handler = NULL; - if (is_string($this->language_alias)) { - @include_once($handler_settings['include_directory'] . $this->language_alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - $handler_class = $handler_settings['handler'] . '_' . $this->language_alias; - if (class_exists($handler_class)) { - $handler = new $handler_class(); - } - unset($handler_class); - } - - if (is_null($handler)) { - if (class_exists($handler_settings['handler'])) { - $handler = new $handler_settings['handler'](); - } - else { - unset($handler); - return parent::pr_build_breadcrumbs(); - } - } - - $this->breadcrumbs = $handler->get_breadcrumbs(); - unset($handler); - - return new c_base_return_true(); - } +class c_standard_path_not_found extends c_standard_path_exception { /** * Implements do_execute(). diff --git a/common/standard/internal/server_error.php b/common/standard/internal/server_error.php index 0930145..79aafa6 100644 --- a/common/standard/internal/server_error.php +++ b/common/standard/internal/server_error.php @@ -7,69 +7,11 @@ require_once('common/base/classes/base_return.php'); require_once('common/base/classes/base_http_status.php'); -require_once('common/standard/classes/standard_path.php'); +require_once('common/standard/classes/standard_path_exception.php'); require_once('common/theme/classes/theme_html.php'); -class c_standard_path_server_error extends c_standard_path { - - /** - * Implementation of pr_build_breadcrumbs(). - */ - protected function pr_build_breadcrumbs() { - if (!is_object($this->path_tree)) { - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $this->path_tree->get_item_reset(); - if ($handler_settings instanceof c_base_return_false) { - unset($handler_settings); - return parent::pr_build_breadcrumbs(); - } - - $handler_settings = $handler_settings->get_value(); - - if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['include_directory']) || !is_string($handler_settings['include_directory'])) { - return parent::pr_build_breadcrumbs(); - } - - if (!isset($handler_settings['handler']) || !is_string($handler_settings['handler'])) { - return parent::pr_build_breadcrumbs(); - } - - require_once($handler_settings['include_directory'] . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - - $handler = NULL; - if (is_string($this->language_alias)) { - @include_once($handler_settings['include_directory'] . $this->language_alias . '/' . $handler_settings['include_name'] . self::SCRIPT_EXTENSION); - - $handler_class = $handler_settings['handler'] . '_' . $this->language_alias; - if (class_exists($handler_class)) { - $handler = new $handler_class(); - } - unset($handler_class); - } - - if (is_null($handler)) { - if (class_exists($handler_settings['handler'])) { - $handler = new $handler_settings['handler'](); - } - else { - unset($handler); - return parent::pr_build_breadcrumbs(); - } - } - - $this->breadcrumbs = $handler->get_breadcrumbs(); - unset($handler); - - return new c_base_return_true(); - } +class c_standard_path_server_error extends c_standard_path_exception { /** * Implements do_execute(). diff --git a/common/standard/menus/menu_utility.php b/common/standard/menus/menu_utility.php index 0cfcbb7..3d0e1f6 100644 --- a/common/standard/menus/menu_utility.php +++ b/common/standard/menus/menu_utility.php @@ -65,7 +65,7 @@ class c_standard_menu_utility extends c_standard_menu { unset($item); } - $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(6), $settings['base_path'] . c_standard_paths::URI_USER_SETTINGS); + $item = $this->pr_create_html_add_menu_item_link($this->pr_get_text(6), $settings['base_path'] . c_standard_paths::URI_USER_VIEW); $item->set_attribute(c_base_markup_attributes::ATTRIBUTE_CLASS, self::CLASS_USER_SETTINGS); $menu->set_tag($item); unset($item); diff --git a/common/standard/paths/u/dashboard.php b/common/standard/paths/u/dashboard.php index 61b0568..1513ae2 100644 --- a/common/standard/paths/u/dashboard.php +++ b/common/standard/paths/u/dashboard.php @@ -16,6 +16,28 @@ class c_standard_path_user_dashboard extends c_standard_path { protected const PATH_SELF = 'u/dashboard'; /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Implements do_execute(). */ public function do_execute(&$http, &$database, &$session, $settings = array()) { @@ -107,6 +129,8 @@ class c_standard_path_user_dashboard extends c_standard_path { $this->html->set_tag($wrapper); unset($wrapper); + $this->pr_add_menus(); + $executed->set_output($this->html); unset($this->html); diff --git a/common/standard/paths/u/ja/user_create.php b/common/standard/paths/u/ja/user_create.php index 90d41cd..3cd6368 100644 --- a/common/standard/paths/u/ja/user_create.php +++ b/common/standard/paths/u/ja/user_create.php @@ -5,9 +5,9 @@ */ /** - * Implements c_standard_path_user_dashboard(). + * Implements c_standard_path_user_create(). */ -class c_standard_path_user_dashboard_ja extends c_standard_path_user_dashboard { +class c_standard_path_user_create_ja extends c_standard_path_user_create { /** * Implements pr_get_text(). diff --git a/common/standard/paths/u/ja/user_delete.php b/common/standard/paths/u/ja/user_delete.php index 90d41cd..9140879 100644 --- a/common/standard/paths/u/ja/user_delete.php +++ b/common/standard/paths/u/ja/user_delete.php @@ -5,9 +5,9 @@ */ /** - * Implements c_standard_path_user_dashboard(). + * Implements c_standard_path_user_delete(). */ -class c_standard_path_user_dashboard_ja extends c_standard_path_user_dashboard { +class c_standard_path_user_delete_ja extends c_standard_path_user_delete { /** * Implements pr_get_text(). diff --git a/common/standard/paths/u/ja/user_edit.php b/common/standard/paths/u/ja/user_edit.php new file mode 100644 index 0000000..e7dc4cb --- /dev/null +++ b/common/standard/paths/u/ja/user_edit.php @@ -0,0 +1,134 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_lock.php b/common/standard/paths/u/ja/user_lock.php index 90d41cd..ef2303e 100644 --- a/common/standard/paths/u/ja/user_lock.php +++ b/common/standard/paths/u/ja/user_lock.php @@ -5,9 +5,9 @@ */ /** - * Implements c_standard_path_user_dashboard(). + * Implements c_standard_path_user_lock(). */ -class c_standard_path_user_dashboard_ja extends c_standard_path_user_dashboard { +class c_standard_path_user_lock_ja extends c_standard_path_user_lock { /** * Implements pr_get_text(). diff --git a/common/standard/paths/u/ja/user_pdf.php b/common/standard/paths/u/ja/user_pdf.php new file mode 100644 index 0000000..49866f3 --- /dev/null +++ b/common/standard/paths/u/ja/user_pdf.php @@ -0,0 +1,29 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_print.php b/common/standard/paths/u/ja/user_print.php new file mode 100644 index 0000000..49b5728 --- /dev/null +++ b/common/standard/paths/u/ja/user_print.php @@ -0,0 +1,29 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_ps.php b/common/standard/paths/u/ja/user_ps.php new file mode 100644 index 0000000..cd675c6 --- /dev/null +++ b/common/standard/paths/u/ja/user_ps.php @@ -0,0 +1,29 @@ +pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/ja/user_unlock.php b/common/standard/paths/u/ja/user_unlock.php index 90d41cd..5bacc6a 100644 --- a/common/standard/paths/u/ja/user_unlock.php +++ b/common/standard/paths/u/ja/user_unlock.php @@ -1,13 +1,13 @@ pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(1), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** + * 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; + }; + + $this->pr_assign_defaults($http, $database, $session, $settings); + + $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; + } + else { + unset($arguments_total); + unset($argument); + 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; + } + + if ($arguments_total > 1) { + $argument = next($arguments); + + if ($argument == 'print') { + // @todo: execute custom print function and then return. + } + elseif ($argument == 'pdf') { + // @todo: execute custom pdf function and then return. + } + elseif ($argument == 'ps') { + // @todo: execute custom postscript function and then return. + } + } + unset($arguments_total); + unset($argument); + 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; + } + unset($arguments); + + if (is_null($id_user)) { + // load current user + } + else { + // @todo: validate if user exists.unset($arguments_total); + + // @todo: on not found, provide page not found. + } + + $this->p_do_execute_view($executed, $this->p_get_user_id_current()); + unset($id_user); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'User Settings'; + break; + case 1: + $string = ''; + break; + case 2: + $string = ''; + break; + case 3: + $string = ''; + break; + case 4: + $string = 'Public'; + break; + case 5: + $string = 'User'; + break; + case 6: + $string = 'Requester'; + break; + case 7: + $string = 'Drafter'; + break; + case 8: + $string = 'Editor'; + break; + case 9: + $string = 'Reviewer'; + break; + case 10: + $string = 'Financer'; + break; + case 11: + $string = 'Insurer'; + break; + case 12: + $string = 'Publisher'; + break; + case 13: + $string = 'Auditor'; + break; + case 14: + $string = 'Manager'; + break; + case 15: + $string = 'Administer'; + break; + case 16: + $string = 'Account Information'; + break; + case 17: + $string = 'Personal Information'; + break; + case 18: + $string = 'Access Information'; + break; + case 19: + $string = 'History Information'; + break; + case 20: + if (array_key_exists(':{user_name}', $arguments)) { + $string = 'View User: :{user_name}'; + } + else { + $string = 'View User'; + } + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } + + /** + * Load and return the user argument + * + * @param array &$arguments + * The array of arguments to process. + * @param int $arguments_total + * The total number of arguments. + * @param bool &$found + * Boolean designating if the path is valid, otherwise page not found is returned. + * + * @return int + * The user id integer. + */ + private function p_get_argument_user(&$arguments, $arguments_total, &$found) { + $argument = 0; + if ($arguments_total == 1) { + // @todo: load current user id. + } + else { + $argument = next($arguments); + if (is_numeric($argument)) { + $argument = (int) $argument; + } + else { + $found = FALSE; + } + + // @todo: check the user id in the database. + } + + // if user id is 0, invalid, or a special case, then provide page not found. + if ($argument == 0) { + $found = FALSE; + } + + return $argument; + } +} diff --git a/common/standard/paths/u/user_lock.php b/common/standard/paths/u/user_lock.php index 73b3fdd..f962a0f 100644 --- a/common/standard/paths/u/user_lock.php +++ b/common/standard/paths/u/user_lock.php @@ -1,7 +1,7 @@ pr_assign_defaults($http, $database, $session, $settings); + + $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); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Lock User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_print.php b/common/standard/paths/u/user_print.php new file mode 100644 index 0000000..d310553 --- /dev/null +++ b/common/standard/paths/u/user_print.php @@ -0,0 +1,79 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $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); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Lock User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_ps.php b/common/standard/paths/u/user_ps.php new file mode 100644 index 0000000..eda5323 --- /dev/null +++ b/common/standard/paths/u/user_ps.php @@ -0,0 +1,79 @@ +pr_assign_defaults($http, $database, $session, $settings); + + $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); + + $executed->set_output($this->html); + unset($this->html); + + return $executed; + } + + /** + * Implementation of pr_create_html_add_header_link_canonical(). + */ + protected function pr_create_html_add_header_link_canonical() { + $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_LINK); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_REL, 'canonical'); + $tag->set_attribute(c_base_markup_attributes::ATTRIBUTE_HREF, $this->settings['base_scheme'] . '://' . $this->settings['base_host'] . $this->settings['base_port'] . $this->settings['base_path'] . self::PATH_SELF); + $this->html->set_header($tag); + + unset($tag); + } + + /** + * Implements pr_get_text_title(). + */ + protected function pr_get_text_title($arguments = array()) { + return $this->pr_get_text(0, $arguments); + } + + /** + * Implements pr_get_text(). + */ + protected function pr_get_text($code, $arguments = array()) { + $string = ''; + switch ($code) { + case 0: + $string = 'Lock User'; + break; + } + + if (!empty($arguments)) { + $this->pr_process_replacements($string, $arguments); + } + + return $string; + } +} diff --git a/common/standard/paths/u/user_settings.php b/common/standard/paths/u/user_settings.php index 4cced3f..74d3e1c 100644 --- a/common/standard/paths/u/user_settings.php +++ b/common/standard/paths/u/user_settings.php @@ -12,9 +12,14 @@ require_once('common/standard/classes/standard_path.php'); require_once('common/theme/classes/theme_html.php'); -class c_standard_path_user_dashboard extends c_standard_path { +class c_standard_path_user_settings extends c_standard_path { protected const PATH_SELF = 'u/settings'; + protected const CLASS_USER_SETTINGS_ACCOUNT = 'user_settings-account'; + protected const CLASS_USER_SETTINGS_PERSONAL = 'user_settings-personal'; + protected const CLASS_USER_SETTINGS_ACCESS = 'user_settings-access'; + protected const CLASS_USER_SETTINGS_HISTORY = 'user_settings-history'; + /** * Implements do_execute(). */ @@ -27,15 +32,12 @@ class c_standard_path_user_dashboard extends c_standard_path { $this->pr_assign_defaults($http, $database, $session, $settings); - $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); + $arguments = $this->pr_get_path_arguments(self::PATH_SELF); + if (!empty($arguments)) { + // @todo: return $this->p_do_execute_X($executed); + } - $executed->set_output($this->html); - unset($this->html); + $this->p_do_execute($executed); return $executed; } @@ -113,6 +115,18 @@ class c_standard_path_user_dashboard extends c_standard_path { case 15: $string = 'Administer'; break; + case 16: + $string = 'Account Information'; + break; + case 17: + $string = 'Personal Information'; + break; + case 18: + $string = 'Access Information'; + break; + case 19: + $string = 'History Information'; + break; } if (!empty($arguments)) { @@ -121,4 +135,70 @@ class c_standard_path_user_dashboard extends c_standard_path { return $string; } + + /** + * Execution of the main path, without arguments. + * + * @param c_base_path_executed &$executed + * The execution results to be returned. + */ + 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); + + + // 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); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // 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)); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // access information + $fieldset = $this->pr_create_tag_fieldset(18, 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)); + + $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)); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // @todo add edit, cancel, etc.. links. + + + $executed->set_output($this->html); + unset($this->html); + } } diff --git a/common/standard/paths/u/user_unlock.php b/common/standard/paths/u/user_unlock.php index a945891..d07d53a 100644 --- a/common/standard/paths/u/user_unlock.php +++ b/common/standard/paths/u/user_unlock.php @@ -1,7 +1,7 @@ pr_assign_defaults($http, $database, $session, $settings); - $wrapper = $this->pr_create_tag_section(array(1 => 0)); + // @todo: this function needs to check to see if the user has administer (or manager?) roles and if they do, set administrative to TRUE when calling do_load(). - // initialize the content as HTML. - $this->pr_create_html(); - $this->html->set_tag($wrapper); - unset($wrapper); + $id_user = NULL; + $arguments = $this->pr_get_path_arguments(self::PATH_SELF); + if (!empty($arguments)) { + $arguments_total = count($arguments); + $argument = reset($arguments); - $executed->set_output($this->html); - unset($this->html); + 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 = NULL; + } + } + else { + unset($arguments_total); + unset($argument); + 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; + } + + 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 = NULL; + } + } + unset($arguments_total); + unset($argument); + + if (is_null($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; + } + } + + 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; + } + unset($user_current); + } + 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) { + $user = NULL; + } + unset($loaded); + } + unset($id_user); + + // user is set to NULL on error. + if (is_null($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); + + $this->p_do_execute_view($executed, $user); + unset($user); return $executed; } @@ -66,52 +160,60 @@ class c_standard_path_user_dashboard extends c_standard_path { $string = ''; switch ($code) { case 0: - $string = 'View User'; + if (array_key_exists(':{user_name}', $arguments)) { + $string = 'View User: :{user_name}'; + } + else { + $string = 'View User'; + } break; case 1: - $string = ''; + $string = 'Public'; break; case 2: - $string = ''; + $string = 'User'; break; case 3: - $string = ''; + $string = 'Requester'; break; case 4: - $string = 'Public'; + $string = 'Drafter'; break; case 5: - $string = 'User'; + $string = 'Editor'; break; case 6: - $string = 'Requester'; + $string = 'Reviewer'; break; case 7: - $string = 'Drafter'; + $string = 'Financer'; break; case 8: - $string = 'Editor'; + $string = 'Insurer'; break; case 9: - $string = 'Reviewer'; + $string = 'Publisher'; break; case 10: - $string = 'Financer'; + $string = 'Auditor'; break; case 11: - $string = 'Insurer'; + $string = 'Manager'; break; case 12: - $string = 'Publisher'; + $string = 'Administer'; break; case 13: - $string = 'Auditor'; + $string = 'Account Information'; break; case 14: - $string = 'Manager'; + $string = 'Personal Information'; break; case 15: - $string = 'Administer'; + $string = 'Access Information'; + break; + case 16: + $string = 'History Information'; break; } @@ -121,4 +223,79 @@ class c_standard_path_user_dashboard 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. + */ + private function p_do_execute_view(&$executed, $user) { + $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}']); + } + + $wrapper = $this->pr_create_tag_section(array(1 => 0), $arguments); + unset($arguments); + + // initialize the content as HTML. + $this->pr_create_html(); + $this->html->set_tag($wrapper); + unset($wrapper); + + + // account information + $fieldset = $this->pr_create_tag_fieldset(13, 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)); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // 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)); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // 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)); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // 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)); + + $fieldset->set_tag($content); + unset($content); + + $this->html->set_tag($fieldset); + unset($fieldset); + + + // @todo add edit, cancel, etc.. links. + + + $executed->set_output($this->html); + unset($this->html); + } }