public function executeConsole(AgaviRequestDataHolder $request_data) { $migration_description = $request_data->getParameter('description'); $migration_timestamp = date('YmdHis'); $migration_slug = StringToolkit::asSnakeCase(trim($request_data->getParameter('name', 'default'))); $migration_name = StringToolkit::asStudlyCaps($migration_slug); $migration_dir = $this->getAttribute('migration_dir'); // Bit of a hack to build namespace if (!preg_match('#.+/app/(?:modules|migration)/(\\w+_?)(?:$|/.+)#', $migration_dir, $matches)) { throw new RuntimeError(sprintf('Could not find namespace info in path %s', $migration_dir)); } $namespace_parts = explode('_', $matches[1]); if (count($namespace_parts) == 1) { // @todo app migration - introduce a project root namespace setting $namespace_parts = ['Your', 'Application']; } // And a hack to determine the technology namespace $target = $request_data->getParameter('target'); if (strpos($target, 'event_source')) { $technology = 'CouchDb'; } elseif (strpos($target, 'view_store')) { $technology = 'Elasticsearch'; } else { $technology = 'RabbitMq'; } $migration_filepath = sprintf('%1$s%2$s%3$s_%4$s%2$s%4$s.php', $migration_dir, DIRECTORY_SEPARATOR, $migration_timestamp, $migration_slug); $twig_renderer = TwigRenderer::create(['template_paths' => [__DIR__]]); $twig_renderer->renderToFile($technology . 'Migration.tpl.twig', $migration_filepath, ['name' => $migration_name, 'timestamp' => $migration_timestamp, 'description' => $migration_description, 'folder' => $migration_dir, 'filepath' => $migration_filepath, 'vendor_prefix' => $namespace_parts[0], 'package_prefix' => $namespace_parts[1], 'technology' => $technology, 'project_prefix' => AgaviConfig::get('core.project_prefix')]); return $this->cliMessage('-> migration template was created here:' . PHP_EOL . $migration_filepath . PHP_EOL); }
protected function createDOM(AgaviRequestDataHolder $rd) { $results = $rd->getParameter("searchResult", null); $count = $rd->getParameter("searchCount"); $DOM = new DOMDocument("1.0", "UTF-8"); $root = $DOM->createElement("results"); $DOM->appendChild($root); foreach ($results as $result) { $resultNode = $DOM->createElement("result"); $root->appendChild($resultNode); foreach ($result as $fieldname => $field) { $node = $DOM->createElement("column"); $node->nodeValue = $field; $name = $DOM->createAttribute("name"); $name->nodeValue = $fieldname; $node->appendChild($name); $resultNode->appendChild($node); } } if ($count) { $count = array_values($count[0]); $node = $DOM->createElement("total"); $node->nodeValue = $count[0]; $root->appendChild($node); } return $DOM; }
public function executeWrite(AgaviRequestDataHolder $rd) { if (!$this->context->getUser()->isAuthenticated() || !$this->context->getUser()->hasCredential('icinga.user')) { return array('Api', 'GenericError'); } if ($this->context->getUser()->getNsmUser()->getTarget('IcingaCommandRo')) { $errors = array('Commands are disabled for this user'); $this->getContainer()->setAttributeByRef('errors', $errors, 'org.icinga.api.auth'); $this->getContainer()->setAttribute('success', false, 'org.icinga.api.auth'); return array('Api', 'GenericError'); } $command = $rd->getParameter("command"); $targets = json_decode($rd->getParameter("target"), true); $data = json_decode($rd->getParameter("data"), true); if (!is_array($data)) { $this->setAttribute('error', 'Parameter data={} could not decoded from json'); return 'Error'; } if (!is_array($targets)) { $targets = array($targets); } $api = $this->getContext()->getModel("System.CommandSender", "Cronks"); $api->setCommandName($command); $api->setData($data); $api->setSelection($targets); // send it try { $api->dispatchCommands(); $this->setAttribute("success", true); } catch (Exception $e) { $this->setAttribute("error", $e->getMessage()); return 'Error'; } return 'Success'; }
public function executeHtml(AgaviRequestDataHolder $rd) { $customViewFields = array("cr_base" => false, "sortField" => false, "sortDir" => false, "groupField" => false, "groupDir" => false, "template" => false, "crname" => false, "filter" => false, "title" => false); $requiredViewFields = array("template", "crname", "title"); $rd->setParameter("isURLView", true); foreach ($customViewFields as $name => $val) { $val = $rd->getParameter($name, null); if ($val == null) { if (in_array($name, $requiredViewFields)) { $rd->setParameter("isURLView", false); break; } else { unset($customViewFields[$name]); } } else { $customViewFields[$name] = $val; } } if ($rd->getParameter("isURLView")) { if (isset($customViewFields["cr_base"]) and trim($customViewFields["cr_base"]) !== "") { $this->formatFields($customViewFields); } $rd->setParameter("URLData", json_encode($customViewFields)); } $this->setupHtml($rd); $this->setAttribute('_title', 'Icinga.Cronks.CronkPortal'); }
public function executeJson(AgaviRequestDataHolder $rd) { $factory = $this->getContext()->getModel('JasperSoapFactory', 'Reporting', array('jasperconfig' => $rd->getParameter('jasperconfig'))); $client = $factory->getSoapClientForWSDL(Reporting_JasperSoapFactoryModel::SERVICE_REPOSITORY); $parameters = $this->getContext()->getModel('JasperParameterStruct', 'Reporting', array('client' => $client, 'uri' => $rd->getParameter('uri'), 'filter' => 'inputControl')); return json_encode($parameters->getJsonStructure()); }
public function executeConsole(\AgaviRequestDataHolder $request_data) { $report = $this->getAttribute('report'); if ($request_data->getParameter('silent', false)) { return; } $message = 'The following items were compiled:' . PHP_EOL . PHP_EOL; foreach ($report as $directory => $data) { $message .= '- ' . $data['name'] . PHP_EOL; if ($request_data->getParameter('verbose', false)) { $message .= 'Command: ' . $data['cmd'] . PHP_EOL; if (!empty($data['stdout'])) { $message .= 'STDOUT: ' . PHP_EOL . $data['stdout'] . PHP_EOL; } if (!empty($data['stderr'])) { $message .= 'STDERR: ' . PHP_EOL . $data['stderr'] . PHP_EOL; } if (empty($data['stdout']) && empty($data['stderr'])) { $message .= PHP_EOL; } if (!empty($data['autoprefixer']['stdout'])) { $message .= 'Autoprefixer STDOUT: ' . PHP_EOL . $data['autoprefixer']['stdout']; } if (!empty($data['autoprefixer']['stderr'])) { $message .= 'Autoprefixer STDERR: ' . PHP_EOL . $data['autoprefixer']['stderr']; } if (empty($data['autoprefixer']['autoprefixer']['stdout']) && empty($data['autoprefixer']['stderr'])) { $message .= PHP_EOL; } } } return $message . PHP_EOL; }
public function executeWrite(\AgaviRequestDataHolder $request_data) { $report = array(); try { $style = $request_data->getParameter('style', AgaviConfig::get('sass.style', 'compressed')); $themes = $request_data->getParameter('themes', []); $packer = new AssetCompiler(); // just in case $packer->symlinkModuleAssets(); if (empty($themes)) { $compilation_succeeded = $packer->compileThemes($style, $report); } else { foreach ($themes as $theme) { $compilation_succeeded = $packer->compileTheme($theme, $style, $report); } } $compilation_succeeded &= $packer->compileModuleStyles($style, $report); $this->setAttribute('report', $report); } catch (\Exception $e) { $this->setAttribute('error', $e->getMessage()); return 'Error'; } if (!$compilation_succeeded) { return 'Error'; } return 'Success'; }
public function executeWrite(AgaviRequestDataHolder $rd) { $username = $rd->getParameter('username'); $password = $rd->getParameter('password'); $do = $rd->getParameter('dologin'); $this->setAttribute('authenticated', false); $this->setAttribute('executed', false); if ($do) { $this->setAttribute('executed', true); $user = $this->getContext()->getUser(); try { $user->doLogin($username, $password); /* * Behaviour for blocking whole access if no icinga access */ //if(!$user->hasCredential("icinga.user")) { // $user->doLogout(); // $this->setAttribute('authenticated', false); //} $this->setAttribute('authenticated', true); } catch (AgaviSecurityException $e) { $this->setAttribute('authenticated', false); } } return $this->getDefaultViewName(); }
public function executeHtml(AgaviRequestDataHolder $rd) { $this->setAttribute('title', 'Icinga.CronkLoader'); $tm = $this->getContext()->getTranslationManager(); try { $model = $this->getContext()->getModel('Provider.CronksData', 'Cronks'); $crname = $rd->getParameter('cronk'); /* * Allow external initialization of cronk stubs */ $parameters = $rd->getParameter('p', array()); if ($model->hasCronk($crname)) { $cronk = $model->getCronk($crname); if (array_key_exists('ae:parameter', $cronk) && is_array($cronk['ae:parameter'])) { $cronk['ae:parameter'] = $this->rebuildComplexData($cronk['ae:parameter']); $parameters = (array) $cronk['ae:parameter'] + $parameters + array('module' => $cronk['module'], 'action' => $cronk['action']); } if (array_key_exists('state', $cronk) && isset($cronk['state'])) { $parameters['state'] = $cronk['state']; } return $this->createForwardContainer($cronk['module'], $cronk['action'], $parameters, 'simple', 'write'); } else { return $tm->_('Sorry, cronk "%s" not found', null, null, array($crname)); } } catch (Exception $e) { return $tm->_('Exception thrown: %s', null, null, array($e->getMessage())); } return 'Some strange error occured'; }
public function executeWrite(\AgaviRequestDataHolder $request_data) { $report = array(); $success = false; try { $optimize_style = $request_data->getParameter('optimize', AgaviConfig::get('requirejs.optimize_style', 'uglify2')); $buildfile_path = $request_data->getParameter('buildfile', AgaviConfig::get('requirejs.buildfile_path', AgaviConfig::get('core.pub_dir') . "/static/buildconfig.js")); $packer = new AssetCompiler(); // just in case $packer->symlinkModuleAssets(); // render buildconfig.js and put it into the target location for compilation $template_service = new ModuleTemplateRenderer(); $buildconfig_content = $template_service->render('rjs/buildconfig.js'); $success = file_put_contents($buildfile_path, $buildconfig_content, LOCK_EX); if (!$success) { $this->setAttribute('error', 'Could not write file: ' . $buildfile_path); } $success = $packer->compileJs($buildfile_path, $optimize_style, $report); $this->setAttribute('report', $report); } catch (\Exception $e) { $this->setAttribute('error', $e->getMessage()); return 'Error'; } if (!$success) { return 'Error'; } return 'Success'; }
/** * Tries to authenticate the user with the given request data. * * @param AgaviRequestDataHolder $request_data * * @return string name of agavi view to select */ protected function authenticate(AgaviRequestDataHolder $request_data) { $vm = $this->getContainer()->getValidationManager(); $tm = $this->getContext()->getTranslationManager(); $user = $this->getContext()->getUser(); $username = $request_data->getParameter('username'); $password = $request_data->getParameter('password'); $service_locator = $this->getContext()->getServiceLocator(); $authentication_service = $service_locator->getAuthenticationService(); $auth_response = $authentication_service->authenticate($username, $password); $log_message = sprintf("username='******' message='%s' auth_provider='%s' errors=''", $username, $auth_response->getMessage(), get_class($authentication_service), join(';', $auth_response->getErrors())); if ($auth_response->getState() === AuthResponse::STATE_AUTHORIZED) { $view_name = 'Success'; $user->setAttributes(array_merge(['acl_role' => AclService::ROLE_NON_PRIV], $auth_response->getAttributes())); $user->setAuthenticated(true); $this->logInfo('[AUTHORIZED] ' . $log_message); } elseif ($auth_response->getState() === AuthResponse::STATE_UNAUTHORIZED) { $view_name = 'Error'; $user->setAuthenticated(false); $vm->addArgumentResult(new \AgaviValidationArgument('username'), AgaviValidator::ERROR); $vm->addArgumentResult(new \AgaviValidationArgument('password'), AgaviValidator::ERROR); $vm->setError('invalid_login', $tm->_('invalid_login', 'honeybee.system_account.user.errors')); $this->logError('[UNAUTHORIZED] ' . $log_message); } else { $view_name = 'Error'; $user->setAuthenticated(false); $this->setAttribute('errors', ['auth' => $auth_response->getMessage()]); $vm->setError('invalid_login', $tm->_('invalid_login', 'honeybee.system_account.user.errors')); $this->logError("[ERROR] state='" . $auth_response->getState() . "' " . $log_message); } return $view_name; }
public function executeWrite(AgaviRequestDataHolder $request_data) { $size = $request_data->getParameter('size', 1); $aggregate_root_type = $request_data->getParameter('type'); $fixture_service = $this->getServiceLocator()->getFixtureService(); $type_prefix = $aggregate_root_type->getPrefix(); $documents[$type_prefix] = $fixture_service->generate($type_prefix, $size); $json = json_encode($documents, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $errors = []; $report = []; $success = true; if ($request_data->hasParameter('target')) { $target = $request_data->getParameter('target'); if (is_writable(dirname($target))) { $success = file_put_contents($target, $json, LOCK_EX) !== false; if (!$success) { $errors[] = sprintf('failed to write to: %s', $target); } } else { $errors[] = sprintf('target filename is not writable: %s', $target); $success = false; } } else { $this->setAttribute('data', $json); } $this->setAttribute('report', $report); $this->setAttribute('size', count($documents[$type_prefix])); if (!$success) { $this->setAttribute('errors', $errors); return 'Error'; } return 'Success'; }
public function executeJson(AgaviRequestDataHolder $rd) { try { $modules = AgaviConfig::get("org.icinga.modules", array()); $fileName = $rd->getParameter('template'); $file = null; foreach ($modules as $name => $path) { if (file_exists($path . "/config/templates/" . $fileName . '.xml')) { $file = AppKitFileUtil::getAlternateFilename($path . "/config/templates/", $fileName, '.xml'); } } if ($file === null) { $file = AppKitFileUtil::getAlternateFilename(AgaviConfig::get('modules.cronks.xml.path.grid'), $rd->getParameter('template'), '.xml'); } $template = new CronkGridTemplateXmlParser($file->getRealPath()); $template->parseTemplate(); $user = $this->getContext()->getUser()->getNsmUser(); $data = $template->getTemplateData(); if ($user->hasTarget('IcingaCommandRestrictions')) { $template->removeRestrictedCommands(); } return json_encode(array('template' => $template->getTemplateData(), 'fields' => $template->getFields(), 'keys' => $template->getFieldKeys(), 'params' => $rd->getParameters(), 'connections' => IcingaDoctrineDatabase::$icingaConnections)); } catch (AppKitFileUtilException $e) { $msg = 'Could not find template for ' . $rd->getParameter('template'); AppKitAgaviUtil::log('Could not find template for ' . $rd->getParameter('template'), AgaviLogger::ERROR); return $msg; } }
public function executeWrite(AgaviRequestDataHolder $rd) { $action = $rd->getParameter("action", null); $instance = $rd->getParameter("instance", null); $this->setAttribute("write", true); if ($instance == null) { $this->setAttribute("errorMsg", "Invalid request"); return "Success"; } $icinga = $this->getContext()->getModel("IcingaControlTask", "Api", array("host" => $instance)); try { switch ($action) { case 'restart': $icinga->restartIcinga(); return "Success"; break; case 'shutdown': $icinga->stopIcinga(); return "Success"; break; default: $this->setAttribute("errorMsg", "Invalid action"); return "Success"; } } catch (Exception $e) { $this->setAttribute("errorMsg", $e->getMessage()); return "Success"; } }
public function executeConsole(AgaviRequestDataHolder $request_data) { $message = sprintf('-> failure generating code for skeleton "%s"', $request_data->getParameter('skeleton')); if (!$request_data->getParameter('quiet')) { $message .= PHP_EOL . ' - ' . $this->getAttribute('errors'); } return $this->cliError($message); }
public function executeJson(AgaviRequestDataHolder $rd) { $start = $rd->getParameter("start"); $limit = $rd->getParameter("limit"); $parser = $this->getContext()->getModel("LogParser", "AppKit"); $logEntries = $parser->parseLog($rd->getParameter('logFile'), $start, $limit, $rd->getParameter("dir", "desc")); return json_encode($logEntries); }
public function executeConsole(AgaviRequestDataHolder $request_data) { $message = sprintf('-> failure importing data from fixture "%s"', $request_data->getParameter('fixture')); if (!$request_data->getParameter('quiet')) { $message .= PHP_EOL . ' - ' . $this->getAttribute('errors'); } return $this->cliError($message); }
public function executeWrite(AgaviRequestDataHolder $rd) { $model = $this->context->getModel('Relation.DataModel', 'Api', array("connection" => $rd->getParameter("connection", "icinga"))); try { $this->setAttribute('data', $model->getRelationDataForObjectId($rd->getParameter('objectId'))); } catch (AppKitModelException $e) { return "Error"; } return $this->getDefaultViewName(); }
public function executeConsole(AgaviRequestDataHolder $request_data) { $message = sprintf('-> successfully imported data from fixture "%s"', $request_data->getParameter('fixture')); if (!$request_data->getParameter('quiet')) { foreach ($this->getAttribute('report', []) as $line) { $message .= sprintf(PHP_EOL . ' - %s', $line); } } return $this->cliMessage($message); }
/** * This Action does not yet serve any Request methods. * When a request comes in and this Action is used, execution will be skipped * and the View returned by getDefaultViewName() will be used. * * If an Action has an execute() method, this means it serves all methods. * Alternatively, you can implement executeRead() and executeWrite() methods, * because "read" and "write" are the default names for Web Request methods. * Other request methods may be explicitely served via execcuteReqmethname(). * * Keep in mind that if an Action serves a Request method, validation will be * performed prior to execution. * * Usually, for example for an AddProduct form, your Action should only be run * when a POST request comes in, which is mapped to the "write" method by * default. Therefor, you'd only implement executeWrite() and put the logic to * add the new product to the database there, while for GET (o.e. "read") * requests, execution would be skipped, and the View name would be determined * using getDefaultViewName(). * * We strongly recommend to prefer specific executeWhatever() methods over the * "catchall" execute(). * * Besides execute() and execute*(), there are other methods that might either * be generic or specific to a request method. These are: * registerValidators() and register*Validators() * validate() and validate*() * handleError() and handle*Error() * * The execution of these methods is not dependent on the respective specific * execute*() being present, e.g. for a "write" Request, validateWrite() will * be run even if there is no executeWrite() method. */ public function executeWrite(AgaviRequestDataHolder $rd) { try { $this->getContext()->getUser()->login($rd->getParameter('username'), $rd->getParameter('password')); return 'Success'; } catch (AgaviSecurityException $e) { $this->setAttribute('error', $e->getMessage()); return 'Error'; } }
public function executeConsole(AgaviRequestDataHolder $request_data) { $message = sprintf('-> failure trying to replay events for aggregate root type "%s"', $request_data->getParameter('type')->getName()); if (!$request_data->getParameter('quiet')) { foreach ($this->getAttribute('errors', []) as $line) { $message .= sprintf(PHP_EOL . ' - %s', $error); } } return $this->cliError($message); }
public function executeJson(AgaviRequestDataHolder $rd) { $this->model = $this->getContext()->getModel('System.ObjectSearchResult', 'Cronks'); $this->model->setQuery($rd->getParameter('q')); if ($rd->getParameter('t')) { $this->model->setSearchType($rd->getParameter('t')); } $data = $this->model->getData(); return json_encode($data); }
public function executeConsole(AgaviRequestDataHolder $request_data) { $state_machine = $request_data->getParameter('subject'); $svg = $this->renderSubject($state_machine); if ($request_data->hasParameter('output')) { $output = $request_data->getParameter('output'); file_put_contents($output, $svg); $message = sprintf('-> successfully generated visualization for "%s"' . PHP_EOL . '-> image was generated here: %s', $state_machine->getName(), realpath($output)); return $this->cliMessage($message); } else { return $svg; } }
public function executeConsole(AgaviRequestDataHolder $request_data) { $message = sprintf('-> successfully generated Trellis code for target "%s"', $request_data->getParameter('target')); if ($this->hasAttribute('mapping_target_path')) { $message .= PHP_EOL . '-> Elasticsearch mapping was created here:'; $message .= PHP_EOL . $this->getAttribute('mapping_target_path') . PHP_EOL; } if (!$request_data->getParameter('quiet')) { foreach ($this->getAttribute('report', []) as $line) { $message .= sprintf(PHP_EOL . ' - %s', $line); } } return $this->cliMessage($message); }
public function validate(AgaviRequestDataHolder $request_data) { $target_path = $request_data->getParameter('target_path'); $skeleton_generator = $request_data->getParameter('skeleton_generator'); if (empty($target_path) && empty($skeleton_generator)) { $this->setAttribute('errors', 'At least one of the following parameters needs to be provided: "target_path" or "skeleton_generator".' . PHP_EOL . 'This may be done via CLI arguments or a skeleton_parameters.validate.xml file.'); return false; } if (empty($target_path) && $skeleton_generator === self::DEFAULT_SKELETON_GENERATOR) { $this->setAttribute('errors', 'The default skeleton generator needs a "target_path" provided ' . 'via CLI or ' . SkeletonFinder::VALIDATION_FILE . ' file.'); return false; } return true; }
public function executeConsole(AgaviRequestDataHolder $request_data) { if ($request_data->getParameter('silent', false)) { return $this->cliError(''); } if ($this->hasAttribute('error')) { return $this->cliError($this->getAttribute('error')); } $error_message = 'Compilation of items had errors.' . PHP_EOL . PHP_EOL; $validation_errors = $this->getErrorMessages(); if (!empty($validation_errors)) { $error_message .= implode(PHP_EOL, $validation_errors) . PHP_EOL; } if (!$this->hasAttribute('report')) { return $this->cliError($error_message); } $report = $this->getAttribute('report'); $error_message .= 'Report for each item:' . PHP_EOL . PHP_EOL; foreach ($report as $directory => $data) { $success = 'OK'; if (!$data['success'] || !empty($data['autoprefixer'] && !$data['autoprefixer']['success'])) { $success = 'FAILED'; } $error_message .= $data['name'] . ': ' . $success; if ($request_data->getParameter('verbose', true)) { $error_message .= PHP_EOL . 'Command: ' . $data['cmd'] . PHP_EOL; if (!empty($data['stdout'])) { $error_message .= 'STDOUT: ' . PHP_EOL . $data['stdout']; } if (!empty($data['stderr'])) { $error_message .= 'STDERR: ' . PHP_EOL . $data['stderr']; } if (empty($data['stdout']) && empty($data['stderr'])) { $error_message .= PHP_EOL; } if (!empty($data['autoprefixer']['stdout'])) { $error_message .= 'Autoprefixer STDOUT: ' . PHP_EOL . $data['autoprefixer']['stdout']; } if (!empty($data['autoprefixer']['stderr'])) { $error_message .= 'Autoprefixer STDERR: ' . PHP_EOL . $data['autoprefixer']['stderr']; } if (empty($data['autoprefixer']['autoprefixer']['stdout']) && empty($data['autoprefixer']['stderr'])) { $error_message .= PHP_EOL; } } $error_message .= PHP_EOL . PHP_EOL; } return $this->cliError($error_message); }
public function executeWrite(AgaviRequestDataHolder $request_data) { $service_locator = $this->getServiceLocator(); $fixture_service = $service_locator->getFixtureService(); $target_name = $request_data->getParameter('target'); $fixture_name = $request_data->getParameter('fixture'); try { $fixture = $fixture_service->import($target_name, $fixture_name); } catch (Exception $e) { $this->setAttribute('errors', $e->getMessage() . PHP_EOL); return 'Error'; } $this->setAttribute('fixture', $fixture); return 'Success'; }
public function executeSimple(AgaviRequestDataHolder $rd) { $client = $this->getContext()->getModel('JasperSoapFactory', 'Reporting', array('jasperconfig' => $rd->getParameter('jasperconfig'))); $resource = $this->getContext()->getModel('ContentResource', 'Reporting', array('jasperconfig' => $rd->getParameter('jasperconfig'), 'client' => $client, 'uri' => $rd->getParameter('uri'))); $resource->doJasperRequest(); $m = $data = $resource->getMetaData(); if ($m['has_attachment'] && $m['download_allowed']) { $this->getResponse()->setHttpHeader('content-length', $m['content_length'], true); $this->getResponse()->setHttpHeader('content-type', $m['content_type'], true); $content_disposition = sprintf('%s; filename=%s', $rd->getParameter('inline') ? 'inline' : 'attachment', $m['name']); $this->getResponse()->setHttpHeader('content-disposition', $content_disposition, true); return $resource->getContent(); } return null; }
public function execute(AgaviRequestDataHolder $rd) { // We need the execute method to work with parameter od the request! if ($rd->getParameter('id')) { try { $roleadmin = $this->getContext()->getModel('RoleAdmin', 'AppKit'); $role = $roleadmin->getRoleById($rd->getParameter('id')); if ($rd->getParameter('toggleActivity', false) == true) { $roleadmin->toggleActivity($role); } } catch (Exception $e) { } } return 'Success'; }
public function execute(AgaviRequestDataHolder $rd) { if ($rd->getParameter('id')) { try { $useradmin = $this->getContext()->getModel('UserAdmin', 'AppKit'); $user = $useradmin->getUserById($rd->getParameter('id')); if ($rd->getParameter('toggleActivity', false) == true) { $useradmin->toggleActivity($user); } } catch (Exception $e) { throw $e; } } return 'Success'; }