Beispiel #1
0
 public static function avatar($user, $size = null)
 {
     $image = call_user_func(array(Helper_Pin::formatUploadModule($user['store']), 'getUserImage'), $user, $size);
     if (!$image) {
         $user['avatar'] = JO_Registry::get('no_avatar');
         $image = call_user_func(array(Helper_Pin::formatUploadModule('locale'), 'getUserImage'), $user, $size);
     }
     return $image;
 }
Beispiel #2
0
 public static function createEvent($user_id, $event_id, $data)
 {
     $db = JO_Db::getDefaultAdapter();
     $rows = self::describeTable('events');
     //$user_info_get = self::getUser($user_id);
     //$created = WM_Date::format($user_info_get['created'], 'yy-mm-dd H:i:s');
     $update = array();
     $avatar = '';
     $followers = false;
     foreach ($rows as $row) {
         if (array_key_exists($row, $data)) {
             if ($row == 'avatar') {
                 if ($data[$row]) {
                     JO_Session::clear('upload_avatar');
                     $avatar = $data[$row];
                 } else {
                     //$update[$row] = $data[$row];
                 }
             } else {
                 $update[$row] = $data[$row];
                 if ($row == 'compartir' && $data[$row] == 'followers') {
                     $followers = true;
                 }
                 if ($row == 'date_event') {
                     $fecha = str_replace("/", "-", $data[$row]);
                     $update[$row] = WM_Date::format($fecha, 'yy-mm-dd H:i:s');
                 }
             }
         }
     }
     if (!$update) {
         if (!$avatar) {
             return false;
         }
     }
     $user_data = "";
     if ($event_id) {
         $user_data = Model_Events::getEventUser((string) $user_id, $event_id);
         if (!$user_data) {
             $db->insert('events', $update);
             $event_id = $db->lastInsertId();
             if ($followers) {
                 $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id));
                 if ($users) {
                     foreach ($users as $key => $user) {
                         Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id);
                         //self::FollowEvent($event_id, $user['user_id']);
                     }
                 }
             }
             if (!$event_id) {
                 return false;
             }
         } else {
             $result = $db->update('events', $update, array('user_id = ' . (string) $user_id . ' AND event_id = ' . (string) $event_id));
             if ($followers) {
                 $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id));
                 if ($users) {
                     foreach ($users as $key => $user) {
                         Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id);
                         //self::FollowEvent($event_id, $user['user_id']);
                     }
                 }
             }
             if (!$result) {
                 return false;
             }
         }
     } else {
         $db->insert('events', $update);
         $event_id = $db->lastInsertId();
         if ($followers) {
             $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id));
             if ($users) {
                 foreach ($users as $key => $user) {
                     Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id);
                     //self::FollowEvent($event_id, $user['user_id']);
                 }
             }
         }
         if (!$event_id) {
             return false;
         }
     }
     if ($avatar) {
         ///// upload images
         //error_log("Vamos a subir la imagen");
         $front = JO_Front::getInstance();
         $request = JO_Request::getInstance();
         $upload_model = Helper_Pin::formatUploadModule(JO_Registry::get('default_upload_method'));
         $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model);
         if (!file_exists($upload_model_file)) {
             $upload_model = Helper_Pin::formatUploadModule('locale');
             $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model);
         }
         $image = false;
         if (file_exists($upload_model_file)) {
             //error_log("EXISTE FILE");
             $image = call_user_func(array($upload_model, 'uploadEventImage'), $avatar, $event_id);
         }
         if ($image) {
             //error_log("EXISTE FILE");
             $result = $db->update('events', array('avatar' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width'], 'last_action_datetime' => new JO_Db_Expr('NOW()')), array('user_id = ' . (string) $user_id . ' AND event_id = ' . (string) $event_id));
             if ($user_data) {
                 if ($user_data['avatar']) {
                     if ($user_data['avatar'] != $image['image']) {
                         call_user_func(array(Helper_Pin::formatUploadModule($user_data['store']), 'deleteEventImage'), $user_data);
                     }
                 }
             }
         }
     }
     return true;
 }
Beispiel #3
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);
         }
     }
 }
