/** * Modul-Liste in View zuweisen * @param \fpcm\model\modules\modulelist $moduleList * @param bool $addInfoLayer */ public function assignModules(\fpcm\model\modules\modulelist $moduleList, $addInfoLayer = true) { $remote = $moduleList->getModulesRemote(); $modules = array_merge($remote, $moduleList->getModulesLocal()); $jsInfo = array(); foreach ($modules as $key => $moduleItem) { if (isset($remote[$key])) { $moduleItem->setVersionRemote($remote[$key]->getVersionRemote()); } $dependencies = $moduleItem->getDependencies(); $depencyData = array(); if (count($dependencies)) { foreach ($dependencies as $mkey => $version) { $depencyData[] = $mkey . ' - ' . $this->lang->translate('VERSION') . ' ' . $version; } } $jsInfo[str_replace('/', '', $moduleItem->getKey())] = array('key' => $moduleItem->getKey(), 'description' => $moduleItem->getDescription(), 'author' => $moduleItem->getAuthor(), 'link' => $moduleItem->getLink() ? '<a href="' . $moduleItem->getLink() . '" target="_blank">' . $moduleItem->getLink() . '</a>' : '', 'dependencies' => count($depencyData) ? implode('<br>', $depencyData) : '-', 'version' => $moduleItem->getVersion(), 'versionrem' => $moduleItem->getVersionRemote()); } $this->view->assign('modules', $modules); if ($addInfoLayer) { $this->view->addJsVars(array('fpcmModuleLayerInfos' => $jsInfo)); } $this->view->assign('permissionInstall', $this->permissions->check(array('modules' => 'install'))); $this->view->assign('permissionUninstall', $this->permissions->check(array('modules' => 'uninstall'))); $this->view->assign('permissionEnable', $this->permissions->check(array('modules' => 'enable'))); }
/** * 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; }