public function save() { $token = md5(uniqid(mt_rand(), true)); $this->member->setConfig('register_mobile_token', $token); $param = array('token' => $token, 'id' => $this->member->getId()); $mail = new opMailSend(); $mail->setSubject(opConfig::get('sns_name') . '携帯登録'); $mail->setTemplate('member/registerMobileMail', $param); $mail->send($this->getValue('mobile_address'), opConfig::get('admin_mail_address')); }
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); } }
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); } }
public static function initialize() { if (!self::$initialized) { opApplicationConfiguration::registerZend(); if ($host = sfConfig::get('op_mail_smtp_host')) { $tr = new Zend_Mail_Transport_Smtp($host, sfConfig::get('op_mail_smtp_config', array())); Zend_Mail::setDefaultTransport($tr); } elseif ($envelopeFrom = sfConfig::get('op_mail_envelope_from')) { $tr = new Zend_Mail_Transport_Sendmail('-f' . $envelopeFrom); Zend_Mail::setDefaultTransport($tr); } opApplicationConfiguration::unregisterZend(); self::$initialized = true; } }
public function executeRegisterEnd(sfWebRequest $request) { $this->forward404Unless($this->getUser()->setRegisterToken($request['token'])); $member = $this->getUser()->getMember(true); if (opConfig::get('retrieve_uid') == 3 && !sfConfig::get('app_is_mobile', false) && !$member->getConfig('mobile_uid')) { $this->forward('member', 'registerMobileToRegisterEnd'); } $this->getUser()->getAuthAdapter()->activate(); $this->getUser()->setIsSNSMember(true); if ($member->getEmailAddress()) { $i18n = sfContext::getInstance()->getI18N(); $params = array('subject' => $i18n->__('Notify of Your Registering'), 'url' => $this->getController()->genUrl(array('sf_route' => 'homepage'), true)); opMailSend::sendTemplateMailToMember('registerEnd', $member, $params); } $this->redirect('@homepage'); }
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 processFriendConfirm(sfEvent $event) { $toMember = Doctrine::getTable('Member')->find($event['id']); $relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($event['member']->id, $toMember->id); if (!$relation) { $relation = Doctrine::getTable('MemberRelationship')->create(array('member_id_from' => $event['member']->id, 'member_id_to' => $toMember->id)); } if (!$relation->isFriendPreTo()) { return false; } if ($event['is_accepted']) { $relation->setFriend(); $event->setReturnValue('You have just accepted %friend% link request.'); $params = array('subject' => sfContext::getInstance()->getI18N()->__('%1% accepted your %friend% link request', array('%1%' => $event['member']->getName())), 'member' => $event['member']); opMailSend::sendTemplateMail('friendLinkComplete', $toMember->getEmailAddress(), opConfig::get('admin_mail_address'), $params); } else { $event->setReturnValue('You have just rejected %friend% link request.'); $relation->removeFriendPre(); } return true; }
public static function sendNotificationMail(Community $community, $id, $type, $nickname, $subject, $body) { if (version_compare(OPENPNE_VERSION, '3.6beta1-dev', '<')) { return null; } sfContext::getInstance()->getConfiguration()->loadHelpers(array('opUtil')); $params = array('community_name' => $community->getName(), 'wiki_name' => $subject, 'nickname' => $nickname, 'body' => $body); $rs = Doctrine::getTable('CommunityMember')->createQuery()->where('community_id = ?', array($community->getId()))->andWhere('is_receive_mail_pc = ? OR is_receive_mail_mobile = ?', array(true, true))->execute(array(), Doctrine::HYDRATE_ON_DEMAND); foreach ($rs as $r) { $member = $r->getMember(); $memberPcAddress = $member->getConfig('pc_address'); $memberMobileAddress = $member->getConfig('mobile_address'); $from = self::getPostMailAddress('mail_community_' . $type . '_comment_create', array('id' => $id, 'hash' => $member->getMailAddressHash())); if ($r->getIsReceiveMailPc() && $memberPcAddress) { $params['url'] = app_url_for('pc_frontend', '@community' . ucfirst($type) . '_show?id=' . $id, true); opMailSend::sendTemplateMail('notifyCommunityPosting', $memberPcAddress, $from, $params); } if ($r->getIsReceiveMailMobile() && $memberMobileAddress) { $params['url'] = app_url_for('mobile_frontend', '@community' . ucfirst($type) . '_show?id=' . $id, true); opMailSend::sendTemplateMail('notifyCommunityPosting', $memberMobileAddress, $from, $params); } } }
public static function sendTemplateMailToMember($template, Member $member, $params = array(), $options = array(), $context = null) { $mailConfigs = Doctrine::getTable('NotificationMail')->getConfigs(); $options = array_merge(array('from' => opConfig::get('admin_mail_address'), 'is_send_pc' => true, 'is_send_mobile' => true, 'pc_params' => array(), 'mobile_params' => array()), $options); // to pc if ($options['is_send_pc'] && ($address = $member->getConfig('pc_address')) && (!isset($mailConfigs['pc'][$template]['member_configurable']) || !$mailConfigs['pc'][$template]['member_configurable'] || $member->getConfig('is_send_pc_' . $template . '_mail', true))) { opMailSend::sendTemplateMail($template, $address, $options['from'], array_merge($params, $options['pc_params']), $context); } // to mobile if ($options['is_send_mobile'] && ($address = $member->getConfig('mobile_address')) && (!isset($mailConfigs['mobile'][$template]['member_configurable']) || !$mailConfigs['mobile'][$template]['member_configurable'] || $member->getConfig('is_send_mobile_' . $template . '_mail', true))) { opMailSend::sendTemplateMail($template, $address, $options['from'], array_merge($params, $options['mobile_params']), $context); } }
protected function sendConfirmMail($token, $to, $params = array()) { $params = array_merge(array('token' => $token, 'subject' => 'メールアドレス変更ページのお知らせ'), $params); opMailSend::sendTemplateMail('changeMailAddress', $to, opConfig::get('admin_mail_address'), $params); }
public function sendMail() { if ($this->doNotSend) { return null; } $address = ''; $member = $this->member; if (!$member) { $member = Doctrine::getTable('Member')->createPre(); } if ($this->getValue('pc_address')) { $address = $this->getValue('pc_address'); $member->setConfig('pc_address_pre', $address); } elseif ($this->getValue('mobile_address')) { $address = $this->getValue('mobile_address'); $member->setConfig('mobile_address_pre', $address); } $token = $member->generateRegisterToken(); $authMode = $this->getOption('authMode', null); if (!$authMode) { $authMode = sfContext::getInstance()->getUser()->getCurrentAuthMode(); } $member->setConfig('register_auth_mode', $authMode); $params = array( 'token' => $token, 'authMode' => 'MailAddress', 'isMobile' => opToolkit::isMobileEmailAddress($address), 'subject' => opConfig::get('sns_name').'招待状', ); opMailSend::sendTemplateMail('notifyRegisterURL', $address, opConfig::get('admin_mail_address'), $params); }
public function sendConfirmMail($to, $params = array()) { $params['subject'] = opConfig::get('sns_name') . ' ' . sfContext::getInstance()->getI18N()->__('New password has been issued'); opMailSend::sendTemplateMail('reissuedPassword', $to, opConfig::get('admin_mail_address'), $params); }
<?php include_once dirname(__FILE__) . '/../../bootstrap/unit.php'; include_once dirname(__FILE__) . '/../../bootstrap/database.php'; $t = new lime_test(4, new lime_output_color()); //------------------------------------------------------------ class dummyActions extends sfActions { } opMailSend::initialize(); Zend_Mail::setDefaultTransport(new opZendMailTransportMock()); $configuration = ProjectConfiguration::getApplicationConfiguration('pc_frontend', 'test', true); sfContext::createInstance($configuration); sfContext::getInstance()->getController()->getActionStack()->addEntry('member', 'home', new dummyActions(sfContext::getInstance(), 'member', 'home')); sfConfig::set('op_is_use_captcha', false); $member = Doctrine::getTable('Member')->find(1); $form = new MemberConfigMobileAddressForm($member, array(), false); $form->bind(array('mobile_address' => '*****@*****.**', 'mobile_address_confirm' => '*****@*****.**')); $t->ok($form->isValid(), 'MemberConfigMobileAddressForm accepts valid form parameter'); $t->ok($form->save(), 'MemberConfigMobileAddressForm is able to save configuration'); $t->ok($member->getConfig('mobile_address_pre'), 'the mobile_address_pre configuration has stored successfully'); $t->ok($member->getConfig('mobile_address_token'), 'the mobile_address_token configuration has stored successfully');
protected function sendConfirmMail($token, $to, $params = array()) { $authMode = $this->getOption('authMode', null); if (!$authMode) { $authMode = sfContext::getInstance()->getUser()->getCurrentAuthMode(); } $params = array('token' => $token, 'authMode' => $authMode, 'isMobile' => opToolkit::isMobileEmailAddress($to), 'name' => $this->getOption('invited') ? sfContext::getInstance()->getUser()->getMember()->getName() : null, 'message' => $this->getOption('invited') ? $this->getValue('message') : null, 'subject' => opConfig::get('sns_name') . '招待状'); opMailSend::sendTemplateMail('requestRegisterURL', $to, opConfig::get('admin_mail_address'), $params); }
protected function sendDeleteAccountMail($member) { $param = array('member' => $member); // to admin $mail = new opMailSend(); $mail->setSubject(opConfig::get('sns_name') . '退会者情報'); $mail->setGlobalTemplate('deleteAccountMail', $param); $mail->send(opConfig::get('admin_mail_address'), opConfig::get('admin_mail_address')); // to member $param['subject'] = sfContext::getInstance()->getI18N()->__('Leaving from this site is finished'); opMailSend::sendTemplateMailToMember('leave', $member, $param); }
public static function sendJoinMail($memberId, $communityId) { $communityMember = Doctrine::getTable('CommunityMember')->retrieveByMemberIdAndCommunityId($memberId, $communityId); if (!$communityMember) { return false; } if (!$communityMember->getIsPre()) { $community = Doctrine::getTable('community')->find($communityId); $member = Doctrine::getTable('Member')->find($memberId); $params = array('subject' => sfContext::getInstance()->getI18N()->__('%1% has just joined your %community%', array('%1%' => $member->name)), 'admin' => $community->getAdminMember(), 'community' => $community, 'new_member' => $member); $isSendPc = $community->getConfig('is_send_pc_joinCommunity_mail'); $isSendMobile = $community->getConfig('is_send_mobile_joinCommunity_mail'); $options = array('is_send_pc' => (bool) (null === $isSendPc ? 1 : $isSendPc), 'is_send_mobile' => (bool) (null === $isSendMobile ? 1 : $isSendMobile)); opMailSend::sendTemplateMailToMember('joinCommunity', $community->getAdminMember(), $params, $options); } }
public static function sendJoinMail($memberId, $communityId) { $communityMember = Doctrine::getTable('CommunityMember')->retrieveByMemberIdAndCommunityId($memberId, $communityId); if (!$communityMember) { return false; } if (!$communityMember->getIsPre()) { $community = Doctrine::getTable('community')->find($communityId); $member = Doctrine::getTable('Member')->find($memberId); $params = array('subject' => sfContext::getInstance()->getI18N()->__('%1% has just joined your %community%', array('%1%' => $member->name)), 'admin' => $community->getAdminMember(), 'community' => $community, 'new_member' => $member); opMailSend::sendTemplateMail('joinCommunity', $community->getAdminMember()->getEmailAddress(), opConfig::get('admin_mail_address'), $params); } }