protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $this->logSection('rdvz', "Retrieving users...") ; $ldap = new uapvLdap() ; $users = Doctrine::getTable('user')->retrieveLdapUsers() ; $this->logSection('rdvz', "Updating information...") ; foreach($users as $user) { $us = $ldap->searchOne(sfConfig::get('app_profile_var_translation_uid')."=".$user->getLdapId()) ; $user->setName($us[sfConfig::get('app_profile_var_translation_name')]) ; $user->setSurname($us[sfConfig::get('app_profile_var_translation_surname')]) ; $user->setMail($us[sfConfig::get('app_profile_var_translation_mail')]) ; $user->save(); } $this->logSection('rdvz', "Done.") ; }
/** * Executes this filter. * * @param sfFilterChain A sfFilterChain instance. */ public function execute($filterChain) { $context = $this->getContext(); $userAttributeHolder = $context->getUser()->getAttributeHolder(); // execute this filter only once if ($this->isFirstCall()) { // flag current flash to be removed after the execution filter $names = $userAttributeHolder->getNames('symfony/flash'); if ($names) { if (sfConfig::get('sf_logging_enabled')) { $context->getLogger()->info('{sfFilter} flag old flash messages ("' . implode('", "', $names) . '")'); } foreach ($names as $name) { $userAttributeHolder->set($name, true, 'symfony/flash/remove'); } } } // execute next filter $filterChain->execute(); // remove flash that are tagged to be removed $names = $userAttributeHolder->getNames('symfony/flash/remove'); if ($names) { if (sfConfig::get('sf_logging_enabled')) { $context->getLogger()->info('{sfFilter} remove old flash messages ("' . implode('", "', $names) . '")'); } foreach ($names as $name) { $userAttributeHolder->remove($name, 'symfony/flash'); $userAttributeHolder->remove($name, 'symfony/flash/remove'); } } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { require_once dirname(__FILE__) . '/sfLimeHarness.class.php'; $h = new sfLimeHarness(array('force_colors' => isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace'])); $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins())); $h->base_dir = sfConfig::get('sf_test_dir'); $status = false; $statusFile = sfConfig::get('sf_cache_dir') . '/.test_all_status'; if ($options['only-failed']) { if (file_exists($statusFile)) { $status = unserialize(file_get_contents($statusFile)); } } if ($status) { foreach ($status as $file) { $h->register($file); } } else { // filter and register all tests $finder = sfFinder::type('file')->follow_link()->name('*Test.php'); $h->register($this->filterTestFiles($finder->in($h->base_dir), $arguments, $options)); } $ret = $h->run() ? 0 : 1; file_put_contents($statusFile, serialize($h->get_failed_files())); if ($options['xml']) { file_put_contents($options['xml'], $h->to_xml()); } return $ret; }
public function setPerformanceTrackList() { $auth = Auth::instance(); $loggedInEmpNumber = $auth->getEmployeeNumber(); $searchParameter = array('page' => $this->getPageNumber(), 'limit' => sfConfig::get('app_items_per_page'), 'employeeId' => $loggedInEmpNumber); $this->performanceTrackList = $this->getPerformanceTrackerService()->getPerformanceTrackerByEmployee($searchParameter); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (count($arguments['name'])) { $files = array(); foreach ($arguments['name'] as $name) { $finder = sfFinder::type('file')->follow_link()->name(basename($name) . 'Test.php'); $files = array_merge($files, $finder->in(sfConfig::get('sf_test_dir') . '/unit/' . dirname($name))); } if ($allFiles = $this->filterTestFiles($files, $arguments, $options)) { foreach ($allFiles as $file) { include $file; } } else { $this->logSection('test', 'no tests found', null, 'ERROR'); } } else { require_once __DIR__ . '/sfLimeHarness.class.php'; $h = new sfLimeHarness(array('force_colors' => isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace'], 'test_path' => sfConfig::get('sf_cache_dir') . '/lime')); $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins())); $h->base_dir = sfConfig::get('sf_test_dir') . '/unit'; // filter and register unit tests $finder = sfFinder::type('file')->follow_link()->name('*Test.php'); $h->register($this->filterTestFiles($finder->in($h->base_dir), $arguments, $options)); $ret = $h->run() ? 0 : 1; if ($options['xml']) { file_put_contents($options['xml'], $h->to_xml()); } return $ret; } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { parent::execute($arguments, $options); $projectWebPath = sfConfig::get('sf_web_dir'); $filesystem = new dmFilesystem($this->dispatcher, $this->formatter); foreach (array('dmAdminPlugin', 'dmFrontPlugin') as $plugin) { $this->logSection('plugin', 'Configuring plugin - ' . $plugin); $this->installPluginAssets($plugin, dm::getDir() . '/' . $plugin); } // remove useless doctrine assets if (is_readable($doctrineAssetPath = dmOs::join($projectWebPath, 'sfDoctrinePlugin'))) { if (!is_link($doctrineAssetPath)) { $filesystem->deleteDirContent($doctrineAssetPath); } $filesystem->remove($doctrineAssetPath); } // remove web cache dir $webCacheDir = sfConfig::get('sf_web_dir') . '/cache'; if (is_link($webCacheDir)) { $filesystem->remove($webCacheDir); } // create web cache dir $filesystem->mkdir($webCacheDir); if (!file_exists(dmOs::join($projectWebPath, 'sf'))) { $filesystem->relativeSymlink(realpath(sfConfig::get('sf_symfony_lib_dir') . '/../data/web/sf'), dmOs::join($projectWebPath, 'sf'), true); } }
function forum_breadcrumb($params, $options = array()) { if (!$params) { return; } $first = true; $title = ''; $id = isset($options['id']) ? $options['id'] : 'forum_navigation'; $html = '<ul id="' . $id . '">'; foreach ($params as $step) { $separator = $first ? '' : sfConfig::get('app_sfSimpleForumPlugin_breadcrumb_separator', ' » '); $first = false; $html .= '<li>' . $separator; $title .= $separator; if (is_array($step)) { $html .= link_to($step[0], $step[1]); $title .= $step[0]; } else { $html .= $step; $title .= $step; } $html .= '</li>'; } $html .= '</ul>'; sfContext::getInstance()->getResponse()->setTitle($title); return $html; }
public function setup() { parent::setup(); $this->widgetSchema['image'] = new sfWidgetFormInputFileEditable(array('file_src' => '/uploads/' . sfConfig::get('app_sfSimpleForumPlugin_upload_dir', '') . $this->getObject()->getImage(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'with_delete' => true)); $this->validatorSchema['image'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_upload_dir') . '/' . sfConfig::get('app_sfSimpleForumPlugin_upload_dir', ''), 'mime_types' => 'web_images')); $this->validatorSchema['image_delete'] = new sfValidatorBoolean(); }
/** * Methods used by unit.php and functional.php bootstrap files */ public function initializeSympal() { copy(sfConfig::get('sf_data_dir') . '/fresh_test_db.sqlite', sfConfig::get('sf_data_dir') . '/test.sqlite'); if (isset($this->pluginConfigurations['sfSympalPlugin'])) { $this->pluginConfigurations['sfSympalPlugin']->getSympalConfiguration()->getCache()->primeCache(true); } }
public function setDynamicRules() { $context = $this->getContext(); $user = $context->getUser(); $request = $context->getRequest(); $module = $request->getParameter('module'); $action = $request->getParameter('action'); $cache = false; $lifetime = 0; $withLayout = false; //the following actions will not be hard cached when access is restricted to admins only $nuclearCachingExceptions = array('sfGuardAuth' => array('signin' => true), 'home' => array('contact' => true, 'join' => true, 'confirmed' => true, 'requested' => true, 'joined' => true, 'confirmEmail' => true, 'chat' => true)); //if access is restricted to admins only, pages not in the home module will be cached for a week if (sfConfig::get('app_login_admin_only') == 'on' && (!$user->isAuthenticated() || !sfGuardUserTable::isAdmin($user->getGuardUser()->id)) && !isset($nuclearCachingExceptions[$module][$action])) { $cache = true; $withLayout = true; $lifetime = self::WEEK_LIFETIME; } elseif ($lifetime = self::$alwaysCached[$module][$action]) { $cache = true; $withLayout = $request->isXmlHttpRequest() || !$user->isAuthenticated(); } elseif (!$user->isAuthenticated() && ($lifetime = self::$outsideCached[$module][$action])) { $cache = true; $withLayout = true; } elseif ($user->isAuthenticated() && ($lifetime = self::$insideCached[$module][$action])) { $cache = true; $withLayout = false; } if ($cache) { $context->getViewCacheManager()->addCache($module, $action, array('withLayout' => $withLayout, 'lifeTime' => $lifetime)); } }
public function save(Doctrine_Connection $conn = null) { try { $this->setIsTosync(1); parent::save($conn); if ($this->getGainId() != null) { $send_email_visiteur_template_id = $this->getGain()->getSendEmailVisiteurTemplateId(); $send_email_admin_template_id = $this->getGain()->getSendEmailAdminTemplateId(); if ($send_email_visiteur_template_id || $send_email_admin_template_id) { $visiteur = Doctrine_Core::getTable('Visiteur')->findOneBy('guid', $this->getVisiteurId()); $gain = $this->getGain(); $univers_status = $this->getUniversStatus(); $visiteur_email = $visiteur->getEmail(); $admin_email = sfConfig::get('app_gain_admin_email', null); $array_replace = array('$visiteur_pseudo' => $visiteur->getPseudoSon(), '$visiteur_nom' => $visiteur->getNom(), '$visiteur_prenom' => $visiteur->getPrenom(), '$visiteur_adresse1' => $visiteur->getAdresse(), '$visiteur_adresse2' => $visiteur->getAdresse2(), '$visiteur_cp' => $visiteur->getCodePostal(), '$visiteur_ville' => $visiteur->getVille(), '$visiteur_num_mobile' => $visiteur->getNumMobile(), '$visiteur_email' => $visiteur->getEmail(), '$host_image_src' => sfConfig::get('app_host_image_src'), '$gain_libelle' => $gain->getLibelle(), '$gain_image' => $gain->getImage(), '$gain_description' => $gain->getDescription(), '$gain_start_at' => $gain->getStartAt(), '$gain_end_at' => $gain->getEndAt(), '$univers_status_level' => $univers_status->getLevel(), '$univers_status_level_name' => $univers_status->getLevelName(), '$univers_status_description' => $univers_status->getDescription(), '$univers_status_libelle' => $univers_status->getLibelle()); } // envoi d'un email au visiteur if ($send_email_visiteur_template_id && $visiteur_email) { $template = Doctrine_Query::create()->from('TemplateMail t')->where('t.guid = ?', $send_email_visiteur_template_id)->fetchOne(); if ($template !== false) { $template->sendEmail($visiteur_email, $array_replace); } } // envoi d'un email a l'admin if ($send_email_admin_template_id && $admin_email) { $template = Doctrine_Query::create()->from('TemplateMail t')->where('t.guid = ?', $send_email_admin_template_id)->fetchOne(); if ($template !== false) { $template->sendEmail($admin_email, $array_replace); } } } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
/** * Constructor * @param object $class * @param integer $maxPerPage * @param sfSphinxClient $sphinx */ public function __construct($class, $maxPerPage = 10, sfSphinxClient $sphinx) { if (sfConfig::get('sf_logging_enabled')) { sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent(null, 'application.log', array('Class ' . __CLASS__ . ' is deprecated in favor of sfSphinxPropelPager.', 'priority' => sfLogger::ERR))); } parent::__construct($class, $maxPerPage, $sphinx); }
public function getNextHost() { if (self::$aHostNumber >= self::$aHostCount) { self::$aHostNumber = 0; } return self::$aHosts[self::$aHostNumber++] . "/" . sfConfig::get('app_amazons3_bucket'); }
/** * Executes this configuration handler. * * @param array $configFiles An array of absolute filesystem path to a configuration file * * @return string Data to be written to a cache file * * @throws sfConfigurationException If a requested configuration file does not exist or is not readable * @throws sfParseException If a requested configuration file is improperly formatted */ public function execute($configFiles) { // parse the yaml $config = self::getConfiguration($configFiles); // init our data $data = ''; // let's do our fancy work foreach ($config as $file) { if (!is_readable($file)) { // file doesn't exist throw new sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file)); } $contents = file_get_contents($file); // strip comments (not in debug mode) if (!sfConfig::get('sf_debug')) { $contents = sfToolkit::stripComments($contents); } // strip php tags $contents = sfToolkit::pregtr($contents, array('/^\\s*<\\?(php\\s*)?/m' => '', '/^\\s*\\?>/m' => '')); // replace windows and mac format with unix format $contents = str_replace("\r", "\n", $contents); // replace multiple new lines with a single newline $contents = preg_replace(array('/\\s+$/Sm', '/\\n+/S'), "\n", $contents); // append file data $data .= "\n" . $contents; } // compile data return sprintf("<?php\n" . "// auto-generated by sfCompileConfigHandler\n" . "// date: %s\n" . "%s\n", date('Y/m/d H:i:s'), $data); }
private function _generateNextLink($application) { if ($application === 'backend') { return sfConfig::get('app_backend_url') . '' . $_SERVER['REQUEST_URI']; } return sfConfig::get('app_frontend_url') . '' . $_SERVER['REQUEST_URI']; }
/** * Dispatches a request. * * This will determine which module and action to use by request parameters specified by the user. */ public function dispatch() { try { if (sfConfig::get('sf_logging_enabled')) { $this->getContext()->getLogger()->info('{sfController} dispatch request'); } // reinitialize filters (needed for unit and functional tests) sfFilter::$filterCalled = array(); // determine our module and action $request = $this->getContext()->getRequest(); $moduleName = $request->getParameter('module'); $actionName = $request->getParameter('action'); // make the first request $this->forward($moduleName, $actionName); } catch (sfException $e) { if (sfConfig::get('sf_test')) { throw $e; } $e->printStackTrace(); } catch (Exception $e) { if (sfConfig::get('sf_test')) { throw $e; } try { // wrap non symfony exceptions $sfException = new sfException(); $sfException->printStackTrace($e); } catch (Exception $e) { header('HTTP/1.0 500 Internal Server Error'); } } }
public static function sendNotification($c, $projects, $send_to, $sf_user) { foreach ($send_to as $type => $users) { switch ($type) { case 'status': $subject = t::__('Project Status Updated'); break; default: $subject = t::__('New Project'); break; } $to = array(); foreach ($users as $v) { if ($u = Doctrine_Core::getTable('Users')->find($v)) { $to[$u->getEmail()] = $u->getName(); } } $user = $sf_user->getAttribute('user'); $from[$user->getEmail()] = $user->getName(); $to[$projects->getUsers()->getEmail()] = $projects->getUsers()->getName(); $to[$user->getEmail()] = $user->getName(); if (sfConfig::get('app_send_email_to_owner') == 'off') { unset($to[$user->getEmail()]); } $subject .= ': ' . $projects->getName() . ($projects->getProjectsStatusId() > 0 ? ' [' . $projects->getProjectsStatus()->getName() . ']' : ''); $body = $c->getComponent('projects', 'emailBody', array('projects' => $projects)); Users::sendEmail($from, $to, $subject, $body, $sf_user); } }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $this->logSection('Create directory', "Visiteur"); $q = Doctrine_Query::create()->from('Visiteur v'); $visiteurs = $q->execute(); foreach ($visiteurs as $visiteur) { $visiteur->createDataFolder(); } $this->logSection('Create directory', "Interactif"); $q = Doctrine_Query::create()->from('Interactif i'); $interactifs = $q->execute(); foreach ($interactifs as $interactif) { $interactif->createDataFolder(); } $this->logSection('Create directory', "Exposition"); $q = Doctrine_Query::create()->from('Exposition v'); $expositions = $q->execute(); foreach ($expositions as $exposition) { $exposition->createDataFolder(); } $this->logSection('Create directory', "Medaille"); $fileSystem = new sfFilesystem(); $fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille"); $this->logSection('Create directory', "MedailleType"); $fileSystem = new sfFilesystem(); $fileSystem->mkdirs(sfConfig::get('sf_web_dir') . "/medaille_type"); }
/** * clean the comment text field from html, in order to use it as submitted text * uses the htmlpurifier library, or a simple strip_tags call, based on the app.yml config file * * @return String * @param String - the text to be cleaned * * @author Guglielmo Celata * @see http://htmlpurifier.org/ **/ public static function clean($text) { $allowed_html_tags = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_allowed_tags', array()); $use_htmlpurifier = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_use_htmlpurifier', false); if ($use_htmlpurifier) { $htmlpurifier_path = sfConfig::get('app_deppPropelActAsCommentableBehaviorPlugin_htmlpurifier_path', SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'htmlpurifier' . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR); require_once $htmlpurifier_path . 'HTMLPurifier.auto.php'; $config = HTMLPurifier_Config::createDefault(); $config->set('HTML', 'Doctype', 'XHTML 1.0 Strict'); $config->set('HTML', 'Allowed', implode(',', array_keys($allowed_html_tags))); if (isset($allowed_html_tags['a'])) { $config->set('HTML', 'AllowedAttributes', 'a.href'); $config->set('AutoFormat', 'Linkify', true); } if (isset($allowed_html_tags['p'])) { $config->set('AutoFormat', 'AutoParagraph', true); } $purifier = new HTMLPurifier($config); $clean_text = $purifier->purify($text); } else { $allowed_html_tags_as_string = ""; foreach ($allowed_html_tags as $tag) { $allowed_html_tags_as_string .= "{$tag}"; } $clean_text = strip_tags($text, $allowed_html_tags_as_string); } return $clean_text; }
function price_for($rt_shop_product, $config = array()) { $format_was = '<span class="price-before">%s<em>%s</em></span>'; $format_now = '<span class="price-now">%s<em>%s</em></span>'; $config['format_was'] = isset($config['format_was']) ? $config['format_was'] : $format_was; $config['format_now'] = isset($config['format_now']) ? $config['format_now'] : $format_now; $config['format_now_preffix_from'] = isset($config['format_now_preffix_from']) ? $config['format_now_preffix_from'] : __('From') . ' '; $config['format_now_preffix_only'] = isset($config['format_now_preffix_only']) ? $config['format_now_preffix_only'] : ''; $config['format_now_preffix_now_only'] = isset($config['format_now_preffix_now_only']) ? $config['format_now_preffix_now_only'] : __('Now') . ' '; $config['format_now_preffix_now_from_only'] = isset($config['format_now_preffix_now_from_only']) ? $config['format_now_preffix_now_from_only'] : __('Now') . ' '; // This might need to be changes to "Now from"? $config['format_was_preffix'] = isset($config['format_was_preffix']) ? $config['format_was_preffix'] : __('Was') . ' '; $currency = sfConfig::get('app_rt_currency', 'USD'); $price_min = $rt_shop_product->isOnPromotion() ? $rt_shop_product->getMinimumPrice() : $rt_shop_product->getMinRetailPrice(); $price_max = max($rt_shop_product->getMaxRetailPrice(), $rt_shop_product->getMaxPromotionPrice()); if (!$rt_shop_product->isOnPromotion()) { return sprintf($config['format_now'], $price_min != $price_max ? $config['format_now_preffix_from'] : $config['format_now_preffix_only'], format_currency($price_min, $currency)); } $string = ''; $retail_prices_match = $rt_shop_product->getMaxRetailPrice() == $rt_shop_product->getMinRetailPrice(); $promo_prices_match = $rt_shop_product->getMaxPromotionPrice() == $rt_shop_product->getMinPromotionPrice(); if ($retail_prices_match) { $string = sprintf($config['format_was'], $config['format_was_preffix'], format_currency($price_max, $currency)); } $string .= ' ' . sprintf($config['format_now'], $promo_prices_match ? $config['format_now_preffix_now_only'] : $config['format_now_preffix_now_from_only'], format_currency($price_min, $currency)); return $string; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $connections = $this->getConnections($databaseManager); $manager = new PropelMigrationManager(); $manager->setConnections($connections); $manager->setMigrationTable($options['migration-table']); $migrationDirectory = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . $options['migration-dir']; $manager->setMigrationDir($migrationDirectory); if (!($nextMigrationTimestamp = $manager->getFirstUpMigrationTimestamp())) { $this->logSection('propel', 'All migrations were already executed - nothing to migrate.'); return false; } $this->logSection('propel', sprintf('Executing migration %s up', $manager->getMigrationClassName($nextMigrationTimestamp))); $migration = $manager->getMigrationObject($nextMigrationTimestamp); if (false === $migration->preUp($manager)) { $this->logSection('propel', 'preUp() returned false. Aborting migration.', null, 'ERROR'); return false; } foreach ($migration->getUpSQL() as $datasource => $sql) { $connection = $manager->getConnection($datasource); if ($options['verbose']) { $this->logSection('propel', sprintf(' Connecting to database "%s" using DSN "%s"', $datasource, $connection['dsn']), null, 'COMMENT'); } $pdo = $manager->getPdoConnection($datasource); $res = 0; $statements = PropelSQLParser::parseString($sql); foreach ($statements as $statement) { try { if ($options['verbose']) { $this->logSection('propel', sprintf(' Executing statement "%s"', $statement), null, 'COMMENT'); } $stmt = $pdo->prepare($statement); $stmt->execute(); $res++; } catch (PDOException $e) { $this->logSection(sprintf('Failed to execute SQL "%s". Aborting migration.', $statement), null, 'ERROR'); return false; // continue } } if (!$res) { $this->logSection('propel', 'No statement was executed. The version was not updated.'); $this->logSection('propel', sprintf('Please review the code in "%s"', $manager->getMigrationDir() . DIRECTORY_SEPARATOR . $manager->getMigrationClassName($nextMigrationTimestamp))); $this->logSection('propel', 'Migration aborted', null, 'ERROR'); return false; } $this->logSection('propel', sprintf('%d of %d SQL statements executed successfully on datasource "%s"', $res, count($statements), $datasource)); $manager->updateLatestMigrationTimestamp($datasource, $nextMigrationTimestamp); if ($options['verbose']) { $this->logSection('propel', sprintf(' Updated latest migration date to %d for datasource "%s"', $nextMigrationTimestamp, $datasource), null, 'COMMENT'); } } $migration->postUp($manager); if ($timestamps = $manager->getValidMigrationTimestamps()) { $this->logSection('propel', sprintf('Migration complete. %d migrations left to execute.', count($timestamps))); } else { $this->logSection('propel', 'Migration complete. No further migration to execute.'); } }
public function __construct(Member $member = null, $options = array(), $CSRFSecret = null) { parent::__construct($member, $options, $CSRFSecret); if (sfConfig::get('op_is_use_captcha', false)) { $this->embedForm('captcha', new opCaptchaForm()); } }
function cryptographp_reload() { $reload_img = sfConfig::get('app_cryptographp_reloadimg', '/sfCryptographpPlugin/images/reload'); //$ret = "<a style=\"cursor:pointer\" onclick=\"javascript:document.getElementById('cryptogram').src='".url_for('cryptographp/index?id=')."/'+Math.round(Math.random(0)*1000)+1\">".image_tag('/sfCryptographpPlugin/images/reload')."</a>"; $ret = "<a style=\"cursor:pointer\" onclick=\"javascript:document.getElementById('cryptogram').src='" . url_for('cryptographp/index?id=') . "/'+Math.round(Math.random(0)*1000)+1\">" . image_tag($reload_img) . "</a>"; return $ret; }
public function initialize() { $enabledModules = sfConfig::get('sf_enabled_modules'); if (is_array($enabledModules)) { sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules'), array('oauth'))); } }
public function getRouteObject() { if (!$this->_routeObject) { $this->_routeObject = new sfRoute($this->getRoutePath(), array('sf_format' => 'html', 'sf_culture' => sfConfig::get('default_culture'))); } return $this->_routeObject; }
/** * Listens to the response.filter_content event. * * @param sfEvent $event The sfEvent instance * @param string $context The response content * * @return string The filtered response content */ public function filterResponseContent(sfEvent $event, $content) { if (!sfConfig::get('sf_web_debug')) { return $content; } // log timers information $messages = array(); foreach (sfTimerManager::getTimers() as $name => $timer) { $messages[] = sprintf('%s %.2f ms (%d)', $name, $timer->getElapsedTime() * 1000, $timer->getCalls()); } $this->dispatcher->notify(new sfEvent($this, 'application.log', $messages)); // don't add debug toolbar: // * for XHR requests // * if 304 // * if not rendering to the client // * if HTTP headers only $response = $event->getSubject(); if (!$this->context->has('request') || !$this->context->has('response') || !$this->context->has('controller') || $this->context->getRequest()->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $this->context->getController()->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) { return $content; } // add needed assets for the web debug toolbar $root = $this->context->getRequest()->getRelativeUrlRoot(); $assets = sprintf(' <script type="text/javascript" src="%s"></script> <link rel="stylesheet" type="text/css" media="screen" href="%s" />', $root . sfConfig::get('sf_web_debug_web_dir') . '/js/main.js', $root . sfConfig::get('sf_web_debug_web_dir') . '/css/main.css'); $content = str_ireplace('</head>', $assets . '</head>', $content); // add web debug information to response content $webDebugContent = $this->webDebug->getResults(); $count = 0; $content = str_ireplace('</body>', $webDebugContent . '</body>', $content, $count); if (!$count) { $content .= $webDebugContent; } return $content; }
/** * Add / update employee emergencyContact * * @param int $empNumber Employee number * * @return boolean true if successfully assigned, false otherwise */ public function execute($request) { $contacts = $request->getParameter('emgcontacts'); $empNumber = isset($contacts['empNumber']) ? $contacts['empNumber'] : $request->getParameter('empNumber'); $this->empNumber = $empNumber; $this->emergencyContactPermissions = $this->getDataGroupPermissions('emergency_contacts', $empNumber); $loggedInEmpNum = $this->getUser()->getEmployeeNumber(); $adminMode = $this->getUser()->hasCredential(Auth::ADMIN_ROLE); if (!$this->IsActionAccessible($empNumber)) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } $essMode = !$adminMode && !empty($loggedInEmpNum) && $empNumber == $loggedInEmpNum; $param = array('empNumber' => $empNumber, 'ESS' => $essMode, 'emergencyContactPermissions' => $this->emergencyContactPermissions); $this->form = new EmployeeEmergencyContactForm(array(), $param, true); if ($this->emergencyContactPermissions->canUpdate() || $this->emergencyContactPermissions->canCreate()) { if ($this->getRequest()->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->form->save(); $this->getUser()->setFlash('templateMessage', array('success', __(TopLevelMessages::SAVE_SUCCESS))); } } } $empNumber = $request->getParameter('empNumber'); $this->redirect('pim/viewEmergencyContacts?empNumber=' . $empNumber); }
/** * @see sfPluginConfiguration */ public function initialize() { sfConfig::set('sf_orm', 'propel'); if (!sfConfig::get('sf_admin_module_web_dir')) { sfConfig::set('sf_admin_module_web_dir', '/sfPropelPlugin'); } sfToolkit::addIncludePath(array(sfConfig::get('sf_root_dir'), sfConfig::get('sf_propel_runtime_path', realpath(dirname(__FILE__) . '/../lib/vendor')))); require_once 'propel/Propel.php'; if (!Propel::isInit()) { if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { Propel::setLogger(new sfPropelLogger($this->dispatcher)); } $propelConfiguration = new PropelConfiguration(); Propel::setConfiguration($propelConfiguration); $this->dispatcher->notify(new sfEvent($propelConfiguration, 'propel.configure')); Propel::initialize(); } $this->dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent')); if (sfConfig::get('sf_web_debug')) { $this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelPropel', 'listenToAddPanelEvent')); } if (sfConfig::get('sf_test')) { $this->dispatcher->connect('context.load_factories', array($this, 'clearAllInstancePools')); } }
public function loadFixtures($fixtures) { // initialize database manager $databaseManager = new sfDatabaseManager($this); // cleanup database $db = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . '/database.sqlite'; if (file_exists($db)) { unlink($db); } // initialize database $sql = file_get_contents(sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'lib.model.schema.sql'); $sql = preg_replace('/^\\s*\\-\\-.+$/m', '', $sql); $sql = preg_replace('/^\\s*DROP TABLE .+?$/m', '', $sql); $con = Propel::getConnection(); $tables = preg_split('/CREATE TABLE/', $sql); foreach ($tables as $table) { $table = trim($table); if (!$table) { continue; } $con->executeQuery('CREATE TABLE ' . $table); } // load fixtures $data = new sfPropelData(); if (is_array($fixtures)) { $data->loadDataFromArray($fixtures); } else { $data->loadData(sfConfig::get('sf_data_dir') . '/' . $fixtures); } }
protected function doClean($values) { $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : ''; $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : ''; $allowEmail = sfConfig::get('app_sf_guard_plugin_allow_login_with_email', true); $method = $allowEmail ? 'retrieveByUsernameOrEmailAddress' : 'retrieveByUsername'; // don't allow to sign in with an empty username if ($username) { if ($callable = sfConfig::get('app_sf_guard_plugin_retrieve_by_username_callable')) { $user = call_user_func_array($callable, array($username)); } else { $user = $this->getTable()->retrieveByUsername($username); } // user exists? if ($user) { // password is ok? if ($user->getIsActive() && $user->checkPassword($password)) { return array_merge($values, array('user' => $user)); } } } if ($this->getOption('throw_global_error')) { throw new sfValidatorError($this, 'invalid'); } throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid'))); }