public function executeEdit(opWebRequest $request)
 {
     $this->form = new sfForm();
     $memberId = $request->getParameter('member_id');
     if ($request->isMethod(sfWebRequest::POST)) {
         $wid = $request->getParameter('wid');
         if (!$memberId || !$wid) {
             return sfView::ERROR;
         }
         $member = Doctrine::getTable('Member')->find($memberId, null);
         if (is_null($member)) {
             return sfView::ERROR;
         }
         $config = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('op_kintai_member_wid', $memberId);
         if (!$config) {
             $config = new MemberConfig();
             $config->setName('op_kintai_member_wid');
             $config->setMember($member);
         }
         $config->setValue($wid);
         $config->save();
         $this->message = "登録しました。";
         $this->member = $member;
         $this->value = $wid;
     } else {
         $this->redirectIf(is_null($memberId), 'opGyoenKintaiPlugin/list');
         $member = Doctrine::getTable('Member')->find($memberId, null);
         $this->redirectIf(is_null($member), 'opGyoenKintaiPlugin/list');
         $this->member = $member;
         $config = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('op_kintai_member_wid', $memberId);
         $this->value = $config ? $config->getValue() : '';
     }
     return sfView::SUCCESS;
 }
示例#2
0
function createModel($memberId, $name, $value = null)
{
    $memberConfig = new MemberConfig();
    $memberConfig->setMemberId($memberId);
    $memberConfig->setName($name);
    $memberConfig->setValue($value);
    return $memberConfig;
}
 protected static function setMemberConfig($memberId, $name, $value)
 {
     $config = new MemberConfig();
     $config->member_id = $memberId;
     $config->name = $name;
     $config->value = $value;
     $config->save();
     $config->free(true);
 }
示例#4
0
function setBlogUrl($memberId, $url)
{
    $memberConfig = Doctrine::getTable('MemberConfig')->findOneByMemberIdAndName($memberId, 'blog_url');
    if (!$memberConfig) {
        $memberConfig = new MemberConfig();
        $memberConfig->setMemberId($memberId);
        $memberConfig->setName('blog_url');
    }
    $memberConfig->setValue($url);
    $memberConfig->save();
}
 private static function countUpOpAshiatoCount($memberId)
 {
     $memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('op_ashiato_count', $memberId);
     if (!$memberConfig) {
         $memberConfig = new MemberConfig();
         $memberConfig->setMemberId($memberId);
         $memberConfig->setName('op_ashiato_count');
     }
     $ashiatoCount = $memberConfig['value'];
     if ($memberConfig['value']) {
         $ashiatoCount = $memberConfig['value'] + 1;
     } else {
         $ashiatoCount = Doctrine::getTable('Ashiato')->getAshiatoMemberListCount($memberId);
     }
     $memberConfig->setValue($ashiatoCount);
     $memberConfig->save();
 }
示例#6
0
 public function saveToken()
 {
     $baseName = $this->getName();
     if (strrpos($baseName, '_pre')) {
         $tokenName = str_replace('_pre', '_token', $baseName);
     } else {
         $tokenName = $baseName . '_token';
     }
     $pre = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($tokenName, $this->getMemberId());
     if (!$pre) {
         $pre = new MemberConfig();
         $pre->setName($tokenName);
         $pre->setMember($this->getMember());
     } else {
         $pre = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($tokenName, $this->getMemberId());
     }
     $pre->setValue($this->createHash());
     return $pre->save();
 }
 private function setMemberConfig($memberId, $name, $value)
 {
     $config = new MemberConfig();
     $config->setMemberId($memberId);
     $config->setName($name);
     $config->setValue($value);
     $config->save();       
     $config->free(true);
 }
