本文整理汇总了PHP中UserSettings::get方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSettings::get方法的具体用法?PHP UserSettings::get怎么用?PHP UserSettings::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserSettings
的用法示例。
在下文中一共展示了UserSettings::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: explode
}
}
foreach ($blog_owners as $moderator_ID => $moderator_blogs) {
// Loop through each blog owner users and set the highest permission in their own blogs
$blogs = explode(',', $moderator_blogs);
foreach ($blogs as $blog_ID) {
// Loop through each blogs of this user
if (!isset($moderators[$moderator_ID])) {
// Init this user moderator perms if it was not initialized yet
$moderators[$moderator_ID] = array();
}
$moderators[$moderator_ID][$blog_ID] = array('perm_edit' => $max_perm_edit, 'perm_statuses' => $max_perm_statuses);
}
}
// Set notify moderation condition
$def_send_moderation_reminder = $UserSettings->get('send_cmt_moderation_reminder');
if ($def_send_moderation_reminder) {
// Send comment moderation reminder is set by default
$send_moderation_reminder_cond = '( ( uset_value IS NOT NULL AND uset_value <> \'0\' ) OR ( uset_value IS NULL ) )';
} else {
// Send comment moderation reminder is NOT set by default
$send_moderation_reminder_cond = '( uset_value IS NOT NULL AND uset_value <> \'0\' )';
}
// Select blocked and spam email addresses to prevent sending emails to them
$blocked_emails = $DB->get_col('SELECT emblk_address FROM T_email__blocked WHERE ' . get_mail_blocked_condition());
$blocked_emails_condition = count($blocked_emails) ? 'user_email NOT IN ( "' . implode('","', $blocked_emails) . '" )' : NULL;
// load all required Users ( global moderators, blog owners and users with advanced blog perms )
$all_required_users = array_unique(array_merge($global_moderators, array_keys($moderators)));
$SQL = new SQL();
$SQL->SELECT('T_users.*');
$SQL->FROM('T_users');
示例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: send_admin_notification
/**
* Send notification to users with edit users permission
*
* @param string notification email suject
* @param string notificaiton email template name
* @param array notification email template params
*/
function send_admin_notification($subject, $template_name, $template_params)
{
global $Session, $UserSettings, $current_User;
$UserCache =& get_UserCache();
$template_params = array_merge(array('login' => ''), $template_params);
// Set default subject and permname:
$subject_suffix = ': ' . $template_params['login'];
$perm_name = 'users';
switch ($template_name) {
case 'account_new':
$check_setting = 'notify_new_user_registration';
break;
case 'account_activated':
$check_setting = 'notify_activated_account';
break;
case 'account_closed':
$check_setting = 'notify_closed_account';
break;
case 'account_reported':
$check_setting = 'notify_reported_account';
break;
case 'scheduled_task_error_report':
$subject_suffix = '';
$check_setting = 'notify_cronjob_error';
$perm_name = 'options';
break;
default:
debug_die('Unhandled admin notification template!');
}
if (empty($current_User) && !empty($Session) && $Session->has_User()) {
// current_User is not set at the time of registration
$current_User =& $Session->get_User();
}
if (empty($UserSettings)) {
// initialize UserSettings
load_class('users/model/_usersettings.class.php', 'UserSettings');
$UserSettings = new UserSettings();
}
// load users with edit all users permission
$UserCache->load_where('user_grp_ID = 1 OR user_grp_ID IN ( SELECT gset_grp_ID FROM T_groups__groupsettings WHERE gset_name = "perm_' . $perm_name . '" AND gset_value = "edit" )');
// iterate through UserCache
$UserCache->rewind();
while ($User =& $UserCache->get_next()) {
// Loop through Users
if (is_logged_in() && $current_User->ID == $User->ID) {
// Don't send a notification to current user, because he already knows about this event
continue;
}
if ($UserSettings->get($check_setting, $User->ID) && $User->check_perm($perm_name, 'edit')) {
// this user must be notifed
locale_temp_switch($User->get('locale'));
// send mail to user (using his local)
$localized_subject = T_($subject) . $subject_suffix;
send_mail_to_User($User->ID, $localized_subject, $template_name, $template_params);
// ok, if this may fail
locale_restore_previous();
}
}
}
示例5: check_allow_new_email
/**
* Check if user can receive new email today with the given email type or the limit was already exceeded
*
* @param string the name of limit/day setting
* @param string the name of the last email setting
* @param integer the user ID
* @return integer/boolean Number of next email counter if new email is allowed, false otherwise
*/
function check_allow_new_email($limit_setting, $last_email_setting, $user_ID)
{
global $UserSettings, $servertimenow;
if (empty($UserSettings)) {
// Initialize $UserSettings object (for example, it must be done when cron_exec.php is called in CLI mode):
load_class('users/model/_usersettings.class.php', 'UserSettings');
$UserSettings = new UserSettings();
}
$limit = $UserSettings->get($limit_setting, $user_ID);
if ($limit == 0) {
// user doesn't allow this kind of emails at all
return false;
}
$email_count = 0;
$last_email = $UserSettings->get($last_email_setting, $user_ID);
if (!empty($last_email)) {
// at least one email was sent
$current_date = date('Y-m-d', $servertimenow);
list($last_email_ts, $last_email_count) = explode('_', $last_email);
$last_date = date('Y-m-d', $last_email_ts);
if ($last_date == $current_date) {
// last email was sent today
if ($last_email_count >= $limit) {
// the limit was already reached
return false;
}
$email_count = $last_email_count;
}
}
$email_count++;
return $email_count;
}
示例6: antispam_block_request
/**
* Block request by IP address, Domain of current user or block because of a Plugin
* Bock by Plugin: e.g. GeoIP plugin can block the request if it comes from a blocked country
*/
function antispam_block_request()
{
global $DB, $Plugins;
// Check block by IP
antispam_block_by_ip();
// Check block by domain
if (is_logged_in()) {
// Current user is logged in, We also can check the domains with blocked status
global $current_User, $UserSettings;
if (empty($UserSettings)) {
// Initialize UserSettings
load_class('users/model/_usersettings.class.php', 'UserSettings');
$UserSettings = new UserSettings();
}
$DomainCache =& get_DomainCache();
$user_domain = $UserSettings->get('user_domain', $current_User->ID);
if (!empty($user_domain) && ($Domain =& $DomainCache->get_by_name($user_domain, false, false)) && $Domain->get('status') == 'blocked') {
// The request from this domain must be blocked
$debug_message = sprintf('A request from \'%s\' domain was blocked because of this domain is blocked.', $user_domain);
exit_blocked_request('Domain', $debug_message);
// WILL exit();
}
load_funcs('sessions/model/_hitlog.funcs.php');
$initial_referer = $UserSettings->get('initial_referer', $current_User->ID);
if (!empty($initial_referer) && ($Domain =& get_Domain_by_url($initial_referer)) && $Domain->get('status') == 'blocked') {
// The request from this domain must be blocked
$debug_message = sprintf('A request from \'%s\' initial referer was blocked because of a blocked domain.', $initial_referer);
exit_blocked_request('Domain', $debug_message);
// WILL exit();
}
}
// Check if plugins may block the request
$Plugins->trigger_event('BeforeBlockableAction');
}
示例7: 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;
}
}