Beispiel #1
0
 public final function upgrade()
 {
     framework\Context::clearRoutingCache();
     framework\Context::clearPermissionsCache();
     $this->_upgrade();
     $this->save();
     Modules::getTable()->setModuleVersion($this->_name, static::VERSION);
 }
Beispiel #2
0
 public function runScope(framework\Request $request)
 {
     $this->scope = new entities\Scope($request['id']);
     $modules = tables\Modules::getTable()->getModulesForScope($this->scope->getID());
     $this->modules = $modules;
     $this->scope_save_error = framework\Context::getMessageAndClear('scope_save_error');
     if ($request->isPost()) {
         try {
             if ($request['scope_action'] == 'delete') {
                 if (!$this->scope->isDefault()) {
                     $this->scope->delete();
                     framework\Context::setMessage('scope_deleted', true);
                     $this->forward(make_url('configure_scopes'));
                 } else {
                     $this->scope_save_error = $this->getI18n()->__('You cannot delete the default scope');
                 }
             } else {
                 if (!$request['name']) {
                     throw new \Exception($this->getI18n()->__('Please specify a scope name'));
                 }
                 $this->scope->setName($request['name']);
                 $this->scope->setDescription($request['description']);
                 $this->scope->setCustomWorkflowsEnabled((bool) $request['custom_workflows_enabled']);
                 $this->scope->setMaxWorkflowsLimit((int) $request['workflow_limit']);
                 $this->scope->setUploadsEnabled((bool) $request['file_uploads_enabled']);
                 $this->scope->setMaxUploadLimit((int) $request['upload_limit']);
                 $this->scope->setMaxProjects((int) $request['project_limit']);
                 $this->scope->setMaxUsers((int) $request['user_limit']);
                 $this->scope->setMaxTeams((int) $request['team_limit']);
                 $this->scope->save();
                 $enabled_modules = $request['module_enabled'];
                 $prev_scope = framework\Context::getScope();
                 foreach ($enabled_modules as $module => $enabled) {
                     if (!framework\Context::getModule($module)->isCore() && !$enabled && array_key_exists($module, $modules)) {
                         $module = tables\Modules::getTable()->getModuleForScope($module, $this->scope->getID());
                         $module->uninstall($this->scope->getID());
                     } elseif (!framework\Context::getModule($module)->isCore() && $enabled && !array_key_exists($module, $modules)) {
                         framework\Context::setScope($this->scope);
                         entities\Module::installModule($module);
                         framework\Context::setScope($prev_scope);
                     }
                 }
                 framework\Context::setMessage('scope_saved', true);
                 $this->forward(make_url('configure_scopes'));
             }
         } catch (\Exception $e) {
             framework\Context::setMessage('scope_save_error', $e->getMessage());
         }
     }
 }
Beispiel #3
0
 public function enable()
 {
     $crit = new \b2db\Criteria();
     $crit->addUpdate(tables\Modules::ENABLED, 1);
     tables\Modules::getTable()->doUpdateById($crit, $this->getID());
     $this->_enabled = true;
 }