示例#1
0
 public static function userAvatars($user)
 {
     $thumb_sizes = Model_Upload_Abstract::userThumbSizes();
     $avatars = array();
     foreach ($thumb_sizes as $size => $prefix) {
         if (isset($user['user_avatar' . strtolower($prefix)]) && $user['user_avatar' . strtolower($prefix)] && count($thumb = explode('|||', $user['user_avatar' . strtolower($prefix)])) == 5) {
             $avatars['avatar_image' . strtolower($prefix)] = $thumb[0];
             $avatars['avatar_original' . strtolower($prefix)] = $thumb[3];
             $avatars['avatar_width' . strtolower($prefix)] = $thumb[1];
             $avatars['avatar_height' . strtolower($prefix)] = $thumb[2];
             $avatars['avatar_mime' . strtolower($prefix)] = $thumb[4];
             $avatars['avatar_size' . strtolower($prefix)] = $prefix;
             $avatars['avatar_user_id' . strtolower($prefix)] = $user['user_id'];
         } else {
             $avatar = Helper_Uploadimages::avatar($user, $prefix);
             if ($avatar) {
                 foreach ($avatar as $k => $v) {
                     $avatars['avatar_' . $k . strtolower($prefix)] = $v;
                 }
             } else {
             }
         }
     }
     return $avatars;
 }
示例#2
0
文件: User.php 项目: noikiy/amatteur
 public static function returnHtmlTop($user, $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();
     }
     /*$response = array();
                     
     		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 < 8; $i ++) {
     					$image = isset( $user['pins_array'][$i] ) ? $user['pins_array'][$i]['image'] : false;
     					if($image) {
     						$data_img = Helper_Uploadimages::pin($user['pins_array'][$i], '_A');
     						if($data_img) {
     							$user['thumbs'][] = array(
     									'thumb' => $data_img['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['Likers'] = true;
     $user['userLikeIgnore'] = true;
     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['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;
     $response = $view->render('boxTop', 'users');
     /*
     	}
     }
     */
     return $response;
 }