示例#8
0
 public function setConfig($configName, $value, $isDateTime = false)
 {
     $config = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($configName, $this->getId());
     if (!$config) {
         $config = new MemberConfig();
         $config->setMember($this);
         $config->setName($configName);
     }
     if ($isDateTime) {
         $config->setValueDatetime($value);
     }
     $config->setValue($value);
     $config->save();
 }
 public static function notify(Member $from, Member $to, $body, array $options = null)
 {
     $notificationItem = array('id' => microtime(), 'body' => $body, 'member_id_from' => $from->getId(), 'created_at' => time(), 'unread' => true, 'category' => $options['category'] ? $options['category'] : 'other', 'url' => $options['url'] ? $options['url'] : null, 'icon_url' => $options['icon_url'] ? $options['icon_url'] : null);
     $notificationObject = Doctrine::getTable('MemberConfig')->findOneByMemberIdAndName($to->getId(), 'notification_center');
     if (!$notificationObject) {
         $notificationObject = new MemberConfig();
         $notificationObject->setMemberId($to->getId());
         $notificationObject->setName('notification_center');
         $notifications = array();
     } else {
         $notifications = unserialize($notificationObject->getValue());
     }
     array_unshift($notifications, $notificationItem);
     $notificationLimit = sfConfig::get('op_notification_limit', 20);
     if ($notificationLimit < count($notifications)) {
         $notifications = array_slice($notifications, 0, $notificationLimit);
     }
     $notificationObject->setValue(serialize($notifications));
     $notificationObject->save();
     $notificationObject->free(true);
 }
 /**
  * Executes config complete action
  *
  * @param sfRequest $request A request object
  */
 public function executeConfigComplete($request)
 {
     $type = $request->getParameter('type');
     $this->forward404Unless($type);
     $memberId = $request->getParameter('id');
     $memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($type . '_token', $memberId);
     $this->forward404Unless($memberConfig);
     $this->forward404Unless((bool) $request->getParameter('token') !== $memberConfig->getValue());
     $option = array('member' => $memberConfig->getMember());
     $this->form = new sfOpenPNEPasswordForm(array(), $option);
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('password'));
         if ($this->form->isValid()) {
             $config = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($type, $memberId);
             $pre = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($type . '_pre', $memberId);
             if (!$config) {
                 $config = new MemberConfig();
                 $config->setName($type);
                 $config->setMemberId($memberId);
             }
             $config->setValue($pre->getValue());
             if ($config->save()) {
                 $pre->delete();
                 $token = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($type . '_token', $memberId);
                 $token->delete();
             }
             $this->redirect('member/home');
         }
     }
     return sfView::SUCCESS;
 }
示例#11
0
 /**
  * Executes configUID action
  *
  * @param sfRequest $request A request object
  */
 public function executeConfigUID($request)
 {
     $option = array('member' => $this->getUser()->getMember());
     $this->passwordForm = new sfOpenPNEPasswordForm(array(), $option);
     $mobileUid = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('mobile_uid', $this->getUser()->getMemberId());
     $this->isSetMobileUid = $mobileUid && $mobileUid->getValue();
     $this->isDeletableUid = (int) opConfig::get('retrieve_uid') < 2 && $this->isSetMobileUid;
     if ($request->isMethod('post')) {
         $this->passwordForm->bind($request->getParameter('password'));
         if ($this->passwordForm->isValid()) {
             if ($request->hasParameter('update')) {
                 if (!$request->getMobileUID()) {
                     $this->getUser()->setFlash('error', 'Your mobile UID was not registered.');
                     $this->redirect('member/configUID');
                 }
                 $memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId('mobile_uid', $this->getUser()->getMemberId());
                 if (!$memberConfig) {
                     $memberConfig = new MemberConfig();
                     $memberConfig->setMember($this->getUser()->getMember());
                     $memberConfig->setName('mobile_uid');
                 }
                 $memberConfig->setValue($request->getMobileUID());
                 $memberConfig->save();
                 $this->getUser()->setFlash('notice', 'Your mobile UID was set successfully.');
                 $this->redirect('member/configUID');
             } elseif ($request->hasParameter('delete') && $this->isDeletableUid) {
                 $mobileUid->delete();
                 $this->getUser()->setFlash('notice', 'Your mobile UID was deleted successfully.');
                 $this->redirect('member/configUID');
             }
         }
     }
     return sfView::SUCCESS;
 }
 public function savePreConfig($name, $value)
 {
     $memberConfig = Doctrine::getTable('MemberConfig')->retrieveByNameAndMemberId($name . '_pre', $this->member->getId());
     if (!$memberConfig) {
         $memberConfig = new MemberConfig();
         $memberConfig->setName($name);
         $memberConfig->setMember($this->member);
     }
     $memberConfig->setValue($value);
     $memberConfig->savePre();
     $memberConfig->saveToken();
 }