public function post_delevents() { $code = 0; $message = "ok"; if ($this->auth_status) { $events = Model_Events::find(Input::post("id", 0)); if ($events != null) { $events->deleted_at = time(); $events->save(); } else { $code = 404; $message = "Content not found."; } } else { $code = 500; $message = "Auth error."; } $this->response(array('code' => $code, 'message' => $message)); }
public function deleteMultiCommentsAction() { $this->setInvokeArg('noViewRenderer', true); if (!WM_Users::allow('delete', $this->getRequest()->getController())) { echo $this->translate('You do not have permission to this action'); } else { $action_check = $this->getRequest()->getPost('action_check'); if ($action_check && is_array($action_check)) { foreach ($action_check as $record_id) { Model_Events::deleteComment($record_id); } } } }
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; }
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); } } }
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'); }
public function likeAction() { $this->noViewRenderer(true); $request = $this->getRequest(); if ((int) JO_Session::get('user[user_id]')) { $history_user_id = $request->getRequest('userio_id'); $user_id = JO_Session::get('user[user_id]'); $event_id = $request->getRequest('event_id'); if ($user_id) { if (Model_Events::isLikeEvent($event_id, $user_id)) { $result = Model_Events::UnLikeEvent($event_id, $user_id); if ($result) { $this->view->ok = $this->translate('Me gusta'); $this->view->classs = 'add'; Model_History::addHistory($history_user_id, Model_History::UNLIKE_EVENT, $event_id); } else { $this->view->error = true; } } else { $result = Model_Events::LikeEvent($event_id, $user_id); if ($result) { $this->view->ok = $this->translate('No me gusta'); $this->view->classs = 'remove'; Model_History::addHistory($history_user_id, Model_History::LIKE_EVENT, $event_id); /* if ($board_info['email_interval'] == 1 && $board_info['follows_email']) { $this->view->user_info = $board_info; $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('now follow you'); Model_Email::send( $board_info['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('follow your'), $this->view->render('follow_user', 'mail') ); } * */ } else { $this->view->error = true; } } } else { $this->view->error = true; } } else { $this->view->location = WM_Router::create($request->getBaseUrl() . '?controller=landing'); } if ($request->isXmlHttpRequest()) { echo $this->renderScript('json'); } else { $this->redirect($request->getServer('HTTP_REFERER')); } }
public function action_add() { if (Input::get("del_id", 0) != 0) { $del_reserve = Model_Lessontime::find(Input::get("del_id", 0)); if ($del_reserve != null) { if ($del_reserve->student_id == $this->user->id) { // send mail $body = View::forge("email/students/cancel_lesson"); date_default_timezone_set(Config::get("timezone.timezone")[$del_reserve->student->timezone]); $body->set("name", $this->user->firstname); $body->set("reservation", $del_reserve); $sendmail = Email::forge("JIS"); $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name")); $sendmail->to($this->user->email); $sendmail->subject("Cancellation of Lesson / Game-bootcamp"); $sendmail->html_body(htmlspecialchars_decode($body)); $sendmail->send(); // send mail $body = View::forge("email/teachers/cancel_lesson"); date_default_timezone_set(Config::get("timezone.timezone")[$del_reserve->teacher->timezone]); $body->set("name", $del_reserve->teacher->firstname); $body->set("reservation", $del_reserve); $sendmail = Email::forge("JIS"); $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name")); $sendmail->to($del_reserve->teacher->email); $sendmail->subject("Cancellation of Lesson / Game-bootcamp"); $sendmail->html_body(htmlspecialchars_decode($body)); $sendmail->send(); date_default_timezone_set(Config::get("timezone.timezone")[$this->user->timezone]); $del_reserve->student_id = 0; $del_reserve->status = 0; $del_reserve->save(); //cancel booking for shared db (set the status to 0) and send data to shared db $query = DB::update('reservation')->value('status', 0)->where('student_id', $this->user->id)->where('edoo_tutor', $del_reserve->teacher->email)->where('freetime_at', $del_reserve->freetime_at)->execute('shared'); } } } $reserved = Model_Lessontime::find("first", ["where" => [["student_id", $this->user->id], ["status", 1], ["deleted_at", 0]]]); $pasts = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]); $lastClass = Model_Lessontime::find("last", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", 0)], ["deleted_at", 0]]]); if ($pasts == null) { $pasts = []; } $data["studentplace"] = Model_User::find("all"); $id = Input::get("id", 0); if ($id != 0 and $reserved == null and ($this->user->charge_html == 1 or Input::get("course", 0) == -1)) { if (Model_Lessontime::courseNumber_1(Input::get("course", 0)) > count($pasts)) { $reserve = Model_Lessontime::find($id); if ($reserve != null) { if ($reserve->status == 0 and $reserve->student_id == 0) { $reserve->student_id = $this->user->id; $reserve->language = Input::get("course", 0); $reserve->status = 1; $reserve->number = count($pasts) + 1; $reserve->history = $this->user->place; $reserve->save(); Model_Lessontime::sendReservedEMail($reserve->id); $reserved = $reserve; //send data to shared db $check_exist = DB::select()->from('reservation')->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); //select from shared database if (count($check_exist) == 1) { $query = DB::update('reservation')->set(array('student_id' => $this->user->id, 'status' => 1, 'freetime_at' => $reserve->freetime_at))->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); } else { $query = DB::insert('reservation')->columns(array('student_id', 'student_email', 'edoo_tutor', 'freetime_at', 'status')); $query->values(array($this->user->id, $this->user->email, $reserve->teacher->email, $reserve->freetime_at, 1))->execute('shared'); } } } } } elseif ($this->user->charge_html == 11 or Input::get("course", 0) == 0) { if (Model_Lessontime::courseNumber_2(Input::get("course", 0)) > count($pasts)) { $reserve = Model_Lessontime::find($id); if ($reserve != null) { if ($reserve->status == 0 and $reserve->student_id == 0) { $reserve->student_id = $this->user->id; $reserve->language = Input::get("course", 0); $reserve->status = 1; $reserve->number = count($pasts) + 1; $reserve->history = $this->user->place; $reserve->save(); Model_Lessontime::sendReservedEMail($reserve->id); $reserved = $reserve; //send data to shared db $check_exist = DB::select()->from('reservation')->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); //select from shared database if (count($check_exist) == 1) { $query = DB::update('reservation')->set(array('student_id' => $this->user->id, 'status' => 1, 'freetime_at' => $reserve->freetime_at))->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); } else { $query = DB::insert('reservation')->columns(array('student_id', 'student_email', 'edoo_tutor', 'freetime_at', 'status')); $query->values(array($this->user->id, $this->user->email, $reserve->teacher->email, $reserve->freetime_at, 1))->execute('shared'); } } } } } elseif ($this->user->charge_html == 111 or Input::get("course", 0) == 0) { if (Model_Lessontime::courseNumber_3(Input::get("course", 0)) > count($pasts)) { $reserve = Model_Lessontime::find($id); if ($reserve != null) { if ($reserve->status == 0 and $reserve->student_id == 0) { $reserve->student_id = $this->user->id; $reserve->language = Input::get("course", 0); $reserve->status = 1; $reserve->number = count($pasts) + 1; $reserve->history = $this->user->place; $reserve->save(); Model_Lessontime::sendReservedEMail($reserve->id); $reserved = $reserve; //send data to shared db $check_exist = DB::select()->from('reservation')->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); //select from shared database if (count($check_exist) == 1) { $query = DB::update('reservation')->set(array('student_id' => $this->user->id, 'status' => 1, 'freetime_at' => $reserve->freetime_at))->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); } else { $query = DB::insert('reservation')->columns(array('student_id', 'student_email', 'edoo_tutor', 'freetime_at', 'status')); $query->values(array($this->user->id, $this->user->email, $reserve->teacher->email, $reserve->freetime_at, 1))->execute('shared'); } } } } } elseif ($this->user->charge_html == 1111 or Input::get("course", 0) == 1) { if (Model_Lessontime::courseNumber_4(Input::get("course", 0)) > count($pasts)) { $reserve = Model_Lessontime::find($id); if ($reserve != null) { if ($reserve->status == 0 and $reserve->student_id == 0) { $reserve->student_id = $this->user->id; $reserve->language = Input::get("course", 0); $reserve->status = 1; $reserve->number = count($pasts) + 1; $reserve->history = $this->user->place; $reserve->save(); Model_Lessontime::sendReservedEMail($reserve->id); $reserved = $reserve; //send data to shared db $check_exist = DB::select()->from('reservation')->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); //select from shared database if (count($check_exist) == 1) { $query = DB::update('reservation')->set(array('student_id' => $this->user->id, 'status' => 1, 'freetime_at' => $reserve->freetime_at))->where('student_email', $this->user->email)->where('edoo_tutor', $reserve->teacher->email)->execute('shared'); } else { $query = DB::insert('reservation')->columns(array('student_id', 'student_email', 'edoo_tutor', 'freetime_at', 'status')); $query->values(array($this->user->id, $this->user->email, $reserve->teacher->email, $reserve->freetime_at, 1))->execute('shared'); } } } } } $course_where = null; switch (Input::get("course", 0)) { case -1: $course_where = ["trial", 1]; break; default: $course_where = ["enchantJS", 1]; } $data["lessons"] = Model_Lessontime::find("all", ["where" => [["deleted_at", 0], ["student_id", 0], ["status", 0], ["freetime_at", ">=", time()], ["freetime_at", "<", time() + 864000]], 'related' => ['teacher' => ['where' => [['deleted_at', 0], $course_where]]], "order_by" => [["freetime_at", "asc"]]]); $data['status'] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["deleted_at", 0], ["status", 1]]]); $data["donetrial"] = Model_Lessontime::find("all", ["where" => [["student_id", $this->user->id], ["status", 2], ["language", Input::get("course", -1)], ["deleted_at", 0]]]); $eventdetails = Model_Events::find("all", ["where" => [["deleted_at", 0]]]); if (Input::post("place", null) !== null and Security::check_token()) { $this->user->place = Input::post("place", 1); $this->user->save(); } $data['eventdetails'] = $eventdetails; $data["pasts"] = $pasts; $data["lastClass"] = $lastClass; $data["reserved"] = $reserved; $data["user"] = $this->user; $data["course"] = Input::get("course", 0); $view = View::forge("students/lesson/add", $data); $this->template->content = $view; }
public static function delete($event_id) { $db = JO_Db::getDefaultAdapter(); $event_info = self::getEvent($event_id); if (!$event_info) { return false; } if ($event_info['store'] == 's3') { self::deleteImagesAmazon($event_info['image']); } else { $model_image = new Helper_Images(); $model_image->deleteImages($event_info['image']); } $comments = Model_Events::getComments(array('filter_event_id' => $event_id)); if ($comments) { foreach ($comments as $comment) { $db->delete('events_comments', array('comment_id = ?' => $comment['comment_id'])); $db->delete('events_reports_comments', array('comment_id = ?' => $comment['comment_id'])); } } $del = $db->delete('events', array('event_id = ?' => $event_id)); if (!$del) { return false; } else { $db->delete('events_likes', array('event_id = ?' => $event_id)); $db->delete('events_reports', array('event_id = ?' => $event_id)); $db->delete('events_following', array('event_id = ?' => $event_id)); $db->delete('users_history', array('pin_id = ?' => $event_id)); self::deleteCache($event_info); return true; } }
public function pinsAction() { $request = $this->getRequest(); $user_data = $this->profileHelp(); $this->setViewChange('profile'); $this->view->active = 'pins'; $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $this->view->boards = ''; $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_marker' => $request->getRequest('marker'), 'filter_user_id' => $user_data['user_id']); if ($request->getQuery('filter') == 'likes') { unset($data['filter_user_id']); $data['filter_likes'] = $user_data['user_id']; $this->view->active = 'likes'; } $pins = Model_Pins::getPins($data); if ($pins) { foreach ($pins as $pin) { $this->view->boards .= Helper_Pin::returnHtml($pin); } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } if ($request->getQuery('filter') == 'likes') { $events = Model_Events::getEvents($data); if ($events) { $i = 0; foreach ($events as $key => $event) { $this->view->all = false; $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['original'] = $avatar['original']; $event['width'] = $avatar['width']; $event['height'] = $avatar['height']; $event["sport_category"] = Model_Boards::getCategoryTitle($event["sport_category"]); $event['href'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']); $href = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']); $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['hrefuser'] = 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->from_url = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=fromurl'); $this->view->successfu_edite = false; $view->event = $event; $this->view->boards .= $view->render('boxEventPin', 'events'); $events[$i]["href"] = $href; $eventsTot[] = $events[$i]; $i++; } // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } } $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'); } }