示例#3
0
 public function autocomplete($query)
 {
     $request = $this->getRequest();
     $result = array();
     $has_friends = (int) JO_Session::get('user[following]') + (int) JO_Session::get('user[followers]');
     $users = $has_friends ? new Model_Users_SearchAutocomplete(array('filter_username' => $query, 'start' => 0, 'limit' => 100)) : new ArrayObject();
     if ($has_friends && $users->count()) {
         foreach ($users as $user) {
             $result[] = array('template' => 'user', 'avatars' => Helper_Uploadimages::userAvatars($user), 'fullname' => $user['fullname'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']));
         }
     }
     return $result;
 }
示例#4
0
 public static function returnHtmlDetail($event, $banners = false)
 {
     //XPER: función que carga PIN
     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();
     }
     /*
     $next_pin = Model_Pins::getNextPin($event['event_id']);
     if($next_pin) {
     	$view->next_navigation_pin = WM_Router::create( $request->getBaseUrl() . '?controller=pin&event_id=' . $next_pin['event_id'] );
     }
     $prev_pin = Model_Pins::getPrevPin($event['event_id']);
     if($prev_pin) {
     	$view->prev_navigation_pin = WM_Router::create( $request->getBaseUrl() . '?controller=pin&event_id=' . $prev_pin['event_id'] );
     }
     */
     $image = call_user_func(array(self::formatUploadModule($event['store']), 'getEventImage'), $event, '_B');
     if ($image) {
         $event['thumb'] = $image['image'];
         $event['thumb_width'] = $image['width'];
         $event['thumb_height'] = $image['height'];
         $event['original_image'] = $image['original'];
     } else {
         JO_Action::getInstance()->forward('error', 'error404');
     }
     $image = call_user_func(array(self::formatUploadModule($event['store']), 'getEventImage'), $event, '_D');
     if ($image) {
         $event['popup'] = $image['image'];
         $event['popup_width'] = $image['width'];
         $event['popup_height'] = $image['height'];
         $event['original_image'] = $image['original'];
     } else {
         //JO_Action::getInstance()->forward('error', 'error404');
         $image = call_user_func(array(self::formatUploadModule($event['store']), 'getEventImage'), $event, '_B');
         if ($image) {
             $event['popup'] = $image['image'];
             $event['popup_width'] = $image['width'];
             $event['popup_height'] = $image['height'];
             $event['original_image'] = $image['original'];
         }
     }
     $event_description = self::descriptionFix($event['description']);
     $event['real_description'] = self::descriptionFix($event['description']);
     $event['description'] = self::descriptionFix($event['description']);
     $event['href'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']);
     //$event['date_event'] = Model_Events::cambiafyh_espanol($event['date_event']);
     $event["sport_category"] = Model_Boards::getCategoryTitle($event["sport_category"]);
     $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_user_id' => $event["user_id"]);
     $users = Model_Users::getUsers($data);
     if ($users) {
         $event['fullname'] = $users[0]["fullname"];
         $event['descriptionUser'] = $users[0]["description"];
         $avataruser = Helper_Uploadimages::avatar($users[0], '_B');
         $event['avataruser'] = $avataruser['image'];
         $event['userHref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']);
         $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']);
     }
     $event['pinmarklet_href'] = WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_pinmarklet'));
     //$event['onto_href'] = WM_Router::create( $request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $event['user_id'] . '&board_id=' . $event['board_id'] );
     //$event['price_formated'] = WM_Currency::format($event['price']);
     // esto es del autor del evento
     /*
     		
     		$view->author = $event['user_id'];
     		
     		$avatar = Helper_Uploadimages::avatar($event['user_id'], '_A');
     		$view->author['avatar'] = $avatar['image'];
     		
     		$view->author['profile'] = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id'] );
     		
     * 
     * 
     */
     //comentarios
     $view->comments = array();
     if ($event['latest_comments']) {
         foreach ($event['latest_comments'] as $key => $comment) {
             if (!isset($comment['user']['store'])) {
                 unset($event['latest_comments'][$key]);
                 continue;
             }
             $avatar = Helper_Uploadimages::avatar($comment['user'], '_A');
             $comment['user']['avatar'] = $avatar['image'];
             $comment['user']['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $comment['user_id']);
             $comment['delete'] = '';
             if (!Model_Events::commentIsReported($comment['comment_id'])) {
                 $comment['report'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=reportComment&comment_id=' . $comment['comment_id']);
             } else {
                 $comment['report'] = '';
             }
             if (JO_Session::get('user[user_id]')) {
                 if (JO_Session::get('user[is_admin]') || JO_Session::get('user[user_id]') == $comment['user_id']) {
                     $comment['delete'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=deleteComment&comment_id=' . $comment['comment_id']);
                 }
             }
             $view->comments[] = $comment;
         }
     }
     $view->get_user_friends = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
     $view->totalFollow = WM_Router::create($request->getBaseUrl() . '?controller=events&action=totalFollow');
     // no se pa que vale
     /*
     		$view->via = array();
     		$view->via_repin = array();
     		if($event['via'] && $event['user_via']) {
     			$view->via = array(
     				'profile' => WM_Router::create( $request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['via'] ),
     				'fullname' => $event['user_via']['fullname']
     			);
     		}
     		
     		$view->replin_info = false;
     		if($request->isXmlHttpRequest()) {
     			$view->target_repin = false;
     			if($event['repin_from']) {
     				$event_repin = Model_Pins::getPin($event['repin_from']);
     				if($event_repin) {
     					$view->source = array();
     					$view->source['source'] = $event_repin['board'];
     					$event['from'] = WM_Router::create( $request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $event_repin['user_id'] . '&board_id=' . $event_repin['board_id'] );
     					$view->target_repin = true;
     				} else {
     					$view->source = Model_Source::getSource($event['source_id']);
     				}
     			} else {
     				$view->source = Model_Source::getSource($event['source_id']);
     			}
     		} else {
     			$view->source = Model_Source::getSource($event['source_id']);
     			
     			
     			if($event['repin_from']) {
     				$repina = Model_Pins::getPin($event['repin_from']);
     				if($repina) {
     					$view->replin_info = array(
     						'pin_href' => WM_Router::create( $request->getBaseUrl() . '?controller=pin&event_id=' . $event['repin_from'] ),
     						'profile' => WM_Router::create( $request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $repina['user_id'] ),
     						'fullname' => $repina['user']['fullname']
     					);
     				}
     			}
     			
     		}
     		if($event['from'] && !preg_match('/^https?:\/\//',$event['from'])) {
     			$event['from'] = 'http://' . $event['from'];
     		}
     		if($event['from_repin'] && !preg_match('/^https?:\/\//',$event['from_repin'])) {
     			$event['from_repin'] = 'http://' . $event['from_repin'];
     		}
     		
     		$event['onto_board'] = $event['onto_board2'] = array();
     		$event['originally_pinned'] = $event['originally_pinned2'] = array();
     */
     /*
     if($request->isXmlHttpRequest()) {
     	$event['onto_board'] = self::getBoardPins($event['board_id']);
     	$event['originally_pinned'] = self::getOriginallyPinned( $event['via']?$event['via']:$event['user_id'] ); 
     } else {
     	$event['onto_board2'] = self::getBoardPins($event['board_id']);
     	$event['originally_pinned2'] = self::getOriginallyPinned( $event['via']?$event['via']:$event['user_id'] );
     }
     
     if($view->source && $request->isXmlHttpRequest()) {
     	$event['source_pins'] = self::getSourcePins($event['source_id']);
     } else {
     	$event['source_pins'] = array();
     }
     
     $event['boardIsFollow'] = Model_Users::isFollow(array(
     	'board_id' => $event['board_id']
     ));
     
     $event['userIsFollow'] = Model_Users::isFollowUser($event['user_id']);
     if($event['via']) {
     	$event['userViaIsFollow'] = Model_Users::isFollowUser($event['via']);
     } else {
     	$event['userViaIsFollow'] = Model_Users::isFollowUser($event['user_id']);
     }
     
     $event['userFollowIgnore'] = $event['user_id'] == JO_Session::get('user[user_id]');
     $event['userViaFollowIgnore'] = ($event['via']?$event['via']:$event['user_id']) == JO_Session::get('user[user_id]');
     
     $view->follow = WM_Router::create( $request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $event['user_id'] . '&board_id=' . $event['board_id'] );
     $view->follow_user = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $event['user_id'] );
     if($event['via']) {
     	$view->follow_user_via = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $event['via'] );
     } else {
     	$view->follow_user_via = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $event['user_id'] );
     }
     
     $view->get_user_friends = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=friends' );
     
     if(JO_Session::get('user[user_id]')) {
     	$view->enable_follow = $event['user_id'] != JO_Session::get('user[user_id]');
     } else {
     	$view->enable_follow = false;
     }
     */
     if (JO_Session::get('user[user_id]')) {
         $event['url_like'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=like&event_id=' . $event['event_id']);
         $event['url_repin'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=repin&event_id=' . $event['event_id']);
         $event['url_comment'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=comment&event_id=' . $event['event_id']);
         $event['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=comment&event_id=' . $event['event_id']);
         $event['edit'] = JO_Session::get('user[user_id]') == $event['user_id'] ? WM_Router::create($request->getBaseUrl() . '?controller=events&action=events&event_id=' . $event['event_id']) : false;
     } else {
         $event['url_like'] = $event['url_repin'] = $event['url_comment'] = $event['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=landing');
         $event['edit'] = false;
     }
     /*
     $likes = self::getPinLikes($event['event_id']);
     $event['likes'] = $likes['data'];
     $event['likes_total'] = $likes['total'];
     
     $event['repins'] = self::getRePins($event['event_id']);
     
     $event['pinIsReported'] = Model_Pins::pinIsReported($event['event_id']);
     
     $date_dif = array_shift( WM_Date::dateDiff($event['date_added'], time()) );
     $event['date_dif'] = $date_dif;
     */
     $view->loged = JO_Session::get('user[user_id]');
     $view->owner = JO_Session::get('user[user_id]') == $event["user_id"];
     $view->site_name = JO_Registry::get('site_name');
     if ($view->loged) {
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $view->self_avatar = $avatar['image'];
         $view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $view->loged);
         $view->self_fullname = JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]');
     }
     /*
     if($event['is_video']) {
     	$auto = new Helper_AutoEmbed();
     	if( $event['repin_from'] && $auto->parseUrl($event['from_repin']) ) {
     		$auto->setWidth('100%');
     		$auto->setHeight('350');
     		$event['video_code'] = $auto->getEmbedCode();
     		$attr = $auto->getObjectAttribs();
     		$event['thumb_width'] = $attr['width'];
     		$event['thumb_height'] = $attr['height'];
     	} else {
     		if( $auto->parseUrl($event['from']) ) {
     			$auto->setWidth('100%');
     			$auto->setHeight('350');
     			$event['video_code'] = $auto->getEmbedCode();
     			$attr = $auto->getObjectAttribs();
     			$event['thumb_width'] = $attr['width'];
     			$event['thumb_height'] = $attr['height'];
     		} else {
     			$event['is_video'] = false;
     		}
     	}
     } else 
                       {
     
     	$auto = new Helper_AutoEmbed();
     	if( $event['repin_from'] && $auto->parseUrl($event['from_repin']) ) {
     		$auto->setWidth('100%');
     		$auto->setHeight('350');
     		$event['video_code'] = $auto->getEmbedCode();
     		$attr = $auto->getObjectAttribs();
     		$event['thumb_width'] = $attr['width'];
     		$event['thumb_height'] = $attr['height'];
     		$event['is_video'] = true;
     	} else if( $auto->parseUrl($event['from']) ) {
     		$auto->setWidth('100%');
     		$auto->setHeight('350');
     		$event['video_code'] = $auto->getEmbedCode();
     		$attr = $auto->getObjectAttribs();
     		$event['thumb_width'] = $attr['width'];
     		$event['thumb_height'] = $attr['height'];
     		$event['is_video'] = true;
     	} else {
     		$event['is_video'] = false;
     	}
     }
     */
     $view->event_url = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']);
     //WM_Router::create( $request->getBaseUrl() . '?controller=events&event_id=' . $event['event_id'] );
     $view->login_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&next=' . urlencode($event['href']));
     $view->like_event = WM_Router::create($request->getBaseUrl() . '?controller=events&action=like&event_id=' . $event['event_id'] . '&userio_id=' . $event['user_id']);
     $view->eventIsLike = Model_Events::isLikeEvent($event['event_id'], JO_Session::get('user[user_id]'));
     $view->editEvent_url = WM_Router::create($request->getBaseUrl() . '?controller=events&action=add?event_id=' . $event['event_id']);
     $view->follow_event = WM_Router::create($request->getBaseUrl() . '?controller=events&action=follow&event_id=' . $event['event_id'] . '&userio_id=' . $event['user_id']);
     $view->eventIsFollow = Model_Events::isFollowEvent($event['event_id'], JO_Session::get('user[user_id]'));
     //Model_Pins::updateViewed($event['event_id']);
     JO_Layout::getInstance()->meta_title = $event['eventname'] . ' - ' . strip_tags(html_entity_decode($event_description));
     JO_Layout::getInstance()->placeholder('pin_url', $view->event_url);
     JO_Layout::getInstance()->placeholder('pin_description', $event_description);
     $params = array();
     $params['content'] = html_entity_decode($event_description . ' ' . $event['eventname'], ENT_QUOTES, 'UTF-8');
     //page content
     $keywords = new WM_Keywords($params);
     $get_keywords = $keywords->get_keywords();
     if ($get_keywords) {
         JO_Layout::getInstance()->placeholder('keywords', $get_keywords);
     }
     JO_Layout::getInstance()->placeholder('pin_image', $event['thumb']);
     JO_Layout::getInstance()->placeholder('board_title', $event['eventname']);
     /*
     $view->banners = array();
     if($banners) {
     	foreach($banners AS $banner1) {
     		foreach($banner1 AS $e) {
     			$e['html'] = html_entity_decode($e['html']);
     			$view->banners[] = $e;
     		}
     	}
     }
     */
     $view->event = $event;
     return $view->render('eventBoxDetail', 'events');
 }
示例#5
0
 public function editAction()
 {
     //		var_dump( htmlspecialchars('⚐') );exit;
     $request = $this->getRequest();
     $pin_id = $request->getRequest('pin_id');
     // 		$pin_info = Model_Pins::getPin($pin_id);
     $pin_info = new Model_Pins_Pin($pin_id);
     if (!$pin_info->count() || $pin_info->data['pin_user_id'] != JO_Session::get('user[user_id]')) {
         $this->forward('error', 'error404');
     }
     $pin_info = $pin_info->data;
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         if ($pin_info['pin_from']) {
             $validate->_set_rules($request->getPost('from'), $this->translate('Link'), 'not_empty;min_length[3];domain');
         } else {
             if (trim($request->getPost('from'))) {
                 $validate->_set_rules($request->getPost('from'), $this->translate('Link'), 'not_empty;min_length[3];domain');
             }
         }
         $data = $request->getPost();
         if ($validate->_valid_form()) {
             $edit = new Model_Pins_Edit($pin_id, $request->getPost());
             $this->redirect(WM_Router::pinAction($pin_info['pin_pin_id']));
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
         foreach ($data as $k => $v) {
             if (isset($pin_info['pin_' . $k])) {
                 $pin_info['pin_' . $k] = $v;
             }
         }
     }
     $pin_info['images'] = Helper_Uploadimages::pinThumbs($pin_info);
     if ($pin_info['pin_gift']) {
         $pin_info['price_formated'] = WM_Currency::format($pin_info['pin_price']);
     } else {
         $pin_info['price_formated'] = '';
         $pin_info['pin_price'] = 0;
     }
     $pin_info['href'] = WM_Router::pinAction($pin_info['pin_pin_id']);
     $this->view->pin_info = $pin_info;
     $view->get_user_friends = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
     $boards = new Model_Boards_BoardsWithShared(array('filter_user_id' => JO_Session::get('user[user_id]')));
     $this->view->boards = array();
     if ($boards->count()) {
         foreach ($boards as $board) {
             $this->view->boards[] = array('board_id' => $board['board_board_id'], 'title' => $board['board_title']);
         }
     }
     ///////////////// Extension on edit //////////////////
     $this->view->form_extensions = array();
     $extensions = Model_Extensions::getByMethod('pin_oneditform');
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $this->view->form_extensions[] = array('html' => $this->view->callChildren('modules_' . $ext . '_oneditform'), 'view' => $this->view->callChildrenView('modules_' . $ext . '_oneditform'), 'key' => $ext);
         }
     }
     $this->view->pin_delete = WM_Router::pinAction($pin_id, 'delete');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#6
0
 public function mailfriendsAction()
 {
     $request = $this->getRequest();
     $this->view->users = array();
     if ((int) JO_Session::get('user[user_id]') && $request->getPost('term')) {
         $friends = Model_Users::getUserMailFriends(array('start' => 0, 'limit' => 100, 'filter_username' => $request->getPost('term'), 'filter_activate' => $request->getPost('act'), 'filter_voluntarios' => $request->getPost('vol')));
         if ($friends) {
             $model_images = new Helper_Images();
             foreach ($friends as $friend) {
                 if (!isset($friend['store'])) {
                     continue;
                 }
                 $avatar = Helper_Uploadimages::avatar($friend, '_A');
                 $this->view->users[] = array('image' => $avatar['image'], 'label' => $friend['fullname'], 'value' => $friend['user_id'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $friend['user_id']), 'username' => $friend['username']);
             }
         }
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->renderScript('json');
     } else {
         $this->forward('error', 'error404');
     }
 }
示例#7
0
 public function sendWeeklyAction()
 {
     $request = $this->getRequest();
     $this->view->base_href = $request->getBaseUrl();
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->on_facebook = JO_Registry::get('config_on_facebook');
     $this->view->site_logo = $this->view->base_href . 'data/images/logo.png';
     if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('site_logo'))) {
         $this->view->site_logo = $this->view->base_href . 'uploads' . JO_Registry::get('site_logo');
     }
     $this->view->settings = WM_Router::create($this->view->base_href . '?controller=prefs');
     $goodies = Model_Pages::getPage(JO_Registry::get('page_goodies'));
     if ($goodies) {
         //$this->view->pin_it = WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_goodies'));
         $this->view->pin_it = 'http://amatteur.com/apps';
     }
     $this->view->pages = array();
     $page = Model_Pages::getPage(JO_Registry::get('page_privacy_policy'));
     if ($page) {
         $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy')));
     }
     $page = Model_Pages::getPage(JO_Registry::get('page_terms'));
     if ($page) {
         $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy')));
     }
     $histories = Model_History::getHistoryToday(array('week_range' => WM_Date::x_week_range($this->now)));
     $no_avatar = JO_Registry::get('no_avatar');
     if ($histories) {
         $model_images = new Helper_Images();
         /* BOARDS */
         $this->view->popular_bards = array();
         $populars = Model_Boards::getBoards(array('start' => 0, 'limit' => 6, 'sort' => 'DESC', 'order' => 'boards.total_views', 'where' => new JO_Db_Expr('pins > 4')));
         if ($populars) {
             foreach ($populars 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 = call_user_func(array(Helper_Pin::formatUploadModule($board['pins_array'][$i]['store']), 'getPinImage'), $board['pins_array'][$i], $size);
                         if ($data_img) {
                             $board['thumbs'][] = $data_img['image'];
                         } else {
                             $board['thumbs'][] = false;
                         }
                     } else {
                         $board['thumbs'][] = false;
                     }
                 }
                 $board['user'] = Model_Users::getUser($board['user_id']);
                 $board['user']['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $board['user_id']);
                 $avatar = Helper_Uploadimages::avatar($board['user'], '_A');
                 $board['user']['avatar'] = $avatar['image'];
                 $this->view->popular_bards[] = $board;
             }
         }
         /* VIDEO */
         //			$this->view->video = array();
         //			$video = Model_Pins::getPins(array(
         //				'start' => 0,
         //				'limit' => 1,
         //				'filter_is_video' => 1
         //			));
         //
         //			if($video) {
         //				foreach($video AS $pin) {
         //					$pin['thumb'] = $model_images->resizeWidth($pin['image'], 194);
         //					$pin['thumb_width'] = $model_images->getSizes('width');
         //					$pin['thumb_height'] = $model_images->getSizes('height');
         //					$pin['description'] = Helper_Pin::descriptionFix($pin['description']);
         //					$pin['href'] = WM_Router::create( $request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id'] );
         //
         //				}
         //			}
         /* HISTORY */
         foreach ($histories as $history) {
             if (!isset($history['store'])) {
                 continue;
             }
             $avatar = Helper_Uploadimages::avatar($history, '_B');
             $history['avatar'] = $avatar['image'];
             $history['user_followers'] = WM_Router::create($this->view->base_href . '?controller=users&action=followers&user_id=' . $history['user_id']);
             $history['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $history['user_id']);
             $history['history_comments_total'] = count($history['history_comments']);
             $history['history_follow_total'] = count($history['history_follow']);
             $history['history_like_total'] = count($history['history_like']);
             $history['history_repin_total'] = count($history['history_repin']);
             $history['history_event_total'] = count($history['history_event']);
             /////comments
             if ($history['history_comments_total']) {
                 foreach ($history['history_comments'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_comments'][$k]['avatar'] = $avatar['image'];
                     $history['history_comments'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             /////follow
             if ($history['history_follow_total']) {
                 foreach ($history['history_follow'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_follow'][$k]['avatar'] = $avatar['image'];
                     $history['history_follow'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             /////like
             if ($history['history_like_total']) {
                 foreach ($history['history_like'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_like'][$k]['avatar'] = $avatar['image'];
                     $history['history_like'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             /////repin
             if ($history['history_repin_total']) {
                 foreach ($history['history_repin'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_repin'][$k]['avatar'] = $avatar['image'];
                     $history['history_repin'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             ////events
             if ($history['history_event_total']) {
                 foreach ($history['history_event'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::event($v, '_A');
                     $history['history_event'][$k]['avatar'] = $avatar['image'];
                     $history['history_event'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             $this->view->events = array();
             $this->view->event = array();
             $dataEvents = array('filter_cron' => $history['user_id']);
             $events = Model_Events::getEvents($dataEvents);
             if ($events) {
                 foreach ($events as $key => $event) {
                     $href = "";
                     $view = JO_View::getInstance();
                     $view->loged = JO_Session::get('user[user_id]');
                     $model_images = new Helper_Images();
                     $avatar = Helper_Uploadimages::avatar($event, '_B');
                     $event['avatar'] = $avatar['image'];
                     $event['thumbs'] = $avatar['image'];
                     $event["sport_category"] = Model_Boards::getCategoryTitle($event["sport_category"]);
                     $data = array('filter_user_id' => $event["user_id"]);
                     $users = Model_Users::getUsers($data);
                     if ($users) {
                         $event['fullname'] = $users[0]["fullname"];
                         $event['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']);
                         $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']);
                     }
                     //$view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=boxeventdetail&event_id=' . $event['event_id']);
                     $view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']);
                     $this->view->event[] = $event;
                     $view->event = $event;
                     $this->view->events[] = $view->render('boxEvent', 'events');
                 }
             }
             /* PINS */
             $likes = Model_History::getHistory(array('history_action' => Model_History::LIKEPIN, 'start' => 0, 'limit' => 30), 'from_user_id', $history['user_id']);
             $history['pins_likes'] = array();
             if ($likes) {
                 $temp = array();
                 foreach ($likes as $like) {
                     $temp[$like['pin_id']] = $like['pin_id'];
                 }
                 if ($temp) {
                     $pins = Model_Pins::getPins(array('start' => 0, 'limit' => 9, 'filter_id_in' => implode(',', $temp)));
                     if ($pins) {
                         foreach ($pins as $pin) {
                             $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B');
                             if ($image) {
                                 $pin['thumb'] = $image['image'];
                                 $pin['thumb_width'] = $image['width'];
                                 $pin['thumb_height'] = $image['height'];
                             } else {
                                 continue;
                             }
                             $pin['description'] = Helper_Pin::descriptionFix($pin['description']);
                             $pin['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
                             $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']);
                             $avatar = Helper_Uploadimages::avatar($pin['user'], '_A');
                             $pin['user']['avatar'] = $avatar['image'];
                             $pin['user']['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $pin['user_id']);
                             $pin['via_profile'] = array();
                             if ($pin['via'] && $pin['user_via']) {
                                 $pin['via_profile'] = array('profile' => WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $pin['via']), 'fullname' => $pin['user_via']['fullname']);
                             }
                             $history['pins_likes'][] = $pin;
                         }
                     }
                 }
             }
             $this->view->history = $history;
             $html = $this->view->render('sendWeekly', 'crons');
             Model_Email::send($history['email'], JO_Registry::get('noreply_mail'), sprintf($this->translate('Weekly %s'), $this->view->site_name), $html);
         }
     }
 }
示例#8
0
 public function getFriendsAction()
 {
     $request = $this->getRequest();
     $facebookObject = new Model_Facebook_Login();
     $follows = $facebookObject->getFacebookFriends();
     $facebook = new Helper_Modules_Facebook();
     $facebook_friends = $this->getFriends();
     if ($facebook_friends === false && (!JO_Session::get('redirect_fb_login') || (int) JO_Session::get('redirect_fb_login') < time())) {
         $this->view->redirect = $facebook->getLoginUrl(WM_Router::create($request->getBaseUrl() . '?controller=modules_facebook_invates'), 'modules_facebook_login');
         JO_Session::set('redirect_fb_login', time() + 100);
         echo $this->renderScript('json');
         exit;
     }
     //$facebook_friends = $this->getFriends();
     $follow_friends_array = array();
     if ($follows) {
         $follow_friends = new Model_Users_UsersInId($follows);
         if ($follow_friends->count()) {
             foreach ($follow_friends as $ff) {
                 foreach ($follows as $fr_fb => $fr_pi) {
                     if ($fr_pi == $ff['user_id']) {
                         $follow_friends_array[$fr_fb] = $ff;
                     }
                 }
             }
         }
     }
     $this->view->fb_friends = array();
     if ($facebook_friends) {
         $friends = $this->formatUsers($facebook_friends);
         if ($friends) {
             $facebook_ids = array();
             foreach ($friends as $fr) {
                 $facebook_ids[] = $fr['id'];
             }
             $not_follow_users = $facebookObject->getFacebookFriendsNotFollowByIds($facebook_ids);
             if (!$not_follow_users) {
                 $not_follow_users = array();
             }
             $model_images = new Helper_Images();
             foreach ($friends as $friend) {
                 if (array_key_exists($friend['id'], $follow_friends_array)) {
                     $user_data = $follow_friends_array[$friend['id']];
                     if ($user_data) {
                         $avatar = Helper_Uploadimages::avatar($user_data, '_A');
                         $this->view->fb_friends['friends_unfollow'][] = array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user_data['user_id']), 'follow_user' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user_data['user_id']), 'avatar' => $avatar['image'], 'name' => $user_data['fullname'], 'user_id' => $user_data['user_id'], 'template' => 'facebook/friends_unfollow', 'text_unfollow' => $this->translate('Unfollow'), 'text_follow' => $this->translate('Follow'));
                     }
                 } else {
                     if (array_key_exists($friend['id'], $not_follow_users)) {
                         $user_data = $not_follow_users[$friend['id']];
                         if ($user_data) {
                             $avatar = Helper_Uploadimages::avatar($user_data, '_A');
                             $this->view->fb_friends['friends_follow'][] = array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user_data['user_id']), 'follow_user' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user_data['user_id']), 'avatar' => $avatar['image'], 'name' => $user_data['fullname'], 'user_id' => $user_data['user_id'], 'template' => 'facebook/friends_follow', 'text_unfollow' => $this->translate('Unfollow'), 'text_follow' => $this->translate('Follow'));
                         }
                     } else {
                         if (!$facebookObject->checkInvateFacebookIDSelf($friend['id'], JO_Session::get('user[user_id]'))) {
                             $this->view->fb_friends['friends_invate'][] = array('profile' => 'http://facebook.com/' . $friend['id'], 'key' => $friend['key'], 'avatar' => $friend['avatar'], 'id' => $friend['id'], 'name' => $friend['name'], 'template' => 'facebook/friends_invate', 'text_invate' => $this->translate('Invite'));
                         }
                     }
                 }
             }
         }
     }
     echo $this->renderScript('json');
 }
示例#9
0
 public function indexAction()
 {
     $request = $this->getRequest();
     //////////// 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;
     }
     //////////// User Type ////////////
     $this->view->user_types = array();
     $user_types = Model_Users::getUserType(array('filter_status' => 1));
     foreach ($user_types as $user_type) {
         $user_type['subuser_types'] = Model_Users::getSubUserType($user_type['user_type_id']);
         $this->view->user_types[] = $user_type;
     }
     /////////// activate //////////
     $_SESSION["activate_url"] = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     $this->view->popup_activate = WM_Router::create($request->getBaseUrl() . '?controller=users&action=activate');
     $_SESSION["deportes_url"] = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     $this->view->deportes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=deportes');
     $this->view->user_sports = array();
     $users_sports = Model_Users::getUserSports(JO_Session::get('user[user_id]'));
     $i = 0;
     foreach ($users_sports as $user_sports) {
         if ($user_sports['sport_category'] != 1) {
             if (!Model_Boards::isCategoryParent($user_sports['sport_category'])) {
                 $this->view->user_sports[] = Model_Boards::getCategoryTitle($user_sports['sport_category']);
                 $i++;
             }
         }
     }
     $this->view->sportcounter = $i;
     $user_data = Model_Users::getUser(JO_Session::get('user[user_id]'));
     $upload = new JO_Upload_SessionStore();
     $upload->setName('upload_avatar');
     $info = $upload->getFileInfo();
     if (JO_Session::get('successfu_edite')) {
         $this->view->successfu_edite = true;
         JO_Session::clear('successfu_edite');
     }
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         $validate->_set_rules($request->getPost('username'), $this->translate('Username'), 'not_empty;min_length[3];max_length[100];username');
         $validate->_set_rules($request->getPost('firstname'), $this->translate('First name'), 'not_empty;min_length[3];max_length[100]');
         //$validate->_set_rules($request->getPost('lastname'), $this->translate('Last name'), 'not_empty;min_length[3];max_length[100]');
         $validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email');
         if ($request->issetPost('type_user')) {
             if ($request->getPost('type_user') != 1 && $request->getPost('type_user') != 5 && $request->getPost('type_user') != 12) {
                 $validate->_set_rules($request->getPost('location'), $this->translate('Location'), 'not_empty;min_length[3];max_length[100]');
             }
         }
         $validate->_set_rules($request->getPost('sports'), $this->translate('Category_id1'), 'not_empty;min_length[3];max_length[100]');
         //is_nan() sino
         /*
                                 if($request->getPost('sport_category_1') == "" && $request->getPost('sport_category_2') == "" && $request->getPost('sport_category_3') == "") {
                                     $validate->_set_rules($request->getPost('sport_category'), $this->translate('Category_id'), 'not_empty;min_length[3];max_length[100]');
         
                                 }
                                  * */
         //$validate->_set_rules($request->getPost('sport_category_1'), $this->translate('Category_id1'), 'not_empty;min_length[3];max_length[100]');
         //$validate->_set_rules($request->getPost('sport_category_2'), $this->translate('Category_id2'), 'not_empty;min_length[3];max_length[100]');
         //$validate->_set_rules($request->getPost('sport_category_3'), $this->translate('Category_id3'), 'not_empty;min_length[3];max_length[100]');
         $validate->_set_rules($request->getPost('type_user'), $this->translate('User_type_id'), 'not_empty;min_length[1];max_length[100]');
         $data = $request->getPost();
         if ($validate->_valid_form()) {
             if (Model_Users::isExistEmail($request->getPost('email'), JO_Session::get('user[email]'))) {
                 $validate->_set_form_errors($this->translate('This e-mail address is already used'));
                 $validate->_set_valid_form(false);
             }
             if (Model_Users::isExistUsername($request->getPost('username'), JO_Session::get('user[username]'))) {
                 $validate->_set_form_errors($this->translate('This username is already used'));
                 $validate->_set_valid_form(false);
             }
         }
         if ($validate->_valid_form()) {
             $data['dont_search_index'] = (int) $request->issetPost('dont_search_index');
             $data['facebook_timeline'] = (int) $request->issetPost('facebook_timeline');
             if ($info) {
                 if (!@file_exists(BASE_PATH . '/cache/avatar/') || !is_dir(BASE_PATH . '/cache/avatar/')) {
                     mkdir(BASE_PATH . '/cache/avatar/');
                 }
                 $filename = BASE_PATH . '/cache/avatar/' . md5(mt_rand() . time()) . $upload->get_extension($info['name']);
                 if (file_put_contents($filename, $info['data'])) {
                     $data['avatar'] = $filename;
                 }
             }
             $new_email_key = md5(JO_Session::get('user[email]') . mt_rand() . time());
             if (JO_Session::get('user[email]') != $request->getPost('email')) {
                 $data['new_email_key'] = $new_email_key;
             } else {
                 $data['new_email_key'] = '';
             }
             $data['new_email'] = $data['email'];
             unset($data['email']);
             /*
             $lat = $data['lat'];
             $len = $data['len'];
             
             while(Model_Users::getUsersLatLen($lat,$len))
             {
             
                 $posLat = strpos($lat, ".");
                 $longLat = strlen(substr((string)$lat, $posLat));
                 $cantLat = 0;
                 for ($i = 0; $i < ($longLat - 4); $i++)
                 {
                     if ($i == 0)
                     {
                         $cantLat .= ".0";
                     }
                     else
                     {
                         $cantLat .= "0";
                     }
                 }
                 $cantLat .= "1";
                 $lat = $lat + $cantLat;
             
                 $posLen = strpos($len, ".");
                 $longLen = strlen(substr((string)$len, $posLen));
                 $cantLen = 0;
                 for ($i = 0; $i < ($longLen - 4); $i++)
                 {
                     if ($i == 0)
                     {
                         $cantLen .= ".0";
                     }
                     else
                     {
                         $cantLen .= "0";
                     }
                 }
                 $cantLen .= "1";
                 $len = $len + $cantLen;
             }
             
             $data['lat'] = $lat;
             $data['len'] = $len;
             */
             if (Model_Users::edit(JO_Session::get('user[user_id]'), $data)) {
                 JO_Session::set('successfu_edite', true);
                 $upload->getFileInfo(true);
                 if (JO_Session::get('user[email]') != $request->getPost('email')) {
                     $this->view->verify_email_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . JO_Session::get('user[user_id]') . '&verify=' . $new_email_key);
                     $this->view->user_info = $user_data;
                     Model_Email::send($request->getPost('email'), JO_Registry::get('noreply_mail'), $this->translate('Please verify your email'), $this->view->render('verify_email', 'mail'));
                 }
                 if (!Model_Users::getUserTypeNotOthers($user_data['type_user'])) {
                     $data['activate'] = 0;
                     //borrar activate
                     if (Model_Users::createActivate(JO_Session::get('user[user_id]'), $data)) {
                     }
                 }
                 if (Model_Users::deleteUsersLocation(JO_Session::get('user[user_id]'))) {
                     for ($i = 0; $i <= $request->getPost('locationcounter'); $i++) {
                         $location = 'location' . $i;
                         $lat = 'lat' . $i;
                         $len = 'len' . $i;
                         if ($request->issetPost($location)) {
                             if ($request->getPost($location) != "") {
                                 $lat = $request->getPost($lat);
                                 $len = $request->getPost($len);
                                 while (Model_Users::getLocationUsersLatLen($lat, $len)) {
                                     $posLat = strpos($lat, ".");
                                     $longLat = strlen(substr((string) $lat, $posLat));
                                     $cantLat = 0;
                                     for ($i = 0; $i < $longLat - 4; $i++) {
                                         if ($i == 0) {
                                             $cantLat .= ".0";
                                         } else {
                                             $cantLat .= "0";
                                         }
                                     }
                                     $cantLat .= "1";
                                     $lat = $lat + $cantLat;
                                     $posLen = strpos($len, ".");
                                     $longLen = strlen(substr((string) $len, $posLen));
                                     $cantLen = 0;
                                     for ($i = 0; $i < $longLen - 4; $i++) {
                                         if ($i == 0) {
                                             $cantLen .= ".0";
                                         } else {
                                             $cantLen .= "0";
                                         }
                                     }
                                     $cantLen .= "1";
                                     $len = $len + $cantLen;
                                 }
                                 if (Model_Users::createUsersLocation(JO_Session::get('user[user_id]'), $request->getPost($location), $lat, $len)) {
                                 }
                             }
                         }
                     }
                 }
                 $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=settings'));
             } else {
                 $this->view->error = $this->translate('There was a problem with the record. Please try again!');
             }
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
         foreach ($data as $k => $v) {
             if (isset($user_data[$k])) {
                 $user_data[$k] = $v;
             }
         }
     }
     if ($info) {
         $user_data['avatar'] = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=temporary_avatar&s=' . microtime(true));
         $user_data['has_avatar'] = true;
     } else {
         $avatar = Helper_Uploadimages::avatar($user_data, '_B');
         $user_data['avatar'] = $avatar['image'] . '?s=' . microtime(true);
         $user_data['has_avatar'] = @getimagesize($user_data['avatar']) ? true : false;
     }
     //////////// User location ////////////
     $this->view->user_location = array();
     $this->view->user_lat = array();
     $this->view->user_len = array();
     $this->view->locationcounter = 0;
     if ($request->issetPost('location1')) {
         $user_location = array();
         $user_lat = array();
         $user_len = array();
         for ($i = 1; $i <= $request->getPost('locationcounter'); $i++) {
             $location = 'location' . $i;
             $lat = 'lat' . $i;
             $len = 'len' . $i;
             if ($request->issetPost($location)) {
                 if ($request->getPost($location) != "") {
                     $user_location[] = $request->getPost($location);
                     $user_lat[] = $request->getPost($lat);
                     $user_len[] = $request->getPost($len);
                 }
             }
         }
         $this->view->user_location = $user_location;
         $this->view->user_lat = $user_lat;
         $this->view->user_len = $user_len;
         $this->view->locationcounter = $request->getPost('locationcounter');
     } else {
         $users_location = Model_Users::getUserLocation(JO_Session::get('user[user_id]'));
         $i = 0;
         foreach ($users_location as $user_location) {
             $this->view->user_location[] = $user_location['location'];
             $this->view->user_lat[] = $user_location['lat'];
             $this->view->user_len[] = $user_location['len'];
             $i++;
         }
         $this->view->locationcounter = $i;
     }
     $this->view->location = '';
     if ($request->issetPost('location')) {
         $this->view->location = $request->getPost('location');
     } else {
         $this->view->location = '';
     }
     $this->view->cat_title1 = '';
     $this->view->sport_category_1 = '';
     if ($request->issetPost('sport_category_1')) {
         $this->view->sport_category_1 = $request->getPost('sport_category_1');
         if ($request->getPost('sport_category_1') != "") {
             if ($request->getPost('sport_category_1') == 1) {
                 $this->view->cat_title1 = "Todo";
             } else {
                 $this->view->cat_title1 = Model_Boards::getCategoryTitle($request->getPost('sport_category_1'));
             }
         }
     } else {
         if ($user_data['sport_category_1'] != "") {
             $this->view->sport_category_1 = $user_data['sport_category_1'];
             if ($user_data['sport_category_1'] == 1) {
                 $this->view->cat_title1 = "Todo";
             } else {
                 $this->view->cat_title1 = Model_Boards::getCategoryTitle($user_data['sport_category_1']);
             }
         }
     }
     $this->view->cat_title2 = '';
     $this->view->sport_category_2 = '';
     if ($request->issetPost('sport_category_2')) {
         $this->view->sport_category_2 = $request->getPost('sport_category_2');
         if ($request->getPost('sport_category_2') != "") {
             if ($request->getPost('sport_category_2') == 1) {
                 $this->view->cat_title2 = "Todo";
             } else {
                 $this->view->cat_title2 = Model_Boards::getCategoryTitle($request->getPost('sport_category_2'));
             }
         }
     } elseif ($user_data['sport_category_2'] != "") {
         $this->view->sport_category_2 = $user_data['sport_category_2'];
         if ($user_data['sport_category_2'] == 1) {
             $this->view->cat_title2 = "Todo";
         } else {
             $this->view->cat_title2 = Model_Boards::getCategoryTitle($user_data['sport_category_2']);
         }
     }
     $this->view->cat_title3 = '';
     $this->view->sport_category_3 = '';
     if ($request->issetPost('sport_category_3')) {
         $this->view->sport_category_3 = $request->getPost('sport_category_3');
         if ($request->getPost('sport_category_3') != "") {
             if ($request->getPost('sport_category_3') == 1) {
                 $this->view->cat_title3 = "Todo";
             } else {
                 $this->view->cat_title3 = Model_Boards::getCategoryTitle($request->getPost('sport_category_3'));
             }
         }
     } elseif ($user_data['sport_category_3'] != "") {
         $this->view->sport_category_3 = $user_data['sport_category_3'];
         if ($user_data['sport_category_3'] == 1) {
             $this->view->cat_title3 = "Todo";
         } else {
             $this->view->cat_title3 = Model_Boards::getCategoryTitle($user_data['sport_category_3']);
         }
     }
     $this->view->usertype_title = '';
     $this->view->type_user = '';
     if ($request->issetPost('type_user')) {
         $this->view->type_user = $request->getPost('type_user');
         if ($request->getPost('type_user') != "") {
             $this->view->usertype_title = Model_Users::getUserTypeTitle($request->getPost('type_user'));
         }
     } elseif ($user_data['type_user'] != "") {
         $this->view->type_user = $user_data['type_user'];
         $this->view->usertype_title = Model_Users::getUserTypeTitle($user_data['type_user']);
     }
     if ($request->issetPost('activate')) {
         $this->view->activate = $request->getPost('activate');
     } else {
         $activate = Model_Users::getActivateUser(JO_Session::get('user[user_id]'));
         if ($activate) {
             $this->view->activate = $activate["activate"];
         } else {
             $this->view->activate = "";
         }
     }
     $this->view->instagram_enable = JO_Registry::get('oauth_in_key');
     $this->view->twitteroauth_enable = JO_Registry::get('oauth_tw_key');
     $this->view->facebook_enable = JO_Registry::get('oauth_fb_key');
     $this->view->user_data = $user_data;
     $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=upload_avatar');
     $this->view->invites_fb = WM_Router::create($request->getBaseUrl() . '?controller=invites&action=facebook');
     $this->view->facebook_connect = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=facebook_connect');
     $this->view->twitter_connect = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=twitter_connect');
     $this->view->instagram_connect = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=instagram_connect');
     $this->view->instagram_fetch = WM_Router::create($request->getBaseUrl() . '?controller=instagram&action=media');
     $this->view->instagram_fetch_cron = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=instagram_cron');
     $this->view->facebook_connect_avatar = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=facebook_connect_avatar');
     $this->view->check_username = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=check_username');
     $this->view->delete_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=delete&user_id=' . $user_data['user_id']);
     $this->view->facebook_connect2 = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=facebook_connect2');
     $this->view->prefs_action = WM_Router::create($request->getBaseUrl() . '?controller=prefs');
     $this->view->new_password = WM_Router::create($request->getBaseUrl() . '?controller=password&action=change');
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->base_href = $request->getBaseUrl();
     $this->view->delete_account = '';
     if (JO_Registry::get('delete_account')) {
         $page_description = Model_Pages::getPage(JO_Registry::get('delete_account'));
         if ($page_description) {
             $this->view->delete_account = html_entity_decode($page_description['description'], ENT_QUOTES, 'utf-8');
         }
     }
     // si llama a los deportes
     if (isset($_SESSION["email"])) {
         $this->view->email = $_SESSION["email"];
         $_SESSION["email"] = null;
     }
     if (isset($_SESSION["firstname"])) {
         $this->view->firstname = $_SESSION["firstname"];
         $_SESSION["firstname"] = null;
     }
     if (isset($_SESSION["username"])) {
         $this->view->username = $_SESSION["username"];
         $_SESSION["username"] = null;
     }
     if (isset($_SESSION["password"])) {
         $this->view->password = $_SESSION["password"];
         $_SESSION["password"] = null;
     }
     if (isset($_SESSION["password2"])) {
         $this->view->password2 = $_SESSION["password2"];
         $_SESSION["password2"] = null;
     }
     if (isset($_SESSION["info"])) {
         $this->view->info = $_SESSION["info"];
         $_SESSION["info"] = null;
     }
     if (isset($_SESSION["location"])) {
         $this->view->location = $_SESSION["location"];
         $_SESSION["location"] = null;
     }
     if (isset($_SESSION["lat"])) {
         $this->view->lat = $_SESSION["lat"];
         $_SESSION["lat"] = null;
     }
     if (isset($_SESSION["len"])) {
         $this->view->len = $_SESSION["len"];
         $_SESSION["len"] = null;
     }
     if (isset($_SESSION["type_user"])) {
         if ($_SESSION["type_user"] != "") {
             $this->view->type_user = $_SESSION["type_user"];
             $this->view->usertype_title = Model_Users::getUserTypeTitle($_SESSION["type_user"]);
         }
         $_SESSION["type_user"] = null;
     }
     if (isset($_SESSION["location1"])) {
         $user_location = array();
         for ($i = 1; $i <= $_SESSION['locationcounter']; $i++) {
             $location = 'location' . $i;
             if (isset($_SESSION[$location])) {
                 if ($_SESSION[$location] != "") {
                     $user_location[] = $_SESSION[$location];
                     $_SESSION[$location] = null;
                 }
             }
         }
         $this->view->user_location = $user_location;
         $this->view->locationcounter = $_SESSION['locationcounter'];
         $_SESSION['locationcounter'] = null;
     }
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#10
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) {
         new Model_Users_Edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
         JO_Session::clear('category_id');
         $template = Model_Notification::getTemplate('welcome');
         if ($template) {
             $template_data = array('user_id' => JO_Session::get('user[user_id]'), 'user_firstname' => JO_Session::get('user[firstname]'), 'user_lastname' => JO_Session::get('user[lastname]'), 'user_fullname' => JO_Session::get('user[fullname]'), 'user_username' => JO_Session::get('user[username]'), 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
             if (!$template['title']) {
                 $template['title'] = $this->translate('Welcome to ${site_name}!');
             }
             $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(JO_Session::get('user[email]'), Helper_Config::get('noreply_mail'), $title, $body);
         }
     }
     $this->view->show_landing = !Helper_Config::get('enable_free_registration');
     $this->getLayout()->placeholder('site_name', Helper_Config::get('site_name'));
     $this->view->site_name = Helper_Config::get('site_name');
     $this->view->meta_title = Helper_Config::get('meta_title');
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(Helper_Config::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (Helper_Config::get('site_logo') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . Helper_Config::get('site_logo');
     }
     ///global metas
     if (!JO_Layout::getInstance()->placeholder('header_metas')) {
         $to_title = '';
         if (JO_Session::get('user[user_id]')) {
             $to_title = JO_Session::get('user[fullname]') . ' / ';
         }
         $this->getLayout()->placeholder('title', $to_title . Helper_Config::get('meta_title'));
         JO_Layout::getInstance()->placeholder('header_metas', $this->view->callChildren('layout/header_metas', array('meta_title' => Helper_Config::get('meta_title'), 'meta_description' => Helper_Config::get('meta_description'), 'meta_keywords' => Helper_Config::get('meta_keywords'), 'site_logo' => $this->view->site_logo)));
     }
     if (Helper_Config::get('favicon') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('favicon'))) {
         $this->getLayout()->placeholder('favicon', $request->getBaseUrl() . 'uploads' . Helper_Config::get('favicon'));
     }
     $this->getLayout()->placeholder('site_logo', $this->view->site_logo);
     $this->view->show_header_invate = !JO_Session::get('user[user_id]');
     $this->view->controller_open = $request->getController();
     //==== brand =====//
     $this->view->show_brand = false;
     /*if( JO_Registry::get('license_powered_check') == 'false' && Helper_Config::get('config_hide_brand') ) {
     			$this->view->show_brand = false;
     		}*/
     ////////// CURRENCY
     //autoupdate currency if set
     if (Helper_Config::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
     }
     //////////// Categories ////////////
     $this->view->categories = array();
     $this->view->category_active = false;
     $categories = Model_Categories::getCategories(array('filter_status' => 1));
     foreach ($categories as $category) {
         $category['href'] = WM_Router::create($request->getBaseUrl() . '?controller=category&category_id=' . $category['category_id']);
         $category['active'] = $category['category_id'] == $request->getRequest('category_id');
         if ($category['active']) {
             $this->view->category_active = $category['title'];
         } else {
         }
         $this->view->categories[] = $category;
     }
     ////////////////////////////// USER MENU ///////////////////////////
     $this->view->is_loged = JO_Session::get('user[user_id]');
     if ($this->view->is_loged) {
         $model_images = new Helper_Images();
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $this->view->self_avatar = Helper_Uploadimages::userAvatars(JO_Session::get('user'));
         $this->view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $this->view->is_loged);
         $this->view->self_firstname = JO_Session::get('user[firstname]');
         $this->view->logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
         $this->view->user_pins = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged);
         $this->view->user_pins_likes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged . '&filter=likes');
         $this->view->settings = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     $this->view->landing = WM_Router::create($request->getBaseUrl() . '?controller=landing');
     $this->view->registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register');
     ////////////////////////////// GIFTS ///////////////////////////
     $this->view->gifts = WM_Router::create($request->getBaseUrl() . '?controller=gifts');
     $this->view->giftSums = array();
     $sums = Model_Gifts::getAll();
     foreach ($sums as $sum) {
         if ($sum['price_from'] || $sum['price_to']) {
             $title = WM_Currency::format($sum['price_from']);
             $url = '';
             if ($sum['price_to']) {
                 $title .= ' - ';
                 $title .= WM_Currency::format($sum['price_to']);
                 $url = '&price_to=' . $sum['price_to'];
             } else {
                 $title .= '+';
             }
             $this->view->giftSums[] = array('title' => $title, 'href' => WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=' . $sum['price_from'] . $url));
         }
     }
     //////////// Video ////////////
     $this->view->video_url = WM_Router::create($request->getBaseUrl() . '?controller=videos');
     //////////// Popular ////////////
     $this->view->popular_url = WM_Router::create($request->getBaseUrl() . '?controller=popular');
     //////////// ALL PINS ////////////
     $this->view->all_url = WM_Router::create($request->getBaseUrl() . '?controller=all');
     ////////////////////////////// SEARCH ///////////////////////////
     //$this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     if ($request->getAction() != 'index' && $request->getController() == 'search') {
         $with_action = $request->getAction();
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction());
     } else {
         $with_action = 0;
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     }
     $this->view->search_autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete');
     if (strpos($this->view->search, '?') !== false) {
         $this->view->show_hidden = true;
         $this->view->with_action = $with_action;
     }
     $this->view->keywords = $request->issetQuery('q') ? $request->getQuery('q') : $this->translate('Search');
     ////////////////////////////// ADD PIN ///////////////////////////
     $this->view->addPin = WM_Router::create($request->getBaseUrl() . '?controller=addpin');
     ////////////////////////////// user ignore search engine ///////////////////////////
     if ($request->getRequest('user_id')) {
         $user_info = Model_Users::getUser($request->getRequest('user_id'));
         if ($user_info && $user_info['dont_search_index']) {
             $this->getLayout()->placeholder('inhead', '<meta name="robots" content="noindex"/>');
         }
     }
     ////////////////////////////// ABOUT MENU ///////////////////////////
     $about_menu = Model_Pages::getMenu(0);
     $this->view->about_menu = array();
     foreach ($about_menu as $row => $page) {
         $class = '';
         if ($row == 0) {
             $class .= ' first';
         } else {
             if (count($about_menu) - 1 == $row) {
                 $class .= ' last';
             }
         }
         if ($page['page_id'] == -1) {
             $has = true;
         } else {
             if ($page['status']) {
                 if (isset($has) && $has) {
                     $class .= " group";
                     $has = false;
                 }
                 $this->view->about_menu[] = array('class' => trim($class), 'title' => $page['title'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page['page_id']));
             }
             $has = false;
         }
     }
     ////////////////////////////// NEW PASSWORD ///////////////////////////
     $this->view->show_new_password = false;
     if (JO_Session::get('user[user_id]') && JO_Session::get('user[email]') != JO_Session::get('user[new_email]')) {
         /*switch(true) {
         			case 'index' == $request->getController():
         			case 'all' == $request->getController():
         			case 'category' == $request->getController():
         			case 'videos' == $request->getController():
         			case 'popular' == $request->getController():
         			case 'gifts' == $request->getController():
         				$this->view->show_new_password = true;
         			break;
         		}*/
         $this->view->show_new_password = true;
     }
     ////////////////////////////// Board category ///////////////////////////
     if (($board_info = JO_Registry::forceGet('board_category_change')) instanceof ArrayObject) {
         $this->view->board_category_change = array('title' => $board_info['board_title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board_info['board_user_id'] . '&board_id=' . $board_info['board_board_id']));
     }
     ///////////////////// invate menu user /////////////////////////////
     $methodsforinvates = $this->view->callChildrenView('invates/methodsforinvates');
     $this->view->methodsforinvates = (array) $methodsforinvates->user_invate_friends;
     ///////////////////// extra metatags /////////////////////////////
     $extra_metas = '';
     $extra_metas_get = Model_Extensions::getByMethod('extra_metas');
     foreach ($extra_metas_get as $id => $mod) {
         $extra_metas .= $this->view->callChildren('modules_' . $mod . '_extrametas');
     }
     if ($extra_metas) {
         JO_Layout::getInstance()->placeholder('header_metas', $extra_metas);
     }
 }
示例#11
0
 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');
     }
 }
示例#12
0
 public function embedAction()
 {
     $request = $this->getRequest();
     $event_id = $request->getRequest('event_id');
     $event = Model_Events::getEventSolo($event_id);
     if (!$event) {
         $this->forward('error', 'error404');
     }
     $image = Helper_Uploadimages::event($event, '_B');
     $image2 = Helper_Uploadimages::event($event, '_D');
     if ($image && $image2) {
         $event['thumb'] = $image2['image'];
         $event['thumb_width'] = $image['width'];
         $event['thumb_height'] = $image['height'];
         $event['original'] = $image['original'];
     } else {
         $event['thumb'] = '';
         $event['thumb_width'] = 0;
         $event['thumb_height'] = 0;
     }
     $event['href'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']);
     $event['onto_href'] = WM_Router::create($request->getBaseUrl());
     $event['onto_title'] = JO_Registry::get('site_name');
     $event['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']);
     $this->view->event = $event;
     $this->view->events_details = $this->view->render('embed', 'events');
     $this->setViewChange('indexeventBoxDetail');
     if ($request->isXmlHttpRequest()) {
         $this->view->popup = true;
         echo $this->view->events_details;
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'layout/left_part');
     }
 }
示例#13
0
 public function logintwAction()
 {
     $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;
     }
     $return = array();
     if (isset($_POST['twitter_id'])) {
         $id = $_POST['twitter_id'];
         $user_data = WM_Users::checkLoginFacebookTwitter($id, 'twitter');
         if ($user_data) {
             JO_Session::set(array('user' => $user_data));
             JO_Session::clear('user_info_twitteroauth');
             JO_Session::clear('access_token_twitteroauth');
             $token = md5($user_data['user_id']);
             $_SESSION['token'] = $token;
             JO_Session::set('token', $token);
             $avatar = Helper_Uploadimages::avatar($user_data, '_A');
             $return = array('id' => $user_data['user_id'], 'username' => $user_data['username'], 'token' => $token, 'firstname' => $user_data['firstname'], 'lastname' => $user_data['lastname'], 'avatar' => $avatar['image']);
         } else {
             $return = array('error' => 14, 'description' => $this->translate("Error en el login de twitter"));
         }
     }
     //$token = md5(uniqid(rand(), true));
     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; charset=utf-8');
         $return = JO_Json::encode($return);
     }
     $response->appendBody($return);
 }
示例#14
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $user_data = Model_Users::getUser(JO_Session::get('user[user_id]'));
     $upload = new JO_Upload_SessionStore();
     $upload->setName('upload_avatar');
     $info = $upload->getFileInfo();
     if (JO_Session::get('successfu_edite')) {
         $this->view->successfu_edite = true;
         JO_Session::clear('successfu_edite');
     }
     if (JO_Session::get('connect_error')) {
         $this->view->error = JO_Session::get('connect_error');
         JO_Session::clear('connect_error');
     }
     $this->view->config_enable_follow_private_profile = Helper_Config::get('config_enable_follow_private_profile');
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         $validate->_set_rules($request->getPost('username'), $this->translate('Username'), 'not_empty;min_length[3];max_length[100];username');
         $validate->_set_rules($request->getPost('firstname'), $this->translate('First name'), 'not_empty;min_length[3];max_length[100]');
         $validate->_set_rules($request->getPost('lastname'), $this->translate('Last name'), 'not_empty;min_length[3];max_length[100]');
         $validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email');
         $data = $request->getPost();
         if ($validate->_valid_form()) {
             if (Model_Users::isExistEmail($request->getPost('email'), JO_Session::get('user[email]'))) {
                 $validate->_set_form_errors($this->translate('This e-mail address is already used'));
                 $validate->_set_valid_form(false);
             }
             if (Model_Users::isExistUsername($request->getPost('username'), JO_Session::get('user[username]'))) {
                 $validate->_set_form_errors($this->translate('This username is already used'));
                 $validate->_set_valid_form(false);
             }
         }
         if ($validate->_valid_form()) {
             $data['dont_search_index'] = (int) $request->issetPost('dont_search_index');
             $data['facebook_timeline'] = (int) $request->issetPost('facebook_timeline');
             /* v2.2 */
             if ($this->view->config_enable_follow_private_profile) {
                 $data['enable_follow'] = (int) (!$request->issetPost('enable_follow'));
                 $data['public'] = (int) (!$request->issetPost('public'));
             }
             /* v2.2 */
             if ($info) {
                 if (!@file_exists(BASE_PATH . '/cache/avatar/') || !is_dir(BASE_PATH . '/cache/avatar/')) {
                     mkdir(BASE_PATH . '/cache/avatar/');
                 }
                 $filename = BASE_PATH . '/cache/avatar/' . md5(mt_rand() . time()) . $upload->get_extension($info['name']);
                 if (file_put_contents($filename, $info['data'])) {
                     $data['avatar'] = $filename;
                 }
             }
             $new_email_key = md5(JO_Session::get('user[email]') . mt_rand() . time());
             if (JO_Session::get('user[email]') != $request->getPost('email')) {
                 $data['new_email_key'] = $new_email_key;
             } else {
                 $data['new_email_key'] = '';
             }
             $data['new_email'] = $data['email'];
             unset($data['email']);
             $result = new Model_Users_Edit(JO_Session::get('user[user_id]'), $data);
             if ($result->affected_rows) {
                 JO_Session::set('successfu_edite', true);
                 $upload->getFileInfo(true);
                 if (JO_Session::get('user[email]') != $request->getPost('email')) {
                     /*$this->view->verify_email_href = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=login&user_id='.JO_Session::get('user[user_id]').'&verify=' . $new_email_key );
                     		$this->view->user_info = $user_data;
                     		Model_Email::send(
                       	        	$request->getPost('email'),
                       	        	Helper_Config::get('noreply_mail'),
                       	        	$this->translate('Please verify your email'),
                       	        	$this->view->render('verify_email', 'mail')
                       	        );*/
                     $template = Model_Notification::getTemplate('verify_email');
                     if ($template) {
                         $template_data = array('user_id' => JO_Session::get('user[user_id]'), 'user_firstname' => JO_Session::get('user[firstname]'), 'user_lastname' => JO_Session::get('user[lastname]'), 'user_fullname' => JO_Session::get('user[fullname]'), 'user_username' => JO_Session::get('user[username]'), 'verify_email_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . JO_Session::get('user[user_id]') . '&verify=' . $new_email_key), 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'user_message' => '', 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
                         if (!$template['title']) {
                             $template['title'] = $this->translate('Please verify your email');
                         }
                         $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($request->getPost('email'), Helper_Config::get('noreply_mail'), $title, $body);
                     }
                 }
                 $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=settings'));
             } else {
                 $this->view->error = $this->translate('There was a problem with the record. Please try again!');
             }
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
         foreach ($data as $k => $v) {
             if (isset($user_data[$k])) {
                 $user_data[$k] = $v;
             }
         }
     }
     if ($info) {
         $user_data['avatar'] = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=temporary_avatar&s=' . microtime(true));
         $user_data['has_avatar'] = true;
     } else {
         $avatar = Helper_Uploadimages::avatar($user_data, '_C');
         $user_data['avatar'] = $avatar['image'] . '?s=' . microtime(true);
         $user_data['has_avatar'] = @getimagesize($user_data['avatar']) ? true : false;
     }
     $this->view->instagram_enable = JO_Registry::get('oauth_in_key');
     $this->view->twitteroauth_enable = JO_Registry::get('oauth_tw_key');
     $this->view->facebook_enable = JO_Registry::get('oauth_fb_key');
     $this->view->user_data = $user_data;
     $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=upload_avatar');
     $this->view->check_username = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=check_username');
     $this->view->delete_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=delete&user_id=' . $user_data['user_id']);
     $this->view->prefs_action = WM_Router::create($request->getBaseUrl() . '?controller=prefs');
     $this->view->new_password = WM_Router::create($request->getBaseUrl() . '?controller=password&action=change');
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->base_href = $request->getBaseUrl();
     $this->view->delete_account = '';
     if (JO_Registry::get('delete_account')) {
         $page_description = Model_Pages::getPage(JO_Registry::get('delete_account'));
         if ($page_description) {
             $this->view->delete_account = html_entity_decode($page_description['description'], ENT_QUOTES, 'utf-8');
         }
     }
     //extensions
     $this->view->user_login_buttons = array();
     $user_login_buttons = Model_Extensions::getByMethod('user_login');
     foreach ($user_login_buttons as $id => $login) {
         $this->view->user_login_buttons[] = $this->view->callChildren('modules_' . $login . '_connect', WM_Router::create($request->getBaseUrl() . '?controller=modules_' . $login . '_register'));
     }
     $this->view->user_avatars = array();
     $user_login_buttons = Model_Extensions::getByMethod('user_avatar');
     foreach ($user_login_buttons as $id => $login) {
         $this->view->user_avatars[] = $this->view->callChildren('modules_' . $login . '_useravatar', WM_Router::create($request->getBaseUrl() . '?controller=modules_' . $login . '_register'));
     }
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#15
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) {
         Model_Users::edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
         JO_Session::clear('category_id');
         $this->view->user_info = JO_Session::get('user');
         Model_Email::send(JO_Session::get('user[email]'), JO_Registry::get('noreply_mail'), sprintf($this->translate('Welcome to %s!'), JO_Registry::get('site_name')), $this->view->render('welcome', 'mail'));
     }
     $this->view->og_namespace = trim(JO_Registry::get('og_namespace'));
     $this->view->og_recipe = trim(JO_Registry::get('og_recipe'));
     if (!$this->view->og_recipe) {
         $this->view->og_namespace = '';
     }
     $this->view->show_landing = !JO_Registry::get('enable_free_registration');
     $to_title = '';
     if (JO_Session::get('user[user_id]')) {
         $to_title = JO_Session::get('user[fullname]') . ' / ';
     }
     if ($this->getLayout()->meta_title) {
         $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . JO_Registry::get('meta_title'));
     } else {
         $this->getLayout()->placeholder('title', $to_title . JO_Registry::get('meta_title'));
     }
     if ($this->getLayout()->meta_description) {
         $this->getLayout()->placeholder('description', $this->getLayout()->meta_description);
     } else {
         $this->getLayout()->placeholder('description', JO_Registry::get('meta_description'));
     }
     if ($this->getLayout()->meta_keywords) {
         $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords);
     } else {
         $this->getLayout()->placeholder('keywords', JO_Registry::get('meta_keywords'));
     }
     $this->getLayout()->placeholder('site_name', JO_Registry::get('site_name'));
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->meta_title = JO_Registry::get('meta_title');
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(JO_Registry::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . JO_Registry::get('site_logo');
     }
     if (JO_Registry::get('favicon') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('favicon'))) {
         $this->getLayout()->placeholder('favicon', $request->getBaseUrl() . 'uploads' . JO_Registry::get('favicon'));
     }
     $this->getLayout()->placeholder('site_logo', $this->view->site_logo);
     $this->view->show_header_invate = !JO_Session::get('user[user_id]');
     if (!JO_Session::get('user[user_id]')) {
         switch (true) {
             case $request->getAction() == 'login':
                 $this->view->show_header_invate = true;
             case $request->getAction() == 'register':
                 $this->view->show_header_invate = true;
                 break;
         }
     }
     $this->view->controller_open = $request->getController();
     $this->view->show_header_line = !in_array($request->getController(), array('pin'));
     $this->view->show_slider = !in_array($request->getController(), array('users', 'pin', 'settings', 'prefs', 'password'));
     if ($request->getController() == 'users') {
         $this->view->show_header_line = false;
     }
     //==== brand =====//
     $this->view->show_brand = true;
     if (JO_Registry::get('license_powered_check') == 'false' && JO_Registry::get('config_hide_brand')) {
         $this->view->show_brand = false;
     }
     ////////// CURRENCY
     //autoupdate currency if set
     if (JO_Registry::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
     }
     $currencies = WM_Currency::getCurrencies();
     $price_left = array();
     $price_right = array();
     if ($currencies) {
         foreach ($currencies as $currency) {
             if (trim($currency['symbol_left'])) {
                 $price_left[] = preg_quote(trim($currency['symbol_left']));
             }
             if (trim($currency['symbol_right'])) {
                 $price_right[] = preg_quote(trim($currency['symbol_right']));
             }
         }
     }
     $this->view->price_left = implode('|', $price_left);
     $this->view->price_right = implode('|', $price_right);
     //////////// Categories ////////////
     $this->view->categories = array();
     $categories1 = array("0" => array("category_id" => "9999", "title" => "TODO", "image" => ""));
     $this->view->category_active = false;
     $categories2 = Model_Categories::getCategories(array('filter_status' => 1));
     $categories = array_merge($categories1, $categories2);
     $x = 0;
     foreach ($categories as $category) {
         if ($x == 0) {
             $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']);
             $category['href'] = WM_Router::create($request->getBaseUrl() . '?controller=all&category_id=' . $category['category_id']);
             if ($request->getRequest('category_id') == 9999) {
                 $category['active'] = TRUE;
                 $this->view->category_active = $category['title'];
             } else {
                 $category['active'] = FALSE;
             }
             $this->view->categories[] = $category;
         } else {
             $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']);
             $category['href'] = WM_Router::create($request->getBaseUrl() . '?controller=category&category_id=' . $category['category_id']);
             $category['active'] = $category['category_id'] == $request->getRequest('category_id');
             if ($category['active']) {
                 $this->view->category_active = $category['title'];
             } else {
                 $i = 0;
                 foreach ($category['subcategories'] as $subcategory) {
                     $category['subcategories'][$i]['active'] = $subcategory['category_id'] == $request->getRequest('category_id');
                     if ($category['subcategories'][$i]['active']) {
                         $this->view->category_active = $subcategory['title'];
                     }
                     $i++;
                 }
             }
             $this->view->categories[] = $category;
         }
         $x = 1;
     }
     ////////////////////////////// USER MENU ///////////////////////////
     $this->view->is_loged = JO_Session::get('user[user_id]');
     if ($this->view->is_loged) {
         $model_images = new Helper_Images();
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $this->view->self_avatar = $avatar['image'];
         $this->view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $this->view->is_loged);
         $this->view->mails = WM_Router::create($request->getBaseUrl() . '?controller=users&action=mails');
         $this->view->self_firstname = JO_Session::get('user[firstname]');
         $this->view->logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
         $this->view->invites = WM_Router::create($request->getBaseUrl() . '?controller=invites');
         $this->view->invites_fb = WM_Router::create($request->getBaseUrl() . '?controller=invites&action=facebook');
         $this->view->user_pins = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged);
         $this->view->user_pins_likes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged . '&filter=likes');
         $this->view->settings = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     $this->view->landing = WM_Router::create($request->getBaseUrl() . '?controller=landing');
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register');
     $category_id = null;
     if ($request->getRequest('category_id')) {
         $category_id = $request->getRequest('category_id');
         ////////////////////////////// GIFTS ///////////////////////////
         $this->view->gifts = WM_Router::create($request->getBaseUrl() . '?controller=gifts&category_id=' . $category_id);
         $this->view->gifts1 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=1&price_to=20&category_id=' . $category_id);
         $this->view->gifts2 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=20&price_to=50&category_id=' . $category_id);
         $this->view->gifts3 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=50&price_to=100&category_id=' . $category_id);
         $this->view->gifts4 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=100&price_to=200&category_id=' . $category_id);
         $this->view->gifts5 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=200&price_to=500&category_id=' . $category_id);
         $this->view->gifts6 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=500&category_id=' . $category_id);
         //////////// Video ////////////
         $this->view->video_url = WM_Router::create($request->getBaseUrl() . '?controller=videos&category_id=' . $category_id);
         /*
                             //////////// Popular ////////////
                             $this->view->popular_url = WM_Router::create( $request->getBaseUrl() . '?controller=popular&category_id='.$category_id );
         */
         //////////// Articles ////////////
         $this->view->article_url = WM_Router::create($request->getBaseUrl() . '?controller=articles&category_id=' . $category_id);
         //////////// Ranking ////////////
         $this->view->pinTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=1&category_id=' . $category_id);
         $this->view->pinTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=2&category_id=' . $category_id);
         $this->view->profileTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=3&category_id=' . $category_id);
         $this->view->profileTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=4&category_id=' . $category_id);
     } else {
         ////////////////////////////// GIFTS ///////////////////////////
         $this->view->gifts = WM_Router::create($request->getBaseUrl() . '?controller=gifts');
         $this->view->gifts1 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=1&price_to=20');
         $this->view->gifts2 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=20&price_to=50');
         $this->view->gifts3 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=50&price_to=100');
         $this->view->gifts4 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=100&price_to=200');
         $this->view->gifts5 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=200&price_to=500');
         $this->view->gifts6 = WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=500');
         //////////// Video ////////////
         $this->view->video_url = WM_Router::create($request->getBaseUrl() . '?controller=videos');
         /*
                             //////////// Popular ////////////
                             $this->view->popular_url = WM_Router::create( $request->getBaseUrl() . '?controller=popular' );
         */
         //////////// Articles ////////////
         $this->view->article_url = WM_Router::create($request->getBaseUrl() . '?controller=articles');
         //////////// Ranking ////////////
         $this->view->pinTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=1');
         $this->view->pinTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=2');
         $this->view->profileTop7_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=3');
         $this->view->profileTop_url = WM_Router::create($request->getBaseUrl() . '?controller=toppins&index_id=4');
     }
     //////////// Popular ////////////
     $this->view->popular_url = WM_Router::create($request->getBaseUrl() . '?controller=premiostt');
     //////////// ALL PINS ////////////
     $this->view->all_url = WM_Router::create($request->getBaseUrl() . '?controller=all');
     //////////// activate ////////////
     $this->view->activate_url = WM_Router::create($request->getBaseUrl() . '?controller=index&action=indexActivate');
     //////////// Eventtos ////////////
     $this->view->events_url = WM_Router::create($request->getBaseUrl() . '?controller=events');
     //////////// Volunttarios ////////////
     if ($this->view->is_loged) {
         $this->view->voluntarios_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=voluntarioMenuPopup&user_id=' . $this->view->is_loged);
     } else {
         $this->view->voluntarios_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=voluntarioMenuPopup');
     }
     ////////////////////////////// SEARCH ///////////////////////////
     //$this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     if (in_array($request->getAction(), array('advanced', 'page', 'view'))) {
         $with_action = $request->getAction();
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction());
     } elseif (in_array($request->getAction(), array('advanced', 'advanced'))) {
         $with_action = $request->getAction();
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction());
     } else {
         $with_action = 0;
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     }
     //$this->view->search_autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete');
     if (strpos($this->view->search, '?') !== false) {
         $this->view->show_hidden = true;
         $this->view->with_action = $with_action;
     }
     //$this->view->keywords = $request->issetQuery('q') ? $request->getQuery('q') : $this->translate('Search...');
     /*
     		if(in_array($request->getAction(), array('amatteur'))) {
     			$with_action = 0;
     			$this->view->search_action_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search');
     		} elseif( in_array($request->getAction(), array('activate', 'services')) ) {
     			$with_action = $request->getAction();
     			$this->view->search_action_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search&action='.$request->getAction());
     } else {
     			$with_action = 0;
     			$this->view->search_action_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search');
     		}
     		
     		$this->view->search_autocomplete_advanced = WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete');
     		if(strpos($this->view->search_advanced, '?') !== false) {
     			$this->view->show_hidden = true;
     			$this->view->with_action = $with_action;    
     		}
     		
     		$this->view->keywords = $request->issetQuery('q') ? $request->getQuery('q') : $this->translate('Search...');
     */
     $this->view->search_url = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=amatteur');
     ////////////////////////////// ADD PIN ///////////////////////////
     $this->view->addPin = WM_Router::create($request->getBaseUrl() . '?controller=addpin');
     ////////////////////////////// MAILS ///////////////////////////
     $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');
     ////////////////////////////// FULL URL ///////////////////////////
     $this->view->full_url_js = false;
     switch (true) {
         case 'index' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl());
             break;
         case 'search' == $request->getController():
             if (in_array($request->getAction(), array('index', 'page', 'view'))) {
                 $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=search&q=' . $request->getRequest('q'));
             } else {
                 $parametros = "";
                 $this->view->keywords = $request->issetQuery('location') ? $request->getQuery('location') : $this->translate('Search...');
                 /*
                                                     if ($request->issetPost('firstname'))
                                                     {
                    $parametros .= "&firstname=". $request->getPost('firstname');
                                                     } 
                 
                                                     if ($request->issetPost('words'))
                                                     {
                    $parametros .= "&words=". $request->getPost('words');
                                                     } 
                                                     if ($request->issetPost('location'))
                                                     {
                    $parametros .= "&location=". $request->getPost('location');
                                                     } 
                                                     if ($request->issetPost('sport_category_1'))
                                                     {
                    $parametros .= "&sport_category_1=". $request->getPost('sport_category_1');
                                                     }         
                                                     if ($request->issetPost('sport_category_2'))
                                                     {
                    $parametros .= "&sport_category_2=". $request->getPost('sport_category_2');
                                                     }
                                                     if ($request->issetPost('sport_category_3'))
                                                     {
                    $parametros .= "&sport_category_3=". $request->getPost('sport_category_3');
                                                     } 
                                                     if ($request->issetPost('type_user'))
                                                     {
                    $parametros .= "&type_user="******"&gender=". $request->getRequest('gender');
                                                     } 
                 
                                                     //location		
                                                     if ($request->issetPost('location'))
                                                     {
                    $parametros .= "&location=". $request->getPost('location');
                                                     } 
                 
                                                     //sport category
                                                     if ($request->issetPost('sport_category'))
                                                     {
                    $parametros .= "&sport_category=". $request->getPost('sport_category');
                                                     } 
                 
                                                     //age
                                                     if ($request->issetPost('age'))
                                                     {
                    $parametros .= "&age=". $request->getPost('age');
                                                     } 
                 
                                                     //level
                                                     if ($request->issetPost('level'))
                                                     {
                    $parametros .= "&level=". $request->getPost('level');
                                                     } 
                 
                                                     //option1		
                                                     if ($request->issetPost('option1'))
                                                     {
                    $parametros .= "&option1=". $request->getPost('option1');
                                                     } 
                 
                                                     //option2		
                                                     if ($request->issetPost('option2'))
                                                     {
                    $parametros .= "&option2=". $request->getPost('option2');
                                                     } 
                 
                                                     //option3
                                                     if ($request->issetPost('option3'))
                                                     {
                    $parametros .= "&option3=". $request->getPost('option3');
                                                     } 
                 
                                                     //option4		
                                                     if ($request->issetPost('option4'))
                                                     {
                    $parametros .= "&option4=". $request->getPost('option4');
                                                     } 
                 
                                                     //option5		
                                                     if ($request->issetPost('option5'))
                                                     {
                    $parametros .= "&option5=". $request->getPost('option5');
                                                     } 
                 
                                                     //option6		
                                                     if ($request->issetPost('option6'))
                                                     {
                    $parametros .= "&option6=". $request->getPost('option6');
                                                     } 
                 
                                                     //option7		
                                                     if ($request->issetPost('option7'))
                                                     {
                    $parametros .= "&option7=". $request->getPost('option7');
                                                     } 
                 
                                                     //option8		
                                                     if ($request->issetPost('option8'))
                                                     {
                    $parametros .= "&option8=". $request->getPost('option8');
                                                     } 
                 
                                                     //option9		
                                                     if ($request->issetPost('option9'))
                                                     {
                    $parametros .= "&option9=". $request->getPost('option9');
                                                     } 
                 
                                                     //option10		
                                                     if ($request->issetPost('option10'))
                                                     {
                    $parametros .= "&option10=". $request->getPost('option10');
                                                     }
                                                     
                                                     //option11		
                                                     if ($request->issetPost('option11'))
                                                     {
                    $parametros .= "&option11=". $request->getPost('option11');
                                                     } 
                 
                                                     //option12		
                                                     if ($request->issetPost('option12'))
                                                     {
                    $parametros .= "&option12=". $request->getPost('option12');
                                                     } 
                 
                                                     //option13
                                                     if ($request->issetPost('option13'))
                                                     {
                    $parametros .= "&option13=". $request->getPost('option13');
                                                     } 
                 
                                                     //option14		
                                                     if ($request->issetPost('option14'))
                                                     {
                    $parametros .= "&option14=". $request->getPost('option14');
                                                     } 
                 
                                                     //option15		
                                                     if ($request->issetPost('option15'))
                                                     {
                    $parametros .= "&option15=". $request->getPost('option15');
                                                     } 
                 
                                                     //option16		
                                                     if ($request->issetPost('option16'))
                                                     {
                    $parametros .= "&option16=". $request->getPost('option16');
                                                     } 
                 
                                                     //option17		
                                                     if ($request->issetPost('option17'))
                                                     {
                    $parametros .= "&option17=". $request->getPost('option17');
                                                     } 
                 
                                                     //option18		
                                                     if ($request->issetPost('option18'))
                                                     {
                    $parametros .= "&option18=". $request->getPost('option18');
                                                     } 
                 * 
                 */
                 if ($request->issetRequest('zoom')) {
                     $parametros .= "&zoom=" . $request->getRequest('zoom');
                 }
                 if ($request->issetRequest('id')) {
                     $parametros .= "&id=" . $request->getRequest('id');
                 }
                 if ($request->issetRequest('firstname')) {
                     $parametros .= "&firstname=" . $request->getRequest('firstname');
                 }
                 if ($request->issetRequest('words')) {
                     $parametros .= "&words=" . $request->getRequest('words');
                 }
                 if ($request->issetRequest('location')) {
                     $parametros .= "&location=" . $request->getRequest('location');
                 }
                 if ($request->issetRequest('sport_category_1')) {
                     $parametros .= "&sport_category_1=" . $request->getRequest('sport_category_1');
                 }
                 if ($request->issetRequest('sport_category_2')) {
                     $parametros .= "&sport_category_2=" . $request->getRequest('sport_category_2');
                 }
                 if ($request->issetRequest('sport_category_3')) {
                     $parametros .= "&sport_category_3=" . $request->getRequest('sport_category_3');
                 }
                 if ($request->issetRequest('type_user')) {
                     $parametros .= "&type_user="******"&gender=" . $request->getRequest('gender');
                 }
                 //location
                 if ($request->issetRequest('location')) {
                     $parametros .= "&location=" . $request->getRequest('location');
                 }
                 //sport category
                 if ($request->issetRequest('sport_category')) {
                     $parametros .= "&sport_category=" . $request->getRequest('sport_category');
                 }
                 //age
                 if ($request->issetRequest('age')) {
                     $parametros .= "&age=" . $request->getRequest('age');
                 }
                 //level
                 if ($request->issetRequest('level')) {
                     $parametros .= "&level=" . $request->getRequest('level');
                 }
                 //option1
                 if ($request->issetRequest('option1')) {
                     $parametros .= "&option1=" . $request->getRequest('option1');
                 }
                 //option2
                 if ($request->issetRequest('option2')) {
                     $parametros .= "&option2=" . $request->getRequest('option2');
                 }
                 //option3
                 if ($request->issetRequest('option3')) {
                     $parametros .= "&option3=" . $request->getRequest('option3');
                 }
                 //option4
                 if ($request->issetRequest('option4')) {
                     $parametros .= "&option4=" . $request->getRequest('option4');
                 }
                 //option5
                 if ($request->issetRequest('option5')) {
                     $parametros .= "&option5=" . $request->getRequest('option5');
                 }
                 //option6
                 if ($request->issetRequest('option6')) {
                     $parametros .= "&option6=" . $request->getRequest('option6');
                 }
                 //option7
                 if ($request->issetRequest('option7')) {
                     $parametros .= "&option7=" . $request->getRequest('option7');
                 }
                 //option8
                 if ($request->issetRequest('option8')) {
                     $parametros .= "&option8=" . $request->getRequest('option8');
                 }
                 //option9
                 if ($request->issetRequest('option9')) {
                     $parametros .= "&option9=" . $request->getRequest('option9');
                 }
                 //option10
                 if ($request->issetRequest('option10')) {
                     $parametros .= "&option10=" . $request->getRequest('option10');
                 }
                 //option11
                 if ($request->issetRequest('option11')) {
                     $parametros .= "&option11=" . $request->getRequest('option11');
                 }
                 //option12
                 if ($request->issetRequest('option12')) {
                     $parametros .= "&option12=" . $request->getRequest('option12');
                 }
                 //option13
                 if ($request->issetRequest('option13')) {
                     $parametros .= "&option13=" . $request->getRequest('option13');
                 }
                 //option14
                 if ($request->issetRequest('option14')) {
                     $parametros .= "&option14=" . $request->getRequest('option14');
                 }
                 //option15
                 if ($request->issetRequest('option15')) {
                     $parametros .= "&option15=" . $request->getRequest('option15');
                 }
                 //option16
                 if ($request->issetRequest('option16')) {
                     $parametros .= "&option16=" . $request->getRequest('option16');
                 }
                 //option17
                 if ($request->issetRequest('option17')) {
                     $parametros .= "&option17=" . $request->getRequest('option17');
                 }
                 //option18
                 if ($request->issetRequest('option18')) {
                     $parametros .= "&option18=" . $request->getRequest('option18');
                 }
                 $parametros .= "&kk=kk";
                 $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction() . '&q=' . $request->getRequest('q') . '&id=' . $request->getRequest('id') . $parametros);
             }
             break;
         case 'all' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=all');
             break;
         case 'videos' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=videos');
             break;
         case 'popular' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=popular');
             break;
         case 'category' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=category&category_id=' . $request->getRequest('category_id'));
             break;
         case 'source' == $request->getController():
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=source&source_id=' . $request->getRequest('source_id'));
             break;
         case 'boards' == $request->getController() && in_array($request->getAction(), array('index', 'page')):
             $url = '';
             if ($request->getRequest('user_id')) {
                 $url = '&user_id=' . $request->getRequest('user_id');
             }
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view' . $url . '&board_id=' . $request->getRequest('board_id'));
             break;
         case 'gifts' == $request->getController():
             $url = '';
             if ($request->issetParam('price_from')) {
                 $url .= (int) $request->getRequest('price_from');
             }
             if ($request->issetParam('price_to')) {
                 $url .= ':' . (int) $request->getRequest('price_to');
             }
             $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=gifts' . ($url ? '&action=' . $url : ''));
             break;
         case 'users' == $request->getController():
             if (in_array($request->getAction(), array('pins', 'followers', 'following', 'likers', 'liking', 'activity')) && $request->getRequest('user_id')) {
                 $this->view->full_url_js = WM_Router::create($request->getBaseUrl() . '?controller=users&action=' . $request->getAction() . '&user_id=' . $request->getRequest('user_id') . ($request->getQuery('filter') ? '&filter=' . $request->getQuery('filter') : ''));
             }
             break;
     }
     if ($request->getRequest('user_id')) {
         $user_info = Model_Users::getUser($request->getRequest('user_id'));
         if ($user_info && $user_info['dont_search_index']) {
             $this->getLayout()->placeholder('inhead', '<meta name="robots" content="noindex"/>');
         }
     }
     ////////////////////////////// ABOUT MENU ///////////////////////////
     $this->view->about_menu = array();
     $has = false;
     if (is_array(JO_Registry::forceGet('about_menu'))) {
         foreach (JO_Registry::forceGet('about_menu') as $row => $page_id) {
             if ($row == 0) {
                 $class = 'first';
             } else {
                 if (count(JO_Registry::forceGet('about_menu')) - 1 == $row) {
                     $class = 'last';
                 } else {
                     $class = '';
                 }
             }
             //				$class = $row==0?' first':'';
             if ($page_id == -1) {
                 $has = true;
             } else {
                 $pinfo = Model_Pages::getPage($page_id);
                 if ($pinfo && $pinfo['status']) {
                     if ($has) {
                         $class .= " group";
                         $has = false;
                     }
                     $this->view->about_menu[] = array('class' => trim($class), 'title' => $pinfo['title'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_id));
                 }
             }
         }
     }
     ////////////////////////////// NEW PASSWORD ///////////////////////////
     $this->view->show_new_password = false;
     if (JO_Session::get('user[user_id]') && JO_Session::get('user[email]') != JO_Session::get('user[new_email]')) {
         switch (true) {
             case 'index' == $request->getController():
             case 'all' == $request->getController():
             case 'category' == $request->getController():
             case 'videos' == $request->getController():
             case 'popular' == $request->getController():
             case 'gifts' == $request->getController():
                 $this->view->show_new_password = true;
                 break;
         }
     }
     ////////////////////////////// Board category ///////////////////////////
     if (is_array($board_info = JO_Registry::forceGet('board_category_change'))) {
         $this->view->board_category_change = array('title' => $board_info['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']));
     }
 }
