Exemple #1
0
 public static function pinThumbs($pin)
 {
     $thumb_sizes = Model_Upload_Abstract::pinThumbSizes();
     $thumbs = array();
     foreach ($thumb_sizes as $size => $prefix) {
         if (isset($pin['pin_thumb' . strtolower($prefix)]) && $pin['pin_thumb' . strtolower($prefix)] && count($thumb = explode('|||', $pin['pin_thumb' . strtolower($prefix)])) == 5) {
             $thumbs['thumb_image' . strtolower($prefix)] = $thumb[0];
             $thumbs['thumb_original' . strtolower($prefix)] = $thumb[3];
             $thumbs['thumb_width' . strtolower($prefix)] = $thumb[1];
             $thumbs['thumb_height' . strtolower($prefix)] = $thumb[2];
             $thumbs['thumb_mime' . strtolower($prefix)] = $thumb[4];
             $thumbs['thumb_size' . strtolower($prefix)] = $prefix;
             $thumbs['thumb_pin_id' . strtolower($prefix)] = $pin['pin_pin_id'];
         } else {
             $image = Helper_Uploadimages::pin($pin, $prefix);
             if ($image) {
                 foreach ($image as $k => $v) {
                     $thumbs['thumb_' . $k . strtolower($prefix)] = $v;
                 }
             } else {
             }
         }
     }
     return $thumbs;
 }
Exemple #2
0
 public function boardsAction()
 {
     $this->setViewChange('index');
     $request = $this->getRequest();
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $query = $request->getRequest('q');
     $this->view->query = $query;
     $this->view->menuSearch = $this->searchMenu($query);
     $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_title' => $query);
     $this->view->pins = '';
     $boards = Model_Boards::getBoards($data);
     if ($boards) {
         $view = JO_View::getInstance();
         $view->loged = JO_Session::get('user[user_id]');
         $view->enable_sort = false;
         $model_images = new Helper_Images();
         foreach ($boards as $board) {
             $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
             $board['thumbs'] = array();
             $get_big = false;
             for ($i = 0; $i < 5; $i++) {
                 $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false;
                 if ($image) {
                     if ($get_big) {
                         $size = '_A';
                     } else {
                         $size = '_C';
                         $get_big = true;
                     }
                     $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size);
                     if ($data_img) {
                         $board['thumbs'][] = $data_img['image'];
                     } else {
                         $board['thumbs'][] = false;
                     }
                 } else {
                     $board['thumbs'][] = false;
                 }
             }
             $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id']));
             $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]');
             $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
             $board['edit'] = false;
             if ($board['user_id'] == JO_Session::get('user[user_id]') || Model_Boards::allowEdit($board['board_id'])) {
                 $board['userFollowIgnore'] = false;
                 $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
             }
             $view->board = $board;
             $this->view->pins .= $view->render('box', 'boards');
         }
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->view->pins;
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
 }
