public function executeWrite(AgaviParameterHolder $rd) { $success = false; $errors = array(); try { $this->security = $this->getContext()->getModel('Provider.CronksSecurity', 'Cronks'); $this->security->setCronkUid($rd->getParameter('cronkuid')); $xaction = $rd->getParameter('xaction', 'read'); if ($xaction === "read") { $success = true; } elseif ($xaction === "write") { $data = json_decode($rd->getParameter('j')); $this->security->updateRoles($data->roles); $success = true; } $this->setAttribute('cronk', $this->security->getCronk()); $this->setAttribute('roles', $this->security->getRoles()); $this->setAttribute('role_uids', $this->security->getRoleUids()); $this->setAttribute('principals', $this->security->getPrincipals()); } catch (AppKitModelException $e) { $success = false; $errors[] = $e->getMessage(); } $this->setAttribute('success', $success); $this->setAttribute('errors', $errors); return $this->getDefaultViewName(); }
public function executeWrite(AgaviParameterHolder $rd) { $success = false; $errors = array(); try { $this->getCategorySecurityModel()->setCategoryUid($rd->getParameter('catid')); $xaction = $rd->getParameter('xaction', 'read'); if ($xaction === 'read') { $success = true; } elseif ($xaction === 'write') { $params = json_decode($rd->getParameter('j')); $this->getCategorySecurityModel()->updateRoles($params->roles); $success = true; } $this->setAttribute('category', $this->getCategorySecurityModel()->getCategory()); $this->setAttribute('roles', $this->getCategorySecurityModel()->getRoles()); $this->setAttribute('role_uids', $this->getCategorySecurityModel()->getRoleUids()); $this->setAttribute('principals', $this->getCategorySecurityModel()->getPrincipals()); } catch (AppKitModelException $e) { $success = false; $errors[] = $e->getMessage(); } $this->setAttribute('success', $success); $this->setAttribute('errors', $errors); return $this->getDefaultViewName(); }
public function agaviDateFormat($val, AgaviParameterHolder $method_params, AgaviParameterHolder $row) { $check = strtotime($val); if ($check <= 0) { return '(null)'; } return $this->context->getTranslationManager()->_d($val, $method_params->getParameter('domain', 'date-tstamp')); }
public function icingaConstants($val, AgaviParameterHolder $method_params, AgaviParameterHolder $row) { $type = $method_params->getParameter('type'); $ref = new ReflectionClass('IcingaConstantResolver'); if ($m = $ref->getMethod($type)) { if ($m->isPublic() && $m->isStatic()) { return AgaviContext::getInstance()->getTranslationManager()->_($m->invoke(null, $val)); } } return $val; }
public function executeWrite(AgaviParameterHolder $rd) { $data = json_decode($rd->getParameter('data'), true); $selection = json_decode($rd->getParameter('selection'), true); $command = $rd->getParameter('command'); $auth = $rd->getParameter('auth'); $this->log('SendCommandAction: Prepare to send command (command=%s)', $command, AgaviLogger::INFO); $IcingaApiCommand = $this->getContext()->getModel('Icinga.ApiContainer', 'Web'); // The model $sender = $this->getContext()->getModel('System.CommandSender', 'Cronks'); if ($sender->checkAuth($rd->getParameter('command'), $rd->getParameter('selection'), $rd->getParameter('data'), $auth) === true) { $this->log('SendCommandAction: Successfull authentication (hmac=%s)', $auth, AgaviLogger::DEBUG); // Prepare the data $sender->setCommandName($command); $sender->setSelection($selection); $sender->setData($data); try { $sender->dispatchCommands(); $this->setAttribute('ok', true); $this->setAttribute('error', null); } catch (Exception $e) { $this->setAttribute("ok", false); $this->setAttribute("error", $e->getMessage()); } } else { $this->setAttribute('ok', false); $this->setAttribute('error', 'Authentification failed'); $this->log('SendCommandAction: Authentification failed! (hmac=%s)', $auth, AgaviLogger::DEBUG); } return $this->getDefaultViewName(); }
/** * Syncs the data structures from XML structure */ public function syncDataStructures() { foreach ($this->__rootNode->attributes as $attribute) { $this->__descriptorAttributes->setParameter($attribute->name, $attribute->value); } if (is_array($tmp = $this->queryToArray('//resourceDescriptor/resourceProperty', 'name'))) { $this->__resourceProperties->setParameters($tmp); } if ($this->getElementsByTagName('label')->length) { $this->__label = trim($this->getElementsByTagName('label')->item(0)->nodeValue); } if ($this->getElementsByTagName('creationDate')->length) { $this->__crdate = trim($this->getElementsByTagName('creationDate')->item(0)->nodeValue); } }
public function executeWrite(AgaviParameterHolder $rd) { $cmd = $rd->getParameter('cmd', 'read'); $provider = $this->getContext()->getModel('Ext.ApplicationState', 'AppKit'); switch ($cmd) { case 'write': if ($data = $rd->getParameter('data', null)) { $provider->writeState($data); } break; case 'read': default: break; } return $this->getDefaultViewName(); }
public function execute(AgaviParameterHolder $rd) { $factory = $this->getContext()->getModel('JasperSoapFactory', 'Reporting', array('jasperconfig' => $rd->getParameter('jasperconfig'))); $scheduler = $this->getContext()->getModel('JasperScheduler', 'Reporting', array('client' => $factory->getSoapClientForWSDL(Reporting_JasperSoapFactoryModel::SERVICE_SCHEDULER), 'jasperconfig' => $rd->getParameter('jasperconfig'), 'uri' => $rd->getParameter('uri'))); switch ($rd->getParameter('action')) { case 'list': return 'List'; break; case 'job': return 'Job'; case 'edit': try { $scheduler->editJob($rd->getParameter('job_data')); $this->setAttribute('success', true); } catch (SoapFault $e) { $this->setAttribute('error', $e->getMessage()); } catch (JasperSchedulerJobException $e) { $this->setAttribute('error', $e->getMessage()); } return $this->getDefaultViewName(); break; case 'delete': try { $scheduler->deleteJob($rd->getParameter('job')); $this->setAttribute('success', true); } catch (SoapFault $e) { $this->setAttribute('error', $e->getMessage()); } return $this->getDefaultViewName(); break; default: return $this->getDefaultViewName(); break; } }
public function executeWrite(AgaviParameterHolder $rd) { if ($rd->getParameter('xaction', false) == 'create' || $rd->getParameter('xaction', false) == 'update' || $rd->getParameter('xaction', false) == 'destroy') { $rows = json_decode($rd->getParameter('rows', array())); if (!is_array($rows)) { $rows = array($rows); } $c = array(); foreach ($rows as $category) { try { if ($rd->getParameter('xaction', false) == 'destroy') { if (isset($category->catid)) { $this->categories->deleteCategoryRecord($category->catid); } } else { $this->categories->createCategory((array) $category); $c[] = (array) $category; } } catch (Doctrine_Exception $e) { } } $this->setAttributeByRef('categories', $c); return $this->getDefaultViewName(); } return $this->executeRead($rd); }
public function executeWrite(AgaviParameterHolder $rd) { $data = (array) json_decode($rd->getParameter('data', "")); $factory = $this->getContext()->getModel('JasperSoapFactory', 'Reporting', array('jasperconfig' => $rd->getParameter('jasperconfig'))); $client = $factory->getSoapClientForWSDL(Reporting_JasperSoapFactoryModel::SERVICE_REPOSITORY); try { $parameters = $this->getContext()->getModel('JasperParameterStruct', 'Reporting', array('client' => $client, 'uri' => $rd->getParameter('uri'), 'filter' => 'reportUnit')); $reports = $parameters->getObjects(); $converter = $this->getContext()->getModel('FieldValueConverter', 'Reporting', array('client' => $client, 'uri' => $rd->getParameter('uri'), 'parameters' => $data)); $creator = $this->getContext()->getModel('ReportGenerator', 'Reporting', array('client' => $client, 'report' => $reports[0], 'format' => $rd->getParameter('output_type'), 'parameters' => $converter->getConvertedParameters())); $data = $creator->getReportData(); $userFile = $this->getContext()->getModel('ReportUserFile', 'Reporting'); $userFile->storeFile($data, $rd->getParameter('output_type'), $reports[0]); $this->setAttribute('success', true); } catch (AppKitModelException $e) { $this->setAttribute('success', false); $this->setAttribute('error', $e->getMessage()); } return $this->getDefaultViewName(); }
public function executeWrite(AgaviParameterHolder $rd) { try { if ($rd->getParameter('xaction') == 'write') { $cronk_record = $this->cronks->createCronkRecord($rd->getParameters()); $cronk_record->save(); } elseif ($rd->getParameter('xaction') == 'delete') { try { $this->cronks->deleteCronkRecord($rd->getParameter('cid'), $rd->getParameter('name')); } catch (Exception $e) { $this->appendAttribute('errors', $e->getMessage()); } } else { $cronks = $this->cronks->getCronks(); $this->setAttributeByRef('cronks', $cronks); } } catch (AppKitModelException $e) { $this->setAttribute('errors', $e->getMessage()); } return $this->getDefaultViewName(); }
/** * Constructor. * * @param array Initial parameters. * * @author David Zülke <*****@*****.**> * @since 0.11.0 */ public function __construct(array $parameters = array()) { parent::__construct(array_merge(array('module' => null, 'template' => null), $parameters)); }
public function testRemoveInvalidKeyCausesNoNotice() { $ph = new AgaviParameterHolder(); $zomg =& $ph->removeParameter('[]foo[]'); $this->assertNull($zomg); }
/** * Constructor. * * @author David Zülke <*****@*****.**> * @since 0.11.0 */ public function __construct() { parent::__construct(); $this->setParameters(array('max_executions' => 20, 'send_response' => true)); }
public function durationString($val, AgaviParameterHolder $method_params, AgaviParameterHolder $row) { $tstamp = $this->getDateString($val, $method_params->getParameter('type')); return $this->simpleDurationString($tstamp); }