示例#16
0
 public function facebookAction()
 {
     $request = $this->getRequest();
     $this->view->friends = array();
     $this->view->getfriends = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=invites&action=getFriends');
     //		$this->view->invate_href = WM_Router::create( $this->getRequest()->getBaseUrl() . '?controller=users&action=register&user_id=' . JO_Session::get('user[user_id]') . '&code=' );
     $this->view->invate_href = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=invited&code=');
     $this->view->add_to_invate = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=addInvate');
     $this->view->invites = WM_Router::create($request->getBaseUrl() . '?controller=invites');
     $this->view->invites_fb = WM_Router::create($request->getBaseUrl() . '?controller=invites&action=facebook');
     $this->view->baseUrl = $request->getBaseUrl();
     /*$this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     		if(JO_Registry::get('site_logo') && file_exists(BASE_PATH .'/uploads'.JO_Registry::get('site_logo'))) {
     		    $this->view->site_logo = $request->getBaseUrl() . 'uploads' . JO_Registry::get('site_logo'); 
     		}*/
     $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_B');
     $this->view->user_avatar = $avatar['image'];
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->meta_description = JO_Registry::get('meta_description');
     $this->view->oauth_fb_key = JO_Registry::get('oauth_fb_key');
     $this->view->fb_session = true;
     //$this->facebook->getSession();
     $this->view->facebook_connect2 = WM_Router::create($request->getBaseUrl() . '?controller=invites&action=facebook_connect2');
     //		var_dump($this->view->fb_session); exit;
     /**/
     $facebook_friends = $this->getFriends();
     $follows = Model_Users::getFacebookFriends();
     $this->view->friends = array();
     $this->view->friends_not_follow = array();
     if ($facebook_friends) {
         $friends = $this->formatUsers($facebook_friends);
         if ($friends) {
             $model_images = new Helper_Images();
             foreach ($friends as $friend) {
                 if (array_key_exists($friend['id'], $follows)) {
                     $user_data = Model_Users::getUser($follows[$friend['id']]);
                     if ($user_data) {
                         $avatar = Helper_Uploadimages::avatar($user_data, '_A');
                         $user_data['avatar'] = $avatar['image'];
                         $user_data['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user_data['user_id']);
                         $user_data['follow_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user_data['user_id']);
                         $this->view->friends[] = $user_data;
                     }
                 } else {
                     if (($user_data = Model_Users::getFacebookFriendsNotFollow($friend['id'])) !== false) {
                         if ($user_data) {
                             $avatar = Helper_Uploadimages::avatar($user_data, '_A');
                             $user_data['avatar'] = $avatar['image'];
                             $user_data['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user_data['user_id']);
                             $user_data['follow_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user_data['user_id']);
                             $this->view->friends_not_follow[] = $user_data;
                         }
                     }
                 }
             }
         }
     }
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#17
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');
     }
 }
示例#18
0
 public function indexAction()
 {
     $request = $this->getRequest();
     //JO_Session::clear('categoria_id');
     //para las APP's
     if (isset($_POST['token']) && $_POST['token'] == md5($_POST['userid'])) {
         $_SESSION['token'] = $_POST['token'];
         JO_Session::set('token', $_POST['token']);
         $result = Model_Users::checkLoginAPP($_POST['userid']);
         if ($result) {
             if ($result['status']) {
                 @setcookie('csrftoken_', md5($result['user_id'] . $request->getDomain() . $result['date_added']), time() + 86400 * 366 * 5, '/', '.' . $request->getDomain());
                 JO_Session::set(array('user' => $result));
             }
         }
     }
     if ($request->getParam('direct_path') == 'true') {
         if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) {
             Model_Users::edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
             JO_Session::clear('category_id');
             $this->view->user_info = JO_Session::get('user');
             Model_Email::send(JO_Session::get('user[email]'), JO_Registry::get('noreply_mail'), sprintf($this->translate('Welcome to %s!'), JO_Registry::get('site_name')), $this->view->render('welcome', 'mail'));
         }
         $this->redirect($request->getBaseUrl());
     }
     /*$img = JO_Phpthumb::getInstance();
     		var_dump($img->isValidImplementation('imagick')); exit;
     		
     		$img = JO_Phpthumb_Factory::create('http://www.desiredanimations.com/wp-content/uploads/2011/08/Cars-2.jpg');
     		
     		$img->adaptiveResize(250, 250)->createReflection(40, 40, 80, true, '#a4a4a4');
     		$img->show();
     		
     		exit;*/
     $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'));
     if (JO_Session::get('user[user_id]')) {
         $data['following_users_from_user_id'] = JO_Session::get('user[user_id]');
         $data['filter_marker'] = $request->getRequest('marker');
     } else {
         $data['filter_rand'] = true;
     }
     $this->view->pins = '';
     //error_log("INICIO PINS: ".date("Y-m-d H:i:s"));
     $pins = Model_Pins::getPins($data);
     //error_log("EMPIEZAN PINES: ".self::udate("Y-m-d H:i:s:u"));
     if ($pins) {
         $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position BETWEEN '" . (int) $data['start'] . "' AND '" . (int) $data['limit'] . "'"));
         $pp = JO_Registry::get('config_front_limit');
         $cuentaPins = 0;
         foreach ($pins as $row => $pin) {
             $cuentaPins = $cuentaPins + 1;
             ///banners
             $key = $row + ($pp * $page - $pp);
             if (isset($banners[$key])) {
                 $this->view->pins .= Helper_Banners::returnHtml($banners[$key]);
             }
             //pins
             //error_log("EMPIEZA PIN(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u"));
             $this->view->pins .= Helper_Pin::returnHtml($pin);
             //error_log("FIN PIN(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u"));
         }
         //error_log("FIN BUCLE (".$cuentaPins." PINS): ".date("Y-m-d H:i:s"));
         if (JO_Session::get('user[user_id]')) {
             // 				JO_Registry::set('marker', Model_Pins::getMaxPin($data));
         }
     }
     //error_log("FIN PINES(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u"));
     if (!$request->isXmlHttpRequest() && JO_Session::get('user[user_id]')) {
         $history = Model_History::getHistory(array('start' => 0, 'limit' => 10, 'sort' => 'DESC', 'order' => 'history_id'));
         $model_images = new Helper_Images();
         foreach ($history as $key => $data) {
             if (!isset($data['user']['store'])) {
                 continue;
             }
             $avatar = Helper_Uploadimages::avatar($data['user'], '_A');
             $history[$key]['user']['avatar'] = $avatar['image'];
             if ($data['history_action'] == Model_History::REPIN) {
                 $history[$key]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $data['pin_id']);
             } else {
                 $history[$key]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $data['from_user_id']);
             }
         }
         $this->view->history = $history;
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->view->pins;
         //			echo $this->renderScript('json');
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
     //		if((int)JO_Registry::get('config_cache_live')) {
     //			$http = new JO_Http();
     //			$http->setTimeout(1);
     //			$http->execute($request->getBaseUrl() . '?action=generateCache');
     //		}
 }
示例#19
0
 public function header_metasAction($board_info = array())
 {
     if ($board_info instanceof ArrayObject && $board_info->count()) {
         $pins = new Model_Pins_Boards(array('filter_board_id' => $board_info['board_board_id'], 'start' => 0, 'limit' => 50));
         $board_image = '';
         $board_keywords = $board_info['board_title'] . html_entity_decode($board_info['board_description'] ? ' ' . $board_info['board_description'] : '');
         if ($pins->count()) {
             foreach ($pins->data as $pin) {
                 if ($pin['pin_description']) {
                     $board_keywords .= ' ' . html_entity_decode($pin['pin_description']);
                 }
                 if (!$board_image) {
                     $filter = array('pin_id' => $pin['pin_pin_id'], 'pin_pin_id' => $pin['pin_pin_id'], 'image' => $pin['pin_image'], 'pin_store' => $pin['pin_store']);
                     foreach ($pin as $k => $v) {
                         if (strpos($k, 'pin_thumb_') !== false) {
                             $filter[$k] = $v;
                         }
                     }
                     $board_image = Helper_Uploadimages::pinThumbs($filter);
                 }
             }
         }
         $params = array('min_word_occur' => 2, 'min_2words_phrase_occur' => 2);
         $params['content'] = $board_keywords;
         //page content
         $keywords = new WM_Keywords($params);
         $this->view->site_name = Helper_Config::get('site_name');
         $this->view->board = array('title' => $board_info['board_title'], 'description' => $board_info['board_description'] ? $board_info['board_description'] : $board_info['board_title'], 'keywords' => htmlspecialchars($keywords->get_keywords()), 'images' => $board_image, 'board_url' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_user_id'] . '&board_id=' . $board_info['board_board_id']), 'board_feed_url' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_user_id'] . '&board_id=' . $board_info['board_board_id'] . '&feed'), 'board_feed_title' => $board_info['board_title'] . ' ' . sprintf($this->translate('on %s'), $this->view->site_name));
         Helper_Config::set('extra_metatags', array('board' => $this->view->board));
     } else {
         $this->noViewRenderer(true);
     }
 }
