One of the downsides of my design is the complex return type handling.
The code because easier when tests do not have to be performed.
I want to provide a way to return a class as a default but provide a way to say that there was no value stored.
Instead of returning the NULL return type class, return the preferred class with an error flag set to "not defined".
This simplifies the code, especially some of the code used on the user view page.
/**
* Get the name.
*
- * @return c_base_return_status
- * TRUE on success.
- * FALSE with error bit set is returned on error.
+ * @return c_base_return_string
+ * The name string on success.
+ * An empty string with error bit set is returned on error.
*/
public function get_name() {
if (!is_string($this->name)) {
/**
* Get the domain name.
*
- * @return c_base_return_status
- * TRUE on success.
- * FALSE with error bit set is returned on error.
+ * @return c_base_return_string
+ * The domain name string on success.
+ * An empty string with error bit set is returned on error.
*/
public function get_domain() {
if (!is_string($this->domain)) {
}
/**
+ * Get the combined name and domain name.
+ *
+ * @return c_base_return_string
+ * The name and domain name string on success.
+ * An empty string with error bit set is returned on error.
+ */
+ public function get_address() {
+ if (!is_string($this->name)) {
+ $this->name = '';
+ }
+
+ if (!is_string($this->domain)) {
+ $this->domain = '';
+ }
+
+ if (empty($this->name) || empty($this->domain)) {
+ return c_base_return_string::s_new('');
+ }
+
+ return c_base_return_string::s_new($this->name . '@' . $this->domain);
+ }
+
+ /**
* Get the is private setting.
*
* @param bool|null $is_private
*
* @param c_base_database_connection_string $connection_string
* An already processed and configured connection string object.
- * This does perform clone().
+ * This object is cloned.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* Returns the connection string.
*
* @return c_base_database_connection_string
- * A connection string object on success.
+ * A (cloned) connection string object on success.
* The error bit set is on error.
- * This does perform clone().
*/
public function get_connection_string() {
if (!is_object($this->connection_string) || !($this->connection_string instanceof c_base_database_connection_string)) {
// default backtrace setting (TRUE = perform backtrace on error, FALSE do not perform backtrace on error).
const BACKTRACE_PERFORM = TRUE;
+ // a machine-friendly date and time format string.
+ const FORMAT_DATE_MACHINE = 'Y/m/d';
+
+ // a machine-friendly date and time format string.
+ const FORMAT_DATE_TIME_MACHINE = 'Y/m/d h:i a';
+
+ // a machine-friendly date and time format string, with seconds.
+ const FORMAT_DATE_TIME_SECONDS_MACHINE = 'Y/m/d h:i:s a';
+
+ // a human-friendly date and time format string.
+ const FORMAT_DATE_HUMAN = 'l, F jS Y';
+
+ // a human-friendly date and time format string.
+ const FORMAT_DATE_TIME_HUMAN = 'l, F jS Y h:ia';
+
+ // a human-friendly date and time format string, with seconds.
+ const FORMAT_DATE_TIME_SECONDS_HUMAN = 'l, F jS Y h:i:sa';
+
+ // a machine-friendly time format string.
+ const FORMAT_TIME_MACHINE = 'h:i a';
+
+ // a machine-friendly time format string, with seconds.
+ const FORMAT_TIME_SECONDS_MACHINE = 'h:i:s a';
+
+ // a human-friendly time format string.
+ const FORMAT_TIME_HUMAN = 'h:i a';
+
+ // a human-friendly time format string, with seconds.
+ const FORMAT_TIME_SECONDS_HUMAN = 'h:i:s a';
+
// Represents the current timestamp of this PHP process/session, see: self::s_get_timestamp_session().
private static $s_timestamp_session = NULL;
const NOT_FOUND_DIRECTORY = 10;
const NOT_FOUND_FILE = 11;
const NOT_FOUND_PATH = 12;
- const NO_CONNECTION = 13;
- const NO_SESSION = 14;
- const NO_SUPPORT = 15;
- const POSTGRESQL_CONNECTION_FAILURE = 16;
- const POSTGRESQL_NO_CONNECTION = 17;
- const POSTGRESQL_NO_RESOURCE = 18;
- const POSTGRESQL_ERROR = 19;
- const SOCKET_FAILURE = 20;
- const ACCESS_DENIED = 21;
- const ACCESS_DENIED_UNAVAILABLE = 22;
- const ACCESS_DENIED_USER = 23;
- const ACCESS_DENIED_ADMINISTRATION = 24;
- const SERVER_ERROR = 25;
+ const NOT_DEFINED = 13;
+ const NO_CONNECTION = 14;
+ const NO_SESSION = 15;
+ const NO_SUPPORT = 16;
+ const POSTGRESQL_CONNECTION_FAILURE = 17;
+ const POSTGRESQL_NO_CONNECTION = 18;
+ const POSTGRESQL_NO_RESOURCE = 19;
+ const POSTGRESQL_ERROR = 20;
+ const SOCKET_FAILURE = 21;
+ const ACCESS_DENIED = 22;
+ const ACCESS_DENIED_UNAVAILABLE = 23;
+ const ACCESS_DENIED_USER = 24;
+ const ACCESS_DENIED_ADMINISTRATION = 25;
+ const SERVER_ERROR = 26;
/**
return c_base_return_string::s_new('Path not found or cannot be accessed.');
}
}
+ elseif ($code === self::NOT_DEFINED) {
+ if ($arguments === TRUE) {
+ return c_base_return_string::s_new('The requested data, :{data_name}, is not defined' . $function_name_string . '.');
+ }
+ else {
+ return c_base_return_string::s_new('The requested data is not defined.');
+ }
+ }
elseif ($code === self::NO_CONNECTION) {
if ($arguments === TRUE) {
return c_base_return_string::s_new('The resource, :{resource_name}, is not connected' . $function_name_string . '.');
return c_base_return_string::s_new('パスが見つかりません。');
}
}
+ elseif ($code === self::NOT_DEFINED) {
+ if ($arguments === TRUE) {
+ return c_base_return_string::s_new('要求されたデータ:{data_name}は定義されていません' . $function_name_string . '.');
+ }
+ else {
+ return c_base_return_string::s_new('要求されたデータは定義されていません。');
+ }
+ }
elseif ($code === self::NO_CONNECTION) {
if ($arguments === TRUE) {
return c_base_return_string::s_new('リソース :{resource_name} は接続されていません' . (is_null($function_name_string) ? '' : '、') . $function_name_string . '。');
*
* @param c_base_cookie $cookie
* The cookie object to assign as a cookie.
+ * This object is cloned.
* These header fields apply only to the immediate client.
* The header name format is:
* - 1*(tchar)
- * This does perform clone().
* @param bool $append
* (optional) If TRUE, then append the header name.
* If FALSE, then assign the header name.
*
* @param c_base_menu_item $item
* An instance of c_base_menu_item to assign.
- * This does perform clone().
+ * This object is cloned.
* @param int|string|NULL $index
* An index to assign a specific value to.
* Set to NULL to append item.
* Assign the items array.
*
* @param c_base_array $items
- * Replace the current array with this value.
+ * Replace the current array object with this object.
+ * This object is cloned.
* If NULL, then a new array is created.
- * This does perform clone().
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* An index to assign a specific value to.
*
* @return c_base_return_status|c_base_menu_item
- * Value on success, FALSE otherwise.
+ * The (cloned) value object.
* FALSE without error bit set is returned if $index us not defined.
* FALSE with the error bit set is returned on error.
- * This does perform clone().
*/
public function get_item($index) {
if (!is_string($index) || empty($index)) {
protected $date_created;
protected $date_changed;
+ protected $date_synced;
protected $date_locked;
+ protected $date_deleted;
protected $include_directory;
protected $include_name;
$this->date_created = NULL;
$this->date_changed = NULL;
+ $this->date_synced = NULL;
$this->date_locked = NULL;
+ $this->date_deleted = NULL;
$this->include_directory = NULL;
$this->include_name = NULL;
unset($this->date_created);
unset($this->date_changed);
+ unset($this->date_synced);
unset($this->date_locked);
+ unset($this->date_deleted);
unset($this->include_directory);
unset($this->include_name);
}
/**
+ * Assigns the date synced setting.
+ *
+ * @param float $date_synced
+ * The date synced associated with the path.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_date_synced($date_synced) {
+ if (!is_float($date_synced) && !is_int($date_synced)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_synced', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->date_synced = (float) $date_synced;
+ return new c_base_return_true();
+ }
+
+ /**
* Assigns the date locked setting.
*
* @param float $date_locked
}
/**
+ * Assigns the date deleted setting.
+ *
+ * @param float $date_deleted
+ * The date deleted associated with the path.
+ *
+ * @return c_base_return_status
+ * TRUE on success, FALSE otherwise.
+ * FALSE with error bit set is returned on error.
+ */
+ public function set_date_deleted($date_deleted) {
+ if (!is_float($date_deleted) && !is_int($date_deleted)) {
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{argument_name}' => 'date_deleted', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::INVALID_ARGUMENT);
+ return c_base_return_error::s_false($error);
+ }
+
+ $this->date_deleted = (float) $date_deleted;
+ return new c_base_return_true();
+ }
+
+ /**
* Assign an include path directory needed to process this path.
*
* This is the prefix part of the path.
}
/**
+ * Gets the date synced setting.
+ *
+ * @return c_base_return_float|c_base_return_null
+ * Date synced on success.
+ * FALSE is returned if the date is not assigned.
+ * Error bit is set on error.
+ */
+ public function get_date_synced() {
+ if (!is_float($this->date_synced)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_float::s_new($this->date_synced);
+ }
+
+ /**
* Gets the date locked setting.
*
* @return c_base_return_float|c_base_return_null
}
/**
+ * Gets the date deleted setting.
+ *
+ * @return c_base_return_float|c_base_return_null
+ * Date deleted on success.
+ * FALSE is returned if the date is not assigned.
+ * Error bit is set on error.
+ */
+ public function get_date_deleted() {
+ if (!is_float($this->date_deleted)) {
+ return new c_base_return_false();
+ }
+
+ return c_base_return_float::s_new($this->date_deleted);
+ }
+
+ /**
* Get the assigned include path directory.
*
* This is the prefix part of the path.
*
* @param object $value
* Any value so long as it is an object.
+ * This object is cloned.
* NULL is not allowed.
- * This does perform clone().
*
* @return bool
* TRUE on success, FALSE otherwise.
* Assigns the cookie associated with this session.
*
* @param c_base_cookie|null $cookie
- * The session cookie.
+ * The session cookie object.
+ * This object is cloned.
* Set to NULL to remove any existing values.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with the error bit set is returned on error.
- * This does perform clone().
*/
public function set_cookie($cookie) {
if (!is_null($cookie) && !($cookie instanceof c_base_cookie)) {
*
* @param c_base_users_user|null $user
* The current user object (generally populated from the database).
+ * This object is cloned.
* If NULL, then the user object is removed.
- * This does perform clone().
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
*
* @param c_base_users_user|null $user
* The current user object (generally populated from the database).
+ * This object is cloned.
* If NULL, then the user object is removed.
- * This does perform clone().
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* Returns the cookie associated with this session.
*
* @return c_base_cookie|c_base_return_null
- * The session cookie or NULL if undefined.
+ * The (cloned) session cookie or NULL if undefined.
* FALSE with the error bit set is returned on error.
- * This does perform clone().
*/
public function get_cookie() {
if (is_null($this->cookie)) {
}
/**
- * Get the current user object
+ * Get the current user object.
*
- * @return c_base_users_user|c_base_return_null
- * The user object is returned on success.
- * NULL is returned if there is no user object assigned.
- * The error bit set is returned on error.
- * This does perform clone().
+ * @return c_base_users_user
+ * The user object (cloned) is returned on success.
+ * A user object with the error bit set is returned on error.
*/
public function get_user_current() {
if ($this->user_current instanceof c_base_users_user) {
return clone($this->user_current);
}
- return new c_base_return_null();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{data_name}' => 'user_current', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_DEFINED);
+ return c_base_return_error::s_return('c_base_users_user', $error);
}
/**
- * Get the session user object
+ * Get the session user object.
*
- * @return c_base_users_user|c_base_return_null
- * The user object is returned on success.
- * NULL is returned if there is no user object assigned.
- * The error bit set is returned on error.
- * This does perform clone().
+ * @return c_base_users_user
+ * The user object (cloned) is returned on success.
+ * A user object with the error bit set is returned on error.
*/
public function get_user_session() {
if ($this->user_session instanceof c_base_users_user) {
return clone($this->user_session);
}
- return new c_base_return_null();
+ $error = c_base_error::s_log(NULL, array('arguments' => array(':{data_name}' => 'user_session', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__)), i_base_error_messages::NOT_DEFINED);
+ return c_base_return_error::s_return('c_base_users_user', $error);
}
/**
protected const CSS_AS_ROW = 'as-row';
protected const CSS_AS_ROW_EVEN = 'as-row-even';
protected const CSS_AS_ROW_ODD = 'as-row-odd';
+ protected const CSS_AS_ROW_VALUE = 'as-row-value';
protected const CSS_AS_SPACER = 'as-spacer';
protected const CSS_IS_JAVASCRIPT_ENABLED = 'javascript-enabled';
}
/**
+ * Creates the standard "row".
+ *
+ * A row only has a single tag within it, generally called the value.
+ *
+ * @param string|null $value
+ * If not NULL, then is text used to be displayed as the field value or description.
+ * @param array $arguments
+ * (optional) An array of arguments to convert into text.
+ * @param string|null $id
+ * (optional) An ID attribute to assign.
+ * If NULL, then this is not assigned.
+ * @param string|null $extra_class
+ * (optional) An additional css class to append to the wrapping block.
+ * May be an array of classes to append.
+ * If NULL, then this is not assigned.
+ * @param int|null $row
+ * (optional) If not NULL, then is a row number to append as an additional class.
+ *
+ * @return c_base_markup_tag
+ * The generated markup tag.
+ */
+ protected function pr_create_tag_row($value = NULL, $arguments = array(), $id = NULL, $extra_class = NULL, $row = NULL) {
+ $classes = array($this->settings['base_css'] . self::CSS_AS_ROW, self::CSS_AS_ROW);
+ if (is_string($extra_class)) {
+ $classes[] = $extra_class;
+ }
+ elseif (is_array($extra_class)) {
+ foreach ($extra_class as $class) {
+ $classes[] = $class;
+ }
+ unset($class);
+ }
+
+ if (is_int($row)) {
+ $classes[] = self::CSS_AS_ROW . '-' . $row;
+ }
+
+ $tag = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, $id, $classes);
+ unset($classes);
+
+ $tag_text = $this->pr_create_tag_text($value, $arguments, $id, self::CSS_AS_ROW_VALUE);
+ $tag->set_tag($tag_text);
+ unset($tag_text);
+
+ return $tag;
+ }
+
+ /**
* Creates the standard "field row".
*
+ * A field row has a field name tag and a field value tag.
+ *
* @param string|null $field_name
* If not NULL, then is text used to be displayed as the field name or label.
* @param string|null $field_value
* This is intended to provide a way to have spacing if CSS is not used (unthemed/raw page).
* If a theme is then used, it can then set the spacer tab to be not displayed.
* If FALSE, this spacer tag is omitted.
+ * @fixme: spacer was added experimentally and may or may not be used in the future depending on how practical it is.
*
* @return c_base_markup_tag
* The generated markup tag.
}
unset($result);
- $roles = array();
- $session_user = $session->get_user_current();
- if ($session_user instanceof c_base_session) {
- $roles = $session_user->get_roles()->get_value_exact();
- }
- unset($session_user);
+ $roles = $session->get_user_current()->get_roles()->get_value_exact();
$menu = $this->pr_create_html_create_menu($settings['base_css'] . self::CLASS_NAME, $this->pr_get_text(0));
$wrapper = $this->pr_create_tag_section(array(1 => 0));
$wrapper->set_tag($this->pr_create_tag_text_block(1));
- $roles = array();
- $current_user = $session->get_user_current();
- #$session_user = $session->get_user_session();
-
-
- $roles = array();
- if ($current_user instanceof c_base_users_user) {
- $roles = $current_user->get_roles()->get_value_exact();
- }
- unset($current_user);
- #unset($session_user);
+ $roles = $session->get_user_current()->get_roles()->get_value_exact();
$wrapper->set_tag($this->pr_create_tag_text_block($this->pr_get_text(2, array('@{user}' => $session->get_name()->get_value_exact()))));
$string = 'パブリック';
break;
case 2:
- $string = '���ーザー';
+ $string = '���ステム';
break;
case 3:
- $string = '���クエスタ';
+ $string = '���ーザー';
break;
case 4:
- $string = '���レイター';
+ $string = '���クエスタ';
break;
case 5:
- $string = '編集者';
+ $string = 'ドレイター';
break;
case 6:
- $string = 'レビューア';
+ $string = '編集者';
break;
case 7:
- $string = '���ァイナンサー';
+ $string = '���ビューア';
break;
case 8:
- $string = '保険会社';
+ $string = 'ファイナンサー';
break;
case 9:
- $string = '出版社';
+ $string = '保険会社';
break;
case 10:
- $string = '���査員';
+ $string = '���版社';
break;
case 11:
- $string = 'マネージャー';
+ $string = '審査員';
break;
case 12:
- $string = '管理者';
+ $string = 'マネージャー';
break;
case 13:
- $string = '口座情報';
+ $string = '管理者';
break;
case 14:
- $string = '���人情報';
+ $string = '���座情報';
break;
case 15:
- $string = 'アクセス情報';
+ $string = '個人情報';
break;
case 16:
- $string = '履歴情報';
+ $string = 'アクセス情報';
break;
case 17:
- $string = '身元';
+ $string = '履歴情報';
break;
case 18:
- $string = '外部身元';
+ $string = '身元';
break;
case 19:
- $string = '���';
+ $string = '���部身元';
break;
case 20:
- $string = 'Eメール';
+ $string = '名';
break;
case 21:
- $string = 'ロール';
+ $string = 'Eメール';
break;
case 22:
- $string = 'ロール管理';
+ $string = 'ロール';
break;
case 23:
- $string = 'ロ���クされている';
+ $string = 'ロ���ルマネージャ';
break;
case 24:
- $string = '削除されました';
+ $string = 'ロックされている';
break;
case 25:
- $string = 'パブリックです';
+ $string = '削除されました';
break;
case 26:
- $string = '���ライベートです';
+ $string = '���ブリックです';
break;
case 27:
- $string = '���ステム';
+ $string = '���ライベートです';
break;
case 28:
$string = '作成日';
$this->pr_assign_defaults($http, $database, $session, $settings);
- // @todo: this function needs to check to see if the user has administer (or manager?) roles and if they do, set administrative to TRUE when calling do_load().
+ // @todo: this function needs to check to see if the user has administer (or manager?) roles (c_base_roles::MANAGER, c_base_roles::ADMINISTER) and if they do, set administrative to TRUE when calling do_load().
+ $roles_current = $this->session->get_user_current()->get_roles()->get_value_exact();
$id_user = NULL;
$arguments = $this->pr_get_path_arguments(self::PATH_SELF);
// @todo: execute custom print function and then return.
$id_user = NULL;
}
- elseif ($argument == 'pdf') {
- // @todo: execute custom pdf function and then return.
- $id_user = NULL;
- }
- elseif ($argument == 'ps') {
- // @todo: execute custom postscript function and then return.
- $id_user = NULL;
- }
+ #elseif ($argument == 'pdf') {
+ # // @todo: execute custom pdf function and then return.
+ # $id_user = NULL;
+ #}
+ #elseif ($argument == 'ps') {
+ # // @todo: execute custom postscript function and then return.
+ # $id_user = NULL;
+ #}
else {
$id_user = NULL;
}
if (is_null($id_user)) {
// load current user.
- $user_current = $this->session->get_user_current();
- if ($user_current instanceof c_base_users_user && $user_current->get_id()->get_value_exact() > 0) {
- $user = $user_current;
+ if ($this->session->get_user_current()->get_id()->get_value_exact() > 0) {
+ $user = $this->session->get_user_current();
}
- unset($user_current);
}
else {
$user = new c_standard_users_user();
$string = 'User';
break;
case 3:
- $string = 'Requester';
+ $string = 'System';
break;
case 4:
- $string = 'Drafter';
+ $string = 'Requester';
break;
case 5:
- $string = 'Editor';
+ $string = 'Drafter';
break;
case 6:
- $string = 'Reviewer';
+ $string = 'Editor';
break;
case 7:
- $string = 'Financer';
+ $string = 'Reviewer';
break;
case 8:
- $string = 'Insurer';
+ $string = 'Financer';
break;
case 9:
- $string = 'Publisher';
+ $string = 'Insurer';
break;
case 10:
- $string = 'Auditor';
+ $string = 'Publisher';
break;
case 11:
- $string = 'Manager';
+ $string = 'Auditor';
break;
case 12:
- $string = 'Administer';
+ $string = 'Manager';
break;
case 13:
- $string = 'Account Information';
+ $string = 'Administer';
break;
case 14:
- $string = 'Personal Information';
+ $string = 'Account Information';
break;
case 15:
- $string = 'Access Information';
+ $string = 'Personal Information';
break;
case 16:
- $string = 'History Information';
+ $string = 'Access Information';
break;
case 17:
- $string = 'ID';
+ $string = 'History Information';
break;
case 18:
- $string = 'External ID';
+ $string = 'ID';
break;
case 19:
- $string = 'Name';
+ $string = 'External ID';
break;
case 20:
- $string = 'E-mail';
+ $string = 'Name';
break;
case 21:
- $string = 'Roles';
+ $string = 'E-mail';
break;
case 22:
- $string = 'Role Management';
+ $string = 'Roles';
break;
case 23:
- $string = 'Is Locked';
+ $string = 'Role Manager';
break;
case 24:
- $string = 'Is Deleted';
+ $string = 'Is Locked';
break;
case 25:
- $string = 'Is Public';
+ $string = 'Is Deleted';
break;
case 26:
- $string = 'Is Private';
+ $string = 'Is Public';
break;
case 27:
- $string = 'Is System';
+ $string = 'Is Private';
break;
case 28:
$string = 'Date Created';
$string = 'Date Changed';
break;
case 30:
- $string = 'Date Synchronized';
+ $string = 'Date Synced';
break;
case 31:
$string = 'Date Locked';
case 36:
$string = 'Disabled';
break;
+ case 37:
+ $string = 'Prefix';
+ break;
+ case 38:
+ $string = 'First';
+ break;
+ case 39:
+ $string = 'Middle';
+ break;
+ case 40:
+ $string = 'Last';
+ break;
+ case 41:
+ $string = 'Suffix';
+ break;
+ case 42:
+ $string = 'Full';
+ break;
+ case 43:
+ $string = 'Undisclosed';
+ break;
}
if (!empty($arguments)) {
$wrapper = $this->pr_create_tag_section(array(1 => 0), $arguments);
}
+ $roles_current = $this->session->get_user_current()->get_roles()->get_value_exact();
+ $roles = $user->get_roles()->get_value_exact();
+
+ $full_view_access = FALSE;
+ if ($id_user === $this->session->get_user_current()->get_id()->get_value_exact()) {
+ $full_view_access = TRUE;
+ }
+ elseif (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) {
+ $full_view_access = TRUE;
+ }
+
// initialize the content as HTML.
$this->pr_create_html(TRUE, $arguments);
// account information
- $fieldset = $this->pr_create_tag_fieldset(13, array(), self::CLASS_USER_VIEW_ACCOUNT, self::CLASS_USER_VIEW_ACCOUNT);
+ $fieldset = $this->pr_create_tag_fieldset(14, array(), self::CLASS_USER_VIEW_ACCOUNT, self::CLASS_USER_VIEW_ACCOUNT);
$content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT));
- $row = $this->pr_create_tag_field_row(17, '' . $id_user, array(), NULL, NULL, 0, TRUE);
- $content->set_tag($row);
- unset($row);
+ $content->set_tag($this->pr_create_tag_field_row(18, '' . $id_user, array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE));
- $fieldset->set_tag($content);
- unset($content);
+ if ($full_view_access || !$user->get_address_email()->is_private()->get_value()) {
+ $count = 1;
- $this->html->set_tag($fieldset);
- unset($fieldset);
- unset($id_user);
+ if ($full_view_access) {
+ $content->set_tag($this->pr_create_tag_field_row(19, '' . $user->get_id_external()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
+ }
+ $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
- // personal information
- $fieldset = $this->pr_create_tag_fieldset(14, array(), self::CLASS_USER_VIEW_PERSONAL, self::CLASS_USER_VIEW_PERSONAL);
- $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT));
+ $content->set_tag($this->pr_create_tag_field_row(21, '' . $user->get_address_email()->get_address()->get_value(), array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
- $fieldset->set_tag($content);
- unset($content);
+ if ($user->is_locked()->get_value_exact()) {
+ $tag_text = $this->pr_get_text(33);
+ }
+ else {
+ $tag_text = $this->pr_get_text(34);
+ }
+ $content->set_tag($this->pr_create_tag_field_row(24, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
- $this->html->set_tag($fieldset);
- unset($fieldset);
+ if ($user->is_private()->get_value_exact()) {
+ $tag_text = $this->pr_get_text(33);
+ }
+ else {
+ $tag_text = $this->pr_get_text(34);
+ }
+ $content->set_tag($this->pr_create_tag_field_row(27, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
+
+ if ($user->can_manage_roles()->get_value_exact()) {
+ $tag_text = $this->pr_get_text(33);
+ }
+ else {
+ $tag_text = $this->pr_get_text(34);
+ }
+ $content->set_tag($this->pr_create_tag_field_row(23, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
+ if (isset($roles_current[c_base_roles::MANAGER]) || isset($roles_current[c_base_roles::ADMINISTER])) {
+ if ($user->is_deleted()->get_value_exact()) {
+ $tag_text = $this->pr_get_text(33);
+ }
+ else {
+ $tag_text = $this->pr_get_text(34);
+ }
+ $content->set_tag($this->pr_create_tag_field_row(25, $tag_text, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
- // access information
- $fieldset = $this->pr_create_tag_fieldset(15, array(), self::CLASS_USER_VIEW_ACCESS, self::CLASS_USER_VIEW_ACCESS);
- $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT));
+ $count++;
+ }
- $fieldset->set_tag($content);
- unset($content);
+ if ($full_view_access) {
- $this->html->set_tag($fieldset);
- unset($fieldset);
+ // date created
+ $date = NULL;
+ if (!is_null($user->get_date_created()->get_value())) {
+ $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_created()->get_value())->get_value_exact();
+ }
+ $content->set_tag($this->pr_create_tag_field_row(28, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
- // history information
- $fieldset = $this->pr_create_tag_fieldset(16, array(), self::CLASS_USER_VIEW_HISTORY, self::CLASS_USER_VIEW_HISTORY);
- $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT));
+
+ // date changed
+ $date = NULL;
+ if (!is_null($user->get_date_changed()->get_value())) {
+ $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_changed()->get_value())->get_value_exact();
+ }
+
+ $content->set_tag($this->pr_create_tag_field_row(29, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
+
+
+ // date synced
+ $date = NULL;
+ if (!is_null($user->get_date_synced()->get_value())) {
+ $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_synced()->get_value())->get_value_exact();
+ }
+
+ $content->set_tag($this->pr_create_tag_field_row(30, $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
+
+
+ // date locked
+ $date = NULL;
+ if (!is_null($user->get_date_locked()->get_value())) {
+ $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_locked()->get_value())->get_value_exact();
+ }
+
+ $content->set_tag($this->pr_create_tag_field_row(31, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
+
+
+ // date deleted
+ $date = NULL;
+ if (!is_null($user->get_date_deleted()->get_value())) {
+ $date = c_base_defaults_global::s_get_date(c_base_defaults_global::FORMAT_DATE_TIME_SECONDS_HUMAN, $user->get_date_deleted()->get_value())->get_value_exact();
+ }
+
+ $content->set_tag($this->pr_create_tag_field_row(32, '' . $date, array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+ $count++;
+ }
+
+ unset($count);
+ unset($date);
+ }
+ else {
+ $content->set_tag($this->pr_create_tag_field_row(20, '' . $user->get_name_machine()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE));
+ $content->set_tag($this->pr_create_tag_field_row(21, $this->pr_get_text(43), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE));
+ }
$fieldset->set_tag($content);
unset($content);
$this->html->set_tag($fieldset);
unset($fieldset);
+ unset($id_user);
+
+
+ if ($full_view_access || !$user->is_private()->get_value()) {
+ // personal information
+ $fieldset = $this->pr_create_tag_fieldset(15, array(), self::CLASS_USER_VIEW_PERSONAL, self::CLASS_USER_VIEW_PERSONAL);
+ $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT));
+
+ #($count & 2 == 0) ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD)
+
+ $content->set_tag($this->pr_create_tag_field_row(37, '' . $user->get_name_human()->get_prefix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 0, TRUE));
+ $content->set_tag($this->pr_create_tag_field_row(38, '' . $user->get_name_human()->get_first()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 1, TRUE));
+ $content->set_tag($this->pr_create_tag_field_row(39, '' . $user->get_name_human()->get_middle()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 2, TRUE));
+ $content->set_tag($this->pr_create_tag_field_row(40, '' . $user->get_name_human()->get_last()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 3, TRUE));
+ $content->set_tag($this->pr_create_tag_field_row(41, '' . $user->get_name_human()->get_suffix()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_EVEN, 4, TRUE));
+ $content->set_tag($this->pr_create_tag_field_row(42, '' . $user->get_name_human()->get_complete()->get_value(), array(), NULL, c_standard_path::CSS_AS_ROW_ODD, 5, TRUE));
+
+ $fieldset->set_tag($content);
+ unset($content);
+
+ $this->html->set_tag($fieldset);
+ unset($fieldset);
+
+
+ // access information
+ $fieldset = $this->pr_create_tag_fieldset(16, array(), self::CLASS_USER_VIEW_ACCESS, self::CLASS_USER_VIEW_ACCESS);
+ $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT));
+
+ $access_to_text_mapping = array(
+ c_base_roles::PUBLIC => 1,
+ c_base_roles::SYSTEM => 2,
+ c_base_roles::USER => 3,
+ c_base_roles::REQUESTER => 4,
+ c_base_roles::DRAFTER => 5,
+ c_base_roles::EDITOR => 6,
+ c_base_roles::REVIEWER => 7,
+ c_base_roles::FINANCER => 8,
+ c_base_roles::INSURER => 9,
+ c_base_roles::PUBLISHER => 10,
+ c_base_roles::AUDITOR => 11,
+ c_base_roles::MANAGER => 12,
+ c_base_roles::ADMINISTER => 13,
+ );
+
+ $id_text = NULL;
+ $count = 0;
+ foreach ($roles as $role) {
+ if (!isset($access_to_text_mapping[$role])) {
+ continue;
+ }
+
+ $content->set_tag($this->pr_create_tag_field_row($access_to_text_mapping[$role], array(), NULL, ($count % 2 == 0 ? c_standard_path::CSS_AS_ROW_EVEN : c_standard_path::CSS_AS_ROW_ODD), $count, TRUE));
+
+ $count++;
+ }
+ unset($role);
+ unset($id_text);
+ unset($count);
+
+ $fieldset->set_tag($content);
+ unset($content);
+
+ $this->html->set_tag($fieldset);
+ unset($fieldset);
+ unset($roles);
+
+
+ // history information
+ $fieldset = $this->pr_create_tag_fieldset(17, array(), self::CLASS_USER_VIEW_HISTORY, self::CLASS_USER_VIEW_HISTORY);
+ $content = c_theme_html::s_create_tag(c_base_markup_tag::TYPE_DIVIDER, self::CSS_AS_FIELD_SET_CONTENT, array(self::CSS_AS_FIELD_SET_CONTENT));
+
+ // @todo: implement code for processing and generating a table/list of history, with the ability to navigate additional entries.
+
+ $fieldset->set_tag($content);
+ unset($content);
+
+ $this->html->set_tag($fieldset);
+ unset($fieldset);
+ }
// @todo add edit, cancel, etc.. links.
*
* @param c_base_html $html
* The markup html to apply the theme to.
+ * This object is cloned.
*
* @return c_base_return_status
* TRUE on success, FALSE otherwise.
* FALSE with error bit set is returned on error.
- * This does perform clone().
*/
public function set_html($html) {
if (!($html instanceof c_base_html)) {
* Get the markup html assigned to this object.
*
* @return c_base_html|c_base_return_status
- * The markup html object.
+ * The (cloned) markup html object.
* FALSE is returned if no id is assigned.
* FALSE with error bit set is returned on error.
- * This does perform clone().
*/
public function get_html() {
if (!($this->html instanceof c_base_html)) {
* Get the HTTP information
*
* @return c_base_http|c_base_return_status
- * The markup tags object.
+ * The (cloned) markup tags object.
* FALSE is returned if no id is assigned.
* FALSE with error bit set is returned on error.
- * This does perform clone().
*/
public function get_http() {
if (!($this->http instanceof c_base_http)) {
// default backtrace setting (TRUE = perform backtrace on error, FALSE do not perform backtrace on error).
const BACKTRACE_PERFORM = TRUE;
+ // a machine-friendly date and time format string.
+ const FORMAT_DATE_MACHINE = 'Y/m/d';
+
+ // a machine-friendly date and time format string.
+ const FORMAT_DATE_TIME_MACHINE = 'Y/m/d h:i a';
+
+ // a machine-friendly date and time format string, with seconds.
+ const FORMAT_DATE_TIME_SECONDS_MACHINE = 'Y/m/d h:i:s a';
+
+ // a human-friendly date and time format string.
+ const FORMAT_DATE_HUMAN = 'l, F jS Y';
+
+ // a human-friendly date and time format string.
+ const FORMAT_DATE_TIME_HUMAN = 'l, F jS Y h:ia';
+
+ // a human-friendly date and time format string, with seconds.
+ const FORMAT_DATE_TIME_SECONDS_HUMAN = 'l, F jS Y h:i:sa';
+
+ // a machine-friendly time format string.
+ const FORMAT_TIME_MACHINE = 'h:i a';
+
+ // a machine-friendly time format string, with seconds.
+ const FORMAT_TIME_SECONDS_MACHINE = 'h:i:s a';
+
+ // a human-friendly time format string.
+ const FORMAT_TIME_HUMAN = 'h:i a';
+
+ // a human-friendly time format string, with seconds.
+ const FORMAT_TIME_SECONDS_HUMAN = 'h:i:s a';
+
// Represents the current timestamp of this PHP process/session, see: self::s_get_timestamp_session().
private static $s_timestamp_session = NULL;