Ejemplo n.º 1
0
function createModel($memberId, $name, $value = null)
{
    $memberConfig = new MemberConfig();
    $memberConfig->setMemberId($memberId);
    $memberConfig->setName($name);
    $memberConfig->setValue($value);
    return $memberConfig;
}
 private function setMemberConfig($memberId, $name, $value)
 {
     $config = new MemberConfig();
     $config->setMemberId($memberId);
     $config->setName($name);
     $config->setValue($value);
     $config->save();       
     $config->free(true);
 }
Ejemplo n.º 3
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();
}
Ejemplo n.º 4
0
 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();
 }
 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;
 }