示例#20
0
 public function friendsAction()
 {
     $request = $this->getRequest();
     $this->view->users = array();
     $self_id = JO_Session::get('user[user_id]');
     if ($self_id && $request->getPost('value')) {
         $has_friends = (int) JO_Session::get('user[following]') + (int) JO_Session::get('user[followers]');
         $users = new Model_Users_SearchAutocomplete(array('start' => 0, 'limit' => 100, 'filter_username' => $request->getPost('value')));
         if ($has_friends && $users->count()) {
             foreach ($users as $user) {
                 if ($user['user_id'] == $self_id) {
                     continue;
                 }
                 $this->view->users[] = array('template' => 'friends', 'template_2' => 'board_friend', 'user_id' => $user['user_id'], 'avatars' => Helper_Uploadimages::userAvatars($user), 'fullname' => $user['fullname'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']), 'text_remove' => $this->translate('Remove'));
             }
         }
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->renderScript('json');
     } else {
         $this->forward('error', 'error404');
     }
 }
示例#21
0
 public static function formatPinData($pin, $detail = false)
 {
     static $model_images = null, $request = null;
     if ($model_images === null) {
         $model_images = new Helper_Images();
     }
     if ($request === null) {
         $request = JO_Request::getInstance();
     }
     ///////////////////////////////////// PIN INFO /////////////////////////////////////
     $pin['pin_id'] = $pin['pin_pin_id'];
     $pin['image'] = $pin['pin_image'];
     //url's
     $pin['pin_url_embed'] = WM_Router::pinAction($pin['pin_pin_id'], 'embed');
     if (!JO_Session::get('user[user_id]')) {
         $login_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         if (Helper_Config::get('enable_free_registration')) {
             //$login_url = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=register' );
         }
         $pin['pin_url_email'] = $pin['pin_url_report'] = $pin['pin_url_like'] = $pin['pin_url_repin'] = $pin['pin_url_comment'] = $login_url;
         $pin['pin_edit'] = false;
     } else {
         $pin['pin_url_email'] = WM_Router::pinAction($pin['pin_pin_id'], 'email');
         $pin['pin_url_report'] = WM_Router::pinAction($pin['pin_pin_id'], 'report');
         $pin['pin_url_like'] = WM_Router::pinAction($pin['pin_pin_id'], 'like');
         $pin['pin_url_repin'] = WM_Router::pinAction($pin['pin_pin_id'], 'repin');
         $pin['pin_url_comment'] = WM_Router::pinAction($pin['pin_pin_id']);
         $pin['pin_edit'] = JO_Session::get('user[user_id]') == $pin['pin_user_id'] ? WM_Router::pinAction($pin['pin_pin_id'], 'edit') : false;
     }
     //$pin['pin_description'] = self::descriptionFix($pin['pin_description']);
     $pin['pin_href'] = WM_Router::pinAction($pin['pin_pin_id']);
     if ($pin['pin_gift']) {
         $pin['pin_price_formated'] = WM_Currency::format($pin['pin_price']);
     } else {
         $pin['pin_price_formated'] = 0;
     }
     //return all image sizes
     $pin['pin_thumbs'] = Helper_Uploadimages::pinThumbs($pin);
     //array_merge($pin, Helper_Uploadimages::pinThumbs($pin));
     $date_dif = array_shift(WM_Date::dateDiff($pin['pin_date_added'], time()));
     $pin['pin_date_dif'] = $date_dif;
     /* URL'S*/
     $pin['pin_onto_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['board_user_id'] . '&board_id=' . $pin['board_board_id']);
     ////follow urls
     $pin['board_follow_href'] = $pin['user_follow_href'] = $pin['via_follow_href'] = false;
     if (JO_Session::get('user[user_id]') ? $pin['board_user_id'] != JO_Session::get('user[user_id]') : false) {
         $pin['board_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $pin['board_user_id'] . '&board_id=' . $pin['board_board_id']);
     }
     if (JO_Session::get('user[user_id]') ? $pin['user_user_id'] != JO_Session::get('user[user_id]') : false) {
         $pin['user_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_user_id']);
     }
     if ($pin['via_user_id']) {
         if (JO_Session::get('user[user_id]') ? $pin['via_user_id'] != JO_Session::get('user[user_id]') : false) {
             $pin['via_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['via_user_id']);
         }
     } else {
         if (JO_Session::get('user[user_id]') ? $pin['user_user_id'] != JO_Session::get('user[user_id]') : false) {
             $pin['via_follow_href'] = $pin['user_follow_href'];
         }
     }
     if ($detail) {
         $pin['pin_next_href'] = '';
         if (isset($pin['pin_next']) && $pin['pin_next']) {
             $pin['pin_next_href'] = WM_Router::pinAction($pin['pin_next']);
         }
         $pin['pin_prev_href'] = '';
         if (isset($pin['pin_prev']) && $pin['pin_prev']) {
             $pin['pin_prev_href'] = WM_Router::pinAction($pin['pin_prev']);
         }
     }
     if (Helper_Config::get('config_comments_list') && !$detail && $pin['pin_comments']) {
         $latest_comments = Model_Comments::getLatestComments2($pin['pin_latest_comments']);
         $pin['pin_latest_comments'] = array();
         $user_id = JO_Session::get('user[user_id]');
         $is_admin = JO_Session::get('user[is_admin]');
         $is_developer = JO_Session::get('user[is_developer]');
         foreach ($latest_comments as $key => $comment) {
             $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $comment['avatar'], 'store' => $comment['store'], 'user_id' => $comment['user_id']));
             $enable_delete = false;
             if ($is_admin) {
                 $enable_delete = true;
             } elseif ($is_developer) {
                 $enable_delete = true;
             } elseif ($user_id == $comment['user_id']) {
                 $enable_delete = true;
             } elseif ($comment['pin_user_id'] == $user_id) {
                 $enable_delete = true;
             }
             $delete = false;
             if ($enable_delete) {
                 $delete = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $comment['comment_id']);
             }
             $pin['pin_latest_comments'][] = array('user' => array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $comment['user_id']), 'avatars' => $user_avatars, 'fullname' => $comment['fullname']), 'comment' => $comment['comment'], 'delete' => $delete);
         }
     } else {
         $pin['pin_latest_comments'] = array();
     }
     $pin['pin_video_code'] = false;
     if ($detail) {
         if ($pin['pin_is_video']) {
             $auto = new Helper_AutoEmbed();
             if ($pin['pin_repin_from'] && $auto->parseUrl($pin['pin_from_repin'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['pin_video_code'] = $auto->getEmbedCode();
             } else {
                 if ($auto->parseUrl($pin['pin_from'])) {
                     $auto->setWidth('100%');
                     $auto->setHeight('350');
                     $pin['pin_video_code'] = $auto->getEmbedCode();
                 } else {
                     $pin['pin_is_video'] = false;
                 }
             }
         } else {
             $auto = new Helper_AutoEmbed();
             if ($pin['pin_repin_from'] && $auto->parseUrl($pin['pin_from_repin'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['pin_video_code'] = $auto->getEmbedCode();
                 $pin['pin_is_video'] = true;
             } else {
                 if ($auto->parseUrl($pin['pin_from'])) {
                     $auto->setWidth('100%');
                     $auto->setHeight('350');
                     $pin['pin_video_code'] = $auto->getEmbedCode();
                     $pin['pin_is_video'] = true;
                 } else {
                     $pin['pin_is_video'] = false;
                 }
             }
         }
         $pin['pin_gallery'] = array();
         $gallery = new Model_Pins_Gallery($pin['pin_pin_id']);
         if ($gallery->count()) {
             foreach ($gallery->data as $gal) {
                 $pin['pin_gallery'][] = Helper_Uploadimages::pinThumbs(array('pin_pin_id' => $gal['pin_id'], 'pin_store' => $gal['store'], 'gallery_id' => $gal['gallery_id'], 'pin_image' => $gal['image']));
             }
         }
     }
     ///////////////////////////////////// AUTHOR INFO /////////////////////////////////////
     //return author all images
     $user_data = array('avatar' => $pin['user_avatar'], 'store' => $pin['user_store'], 'user_id' => $pin['user_user_id']);
     foreach ($pin as $k => $v) {
         if (strpos($k, 'user_avatar_') === 0) {
             $user_data[$k] = $v;
         }
     }
     $pin['user_avatars'] = Helper_Uploadimages::userAvatars($user_data);
     $pin['user_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_user_id']);
     ///////////////////////////////////// VIA INFO /////////////////////////////////////
     $pin['via_profile'] = array();
     if ($pin['via_user_id']) {
         $via_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $pin['via_avatar'], 'store' => $pin['via_store'], 'user_id' => $pin['via_user_id']));
         $pin['via_profile'] = array('avatars' => $via_avatars, 'profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['via_user_id']), 'fullname' => $pin['via_fullname']);
     }
     ///////////////////////////////////// SELF INFO /////////////////////////////////////
     $pin['self_profile'] = false;
     if (JO_Session::get('user[user_id]')) {
         $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => JO_Session::get('user[avatar]'), 'store' => JO_Session::get('user[store]'), 'user_id' => JO_Session::get('user[user_id]')));
         $pin['self_profile']['avatars'] = $user_avatars;
         $pin['self_profile']['fullname'] = JO_Session::get('user[fullname]');
         $pin['self_profile']['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
     }
     ///////////////////////////////////// SOURCE INFO /////////////////////////////////////
     $pin['pin_source'] = array();
     $pin['pin_target_repin'] = false;
     if ($detail) {
         if ($pin['pin_repin_from']) {
             $pin_repin = new Model_Pins_Pin($pin['pin_repin_from']);
             if ($pin_repin->count()) {
                 $pin_repin = $pin_repin->data;
                 $pin['pin_source']['source'] = $pin_repin['board_title'];
                 $pin['pin_from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_user_id'] . '&board_id=' . $pin_repin['board_board_id']);
                 $pin['pin_target_repin'] = true;
             } else {
                 $source = new Model_Sources_Source($pin['pin_source_id']);
                 if ($source->count()) {
                     $pin['pin_source']['source'] = $source['source'];
                 }
             }
         } else {
             $source = new Model_Sources_Source($pin['pin_source_id']);
             if ($source->count()) {
                 $pin['pin_source']['source'] = $source['source'];
             }
         }
     }
     ///for mobile
     $pin['mobile_upload'] = false;
     if ($pin['pin_from'] == 'Mobile') {
         $pin['pin_from'] = '';
         $pin['mobile_upload'] = true;
     }
     return $pin;
 }
