/** * Executes this task. */ public function main() { if ($this->path === null) { throw new BuildException('The path attribute must be specified'); } $check = new AgaviModuleFilesystemCheck(); $check->setConfigDirectory($this->project->getProperty('module.config.directory')); $check->setPath($this->path->getAbsolutePath()); if (!$check->check()) { throw new BuildException('The path attribute must be a valid module base directory'); } /* We don't know whether the module is configured or not here, so load the * values we want properly. */ $this->tryLoadAgavi(); $this->tryBootstrapAgavi(); require_once AgaviConfigCache::checkConfig(sprintf('%s/%s/module.xml', $this->path->getAbsolutePath(), (string) $this->project->getProperty('module.config.directory'))); $actionPath = AgaviToolkit::expandVariables(AgaviToolkit::expandDirectives(AgaviConfig::get(sprintf('modules.%s.agavi.action.path', strtolower($this->path->getName())), '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php')), array('moduleName' => $this->path->getName())); $pattern = '#^' . AgaviToolkit::expandVariables(str_replace('\\$\\{actionName\\}', '${actionName}', preg_quote($actionPath, '#')), array('actionName' => '(?P<action_name>.*?)')) . '$#'; $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath())); for (; $iterator->valid(); $iterator->next()) { $rdi = $iterator->getInnerIterator(); if ($rdi->isDot() || !$rdi->isFile()) { continue; } $file = $rdi->getPathname(); if (preg_match($pattern, $file, $matches)) { $this->log(str_replace(DIRECTORY_SEPARATOR, '.', $matches['action_name'])); } } }
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); }
public function __construct() { if (file_exists($this->icingaWebDir . '/app/config.php')) { require $this->icingaWebDir . '/lib/agavi/src/agavi.php'; require $this->icingaWebDir . '/app/config.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Exception.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Locator/Injectable.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Access.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record/Abstract.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record/Iterator.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Null.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Core.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Configurable.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Manager/Exception.php'; require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Manager.php'; require_once $this->icingaWebDir . '/app/modules/AppKit/lib/database/models/generated/BaseNsmUser.php'; require_once $this->icingaWebDir . '/app/modules/AppKit/lib/database/models/NsmUser.php'; Agavi::bootstrap('production'); AgaviConfig::set('core.default_context', 'web'); AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext'); AgaviContext::getInstance('web')->getController()->dispatch(); $icingWebUser = new NsmUser('nsm_user'); // $icingWebUser-> $icingWebUser->updatePassword($newPassword); } }
/** * Execute this configuration handler. * * @param AgaviXmlConfigDomDocument The document to parse. * * @return string Data to be written to a cache file. * * @throws <b>AgaviParseException</b> If a requested configuration file is * improperly formatted. * * @author Sean Kerr <*****@*****.**> * @author Dominik del Bondio <*****@*****.**> * @author David Zülke <*****@*****.**> * @since 0.9.0 */ public function execute(AgaviXmlConfigDomDocument $document) { // set up our default namespace $document->setDefaultNamespace(self::XML_NAMESPACE, 'compile'); $config = $document->documentURI; $data = array(); // let's do our fancy work foreach ($document->getConfigurationElements() as $configuration) { if (!$configuration->has('compiles')) { continue; } foreach ($configuration->get('compiles') as $compileFile) { $file = trim($compileFile->getValue()); $file = AgaviToolkit::expandDirectives($file); $file = self::replacePath($file); $file = realpath($file); if (!is_readable($file)) { // file doesn't exist $error = 'Configuration file "%s" specifies nonexistent ' . 'or unreadable file "%s"'; $error = sprintf($error, $config, $compileFile->getValue()); throw new AgaviParseException($error); } if (AgaviConfig::get('core.debug', false)) { // debug mode, just require() the files, makes for nicer stack traces $contents = 'require(' . var_export($file, true) . ');'; } else { // no debug mode, so make things fast $contents = $this->formatFile(file_get_contents($file)); } // append file data $data[$file] = $contents; } } return $this->generate($data, $config); }
/** * @group Module */ public function testModuleLoading() { $ctx = IcingaWebTestTool::getContext(); $ctx->getController()->initializeModule(self::MODULE_NAME); $re = AgaviConfig::get('modules.' . strtolower(self::MODULE_NAME) . '.enabled'); $this->assertTrue($re); }
/** * Execute any html related presentation logic and sets up our template attributes. * * @param AgaviRequestDataHolder $request_data */ public function executeHtml(AgaviRequestDataHolder $request_data) { $this->setAttribute(self::ATTRIBUTE_RENDERED_NAVIGATION, ''); $this->setupHtml($request_data); if ($this->container->hasAttributeNamespace('org.agavi.controller.forwards.login')) { // forward from controller due to secure action (and login action could not authenticate automatically) // store the input URL in the session for a redirect after login $base_href = $this->routing->getBaseHref(); $url = $this->request->getUrl(); // we only want to store the requested URL when it starts with the current base href if (strpos($url, "{$base_href}", 0) === 0) { // only store URL when it was a GET as otherwise the URL may not even have a read method if ($this->request->getMethod() !== 'read') { // we store the REFERER when the request is not GET, as it's most probably a form on that page. // when no valid REFERER is available we use the target input URL instead $url = $request_data->get('headers', 'REFERER', $url); } $this->user->setAttribute('redirect_url', $url, 'de.honeybee-cms.login'); } // as this is an internal forward the input form will not be the expected output of users/consumers, // thus we need to tell them that they're not authenticated and must fill the form or fix it otherwise $this->getResponse()->setHttpStatusCode(401); } else { // clear redirect from session as it's probably just a direct request of this login form if ($this->request->getMethod() === 'read') { $this->user->removeAttribute('redirect_url', 'de.honeybee-cms.login'); } else { // when users submit wrong credentials we don't want to forget his original target url } } $this->setAttribute('reset_password_enabled', AgaviConfig::get('core.reset_password_enabled', true)); }
/** * retrieves content via model and returns it * @param AgaviRequestDataHolder $rd required by Agavi but not used here * @return string $content generated content * @author Christian Doebler <*****@*****.**> */ public function executeSimple(AgaviRequestDataHolder $rd) { if ($rd->getParameter('interface', false) == true) { return $this->executeHtml($rd); } try { 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.to'), $fileName, '.xml'); } $model = $this->getContext()->getModel('System.StaticContent', 'Cronks', array('rparam' => $rd->getParameter('p', array()))); $model->setTemplateFile($file->getRealPath()); $content = $model->renderTemplate($rd->getParameter('render', 'MAIN'), $rd->getParameters()); return sprintf('<div class="%s">%s</div>', 'static-content-container', $content); } 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; } } catch (Exception $e) { return $e->getMessage(); } }
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 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 static function registerValidators(Form_FormModel $form, AgaviValidationManager $vm, array $parameters, array $files = array()) { $conditions = array(); foreach ($form->getChildren() as $child) { if ($child instanceof Form_Elements_FieldsetModel) { continue; } $parents = (array) $child->parents; $depends = array(); foreach ($parents as $id => $condition) { $depend = bin2hex("{$id}_{$condition['opration']}_{$condition['condition']}"); $parent = $form->getChildById($id); if (is_null($parent)) { throw new Exception("can't find parent with id={$id} for {$child->id}"); } if (!isset($conditions[$depend])) { $vm->createValidator('Form_ValidatorModel', array($parent->name), array(), array('model' => 'Elements.Condition', 'name' => $depend, 'module' => 'Form', 'configuration' => $condition, 'provides' => $depend, 'severity' => 'info')); $conditions[$depend] = true; } $depends[] = $depend; } if (is_callable(array($child, 'registerValidators'))) { $child->registerValidators($vm, $depends, $parameters, $files); } else { $vm->createValidator('Form_ValidatorModel', array($child->name), array('' => 'field is required'), array('element' => $child, 'name' => $child->name, 'export' => $child->name, 'depends' => $depends, 'translation_domain' => AgaviConfig::get('Form.TranslationDomain'), 'required' => (bool) $child->required)); } } }
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'; }
public function executeHtml(AgaviRequestDataHolder $rd) { $this->setupHtml($rd); if ($this->getContext()->getUser()->isAuthenticated() !== true) { $this->getResponse()->setHttpStatusCode('403'); } $this->setAttribute('message', false); $message = AgaviConfig::get('modules.appkit.auth.message', false); if ($rd->has('cookies', 'icinga-web-loginname') && AgaviConfig::get('modules.appkit.auth.behaviour.store_loginname', false) === true) { $this->setAttribute('username', $rd->get('cookies', 'icinga-web-loginname')); } if ($message !== false && is_array($message)) { if (isset($message['show']) && $message['show'] == true) { if (isset($message['include_file']) && file_exists($message['include_file'])) { $text = file_get_contents($message['include_file']); } else { $text = isset($message['text']) ? $message['text'] : null; } if ($text) { $text = AppKitAgaviUtil::replaceConfigVars($text); } $this->setAttribute('message', true); $this->setAttribute('message_text', $text); $this->setAttribute('message_title', $message['title']); $this->setAttribute('message_expand_first', isset($message['expand_first']) ? (bool) $message['expand_first'] : false); } } }
public static function dispatch($arguments = array()) { $GLOBALS['__PHPUNIT_BOOTSTRAP'] = dirname(__FILE__) . '/templates/AgaviBootstrap.tpl.php'; $suites = (include AgaviConfigCache::checkConfig(AgaviConfig::get('core.testing_dir') . '/config/suites.xml')); $master_suite = new AgaviTestSuite('Master'); if (!empty($arguments['include-suite'])) { $names = explode(',', $arguments['include-suite']); unset($arguments['include-suite']); foreach ($names as $name) { if (empty($suites[$name])) { throw new InvalidArgumentException(sprintf('Invalid suite name %1$s.', $name)); } $master_suite->addTest(self::createSuite($name, $suites[$name])); } } else { $excludes = array(); if (!empty($arguments['exclude-suite'])) { $excludes = explode(',', $arguments['exclude-suite']); unset($arguments['exclude-suite']); } foreach ($suites as $name => $suite) { if (!in_array($name, $excludes)) { $master_suite->addTest(self::createSuite($name, $suite)); } } } $runner = new PHPUnit_TextUI_TestRunner(); $runner->doRun($master_suite, $arguments); }
public function execute(AgaviRequestDataHolder $rd) { $enable_silent = AgaviConfig::get('modules.appkit.auth.behaviour.enable_silent', false); $enable_dialog = AgaviConfig::get('modules.appkit.auth.behaviour.enable_dialog', false); $this->setAttribute('authenticated', false); $this->setAttribute('template', false); if (!$enable_dialog && !$enable_silent) { return 'ConfigError'; } $dispatch = $this->getContext()->getModel('Auth.Dispatch', 'AppKit'); if ($enable_silent == true) { if ($dispatch->hasSilentProvider()) { $username = $dispatch->guessUsername(); if ($username !== false) { $user = $this->getContext()->getUser(); try { $user->doLogin($username, null, false); $this->setAttribute('authenticated', true); } catch (AgaviSecurityException $e) { if ($enable_dialog == false) { return 'Error'; } } } } } return $this->getDefaultViewName(); }
public function setUp() { $this->_file = tempnam(AgaviConfig::get('core.cache_dir'), 'AgaviFileLoggerAppenderTest'); unlink($this->_file); $this->_fa = new AgaviFileLoggerAppender(); $this->_fa->initialize($this->getContext(), array('file' => $this->_file)); $this->_fa->setLayout(new AgaviPassthruLoggerLayout()); }
public function testOverwrite() { $this->loadTestConfig('env2'); $this->assertInstanceOf('DCHTestDatabase', $this->databases['test1']); $paramsExpected = array('host' => 'localhost1', 'user' => 'testuser1', 'config' => AgaviConfig::get('core.app_dir') . '/config/project-conf.php'); $this->assertSame($paramsExpected, $this->databases['test1']->params); $this->assertSame($this->databases['test2'], $this->databases[$this->defaultDatabaseName]); }
public function testParseEntities() { $RACH = new AgaviReturnArrayConfigHandler(); $document = $this->parseConfiguration(AgaviConfig::get('core.config_dir') . '/tests/entities.xml'); $actual = $this->includeCode($RACH->execute($document)); $expected = array('Name' => 'bar'); $this->assertSame($expected, $actual); }
public function testParseComplex() { $RACH = new AgaviReturnArrayConfigHandler(); $document = $this->parseConfiguration(AgaviConfig::get('core.config_dir') . '/tests/rach_complex.xml'); $actual = $this->includeCode($RACH->execute($document)); $expected = array('cachings' => array('Browse' => array('enabled' => true, 'action' => AgaviConfig::get('core.app_dir'), 'groups' => array('foo' => 'bar', 'categories' => '', 'id' => array('source' => 'request.parameter', 'value' => ''), 'LANG' => array('source' => 'constant', 'value' => ''), 'admin' => array('source' => 'user.credential', 'value' => '')), 'decorator' => array('include' => false, 'slots' => array('breadcrumb'), 'variables' => array('bar' => 'baz', '_title', '_section')), 'variables' => array('categoryId' => array('source' => 'request.attribute', 'value' => ''), 'isRootCat' => array('source' => 'request.attribute', 'value' => ''))))); $this->assertEquals($expected, $actual); }
protected function createValidationManager($environment) { $VCH = new AgaviValidatorConfigHandler(); $document = $this->parseConfiguration(AgaviConfig::get('core.config_dir') . '/tests/validators.xml', AgaviConfig::get('core.agavi_dir') . '/config/xsl/validators.xsl', $environment); $vm = $this->getContext()->createInstanceFor('validation_manager'); $this->includeCode($VCH->execute($document), array('validationManager' => $vm)); return $vm; }
public function executeHtml(AgaviRequestDataHolder $rd) { // will automatically load "slot" layout for us $this->setupHtml($rd); $this->setAttribute('locales', $this->tm->getAvailableLocales()); $this->setAttribute('current_locale', $this->tm->getCurrentLocaleIdentifier()); $this->setAttribute('agavi_plug', AgaviConfig::get('agavi.release')); }
private function clearAdditionalCache() { $cacheDir = AgaviConfig::get('core.cache_dir'); foreach (self::$additionalCacheDirs as $sub) { AppKitFileUtil::rmdir($cacheDir . DIRECTORY_SEPARATOR . $sub); $this->log('Cleared sub cache %s from webinterface', $sub, AgaviLogger::INFO); } }
public function testHandler() { $document = $this->parseConfiguration(AgaviConfig::get('core.config_dir') . '/tests/rbac_definitions.xml', AgaviConfig::get('core.agavi_dir') . '/config/xsl/rbac_definitions.xsl'); $handler = new AgaviRbacDefinitionConfigHandler(); $cfg = $this->includeCode($handler->execute($document)); $expected = array('administrator' => array('parent' => NULL, 'permissions' => array('admin')), 'photographer' => array('parent' => 'member', 'permissions' => array(0 => 'photos.edit-own', 1 => 'photos.add', 2 => 'photos.lock')), 'photomoderator' => array('parent' => 'member', 'permissions' => array(0 => 'photos.edit', 1 => 'photos.delete', 2 => 'photos.unlock')), 'member' => array('parent' => 'guest', 'permissions' => array(0 => 'photos.comments.view', 1 => 'photos.comments.add', 2 => 'photos.rate', 3 => 'lightbox', 4 => 'tags.suggest')), 'guest' => array('parent' => NULL, 'permissions' => array(0 => 'photos.list', 1 => 'photos.detail'))); $this->assertEquals($expected, $cfg); }
public function testOverwrite() { $this->runHandler('test-overwrite'); $expected = array('AgaviConfigAutoloadClass1' => AgaviConfig::get('core.app_dir') . '/lib/config/autoload/AgaviConfigAutoloadClass1.class.php', 'AgaviConfigAutoloadClass2' => AgaviConfig::get('core.app_dir') . '/lib/config/autoload/AgaviConfigAutoloadClass3.class.php', 'AgaviConfigAutoloadClass3' => AgaviConfig::get('core.app_dir') . '/lib/config/autoload/AgaviConfigAutoloadClass3.class.php'); $this->assertEquals($expected, MyAutoloader::$classes); $expected = array('Agavi\\TestAbsolute' => AgaviConfig::get('core.app_dir') . '/lib/config', 'Agavi\\TestRelative' => AgaviConfig::get('core.app_dir') . '/lib/config/autoload'); $this->assertEquals($expected, MyAutoloader::$namespaces); }
/** * Connect to the database. * * @throws <b>AgaviDatabaseException</b> If a connection could not be * created. * * @author Bram Goessens <*****@*****.**> */ protected function connect() { // determine how to get our parameters $method = $this->getParameter('method', 'normal'); // get parameters switch ($method) { case 'normal': // get parameters normally $host = $this->getParameter('host'); $port = $this->getParameter('port', 389); $version = $this->getParameter('version', 3); $basedn = $this->getParameter('basedn'); $binddn = $this->getParameter('binddn', null); $bindpw = $this->getParameter('bindpw', null); if ($host == null || $port == null || $version == null || $basedn == null) { // missing required dsn parameter $error = 'Database configuration specifies method "normal", but is missing 1 or more parameters. Required parameters are host, port, version, basedn'; throw new AgaviDatabaseException($error); } break; default: // who knows what the user wants... $error = 'Invalid KVDag_LdapDatabase parameter retrieval method "%s"'; $error = sprintf($error, $method); throw new AgaviDatabaseException($error); } // The configuration array: $config = array('host' => $host, 'port' => $port, 'version' => $version, 'basedn' => $basedn); //Connecteer de proxyuser if ($binddn != null && $bindpw != null) { $config['binddn'] = $binddn; $config['bindpw'] = $bindpw; } //Connecteer de authzID gebruiker if (AgaviConfig::get('ldap.proxyAs', false)) { $authzID = AgaviConfig::get('ldap.proxyAs'); $proxy_auth_ctrl = array('oid' => '2.16.840.1.113730.3.4.18', 'value' => "dn:{$authzID}", 'iscritical' => true); $config['options'] = array('LDAP_OPT_SERVER_CONTROLS' => array($proxy_auth_ctrl)); } // Connecting using the configuration: $this->connection = Net_LDAP2::connect($config); // Testing for connection error if (Net_LDAP2::isError($this->connection)) { // the connection's foobar'd $error = 'Failed to create a KVDag_LdapDatabase connection'; throw new AgaviDatabaseException($error); } // make sure the connection went through if ($this->connection === false) { // the connection's foobar'd $error = 'Failed to create a KVDag_LdapDatabase connection'; throw new AgaviDatabaseException($error); } // since we're not an abstraction layer, we copy the connection // to the resource $this->resource =& $this->connection; }
private function createImage() { $file = AgaviConfig::get('org.icinga.appkit.image_absolute_path') . self::BASE_IMAGE_FILE; if (!is_file($file)) { throw new AppKitModelException("Could not read base image file: " . $file); } $this->contentType = 'image/png'; return file_get_contents($file); }
/** * (non-PHPdoc) * @see CronksBaseModel::initialize() */ public function initialize(AgaviContext $context, array $parameters = array()) { parent::initialize($context, $parameters); // Init cronk categgory configurtion $tmp = (include AgaviConfigCache::checkConfig(AgaviConfig::get('core.config_dir') . '/cronks.xml')); self::$xml_categories = (array) $tmp[1]; // Init user objects $this->refreshUser(); }
public function executeConsole(AgaviRequestDataHolder $request_data) { $command = $request_data->getParameter('command'); $values = $command->getValues(); // this should be more sophisticated as it e.g. doesn't include a custom port $set_password_url = sprintf('%shoneybee-system_account-user/password?token=%s', AgaviConfig::get('local.base_href'), $values['auth_token']); $set_password_cli_command = $this->routing->gen('honeybee.system_account.user.password', ['token' => $values['auth_token']]); $this->cliMessage(PHP_EOL . $this->translation_manager->_('Please set a password for the created account at: ') . $set_password_url . PHP_EOL . $this->translation_manager->_('Via CLI use the following: ') . $set_password_cli_command . PHP_EOL); }
public function tearDown() { $_SERVER = $this->_SERVER; $_ENV = $this->_ENV; $_GET = $this->_GET; $ctx = AgaviContext::getInstance('routing-server-cases'); $ctx->getRequest()->initialize($ctx); AgaviConfig::set('core.use_routing', false); }
/** * Initialize this AgaviLoggingManager. * * @param AgaviContext An AgaviContext instance. * @param array An array of initialization parameters. * * @throws <b>AgaviInitializationException</b> If an error occurs while * initializing this instance. * * @author David Zülke <*****@*****.**> * @author Sean Kerr <*****@*****.**> * @since 0.9.0 */ public function initialize(AgaviContext $context, array $parameters = array()) { $this->context = $context; if (isset($parameters['default_message_class'])) { $this->defaultMessageClass = $parameters['default_message_class']; } // load logging configuration require AgaviConfigCache::checkConfig(AgaviConfig::get('core.config_dir') . '/logging.xml', $context->getName()); }
public function main() { require_once dirname(__FILE__) . '/../../app/config.php'; Agavi::bootstrap('development'); AgaviController::initializeModule('AppKit'); AgaviConfig::set('core.default_context', 'console'); AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext'); AgaviContext::getInstance('console')->getController()->dispatch(); }