* @version $Revision: 24154 $ * @author SARL OpenXtrem * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ CCanDo::checkEdit(); $user_id = CCanDo::edit() ? CValue::getOrSession("user_id", "default") : null; $user = CUser::get($user_id); $prof = $user->profile_id ? CUser::get($user->profile_id) : new CUser(); if ($user_id == "default") { $user->_id = null; } $prefvalues = array("default" => CPreferences::get(null, true), "template" => $user->profile_id ? CPreferences::get($user->profile_id, true) : array(), "user" => $user->_id !== "" ? CPreferences::get($user->_id, true) : array()); // common sera toujours au debut $prefs = array("common" => array()); // Classement par module et par permission fonctionnelle CPreferences::loadModules(true); foreach (CPreferences::$modules as $modname => $prefnames) { $module = CModule::getActive($modname); $canRead = $module ? CPermModule::getPermModule($module->_id, PERM_READ, $user_id) : false; if ($modname == "common" || $user_id == "default" || $canRead) { $prefs[$modname] = array(); foreach ($prefnames as $prefname) { $prefs[$modname][$prefname] = array("default" => CMbArray::extract($prefvalues["default"], $prefname), "template" => CMbArray::extract($prefvalues["template"], $prefname), "user" => CMbArray::extract($prefvalues["user"], $prefname)); } } } // Warning: user clone necessary! // Some module index change $user global $user_clone = $user; // Chargement des modules $modules = CPermModule::getVisibleModules();
/** * Launches module upgrade process * * @param string $oldRevision Revision before upgrade * @param bool $core_upgrade True if it's a core module upgrade * * @return string|null New revision, null on error */ function upgrade($oldRevision, $core_upgrade = false) { /*if (array_key_exists($this->mod_version, $this->queries)) { CAppUI::setMsg("Latest revision '%s' should not have upgrade queries", UI_MSG_ERROR, $this->mod_version); return; }*/ if (!array_key_exists($oldRevision, $this->queries) && !array_key_exists($oldRevision, $this->config_moves) && !array_key_exists($oldRevision, $this->functions)) { CAppUI::setMsg("No queries, functions or config moves for '%s' setup at revision '%s'", UI_MSG_WARNING, $this->mod_name, $oldRevision); return null; } // Point to the current revision reset($this->revisions); while ($oldRevision != ($currRevision = current($this->revisions))) { next($this->revisions); } $depFailed = false; do { // Check for dependencies foreach ($this->dependencies[$currRevision] as $dependency) { $module = @CModule::getInstalled($dependency->module); if (!$module || $module->mod_version < $dependency->revision) { $depFailed = true; CAppUI::setMsg("Failed module depency for '%s' at revision '%s'", UI_MSG_WARNING, $dependency->module, $dependency->revision); } } if ($depFailed) { return $currRevision; } // Set Time Limit if ($this->timeLimit[$currRevision]) { CApp::setTimeLimit($this->timeLimit[$currRevision]); } // Query upgrading foreach ($this->queries[$currRevision] as $_query) { list($query, $ignore_errors, $dsn) = $_query; $ds = $dsn ? CSQLDataSource::get($dsn) : $this->ds; if (!$ds->exec($query)) { if ($ignore_errors) { CAppUI::setMsg("Errors ignored for revision '%s'", UI_MSG_OK, $currRevision); continue; } CAppUI::setMsg("Error in queries for revision '%s': see logs", UI_MSG_ERROR, $currRevision); return $currRevision; } } // Callback upgrading foreach ($this->functions[$currRevision] as $function) { if (!call_user_func($function)) { $function_name = get_class($function[0]) . "->" . $function[1]; CAppUI::setMsg("Error in function '%s' call back for revision '%s': see logs", UI_MSG_ERROR, $function_name, $currRevision); return $currRevision; } } // Preferences foreach ($this->preferences[$currRevision] as $_pref) { list($_name, $_default, $_restricted) = $_pref; // Former pure SQL system // Cannot check against module version or fresh install will generate errors if (self::isOldPrefSystem($core_upgrade)) { $query = "SELECT * FROM `user_preferences` WHERE `pref_user` = '0' AND `pref_name` = '{$_name}'"; $result = $this->ds->exec($query); if (!$this->ds->numRows($result)) { $query = "INSERT INTO `user_preferences` (`pref_user` , `pref_name` , `pref_value`)\n VALUES ('0', '{$_name}', '{$_default}');"; $this->ds->exec($query); } } else { $pref = new CPreferences(); $where = array(); $where["user_id"] = " IS NULL"; $where["key"] = " = '{$_name}'"; if (!$pref->loadObject($where)) { $pref->key = $_name; $pref->value = $_default; $pref->restricted = $_restricted ? "1" : "0"; $pref->store(); } } } // Config moves if (count($this->config_moves[$currRevision])) { foreach ($this->config_moves[$currRevision] as $config) { CAppUI::setConf($config[1], CAppUI::conf($config[0])); } } } while ($currRevision = next($this->revisions)); return $this->mod_version; }
<?php /** * $Id$ * * @category Admin * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $key = CValue::get("key"); // Load preferences $preference = new CPreferences(); $where["key"] = "= '{$key}'"; $where["value"] = "IS NOT NULL"; $preferences = $preference->loadList($where); // Mass preloading /** @var CUser[] $users */ $users = CMbObject::massLoadFwdRef($preferences, "user_id"); $profiles = CMbObject::massLoadFwdRef($users, "profile_id"); // Attach preferences to users $default = null; foreach ($preferences as $_preference) { if (!$_preference->user_id) { $default = $_preference; continue; } $users[$_preference->user_id]->_ref_preference = $_preference;
* @subpackage admin * @version $Revision: 24154 $ * @author SARL OpenXtrem * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html */ $user_id = CCanDo::edit() ? CValue::getOrSession("user_id", "default") : null; $user = CUser::get($user_id); $prof = $user->profile_id ? CUser::get($user->profile_id) : new CUser(); if ($user_id == "default") { $user->_id = null; } $prefvalues = array("default" => CPreferences::get(), "template" => $user->profile_id ? CPreferences::get($user->profile_id) : array(), "user" => $user->_id !== "" ? CPreferences::get($user->_id) : array()); // common sera toujours au debut $prefs = array("common" => array()); // Classement par module et par préférences CPreferences::loadModules(); foreach (CPreferences::$modules as $modname => $prefnames) { $module = CModule::getActive($modname); $canRead = $module ? CPermModule::getPermModule($module->_id, PERM_READ, $user_id) : false; if ($modname == "common" || $user_id == "default" || $canRead) { $prefs[$modname] = array(); foreach ($prefnames as $prefname) { $prefs[$modname][$prefname] = array("default" => CMbArray::extract($prefvalues["default"], $prefname), "template" => CMbArray::extract($prefvalues["template"], $prefname), "user" => CMbArray::extract($prefvalues["user"], $prefname)); } } } // Warning: user clone necessary! // Some module index change $user global $user_clone = $user; // Chargement des modules $modules = CPermModule::getVisibleModules();
<?php /* SYSTEM $Id: do_preference_aed.php,v 1.4 2005/02/10 17:51:14 cyberhorse Exp $ */ $del = isset($_POST['del']) ? $_POST['del'] : 0; $obj = new CPreferences(); $obj->pref_user = isset($_POST['pref_user']) ? $_POST['pref_user'] : 0; foreach ($_POST['pref_name'] as $name => $value) { $obj->pref_name = $name; $obj->pref_value = $value; // prepare (and translate) the module name ready for the suffix $AppUI->setMsg('Preferences'); if ($del) { if ($msg = $obj->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $AppUI->setMsg("deleted", UI_MSG_ALERT, true); } } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { if ($obj->pref_user) { // if user preferences, reload them now $AppUI->loadPrefs($AppUI->user_id); $AppUI->setUserLocale(); include_once dPRealPath("./locales/{$AppUI->user_locale}/locales.php"); include dPRealPath("./locales/core.php"); $AppUI->setMsg('Preferences'); } $AppUI->setMsg("updated", UI_MSG_OK, true); }
/** * Load the stored user preferences from the database into cache * * @param integer $user_id User ID, 0 for default preferences * * @return void */ static function loadPrefs($user_id = null) { $ds = CSQLDataSource::get("std"); if ($ds->loadField("user_preferences", "pref_name")) { // Former pure SQL system $query = "SELECT pref_name, pref_value\n FROM user_preferences\n WHERE pref_user = '******'"; $user_prefs = $ds->loadHashList($query); } else { // Latter object oriented system $user_prefs = CPreferences::get($user_id); } self::$instance->user_prefs = array_merge(self::$instance->user_prefs, $user_prefs); }
$where["source_pop_id"] = " = '{$account_id}'"; } $order = "'last_update' ASC"; $limit = "0, {$nbAccount}"; $sources = $source->loadList($where, $order, $limit); /** @var $sources CSourcePOP[] */ foreach ($sources as $_source) { $user = $_source->loadRefMetaObject(); //no user => next if (!$_source->user) { CAppUI::stepAjax("pas d'utilisateur pour cette source %s", UI_MSG_WARNING, $_source->_view); continue; } // when a mail is copied in mediboard, will it be marked as read on the server ? $markReadServer = 0; $prefs = CPreferences::get($_source->object_id); //for user_id $markReadServer = isset($prefs["markMailOnServerAsRead"]) ? $prefs["markMailOnServerAsRead"] : CAppUI::pref("markMailOnServerAsRead"); $archivedOnReception = isset($prefs["mailReadOnServerGoToArchived"]) ? $prefs["mailReadOnServerGoToArchived"] : CAppUI::pref("mailReadOnServerGoToArchived"); //last email uid from mediboard $mbMailUid = CUserMail::getLastMailUid($_source->_id) ? CUserMail::getLastMailUid($_source->_id) : 0; // last email datetime if ($import) { $firstEmailDate = CUserMail::getFirstMailDate($_source->_id); $firstCheck = $firstEmailDate; $firstCheck = CMbDT::dateTime("+1 DAY", $firstCheck); $month_number = CMbDT::format($firstCheck, "%m"); $month = reset(array_keys(CFTP::$month_to_number, $month_number)); $dateIMAP = CMbDT::format($firstCheck, "%d-{$month}-%Y"); } else { $lastEmailDate = CUserMail::getLastMailDate($_source->_id);
<?php /** * $Id$ * * @category Admin * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkEdit(); $pref_id = CValue::getOrSession("pref_id"); $preference = new CPreferences(); $preference->load($pref_id); $preference->loadRefsNotes(); $smarty = new CSmartyDP(); $smarty->assign("preference", $preference); $smarty->display("inc_edit_pref.tpl");
* * @category Admin * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ $prefs = CValue::post("pref", array()); $user_id = CValue::post("user_id"); $restricted = CValue::post("restricted"); $pref = new CPreferences(); $ds = $pref->getDS(); // @todo: voir à utiliser CDoObjectAddEdit foreach ($prefs as $key => $value) { $pref = new CPreferences(); $where = array("user_id" => $user_id ? $ds->prepare("= '{$user_id}'") : "IS NULL", "key" => $ds->prepare("= '{$key}'")); $pref->loadObject($where); $pref->user_id = $user_id; $pref->key = $key; $pref->value = stripslashes($value); $pref->restricted = $restricted ? "1" : "0"; if ($msg = $pref->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } else { CAppUI::setMsg("CPreferences-msg-modify", UI_MSG_OK); } } // Reload user preferences if ($pref->user_id) { CAppUI::buildPrefs();