protected function _moveUserDataFolders($source, $destination, $chmodOctal) { $system = new RM_Filesystem(); if (!is_dir($destination)) { mkdir($destination); chmod($destination, $chmodOctal); } $system->recursivecopy($source, $destination); rmdir($source); chmod($destination, $chmodOctal); }
/** Copy the new Core files to the RM folder and upgrade the files * step 4 * * @return json */ public function copyfilesJsonAction() { $core = $this->_getParam('core'); $modules = $this->_getParam('modules'); $plugins = $this->_getParam('plugins'); $userdata = $this->_getParam('userdata'); // sources $coreSource = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'temp', 'upgrade', 'system')); $moduleSource = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'temp', 'upgrade', 'modules')); $pluginSource = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'temp', 'upgrade', 'plugins')); $userdataSource = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata', 'temp', 'upgrade', 'userdata')); // destinations $coreDest = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'system')); $moduleDest = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'modules')); $pluginDest = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'plugins')); $userdataDest = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getRootPath(), 'RM', 'userdata')); // this is any file excludes //$systemExclude = array('application'.DIRECTORY_SEPARATOR.'controllers'.DIRECTORY_SEPARATOR.'RM'.DIRECTORY_SEPARATOR.'Admin'); $userDataExclude = array('backups', 'images' . DIRECTORY_SEPARATOR . 'media', 'images' . DIRECTORY_SEPARATOR . 'units', 'logs', 'css' . DIRECTORY_SEPARATOR . 'user_overrides.css', 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'scripts' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'invoice.phtml'); $msg = 0; $RMFS = new RM_Filesystem(); if ($modules) { $copyResult = $RMFS->recursivecopy($moduleSource, $moduleDest); if (!$copyResult) { $msg .= " Errors occured in copying upgrade files: " . $copyResult; } } if ($plugins) { $copyResult = $RMFS->recursivecopy($pluginSource, $pluginDest); if (!$copyResult) { $msg .= " Errors occured in copying upgrade files: " . $copyResult; } } if ($userdata) { $copyResult = $RMFS->recursivecopy($userdataSource, $userdataDest, $userDataExclude); if (!$copyResult) { $msg .= " Errors occured in copying upgrade files: " . $copyResult; } } // core must be last, as the script running the upgrade will be replaced if ($core) { // !!!MUST BE LAST!!!! $copyResult = $RMFS->recursivecopy($coreSource, $coreDest); if (!$copyResult) { $msg .= " Errors occured in copying upgrade files: " . $copyResult; } } if ($msg === 0) { RM_Environment::getInstance()->clearCache(); RM_Log::toLog('Upgrade - File Copy Completed OK', RM_Log::INFO); return array('data' => array('success' => true)); } else { RM_Log::toLog('Upgrade - File Copy Failed', RM_Log::ERR); return array('data' => array('success' => false, 'msg' => $msg)); } }
protected function _copyMediaFiles(RM_Unit_Row $original, RM_Unit_Row $copy) { $rmConfig = new RM_Config(); $chmodOctal = intval($rmConfig->getValue('rm_config_chmod_value'), 8); $destination = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getCorePath(), 'userdata', 'images', 'units', $copy->getId())); $result = mkdir($destination, $chmodOctal, true); if (!$result) { throw new RM_Exception(RM_Environment::getInstance()->getTranslation()->_('Admin.Units.List', 'CopyErrorMediaFolderCreation') . ' ' . $destination); } $fileSystem = new RM_Filesystem(); $source = implode(DIRECTORY_SEPARATOR, array(RM_Environment::getConnector()->getCorePath(), 'userdata', 'images', 'units', $original->getId())); $result = $fileSystem->recursivecopy($source, $destination); if ($result == false) { throw new RM_Exception(sprintf(RM_Environment::getInstance()->getTranslation()->_('Admin.Units.List', 'CopyErrorMediaFilesCopy'), $source, $destination)); } }