Exemplo n.º 1
0
    protected function execute($arguments = array(), $options = array())
    {
        $configuration = ProjectConfiguration::getApplicationConfiguration($options['application'], $options['env'], true);
        $databaseManager = new sfDatabaseManager($this->configuration);
        $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
        $oBilling = new BillingClass();
        $oBilling->puserDailyPayment();
        $q = Doctrine_Query::create()->from('BalanceUser bu')->innerJoin('bu.User u')->where('bu.payable > 0')->andWhere('bu.was_paid = 0')->andWhere('u.active = 1')->andWhere('u.utype = "puser"')->groupBy('bu.id_user')->execute();
        $frontendRouting = new sfPatternRouting(new sfEventDispatcher());
        $config = new sfRoutingConfigHandler();
        $routes = $config->evaluate(array(sfConfig::get('sf_apps_dir') . '/frontend/config/routing.yml'));
        $frontendRouting->setRoutes($routes);
        foreach ($q as $rec) {
            if (!preg_match('/^R[0-9]{12}$/', $rec->getUser()->getAccountNumber())) {
                $email = $rec->getUser()->getEmail();
                $url = 'http://read2read.ru' . $frontendRouting->generate('profile_p_invoice', array(), true);
                $message = $this->getMailer()->compose(sfConfig::get('app_r2r_noreply_email'), $email, 'Read2Read - Напоминание о заполнении номера кошелька', <<<EOF
Вы зарегистрировались на сайте Read2Read.ru и на вашем счету имеется сумма положенная
к выплате в следующем платежном периоде. Для получения этих средств перейдите на сайт
Read2Read.ru и заполните номер кошелька. Ссылка для перехода: {$url}
EOF
);
                $this->getMailer()->send($message);
            }
        }
    }
Exemplo n.º 2
0
 /**
  * @see sfTask
  */
 protected function doRun(sfCommandManager $commandManager, $options)
 {
     $this->process($commandManager, $options);
     $this->checkProjectExists();
     $application = $commandManager->getArgumentSet()->hasArgument('application') ? $commandManager->getArgumentValue('application') : null;
     $env = $commandManager->getOptionSet()->hasOption('env') ? $commandManager->getOptionValue('env') : 'test';
     if (!is_null($application)) {
         $this->checkAppExists($application);
         require_once sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php';
         $isDebug = $commandManager->getOptionSet()->hasOption('debug') ? $commandManager->getOptionValue('debug') : true;
         $this->configuration = ProjectConfiguration::getApplicationConfiguration($application, $env, $isDebug, null, $this->dispatcher);
     } else {
         if (file_exists(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php')) {
             require_once sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php';
             $this->configuration = new ProjectConfiguration(null, $this->dispatcher);
         } else {
             $this->configuration = new sfProjectConfiguration(getcwd(), $this->dispatcher);
         }
     }
     $autoloader = sfSimpleAutoload::getInstance();
     foreach ($this->configuration->getModelDirs() as $dir) {
         $autoloader->addDirectory($dir);
     }
     if (!is_null($this->commandApplication) && !$this->commandApplication->withTrace()) {
         sfConfig::set('sf_logging_enabled', false);
     }
     return $this->execute($commandManager->getArgumentValues(), $commandManager->getOptionValues());
 }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $db = Doctrine_Manager::connection();
     $models = array('Entity', 'Relationship', 'LsList');
     foreach ($models as $model) {
         $modelAlias = strtolower($model);
         $updateAlias = $model == 'LsList' ? 'ls_list' : $modelAlias;
         //get records to update
         $q = LsDoctrineQuery::create()->select('id')->from($model . ' ' . $modelAlias)->where($modelAlias . '.last_user_id IS NULL')->limit($options['limit'])->setHydrationMode(Doctrine::HYDRATE_NONE);
         if (!count($rows = $q->execute())) {
             //nothing to update, go to next model
             continue;
         }
         foreach ($rows as $row) {
             $id = $row[0];
             //get last_user_id
             $result = LsDoctrineQuery::create()->select('m.user_id')->from('Modification m')->where('m.object_model = ? AND m.object_id = ?', array($model, $id))->orderBy('m.id DESC')->setHydrationMode(Doctrine::HYDRATE_NONE)->fetchOne();
             if ($lastUserId = $result[0]) {
                 $query = 'UPDATE ' . $updateAlias . ' SET last_user_id=? WHERE id=?';
                 //use PDO for speed
                 $db->execute($query, array($lastUserId, $id));
             } else {
                 throw new Exception("Couldn't find last_user_id for " . $model . ' #' . $id);
             }
         }
         //only update records of one model at a time
         break;
     }
     //DONE
     LsCli::beep();
 }
 public function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     // Récupération de toutes les notices.
     $noeuds = $conn->execute("SELECT id, name FROM ei_data_set_structure;");
     $this->log('Récupération des noeuds...OK');
     // Création de la requête permettant
     $this->log('Création de la requête de mise à jour...');
     $requeteToUpdate = "UPDATE ei_data_set_structure SET slug = #{NEW_SLUG} WHERE id = #{NODE_ID};";
     $requeteGlobale = array();
     foreach ($noeuds->fetchAll() as $noeud) {
         // Remplacement SLUG.
         $tmpRequete = str_replace("#{NEW_SLUG}", $conn->quote(MyFunction::sluggifyForXML($noeud["name"])), $requeteToUpdate);
         // Remplacement ID.
         $tmpRequete = str_replace("#{NODE_ID}", $noeud["id"], $tmpRequete);
         // Ajout dans la requête globale.
         $requeteGlobale[] = $tmpRequete;
     }
     // Préparation de la requête.
     $this->log("Préparation de la requête...");
     $requete = implode(" ", $requeteGlobale);
     try {
         // Exécution de la requête.
         $this->log("Exécution de la requête...");
         $conn->execute($requete);
         // Fin.
         $this->log("Processus terminé avec succès.");
     } catch (Exception $exc) {
         $this->log($exc->getMessage());
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration($options['app'], $options['env'], true);
     if (!sfConfig::get('app_sf_amazon_plugin_access_key', false)) {
         throw new sfException(sprintf('You have not set an amazon access key'));
     }
     if (!sfConfig::get('app_sf_amazon_plugin_secret_key', false)) {
         throw new sfException(sprintf('You have not set an amazon secret key'));
     }
     $s3 = new AmazonS3(sfConfig::get('app_sf_amazon_plugin_access_key'), sfConfig::get('app_sf_amazon_plugin_secret_key'));
     $this->s3_response = $s3->create_bucket($arguments['bucket'], $options['region'], $options['acl']);
     if ($this->s3_response->isOk()) {
         $this->log('Bucketed is being created...');
         /* Since AWS follows an "eventual consistency" model, sleep and poll
            until the bucket is available. */
         $exists = $s3->if_bucket_exists($arguments['bucket']);
         while (!$exists) {
             // Not yet? Sleep for 1 second, then check again
             sleep(1);
             $exists = $s3->if_bucket_exists($arguments['bucket']);
         }
         $this->logSection('Bucket+', sprintf('"%s" created successfully', $arguments['bucket']));
     } else {
         throw new sfException($this->s3_response->body->Message);
     }
 }