Beispiel #4
0
 public static function edit($user_id, $data)
 {
     $db = JO_Db::getDefaultAdapter();
     $rows = self::describeTable('users');
     $user_info_get = self::getUser($user_id);
     $date_added = WM_Date::format($user_info_get['date_added'], 'yy-mm-dd H:i:s');
     $update = array();
     $avatar = '';
     foreach ($rows as $row) {
         if (array_key_exists($row, $data)) {
             if ($row == 'avatar') {
                 if ($data[$row]) {
                     JO_Session::clear('upload_avatar');
                     $avatar = $data[$row];
                 } else {
                     //$update[$row] = $data[$row];
                 }
             } elseif ($row == 'password' || $row == 'new_password') {
                 $update[$row] = md5($data[$row]);
             } elseif ($row == 'location') {
                 if ($data[$row] != "Introduce tu ubicación") {
                     $update[$row] = $data[$row];
                 }
             } elseif ($row == 'firstname') {
                 $update[$row] = self::quotesFix($data[$row]);
             } elseif ($row == 'description') {
                 $update[$row] = self::quotesFix($data[$row]);
             } else {
                 $update[$row] = $data[$row];
             }
         }
     }
     if (!$update) {
         if (!$avatar) {
             return false;
         }
     }
     $rebuild = $result = $db->update('users', $update, array('user_id = ?' => (string) $user_id));
     if ($avatar) {
         ///// upload images
         //error_log("Vamos a subir la imagen");
         $front = JO_Front::getInstance();
         $request = JO_Request::getInstance();
         $upload_model = Helper_Pin::formatUploadModule(JO_Registry::get('default_upload_method'));
         $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model);
         if (!file_exists($upload_model_file)) {
             $upload_model = Helper_Pin::formatUploadModule('locale');
             $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model);
         }
         $image = false;
         if (file_exists($upload_model_file)) {
             //error_log("EXISTE FILE");
             $image = call_user_func(array($upload_model, 'uploadUserAvatar'), $avatar, $user_id);
         }
         if ($image) {
             //error_log("EXISTE FILE");
             $result = $db->update('users', array('avatar' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width'], 'last_action_datetime' => new JO_Db_Expr('NOW()')), array('user_id = ?' => (string) $user_id));
             if ($user_info_get && $user_info_get['avatar']) {
                 if ($user_info_get['avatar'] != $image['image']) {
                     call_user_func(array(Helper_Pin::formatUploadModule($user_info_get['store']), 'deleteUserImage'), $user_info_get);
                 }
             }
             if (!$rebuild) {
                 $rebuild = $result;
             }
         }
     }
     if (isset($data['username'])) {
         $db->query("DELETE FROM url_alias WHERE query = 'user_id=" . (string) $user_id . "'");
         $db->insert('url_alias', array('query' => 'user_id=' . (string) $user_id, 'keyword' => $data['username'], 'path' => $data['username'], 'route' => 'users/profile'));
     }
     if ($rebuild) {
         $total = $db->update('pins', array('date_modified' => WM_Date::format(time(), 'yy-mm-dd H:i:s')), array('user_id = ? OR (pin_id IN (SELECT DISTINCT pin_id FROM pins_comments WHERE user_id = ?))' => (string) $user_id));
     }
     $db->update('users', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE user_id = users.user_id)'), 'boards' => new JO_Db_Expr('(SELECT COUNT(DISTINCT board_id) FROM boards WHERE user_id = users.user_id)'), 'likes' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins_likes WHERE user_id = users.user_id)'), 'following' => new JO_Db_Expr('(SELECT COUNT(DISTINCT following_id) FROM users_following_user WHERE user_id = users.user_id AND following_id != users.user_id)'), 'followers' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = users.user_id AND user_id != users.user_id)'), 'liking' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_like_id) FROM users_likes WHERE user_id = users.user_id AND user_like_id != users.user_id)'), 'likers' => new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM users_likes WHERE user_like_id = users.user_id AND user_id != users.user_id)')), array('user_id = ?' => (string) $user_id));
     return true;
 }
