protected function execute($arguments = array(), $options = array())
 {
     $this->openDatabaseConnection();
     // opMailSend requires Zend
     opApplicationConfiguration::registerZend();
     opDoctrineRecord::setDefaultCulture(sfConfig::get('default_culture', 'ja_JP'));
 }
 public function run()
 {
     opApplicationConfiguration::unregisterZend();
     $task = new sfDoctrineBuildModelTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => 'pc_frontend', 'env' => sfConfig::get('sf_environment', 'prod')));
     $task = new sfCacheClearTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => null, 'env' => sfConfig::get('sf_environment', 'prod')));
     opApplicationConfiguration::registerZend();
 }
 public function initialize()
 {
     parent::initialize();
     if (!opMobileUserAgent::getInstance()->isCookie()) {
         ini_set('session.use_only_cookies', 0);
         ini_set('session.use_cookies', 0);
         ini_set('session.use_trans_sid', 1);
     }
     sfWidgetFormSchema::setDefaultFormFormatterName('mobile');
 }
Exemplo n.º 4
0
 public function executeTrust(sfWebRequest $request)
 {
     opApplicationConfiguration::registerJanRainOpenID();
     require_once 'Auth/OpenID/Server.php';
     require_once 'Auth/OpenID/FileStore.php';
     require_once 'Auth/OpenID/SReg.php';
     require_once 'Auth/OpenID/AX.php';
     $info = unserialize($_SESSION['request']);
     $this->forward404Unless($info);
     $trusted = $request->hasParameter('trust') || $request->hasParameter('permanent');
     if (!$trusted) {
         unset($_SESSION['request']);
         $url = $info->getCancelURL();
         $this->redirect($url);
     }
     $reqUrl = $this->getController()->genUrl('OpenID/member?id=' . $this->getUser()->getMemberId(), true);
     if (!$info->idSelect()) {
         $this->forward404Unless($reqUrl === $info->identity, 'request:' . $reqUrl . '/identity:' . $info->identity);
     }
     unset($_SESSION['request']);
     $server = new Auth_OpenID_Server(new Auth_OpenID_FileStore(sfConfig::get('sf_cache_dir')), $info->identity);
     $response = $info->answer(true, null, $reqUrl);
     $sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($info);
     $axRequest = Auth_OpenID_AX_FetchRequest::fromOpenIDRequest($info);
     $allowedProfiles = $request->getParameter('profiles', array());
     $requiredProfiles = $this->createListOfRequestedProfiles($sregRequest, $axRequest);
     $rejectedProfiles = array_diff_key($requiredProfiles, array_flip($allowedProfiles));
     if (in_array(true, $rejectedProfiles)) {
         $url = $info->getCancelURL();
         $this->redirect($url);
     }
     if ($sregRequest) {
         $sregExchange = new opOpenIDProfileExchange('sreg', $this->getUser()->getMember());
         $sregResp = Auth_OpenID_SRegResponse::extractResponse($sregRequest, $sregExchange->getData($allowedProfiles));
         $response->addExtension($sregResp);
     }
     if ($axRequest && !$axRequest instanceof Auth_OpenID_AX_Error) {
         $axResp = new Auth_OpenID_AX_FetchResponse();
         $axExchange = new opOpenIDProfileExchange('ax', $this->getUser()->getMember());
         $userData = $axExchange->getData($allowedProfiles);
         foreach ($axRequest->requested_attributes as $k => $v) {
             if (!empty($userData[$k])) {
                 $axResp->addValue($k, $userData[$k]);
             }
         }
         $response->addExtension($axResp);
     }
     $log = Doctrine::getTable('OpenIDTrustLog')->log($info->trust_root, $this->getUser()->getMemberId());
     if ($request->hasParameter('permanent')) {
         $log->is_permanent = true;
         $log->save();
     }
     $response = $server->encodeResponse($response);
     return $this->writeResponse($response);
 }
 public function analyze($text)
 {
     $result = parent::analyze($text);
     opApplicationConfiguration::registerZend();
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
     $analyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
     $analyzer->setInput($text, 'UTF-8');
     while (($nextToken = $analyzer->nextToken()) !== null) {
         $result[] = $nextToken->getTermText();
     }
     return $result;
 }
 public function run()
 {
     $this->getDatabaseManager();
     // build all tables for models
     if (!$this->getOption('models')) {
         opApplicationConfiguration::unregisterZend();
         $path = sfConfig::get('sf_lib_dir') . '/model/doctrine';
         Doctrine_Core::loadModels($path, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
         Doctrine_Core::createTablesFromArray(Doctrine_Core::getLoadedModels());
         opApplicationConfiguration::registerZend();
         return true;
     }
     foreach ($this->getQueries() as $query) {
         $db = $this->getDatabaseManager()->getDatabase('doctrine');
         $db->getDoctrineConnection()->execute($query);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     parent::execute($arguments, $options);
     opApplicationConfiguration::unregisterZend();
     $birthday = Doctrine::getTable('Profile')->retrieveByName('op_preset_birthday');
     if (!$birthday) {
         throw new sfException('This project doesn\'t have the op_preset_birthday profile item.');
     }
     $profiles = Doctrine::getTable('MemberProfile')->createQuery()->where('profile_id = ?', $birthday->id)->andWhere('DATE_FORMAT(value_datetime, ?) = ?', array('%m-%d', date('m-d', strtotime('+ 1 week'))))->execute();
     opApplicationConfiguration::registerZend();
     $context = sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'));
     $i18n = $context->getI18N();
     foreach ($profiles as $profile) {
         $birthMember = $profile->getMember();
         foreach ($birthMember->getFriends() as $member) {
             $params = array('member' => $member, 'birthMember' => $birthMember, 'subject' => $i18n->__('There is your %my_friend% that its birthday is coming soon'));
             opMailSend::sendTemplateMailToMember('birthday', $member, $params, array(), $context);
         }
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     sfConfig::set('sf_test', true);
     opApplicationConfiguration::registerZend();
     $stdin = file_get_contents('php://stdin');
     $message = new opMailMessage(array('raw' => $stdin));
     opMailRequest::setMailMessage($message);
     opApplicationConfiguration::unregisterZend();
     $configuration = ProjectConfiguration::getApplicationConfiguration('mobile_mail_frontend', 'prod', false);
     $context = sfContext::createInstance($configuration);
     $request = $context->getRequest();
     ob_start();
     $context->getController()->dispatch();
     $retval = ob_get_clean();
     if ($retval) {
         $subject = $context->getResponse()->getTitle();
         $to = $message->from;
         $from = $message->to;
         opMailSend::execute($subject, $to, $from, $retval);
     }
 }
 public static function unregisterZend()
 {
     if (!self::$zendLoaded) {
         return true;
     }
     require_once 'Zend/Loader.php';
     Zend_Loader::registerAutoLoad('Zend_Loader', false);
     self::$zendLoaded = false;
 }
Exemplo n.º 10
0
 public static function execute($subject, $to, $from, $body)
 {
     if (!$to) {
         return false;
     }
     self::initialize();
     opApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     if ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) {
         $mailer->setReturnPath($envelopeFrom);
     }
     $result = $mailer->send();
     Zend_Loader::registerAutoLoad('Zend_Loader', false);
     return $result;
 }
  protected function execute($arguments = array(), $options = array())
  {
    $databaseManager = new sfDatabaseManager($this->configuration);
    $this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection();

    $sql = 'SELECT id FROM member WHERE is_active != 0';
    $where = array();
    if ( $options['min'] && $options['max']  && $options['min'] <= $options['max'])
    {
        $sql .= ' AND id BETWEEN ? AND ?';
        $where = array(intval($options['min']),intval($options['max']));
    }
    $memberIds = $this->conn->fetchColumn($sql, $where);

    // configを増やす
    if ($options['config'])
    {
      $configs = explode(',',$options['config']);
      foreach ($memberIds as $memberid)
      {
        $member = Doctrine::getTable('Member')->find($memberid);
        foreach ($configs as $config)
        {
          $member->setConfig($config, 'dummy');
          $this->logSection('member_config', sprintf("%s - %s", $config, $memberid));
        }
        $member->free();
      }
    }

    // profileを増やす
    if ($options['profile'])
    {
      $profiles = explode(',',$options['profile']);
      $preProfiles = Doctrine::getTable('Profile')->createQuery()
        ->select('id')
        ->execute(array(), Doctrine::HYDRATE_NONE);
      foreach ($preProfiles as $key => $value)
      {
        $profileid = $value[0];
        if (in_array($profileid, $profiles))
        {
          foreach ($memberIds as $memberid)
          {
            $sql = 'SELECT id FROM member_profile WHERE member_id = ? AND profile_id = ?';
            $where = array(intval($memberid), intval($profileid));
            $mp = $this->conn->fetchOne($sql, $where);
print "$mp";
            if (!$mp)
            {
              opApplicationConfiguration::registerZend();
              $memberProfile = new MemberProfile();
              $memberProfile->setMemberId($memberid);
              $memberProfile->setProfileId($profileid);
              $memberProfile->setValue('dummy');
              $memberProfile->save();
              $memberProfile->free();
              $this->logSection('member_profile', sprintf("%s - %s", $memberid, $profileid));
            } 
          }
        }
      }
    }

  }
 public static function unregisterZend()
 {
     if (!self::$zendLoaded) {
         return true;
     }
     Zend_Loader_Autoloader::resetInstance();
     spl_autoload_unregister(array('Zend_Loader_Autoloader', 'autoload'));
     self::$zendLoaded = false;
 }
 public function initialize()
 {
     parent::initialize();
     sfWidgetFormSchema::setDefaultFormFormatterName('pc');
 }
 protected function dataLoad($path)
 {
     opApplicationConfiguration::unregisterZend();
     Doctrine::loadData($path, true);
     opApplicationConfiguration::registerZend();
 }
Exemplo n.º 15
0
 protected function execute($arguments = array(), $options = array())
 {
     $definitions = $this->getDefinition();
     $timer = new sfTimer();
     $succeeded = array();
     $targets = $this->getOption('targets', array_keys($definitions));
     foreach ((array) $definitions as $k => $v) {
         if (!in_array($k, $targets)) {
             continue;
         }
         $timer->startTimer();
         $defaultOptions = array_merge($this->options, array('name' => $k, 'dir' => $this->basePath, 'required_rules' => array(), 'configuration' => $this->configuration, 'dispatcher' => new sfEventDispatcher(), 'formatter' => $this->formatter));
         $v = array_merge(array('options' => $defaultOptions), $v);
         if (!isset($v['options']['required_rules'])) {
             $v['options']['required_rules'] = array();
         }
         $requiredRules = (array) $v['options']['required_rules'];
         if (!empty($requiredRules) && array_diff($requiredRules, $succeeded)) {
             $this->logSection('upgrade', 'Passed ' . $k, null, 'ERROR');
             continue;
         }
         $this->logSection('upgrade', 'Processing ' . $k);
         if (isset($v['file']) && is_file($v['file'])) {
             require_once $v['file'];
         }
         if (class_exists($v['strategy'])) {
             $className = $v['strategy'];
         } else {
             $className = 'opUpgrade' . $v['strategy'] . 'Strategy';
         }
         opApplicationConfiguration::registerZend();
         try {
             // disable Doctrine profiling
             sfConfig::set('sf_debug', false);
             $strategy = new $className($v['options']);
             $strategy->run();
             $succeeded[] = $k;
         } catch (Exception $e) {
             $this->logBlock($e->getMessage(), 'ERROR');
         }
         opApplicationConfiguration::unregisterZend();
         $this->logSection('upgrade', sprintf('Processed %s (%.2f sec)', $k, $timer->addTime()));
     }
     $this->logSection('upgrade', sprintf('Completed Upgrading (%.2f sec)', $timer->getElapsedTime()));
     $this->logSection('upgrade', sprintf('The %.2f MB memory allocated', round(memory_get_peak_usage(true) / 1048576, 2)));
 }
Exemplo n.º 16
0
 public static function execute($subject, $to, $from, $body)
 {
     if (!$to) {
         return false;
     }
     self::initialize();
     opApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     $result = $mailer->send();
     opApplicationConfiguration::unregisterZend();
     return $result;
 }
Exemplo n.º 17
0
 public static function execute($subject, $to, $from, $body)
 {
     if (!$to) {
         return false;
     }
     self::initialize();
     opApplicationConfiguration::registerZend();
     $subject = mb_convert_kana($subject, 'KV');
     $mailer = new Zend_Mail('iso-2022-jp');
     $mailer->setHeaderEncoding(Zend_Mime::ENCODING_BASE64)->setFrom($from)->addTo($to)->setSubject(mb_encode_mimeheader($subject, 'iso-2022-jp'))->setBodyText(mb_convert_encoding($body, 'JIS', 'UTF-8'), 'iso-2022-jp', Zend_Mime::ENCODING_7BIT);
     if ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) {
         $mailer->setReturnPath($envelopeFrom);
     }
     try {
         $result = $mailer->send();
     } catch (Zend_Mail_Protocol_Exception $e) {
         if (sfContext::getInstance()->getActionName() === null) {
             error_log('Mail Send Error');
         } else {
             $action = sfContext::getInstance()->getActionStack()->getFirstEntry()->getActionInstance();
             $action->redirect('default/mailError');
         }
     }
     Zend_Loader::registerAutoLoad('Zend_Loader', false);
     return $result;
 }