本文整理汇总了PHP中Config::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::setValue方法的具体用法?PHP Config::setValue怎么用?PHP Config::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doBackup
/**
* Realizar backup de la BBDD y aplicación.
*
* @return bool
*/
public static function doBackup()
{
$siteName = Util::getAppInfo('appname');
$backupDir = Init::$SERVERROOT;
// Generar hash unico para evitar descargas no permitidas
$backupUniqueHash = uniqid();
Config::setValue('backup_hash', $backupUniqueHash);
$backupDstDir = $backupDir . DIRECTORY_SEPARATOR . 'backup';
$bakFileApp = $backupDstDir . DIRECTORY_SEPARATOR . $siteName . '-' . $backupUniqueHash . '.tar';
$bakFileDB = $backupDstDir . DIRECTORY_SEPARATOR . $siteName . '_db-' . $backupUniqueHash . '.sql';
try {
self::checkBackupDir($backupDstDir);
self::deleteOldBackups($backupDstDir);
self::backupTables('*', $bakFileDB);
self::backupApp($bakFileApp);
} catch (\Exception $e) {
Log::writeNewLogAndEmail(__FUNCTION__, $e->getMessage());
return false;
}
return true;
}
示例2: upgradeConfig
/**
* Migrar valores de configuración.
*
* @param int $version El número de versión
* @return bool
*/
public static function upgradeConfig($version)
{
$mapParams = array('files_allowed_exts' => 'allowed_exts', 'files_allowed_size' => 'allowed_size', 'demo_enabled' => 'demoenabled', 'files_enabled' => 'filesenabled', 'ldap_base' => 'ldapbase', 'ldap_bindpass' => 'ldapbindpass', 'ldap_binduser' => 'ldapbinduser', 'ldap_enabled' => 'ldapenabled', 'ldap_group' => 'ldapgroup', 'ldap_server' => 'ldapserver', 'log_enabled' => 'logenabled', 'mail_enabled' => 'mailenabled', 'mail_from' => 'mailfrom', 'mail_pass' => 'mailpass', 'mail_port' => 'mailport', 'mail_requestsenabled' => 'mailrequestsenabled', 'mail_security' => 'mailsecurity', 'mail_server' => 'mailserver', 'mail_user' => 'mailuser', 'wiki_enabled' => 'wikienabled', 'wiki_filter' => 'wikifilter', 'wiki_pageurl' => 'wikipageurl', 'wiki_searchurl' => 'wikisearchurl');
$currData = Config::getKeys(true);
foreach ($mapParams as $newParam => $oldParam) {
if (array_key_exists($oldParam, $currData)) {
Config::setValue($newParam, $currData[$oldParam]);
Config::deleteParam($oldParam);
}
}
Log::writeNewLog(_('Actualizar Configuración'), _('Actualización de la Configuración realizada correctamente.') . ' (v' . $version . ')');
return true;
}
示例3: saveSettings
/**
* called by include/dashboard_ajax.php
*
* save dashboard settings for [team, user]
*
* Note: the dashboard can contain the same plugin
* multiple times, each one having specific attributes.
* ex: ProgressHistoryIndic for Cmd1, Cmd2, Cmd2
*
* settings = array (
* 'dashboardTitle' => 'dashboard title'
* 'displayedPlugins' => array(
* array(
* 'pluginClassName' => <pluginClassName>,
* 'plugin_attr1' => 'val',
* 'plugin_attr2' => 'val',
* )
* )
* )
*
* @param array $settings containing dashboard & plugin attributes.
* @param int $teamid
* @param int $userid if NULL, default settings for team will be saved.
*/
public function saveSettings($settings, $teamid, $userid = NULL)
{
if (!is_array($settings)) {
self::$logger->error("saveSettings: not an array !");
return false;
}
if (!array_key_exists(self::SETTINGS_DISPLAYED_PLUGINS, $settings)) {
self::$logger->error("saveSettings: missing key: " . self::SETTINGS_DISPLAYED_PLUGINS);
return false;
}
if (!array_key_exists(self::SETTINGS_DASHBOARD_TITLE, $settings)) {
self::$logger->error("saveSettings: missing key: " . self::SETTINGS_DASHBOARD_TITLE);
return false;
}
$jsonSettings = json_encode($settings);
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("saveSettings: save ok: " . $jsonSettings);
}
Config::setValue(Config::id_dashboard . $this->id, $jsonSettings, Config::configType_string, NULL, 0, $userid, $teamid);
}
示例4: setGeneralPrefsList
/**
* @param array $checkList ('checkName' => [0,1] isEnabled)
*/
function setGeneralPrefsList(array $checkList)
{
$this->generalPrefsList = $checkList;
$keyvalue = Tools::doubleImplode(':', ',', $this->generalPrefsList);
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Write team {$this->id} generalPrefsList : {$keyvalue}");
}
// save new settings
Config::setValue(Config::id_teamGeneralPreferences, $keyvalue, Config::configType_keyValue, NULL, 0, 0, $this->id);
}
示例5: setValue
/** old style usage with $value, $user_id, $key as params
* still works but is deprecated
*
* @see lib/classes/Config::setValue()
*/
function setValue($field, $value)
{
$args = func_get_args();
if (count($args) > 2) {
list($value, $user_id, $key) = $args;
if ($user_id !== null && $key !== null) {
$ret = UserConfig::get($user_id)->store($key, $value);
}
if ($user_id === null && $key !== null) {
$ret = $this->store($key, $value);
}
trigger_error('deprecated use of ' . __METHOD__, E_USER_NOTICE);
return $ret;
}
return parent::setValue($field, $value);
}
示例6: setExportFile
/**
* Genera el nombre del archivo usado para la exportación.
*/
private function setExportFile()
{
// Generar hash unico para evitar descargas no permitidas
$exportUniqueHash = uniqid();
Config::setValue('export_hash', $exportUniqueHash);
$this->_exportFile = $this->_exportDir . DIRECTORY_SEPARATOR . Util::getAppInfo('appname') . '-' . $exportUniqueHash . '.xml';
}
示例7: migrateConfig
/**
* Migrar la configuración desde phpPMS.
*
* @return array resultado
*/
private static function migrateConfig()
{
// Obtener la configuración actual
self::getSourceConfig();
$skip = array('version', 'installed', 'install', 'dbhost', 'dbname', 'dbuser', 'dbpass', 'siteroot', 'sitelang', 'sitename', 'siteshortname', 'md5_pass', 'password_show', 'lastupdatempass', 'passwordsalt');
$totalParams = count(self::$_oldConfig);
$num = 0;
// Guardar la nueva configuración
foreach (self::$_oldConfig as $key => $value) {
if (array_key_exists($key, $skip)) {
continue;
}
Config::setValue($key, $value);
$num++;
}
$log = new Log(_('Importar Configuración'));
$log->addDescription('OK');
$log->addDescription(_('Registros') . ': ' . $num . '/' . $totalParams);
$log->writeLog();
}
示例8: array
if ($isJob3) {
Jobs::create($job3, Job::type_commonJob, $job3_color);
}
if ($isJob4) {
Jobs::create($job4, Job::type_commonJob, $job4_color);
}
if ($isJob5) {
Jobs::create($job5, Job::type_commonJob, $job5_color);
}
// Set default Issue tooltip content
echo "<script type=\"text/javascript\">console.log(\"DEBUG set default content for Issue tooltip\");</script>";
$customField_type = Config::getInstance()->getValue(Config::id_customField_type);
$backlogField = Config::getInstance()->getValue(Config::id_customField_backlog);
$fieldList = array('project_id', 'category_id', 'custom_' . $customField_type, 'status', 'codevtt_elapsed', 'custom_' . $backlogField, 'codevtt_drift');
$serialized = serialize($fieldList);
Config::setValue(Config::id_issueTooltipFields, $serialized, Config::configType_string, 'fields to be displayed in issue tooltip');
// Add custom fields to existing projects
echo "<script type=\"text/javascript\">console.log(\"DEBUG prepare existing projects\");</script>";
if (isset($_POST['projects']) && !empty($_POST['projects'])) {
$selectedProjects = $_POST['projects'];
foreach ($selectedProjects as $projectid) {
$project = ProjectCache::getInstance()->getProject($projectid);
echo "<script type=\"text/javascript\">console.log(\" prepare project: " . $project->getName() . "\");</script>";
Project::prepareProjectToCodev($projectid);
}
}
echo "<script type=\"text/javascript\">console.log(\"DEBUG install Mantis plugin: CodevTT\");</script>";
$errStr = installMantisPlugin('CodevTT', true);
if (NULL !== $errStr) {
echo "<script type=\"text/javascript\">console.error(\"{$errStr}\");</script>";
$errMsg .= $errStr . '<br>';
示例9: setupMySQLDatabase
/**
* Configurar la base de datos.
* Esta función crea la base de datos y el usuario necesario para sysPass.
*
* @throws SPException
*/
private static function setupMySQLDatabase()
{
// Si no es modo hosting se crea un hash para la clave y un usuario con prefijo "sp_" para la DB
if (!self::$_isHostingMode) {
self::setDbpass(md5(time() . self::$_password));
self::setDbuser(substr('sp_' . self::$_username, 0, 16));
// Comprobar si el usuario sumistrado existe
$query = "SELECT COUNT(*) FROM mysql.user WHERE user='" . self::$_username . "' AND host='" . self::$_dbhost . "'";
try {
// Si no existe el usuario, se intenta crear
if (intval(self::$_dbc->query($query)->fetchColumn()) === 0) {
// Se comprueba si el nuevo usuario es distinto del creado en otra instalación
if (self::$_dbuser != Config::getValue('dbuser')) {
self::createDBUser();
}
}
} catch (\PDOException $e) {
throw new SPException(SPException::SP_CRITICAL, _('No es posible comprobar el usuario de sysPass') . ' (' . self::$_username . ')', _('Compruebe los permisos del usuario de conexión a la BD'));
}
}
// Guardar el nuevo usuario/clave de conexión a la BD
Config::setValue('dbuser', self::$_dbuser);
Config::setValue('dbpass', self::$_dbpass);
try {
self::createMySQLDatabase();
self::createDBStructure();
} catch (SPException $e) {
throw $e;
}
}
示例10: setIssueTooltipFields
/**
* store fields to display in the Issue tooltip
*
* fields can be
* - mantis_bug_table columns (ex: project_id, status)
* - customField id prefixed with 'custom_' (ex: custom_23)
* - CodevTT fields prefixed with 'codevtt_' (ex: codevtt_commands)
*
* if $fieldList == NULL, delete IssueTooltip custo for this project
*
* @param array $fieldList
* @param int $teamid
* @param int $userid
*/
public function setIssueTooltipFields($fieldList = NULL, $teamid = 0, $userid = 0)
{
if (!is_null($fieldList)) {
$serialized = serialize($fieldList);
Config::setValue('issue_tooltip_fields', $serialized, Config::configType_string, 'fields to be displayed in issue tooltip', $this->id, $userid, $teamid);
$key = 'team' . $teamid . '_user' . $userid;
if (is_null($this->issueTooltipFieldsCache)) {
$this->issueTooltipFieldsCache = array();
}
$this->issueTooltipFieldsCache[$key] = $fieldList;
} else {
// if $fieldList NULL, remove issueTooltip custo fot this project
Config::deleteValue(Config::id_issueTooltipFields, array($userid, $this->id, $teamid, 0, 0, 0));
unset($this->issueTooltipFieldsCache[$key]);
}
}
示例11: setPlanningOptions
/**
*
* @param int $team_id
* @param array $planningOptions as key:value
*/
public function setPlanningOptions($team_id, $planningOptions)
{
$this->planningOptions = $planningOptions;
$keyvalue = Tools::doubleImplode(':', ',', $this->planningOptions);
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Write user {$this->id}, team {$team_id}, planningOptions = {$keyvalue}");
}
// save new settings
Config::setValue(Config::id_planningOptions, $keyvalue, Config::configType_keyValue, NULL, 0, $this->id, $team_id);
}
示例12: testSetValueWithEmptyIdentifier
/**
* Test
*
* @return void
*/
public function testSetValueWithEmptyIdentifier()
{
$this->assertFalse($this->object->setValue('', 'string_result_insert_value'));
}
示例13: array
if ($isJob3) {
Jobs::create($job3, Job::type_commonJob, $job3_color);
}
if ($isJob4) {
Jobs::create($job4, Job::type_commonJob, $job4_color);
}
if ($isJob5) {
Jobs::create($job5, Job::type_commonJob, $job5_color);
}
// Set default Issue tooltip content
echo "DEBUG 14/16 Set default content for Issue tooltip <br/>";
$customField_type = Config::getInstance()->getValue(Config::id_customField_type);
$backlogField = Config::getInstance()->getValue(Config::id_customField_backlog);
$fieldList = array('project_id', 'category_id', 'custom_' . $customField_type, 'codevtt_elapsed', 'custom_' . $backlogField, 'codevtt_drift');
$serialized = serialize($fieldList);
Config::setValue('issue_tooltip_fields', $serialized, Config::configType_string, 'fields to be displayed in issue tooltip');
// Add custom fields to existing projects
echo "DEBUG 15/16 Prepare existing projects<br/>";
if (isset($_POST['projects']) && !empty($_POST['projects'])) {
$selectedProjects = $_POST['projects'];
foreach ($selectedProjects as $projectid) {
$project = ProjectCache::getInstance()->getProject($projectid);
echo "DEBUG prepare project: " . $project->getName() . "<br/>";
Project::prepareProjectToCodev($projectid);
}
}
echo "DEBUG 16/16 Install Mantis plugins<br/>";
installMantisPlugin('CodevTT', true);
installMantisPlugin('FilterBugList', false);
echo "DEBUG done.<br/>";
// load homepage
示例14: changeConfigTable
public function changeConfigTable($definition)
{
try {
$change = new SimpleXMLElement($definition);
$operation = $change->operation;
$operation = trim($operation . "");
switch ($operation) {
case 'UPDATE':
$key = trim($change->key . "");
$value = trim($change->value . "");
$result = $this->_setConfigValue($key, $value);
break;
case 'ADD':
$key = trim($change->key . "");
$value = trim($change->value . "");
$config = new Config();
$config->setProperty($key);
$config->setValue($value);
$config->save();
default:
}
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
}
示例15: update_v10_to_v11
/**
* update 0.99.19 to 0.99.20 (DB v10 to DB v11)
*
* there is no .sql script to run, but db version is increased to 11 (add default issue_tooltip_fields)
*
*/
function update_v10_to_v11()
{
// add default issue tooltips
$customField_type = Config::getInstance()->getValue(Config::id_customField_type);
$backlogField = Config::getInstance()->getValue(Config::id_customField_backlog);
$fieldList = array('project_id', 'category_id', 'custom_' . $customField_type, 'codevtt_elapsed', 'custom_' . $backlogField, 'codevtt_drift');
$serialized = serialize($fieldList);
Config::setValue('issue_tooltip_fields', $serialized, Config::configType_string, 'fields to be displayed in issue tooltip');
$query = "UPDATE `codev_config_table` SET `value`='11' WHERE `config_id`='database_version';";
$result = execQuery($query);
}