コード例 #1
0
 function install()
 {
     if ($this->firstExec('cacheqgis')) {
         $profiles = new jIniFileModifier(jApp::configPath('profiles.ini.php'));
         if (!$profiles->isSection('jcache:qgisprojects')) {
             $profiles->setValues(array('enabled' => 1, 'driver' => 'file', 'ttl' => 0), 'jcache:qgisprojects');
             $profiles->save();
         }
     }
 }
 /**
  * @param jIniFileModifier $ini
  */
 protected function modifyIni($ini)
 {
     if ($ini->isSection('mailLogger')) {
         // in a previous update (newerrormanager), emailHeaders was
         // moved with the value of email, so we should delete it
         // except if it has been changed since..
         $logEmail = $ini->getValue('email', 'mailLogger');
         $logEmailHeaders = $ini->getValue('emailHeaders', 'mailLogger');
         if ($logEmail == $logEmailHeaders) {
             $ini->removeValue('emailHeaders', 'mailLogger');
         }
     }
 }
コード例 #3
0
 /**
  * declare a new db profile. if the content of the section is not given,
  * it will declare an alias to the default profile
  * @param string $name  the name of the new section/alias
  * @param null|string|array  $sectionContent the content of the new section, or null
  *     to create an alias.
  * @param boolean $force true:erase the existing profile
  * @return boolean true if the ini file has been changed
  */
 protected function declareDbProfile($name, $sectionContent = null, $force = true)
 {
     $profiles = new jIniFileModifier(jApp::configPath('profiles.ini.php'));
     if ($sectionContent == null) {
         if (!$profiles->isSection('jdb:' . $name)) {
             // no section
             if ($profiles->getValue($name, 'jdb') && !$force) {
                 // already a name
                 return false;
             }
         } else {
             if ($force) {
                 // existing section, and no content provided : we erase the section
                 // and add an alias
                 $profiles->removeValue('', 'jdb:' . $name);
             } else {
                 return false;
             }
         }
         $default = $profiles->getValue('default', 'jdb');
         if ($default) {
             $profiles->setValue($name, $default, 'jdb');
         } else {
             // default is a section
             $profiles->setValue($name, 'default', 'jdb');
         }
     } else {
         if ($profiles->getValue($name, 'jdb') !== null) {
             if (!$force) {
                 return false;
             }
             $profiles->removeValue($name, 'jdb');
         }
         if (is_array($sectionContent)) {
             foreach ($sectionContent as $k => $v) {
                 $profiles->setValue($k, $v, 'jdb:' . $name);
             }
         } else {
             $profile = $profiles->getValue($sectionContent, 'jdb');
             if ($profile !== null) {
                 $profiles->setValue($name, $profile, 'jdb');
             } else {
                 $profiles->setValue($name, $sectionContent, 'jdb');
             }
         }
     }
     $profiles->save();
     jProfiles::clear();
     return true;
 }
コード例 #4
0
 /**
  * Removes a repository
  */
 public static function removeRepository($key)
 {
     if (!in_array($key, self::$repositories)) {
         if (!in_array($key, self::getRepositoryList())) {
             return false;
         }
     }
     // Get access to the ini file
     $iniFile = jApp::configPath('lizmapConfig.ini.php');
     $ini = new jIniFileModifier($iniFile);
     // Remove the section corresponding to the repository
     $section = 'repository:' . $key;
     if ($ini->isSection($section)) {
         $ini->removeValue(null, $section);
         $ini->save();
         self::getRepositoryList();
         if (array_key_exists($key, self::$repositoryInstances)) {
             unset(self::$repositoryInstances[$key]);
         }
         return true;
     }
     return false;
 }
コード例 #5
0
 /**
  * @param jIniFileModifier $ini
  */
 protected function modifyIni($ini)
 {
     if ($ini->isSection('logfiles')) {
         $ini->renameSection('logfiles', 'fileLogger');
     }
 }