Esempio n. 1
0
 /**
  * Callback for a common operation for upgrade
  *
  * @param string  $path       File short path
  * @param boolean $isTestMode If in test mode
  *
  * @return void
  */
 protected function addFileCallback($path, $isTestMode)
 {
     if ($isTestMode) {
         // Short names
         $topDir = $this->manageFile($path, 'getDir');
         $lcRoot = \Includes\Utils\FileManager::getRealPath(LC_DIR_ROOT);
         $sysRoot = \Includes\Utils\FileManager::getRealPath('/');
         // Search for writable directory
         while (!\Includes\Utils\FileManager::isDir($topDir) && $topDir !== $lcRoot && $topDir !== $sysRoot) {
             $topDir = \Includes\Utils\FileManager::getDir($topDir);
         }
         // Permissions are invalid
         if (!\Includes\Utils\FileManager::isDirWriteable($topDir)) {
             $this->addFileErrorMessage('Directory is not writable: "{{dir}}"', $path, false, array('dir' => $topDir));
             $this->wrongPermissions[] = $topDir;
         }
     } else {
         $source = $this->getFileSource($path);
         if ($source !== null) {
             if ($this->manageFile($path, 'write', array($source))) {
                 $this->addFileInfoMessage('File is added', $path, true);
             } else {
                 $this->addFileErrorMessage('Unable to add file', $path, true);
             }
         } else {
             $this->addFileErrorMessage('Unable to read file while adding', $path, true);
         }
     }
 }