public function run()
 {
     $path = $this->options['dir'] . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . $this->options['name'] . '.sql';
     if (!file_exists($path)) {
         throw new RuntimeException('The specified sql doesn\'t exist.');
     }
     $db = $this->getDatabaseManager()->getDatabase('doctrine');
     $this->conn = $db->getDoctrineConnection();
     $this->conn->beginTransaction();
     $this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
     // for mysql
     $sql = opToolkit::unifyEOLCharacter($this->parseSql($path));
     $queries = explode("\n", $sql);
     try {
         $this->executeQueries($queries);
         $this->conn->commit();
     } catch (Exception $e) {
         $this->conn->rollback();
         $this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
         // for mysql
         throw $e;
     }
     $this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
     // for mysql
 }
 public function sendMail()
 {
     $token = md5(opToolkit::generatePasswordString());
     $this->member->setConfig('password_recovery_token', $token);
     $params = array('token' => $token, 'id' => $this->member->id, 'subject' => '【' . opConfig::get('sns_name') . '】パスワード再設定用URL発行のお知らせ');
     sfOpenPNEMailSend::sendTemplateMail('passwordRecovery', $this->member->getEMailAddress(), opConfig::get('admin_mail_address'), $params);
 }
 public function save()
 {
     parent::save();
     $emailAddress = $this->member->getEmailAddress();
     $params = array('mailAddress' => $emailAddress, 'newPassword' => $this->plainPassword, 'isMobile' => opToolkit::isMobileEmailAddress($emailAddress));
     $this->sendConfirmMail($emailAddress, $params);
 }
 private function sendDailyNews($app)
 {
     $isAppMobile = 'mobile_frontend' === $app;
     $dailyNewsName = $isAppMobile ? 'mobileDailyNews' : 'dailyNews';
     $context = sfContext::createInstance($this->createConfiguration($app, 'prod'), $app);
     $gadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName($dailyNewsName);
     $gadgets = $gadgets[$dailyNewsName . 'Contents'];
     $targetMembers = Doctrine::getTable('Member')->findAll();
     foreach ($targetMembers as $member) {
         $address = $member->getEmailAddress();
         if ($isAppMobile !== opToolkit::isMobileEmailAddress($address)) {
             continue;
         }
         $dailyNewsConfig = $member->getConfig('daily_news');
         if (null !== $dailyNewsConfig && 0 === (int) $dailyNewsConfig) {
             continue;
         }
         if (1 === (int) $dailyNewsConfig && !$this->isDailyNewsDay()) {
             continue;
         }
         $filteredGadgets = array();
         if ($gadgets) {
             foreach ($gadgets as $gadget) {
                 if ($gadget->isEnabled($member)) {
                     $filteredGadgets[] = array('component' => array('module' => $gadget->getComponentModule(), 'action' => $gadget->getComponentAction()), 'gadget' => $gadget, 'member' => $member);
                 }
             }
         }
         $params = array('member' => $member, 'gadgets' => $filteredGadgets, 'subject' => $context->getI18N()->__('デイリーニュース'), 'today' => time());
         opMailSend::sendTemplateMail('dailyNews', $address, opConfig::get('admin_mail_address'), $params, $context);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     parent::execute($arguments, $options);
     sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'), 'pc_frontend');
     $pcGadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName('dailyNews');
     $mobileGadgets = Doctrine::getTable('Gadget')->retrieveGadgetsByTypesName('mobileDailyNews');
     $targetMembers = Doctrine::getTable('Member')->findAll();
     foreach ($targetMembers as $member) {
         if (!$member->getConfig('daily_news')) {
             continue;
         }
         if (1 == $member->getConfig('daily_news') && !$this->isDailyNewsDay()) {
             continue;
         }
         $address = $member->getEmailAddress();
         $gadgets = $pcGadgets['dailyNewsContents'];
         if (opToolkit::isMobileEmailAddress($address)) {
             $gadgets = $mobileGadgets['mobileDailyNewsContents'];
         }
         $filteredGadgets = array();
         if ($gadgets) {
             foreach ($gadgets as $gadget) {
                 if ($gadget->isEnabled()) {
                     $filteredGadgets[] = array('component' => array('module' => $gadget->getComponentModule(), 'action' => $gadget->getComponentAction()), 'gadget' => $gadget, 'member' => $member);
                 }
             }
         }
         $context = $this->getContextByEmailAddress($address);
         $params = array('member' => $member, 'gadgets' => $filteredGadgets, 'subject' => $context->getI18N()->__('デイリーニュース'), 'today' => time());
         opMailSend::sendTemplateMail('dailyNews', $address, opConfig::get('admin_mail_address'), $params, $context);
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     if (!isset($options['origin'])) {
         $options['origin'] = '2.12';
     }
     if (!in_array($options['origin'], array('2.12', '2.14', '3.4'))) {
         throw new RuntimeException('You must specify "2.12", "2.14" or "3.4" to the --origin option. (--origin オプションには 2.12、 2.14 または 3.4 を指定してください。)');
     }
     sfConfig::set('op_upgrade2_version', $options['origin']);
     $op2config = sfConfig::get('sf_config_dir') . DIRECTORY_SEPARATOR . 'config.OpenPNE2.php';
     if (!is_readable($op2config)) {
         throw new RuntimeException('You must copy the config.php in your OpenPNE2 as config/config.OpenPNE2.php. (お使いの OpenPNE2 の config.php を config/config.OpenPNE2.php としてコピーしてください。)');
     }
     if (!defined('OPENPNE_DIR')) {
         define('OPENPNE_DIR', sfConfig::get('sf_root_dir'));
     }
     require_once $op2config;
     $this->runTask('configure:database', array(opToolkit::createStringDsnFromArray($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']), $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['username'], empty($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['password']) ? null : $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['password']));
     $path = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR . '2';
     $upgrader = new opUpgrader($this->dispatcher, $this->formatter, $path, $this->configuration);
     if ($options['rules']) {
         $upgrader->setOption('targets', $options['rules']);
     }
     if ('3.4' === $options['origin']) {
         $upgrader->setDefinitionName('definition-34to36.yml');
     }
     $this->logSection('upgrade', 'Begin upgrading from 2.x');
     $upgrader->execute();
     $task = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter);
     $task->run(array(), array());
 }
 /**
  * @see sfValidatorRegex
  */
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $filter = create_function('$value', 'return preg_quote($value, \'/\');');
     $str = join('|', array_filter(opToolkit::getMobileMailAddressDomains(), $filter));
     $this->setOption('pattern', '/^([^@\\s]+)@(' . $str . ')$/i');
 }
 public function save()
 {
     foreach ($this->getValues() as $k => $v) {
         opSkinClassicConfig::set($k, $v);
     }
     opToolkit::clearCache();
 }
Пример #9
0
 public static function sendTemplateMail($template, $to, $from, $params = array(), $context = null)
 {
     if (!$to) {
         return false;
     }
     if (empty($params['target'])) {
         $target = opToolkit::isMobileEmailAddress($to) ? 'mobile' : 'pc';
     } else {
         $target = $params['target'];
     }
     if (in_array($target . '_' . $template, Doctrine::getTable('NotificationMail')->getDisabledNotificationNames())) {
         return false;
     }
     if (null === $context) {
         $context = sfContext::getInstance();
     }
     $body = self::getMailTemplate($template, $target, $params, false, $context);
     $signature = self::getMailTemplate('signature', $target, array(), true, $context);
     if ($signature) {
         $signature = "\n" . $signature;
     }
     $subject = $params['subject'];
     $notificationMail = Doctrine::getTable('NotificationMail')->fetchTemplate($target . '_' . $template);
     if ($notificationMail instanceof NotificationMail && $notificationMail->getTitle()) {
         $subject = $notificationMail->getTitle();
         $templateStorage = new sfTemplateStorageString($subject);
         $renderer = new opTemplateRendererTwig();
         $params['sf_type'] = null;
         $parameterHolder = new sfViewParameterHolder($context->getEventDispatcher(), $params);
         $subject = $renderer->evaluate($templateStorage, $parameterHolder->toArray());
         $notificationMail->free(true);
     }
     return self::execute($subject, $to, $from, $body . $signature);
 }
Пример #10
0
 /**
  * @see sfValidatorString
  */
 protected function doClean($value)
 {
     $clean = parent::doClean($value);
     if (opToolkit::isMobileEmailAddress($clean)) {
         throw new sfValidatorError($this, 'invalid', array('value' => $value));
     }
     return $clean;
 }
Пример #11
0
 public function getPresetConfig()
 {
     $list = opToolkit::getPresetProfileList();
     if (!empty($list[$this->getRawPresetName()])) {
         return $list[$this->getRawPresetName()];
     }
     return array();
 }
Пример #12
0
 public function executeRequestRegisterURL($request)
 {
     $adapter = new opAuthAdapterMailAddress('MailAddress');
     if ($adapter->getAuthConfig('invite_mode') < 2) {
         $this->forward404();
     }
     $this->forward404Unless(opToolkit::isEnabledRegistration());
     return sfView::INPUT;
 }
Пример #13
0
 protected function getRandom($length)
 {
     if (is_callable(array('opToolkit', 'getRandom'))) {
         // for OpenPNE3.6 <=
         return opToolkit::getRandom($length);
     }
     mt_srand();
     return substr(md5(mt_rand()), 0, $length);
 }
Пример #14
0
 public function &getAll($isStripNullbyte = true)
 {
     if ($isStripNullbyte) {
         $value = opToolkit::stripNullByteDeep(parent::getAll());
     } else {
         $value =& parent::getAll();
     }
     return $value;
 }
Пример #15
0
 protected function getPackageInfo()
 {
     $xmlPath = sfConfig::get('sf_plugins_dir') . '/' . $this->getName() . '/package.xml';
     if (!is_readable($xmlPath)) {
         return false;
     }
     $content = file_get_contents($xmlPath);
     return opToolkit::loadXmlString($content, array('return' => 'SimpleXMLElement'));
 }
Пример #16
0
 public function executeCache(sfWebRequest $request)
 {
     $this->form = new sfForm();
     if ($request->isMethod(sfWebRequest::POST)) {
         $request->checkCSRFProtection();
         opToolkit::clearCache();
         $this->getUser()->setFlash('notice', 'Caches are now cleared.');
         $this->redirect('sns/cache');
     }
 }
Пример #17
0
 public function generateMobileUidCookie()
 {
     $request = sfContext::getInstance()->getRequest();
     if (!$request->isMobile() || !$request->isCookie()) {
         return false;
     }
     $value = opToolkit::getRandom();
     $this->setCookie(opWebRequest::MOBILE_UID_COOKIE_NAME, $value, strtotime('+20years'));
     return $value;
 }
 public function getAPICaptions()
 {
     $apiList = array();
     foreach (opToolkit::retrieveAPIList() as $key => $value) {
         if (in_array($key, $this->getUsingApis())) {
             $apiList[] = $value;
         }
     }
     return $apiList;
 }
 public function configure()
 {
     unset($this['created_at'], $this['updated_at'], $this['file_id'], $this['key_string'], $this['secret'], $this['member_id']);
     $this->setWidget('image', new sfWidgetFormInputFile());
     $this->setValidator('image', new opValidatorImageFile(array('required' => false)));
     $apis = opToolkit::retrieveAPIList();
     $this->setWidget('using_apis', new sfWidgetFormSelectMany(array('choices' => $apis), array('size' => 10)));
     $this->setValidator('using_apis', new sfValidatorChoice(array('multiple' => true, 'choices' => array_keys($apis))));
     $this->getWidgetSchema()->setHelp('using_apis', 'Select apis that your application needs.');
     $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('api');
 }
 protected function appendMobileInputMode()
 {
     parent::appendMobileInputMode();
     foreach ($this as $k => $v) {
         $widget = $this->widgetSchema[$k];
         $validator = $this->validatorSchema[$k];
         if ($widget instanceof opWidgetFormInputIncreased) {
             opToolkit::appendMobileInputModeAttributesForFormWidget($widget, 'numeric');
         }
     }
 }
Пример #21
0
 public function save()
 {
     if (!$this->isValid()) {
         return false;
     }
     $plugins = $this->getOption('plugins');
     foreach ($this->values as $key => $value) {
         $plugins[$key]->setIsActive($value);
     }
     opToolkit::clearCache();
     return true;
 }
 public function save($con = null)
 {
     $values = $this->getValues();
     $presetList = opToolkit::getPresetProfileList();
     $presetName = $values['preset'];
     $preset = $presetList[$presetName];
     $values = $this->mergePresetAndValues($preset, $values);
     $values['name'] = 'op_preset_' . $values['name'];
     unset($values['preset'], $values['choices'], $values['caption']);
     $this->values = $values;
     parent::save($con);
 }
Пример #23
0
 public function validate($validator, $value, $arguments = array())
 {
     $value = opToolkit::unifyEOLCharacter($value);
     $list = array_map('trim', explode("\n", $value));
     $list = array_unique($list);
     foreach ($list as $item) {
         if (!preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/', $item)) {
             throw new sfValidatorError($validator, 'invalid');
         }
     }
     return implode("\n", $list);
 }
Пример #24
0
 protected function getContextByEmailAddress($address)
 {
     $application = 'pc_frontend';
     if (opToolkit::isMobileEmailAddress($address)) {
         $application = 'mobile_frontend';
     }
     if (!sfContext::hasInstance($application)) {
         $context = sfContext::createInstance($this->createConfiguration($application, 'prod'), $application);
     } else {
         $context = sfContext::getInstance($application);
     }
     return $context;
 }
 public function configure()
 {
     $this->user = sfContext::getInstance()->getUser();
     $languages = sfConfig::get('op_supported_languages');
     $opt_languages = $this->getOption('languages', array());
     $languages = array_unique(array_merge($languages, $opt_languages));
     $choices = opToolkit::getCultureChoices($languages);
     $this->setDefaults(array('culture' => $this->user->getCulture()));
     $this->setWidgets(array('culture' => new sfWidgetFormChoice(array('choices' => $choices)), 'next_uri' => new opWidgetFormInputHiddenNextUri()));
     $this->setValidators(array('culture' => new sfValidatorChoice(array('choices' => array_keys($choices))), 'next_uri' => new opValidatorNextUri()));
     $this->widgetSchema->setLabels(array('culture' => 'Languages'));
     $this->widgetSchema->setNameFormat('language[%s]');
 }
Пример #26
0
 public function executeLocalNav()
 {
     if (!opToolkit::isSecurePage()) {
         return sfView::NONE;
     }
     $context = sfContext::getInstance();
     $module = $context->getActionStack()->getLastEntry()->getModuleName();
     $action = $context->getActionStack()->getLastEntry()->getActionName();
     $this->type = sfConfig::get('sf_nav_type', sfConfig::get('mod_' . $module . '_default_nav', 'default'));
     $this->navs = Doctrine::getTable('Navigation')->retrieveByType($this->type);
     if ('default' !== $this->type) {
         $this->navId = sfConfig::get('sf_nav_id', $context->getRequest()->getParameter('id'));
     }
 }
Пример #27
0
 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     $filterChain->execute();
     $response = $this->getContext()->getResponse();
     $request = $this->getContext()->getRequest();
     $content = $response->getContent();
     if (!$request->isMobile()) {
         list($list, $content) = opToolkit::replacePatternsToMarker($content);
     }
     $content = OpenPNE_KtaiEmoji::convertEmoji($content);
     if (!$request->isMobile()) {
         $content = str_replace(array_keys($list), array_values($list), $content);
     }
     $response->setContent($content);
 }
 public function save()
 {
     $target = $this->getOption('target');
     $rawConfig = Doctrine::getTable('SkinConfig')->retrieveByPluginAndName('opSkinClassicPlugin', $target . '_image');
     if ($rawConfig) {
         $file = Doctrine::getTable('File')->findOneByName($rawConfig->value);
         if ($file) {
             $file->delete();
         }
     }
     $file = new File();
     $file->setFromValidatedFile($this->getValue('image'));
     $file->save();
     opSkinClassicConfig::set($target . '_image', $file->name);
     opToolkit::clearCache();
 }
Пример #29
0
 public function executeDownload(sfWebRequest $request)
 {
     $this->form = new opCsvExportForm();
     if ($request->isMethod(sfRequest::POST)) {
         $this->form->bind($request->getParameter('opCsvExport'));
         if (!$this->form->isValid()) {
             return sfView::SUCCESS;
         }
         $memberCsvList = new opMemberCsvList($this->form->getValue('from'), $this->form->getValue('to'));
         $csvStr = opMemberCsvList::getHeader() . "\n";
         foreach ($memberCsvList as $memberCsv) {
             $csvStr .= $memberCsv . "\n";
         }
         opToolkit::fileDownload('member.csv', $csvStr);
         return sfView::NONE;
     }
 }
Пример #30
0
 public function executeRequestRegisterURL($request)
 {
     $adapter = new opAuthAdapterMailAddress('MailAddress');
     if ($adapter->getAuthConfig('invite_mode') < 2) {
         $this->forward404();
     }
     $this->forward404Unless(opToolkit::isEnabledRegistration());
     $this->form = new opRequestRegisterURLForm(null, array('authMode' => 'MailAddress'));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('request_register_url'));
         if ($this->form->isValid()) {
             $this->form->sendMail();
             return sfView::SUCCESS;
         }
     }
     return sfView::INPUT;
 }