本文整理匯總了PHP中rcube_db::is_replicated方法的典型用法代碼示例。如果您正苦於以下問題:PHP rcube_db::is_replicated方法的具體用法?PHP rcube_db::is_replicated怎麽用?PHP rcube_db::is_replicated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rcube_db
的用法示例。
在下文中一共展示了rcube_db::is_replicated方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
/**
* Write the given user prefs to the user's record
*
* @param array $a_user_prefs User prefs to save
* @param bool $no_session Simplified language/preferences handling
*
* @return boolean True on success, False on failure
*/
function save_prefs($a_user_prefs, $no_session = false)
{
if (!$this->ID) {
return false;
}
$plugin = $this->rc->plugins->exec_hook('preferences_update', array('userid' => $this->ID, 'prefs' => $a_user_prefs, 'old' => (array) $this->get_prefs()));
if (!empty($plugin['abort'])) {
return;
}
$a_user_prefs = $plugin['prefs'];
$old_prefs = $plugin['old'];
$config = $this->rc->config;
// merge (partial) prefs array with existing settings
$save_prefs = $a_user_prefs + $old_prefs;
unset($save_prefs['language']);
// don't save prefs with default values if they haven't been changed yet
foreach ($a_user_prefs as $key => $value) {
if ($value === null || !isset($old_prefs[$key]) && $value == $config->get($key)) {
unset($save_prefs[$key]);
}
}
$save_prefs = serialize($save_prefs);
if (!$no_session) {
$this->language = $_SESSION['language'];
}
$this->db->query("UPDATE " . $this->db->table_name('users') . " SET preferences = ?" . ", language = ?" . " WHERE user_id = ?", $save_prefs, $this->language, $this->ID);
// Update success
if ($this->db->affected_rows() !== false) {
$this->data['preferences'] = $save_prefs;
if (!$no_session) {
$config->set_user_prefs($a_user_prefs);
if (isset($_SESSION['preferences'])) {
$this->rc->session->remove('preferences');
$this->rc->session->remove('preferences_time');
}
}
return true;
} else {
if (!$no_session && $this->db->is_replicated() && $config->get('session_storage', 'db') != 'db') {
$_SESSION['preferences'] = $save_prefs;
$_SESSION['preferences_time'] = time();
$config->set_user_prefs($a_user_prefs);
$this->data['preferences'] = $save_prefs;
}
}
return false;
}