/** * url_stat * * @param string $_path * @param array $_flags * @return boolean|array */ public function url_stat($_path, $_flags) { $nodeController = Expressodriver_Controller_Node::getInstance(); $statLink = (bool) ($_flags & STREAM_URL_STAT_LINK); $quiet = (bool) ($_flags & STREAM_URL_STAT_QUIET); try { $node = $nodeController->stat(substr($_path, 11)); } catch (Tinebase_Exception_InvalidArgument $teia) { if (!$quiet) { trigger_error($teia->getMessage(), E_USER_WARNING); } return false; } catch (Tinebase_Exception_NotFound $tenf) { if (!$quiet) { trigger_error($tenf->getMessage(), E_USER_WARNING); } return false; } $timestamp = $node->last_modified_time instanceof Tinebase_DateTime ? $node->last_modified_time->getTimestamp() : $node->creation_time->getTimestamp(); $mode = 0; // set node type (directory, file, link) $mode = $node->type == Tinebase_Model_Tree_FileObject::TYPE_FOLDER ? $mode | 040000 : $mode | 0100000; $stat = array(0 => 0, 1 => crc32($node->object_id), 2 => $mode, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => $node->size, 8 => $timestamp, 9 => $timestamp, 10 => $node->creation_time->getTimestamp(), 11 => -1, 12 => -1, 'dev' => 0, 'ino' => crc32($node->object_id), 'mode' => $mode, 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => $node->size, 'atime' => $timestamp, 'mtime' => $timestamp, 'ctime' => $node->creation_time->getTimestamp(), 'blksize' => -1, 'blocks' => -1); return $stat; }
/** * save node * save node here in json fe just updates meta info (name, description, relations, customfields, tags, notes), * if record already exists (after it had been uploaded) * @param array with record data * @return array with tree node */ public function saveNode($recordData) { if (isset($recordData['created_by']) || array_key_exists('created_by', $recordData)) { return $this->_save($recordData, Expressodriver_Controller_Node::getInstance(), 'Node'); } else { // on upload complete return $recordData; } }
/** * the singleton pattern * * @return Expressodriver_Controller_Node */ public static function getInstance() { if (self::$_instance === NULL) { self::$_instance = new Expressodriver_Controller_Node(); } return self::$_instance; }