コード例 #1
0
ファイル: Changes.php プロジェクト: horde/horde
 /**
  * Return an LDAP changeset from the difference between the current object
  * data and the new dataset.
  *
  * @return array The LDAP changeset.
  */
 public function getChangeset()
 {
     $cs = array();
     $old = $this->_object->readInternal();
     $new = $this->_data;
     $attributes = array_merge(array_keys($old), array_keys($new));
     foreach ($attributes as $attribute) {
         if (!isset($old[$attribute])) {
             $cs['add'][$attribute] = $new[$attribute];
             continue;
         }
         if (!isset($new[$attribute])) {
             $cs['delete'][] = $attribute;
             continue;
         }
         if ((!is_array($new[$attribute]) || count($new[$attribute]) == 1) && (!is_array($old[$attribute]) || count($old[$attribute]) == 1)) {
             if ($new[$attribute][0] == $old[$attribute][0]) {
                 continue;
             } else {
                 $cs['replace'][$attribute] = $new[$attribute][0];
                 continue;
             }
         }
         $adds = array_diff($new[$attribute], $old[$attribute]);
         if (!empty($adds)) {
             $cs['add'][$attribute] = array_values($adds);
         }
         $deletes = array_diff($old[$attribute], $new[$attribute]);
         if (!empty($deletes)) {
             $cs['delete'][$attribute] = array_values($deletes);
         }
     }
     return $cs;
 }
コード例 #2
0
ファイル: Mcached.php プロジェクト: horde/horde
 /**
  * Get the specified internal attributes.
  *
  * @param array $attributes The internal attribute.
  *
  * @return array The value(s) of these attribute
  */
 public function getInternal(array $attributes)
 {
     if (!isset($this->_cache_int[$attr])) {
         if (!in_array($attr, array_keys($this->getInternalAttributes()))) {
             throw new Horde_Kolab_Server_Exception(sprintf("Attribute \"%s\" not supported!", $attr));
         }
         $this->_object->readInternal();
         if (!isset($this->_cache_int[$attr])) {
             throw new Horde_Kolab_Server_Exception(sprintf("Failed to read attribute \"%s\"!", $attr));
         }
     }
     return $this->_cache_int[$attr];
 }
コード例 #3
0
ファイル: Hash.php プロジェクト: horde/horde
 /**
  * Read the object into the cache
  *
  * @return array The read data.
  */
 public function readInternal()
 {
     return $this->_object->readInternal();
 }