Автор: Michael Slusarz (slusarz@horde.org)
Наследование: implements Iterator, implements Serializable
Пример #1
0
 /**
  * Stores changed preferences in the storage backend.
  *
  * @param Horde_Prefs_Scope $scope_ob  The scope object.
  *
  * @throws Horde_Prefs_Exception
  */
 public function store($scope_ob)
 {
     $this->_loadFileCache();
     /* Driver has no support for storing locked status. */
     foreach ($scope_ob->getDirty() as $name) {
         $value = $scope_ob->get($name);
         if (is_null($value)) {
             unset($this->_fileCache[$scope_ob->scope][$name]);
         } else {
             $this->_fileCache[$scope_ob->scope][$name] = $value;
         }
     }
     $tmp_file = Horde_Util::getTempFile('PrefsFile', true, $this->_params['directory']);
     if (file_put_contents($tmp_file, serialize($this->_fileCache)) === false || @rename($tmp_file, $this->_fullpath) === false) {
         throw new Horde_Prefs_Exception(sprintf('Write of preferences to %s failed', $this->_fullpath));
     }
 }
Пример #2
0
 /**
  * Stores changed preferences in the storage backend.
  *
  * @param Horde_Prefs_Scope $scope_ob  The scope object.
  *
  * @throws Horde_Prefs_Exception
  */
 public function store($scope_ob)
 {
     /** This *must* succeed */
     $data = $this->_getStorage(true);
     $query = $data->getQuery(Horde_Kolab_Storage_Data::QUERY_PREFS);
     try {
         $pref = $query->getApplicationPreferences($scope_ob->scope);
     } catch (Horde_Kolab_Storage_Exception $e) {
         $pref = array('application' => $scope_ob->scope);
     }
     if (isset($pref['pref'])) {
         $new = $this->_prefToArray($pref['pref']);
     } else {
         $new = array();
     }
     foreach ($scope_ob->getDirty() as $name) {
         $new[$name] = $scope_ob->get($name);
     }
     $pref['pref'] = $this->_arrayToPref($new);
     try {
         if (!isset($pref['uid'])) {
             $data->create($pref);
         } else {
             $data->modify($pref);
         }
     } catch (Horde_Kolab_Storage_Exception $e) {
         throw new Horde_Prefs_Exception($e);
     }
 }