Exemplo n.º 6
0
 public function authenticate(MOXMAN_Auth_User $user)
 {
     $config = MOXMAN::getConfig();
     if ($config->get('SymfonyAuthenticator.application_name') == '') {
         die('You should define a SymfonyAuthenticator.application_name name in Moxiemanager config file.');
     }
     if ($config->get('SymfonyAuthenticator.application_env') == '') {
         die('You should define a SymfonyAuthenticator.application_env in Moxiemanager config file.');
     }
     if ($config->get('SymfonyAuthenticator.project_configuration_path') == '') {
         die('You should define a SymfonyAuthenticator.project_configuration_path in Moxiemanager config file.');
     }
     require_once $config->get('SymfonyAuthenticator.project_configuration_path');
     $configuration = ProjectConfiguration::getApplicationConfiguration($config->get('SymfonyAuthenticator.application_name'), $config->get('SymfonyAuthenticator.application_env'), false);
     $context = sfContext::createInstance($configuration);
     // Is the user authenticated ?
     if ($context->getUser()->isAuthenticated()) {
         // Do we need a special role to access to the moxiemanager ?
         if ($config->get('SymfonyAuthenticator.credential') != '') {
             if ($context->getUser()->hasCredential($config->get('SymfonyAuthenticator.credential'))) {
                 return true;
             } else {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
Exemplo n.º 7
0
 protected function execute($arguments = array(), $options = array())
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
     $this->context = sfContext::createInstance($this->configuration);
     $databaseManager = new sfDatabaseManager($this->configuration);
     $dbdsn = $databaseManager->getDatabase('propel')->getParameter('dsn');
     $dbusername = $databaseManager->getDatabase('propel')->getParameter('username');
     $dbpassword = $databaseManager->getDatabase('propel')->getParameter('password');
     $dbname = preg_replace('/^.*dbname=([^;=]+).*$/', '${1}', $dbdsn);
     ConfigurationHelper::load();
     $backup_method = ConfigurationHelper::getParameter('Backup', 'backup_method');
     $this->logSection('tempos', sprintf('Backup method: %s', $backup_method), 1024);
     if ($backup_method == 'ftp') {
         $backupname = 'tempos-backup.sql';
         $configname = ConfigurationHelper::getDefaultConfigurationFileName();
         $configpath = ConfigurationHelper::getDefaultConfigurationFilePath();
         copy($configpath, '/tmp/' . $configname);
         chdir('/tmp');
         system(sprintf('mysqldump --user=%s --password=%s %s > %s', escapeshellarg($dbusername), escapeshellarg($dbpassword), escapeshellarg($dbname), escapeshellarg($backupname)));
         $tmpfilename = 'tempos-backup-' . date('Y-m-d') . '.tar.gz';
         system(sprintf('tar zcf %s %s %s', escapeshellarg($tmpfilename), escapeshellarg($backupname), escapeshellarg($configname)));
         unlink($backupname);
         unlink($configname);
         try {
             FTPHelper::backupFile($tmpfilename);
         } catch (Exception $ex) {
             unlink($tmpfilename);
             throw $ex;
         }
         unlink($tmpfilename);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $db = Doctrine_Manager::connection();
     //get person entities with all-caps names
     $sql = 'SELECT e.id, e.name FROM entity e ' . 'WHERE e.name <> \'\' AND e.primary_ext = ? AND CAST(UPPER(e.name) AS BINARY) = CAST(e.name AS BINARY)';
     $stmt = $db->execute($sql, array('Person'));
     $names = $stmt->fetchAll(PDO::FETCH_ASSOC);
     foreach ($names as $ary) {
         $new = PersonTable::nameizePersonName($ary['name']);
         if ($new != $ary['name']) {
             $sql = 'UPDATE entity SET name = ? WHERE id = ?';
             $stmt = $db->execute($sql, array($new, $ary['id']));
             print "Changed Entity name " . $ary['name'] . " to " . $new . "\n";
         }
     }
     //get aliases with all-caps names
     $sql = 'SELECT a.id, a.name FROM alias a LEFT JOIN entity e ON (e.id = a.entity_id) ' . 'WHERE a.name <> \'\' AND a.is_primary = 1 AND e.primary_ext = ? AND ' . 'CAST(UPPER(a.name) AS BINARY) = CAST(a.name AS BINARY)';
     $stmt = $db->execute($sql, array('Person'));
     $names = $stmt->fetchAll(PDO::FETCH_ASSOC);
     foreach ($names as $ary) {
         $new = PersonTable::nameizePersonName($ary['name']);
         if ($new != $ary['name']) {
             $sql = 'UPDATE alias SET name = ? WHERE id = ?';
             $stmt = $db->execute($sql, array($new, $ary['id']));
             print "Changed Alias " . $ary['name'] . " to " . $new . "\n";
         }
     }
     //DONE
     LsCli::beep();
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     require_once dirname(__FILE__) . '/../../../config/ProjectConfiguration.class.php';
     $configuration = ProjectConfiguration::getApplicationConfiguration('public', 'prod', true);
     sfContext::createInstance($configuration);
     $liveLang = $arguments['live_lang'];
     $langToDeploy = $arguments['lang_to_deploy'];
     $liveLangs = SfConfig::get('app_site_langs');
     $langsUnderDev = SfConfig::get('app_site_langsUnderDev');
     if (in_array($liveLang, $liveLangs) === false) {
         die("The live lang doesn't seem to be live!");
     }
     if (in_array($langToDeploy, $langsUnderDev) === false) {
         die("You can deploy only a language under development");
     }
     $c = new Criteria();
     $c->add(PcTranslationPeer::LANGUAGE_ID, $langToDeploy);
     $translationsToDeploy = PcTranslationPeer::doSelect($c);
     $i = 0;
     foreach ($translationsToDeploy as $translationToDeploy) {
         $this->log("Deploying the string " . $translationToDeploy->getStringId() . " from {$langToDeploy} to {$liveLang}");
         $liveTranslation = PcTranslationPeer::retrieveByPK($liveLang, $translationToDeploy->getStringId());
         $liveTranslation->setString($translationToDeploy->getString())->save();
         $translationToDeploy->delete();
         $i++;
     }
     $this->log("All done. {$i} strings deployed.");
 }
    protected function execute($arguments = array(), $options = array())
    {
        $autoloader = sfSimpleAutoload::getInstance();
        $autoloader->addDirectory(sfConfig::get('sf_plugins_dir') . '/sfPropelMigrationsLightPlugin/lib');

        $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'],
                        $options['env'], true);

        $databaseManager = new sfDatabaseManager($configuration);

        $migrator = new sfMigrator;

        if (isset($arguments['schema-version']) && ctype_digit($arguments['schema-version'])) {
            $max = $arguments['schema-version'];
        } else {
            $max = $migrator->getMaxVersion();
        }

        $migrations = $migrator->getMigrationsToRunUpTo($max);

        foreach ($migrations as $migration) {
            echo "Marking as Migrated: $migration\n";
            $migrator->markMigration($migration);
        }
    }
 /**
  * Executes the current task.
  *
  * @param array $arguments An array of arguments
  * @param array $options An array of options
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     /** @var $parametres Récupération des paramètres à charger */
     $parametres = $conn->execute("\n            SELECT *\n            FROM ei_function_has_param, ei_fonction\n            WHERE param_type = 'OUT'\n            AND (param_id, ei_fonction.id) NOT IN (SELECT ei_param_function_id, ei_function_id FROM ei_param_block_function_mapping)\n            AND ei_function_has_param.function_ref = ei_fonction.function_ref\n            AND ei_function_has_param.function_id = ei_fonction.function_id\n        ");
     $this->log('Récupération des paramètres...OK');
     // Création de la requête permettant
     $this->log('Création de la requête d\'insertion...');
     $requeteToInsert = "INSERT INTO ei_param_block_function_mapping (ei_param_function_id, created_at, updated_at, ei_function_id) ";
     $requeteToInsert .= "VALUES(#{PARAM_ID}, now(), now(), #{FONCTION_ID});";
     $pile = array();
     foreach ($parametres->fetchAll() as $parametre) {
         // Remplacement PARAM ID.
         $tmpRequete = str_replace("#{PARAM_ID}", $parametre["param_id"], $requeteToInsert);
         // Remplacement FONCTION ID.
         $tmpRequete = str_replace("#{FONCTION_ID}", $parametre["id"], $tmpRequete);
         // Ajout dans la requête globale.
         $pile[] = $tmpRequete;
     }
     // Préparation de la requête.
     $this->log("Préparation de la requête...");
     $requete = implode(" ", $pile);
     try {
         // Exécution de la requête.
         $this->log("Exécution de la requête...");
         $conn->execute($requete);
         // Fin.
         $this->log("Processus terminé avec succès.");
     } catch (Exception $exc) {
         $this->log($exc->getMessage());
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $this->db = Doctrine_Manager::connection();
     if ($options['house_senate'] == 'house') {
         $sql = 'select e1.id,e2.id from entity e1 left join political_candidate pc on pc.entity_id = e1.id left join political_candidate pc2 on pc2.house_fec_id = pc.house_fec_id left join entity e2 on e2.id = pc2.entity_id where e1.is_deleted = 0 and e2.is_deleted = 0 and e1.id <> e2.id and pc.id is not null and pc2.id is not null and pc.id <> pc2.id and pc.house_fec_id is not null and pc.house_fec_id <> "" and e1.id < e2.id group by e1.id,e2.id';
     } else {
         if ($options['house_senate'] == 'senate') {
             $sql = 'select e1.id,e2.id from entity e1 left join political_candidate pc on pc.entity_id = e1.id left join political_candidate pc2 on pc2.senate_fec_id = pc.senate_fec_id left join entity e2 on e2.id = pc2.entity_id where e1.is_deleted = 0 and e2.is_deleted = 0 and e1.id <> e2.id and pc.id is not null and pc2.id is not null and pc.id <> pc2.id and pc.senate_fec_id is not null and pc.senate_fec_id <> "" and e1.id < e2.id group by e1.id,e2.id';
         } else {
             echo 'House or Senate not selected...ending script' . "\n";
             die;
         }
     }
     $stmt = $this->db->execute($sql);
     $rows = $stmt->fetchAll();
     foreach ($rows as $row) {
         $e1 = Doctrine::getTable('Entity')->find($row[0]);
         $e2 = Doctrine::getTable('Entity')->find($row[1]);
         $mergedEntity = EntityTable::mergeAll($e1, $e2);
         $e2->setMerge(true);
         $e2->clearRelated();
         $e2->delete();
         echo '  Successfully merged ' . $e2->name . "\n";
         if ($options['test_mode']) {
             die;
         }
     }
 }
 /**
  * Returns current sfApplicationConfiguration instance.
  * If no configuration does currently exist, a new one will be created.
  *
  * @return sfApplicationConfiguration
  */
 protected function getApplicationConfiguration()
 {
     if (is_null($this->applicationConfiguration)) {
         $this->applicationConfiguration = ProjectConfiguration::getApplicationConfiguration($this->getApplication(), $this->getEnvironment(), true);
     }
     return $this->applicationConfiguration;
 }
 /**
  * {@inheritdoc}
  */
 public function boot(ContainerInterface $container)
 {
     if (empty($this->options)) {
         throw new \RuntimeException('You must provide options for the Symfony 1.4 kernel.');
     }
     if ($this->isBooted()) {
         return;
     }
     if ($this->classLoader && !$this->classLoader->isAutoloaded()) {
         $this->classLoader->autoload();
     }
     $dispatcher = $container->get('event_dispatcher');
     $event = new LegacyKernelBootEvent($container->get('request'), $this->options);
     $dispatcher->dispatch(LegacyKernelEvents::BOOT, $event);
     $this->options = $event->getOptions();
     require_once $this->rootDir . '/config/ProjectConfiguration.class.php';
     $application = $this->options['application'];
     $environment = $this->options['environment'];
     $debug = $this->options['debug'];
     $this->configuration = \ProjectConfiguration::getApplicationConfiguration($application, $environment, $debug, $this->getRootDir());
     $this->configuration->loadHelpers(array('Url'));
     // Create a context to use with some helpers like Url.
     if (!\sfContext::hasInstance()) {
         $session = $container->get('session');
         if ($session->isStarted()) {
             $session->save();
         }
         ob_start();
         \sfContext::createInstance($this->configuration);
         ob_end_flush();
         $session->migrate();
     }
     $this->isBooted = true;
 }
Exemplo n.º 15
0
 /**
  * Returns the current application context.
  *
  * @param  bool $forceReload  true to force context reload, false otherwise
  *
  * @return sfContext
  */
 public function getContext($forceReload = false)
 {
     if (null === $this->context || $forceReload) {
         $isContextEmpty = null === $this->context;
         $context = $isContextEmpty ? sfContext::getInstance() : $this->context;
         // create configuration
         $currentConfiguration = $context->getConfiguration();
         $configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug());
         // connect listeners
         $configuration->getEventDispatcher()->connect('application.throw_exception', array($this, 'listenToException'));
         foreach ($this->listeners as $name => $listener) {
             $configuration->getEventDispatcher()->connect($name, $listener);
         }
         // create context
         $this->context = sfContext::createInstance($configuration);
         unset($currentConfiguration);
         if (!$isContextEmpty) {
             sfConfig::clear();
             sfConfig::add($this->rawConfiguration);
         } else {
             $this->rawConfiguration = sfConfig::getAll();
         }
     }
     return $this->context;
 }
Exemplo n.º 16
0
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $fh = fopen($options['file_name'], 'a+');
     $start = count(file($options['file_name']));
     $this->db = Doctrine_Manager::connection();
     $this->list = Doctrine::getTable('LsList')->find($options['list_id']);
     $q = $this->list->getListEntitiesByRankQuery();
     $list_entities = $q->execute();
     function func($value)
     {
         return $value['name'];
     }
     for ($i = $start; $i < count($list_entities); $i++) {
         $entity = $list_entities[$i]->Entity;
         $people = $entity->getRelatedEntitiesQuery(array('Person'), array(1, 2, 3, 4, 6, 7, 8, 9, 10))->execute();
         $orgs = $entity->getRelatedEntitiesQuery(array('Org'), array(1, 2, 3, 4, 6, 7, 8, 9, 10))->execute();
         $donations = $entity->getRelatedEntitiesQuery(array('Person'), array(5))->execute();
         $people = implode("; ", array_map("func", $people->toArray()));
         $orgs = implode("; ", array_map("func", $orgs->toArray()));
         $donations = implode("; ", array_map("func", $donations->toArray()));
         $arr = array($entity, $people, $orgs, $donations);
         $str = implode("\t", $arr);
         fwrite($fh, $str . "\n");
     }
 }
 protected function createContextInstance($application = 'frontend', $enviroment = 'dev', $debug = true)
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($application, $enviroment, $debug);
     sfContext::createInstance($configuration);
     sfContext::switchTo($application);
     $this->context = sfContext::getInstance();
 }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $this->db = Doctrine_Manager::connection();
     $this->s3 = new S3(sfConfig::get('app_amazon_access_key'), sfConfig::get('app_amazon_secret_key'));
     // hide strict errors
     error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
     $sql = "SELECT DISTINCT(r.source) FROM reference r ORDER BY id ASC LIMIT " . $options["limit"] . " OFFSET " . $options["offset"];
     $stmt = $this->db->execute($sql);
     $sources = $stmt->fetchAll(PDO::FETCH_COLUMN);
     foreach ($sources as $source) {
         if (!$options["localdir"]) {
             $s3path = ReferenceTable::generateS3path($source);
             if (!$options["overwrite"] && $this->s3->getObjectInfo(sfConfig::get('app_amazon_s3_bucket'), $s3path) !== false) {
                 print "ALREADY UPLOADED: " . $s3path . "\n";
                 continue;
             }
         }
         $this->writeTmpFile($source, $options["debug_mode"], $options["localdir"]);
         if (!$options["localdir"]) {
             $this->uploadTmpFile($source, $options["overwrite"], $options["debug_mode"]);
             if (unlink($this->getLocalPath($source, $options["local_dir"])) && $options["debug_mode"]) {
                 print "REMOVED LOCAL: " . $source . " [" . sha1($source) . "]\n";
             }
         }
         print "----------------------------------------------------------------\n";
     }
     //DONE
     LsCli::beep();
 }
 /**
  * コンストラクタ
  *
  * @param  string  $app  アプリケーションの種類 (ex. front, dev,... )
  */
 public function __construct($app)
 {
     $this->configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', true);
     new sfDatabaseManager($this->configuration);
     $this->connection = Doctrine_Manager::connection();
     $this->connection->beginTransaction();
 }
 protected function init($arguments, $options)
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     sfContext::createInstance($configuration, 'default');
     $this->db = LsDb::getDbConnection();
     $this->rawDb = LsDb::getDbConnection('raw');
     /*
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $this->db = Doctrine_Manager::connection();
     $rawDb = $databaseManager->getDatabase('raw');
     $this->rawDb = Doctrine_Manager::connection($rawDb->getParameter('dsn'));  
     */
     $this->types = explode(',', $options['types']);
     $this->debugMode = $options['debug_mode'];
     $this->limit = $options['limit'];
     if ($options['expiration_date']) {
         $this->expirationDate = date('Y-m-d H:i:s', strtotime($options['expiration_date']));
     }
     $this->exactNameOverride = $options['exact_name_override'];
     //create insert statement
     $valStr = str_repeat('?, ', 5);
     $valStr = substr($valStr, 0, -2);
     $insertSql = 'INSERT INTO os_entity_category (entity_id, category_id, source, created_at, updated_at) VALUES (' . $valStr . ')';
     $this->insertStmt = $this->db->prepare($insertSql);
     //create lookup statement
     $selectSql = "SELECT category_name FROM os_category WHERE category_id = ?";
     $this->selectStmt = $this->db->prepare($selectSql);
 }
