Пример #1
0
 /**
  * Move a file with or without security rights, depends on @param $bSecured
  * - This file must be writable
  * - The target file shouldn't exist
  * - The target directory must be writable (see @param $bSecured)
  *
  * @param string $sDirectory Targeted directory
  * @param string $sName Optional new name
  * @param boolean $bSecured :
  * - If set to TRUE : Rights will be kept
  * - If set to FALSE :
  *   - Rights will not be kept and new rights will depends on new parent directory
  *   - The target directory must be readable, but not necessary writable
  * @return null|string|XML_File If $bSecured is set to true, the resulting new XML_file if move success or null if not
  *    If $bSecured is set to false, then it will return (string) path if move success or null if not.
  */
 protected function moveSecured(fs\directory $dir, $sNewName = '', $bSecured = true)
 {
     $result = null;
     if ($this->checkRights(\Sylma::MODE_WRITE)) {
         $sName = $this->getName();
         if (!$sNewName) {
             $sNewName = $sName;
         }
         if ($bSecured && !$dir->checkRights(\Sylma::MODE_WRITE)) {
             $this->throwException("Cannot write to directory : {$dir}");
         }
         if (rename($this->getRealPath(), $dir->getRealPath() . '/' . $sNewName)) {
             //        $this->update();
             /*
                     if ($dir != $this->getParent()) {
             
                       if ($bSecured) {
             
                         $dir->getSettings()->updateFile($sNewName, $this->getOwner(), $this->getGroup(), $this->getMode()); // copy security attributes
                       }
             
                       $this->getSettings()->deleteFile($sName);
                     }
             */
             if ($bSecured) {
                 $result = $dir->updateFile($sNewName);
             } else {
                 $result = $dir . '/' . $sNewName;
             }
             // if not secured, target file may be not readable
             // update directory settings
             //$this->getSettings()->updateFileName($this->getName(), $sName);
         }
     }
     return $result;
 }
Пример #2
0
 protected function onFinish()
 {
     if ($this->tmp) {
         $this->tmp->delete();
     }
 }
Пример #3
0
 protected function findAction(fs\directory $dir, $sPath)
 {
     $result = null;
     foreach ($this->getExtensions() as $sExtension) {
         if ($result = $dir->getFile($sPath . '.' . $sExtension, false)) {
             break;
         }
     }
     return $result;
 }