本文整理汇总了PHP中UserSettings::set方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSettings::set方法的具体用法?PHP UserSettings::set怎么用?PHP UserSettings::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserSettings
的用法示例。
在下文中一共展示了UserSettings::set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserSettings
/**
* Initialize the order param
*/
function init_order_param()
{
global $UserSettings;
if (empty($UserSettings)) {
$UserSettings = new UserSettings();
}
// attribution of an order type
$this->order_param = 'results_' . $this->param_prefix . 'order';
$order_request = param($this->order_param, 'string', '', true);
// remove symbols '-' from the end
$order_request = rtrim($order_request, '-');
if ($this->force_order_by_count !== NULL && !empty($order_request)) {
// Check if we should force an order filed to default value
if ($this->get_total_rows() > $this->force_order_by_count) {
// This table has very much records we should force an order to default
$reverse_default_order = str_replace('D', 'A', $this->default_order);
$reverse_default_order = $reverse_default_order == $this->default_order ? str_replace('A', 'D', $this->default_order) : $reverse_default_order;
if ($order_request != $this->default_order && $order_request != $reverse_default_order) {
// If an order from request is not default then we must change it to default
$this->order = $this->default_order;
$order_request_title = $order_request;
if (isset($this->cols)) {
// Try to find a title of the ordered field to display it in warning message
$order_index = strpos($order_request, 'A');
$order_index = $order_index === FALSE ? strpos($order_request, 'D') : $order_index;
if (isset($this->cols[$order_index]) && isset($this->cols[$order_index]['th'])) {
$order_request_title = $this->cols[$order_index]['th'];
}
}
// Add a message to inform user about this order type is not allowed in this case
$this->add_message(sprintf(T_('In order to maintain good performance, you cannot sort by %s when there are more than %s results.'), $order_request_title, number_format($this->force_order_by_count, 0, '', ' ')));
}
}
}
if (empty($this->order)) {
// Set an order from GET request
$this->order = $order_request;
}
if (!empty($this->param_prefix) && !empty($this->order) && $this->order != $UserSettings->get($this->order_param)) {
// Change an order param in DB for current user and current list
if ($this->order == $this->default_order) {
// Delete an order param for current list if it is a default value
$UserSettings->delete($this->order_param);
} else {
// Set a new value of an order param for current list
$UserSettings->set($this->order_param, $this->order);
}
$UserSettings->dbupdate();
}
if (!empty($this->param_prefix) && empty($this->order)) {
// Set an order param from DB
if ($UserSettings->get($this->order_param) != '') {
// Set a value for current list if it was already defined
$this->order = $UserSettings->get($this->order_param);
}
}
if (empty($this->order)) {
// Set a default value
$this->order = $this->default_order;
}
}
示例2: array
if (empty($users_to_remind_ids)) {
// There is no user to remind after we have filtered out those ussers who haven't logged in since a long time
$result_message = T_('It was not necessary to send any reminder!');
return 1;
}
// Set TRUE to use gender settings from back office
global $is_admin_page;
$is_admin_page = true;
// Get all those user threads and their recipients where the corresponding users have unread messages
$unread_threads = get_users_unread_threads($users_to_remind_ids, NULL, 'array', 'html');
// Get unread thread urls
list($threads_link) = get_messages_link_to();
$reminder_sent = 0;
foreach ($users_to_remind_ids as $user_ID) {
// send reminder email
$email_template_params = array('unread_threads' => $unread_threads[$user_ID], 'threads_link' => $threads_link);
$notify_User = $UserCache->get_by_ID($user_ID);
// Change locale here to localize the email subject and content
locale_temp_switch($notify_User->get('locale'));
if (send_mail_to_User($user_ID, T_('You have unread messages!'), 'private_messages_unread_reminder', $email_template_params)) {
// Update users last unread message reminder timestamp
$UserSettings->set('last_unread_messages_reminder', date2mysql($servertimenow), $user_ID);
// save UserSettings after each email, because the cron task mail fail and users won't be updated!
$UserSettings->dbupdate();
$reminder_sent++;
}
locale_restore_previous();
}
$result_message = sprintf(T_('%d reminder emails were sent!'), $reminder_sent);
return 1;
/* ok */
示例3: UserSettings
function test_usersettings()
{
$us = new UserSettings();
$this->assertFalse($us->get('foo'));
// no current user
$this->assertNull($us->get('foo', 1));
// not set
$this->assertTrue($us->set('foo', 'bar', 1));
// successfully set
$this->assertEqual('bar', $us->get('foo', 1));
$us->dbupdate();
}
示例4: UserSettings
/**
* Initialize the order param
*
* @param string default ordering of columns (special syntax) if not specified in the URL params
* example: -A-- will sort in ascending order on 2nd column
* example: ---D will sort in descending order on 4th column
*/
function init_order_param($default_order)
{
global $UserSettings;
if (empty($UserSettings)) {
$UserSettings = new UserSettings();
}
// attribution of an order type
$this->order_param = 'results_' . $this->param_prefix . 'order';
$this->order = param($this->order_param, 'string', '', true);
// remove symbols '-' from the end
$this->order = preg_replace('/(-*[AD]+)(-*)/i', '$1', $this->order);
if (!empty($this->param_prefix) && !empty($this->order) && $this->order != $UserSettings->get($this->order_param)) {
// Change an order param in DB for current user and current list
if ($this->order == $default_order) {
// Delete an order param for current list if it is a default value
$UserSettings->delete($this->order_param);
} else {
// Set a new value of an order param for current list
$UserSettings->set($this->order_param, $this->order);
}
$UserSettings->dbupdate();
}
if (!empty($this->param_prefix) && empty($this->order)) {
// Set an order param from DB
if ($UserSettings->get($this->order_param) != '') {
// Set a value for current list if it was already defined
$this->order = $UserSettings->get($this->order_param);
}
}
if (empty($this->order)) {
// Set a default value
$this->order = $default_order;
}
}