Exemplo n.º 21
0
  public function setup($options, $parameters = array())
  {
    $this->projectDir = dirname(__FILE__).'/../fixtures';
    $this->cleanup();

    foreach (array('model', 'urlPrefix', 'moduleName', 'singularName', 'pluralName', 'projectDir') as $param)
    {
      if (isset($parameters[$param]))
      {
        $this->$param = $parameters[$param];
      }
    }

    chdir($this->projectDir);
    $task = new sfPropelGenerateModuleTask(new sfEventDispatcher(), new sfFormatter());
    $options[] = 'env=test';
    $options[] = 'singular='.$this->singularName;
    $options[] = 'plural='.$this->pluralName;
    $options[] = '--non-verbose-templates';
    $task->run(array('crud', $this->moduleName, $this->model), $options);

    require_once($this->projectDir.'/config/ProjectConfiguration.class.php');
    sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('crud', 'test', true, $this->projectDir));

    return $options;
  }
 public function configure()
 {
     $gifts = array();
     $this->premium_choices = sfConfig::get('app_premium_choices', array('hat' => array('Hat - One Size', 1, 0)));
     foreach ($this->premium_choices as $key => $gift) {
         $gifts[$key] = $gift[0];
     }
     $yes_no = array(1 => 'Yes', 0 => 'No');
     //$total=$request->getParameter('total_amount');
     //print_r($total);
     //die();
     //farazi Condition of validation for admin and mormal member
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);
     $context = sfContext::getInstance();
     $user = $context->getUser();
     $totalAmount = $context->getRequest()->getParameter('total_amount');
     if ($totalAmount > 0) {
         //echo "1";
         $card = array('ccard_number' => new sfValidatorString(array('max_length' => 20, 'required' => true), array('required' => 'Please confirm Credit Card Number')), 'ccard_code' => new sfValidatorString(array('max_length' => 5, 'required' => true)), 'ccard_expire' => new sfValidatorDate(array('date_output' => 'm/Y', 'date_format' => '#\\d\\d\\/\\d\\d\\d\\d#', 'required' => false, 'with_time' => false), array('bad_format' => 'Format errro', 'required' => 'Please confirm Expiration Date', 'invalid' => 'Date of birth is invalid !.')));
     } else {
         //echo "1";
         $card = array('ccard_number' => new sfValidatorString(array('max_length' => 20, 'required' => false), array('required' => 'Please confirm Credit Card Number')), 'ccard_code' => new sfValidatorString(array('max_length' => 5, 'required' => false)), 'ccard_expire' => new sfValidatorDate(array('date_output' => 'm/Y', 'date_format' => '#\\d\\d\\/\\d\\d\\d\\d#', 'required' => false, 'with_time' => false), array('bad_format' => 'Format errro', 'required' => 'Please confirm Expiration Date', 'invalid' => 'Date of birth is invalid !.')));
     }
     /*
         
           //echo "1";
           $card = array(
               'ccard_number' => new sfValidatorString(array('max_length' => 20, 'required' => true),array('required'=>'Please confirm Credit Card Number')),
               'ccard_code'                   => new sfValidatorString(array('max_length' => 5, 'required' => true)),
               'ccard_expire'                 => new sfValidatorDate(array('date_output' =>'m/Y', 'date_format' => '#\d\d\/\d\d\d\d#', 'required' => true, 'with_time' => false), array('bad_format' => 'Format errro', 'required'=>'Please confirm Expiration Date', 'invalid'=> 'Date of birth is invalid !.')),
           );
         }else {
             //echo "1";
             $card = array(
               'ccard_number' => new sfValidatorString(array('max_length' => 20, 'required' => false),array('required'=>'Please confirm Credit Card Number')),
               'ccard_code'                   => new sfValidatorString(array('max_length' => 5, 'required' => false)),
               'ccard_expire'                 => new sfValidatorDate(array('date_output' =>'m/Y', 'date_format' => '#\d\d\/\d\d\d\d#', 'required' => false, 'with_time' => false), array('bad_format' => 'Format errro', 'required'=>'Please confirm Expiration Date', 'invalid'=> 'Date of birth is invalid !.')),
              );
         }*/
     $widgets = array('id' => new sfWidgetFormInputHidden(), 'premium_choice' => new sfWidgetFormSelectRadio(array('choices' => $gifts)), 'premium_size' => new sfWidgetFormInput(), 'mission_orientation' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'mission_coordination' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'pilot_recruitment' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'fund_raising' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'celebrity_contacts' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'graphic_arts' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'hospital_outreach' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'event_planning' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'media_relations' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'telephone_work' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'computers' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'clerical' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'printing' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'writing' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'speakers_bureau' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'wing_team' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'web_internet' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'foundation_contacts' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'aviation_contacts' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'will')), 'member_aopa' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'wiss')), 'member_kiwanis' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'wiss')), 'member_rotary' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'wiss')), 'member_lions' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'wiss')), 'member_99s' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'wiss')), 'member_wia' => new sfWidgetFormInputCheckbox(array(), array('value' => 1, 'class' => 'wiss')), 'company_name' => new sfWidgetFormInput(array(), array('class' => 'text')), 'company_position' => new sfWidgetFormInput(array(), array('class' => 'text')), 'company_match_funds' => new sfWidgetFormSelectRadio(array('choices' => $yes_no, 'formatter' => array($this, 'formatterRaw'))), 'referral_source' => new sfWidgetFormPropelChoice(array('model' => 'RefSource', 'method' => 'getSourceName', 'add_empty' => 'Please Select', 'order_by' => array('SourceName', 'asc'))), 'referral_source_other' => new sfWidgetFormInput(array(), array('class' => 'text narrow')), 'referer_name' => new sfWidgetFormInput(array(), array('class' => 'text')), 'mission_email_optin' => new sfWidgetFormSelectRadio(array('choices' => $yes_no, 'formatter' => array($this, 'formatterRaw'))), 'hseats_interest' => new sfWidgetFormSelectRadio(array('choices' => $yes_no, 'formatter' => array($this, 'formatterRaw'))), 'ccard_number' => new widgetFormInputPhone(array('mask' => '9999-9999-9999-9999', 'ok_class' => 'field_ok', 'holder_class' => 'field_hold'), array('style' => 'width:200')), 'ccard_code' => new sfWidgetFormInput(array(), array('class' => 'text narrowest')), 'ccard_expire' => new widgetFormDate(array('change_year' => true, 'change_month' => true, 'format_date' => array('js' => 'mm/yy', 'php' => 'm/Y'), 'button' => '/images/icons/calendar.gif'), array('class' => 'text narrow')));
     $labels = array('premium_choice' => 'Choose a Gift*', 'mission_orientation' => 'Mission Orientation', 'mission_coordination' => 'Mission Coordination', 'pilot_recruitment' => 'Pilot Recruitment', 'fund_raising' => 'Fund Raising', 'celebrity_contacts' => 'Celebrity Contacts', 'graphic_arts' => 'Graphic Arts', 'hospital_outreach' => 'Hospital Outreach', 'event_planning' => 'Event Planning', 'media_relations' => 'Media Relations', 'telephone_work' => 'Telephone Work', 'computers' => 'Computers', 'clerical' => 'Clerical', 'printing' => 'Printing', 'writing' => 'Writing (grants, newsletter, etc.)', 'speakers_bureau' => 'Speaker\'s Bureau', 'wing_team' => 'Wing Leadership', 'web_internet' => 'Web/Internet', 'foundation_contacts' => 'Foundation Contacts', 'aviation_contacts' => 'Aviation Business Contacts', 'member_aopa' => 'AOPA', 'member_kiwanis' => 'Kiwanis', 'member_rotary' => 'Rotary', 'member_lions' => 'Lions', 'member_99s' => '99\'s', 'member_wia' => 'Women in Aviation', 'company_name' => 'Your company or Employer Name', 'company_position' => 'Your position', 'company_match_funds' => 'Does your company provide matching grants?', 'referral_source' => 'How did you hear about Angel Flight West?', 'referral_source_other' => 'Or, other', 'referer_name' => 'Referer Name', 'mission_email_optin' => 'Do you wish to receive emails listing available missions?', 'hseats_interest' => 'Are you interested in serving as a homeland security pilot?', 'ccard_number' => 'Credit Card Number', 'ccard_code' => 'Code', 'ccard_expire' => 'Expiration Date');
     $helps = array('referer_name' => 'If you were referred to Angel Flight West by a person, please enter his or her name', 'mission_email_optin' => 'Periodic emails will be sent', 'hseats_interest' => 'You will serve as homeland security pilot');
     //'premium_choice'               => new sfValidatorChoice(array('choices' => array_keys($gifts))),
     $isRenewal = ApplicationTempPeer::getRenewalStatus($context->getRequest()->getParameter('id'));
     $validators = array('id' => new sfValidatorPropelChoice(array('model' => 'ApplicationTemp', 'column' => 'id', 'required' => false)), 'premium_choice' => new sfValidatorChoice(array('required' => $isRenewal ? false : true, 'choices' => array_keys($gifts))), 'premium_size' => new sfValidatorInteger(array('required' => false)), 'mission_orientation' => new sfValidatorInteger(array('required' => false)), 'mission_coordination' => new sfValidatorInteger(array('required' => false)), 'pilot_recruitment' => new sfValidatorInteger(array('required' => false)), 'fund_raising' => new sfValidatorInteger(array('required' => false)), 'celebrity_contacts' => new sfValidatorInteger(array('required' => false)), 'graphic_arts' => new sfValidatorInteger(array('required' => false)), 'hospital_outreach' => new sfValidatorInteger(array('required' => false)), 'event_planning' => new sfValidatorInteger(array('required' => false)), 'media_relations' => new sfValidatorInteger(array('required' => false)), 'telephone_work' => new sfValidatorInteger(array('required' => false)), 'computers' => new sfValidatorInteger(array('required' => false)), 'clerical' => new sfValidatorInteger(array('required' => false)), 'printing' => new sfValidatorInteger(array('required' => false)), 'writing' => new sfValidatorInteger(array('required' => false)), 'speakers_bureau' => new sfValidatorInteger(array('required' => false)), 'wing_team' => new sfValidatorInteger(array('required' => false)), 'web_internet' => new sfValidatorInteger(array('required' => false)), 'foundation_contacts' => new sfValidatorInteger(array('required' => false)), 'aviation_contacts' => new sfValidatorInteger(array('required' => false)), 'member_aopa' => new sfValidatorInteger(array('required' => false)), 'member_kiwanis' => new sfValidatorInteger(array('required' => false)), 'member_rotary' => new sfValidatorInteger(array('required' => false)), 'member_lions' => new sfValidatorInteger(array('required' => false)), 'member_99s' => new sfValidatorInteger(array('required' => false)), 'member_wia' => new sfValidatorInteger(array('required' => false)), 'company_name' => new sfValidatorString(array('max_length' => 40, 'required' => false)), 'company_position' => new sfValidatorString(array('max_length' => 40, 'required' => false)), 'company_match_funds' => new sfValidatorInteger(array('required' => false)), 'referral_source' => new sfValidatorPropelChoice(array('model' => 'RefSource', 'column' => 'id', 'required' => false)), 'referral_source_other' => new sfValidatorString(array('max_length' => 40, 'required' => false)), 'referer_name' => new sfValidatorString(array('max_length' => 40, 'required' => false)), 'mission_email_optin' => new sfValidatorInteger(array('required' => false)), 'hseats_interest' => new sfValidatorInteger(array('required' => false)));
     $validators = array_merge((array) $validators, (array) $card);
     /*
     echo "<pre>";
     print_r($validators);
     echo "</pre>";
     die();
     */
     $this->setWidgets($widgets);
     $this->widgetSchema->setLabels($labels);
     $this->widgetSchema->setHelps($helps);
     $this->setValidators($validators);
     $this->widgetSchema->setNameFormat('application[%s]');
     $this->widgetSchema->getFormFormatter()->setHelpFormat('%help%');
 }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $this->debugMode = $options['debug_mode'];
     $this->db = Doctrine_Manager::connection();
     $this->s3 = new S3(sfConfig::get('app_amazon_access_key'), sfConfig::get('app_amazon_secret_key'));
     // hide strict errors
     error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
     //get array of active entity image filenames
     if ($options['list_id']) {
         $sql = "SELECT i.id, i.filename, i.url, i.entity_id, e.name, e.primary_ext " . "FROM ls_list_entity le " . "LEFT JOIN image i ON (i.entity_id = le.entity_id) " . "LEFT JOIN entity e ON (e.id = le.entity_id) " . "WHERE le.list_id = ? AND le.is_deleted = 0 " . "AND i.is_deleted = 0 AND i.has_square = 0 " . "ORDER BY id DESC LIMIT " . $options['limit'];
         $params = array($options['list_id']);
     } else {
         $sql = "SELECT i.id, i.filename FROM image i " . "WHERE is_deleted = 0 AND has_square = 0 " . "ORDER BY id DESC LIMIT " . $options['limit'];
         $params = array();
     }
     $stmt = $this->db->execute($sql, $params);
     $images = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $count = count($images);
     foreach ($images as $image) {
         $this->printDebug("Processing image {$image['id']} belonging to entity {$image['entity_id']}...");
         if ($this->downloadLarge($image['filename'])) {
             $this->printDebug("Downloaded large image from S3: " . $s3Path);
         } else {
             $s3Path = ImageTable::generateS3Url(ImageTable::getPath($image['filename'], 'large'));
             $this->printDebug("Couldn't download large image from S3: " . $s3Path);
             if ($image['url']) {
                 if ($this->downloadToTmp($image['url'], $image['filename'])) {
                     $this->printDebug("Downloaded original image: " . $image['url']);
                 } else {
                     $this->printDebug("Couldn't download original image: " . $image['url']);
                     if ($this->downloadFromGoogle($image['name'])) {
                         $this->printDebug("Downloaded new image of {$image['name']} from google");
                     } else {
                         $count--;
                         continue;
                     }
                 }
             } else {
                 $count--;
                 continue;
             }
         }
         if (!$this->createSquare($image['filename'], $options['size'])) {
             $this->printDebug("Coudln't create square image: {$image['filename']}");
             $count--;
             continue;
         }
         if ($this->uploadFile($image['filename'], $options['check_first'], $options['debug_mode'])) {
             $this->recordSquare($image['id']);
         }
         $count--;
         print $count . " images remaining...\n";
     }
     //DONE
     LsCli::beep();
 }