Beispiel #5
0
 public static function delete($pin_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $pin_info = self::getPin($pin_id);
     if (!$pin_info) {
         return false;
     }
     call_user_func(array(Helper_Pin::formatUploadModule($pin_info['store']), 'deletePinImage'), $pin_info);
     if ($pin_info['latest_comments']) {
         foreach ($pin_info['latest_comments'] as $c) {
             self::deleteComment($c['comment_id']);
         }
     }
     self::deleteCache($pin_info);
     $del = $db->delete('pins', array('pin_id = ?' => $pin_id));
     if (!$del) {
         return false;
     } else {
         $latest_pins = array();
         $pins_query = $db->select()->from('pins', array('pin_id', 'pin_id'))->where('user_id = ?', $pin_info['user_id'])->order('pin_id DESC')->limit(15);
         $latest = $db->fetchPairs($pins_query);
         if ($latest) {
             $latest_pins = $latest;
         }
         $db->delete('pins_invert', array('pin_id = ?' => $pin_id));
         $db->delete('pins_likes', array('pin_id = ?' => $pin_id));
         $db->delete('pins_reports', array('pin_id = ?' => $pin_id));
         $db->delete('pins_views', array('pin_id = ?' => $pin_id));
         $db->delete('users_history', array('pin_id = ?' => $pin_id));
         $db->delete('pins_images', array('pin_id = ?' => $pin_id));
         $update = array('pins' => new JO_Db_Expr("(SELECT COUNT(pin_id) FROM pins WHERE user_id=users.user_id)"), 'latest_pins' => implode(',', $latest_pins));
         $update['likes'] = new JO_Db_Expr('likes-' . (int) $db->fetchOne($db->select()->from('pins_likes', 'COUNT(like_id)')->where('pin_id = ?', $pin_id)));
         $db->update('users', $update, array('user_id=?' => $pin_info['user_id']));
         $latest_pins = array();
         $pins_query = $db->select()->from('pins', array('pin_id', 'pin_id'))->where('board_id = ?', $pin_info['board_id'])->order('pin_id DESC')->limit(15);
         $latest = $db->fetchPairs($pins_query);
         if ($latest) {
             $latest_pins = $latest;
         }
         $update = array('pins' => new JO_Db_Expr('(SELECT COUNT(pin_id) FROM pins WHERE board_id=boards.board_id)'), 'latest_pins' => implode(',', $latest_pins));
         $update['latest_pins'] = implode(',', $latest_pins);
         $db->update('boards', $update, array('board_id=?' => $pin_info['board_id']));
         return true;
     }
 }
