Exemplo n.º 1
0
 public function getSearchResultAction($return_data = false)
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $query = $request->getRequest('q');
     $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, 'filter_description' => $query);
     $return = array();
     /* set board count */
     $has_pins = true;
     if (!trim($query)) {
         $has_pins = false;
     }
     // pins data
     $pins = $has_pins ? new Model_Pins_Search($data) : new ArrayObject();
     //format response data
     $formatObject = new Helper_Format();
     if ($has_pins && $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);
 }
Exemplo n.º 2
0
 public function getSearchResultAction($return_data = false)
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $query = $request->getRequest('q');
     $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, 'filter_username' => $query);
     $return = array();
     /* set board count */
     $has_people = true;
     if (!trim($query)) {
         $has_people = false;
     }
     // pins data
     $peoples = $has_people ? new Model_Users_Search($data) : new ArrayObject();
     //format response data
     $formatObject = new Helper_Format();
     if ($has_people && $peoples->count()) {
         $loged = JO_Session::get('user[user_id]');
         /* v2.2 */
         $config_enable_follow_private_profile = Helper_Config::get('config_enable_follow_private_profile');
         /* v2.2 */
         foreach ($peoples as $row => $user) {
             //pins
             $return[] = array('template' => 'people_search', 'user_id' => $user['user_id'], 'loged' => $loged, 'avatars' => Helper_Uploadimages::userAvatars($user), 'fullname' => $user['fullname'], 'location' => $user['location'], 'user_is_follow' => $user['following_user'], 'enable_follow_user' => $loged && $loged != $user['user_id'] && ($config_enable_follow_private_profile ? $user['enable_follow'] : true), 'user_href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']), 'user_follow_href' => $loged && $loged != $user['user_id'] ? WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $user['user_id']) : false, 'text_follow' => $this->translate('Follow'), 'text_unfollow' => $this->translate('Unfollow'));
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No users!');
         } else {
             $message = $this->translate('No more users!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
Exemplo n.º 3
0
 public function getSearchResultAction($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');
     }
     $query = $request->getRequest('q');
     $data = array('start' => $pp * $page - $pp, 'limit' => $pp, 'filter_title' => $query);
     $return = array();
     /* set board count */
     $has_boards = true;
     if (!trim($query)) {
         $has_boards = false;
     }
     // pins data
     $boards = $has_boards ? new Model_Boards_Search($data) : new ArrayObject();
     //format response data
     $formatObject = new Helper_Format();
     if ($has_boards && $boards->count()) {
         foreach ($boards as $row => $board) {
             //boards
             $return[] = $formatObject->fromatListBoard($board);
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No boards!');
         } else {
             $message = $this->translate('No more boards!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
      </tr>
   </thead>
   <tbody>
<?php 
$i = 0;
foreach ($users as $obj) {
    $row = $obj->as_array();
    // reformat dates
    // Note: fields that do not exist in the default configuration are commented out. See /modules/user/classes/model/user.php for details.
    //      <th scope="col">Last login</th>
    //      <th scope="col">Failed logins</th>
    //      <th scope="col">Last failed login</th>
    // $row['created'] = Helper_Format::friendly_datetime($row['created']);
    // $row['modified'] = Helper_Format::friendly_datetime($row['modified']);
    if ($row['last_login'] != '') {
        $row['last_login'] = Helper_Format::relative_time($row['last_login']);
    }
    //   if($row['last_failed_login'] != '0000-00-00 00:00:00') {
    //      $row['last_failed_login'] = Helper_Format::relative_time(strtotime($row['last_failed_login']));
    //   } else {
    //      $row['last_failed_login'] = '******';
    //   }
    // add actions
    $row['actions'] = Html::anchor('admin_user/edit/' . $row['id'], 'Edit') . ' ' . Html::anchor('admin_user/delete/' . $row['id'], 'Delete');
    // set roles
    $row['role'] = '';
    foreach ($obj->roles->find_all() as $role) {
        $row['role'] .= $role->name . ', ';
    }
    // remove last comma
    $row['role'] = substr($row['role'], 0, -2);
Exemplo n.º 6
0
 public function getActivityAction($user_data = array(), $return_data = false)
 {
     if (!$user_data) {
         $this->forward('error', 'error404');
     }
     $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);
     $history = new Model_History_Activity($data, 'from_user_id', $user_data['user_id']);
     $return = array();
     $formatObject = new Helper_Format();
     if ($history->count()) {
         foreach ($history as $key => $row) {
             $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $row['to_user_id']);
             if ($row['history_action'] == Model_History_Abstract::REPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate('Repinned to %s via %s.'), '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>', '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_repin';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::ADDPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate('Pinned to %s.'), '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['activity_class'] = 'a_addpin';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::LIKEPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Liked %s's pin on %s."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_like';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::UNLIKEPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Unliked %s's pin on %s."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_unlike';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::COMMENTPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Commented on %s's pin and said \"%s\"."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', JO_Utf8::splitText($row['comment'], 60, '...'));
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_comment';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::ADDBOARD) {
                 $row['user_user_id'] = $row['from_user_id'];
                 $row_data = $formatObject->fromatListBoard($row);
                 $row_data['set_activity_title'] = $this->translate('Created');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_addboard';
                 $return[] = $row_data;
             } else {
                 if ($row['history_action'] == Model_History_Abstract::FOLLOW_USER) {
                     $row_data = $formatObject->fromatUserFollow($row);
                     $row_data['activity_class'] = 'a_follow_user';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::UNFOLLOW_USER) {
                     $row_data = $formatObject->fromatUserFollow($row);
                     $row_data['activity_class'] = 'a_unfollow_user';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::FOLLOW) {
                     $row['user_user_id'] = $row['from_user_id'];
                     $row_data = $formatObject->fromatListBoard($row);
                     $row_data['set_activity_title'] = $this->translate('Follow');
                     $row_data['history_id'] = $row['history_id'];
                     $row_data['activity_class'] = 'a_follow_board';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::UNFOLLOW) {
                     $row['user_user_id'] = $row['from_user_id'];
                     $row_data = $formatObject->fromatListBoard($row);
                     $row_data['set_activity_title'] = $this->translate('Unfollow');
                     $row_data['history_id'] = $row['history_id'];
                     $row_data['activity_class'] = 'a_unfollow_board';
                     $return[] = $row_data;
                 }
             }
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No activity!');
         } else {
             $message = $this->translate('No more activity!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
Exemplo n.º 7
0
 public function getOtherDataAction()
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $pin_id = $request->getRequest('pin_id');
     $pin_info = new Model_Pins_Pin($pin_id);
     $return = array();
     $formatObject = new Helper_Format();
     if ($pin_info->count()) {
         $pin_info = $pin_info->data;
         $pin_info = array_merge((array) $pin_info, Helper_Pin::formatPinData((array) $pin_info));
         $loged = JO_Session::get('user[user_id]');
         /* v2.2 */
         $config_enable_follow_private_profile = Helper_Config::get('config_enable_follow_private_profile');
         if ($config_enable_follow_private_profile) {
             $user_enable_follow = $pin_info['via_user_id'] ? $pin_info['via_enable_follow'] : $pin_info['user_enable_follow'];
         } else {
             $user_enable_follow = true;
         }
         /* v2.2 */
         $return = array('loged' => $loged, 'enable_follow_board' => $loged ? $pin_info['board_user_id'] != $loged && $user_enable_follow : false, 'enable_follow_user' => $loged ? $pin_info['user_user_id'] != $loged && $user_enable_follow : false, 'enable_follow_via' => $loged ? ($pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['user_user_id']) != $loged && $user_enable_follow : false, 'board_is_follow' => $pin_info['following_board'], 'via_is_follow' => $pin_info['via_user_id'] ? $pin_info['following_via'] : $pin_info['following_user'], 'pin_likes' => $pin_info['pin_likes'], 'pin_likes_total' => $pin_info['pin_likes'] > 20 ? $pin_info['pin_likes'] - 20 : 0, 'user_follow_href' => $pin_info['user_follow_href'], 'board_follow_href' => $pin_info['board_follow_href'], 'via_follow_href' => $pin_info['via_follow_href'], 'text_unfollow' => $this->translate('Unfollow'), 'text_follow' => $this->translate('Follow'), 'text_likes' => $this->translate('Likes'), 'text_repins' => $this->translate('Repins'), 'text_onto_board' => $this->translate('Pinned onto the board'), 'text_onto' => $this->translate('onto'), 'text_originally_pinned' => $this->translate('Originally pinned by'), 'text_pined_via' => sprintf($this->translate('Pinned via %s from'), Helper_Config::get('site_name')), 'pin_likes_total_text' => sprintf($this->translate('+%d more likes'), $pin_info['pin_likes'] - 20));
         //other pins from board
         $return['onto_board'] = false;
         $pins = new Model_Pins_Boards(array('start' => 0, 'limit' => 12, 'filter_board_id' => $pin_info['pin_board_id']));
         if ($pins->count()) {
             $board_info = new Model_Boards_Board($pin_info['pin_board_id']);
             if ($board_info->count()) {
                 $href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_info['pin_user_id'] . '&board_id=' . $pin_info['pin_board_id']);
                 $return['onto_board'] = array('pins' => array(), 'url' => $href, 'name' => $pin_info['board_title'], 'user_id' => $board_info['user_user_id']);
                 $total = $pins->count();
                 foreach ($pins->data as $row => $pin) {
                     $pin['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['onto_board']['pins'][] = array('images' => Helper_Uploadimages::pinThumbs($pin), 'href' => $href, 'key' => $key);
                 }
             }
         }
         // others pin from via or user
         $return['originally_pinned'] = false;
         $pins = new Model_Pins_Users(array('start' => 0, 'limit' => 6, 'filter_user_id' => $pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['pin_user_id']));
         if ($pins->count()) {
             $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . ($pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['pin_user_id']));
             $return['originally_pinned'] = array('pins' => array(), 'url' => $href, 'name' => $pin_info['via_user_id'] ? $pin_info['via_fullname'] : $pin_info['user_fullname'], 'via' => $pin_info['via_user_id'] ? true : false, 'user_id' => $pin_info['via_user_id'] ? $pin_info['via_user_id'] : $pin_info['pin_user_id']);
             $total = $pins->count();
             foreach ($pins->data as $row => $pin) {
                 $pin['pin_id'] = $pin['pin_pin_id'];
                 $key = false;
                 if ($row == 0) {
                     $key = 'first';
                 } else {
                     if ($row == $total - 1) {
                         $key = 'last';
                     }
                 }
                 $return['originally_pinned']['pins'][] = array('images' => Helper_Uploadimages::pinThumbs($pin), 'href' => $href, 'key' => $key);
             }
         }
         // others pin from source
         $return['source'] = false;
         if ($pin_info['pin_source_id']) {
             $pins = new Model_Pins_Source(array('start' => 0, 'limit' => 5, 'filter_source_id' => $pin_info['pin_source_id']));
             if ($pins->count()) {
                 $href = WM_Router::create($request->getBaseUrl() . '?controller=source&source_id=' . $pin_info['pin_source_id']);
                 $return['source'] = array('pins' => array(), 'url' => $href, 'name' => $pin_info['source_source']);
                 $total = $pins->count();
                 foreach ($pins->data as $row => $pin) {
                     $pin['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['source']['pins'][] = array('images' => Helper_Uploadimages::pinThumbs($pin), 'href' => $href, 'key' => $key);
                 }
             }
         }
         // others pin likes
         $return['users_likes'] = false;
         if ($pin_info['pin_likes']) {
             $users = new Model_Users_LikesPin(array('start' => 0, 'limit' => 20, 'filter_like_pin_id' => $pin_info['pin_id']));
             if ($users->count()) {
                 $total = $users->count();
                 foreach ($users as $row => $user) {
                     $user['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['users_likes'][] = array('avatars' => Helper_Uploadimages::userAvatars($user), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']), 'fullname' => $user['fullname'], 'key' => $key);
                 }
             }
         }
         // others pin from source
         $return['users_repins'] = false;
         if ($pin_info['pin_repins']) {
             $pins = new Model_Pins_Repins(array('start' => 0, 'limit' => 6, 'filter_like_pin_id' => $pin_info['pin_id']));
             if ($pins->count()) {
                 $total = $pins->count();
                 foreach ($pins->data as $row => $pin) {
                     $pin['pin_id'] = $pin['pin_pin_id'];
                     $key = false;
                     if ($row == 0) {
                         $key = 'first';
                     } else {
                         if ($row == $total - 1) {
                             $key = 'last';
                         }
                     }
                     $return['users_repins'][$pin['user_user_id']] = array('user' => array('fullname' => $pin['user_fullname'], 'avatars' => Helper_Uploadimages::userAvatars(array('avatar' => $pin['user_avatar'], 'store' => $pin['user_store'], 'user_id' => $pin['user_user_id'])), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_user_id'])), 'board' => array('name' => $pin['board_title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['user_user_id'] . '&board_id=' . $pin['board_board_id'])), 'key' => $key);
                 }
             }
         }
     }
     //format response data
     $formatObject = new Helper_Format();
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
Exemplo n.º 8
0
 public function feedAction($data = array())
 {
     $request = $this->getRequest();
     if (!$data) {
         $this->forward('error', 'error404');
     } else {
         $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, 'filter_board_id' => $request->getParam('board_id'));
         $pins = new Model_Pins_Boards($data);
         $formatObject = new Helper_Format();
         $this->view->item = array();
         if ($pins->count()) {
             foreach ($pins->data as $pin) {
                 $pin = $formatObject->fromatList($pin);
                 $category_info = Model_Categories::getCategory($pin['category_id']);
                 if ($category_info) {
                     $pin['text_board'] = $category_info['title'] . ' >> ' . $pin['text_board'];
                 }
                 $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $pin['images']['thumb_image_b'], 'description' => $pin['description'], 'title' => JO_Utf8::splitText($pin['description'], 60, '...'), 'link' => $pin['pin_url'], 'author' => $pin['author_profile']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['text_board']);
             }
         }
         echo $this->renderScript('rss');
     }
 }
Exemplo n.º 9
0
 public function getMediasAction()
 {
     $request = $this->getRequest();
     $medias = array();
     if ($request->isXmlHttpRequest()) {
         $media_id_not_in = JO_Session::get('media_id_not_in_' . JO_Session::get('user[user_id]'));
         if ($request->getQuery('first') == 'true') {
             $media_id_not_in = array();
         }
         if (!is_array($media_id_not_in)) {
             $media_id_not_in = array();
         }
         $data = array('filter_user_id' => JO_Session::get('user[user_id]'), 'media_id_not_in' => $media_id_not_in);
         $meduas = Model_Instagram_Media::getUserMediasData($data);
         foreach ($meduas as $image) {
             $old_image = basename($image['media']);
             $new_image = str_replace($old_image, str_replace('_7', '_5', $old_image), $image['media']);
             $medias[] = array('title' => $image['title'], 'media_id' => $image['media_id'], 'thumb' => $new_image);
             $media_id_not_in[$image['media_id']] = $image['media_id'];
         }
         JO_Session::set('media_id_not_in_' . JO_Session::get('user[user_id]'), $media_id_not_in);
         //echo 'addResponseData('.JO_Json::encode($medias).');';
     }
     $this->noViewRenderer(true);
     $objectFormat = new Helper_Format();
     $objectFormat->responseJsonCallback($medias);
 }
Exemplo n.º 10
0
 public function boardsAction()
 {
     $request = $this->getRequest();
     $category_id = $request->getPost('category_id');
     $this->view->boards = array();
     if ($category_id) {
         /* v2.2 */
         $config_enable_follow_private_profile = '';
         if (Helper_Config::get('config_enable_follow_private_profile')) {
             $config_enable_follow_private_profile = ' AND boards.user_id IN (SELECT user_id FROM users WHERE public = 1)';
         }
         /* v2.2 */
         $boards = new Model_Boards_PopularBoards(array('start' => 0, 'limit' => 25, 'sort' => 'DESC', 'order' => 'boards.total_views', 'where' => new JO_Db_Expr("boards.category_id = '" . $category_id . "' AND boards.pins > 0 " . $config_enable_follow_private_profile)));
         if ($boards->count()) {
             $formatObject = new Helper_Format();
             foreach ($boards as $board) {
                 $data = $formatObject->fromatListBoard($board);
                 $this->view->boards[] = array('board_id' => $data['board_id'], 'thumbs' => $data['thumbs'], 'title' => $data['title'], 'fullname' => $data['fullname'], 'autor_id' => $board['board_user_id'], 'following_board' => $data['following_board'], 'text_by' => $this->translate('by'), 'text_follow' => $this->translate('Follow'), 'text_unfollow' => $this->translate('Unfollow'), 'board_follow_href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $data['autor_id'] . '&board_id=' . $data['board_id']));
             }
         } else {
             $this->view->error = $this->translate('No boards in this category!');
         }
     }
     echo $this->renderScript('json');
 }