Exemplo n.º 24
0
 /**
  * Executes the current task.
  *
  * @param array $arguments An array of arguments
  * @param array $options An array of options
  *
  * @return integer 0 if everything went fine, or an error code
  */
 protected function execute($arguments = array(), $options = array())
 {
     // Initialisation de la base de données.
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
     sfContext::createInstance($configuration);
     $conn = Doctrine_Manager::connection();
     $sql1 = "UPDATE ei_test_set_state SET state_code = 'ABORTED' WHERE name = 'Aborted';";
     $sql2 = "UPDATE ei_campaign_execution SET termine = 1;";
     $sql3 = "UPDATE ei_test_set SET termine = 1;";
     $sql4 = "\n        INSERT INTO ei_test_set_state (name, color_code, state_code, project_id, project_ref, created_at, updated_at)\n\nSELECT 'Processing', '#FFD300', 'NA', project_id, project_ref, NOW(), NOW()\n\nFROM ei_test_set_state\n\nWHERE (project_id, project_ref) NOT IN\n(\nSELECT project_id, project_ref\nFROM ei_test_set_state\nWHERE name = 'Processing'\nGROUP BY project_id, project_ref\n)\n\n\nGROUP BY project_id, project_ref\n        ";
     $sql5 = "UPDATE ei_campaign_execution_graph exg, ei_test_set_status_vw ts\nSET state = (CASE WHEN ts.status_nom = 'Success' THEN 'Ok' WHEN ts.status_nom = 'Failed' THEN 'Ko' WHEN 'Aborted' THEN 'Aborted' ELSE 'Blank' END)\nWHERE exg.ei_test_set_id = ts.id\n;";
     $sql6 = "UPDATE ei_test_set ts LEFT JOIN (\nSELECT\n\tCASE\n\t\tWHEN SUM(CASE WHEN func.status ='ko' THEN 1 else 0 end ) > 0 THEN 'KO'\n\t\tWHEN SUM(CASE WHEN func.status ='NA' THEN 1 else 0 end ) > 0 THEN 'AB'\n\t\tWHEN SUM(CASE WHEN (func.status ='processing' OR func.status = 'blank') THEN 1 else 0 end ) > 0 THEN 'AB'\n\t\tELSE 'OK'\n\tEND as statut, ts.id\nFROM ei_test_set_function func, ei_test_set ts\nWHERE ts.id = ei_test_set_id\nGROUP BY ei_test_set_id\n) tsf ON tsf.id = ts.id\nSET ts.status = (CASE WHEN tsf.statut IS NULL THEN 'AB' ELSE tsf.statut END)\n;\n        ";
     $sql7 = "update kal_function set criticity='Blank' where criticity is NULL";
     try {
         $this->log("[INFO] Mise à jour du statut ABORTED.");
         $conn->execute($sql1);
         $this->log("[INFO] Passage de toutes les exécutions de campagne à l'état <terminé>.");
         $conn->execute($sql2);
         $this->log("[INFO] Passage de tous les jeux de test à l'état <terminé>.");
         $conn->execute($sql3);
         $this->log("[INFO] Ajout du statut <Processing> dans tous les projets ne le comportant pas.");
         $conn->execute($sql4);
         $this->log("[INFO] Mise à jour des statuts de campagne par rapport aux statuts des jeux de test.");
         $conn->execute($sql5);
         $this->log("[INFO] Mise à jour des statuts du jeu de tests.");
         $conn->execute($sql6);
         $this->log("Mise à jour des criticité de fonction à null. Remplacement par des criticités 'Blank'.");
         $conn->execute($sql7);
         /* Mise à jour des positions des éléments de l'arbre des scénarios */
         $this->log("Mise à jour des positions des éléments de l'arbre des scénarios.");
         /* trouver tous les root_id c'est-à-dire la liste des noeuds parents */
         $stmt = $conn->prepare("SELECT DISTINCT root_id FROM ei_node WHERE (type LIKE 'EiScenario' OR type LIKE 'EiFolder') AND root_id IS NOT NULL");
         $stmt->execute(array());
         $result = $stmt->fetchAll();
         foreach ($result as $root_id) {
             /* Pour chaque noeud parent, on trouve les id des fils */
             $parent_id = $root_id['root_id'];
             $stmt2 = $conn->prepare("SELECT id FROM ei_node WHERE root_id = :root_id ORDER BY position");
             $stmt2->bindValue("root_id", $parent_id);
             $stmt2->execute(array());
             $result2 = $stmt2->fetchAll();
             $position = 0;
             foreach ($result2 as $child_id) {
                 /* update de la position du fils */
                 $id = $child_id['id'];
                 $position++;
                 $stmt3 = $conn->prepare('UPDATE ei_node SET position = :position where id = :id');
                 $stmt3->bindValue("position", $position);
                 $stmt3->bindValue("id", $id);
                 $stmt3->execute(array());
             }
         }
         $this->transformDataSetTreeFromRecursiveToNested($conn);
     } catch (Exception $e) {
         $this->log("[ERROR] " . $e->getMessage());
     }
     /* Changement des statuts de livraison de "Close" à "Closed" */
     $conn->execute("update ei_delivery_state set name ='Closed' where name like '%Close%' ");
 }
 /**
  * Returns current sfApplicationConfiguration instance.
  * If no configuration does currently exist, a new one will be created.
  *
  * @return sfApplicationConfiguration
  */
 protected function getApplicationConfiguration()
 {
     $key = $this->getApplication() . '_' . $this->getEnvironment() . '_' . intval($this->isDebug());
     if (!isset($this->applicationConfigurations[$key])) {
         $this->applicationConfigurations[$key] = ProjectConfiguration::getApplicationConfiguration($this->getApplication(), $this->getEnvironment(), $this->isDebug());
     }
     return $this->applicationConfigurations[$key];
 }
 public function setUp()
 {
     // generate this form
     $generatorManager = new sfGeneratorManager(ProjectConfiguration::getApplicationConfiguration('backend', 'dev', true));
     $generatorManager->generate('sfDoctrineFormGenerator', array('connection' => 'doctrine', 'model_dir_name' => 'model', 'form_dir_name' => 'form'));
     $generator = new CommentFormGenerator($generatorManager);
     $generator->generate(array('connection' => 'doctrine'));
 }
 public function callRegisteredShutdown()
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration('orangehrm', 'prod', true);
     sfContext::createInstance($configuration);
     $this->logger->info('Connection Terminated By Client.');
     $this->releaseLock();
     exit;
 }
Exemplo n.º 28
0
 protected function boot()
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($this->options['app'], $this->options['env'], $this->options['debug']);
     $this->context = dm::createContext($configuration);
     sfConfig::set('sf_logging_enabled', false);
     // remove all cache
     sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
 }
Exemplo n.º 29
0
 protected function setUp()
 {
     parent::setUp();
     $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
     $this->context = sfContext::createInstance($configuration);
     $this->request = mock('sfWebRequest');
     $this->context->set('request', $this->request);
 }
 protected function createContextInstance($application = 'backend', $enviroment = 'dev', $debug = true)
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($application, $enviroment, $debug);
     sfContext::createInstance($configuration);
     sfContext::switchTo($application);
     $this->context = sfContext::getInstance();
     //include(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/nc_flavor.yml'));
 }