示例#1
0
 public function setInvate($data)
 {
     if (isset($data['if_id'])) {
         Helper_Db::delete('invate_facebook', array('if_id => ?' => $data['if_id']));
     }
     if (isset($data['self_id']) && isset($data['user_id'])) {
         $follow = new Model_Users_Follow($data['self_id'], $data['user_id']);
         if (!$follow->is_follow) {
             $follow->followUser();
         }
         $follow = new Model_Users_Follow($data['user_id'], $data['self_id']);
         if (!$follow->is_follow) {
             $follow->followUser();
         }
     }
 }
示例#2
0
 public function followAction()
 {
     $this->noViewRenderer(true);
     $request = $this->getRequest();
     if ($request->isXmlHttpRequest()) {
         if ((int) JO_Session::get('user[user_id]')) {
             $user_id = $request->getRequest('user_id');
             $user_info = new Model_Users_User($user_id);
             if ($user_info->count()) {
                 $follow = new Model_Users_Follow($user_id);
                 if ($user_info['following_user']) {
                     $result = $follow->unfollowUser();
                     if ($result === true) {
                         new Model_History_AddHistory($user_id, Model_History_Abstract::UNFOLLOW_USER);
                         $this->view->ok = $this->translate('Follow');
                         $this->view->classs = 'add';
                         $this->view->boardauthorid = $user_id;
                     } else {
                         $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                     }
                 } else {
                     $result = $follow->followUser();
                     if ($result === true) {
                         new Model_History_AddHistory($user_id, Model_History_Abstract::FOLLOW_USER);
                         $this->view->ok = $this->translate('Unfollow');
                         $this->view->classs = 'remove';
                         $this->view->boardauthorid = $user_id;
                         if ($user_info['email_interval'] && $user_info['follows_email']) {
                             $template = Model_Notification::getTemplate('follow_user');
                             if ($template) {
                                 $template_data = array('user_id' => $user_info['user_id'], 'user_firstname' => $user_info['firstname'], 'user_lastname' => $user_info['lastname'], 'user_fullname' => $user_info['fullname'], 'user_username' => $user_info['username'], 'author_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')), 'author_fullname' => JO_Session::get('user[fullname]'), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
                                 if (!$template['title']) {
                                     $template['title'] = '${author_fullname} ' . $this->translate('now follow you');
                                 }
                                 $title = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data);
                                 $body = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data);
                                 Model_Email::send($user_info['email'], Helper_Config::get('noreply_mail'), $title, $body);
                             }
                         }
                     } else {
                         $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                     }
                 }
             } else {
                 $this->view->error = $this->translate('There was a problem with the record. Please try again!');
             }
         } else {
             $this->view->location = WM_Router::create($request->getBaseUrl() . '?controller=landing');
         }
     } else {
         $this->forward('error', 'error404');
     }
     echo $this->renderScript('json');
 }