Ejemplo n.º 1
0
 /**
  * Decompress uploaded plugin and install in the correct plugin directory.
  * $param function string type of operation to perform after upload ('upgrade' or 'install')
  */
 function uploadPlugin($function)
 {
     $templateMgr =& TemplateManager::getManager();
     $this->setupTemplate(true);
     $templateMgr->assign('error', false);
     $templateMgr->assign('uploaded', false);
     $templateMgr->assign('path', $function);
     $templateMgr->assign('pageHierarchy', PluginManagementHandler::setBreadcrumbs(true));
     if (Request::getUserVar('uploadPlugin')) {
         import('file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $user =& Request::getUser();
         if ($temporaryFile = $temporaryFileManager->handleUpload('newPlugin', $user->getId())) {
             // tar archive basename must equal plugin directory name, and plugin files must be in root directory
             $pluginName = basename($temporaryFile->getOriginalFileName(), '.tar.gz');
             $pluginDir = dirname($temporaryFile->getFilePath());
             exec('tar -xzf ' . escapeshellarg($temporaryFile->getFilePath()) . ' -C ' . escapeshellarg($pluginDir));
             if ($function == 'install') {
                 PluginManagementHandler::installPlugin($pluginDir . DIRECTORY_SEPARATOR . $pluginName, $templateMgr);
             } else {
                 if ($function == 'upgrade') {
                     PluginManagementHandler::upgradePlugin($pluginDir . DIRECTORY_SEPARATOR . $pluginName, $templateMgr);
                 }
             }
         } else {
             $templateMgr->assign('error', true);
             $templateMgr->assign('message', 'manager.plugins.uploadError');
         }
     } else {
         if (Request::getUserVar('installPlugin')) {
             if (Request::getUserVar('pluginUploadLocation') == '') {
                 $templateMgr->assign('error', true);
                 $templateMgr->assign('message', 'manager.plugins.fileSelectError');
             }
         }
     }
     $templateMgr->display('manager/plugins/managePlugins.tpl');
 }
 /**
  * Decompress uploaded plugin and install in the correct plugin directory.
  * $param function string type of operation to perform after upload ('upgrade' or 'install')
  */
 function uploadPlugin($function)
 {
     $templateMgr =& TemplateManager::getManager();
     $this->setupTemplate(true);
     $templateMgr->assign('error', false);
     $templateMgr->assign('uploaded', false);
     $templateMgr->assign('path', $function);
     $templateMgr->assign('pageHierarchy', PluginManagementHandler::setBreadcrumbs(true));
     if (Request::getUserVar('uploadPlugin')) {
         import('file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $pluginFile = $_FILES['newPlugin']['name'];
         $pluginName = basename($pluginFile, '.tar.gz');
         if ($publicFileManager->uploadSiteFile('newPlugin', $pluginFile)) {
             // tar archive basename must equal plugin directory name, and plugin files must be in root directory
             $pluginDir = Core::getBaseDir() . DIRECTORY_SEPARATOR . $publicFileManager->getSiteFilesPath();
             exec('tar -xzf ' . escapeshellarg($pluginDir . DIRECTORY_SEPARATOR . $pluginFile) . ' -C ' . escapeshellarg($pluginDir));
             if ($function == 'install') {
                 PluginManagementHandler::installPlugin($pluginDir . DIRECTORY_SEPARATOR . $pluginName, $templateMgr);
             } else {
                 if ($function == 'upgrade') {
                     PluginManagementHandler::upgradePlugin($pluginDir . DIRECTORY_SEPARATOR . $pluginName, $templateMgr);
                 }
             }
             $publicFileManager->removeSiteFile($pluginFile);
         } else {
             $templateMgr->assign('error', true);
             $templateMgr->assign('message', 'manager.plugins.uploadError');
         }
     } else {
         if (Request::getUserVar('installPlugin')) {
             if (Request::getUserVar('pluginUploadLocation') == '') {
                 $templateMgr->assign('error', true);
                 $templateMgr->assign('message', 'manager.plugins.fileSelectError');
             }
         }
     }
     $templateMgr->display('admin/managePlugins.tpl');
 }