本文整理汇总了PHP中ca_users::getPreference方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_users::getPreference方法的具体用法?PHP ca_users::getPreference怎么用?PHP ca_users::getPreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_users
的用法示例。
在下文中一共展示了ca_users::getPreference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThemeDirectoryPath
public function getThemeDirectoryPath($pb_use_default = false)
{
if ($this->config->get('always_use_default_theme')) {
$pb_use_default = true;
}
if (!$pb_use_default && $this->isLoggedIn()) {
$vs_theme = $this->user->getPreference('ui_theme');
} else {
$vs_theme = $this->config->get('theme');
// default theme
}
return $this->config->get('themes_directory') . '/' . $vs_theme;
}
示例2: DownloadUserReport
public function DownloadUserReport()
{
$vs_download_format = $this->request->getParameter("download_format", pString);
if (!$vs_download_format) {
$vs_download_format = "tab";
}
$this->view->setVar("download_format", $vs_download_format);
switch ($vs_download_format) {
default:
case "tab":
$this->view->setVar("file_extension", "txt");
$this->view->setVar("mimetype", "text/plain");
$vs_delimiter_col = "\t";
$vs_delimiter_row = "\n";
break;
# -----------------------------------
# -----------------------------------
case "csv":
$this->view->setVar("file_extension", "txt");
$this->view->setVar("mimetype", "text/plain");
$vs_delimiter_col = ",";
$vs_delimiter_row = "\n";
break;
# -----------------------------------
}
$o_db = new Db();
$t_user = new ca_users();
$va_fields = array("lname", "fname", "email", "user_name", "userclass", "active", "last_login");
$va_profile_prefs = $t_user->getValidPreferences('profile');
$va_profile_prefs_labels = array();
foreach ($va_profile_prefs as $vs_pref) {
$va_pref_info = $t_user->getPreferenceInfo($vs_pref);
$va_profile_prefs_labels[$vs_pref] = $va_pref_info["label"];
}
$qr_users = $o_db->query("SELECT * FROM ca_users ORDER BY user_id DESC");
if ($qr_users->numRows()) {
$va_rows = array();
# --- headings
$va_row = array();
# --- headings for field values
foreach ($va_fields as $vs_field) {
switch ($vs_field) {
case "last_login":
$va_row[] = _t("Last login");
break;
# --------------------
# --------------------
default:
$va_row[] = $t_user->getDisplayLabel("ca_users." . $vs_field);
break;
# --------------------
}
}
# --- headings for profile prefs
foreach ($va_profile_prefs_labels as $vs_pref => $vs_pref_label) {
$va_row[] = $vs_pref_label;
}
$va_rows[] = join($vs_delimiter_col, $va_row);
reset($va_fields);
reset($va_profile_prefs_labels);
$o_tep = new TimeExpressionParser();
while ($qr_users->nextRow()) {
$va_row = array();
# --- fields
foreach ($va_fields as $vs_field) {
switch ($vs_field) {
case "userclass":
$va_row[] = $t_user->getChoiceListValue($vs_field, $qr_users->get("ca_users." . $vs_field));
break;
# -----------------------
# -----------------------
case "active":
$va_row[] = $qr_users->get("ca_users." . $vs_field) == 1 ? _t("active") : _t("not active");
break;
# -----------------------
# -----------------------
case "last_login":
//if (!is_array($va_vars = $qr_users->getVars('vars'))) { $va_vars = array(); }
if (!is_array($va_vars = $qr_users->getVars('volatile_vars'))) {
$va_vars = array();
}
if ($va_vars['last_login'] > 0) {
$o_tep->setUnixTimestamps($va_vars['last_login'], $va_vars['last_login']);
$va_row[] = $o_tep->getText();
} else {
$va_row[] = "-";
}
break;
# -----------------------
# -----------------------
default:
if ($vs_download_format == "csv") {
$va_row[] = str_replace(",", "-", $qr_users->get("ca_users." . $vs_field));
} else {
$va_row[] = $qr_users->get("ca_users." . $vs_field);
}
break;
# -----------------------
}
}
//.........这里部分代码省略.........
示例3: GetUserProfileInfo
/**
* Return user profile values for specified user
*/
public function GetUserProfileInfo()
{
if (!$this->request->user->canDoAction('can_manage_clients')) {
return null;
}
$pn_user_id = $this->request->getParameter('user_id', pInteger);
$t_user = new ca_users($pn_user_id);
$va_profile_prefs = $t_user->getValidPreferences('profile');
if (is_array($va_profile_prefs) && sizeof($va_profile_prefs)) {
$va_elements = array();
foreach ($va_profile_prefs as $vs_pref) {
$va_pref_info = $t_user->getPreferenceInfo($vs_pref);
$va_elements[str_replace('user_profile_', '', $vs_pref)] = array($t_user->getPreference($vs_pref));
}
$this->view->setVar("profile_values", $va_elements);
}
$this->view->setVar("user_id", $pn_user_id);
$this->render('ajax_user_profile_info_json.php');
}
示例4: Save
//.........这里部分代码省略.........
if ($vn_user_id) {
// try to create transaction
$t_trans = new ca_commerce_transactions();
$t_trans->setMode(ACCESS_WRITE);
$t_trans->set('user_id', $vn_user_id);
$t_trans->set('short_description', "Created on " . date("c"));
$t_trans->set('set_id', null);
$t_trans->insert();
if ($t_trans->numErrors()) {
$this->notification->addNotification(_t('Errors occurred when creating commerce transaction: %1', join('; ', $t_trans->getErrors())), __NOTIFICATION_TYPE_ERROR__);
} else {
$vn_transaction_id = $t_trans->getPrimaryKey();
}
} else {
$this->notification->addNotification(_t('You must specify a client'), __NOTIFICATION_TYPE_ERROR__);
$va_errors['general'][] = new Error(1100, _t('You must specify a client'), 'CheckOutController->Save()', false, false, false);
}
}
$this->opt_order->set('transaction_id', $vn_transaction_id);
if ($vn_transaction_id) {
$this->opt_order->set('order_type', 'L');
// L = loan (as opposed to 'O' for sales orders)
$this->opt_order->set('order_status', 'OPEN');
$this->opt_order->insert();
$this->request->setParameter('order_id', $x = $this->opt_order->getPrimaryKey());
}
}
if ($vn_transaction_id) {
// set user profile if not already set
$t_trans = new ca_commerce_transactions($vn_transaction_id);
$t_user = new ca_users($t_trans->get('user_id'));
$t_user->setMode(ACCESS_WRITE);
foreach ($va_mapping as $vs_field => $vs_pref) {
if (!strlen($t_user->getPreference($vs_pref))) {
$t_user->setPreference($vs_pref, $this->opt_order->get($vs_field));
}
}
$t_user->update();
$va_additional_fee_codes = $this->opo_client_services_config->getAssoc('additional_loan_fees');
// Look for newly added items
$vn_items_added = 0;
$vn_item_errors = 0;
$vs_errors = '';
foreach ($_REQUEST as $vs_k => $vs_v) {
if (preg_match("!^item_list_idnew_([\\d]+)\$!", $vs_k, $va_matches)) {
if ($vn_object_id = (int) $vs_v) {
// add item to order
$va_values = array();
foreach ($_REQUEST as $vs_f => $vs_value) {
if (preg_match("!^item_list_([A-Za-z0-9_]+)_new_" . $va_matches[1] . "\$!", $vs_f, $va_matches2)) {
$va_values[$va_matches2[1]] = $vs_value;
}
}
// Set additional fees
//
$va_fee_values = array();
foreach ($va_additional_fee_codes as $vs_code => $va_info) {
$va_fee_values[$vs_code] = $_REQUEST['additional_order_item_fee_' . $vs_code . '_new_' . $va_matches[1]];
}
$t_item = $this->opt_order->addItem($vn_object_id, $va_values, array('additional_fees' => $va_fee_values));
if ($t_item && $t_item->getPrimaryKey()) {
$vn_items_added++;
} else {
if ($this->opt_order->numErrors()) {
$t_object = new ca_objects($vn_object_id);
$this->notification->addNotification(_t('Could not check-out item <em>%1</em> (%2) due to errors: %3', $t_object->get('ca_objects.preferred_labels.name'), $t_object->get('idno'), join("; ", $this->opt_order->getErrors())), __NOTIFICATION_TYPE_ERROR__);
示例5: duplicateItemsInSet
/**
* Duplicate all items in this set
* @param int $pn_user_id
* @param array $pa_options
* @return ca_sets|bool
*/
public function duplicateItemsInSet($pn_user_id, $pa_options = array())
{
if (!$this->getPrimaryKey()) {
return false;
}
if ($this->getItemCount() < 1) {
return false;
}
$t_user = new ca_users($pn_user_id);
if (!$t_user->getPrimaryKey()) {
return false;
}
// we need a user for duplication
global $g_ui_locale_id;
if (caGetOption('addToCurrentSet', $pa_options, false)) {
$t_set_to_add_dupes_to = $this;
} else {
// create new set for dupes
$t_set_to_add_dupes_to = new ca_sets();
$t_set_to_add_dupes_to->set('type_id', $this->get('type_id'));
$t_set_to_add_dupes_to->set('table_num', $this->get('table_num'));
$t_set_to_add_dupes_to->set('user_id', $this->get('user_id'));
$t_set_to_add_dupes_to->set('set_code', $this->get('set_code') . '-' . _t('dupes'));
$t_set_to_add_dupes_to->setMode(ACCESS_WRITE);
$t_set_to_add_dupes_to->insert();
if (!$t_set_to_add_dupes_to->getPrimaryKey()) {
$this->errors = $t_set_to_add_dupes_to->errors;
return false;
}
$t_set_to_add_dupes_to->addLabel(array('name' => $this->getLabelForDisplay() . ' ' . _t('[Duplicates]')), $g_ui_locale_id, null, true);
}
$va_items = array_keys($this->getItemRowIDs());
$va_dupes = array();
foreach ($va_items as $vn_row_id) {
/** @var BundlableLabelableBaseModelWithAttributes $t_instance */
$t_instance = $this->getAppDatamodel()->getInstance($this->get('table_num'));
if (!$t_user->canDoAction('can_duplicate_' . $t_instance->tableName())) {
$this->postError(2580, _t('You do not have permission to duplicate these items'), 'ca_sets->duplicateItemsInSet()');
return false;
}
if (!$t_instance->load($vn_row_id)) {
continue;
}
// let's dupe
$t_dupe = $t_instance->duplicate(array('user_id' => $pn_user_id, 'duplicate_nonpreferred_labels' => $t_user->getPreference($t_instance->tableName() . '_duplicate_nonpreferred_labels'), 'duplicate_attributes' => $t_user->getPreference($t_instance->tableName() . '_duplicate_attributes'), 'duplicate_relationships' => $t_user->getPreference($t_instance->tableName() . '_duplicate_relationships'), 'duplicate_media' => $t_user->getPreference($t_instance->tableName() . '_duplicate_media'), 'duplicate_subitems' => $t_user->getPreference($t_instance->tableName() . '_duplicate_subitems')));
if ($t_dupe instanceof BaseModel) {
$va_dupes[] = $t_dupe->getPrimaryKey();
}
}
$t_set_to_add_dupes_to->addItems($va_dupes);
return $t_set_to_add_dupes_to;
}