示例#22
0
 public function autocompleteAction()
 {
     $request = $this->getRequest();
     $this->view->items = array();
     if (JO_Session::get('user[user_id]') && $request->getPost('value')) {
         $friends = Model_Users::getUserFriends(array('filter_username' => $request->getPost('value')));
         if ($friends) {
             $model_images = new Helper_Images();
             foreach ($friends as $friend) {
                 if (!isset($friend['store'])) {
                     continue;
                 }
                 $avatar = Helper_Uploadimages::avatar($friend, '_A');
                 $this->view->items[] = array('image' => $avatar['image'], 'label' => $friend['fullname'], 'value' => $friend['user_id'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $friend['user_id']), 'username' => $friend['username']);
             }
         }
         $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'friendly' => JO_Session::get('user[user_id]'), 'filter_title' => $request->getPost('value'), 'sort' => 'asc', 'order' => 'boards.title'));
         if ($boards) {
             foreach ($boards as $board) {
                 $this->view->items[] = array('image' => $request->getBaseUrl() . 'data/images/typeahead_board.png', 'label' => $board['title'], 'value' => $board['board_id'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']), 'username' => $board['title']);
             }
         }
     }
     $this->view->items[] = array('search_for' => 1, 'label' => sprintf($this->translate('Search for %s'), $request->getPost('value')), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=search&q=' . $request->getPost('value')));
     if ($request->isXmlHttpRequest()) {
         echo $this->renderScript('json');
     } else {
         $this->forward('error', 'error404');
     }
 }
示例#23
0
 public function fromatListBoard($board)
 {
     $request = $this->getRequest();
     $limit_thumbs = 5;
     $pins_filter = array();
     $latest = explode(',', $board['latest_pins']);
     if ($latest) {
         foreach ($latest as $l) {
             if ($l) {
                 $pins_filter[] = $l;
             }
         }
     }
     $pins = $pins_filter ? new Model_Pins_PinsThumbsForBoard(array('cover' => $board['board_cover'], 'pins' => $pins_filter, 'start' => 0, 'limit' => $limit_thumbs)) : new ArrayObject();
     $thumbs = array();
     $total_pins = $pins->count();
     for ($i = 0; $i < min($limit_thumbs, max($total_pins, $limit_thumbs)); $i++) {
         if (isset($pins->data[$i])) {
             $pin_data = $pins->data[$i];
             foreach ($pin_data as $key => $ppd) {
                 if (strpos($key, 'pin_') === 0) {
                     $pin_data[substr($key, 4)] = $ppd;
                 }
             }
             $thumbs[] = Helper_Uploadimages::pinThumbs($pin_data);
         } else {
             $thumbs[] = false;
         }
     }
     $loged = JO_Session::get('user[user_id]');
     $user_data = array();
     foreach ($board as $k => $v) {
         if (strpos($k, 'user_') === 0) {
             $user_data[substr($k, 5)] = $v;
         }
     }
     /* v2.2 */
     $config_enable_follow_private_profile = Helper_Config::get('config_enable_follow_private_profile');
     if ($config_enable_follow_private_profile) {
         $user_enable_follow = $board['user_enable_follow'];
     } else {
         $user_enable_follow = true;
     }
     /* v2.2 */
     return array('template' => 'boards', 'loged' => $loged, 'board_id' => $board['board_board_id'], 'autor_id' => $board['board_user_id'], 'history_id' => isset($board['history_id']) && $board['history_id'] ? $board['history_id'] : 0, 'title' => $board['board_title'], 'fullname' => $board['user_fullname'], 'following_board' => $board['following_board'], 'following_user' => $board['following_user'], 'thumbs' => $thumbs, 'avatars' => Helper_Uploadimages::userAvatars($user_data), 'pins' => $board['board_pins'], 'enable_sort' => isset($board['enable_sort']) && $board['enable_sort'] ? $board['enable_sort'] : false, 'enable_follow_board' => $loged ? $board['board_user_id'] != $loged && $user_enable_follow : false, 'enable_follow_user' => $loged ? $board['board_user_id'] != $loged && $user_enable_follow : false, 'enable_follow_user1' => array($loged != $board['board_user_id'], $loged, $board['board_user_id'], $loged, false), 'user_href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $board['board_user_id']), 'user_follow_href' => $loged && $board['board_user_id'] != $loged ? WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $board['board_user_id']) : false, 'board_follow_href' => $loged && $board['board_user_id'] != $loged ? WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board['board_user_id'] . '&board_id=' . $board['board_board_id']) : false, 'edit_url' => $loged && $board['board_user_id'] == $loged ? WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board['board_user_id'] . '&board_id=' . $board['board_board_id']) : false, 'board_url' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['board_user_id'] . '&board_id=' . $board['board_board_id']), 'board_cover' => $loged && $board['board_user_id'] == $loged ? WM_Router::create($request->getBaseUrl() . '?controller=boards&action=cover&user_id=' . $board['board_user_id'] . '&board_id=' . $board['board_board_id'] . (isset($board['history_id']) && $board['history_id'] ? '&hid=' . $board['history_id'] : '')) : false, 'board_accept' => $loged && $board['board_user_id'] != $loged ? WM_Router::create($request->getBaseUrl() . '?controller=users&action=allowInvate&type=accept&user_id=' . $board['board_user_id'] . '&board_id=' . $board['board_board_id']) : false, 'board_decline' => $loged && $board['board_user_id'] != $loged ? WM_Router::create($request->getBaseUrl() . '?controller=users&action=allowInvate&type=decline&user_id=' . $board['board_user_id'] . '&board_id=' . $board['board_board_id']) : false, 'text_pin_s' => $board['board_pins'] == 1 ? $this->translate('Pin') : $this->translate('Pins'), 'text_follow' => $this->translate('Follow'), 'text_unfollow' => $this->translate('Unfollow'), 'text_edit' => $this->translate('Edit'), 'text_edit_board_cover' => $this->translate('Edit Board cover'), 'text_accept' => $this->translate('Accept'), 'text_decline' => $this->translate('No thanks'), 'text_invited_you' => $this->translate('invited you to this board'));
 }
示例#24
0
 public function getPinsAction($return_data = false)
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $pp = (int) Helper_Config::get('config_front_limit');
     if (!(int) $pp) {
         $pp = 50;
     }
     if ((int) $request->getRequest('per_page') > 0 && (int) $request->getRequest('per_page') < 300) {
         $pp = (int) $request->getRequest('per_page');
     }
     $data = array('start' => $pp * $page - $pp, 'limit' => $pp);
     $return = array();
     //Recent Activity
     if ($page == 1 && JO_Session::get('user[user_id]')) {
         $history_data = Model_History_Activity::getHistoryV2(array('start' => 0, 'limit' => 10, 'sort' => 'DESC', 'order' => 'history_id'));
         $history = array();
         foreach ($history_data as $row) {
             $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $row['user_avatar'], 'store' => $row['user_store'], 'user_id' => $row['user_user_id']));
             $haystack_pins = array(Model_History_Abstract::REPIN, Model_History_Abstract::ADDPIN, Model_History_Abstract::COMMENTPIN, Model_History_Abstract::LIKEPIN);
             $text = $row['history_text_type'];
             $href_pin = false;
             /*if( in_array($row['history_history_action'], $haystack_pins) ) {
             // 				if($row['history_history_action'] == Model_History_Abstract::REPIN) {
             					$href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $row['history_pin_id']);
             				} else {*/
             $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $row['history_from_user_id']);
             if (Model_History_Abstract::REPIN == $row['history_history_action']) {
                 $text = array($this->translate('repinned your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::LIKEPIN == $row['history_history_action']) {
                 $text = array($this->translate('like your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::UNLIKEPIN == $row['history_history_action']) {
                 $text = array($this->translate('unlike your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::COMMENTPIN == $row['history_history_action']) {
                 $text = array($this->translate('comment your'), $this->translate('pin'), 1);
                 $href_pin = WM_Router::pinAction($row['history_pin_id']);
             } elseif (Model_History_Abstract::FOLLOW == $row['history_history_action']) {
                 $board_info = new Model_Boards_Board($row['history_board_id']);
                 if ($board_info->count()) {
                     $text = array($this->translate('is now following your'), $board_info['board_title']);
                     $href_pin = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['board_user_id'] . '&board_id=' . $board_info['board_board_id']);
                 }
             } elseif (Model_History_Abstract::UNFOLLOW == $row['history_history_action']) {
                 $board_info = new Model_Boards_Board($row['history_board_id']);
                 if ($board_info->count()) {
                     $text = array($this->translate('has unfollow your'), $board_info['board_title']);
                     $href_pin = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['board_user_id'] . '&board_id=' . $board_info['board_board_id']);
                 }
             }
             //}
             $history[] = array('history_id' => $row['history_history_id'], 'date_added' => $row['history_date_added'], 'profile' => array('fullname' => $row['user_fullname'], 'avatars' => $user_avatars), 'href' => $href, 'href_pin' => $href_pin, 'text_type' => $text, 'text_date_dif' => sprintf($this->translate('%d %s ago'), $row['history_date_dif']['value'], $this->translate($row['history_date_dif']['key'])));
         }
         if ($history) {
             $return[] = array('template' => 'home_history', 'history' => $history, 'text_title_box' => $this->translate('Recent Activity'));
         }
     }
     // pins data
     $pins = new Model_Pins_HomePage($data);
     //format response data
     $formatObject = new Helper_Format();
     if ($pins->count()) {
         $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position >= '" . (int) $data['start'] . "' AND position <= '" . (int) ($data['start'] + $pp) . "'"));
         foreach ($pins->data as $row => $pin) {
             ///banners
             $key = $row + ($pp * $page - $pp);
             if (isset($banners[$key]) && $banners[$key]) {
                 if (($banners_result = $formatObject->fromatListBanners($banners[$key])) !== false) {
                     $return[] = $banners_result;
                 }
             }
             //pins
             $return[] = $formatObject->fromatList($pin);
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No pyngs!');
         } else {
             $message = $this->translate('No more pyngs!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
示例#25
0
 public function editAction()
 {
     $request = $this->getRequest();
     $board_id = $request->getRequest('board_id');
     $board_info = Model_Boards::getBoard($board_id);
     if (!$board_info) {
         $this->forward('error', 'error404');
     }
     $shared = Model_Boards::allowEdit($board_id);
     if ($board_info['user_id'] != JO_Session::get('user[user_id]')) {
         if (!$shared) {
             $this->forward('error', 'error404');
         }
     }
     $this->view->shared = $shared;
     if ($shared) {
         $_POST['newboard'] = $board_info['title'];
         $_POST['category_id'] = $board_info['category_id'];
     }
     $this->view->is_edit = true;
     if ($request->isPost()) {
         if (JO_Session::get('user[user_id]')) {
             if (trim($request->getPost('newboard'))) {
                 $data = Model_Boards::editBoard($board_id, array('title' => trim($request->getPost('newboard')), 'category_id' => $request->getPost('category_id'), 'friends' => $request->getPost('friends')));
                 if ($data) {
                     $data = array();
                     $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $board_id);
                     $this->view->data = $data;
                 } else {
                     $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                 }
             } else {
                 $this->view->error = $this->translate('Board name must not be empty!');
             }
         } else {
             $this->view->error = 'error login';
         }
         echo $this->renderScript('json');
     } else {
         $this->view->cat_title = Model_Boards::getCategoryTitle($board_info['category_id']);
         $this->view->title = $board_info['title'];
         $this->view->category_id = $board_info['category_id'];
         $this->view->another_users = array();
         $this->view->board_id = $board_id;
         $model_images = new Helper_Images();
         foreach ($board_info['board_users'] as $u) {
             $avatar = Helper_Uploadimages::avatar($u, '_A');
             $u['avatar'] = $avatar['image'];
             $u['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $u['user_id']);
             $this->view->another_users[] = $u;
         }
         $uin = Model_Users::getUser($board_info['user_id']);
         $avatar = Helper_Uploadimages::avatar($uin, '_A');
         $this->view->avatar = $avatar['image'];
         $this->view->fullname = $uin['fullname'];
         $this->view->userhref = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $uin['user_id']);
         $this->view->friends_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
         $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $uin['user_id'] . '&board_id=' . $board_id);
         $this->view->board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&user_id=' . $uin['user_id'] . '&board_id=' . $board_id);
         $this->view->board_delete = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=delete&user_id=' . $uin['user_id'] . '&board_id=' . $board_id);
         //////////// 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('popup_form', 'boards');
         $this->setViewChange('form');
         if ($request->isXmlHttpRequest()) {
             $this->view->popup = true;
             echo $this->view->popup_main_box;
             $this->noViewRenderer(true);
         } else {
             $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
         }
     }
 }