Example #1
0
 /**
  * Controller-Processing
  * @return boolean
  */
 public function process()
 {
     if (!parent::process()) {
         return false;
     }
     $this->view->setViewJsFiles(array(\fpcm\classes\baseconfig::$jsPath . 'moduleinstaller.js'));
     $tempFile = new \fpcm\model\files\tempfile('installkeys');
     if (!$tempFile->getContent()) {
         trigger_error('No module key data found!');
         $this->view->addErrorMessage('MODULES_FAILED_TEMPKEYS');
         $this->view->assign('nokeys', true);
         $this->view->render();
         return false;
     }
     $startStep = $this->forceStep ? $this->forceStep : (\fpcm\classes\baseconfig::canConnect() ? 1 : 4);
     $keys = json_decode($tempFile->getContent(), true);
     $params = $this->initPkgManagerData();
     $params['fpcmModuleKeys'] = $keys;
     $params['fpcmModuleUrl'] = \fpcm\classes\baseconfig::$moduleServer . 'packages/{{pkgkey}}.zip';
     $params['fpcmUpdaterStartStep'] = $this->forceStep ? $this->forceStep : (\fpcm\classes\baseconfig::canConnect() ? 1 : 4);
     $params['fpcmProgressbarMax'] = count($keys);
     $params['fpcmUpdaterMessages']['EXIT_1'] = $this->lang->translate('MODULES_SUCCESS_INSTALL');
     $params['fpcmUpdaterMessages']['4_0'] = $this->lang->translate('MODULES_FAILED_INSTALL');
     $this->view->addJsVars($params);
     $this->view->render();
     $tempFile->delete();
 }
Example #2
0
 /**
  * Request-Handler
  * @return boolean
  */
 public function request()
 {
     if (!$this->session->exists() && !$this->permissions->check($this->checkPermission)) {
         return false;
     }
     if (is_null($this->getRequestVar('action')) || is_null($this->getRequestVar('keys'))) {
         return true;
     }
     $this->cache->cleanup();
     $this->action = $this->getRequestVar('action');
     $this->keys = $this->getRequestVar('keys', array(1, 4, 7));
     if (!is_array($this->keys)) {
         $this->keys = json_decode($this->keys, true);
     }
     if (!is_array($this->keys)) {
         return true;
     }
     $this->keys = array_map('trim', $this->keys);
     $this->keys = array_map('base64_decode', $this->keys);
     switch ($this->action) {
         case 'disable':
             if (!$this->permissions->check(array('modules' => 'enable'))) {
                 return true;
             }
             $res = $this->modulelist->disableModules($this->keys);
             break;
         case 'enable':
             if (!$this->permissions->check(array('modules' => 'enable'))) {
                 return true;
             }
             $res = $this->modulelist->enableModules($this->keys);
             break;
         case 'uninstall':
             if (!$this->permissions->check(array('modules' => 'uninstall'))) {
                 return true;
             }
             $res = $this->modulelist->uninstallModules($this->keys);
             break;
         case 'install':
             if (!$this->permissions->check(array('modules' => 'install'))) {
                 return true;
             }
             $this->keys = array_diff($this->keys, $this->modulelist->getInstalledModules());
             $tempFile = new \fpcm\model\files\tempfile('installkeys', json_encode($this->keys));
             if (!$tempFile->save()) {
                 trigger_error('Unable to save module keys to temp file');
                 return true;
             }
             break;
         case 'update':
             if (!$this->permissions->check(array('modules' => 'install'))) {
                 return true;
             }
             $updater = new \fpcm\model\updater\modules();
             $updater->getModulelist();
             $remotes = $updater->getRemoteData();
             $this->keys = array_intersect($this->keys, $this->modulelist->getInstalledModules());
             $versionKeys = array();
             foreach ($this->keys as $key) {
                 $versionKeys[] = $key . '_version' . $remotes[$key]['version'];
             }
             $tempFile = new \fpcm\model\files\tempfile('installkeys', json_encode($versionKeys));
             if (!$tempFile->save()) {
                 trigger_error('Unable to save module keys to temp file');
                 return true;
             }
             break;
     }
     if (!isset($res)) {
         return true;
     }
     if ($res) {
         $this->view->addNoticeMessage('MODULES_SUCCESS_' . strtoupper($this->action));
     } else {
         $this->view->addErrorMessage('MODULES_FAILED_' . strtoupper($this->action));
     }
     return true;
 }