Example #1
0
 protected function _createDirByPath(RM_ObjectFs_Dir $dir, $path)
 {
     $parts = explode('/', $path);
     $tmp = $dir->createDir($parts[0]);
     unset($parts[0]);
     if (count($parts) > 0) {
         $this->_createDirByPath($tmp, join('/', $parts));
     }
     return $tmp;
 }
Example #2
0
 public function free()
 {
     if ($this->_root) {
         $this->_root->free();
     }
     unset($this->_mapper, $this->_root);
     parent::free();
 }
Example #3
0
 /**
  *	Returns list of dir entities.
  *	Available filters:
  *	@code@
  *		name
  *		parent_id
  *		owner_id
  *		cdate
  *		mdate
  *		type
  *	@endcode@
  *
  *	@param		dir	RM_ObjectFs_Dir		Dir
  *	@return		RM_Store_iRequest<RM_ObjecFs_Entity>
  */
 public function dirGetFiles(RM_ObjectFs_Dir $dir)
 {
     return $this->requestFiles()->filter('parent_id = ?', $dir->id());
 }
Example #4
0
 /**
  *	Moves or/and renames entity. For safe move:
  *		$file->move($target, ''); // generates unique filename in target
  *
  *	@param		target      RM_ObjectFs_Dir		Target dir. Pass NULL if you don't want to move entity
  *	@param  	name  		string				New name. Pass empty string if you want to generate name automatically.
  *	@return		void
  */
 public function move(RM_ObjectFs_Dir $target = NULL, $newName = NULL)
 {
     $this->_mapper->access($this, 'OFS-WRITE-INFO');
     // rename
     if ($newName !== NULL) {
         $this->_props['name'] = $newName == '' ? NULL : $newName;
     }
     // move
     if ($target and $this->_props['parent_id'] != $target->id()) {
         $this->_mapper->access($this->getParent(), 'OFS-WRITE-CONTENT');
         $this->_mapper->access($target, 'OFS-WRITE-CONTENT');
         $this->_props['parent_id'] = $target->id();
         $this->_props['fs_id'] = $target->_getFsId();
         if ($this->_accessInherit()) {
             $this->_accessId($target->_accessId());
         }
     }
     try {
         $this->save();
     } catch (RM_Db_Exception_ConstraintViolation $e) {
         throw new RM_ObjectFs_Exception_FileExists($this->getParent(), $this);
     }
 }