Beispiel #6
0
 public function searchAction()
 {
     $this->noViewRenderer(true);
     $request = $this->getRequest();
     $response = $this->getResponse();
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $callback = $request->getRequest('callback');
     if (!preg_match('/^([a-z0-9_.]{1,})$/', $callback)) {
         $callback = false;
     }
     $data = array();
     $url = "";
     $return = array();
     $kind = $request->getRequest('kind');
     $query = $request->getRequest('query');
     $userId = $request->getRequest('userId');
     if ($kind == 0) {
         // pins
         $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_description' => $query, 'filter_marker' => $request->getRequest('marker'));
         $this->view->pins = '';
         $pins = Model_Pins::getPinsAPP($data);
         if ($pins) {
             $model_images = new Helper_Images();
             foreach ($pins as $pin) {
                 $images = array();
                 $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B');
                 if ($image) {
                     $images['thumb']['src'] = $image['image'];
                     $images['thumb']['width'] = $image['width'];
                     $images['thumb']['height'] = $image['height'];
                     $images['original'] = $image['original'];
                 }
                 $categorias = array();
                 $categories = Model_Categories::getCategory($pin['category_id']);
                 if ($categories['parent_id'] != 0) {
                     $categorias['category_id'] = $categories['parent_id'];
                     $categorias['subcategory_id'] = $categories['category_id'];
                 } else {
                     $categorias['category_id'] = $categories['category_id'];
                     $categorias['subcategory_id'] = $categories['parent_id'];
                 }
                 $pos = strripos($pin['image'], '.');
                 $return['data'][] = array('pin_id' => $pin['pin_id'], 'pinFooter' => $pin['description'], 'category_id' => $categorias['category_id'], 'subcategory_id' => $categorias['subcategory_id'], 'pinImage' => substr_replace($pin['image'], '_B.', $pos, 1), 'pinWidth' => $pin['width'], 'pinHeight' => $pin['height'], 'pinUrl' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']), 'userId' => $pin['user_id'], 'username' => $pin['username'], 'avatar' => $pin['avatar'], 'userLike' => $pin['liked'], 'pinVideo' => $pin['from']);
             }
             $return['next_page'] = WM_Router::create($request->getBaseUrl() . '?controller=apiv1&action=timeline' . $url);
         }
     } else {
         if ($kind == 1) {
             //boards
             $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_title' => $query);
             $this->view->pins = '';
             $boards = Model_Boards::getBoards($data);
             if ($boards) {
                 $view = JO_View::getInstance();
                 $view->loged = JO_Session::get('user[user_id]');
                 $view->enable_sort = false;
                 $model_images = new Helper_Images();
                 foreach ($boards as $board) {
                     $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
                     $board['thumbs'] = array();
                     $get_big = false;
                     for ($i = 0; $i < 5; $i++) {
                         $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false;
                         if ($image) {
                             if ($get_big) {
                                 $size = '_A';
                             } else {
                                 $size = '_C';
                                 $get_big = true;
                             }
                             $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size);
                             if ($data_img) {
                                 $board['thumbs'][] = $data_img['image'];
                             } else {
                                 $board['thumbs'][] = false;
                             }
                         } else {
                             $board['thumbs'][] = false;
                         }
                     }
                     $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id']));
                     $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]');
                     $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
                     $board['edit'] = false;
                     if ($board['user_id'] == JO_Session::get('user[user_id]') || Model_Boards::allowEdit($board['board_id'])) {
                         $board['userFollowIgnore'] = false;
                         $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
                     }
                     $username = Model_Users::getUsername($board["user_id"]);
                     $url_base = WM_Router::create($request->getBaseUrl());
                     $return['data'][] = array('folderId' => $board['board_id'], 'folderName' => $board['title'], 'folderUrl' => $url_base . $username . "/" . $board['title'], 'folderImage' => $board['image'], 'folderQty' => $board['pins']);
                     //$return[] = $board;
                 }
             }
         } else {
             if ($kind == 2) {
                 //people
                 $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_username' => $query);
                 $users = Model_Users::getUsers($data);
                 if ($users) {
                     $this->view->follow_user = true;
                     $view = JO_View::getInstance();
                     $view->loged = JO_Session::get('user[user_id]');
                     $model_images = new Helper_Images();
                     foreach ($users as $key => $user) {
                         $avatar = Helper_Uploadimages::avatar($user, '_B');
                         $user['avatar'] = $avatar['image'];
                         if ($view->loged) {
                             $user['userIsFollow'] = Model_Users::isFollowUser($user['user_id']);
                             $user['userFollowIgnore'] = $user['user_id'] == JO_Session::get('user[user_id]');
                         } else {
                             $user['userFollowIgnore'] = true;
                         }
                         $user['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']);
                         $user['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user['user_id']);
                         $return['data'][] = array('userId' => $user['user_id'], 'userName' => $user['username'], 'userDesc' => $user['description'], 'userLocation' => $user['location'], 'avatar' => $user['avatar'], 'follower' => $user['followers'], 'following' => $user['following']);
                     }
                 }
             }
         }
     }
     if ($callback) {
         $return = $callback . '(' . JO_Json::encode($return) . ')';
     } else {
         $response->addHeader('Cache-Control: no-cache, must-revalidate');
         $response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         $response->addHeader('Content-type: application/json');
         $return = JO_Json::encode($return);
     }
     $response->appendBody($return);
 }