Exemple #3
0
 public static function getSourcePins($source_id, $limit = 5, $thumb = 75)
 {
     static $result = array(), $model_images = null, $request = null;
     if (isset($result[$source_id])) {
         return $result[$source_id];
     }
     if ($model_images === null) {
         $model_images = new Helper_Images();
     }
     if ($request === null) {
         $request = JO_Request::getInstance();
     }
     $pins = Model_Pins::getPins(array('filter_source_id' => $source_id, 'start' => 0, 'limit' => $limit));
     $data = array();
     if ($pins) {
         foreach ($pins as $pin) {
             $image = Helper_Uploadimages::pin($pin, '_A');
             if ($image) {
                 $data[] = array('thumb' => $image['image'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=source&source_id=' . $pin['source_id']));
             }
         }
     }
     $result[$source_id] = $data;
     return $data;
 }
Exemple #4
0
 public static function returnHtmlTop($pin, $recache = false)
 {
     static $view = null, $model_images = null, $request = null;
     if ($view === null) {
         $view = JO_View::getInstance();
     }
     if ($model_images === null) {
         $model_images = new Helper_Images();
     }
     if ($request === null) {
         $request = JO_Request::getInstance();
     }
     $image = Helper_Uploadimages::pin($pin, '_D');
     if ($image) {
         $pin['thumb'] = $image['image'];
         $pin['thumb_width'] = $image['width'];
         $pin['thumb_height'] = $image['height'];
         $pin['original_image'] = $image['original'];
     } else {
         return '';
     }
     $date_dif = array_shift(WM_Date::dateDiff($pin['date_added'], time()));
     $pin['date_dif'] = $date_dif;
     $pin['description'] = self::descriptionFix($pin['description']);
     $pin['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
     if (JO_Session::get('user[user_id]')) {
         $pin['url_like'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=like&pin_id=' . $pin['pin_id']);
         $pin['url_repin'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=repin&pin_id=' . $pin['pin_id']);
         $pin['url_comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
         $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
         $pin['edit'] = JO_Session::get('user[user_id]') == $pin['user_id'] ? WM_Router::create($request->getBaseUrl() . '?controller=pin&action=edit&pin_id=' . $pin['pin_id']) : false;
     } else {
         $pin['url_like'] = $pin['url_repin'] = $pin['url_comment'] = $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=landing');
         $pin['edit'] = false;
     }
     $pin['onto_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['user_id'] . '&board_id=' . $pin['board_id']);
     $pin['price_formated'] = WM_Currency::format($pin['price']);
     $view->author = $pin['user'];
     $avatar = Helper_Uploadimages::avatar($pin['user'], '_A');
     $view->author['avatar'] = $avatar['image'];
     $view->author['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_id']);
     if (JO_Session::get('user[user_id]')) {
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $view->author_self = $avatar['image'];
         $view->profile_self = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
     }
     if ($pin['latest_comments']) {
         foreach ($pin['latest_comments'] as $key => $comment) {
             if (!isset($pin['latest_comments'][$key]['user']['store'])) {
                 unset($pin['latest_comments'][$key]);
                 continue;
             }
             $avatar = Helper_Uploadimages::avatar($pin['latest_comments'][$key]['user'], '_A');
             $pin['latest_comments'][$key]['user']['avatar'] = $avatar['image'];
             $pin['latest_comments'][$key]['user']['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $comment['user_id']);
             $pin['latest_comments'][$key]['delete'] = '';
             if (JO_Session::get('user[user_id]')) {
                 if (JO_Session::get('user[is_admin]') || JO_Session::get('user[user_id]') == $comment['user_id']) {
                     $pin['latest_comments'][$key]['delete'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $comment['comment_id']);
                 }
             }
         }
     }
     $view->via = array();
     if ($pin['via']) {
         $view->via = array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['via']), 'fullname' => $pin['user_via']['fullname']);
     }
     $view->loged = (int) JO_Session::get('user[user_id]');
     $view->site_name = JO_Registry::get('site_name');
     $view->history_id = isset($pin['history_id']) ? $pin['history_id'] : '';
     $view->history_action = isset($pin['history_action']) ? ' ' . $pin['history_action'] : '';
     $view->pin = $pin;
     $response = $view->render('pinBoxTop', 'pin');
     return $response;
 }
Exemple #5
0
 public function repinAction()
 {
     $request = $this->getRequest();
     $pin_id = $request->getRequest('pin_id');
     $pin_info = Model_Pins::getPin($pin_id);
     if (!$pin_info) {
         $this->forward('error', 'error404');
     }
     $model_images = new Helper_Images();
     $this->view->title = $pin_info['title'];
     $this->view->price = $pin_info['price'];
     $image = Helper_Uploadimages::pin($pin_info, '_B');
     if ($image) {
         $this->view->media = $image['original'];
     } else {
         $this->view->media = false;
     }
     $this->view->is_video = $pin_info['is_video'] ? 'true' : 'false';
     $this->view->is_article = $pin_info['is_article'] ? 'true' : 'false';
     $this->view->from = $pin_info['from'];
     $this->view->description = $pin_info['description'];
     $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=repin&pin_id=' . $pin_id);
     $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
     $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'order' => 'boards.sort_order', 'sort' => 'ASC', 'friendly' => JO_Session::get('user[user_id]')));
     $this->view->boards = array();
     if ($boards) {
         foreach ($boards as $board) {
             $this->view->boards[] = array('board_id' => $board['board_id'], 'title' => $board['title']);
         }
     }
     //////////// Categories ////////////
     $this->view->categories = array();
     $categories = Model_Categories::getCategories(array('filter_status' => 1));
     foreach ($categories as $category) {
         $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']);
         $this->view->categories[] = $category;
     }
     $this->view->popup_main_box = $this->view->render('repin', 'pin');
     $this->view->is_article = $pin_info['is_article'] ? 'true' : 'false';
     if ($request->isPost()) {
         $result = Model_Pins::create(array('title' => $pin_info['title'], 'from' => $pin_info['from'], 'image' => $this->view->media, 'is_video' => $pin_info['is_video'] ? 'true' : 'false', 'is_article' => $pin_info['is_article'] ? 'true' : 'false', 'description' => $request->getPost('message'), 'price' => $request->getPost('price'), 'board_id' => $request->getPost('board_id'), 'via' => $pin_info['user_id'], 'repin_from' => $pin_info['pin_id'], 'from_repin' => $pin_info['from']));
         if ($result) {
             $this->view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result);
             $this->view->popup_main_box = $this->view->render('success', 'addpin');
             //add history
             Model_History::addHistory($pin_info['user_id'], Model_History::REPIN, $result);
             if ($pin_info['user']['email_interval'] == 1 && $pin_info['user']['repins_email']) {
                 $this->view->user_info = $pin_info['user'];
                 $this->view->profile_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
                 $this->view->full_name = JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]');
                 $this->view->text_email = $this->translate('repin your');
                 $this->view->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin_id);
                 Model_Email::send($pin_info['user']['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('repin your pin'), $this->view->render('repin_pin', 'mail'));
             }
         }
     }
     $this->setViewChange('index');
     if ($request->isXmlHttpRequest()) {
         $this->noViewRenderer(true);
         echo $this->view->popup_main_box;
         $this->view->is_popup = true;
     } else {
         $this->view->pins_details = $this->view->popup_main_box;
         $this->view->is_popup = false;
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'pin/left_part');
     }
 }
 public function indexAction()
 {
     /*	
     		$request = $this->getRequest();
     		
     		if($request->isPost()) {
     			if( !$request->getPost('category_id') || count($request->getPost('category_id')) < 1 ) {
     				$this->view->error = true;
     			} else {
     				JO_Session::set('category_id', $request->getPost('category_id'));
     				$this->redirect( WM_Router::create($request->getBaseUrl() . '?controller=welcome&action=second') );
     			}
     		}
     		
     		$this->helpas();
     		
     		//////////// Categories ////////////
     		$this->view->categories = array();
     		$categories = Model_Categories::getCategories(array(
     			'filter_status' => 1
     		));
     		
     		$model_images = new Helper_Images();
     		
     		foreach($categories AS $category) {
     			if($category['image']) {
     				$category['thumb'] = $model_images->resize($category['image'], 113, 113, true);
     			} else {
     				$category['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 113, 113);
     			}
     			
     			$this->view->categories[] = $category;
     		}
     		
     		
     	}
     	
     	function secondAction() {
     */
     $request = $this->getRequest();
     $this->helpas();
     //$categories = JO_Session::get('category_id');
     $userSports = Model_Users::getUserSports(JO_Session::get('user[user_id]'));
     $categories = array();
     foreach ($userSports as $userSport) {
         $categories[] = $userSport["sport_category"];
     }
     $users = "";
     if (!$categories || count($categories) < 1) {
         $this->view->error = true;
         Model_Users::edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
     } else {
         JO_Session::set('category_id', $categories);
         $users = Model_Users::getUsers(array('filter_welcome' => $categories, 'start' => 0, 'limit' => 20));
     }
     /*if(!$users) {
     			JO_Session::clear('category_id');
     			$this->redirect( WM_Router::create($request->getBaseUrl() . '?controller=welcome') );
     		}
     		*/
     $this->view->boards = '';
     if ($users) {
         $view = JO_View::getInstance();
         $view->loged = JO_Session::get('user[user_id]');
         $model_images = new Helper_Images();
         foreach ($users as $key => $user) {
             $user['thumbs'] = array();
             for ($i = 0; $i < min(8, count($user['pins_array'])); $i++) {
                 $image = isset($user['pins_array'][$i]) ? $user['pins_array'][$i]['image'] : false;
                 if (isset($user['pins_array'][$i])) {
                     $image = Helper_Uploadimages::pin($user['pins_array'][$i], '_A');
                     if ($image) {
                         $user['thumbs'][] = array('thumb' => $image['image'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $user['pins_array'][$i]['pin_id']), 'title' => $user['pins_array'][$i]['title']);
                     }
                 }
             }
             $avatar = Helper_Uploadimages::avatar($user, '_B');
             $user['avatar'] = $avatar['image'];
             $user['userLikeIgnore'] = true;
             if (JO_Session::get('user[user_id]') == $user['user_id']) {
                 $user['userIsFollow'] = 1;
                 $user['userFollowIgnore'] = true;
             } else {
                 $user['userIsFollow'] = Model_Users::isFollowUser($user['user_id']);
                 if (!$user['userIsFollow']) {
                     $user['userIsFollow'] = Model_Users::FollowUser($user['user_id']);
                 }
                 $user['userFollowIgnore'] = false;
             }
             $user['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']);
             $user['pins_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $user['user_id']);
             $user['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user['user_id']);
             $view->key = $key % 2 == 0;
             $view->user = $user;
             $this->view->boards .= $view->render('box', 'users');
         }
     }
     $this->view->pinmarklet_href = WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_pinmarklet'));
     //$this->view->direct_path = WM_Router::create( $request->getBaseUrl() . '?direct_path=true' );
     if (JO_Registry::get('isMobile')) {
         $this->view->direct_path = WM_Router::create($request->getBaseUrl());
     } else {
         $this->view->direct_path = WM_Router::create($request->getBaseUrl() . '?controller=guia-rapida');
     }
 }
Exemple #7
0
 public function searchAction()
 {
     $this->noViewRenderer(true);
     $request = $this->getRequest();
     $response = $this->getResponse();
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $callback = $request->getRequest('callback');
     if (!preg_match('/^([a-z0-9_.]{1,})$/', $callback)) {
         $callback = false;
     }
     $data = array();
     $url = "";
     $return = array();
     $kind = $request->getRequest('kind');
     $query = $request->getRequest('query');
     $userId = $request->getRequest('userId');
     if ($kind == 0) {
         // pins
         $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_description' => $query, 'filter_marker' => $request->getRequest('marker'));
         $this->view->pins = '';
         $pins = Model_Pins::getPinsAPP($data);
         if ($pins) {
             $model_images = new Helper_Images();
             foreach ($pins as $pin) {
                 $images = array();
                 $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B');
                 if ($image) {
                     $images['thumb']['src'] = $image['image'];
                     $images['thumb']['width'] = $image['width'];
                     $images['thumb']['height'] = $image['height'];
                     $images['original'] = $image['original'];
                 }
                 $categorias = array();
                 $categories = Model_Categories::getCategory($pin['category_id']);
                 if ($categories['parent_id'] != 0) {
                     $categorias['category_id'] = $categories['parent_id'];
                     $categorias['subcategory_id'] = $categories['category_id'];
                 } else {
                     $categorias['category_id'] = $categories['category_id'];
                     $categorias['subcategory_id'] = $categories['parent_id'];
                 }
                 $pos = strripos($pin['image'], '.');
                 $return['data'][] = array('pin_id' => $pin['pin_id'], 'pinFooter' => $pin['description'], 'category_id' => $categorias['category_id'], 'subcategory_id' => $categorias['subcategory_id'], 'pinImage' => substr_replace($pin['image'], '_B.', $pos, 1), 'pinWidth' => $pin['width'], 'pinHeight' => $pin['height'], 'pinUrl' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']), 'userId' => $pin['user_id'], 'username' => $pin['username'], 'avatar' => $pin['avatar'], 'userLike' => $pin['liked'], 'pinVideo' => $pin['from']);
             }
             $return['next_page'] = WM_Router::create($request->getBaseUrl() . '?controller=apiv1&action=timeline' . $url);
         }
     } else {
         if ($kind == 1) {
             //boards
             $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_title' => $query);
             $this->view->pins = '';
             $boards = Model_Boards::getBoards($data);
             if ($boards) {
                 $view = JO_View::getInstance();
                 $view->loged = JO_Session::get('user[user_id]');
                 $view->enable_sort = false;
                 $model_images = new Helper_Images();
                 foreach ($boards as $board) {
                     $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
                     $board['thumbs'] = array();
                     $get_big = false;
                     for ($i = 0; $i < 5; $i++) {
                         $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false;
                         if ($image) {
                             if ($get_big) {
                                 $size = '_A';
                             } else {
                                 $size = '_C';
                                 $get_big = true;
                             }
                             $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size);
                             if ($data_img) {
                                 $board['thumbs'][] = $data_img['image'];
                             } else {
                                 $board['thumbs'][] = false;
                             }
                         } else {
                             $board['thumbs'][] = false;
                         }
                     }
                     $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id']));
                     $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]');
                     $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
                     $board['edit'] = false;
                     if ($board['user_id'] == JO_Session::get('user[user_id]') || Model_Boards::allowEdit($board['board_id'])) {
                         $board['userFollowIgnore'] = false;
                         $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
                     }
                     $username = Model_Users::getUsername($board["user_id"]);
                     $url_base = WM_Router::create($request->getBaseUrl());
                     $return['data'][] = array('folderId' => $board['board_id'], 'folderName' => $board['title'], 'folderUrl' => $url_base . $username . "/" . $board['title'], 'folderImage' => $board['image'], 'folderQty' => $board['pins']);
                     //$return[] = $board;
                 }
             }
         } else {
             if ($kind == 2) {
                 //people
                 $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_username' => $query);
                 $users = Model_Users::getUsers($data);
                 if ($users) {
                     $this->view->follow_user = true;
                     $view = JO_View::getInstance();
                     $view->loged = JO_Session::get('user[user_id]');
                     $model_images = new Helper_Images();
                     foreach ($users as $key => $user) {
                         $avatar = Helper_Uploadimages::avatar($user, '_B');
                         $user['avatar'] = $avatar['image'];
                         if ($view->loged) {
                             $user['userIsFollow'] = Model_Users::isFollowUser($user['user_id']);
                             $user['userFollowIgnore'] = $user['user_id'] == JO_Session::get('user[user_id]');
                         } else {
                             $user['userFollowIgnore'] = true;
                         }
                         $user['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']);
                         $user['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user['user_id']);
                         $return['data'][] = array('userId' => $user['user_id'], 'userName' => $user['username'], 'userDesc' => $user['description'], 'userLocation' => $user['location'], 'avatar' => $user['avatar'], 'follower' => $user['followers'], 'following' => $user['following']);
                     }
                 }
             }
         }
     }
     if ($callback) {
         $return = $callback . '(' . JO_Json::encode($return) . ')';
     } else {
         $response->addHeader('Cache-Control: no-cache, must-revalidate');
         $response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         $response->addHeader('Content-type: application/json');
         $return = JO_Json::encode($return);
     }
     $response->appendBody($return);
 }
Exemple #8
0
 public function activityAction()
 {
     $request = $this->getRequest();
     $user_data = $this->profileHelp();
     $this->setViewChange('profile');
     $this->view->active = 'activity';
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $this->view->boards = '';
     $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'sort' => 'DESC', 'order' => 'history_id');
     $history = Model_History::getHistory($data, 'from_user_id', $user_data['user_id']);
     if ($history) {
         $view = JO_View::getInstance();
         $view->loged = JO_Session::get('user[user_id]');
         $model_images = new Helper_Images();
         foreach ($history as $key => $data) {
             if ($data['history_action'] == Model_History::REPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'repin-box';
                     $userdata = Model_Users::getUser($data['to_user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate('Repinned to %s via %s.'), '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>', '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::ADDPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'addpin-box';
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $view->set_activity_title = sprintf($this->translate('Pinned to %s.'), '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::LIKEPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'likepin-box';
                     $userdata = Model_Users::getUser($pin_data['user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate("Liked %s's pin on %s."), '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>', '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::UNLIKEPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'unlikepin-box';
                     $userdata = Model_Users::getUser($pin_data['user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate("Unliked %s's pin on %s."), '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>', '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::COMMENTPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'commentpin-box';
                     $userdata = Model_Users::getUser($pin_data['user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate("Commented on %s's pin and said \"%s\"."), '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>', JO_Utf8::splitText($data['comment'], 60, '...'));
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::ADDBOARD) {
                 $board = Model_Boards::getBoard($data['board_id']);
                 if ($board) {
                     $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $user_data['user_id'] . '&board_id=' . $board['board_id']);
                     $board['thumbs'] = array();
                     /* for( $i = 0; $i < min(9, count($board['pins_array'])); $i ++) {
                        $image = isset( $board['pins_array'][$i] ) ? $board['pins_array'][$i]['image'] : false;
                        $board['thumbs'][] = $model_images->resize($image, 60, 60, true);
                        } */
                     $get_big = false;
                     for ($i = 0; $i < 5; $i++) {
                         $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false;
                         if ($image) {
                             if ($get_big) {
                                 $size = '_A';
                             } else {
                                 $size = '_C';
                                 $get_big = true;
                             }
                             $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size);
                             if ($data_img) {
                                 $board['thumbs'][] = $data_img['image'];
                             } else {
                                 $board['thumbs'][] = false;
                             }
                         } else {
                             $board['thumbs'][] = false;
                         }
                     }
                     $board['edit'] = false;
                     if ($board['user_id'] == JO_Session::get('user[user_id]')) {
                         $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $user_data['user_id'] . '&board_id=' . $board['board_id']);
                     }
                     $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id']));
                     $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]');
                     $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $user_data['user_id'] . '&board_id=' . $board['board_id']);
                     $board['history_action'] = 'addboard-box';
                     $view->board = $board;
                     $view->set_activity_title = $this->translate('Created');
                     $this->view->boards .= $view->render('box', 'boards');
                 }
             } else {
                 $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $data['to_user_id']);
                 $avatar = Helper_Uploadimages::avatar($data['user'], '_B');
                 $data['thumb'] = $avatar['image'];
                 $data['thumb_width'] = $avatar['width'];
                 $data['thumb_height'] = $avatar['height'];
                 if (!@getimagesize($data['thumb'])) {
                     $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                     $data['thumb_width'] = $model_images->getSizes('width');
                     $data['thumb_height'] = $model_images->getSizes('height');
                 }
                 $view->history = $data;
                 if ($data['history_action'] == Model_History::FOLLOW_USER) {
                     $view->history['userIsFollow'] = Model_Users::isFollowUser($view->history['to_user_id']);
                     $view->history['follow_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $view->history['to_user_id']);
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $this->view->boards .= $view->render('history/follow_user', 'users');
                 } elseif ($data['history_action'] == Model_History::UNFOLLOW_USER) {
                     $view->history['userIsFollow'] = Model_Users::isFollowUser($view->history['to_user_id']);
                     $view->history['follow_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $view->history['to_user_id']);
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $this->view->boards .= $view->render('history/unfollow_user', 'users');
                 } elseif ($data['history_action'] == Model_History::FOLLOW) {
                     $board_info = Model_Boards::getBoard($data['board_id']);
                     if ($board_info) {
                         $board_info['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board_info['board_id']));
                         $board_info['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $board_info['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $view->history['fullname'] = $data['user']['fullname'];
                         $view->history['avatar'] = $avatar['image'];
                         $view->history['board'] = $board_info;
                         $this->view->boards .= $view->render('history/follow_board', 'users');
                     }
                 } elseif ($data['history_action'] == Model_History::UNFOLLOW) {
                     $board_info = Model_Boards::getBoard($data['board_id']);
                     if ($board_info) {
                         $board_info['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board_info['board_id']));
                         $board_info['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $board_info['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $view->history['fullname'] = $data['user']['fullname'];
                         $view->history['avatar'] = $avatar['image'];
                         $view->history['board'] = $board_info;
                         $this->view->boards .= $view->render('history/unfollow_board', 'users');
                     }
                 } elseif ($data['history_action'] == Model_History::LIKEUSER) {
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['userIsLike'] = Model_Users::isLikeUser($view->history['to_user_id']);
                     $view->history['like_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id']);
                     $this->view->boards .= $view->render('history/like_user', 'users');
                 } elseif ($data['history_action'] == Model_History::UNLIKEUSER) {
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['userIsLike'] = Model_Users::isLikeUser($view->history['to_user_id']);
                     $view->history['like_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id']);
                     $this->view->boards .= $view->render('history/unlike_user', 'users');
                 } elseif ($data['history_action'] == Model_History::COMMENTUSER) {
                     $view->history['href'] = $data['href'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['text_type'] = $data['text_type'];
                     $view->history['comment'] = $data['comment'];
                     $view->history['date_added'] = $data['date_added'];
                     $view->history['value'] = $data['date_dif']['value'];
                     $view->history['key'] = $data['date_dif']['key'];
                     $this->view->boards .= $view->render('history/history', 'users');
                     //$view->history['comment_user'] = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id'] );
                     //$this->view->boards .= $view->render('history/comment_user', 'users');
                 } elseif ($data['history_action'] == Model_History::MESSAGEUSER) {
                     $view->history['href'] = $data['href'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['text_type'] = $data['text_type'];
                     $view->history['comment'] = $data['comment'];
                     $view->history['date_added'] = $data['date_added'];
                     $view->history['value'] = $data['date_dif']['value'];
                     $view->history['key'] = $data['date_dif']['key'];
                     $this->view->boards .= $view->render('history/history', 'users');
                     //$view->history['messageUser'] = Model_Users::isLikeUser($view->history['to_user_id']);
                     //$view->history['message_user'] = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id'] );
                     //$this->view->boards .= $view->render('history/message_user', 'users');
                 } elseif ($data['history_action'] == Model_History::UNMESSAGEUSER) {
                     $view->history['href'] = $data['href'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['text_type'] = $data['text_type'];
                     $view->history['comment'] = $data['comment'];
                     $view->history['date_added'] = $data['date_added'];
                     $view->history['value'] = $data['date_dif']['value'];
                     $view->history['key'] = $data['date_dif']['key'];
                     $this->view->boards .= $view->render('history/history', 'users');
                     //$view->history['unmessage_user'] = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id'] );
                     //$this->view->boards .= $view->render('history/unmessage_user', 'users');
                 } elseif ($data['history_action'] == Model_History::FOLLOW_EVENT) {
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsFollow'] = Model_Events::isFollowEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['follow_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=follow&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/follow_event', 'users');
                 } elseif ($data['history_action'] == Model_History::UNFOLLOW_EVENT) {
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsFollow'] = Model_Events::isFollowEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['follow_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=follow&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/unfollow_event', 'users');
                 } elseif ($data['history_action'] == Model_History::LIKE_EVENT) {
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsLike'] = Model_Events::isLikeEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['like_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=like&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/like_event', 'users');
                 } elseif ($data['history_action'] == Model_History::UNLIKE_EVENT) {
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsLike'] = Model_Events::isLikeEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['like_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=like&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/unlike_event', 'users');
                 }
             }
         }
     }
     $agendas = Model_Users::getUserAgenda(array('filter_user_id' => $user_data['user_id']));
     $this->view->has_agendas = false;
     $this->view->agendas_users = "";
     if ($agendas) {
         $this->view->has_agendas = true;
         foreach ($agendas as $agenda) {
             $agenda['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopupDelete&agenda_id=' . $agenda['agenda_id'] . '&user_id=' . $user_data['user_id']);
             $this->view->agenda = $agenda;
             $this->view->agendas_users .= $this->view->render('agenda', 'users');
         }
     }
     $session_user = JO_Session::get('user[user_id]');
     $this->view->popup_agenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopup&user_id=' . $user_data['user_id']);
     //no mover de esta ubicación
     $messages = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => 0));
     $this->view->has_messages = false;
     $this->view->messages_users = "";
     if ($messages) {
         $this->view->has_messages = true;
         foreach ($messages as $message) {
             $avatar = Helper_Uploadimages::avatar($message, '_A');
             $message['avatar'] = $avatar['image'];
             $message['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $message['user_id']);
             $message['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $message['message_id'] . '&user_id=' . $user_data['user_id']);
             $message['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $message['message_id']);
             $this->view->message = $message;
             $this->view->messages_users .= $this->view->render('message', 'users');
             //ahora vamos a consultar las respuestas a este:
             $messagesHijos = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => $message['message_id']));
             if ($messagesHijos) {
                 foreach ($messagesHijos as $messageHijo) {
                     $avatar = Helper_Uploadimages::avatar($messageHijo, '_A');
                     $messageHijo['avatar'] = $avatar['image'];
                     $messageHijo['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $messageHijo['user_id']);
                     $messageHijo['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $messageHijo['message_id'] . '&user_id=' . $user_data['user_id']);
                     $messageHijo['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $messageHijo['message_id']);
                     $this->view->message = $messageHijo;
                     $this->view->messages_users .= $this->view->render('message', 'users');
                 }
             }
         }
     }
     $session_user = JO_Session::get('user[user_id]');
     $this->view->popup_messages = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=0');
     //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activatePopup'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0'  );
     //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activateDetail'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0'  );
     $_SESSION["activate_url"] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
     $this->view->popup_activate = WM_Router::create($request->getBaseUrl() . '?controller=users&action=activate');
     $this->view->search_url = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=activate');
     //$this->view->deportes = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=deportes');
     $this->view->addMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=create');
     $this->view->stateMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=state');
     $this->view->viewMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=view');
     $activate = Model_Users::getActivateUser(JO_Session::get('user[user_id]'));
     if ($activate) {
         $this->view->userIsActivate = $activate["activate"];
     }
     if ($user_data['type_user']) {
         $this->view->userCanActivate = Model_Users::getUserTypeNotOthers($user_data['type_user']);
     }
     if (JO_Registry::get('isMobile')) {
         $this->view->urlagenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agenda&user_id=' . $user_data['user_id']);
         $this->view->urlmensajes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=mensajes&user_id=' . $user_data['user_id']);
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->view->boards;
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
 }
Exemple #9
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $board_id = $request->getRequest('board_id');
     $user_id = $request->getRequest('user_id');
     $board_info = Model_Boards::getBoard($board_id, true);
     if (!$board_info) {
         $this->forward('error', 'error404');
     }
     if (!$board_info['category_id'] && JO_Session::get('user[user_id]') == $board_info['user_id']) {
         JO_Registry::set('board_category_change', $board_info);
     }
     $user_info = Model_Users::getUserByBoard($board_info['user_id'], $board_id);
     $model_images = new Helper_Images();
     if ($user_info) {
         $avatar = Helper_Uploadimages::avatar($user_info, '_A');
         $user_info['avatar'] = $avatar['image'];
         $user_info['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user_info['user_id']);
         $this->view->user_info = $user_info;
         $user_id = $user_info['user_id'];
     }
     Model_Boards::updateViewed($board_id);
     if (!$board_info['public'] && $user_id != JO_Registry::get('user[user_id]')) {
         $this->forward('error', 'error404');
     }
     $board_info['isFollow'] = Model_Users::isFollow(array('board_id' => $board_info['board_id']));
     $this->view->follow = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow' . ($board_info['user_id'] ? '&user_id=' . $board_info['user_id'] : '') . '&board_id=' . $board_info['board_id']);
     if (Model_Boards::allowEdit($board_id)) {
         $this->view->is_enable_follow = false;
         $board_info['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
     } else {
         $board_info['edit'] = false;
         if (JO_Session::get('user[user_id]')) {
             if (JO_Session::get('user[user_id]') != $board_info['user_id']) {
                 $this->view->is_enable_follow = true;
             } else {
                 $this->view->is_enable_follow = false;
                 $board_info['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
             }
         } else {
             $this->view->is_enable_follow = false;
         }
     }
     $this->view->board_url = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
     $this->view->board_users = array();
     if ($board_info['board_users']) {
         foreach ($board_info['board_users'] as $usr) {
             $avatar = Helper_Uploadimages::avatar($usr, '_A');
             $usr['avatar'] = $avatar['image'];
             $usr['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $usr['user_id']);
             $this->view->board_users[] = $usr;
         }
     }
     $this->view->board = $board_info;
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_board_id' => $board_info['board_id'], 'filter_marker' => $request->getRequest('marker'));
     //		if((int)JO_Session::get('user[user_id]')) {
     //			$data['following_users_from_user_id'] = JO_Session::get('user[user_id]');
     //		}
     $this->view->pins = '';
     $pins = Model_Pins::getPins($data);
     //==== FEED ====//
     JO_Registry::set('rss_feed', array('title' => $board_info['title'] . ' ' . sprintf($this->translate('on %s'), JO_Registry::get('site_name')), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id'] . '&feed')));
     $_route_ = $request->getParam('_route_');
     $_route_parts = explode('/', $_route_);
     if (isset($_route_parts[2]) && $_route_parts[2] == 'feed') {
         $this->forward('boards', 'feed', array('pins' => $pins, 'view' => $this->view));
     }
     //==== FEED ====//
     $image = '';
     if ($pins) {
         foreach ($pins as $pin) {
             $this->view->pins .= Helper_Pin::returnHtml($pin);
             if (!$image) {
                 $img = Helper_Uploadimages::pin($pin, '_D');
                 if ($img) {
                     $image = $img['image'];
                 }
             }
         }
         // 			JO_Registry::set('marker', Model_Pins::getMaxPin($data));
     }
     $this->getLayout()->placeholder('pin_url', $this->view->board_url);
     if ($image) {
         $this->getLayout()->placeholder('pin_image', $image);
     }
     $this->getLayout()->placeholder('pin_description', 'null');
     if ($request->isXmlHttpRequest()) {
         echo $this->view->pins;
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
     JO_Layout::getInstance()->meta_title = $board_info['title'];
 }