public function followAction() { $this->noViewRenderer(true); $request = $this->getRequest(); if ($request->isXmlHttpRequest()) { if ((int) JO_Session::get('user[user_id]')) { $board_id = $request->getRequest('board_id'); $board_info = new Model_Boards_Board($board_id); if ($board_info->count()) { $follow = new Model_Boards_Follow($board_id); $followed_user = new Model_Users_Follow($board_info['user_user_id']); $is_user_followed = $followed_user->is_follow; if ($board_info['following_board']) { $result = $follow->unfollowBoard(); if ($result === true) { new Model_History_AddHistory($board_info['user_user_id'], Model_History_Abstract::UNFOLLOW, 0, $board_id); $this->view->ok = $this->translate('Follow'); $this->view->classs = 'add'; $this->view->boardauthorid = $board_info['user_user_id']; $this->view->is_follow_user = $follow->is_follow_user; } else { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } else { $result = $follow->followBoard(); if ($result === true) { new Model_History_AddHistory($board_info['user_user_id'], Model_History_Abstract::FOLLOW, 0, $board_id); $this->view->ok = $this->translate('Unfollow'); $this->view->classs = 'remove'; $this->view->boardauthorid = $board_info['user_user_id']; $this->view->is_follow_user = $follow->is_follow_user; if (!$is_user_followed && $board_info['user_email_interval'] && $board_info['user_follows_email']) { $template = Model_Notification::getTemplate('follow_user'); if ($template) { $template_data = array('user_id' => $board_info['user_user_id'], 'user_firstname' => $board_info['user_firstname'], 'user_lastname' => $board_info['user_lastname'], 'user_fullname' => $board_info['user_fullname'], 'user_username' => $board_info['user_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($board_info['user_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'); }
public function thirdAction() { $request = $this->getRequest(); $this->view->total_following = Model_Boards_Follow::totalBoardFollow(JO_Session::get('user[user_id]')); if ($this->view->total_following < 5) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=welcome')); } $this->view->board_url = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=boards&action=view&ignoreDisabled=true&board_id=' . $this->getRequest()->getQuery('board_id')); $this->view->board_name = $this->getRequest()->getQuery('name'); //call header and footer childrens $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); }