Beispiel #7
0
 public function likingAction()
 {
     $request = $this->getRequest();
     $user_data = $this->profileHelp();
     $this->setViewChange('profile');
     $this->view->active = 'liking';
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $users = Model_Users::getUsers(array('filter_likers_user_id' => $user_data['user_id']));
     $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 < 8; $i++) {
                 $image = isset($user['pins_array'][$i]) ? $user['pins_array'][$i]['image'] : false;
                 if ($image) {
                     $data_img = call_user_func(array(Helper_Pin::formatUploadModule($user['pins_array'][$i]['store']), 'getPinImage'), $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['userFollowIgnore'] = true;
             if ($view->loged) {
                 $user['userIsLike'] = Model_Users::isLikeUser($user['user_id']);
                 $user['userLikeIgnore'] = $user['user_id'] == JO_Session::get('user[user_id]');
             } else {
                 $user['userLikeIgnore'] = 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['likeUser'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $user['user_id']);
             $view->key = $key % 2 == 0;
             $view->user = $user;
             $this->view->boards .= $view->render('box', 'users');
         }
     }
     $this->view->class_contaner = 'persons';
     $agendas = Model_Users::getUserAgenda(array('filter_user_id' => $user_data['user_id']));
     $this->view->has_agendas = false;
     $this->view->agendas_users = "";
     if ($agendas) {
         $this->view->has_agendas = true;
         foreach ($agendas as $agenda) {
             $agenda['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopupDelete&agenda_id=' . $agenda['agenda_id'] . '&user_id=' . $user_data['user_id']);
             $this->view->agenda = $agenda;
             $this->view->agendas_users .= $this->view->render('agenda', 'users');
         }
     }
     $session_user = JO_Session::get('user[user_id]');
     $this->view->popup_agenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopup&user_id=' . $user_data['user_id']);
     //no mover de esta ubicación
     $messages = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => 0));
     $this->view->has_messages = false;
     $this->view->messages_users = "";
     if ($messages) {
         $this->view->has_messages = true;
         foreach ($messages as $message) {
             $avatar = Helper_Uploadimages::avatar($message, '_A');
             $message['avatar'] = $avatar['image'];
             $message['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $message['user_id']);
             $message['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $message['message_id'] . '&user_id=' . $user_data['user_id']);
             $message['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $message['message_id']);
             $this->view->message = $message;
             $this->view->messages_users .= $this->view->render('message', 'users');
             //ahora vamos a consultar las respuestas a este:
             $messagesHijos = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => $message['message_id']));
             if ($messagesHijos) {
                 foreach ($messagesHijos as $messageHijo) {
                     $avatar = Helper_Uploadimages::avatar($messageHijo, '_A');
                     $messageHijo['avatar'] = $avatar['image'];
                     $messageHijo['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $messageHijo['user_id']);
                     $messageHijo['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $messageHijo['message_id'] . '&user_id=' . $user_data['user_id']);
                     $messageHijo['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $messageHijo['message_id']);
                     $this->view->message = $messageHijo;
                     $this->view->messages_users .= $this->view->render('message', 'users');
                 }
             }
         }
     }
     $session_user = JO_Session::get('user[user_id]');
     $this->view->popup_messages = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=0');
     //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activatePopup'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0'  );
     //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activateDetail'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0'  );
     $_SESSION["activate_url"] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
     $this->view->popup_activate = WM_Router::create($request->getBaseUrl() . '?controller=users&action=activate');
     $this->view->search_url = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=activate');
     //$this->view->deportes = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=deportes');
     $this->view->addMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=create');
     $this->view->stateMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=state');
     $this->view->viewMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=view');
     $activate = Model_Users::getActivateUser(JO_Session::get('user[user_id]'));
     if ($activate) {
         $this->view->userIsActivate = $activate["activate"];
     }
     if ($user_data['type_user']) {
         $this->view->userCanActivate = Model_Users::getUserTypeNotOthers($user_data['type_user']);
     }
     if (JO_Registry::get('isMobile')) {
         $this->view->urlagenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agenda&user_id=' . $user_data['user_id']);
         $this->view->urlmensajes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=mensajes&user_id=' . $user_data['user_id']);
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->view->boards;
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
 }
Beispiel #8
0
 public function feedAction($data = array())
 {
     $request = $this->getRequest();
     if (!$data) {
         $this->forward('error', 'error404');
     } else {
         $this->view->item = array();
         $model_images = new Helper_Images();
         foreach ($data['pins'] as $pin) {
             $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_D');
             if ($image) {
                 $enclosure = $image['image'];
             } else {
                 continue;
             }
             $category_info = Model_Categories::getCategory($pin['category_id']);
             if ($category_info) {
                 $pin['board'] = $category_info['title'] . ' >> ' . $pin['board'];
             }
             $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $enclosure, 'description' => Helper_Pin::descriptionFix($pin['description']), 'title' => Helper_Pin::descriptionFix(JO_Utf8::splitText($pin['description'], 60, '...')), 'link' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']), 'author' => $pin['user']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['board']);
         }
         echo $this->renderScript('rss');
     }
 }