示例#1
0
 /**
  * update node
  * 
  * @param Tinebase_Model_Tree_Node $_node
  * @return Tinebase_Model_Tree_Node
  */
 public function updateNode(Tinebase_Model_Tree_Node $_node)
 {
     $currentNodeObject = $this->_treeNodeBackend->get($_node->getId());
     $modLog = Tinebase_Timemachine_ModificationLog::getInstance();
     $modLog->setRecordMetaData($_node, 'update', $currentNodeObject);
     return $this->_treeNodeBackend->update($_node);
 }
 /**
  * @param  string  $path
  * @return Tinebase_Model_Tree_Node
  */
 public function stat($path)
 {
     $pathParts = $this->_splitPath($path);
     $cacheId = $this->_getCacheId($pathParts);
     // let's see if the path is cached in statCache
     if (isset($this->_statCache[$cacheId]) || array_key_exists($cacheId, $this->_statCache)) {
         try {
             // let's try to get the node from backend, to make sure it still exists
             return $this->_treeNodeBackend->get($this->_statCache[$cacheId]);
         } catch (Tinebase_Exception_NotFound $tenf) {
             // something went wrong. let's clear the whole statCache
             $this->clearStatCache();
         }
     }
     $parentNode = null;
     $node = null;
     // find out if we have cached any node up in the path
     while ($pathPart = array_pop($pathParts) !== null) {
         $cacheId = $this->_getCacheId($pathParts);
         if (isset($this->_statCache[$cacheId]) || array_key_exists($cacheId, $this->_statCache)) {
             $parentNode = $this->_statCache[$cacheId];
             break;
         }
     }
     $missingPathParts = array_diff_assoc($this->_splitPath($path), $pathParts);
     foreach ($missingPathParts as $pathPart) {
         $node = $this->_treeNodeBackend->getChild($parentNode, $pathPart);
         // keep track of current path position
         array_push($pathParts, $pathPart);
         // add found path to statCache
         $this->_addStatCache($pathParts, $node);
         $parentNode = $node;
     }
     return $node;
 }