/** * Get additional content data selected * * @param $result = Query result */ public static function post_find($result) { if ($result !== null) { if (is_array($result)) { foreach ($result as $item) { // It will first check if we already have result in temporary result, // and only execute query if we dont. That way we dont have duplicate queries // Get products $item->get_products = static::lazy_load(function () use($item) { return Model_Products::find(array('where' => array('order_id' => $item->id))); }, $item->id, 'products'); // Get order payments $item->get_payments = static::lazy_load(function () use($item) { return \Payment\Model_Payment::find(array('where' => array('order_id' => $item->id), 'order_by' => array('id' => 'desc'))); }, $item->id, 'payments'); // Get last payment status $item->get_last_payment = static::lazy_load(function () use($item) { $payments = \Payment\Model_Payment::find(array('where' => array('order_id' => $item->id), 'order_by' => array('id' => 'desc'))); return isset($payments[0]) ? $payments[0] : array(); }, $item->id, 'last_payment', 'object'); // Get history $item->get_history = static::lazy_load(function () use($item) { return Model_History::find(array('where' => array('order_id' => $item->id), 'order_by' => array('created_at' => 'desc'))); }, $item->id, 'history'); // Get artworks $item->get_artwork = static::lazy_load(function () use($item) { return Model_Artwork::find(array('where' => array('order_id' => $item->id))); }, $item->id, 'artwork'); // Get artworks status $item->get_artwork_status = static::lazy_load(function () use($item) { $out = array(0, 0); $products = Model_Products::find(array('where' => array('order_id' => $item->id, 'artwork_required' => 1))); if (!$products) { return $out; } $out[0] = count($products); foreach ($products as $product) { if ($product->artwork) { $out[1]++; } } return $out; }, $item->id, 'artwork_status', 'array'); // Get order user object $item->get_user = static::lazy_load(function () use($item) { return \Sentry::user((int) $item->user_id); }, $item->id, 'user', 'object'); } } } // return the result return $result; }
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 indexAction() { $request = $this->getRequest(); if (!JO_Session::get('user[user_id]')) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&popup=true&next=' . urlencode($request->getFullUrl()))); } $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create'); $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'order' => 'boards.sort_order', 'sort' => 'ASC', 'friendly' => JO_Session::get('user[user_id]'))); $this->view->boards = array(); if ($boards) { foreach ($boards as $board) { $this->view->boards[] = array('board_id' => $board['board_id'], 'title' => $board['title']); } } //////////// Categories //////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_status' => 1)); foreach ($categories as $category) { $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']); $this->view->categories[] = $category; } $this->view->title = JO_Utf8::convertToUtf8($request->getQuery('title')); $this->view->url = JO_Utf8::convertToUtf8(urldecode($request->getQuery('url'))); $this->view->media = JO_Utf8::convertToUtf8($request->getQuery('media')); $this->view->is_video = JO_Utf8::convertToUtf8($request->getQuery('is_video')); $this->view->description = JO_Utf8::convertToUtf8($request->getQuery('description')); $this->view->charset = JO_Utf8::convertToUtf8($request->getQuery('charset')); if (!trim($this->view->description)) { $this->view->description = $this->view->title; } if (JO_Session::get('success_added')) { $this->view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . JO_Session::get('success_added')); $this->setViewChange('success'); JO_Session::clear('success_added'); } else { if ($request->isPost()) { $result = Model_Pins::create(array('title' => $this->view->title, 'from' => $this->view->url, 'image' => $this->view->media, 'is_video' => $this->view->is_video, 'description' => $request->getPost('message'), 'price' => $request->getPost('price'), 'board_id' => $request->getPost('board_id'), 'pinmarklet' => 1)); if ($result) { Model_History::addHistory(0, Model_History::ADDPIN, $result); $session_user = JO_Session::get('user[user_id]'); $group = Model_Boards::isGroupBoard($request->getPost('board_id')); if ($group) { $users = explode(',', $group); foreach ($users as $user_id) { if ($user_id != $session_user) { $user_data = Model_Users::getUser($user_id); if ($user_data && $user_data['email_interval'] == 1 && $user_data['groups_pin_email']) { $this->view->user_info = $user_data; $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->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result); $board_info = Model_Boards::getBoard($request->getPost('board_id')); if ($board_info) { $this->view->board_title = $board_info['title']; $this->view->board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']); } Model_Email::send($user_data['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('added new pin to a group board'), $this->view->render('group_board', 'mail')); } } } } JO_Session::set('success_added', $result); $this->redirect($request->getBaseUrl() . '?controller=bookmarklet'); } } } }
public function fromfileAction() { $request = $this->getRequest(); $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=upload_images'); $this->view->upload_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=upload_imagesView'); $this->view->popup_main_box = $this->view->render('fromfile', 'addpin'); if ($request->isPost()) { $result = Model_Pins::create(array('title' => $request->getPost('title'), 'from' => '', 'image' => BASE_PATH . JO_Session::get('upload_from_file'), 'is_video' => $request->getPost('is_video'), 'is_article' => $request->getPost('is_article'), 'description' => $request->getPost('message'), 'price' => $request->getPost('price'), 'board_id' => $request->getPost('board_id'))); if ($result) { Model_History::addHistory(0, Model_History::ADDPIN, $result); if (JO_Registry::get('isMobile')) { $this->redirect('/'); } $session_user = JO_Session::get('user[user_id]'); $group = Model_Boards::isGroupBoard($request->getPost('board_id')); if ($group) { $users = explode(',', $group); foreach ($users as $user_id) { if ($user_id != $session_user) { $user_data = Model_Users::getUser($user_id); if ($user_data && $user_data['email_interval'] == 1 && $user_data['groups_pin_email']) { $this->view->user_info = $user_data; $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->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result); $board_info = Model_Boards::getBoard($request->getPost('board_id')); if ($board_info) { $this->view->board_title = $board_info['title']; $this->view->board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']); } Model_Email::send($user_data['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('added new pin to a group board'), $this->view->render('group_board', 'mail')); } } } } $this->view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result); $this->view->popup_main_box = $this->view->render('success', 'addpin'); if (JO_Session::get('upload_from_file')) { @unlink(BASE_PATH . JO_Session::get('upload_from_file')); JO_Session::clear('upload_from_file'); JO_Session::clear('upload_from_file_name'); } } } $this->setViewChange('index'); if ($request->isXmlHttpRequest()) { $this->view->popup = true; echo $this->view->popup_main_box; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'layout/left_part'); } }
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 function indexAction() { $request = $this->getRequest(); //JO_Session::clear('categoria_id'); //para las APP's if (isset($_POST['token']) && $_POST['token'] == md5($_POST['userid'])) { $_SESSION['token'] = $_POST['token']; JO_Session::set('token', $_POST['token']); $result = Model_Users::checkLoginAPP($_POST['userid']); if ($result) { if ($result['status']) { @setcookie('csrftoken_', md5($result['user_id'] . $request->getDomain() . $result['date_added']), time() + 86400 * 366 * 5, '/', '.' . $request->getDomain()); JO_Session::set(array('user' => $result)); } } } if ($request->getParam('direct_path') == 'true') { if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) { Model_Users::edit(JO_Session::get('user[user_id]'), array('first_login' => '0')); JO_Session::clear('category_id'); $this->view->user_info = JO_Session::get('user'); Model_Email::send(JO_Session::get('user[email]'), JO_Registry::get('noreply_mail'), sprintf($this->translate('Welcome to %s!'), JO_Registry::get('site_name')), $this->view->render('welcome', 'mail')); } $this->redirect($request->getBaseUrl()); } /*$img = JO_Phpthumb::getInstance(); var_dump($img->isValidImplementation('imagick')); exit; $img = JO_Phpthumb_Factory::create('http://www.desiredanimations.com/wp-content/uploads/2011/08/Cars-2.jpg'); $img->adaptiveResize(250, 250)->createReflection(40, 40, 80, true, '#a4a4a4'); $img->show(); exit;*/ $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit')); if (JO_Session::get('user[user_id]')) { $data['following_users_from_user_id'] = JO_Session::get('user[user_id]'); $data['filter_marker'] = $request->getRequest('marker'); } else { $data['filter_rand'] = true; } $this->view->pins = ''; //error_log("INICIO PINS: ".date("Y-m-d H:i:s")); $pins = Model_Pins::getPins($data); //error_log("EMPIEZAN PINES: ".self::udate("Y-m-d H:i:s:u")); if ($pins) { $banners = Model_Banners::getBanners(new JO_Db_Expr("`controller` = '" . $request->getController() . "' AND position BETWEEN '" . (int) $data['start'] . "' AND '" . (int) $data['limit'] . "'")); $pp = JO_Registry::get('config_front_limit'); $cuentaPins = 0; foreach ($pins as $row => $pin) { $cuentaPins = $cuentaPins + 1; ///banners $key = $row + ($pp * $page - $pp); if (isset($banners[$key])) { $this->view->pins .= Helper_Banners::returnHtml($banners[$key]); } //pins //error_log("EMPIEZA PIN(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u")); $this->view->pins .= Helper_Pin::returnHtml($pin); //error_log("FIN PIN(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u")); } //error_log("FIN BUCLE (".$cuentaPins." PINS): ".date("Y-m-d H:i:s")); if (JO_Session::get('user[user_id]')) { // JO_Registry::set('marker', Model_Pins::getMaxPin($data)); } } //error_log("FIN PINES(".$cuentaPins."): ".self::udate("Y-m-d H:i:s:u")); if (!$request->isXmlHttpRequest() && JO_Session::get('user[user_id]')) { $history = Model_History::getHistory(array('start' => 0, 'limit' => 10, 'sort' => 'DESC', 'order' => 'history_id')); $model_images = new Helper_Images(); foreach ($history as $key => $data) { if (!isset($data['user']['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($data['user'], '_A'); $history[$key]['user']['avatar'] = $avatar['image']; if ($data['history_action'] == Model_History::REPIN) { $history[$key]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $data['pin_id']); } else { $history[$key]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $data['from_user_id']); } } $this->view->history = $history; } if ($request->isXmlHttpRequest()) { echo $this->view->pins; // echo $this->renderScript('json'); $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } // if((int)JO_Registry::get('config_cache_live')) { // $http = new JO_Http(); // $http->setTimeout(1); // $http->execute($request->getBaseUrl() . '?action=generateCache'); // } }
public function historyAction() { if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to view your history')); $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=login')); } $this->getLayout()->meta_title = $this->translate('History'); $this->getLayout()->meta_description = $this->translate('History'); $this->view->history = array(); $history = Model_History::getAll(0, 0, " `user_id` = '" . JO_Session::get('user_id') . "'"); if ($history) { foreach ($history as $his) { $his['datetime'] = JO_Date::getInstance($his['datetime'], 'dd MM yy H:i:s')->toString(); $this->view->history[] = $his; } } $this->view->usertotal = WM_Currency::format(JO_Session::get('total')); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; $this->view->children['users_toolbar'] = 'layout/users_toolbar'; }
public function depositIsPay($id) { $row = self::getDeposit($id); if ($row) { if ($row['added'] == 'true') { return; } $db = JO_Db::getDefaultAdapter(); if (JO_Session::get('user_id')) { $user_data = Model_Users::getUser($row['user_id']); /* razkomentirame, ako iskame da nachislqva pari na referral_id i pri deposit if($user_data['referal_id'] > 0) { $referal = Model_Users::getUser($user_data['referal_id']); $referal_cnt = JO_Registry::forceGet('referal_sum'); $percent = str_replace('%', '', JO_Registry::forceGet('referal_percent')); $sum = $row['deposit'] * ((int) $percent / 100); if($referal_cnt > 0) { $cnt = Model_Users::getTotalReferals($user_data['user_id'], $user_data['referal_id']); if(($cnt + 1) >= $referal_cnt) $user_data['referal_id'] = 0; } $db->update(Model_Users::getPrefixDB().'users', array( 'earning' => new JO_Db_Expr('earning + ' . $sum), 'total' => new JO_Db_Expr('total + ' . $sum) ), array('user_id = ?' => (int)$referal['user_id'])); $db->insert(Model_Users::getPrefixDB().'users_referals_count', array( 'user_id' => (int)$row['user_id'], 'referal_id' => (int)$referal['user_id'], 'datetime' => new JO_Db_Expr('NOW()'), 'order_type' => 'deposit', 'referal_sum' => (float) $sum )); } */ $db->update(Model_Users::getPrefixDB() . 'users', array('deposit' => new JO_Db_Expr('deposit + ' . $row['deposit']), 'total' => new JO_Db_Expr('total + ' . $row['deposit'])), array('user_id = ?' => (int) $row['user_id'])); $db->update(Model_Users::getPrefixDB() . 'deposit', array('added' => 'true'), array('id = ?' => (int) $id)); if ($user_data) { $groups = unserialize($user_data['groups']); if (is_array($groups) && count($groups) > 0) { $query_group = $db->select()->from(Model_Users::getPrefixDB() . 'user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups)))); $fetch_all = $db->fetchAll($query_group); $user_data['access'] = array(); if ($fetch_all) { foreach ($fetch_all as $row) { $modules = unserialize($row['rights']); if (is_array($modules)) { foreach ($modules as $module => $ison) { $user_data['access'][$module] = $module; } } } } } } if ($user_data) { if (isset($user_data['access']) && count($user_data['access'])) { $user_data['is_admin'] = true; } JO_Session::set($user_data); } } $translate = JO_Translate::getInstance(); Model_History::add($translate->translate('Deposit from') . ' ' . WM_Currency::format($row['deposit']), $id, $row['user_id']); } }
public function action_index() { if ($this->type >= 0) { switch ($this->type) { default: echo json_encode(array('nop' => 'ok')); break; break; case 0: //get all $this->get_ip_history('all'); break; case 1: case 2: //get subnodes $this->get_ip_history($this->id); break; //subnets //subnets case 3: $sub = Model_Subnet::find($this->id); $this->subArray = array(); if ($sub) { $from_pos = $sub['range_from']; $to_pos = $sub['range_to']; $ips = Model_History::find()->where('ip_int', '>=', $from_pos)->where('ip_int', '<=', $to_pos)->get(); foreach ($ips as $ip) { $device = $ip->dev; // print_r($device); array_push($this->subArray, array('id' => $ip->id, 'ip' => $ip->ip_dotted, 'date' => date('d/m/Y H:i:s', $ip->time), 'device' => array('id' => $ip->device, 'name' => $ip->devname, 'erased' => 0))); } } $out = array('history' => $this->subArray); echo json_encode($out); break; //reserved ip-s } } }
public function repinAction() { $request = $this->getRequest(); $pin_id = $request->getRequest('pin_id'); $pin_info = Model_Pins::getPin($pin_id); if (!$pin_info) { $this->forward('error', 'error404'); } $model_images = new Helper_Images(); $this->view->title = $pin_info['title']; $this->view->price = $pin_info['price']; $image = Helper_Uploadimages::pin($pin_info, '_B'); if ($image) { $this->view->media = $image['original']; } else { $this->view->media = false; } $this->view->is_video = $pin_info['is_video'] ? 'true' : 'false'; $this->view->is_article = $pin_info['is_article'] ? 'true' : 'false'; $this->view->from = $pin_info['from']; $this->view->description = $pin_info['description']; $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=repin&pin_id=' . $pin_id); $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create'); $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'order' => 'boards.sort_order', 'sort' => 'ASC', 'friendly' => JO_Session::get('user[user_id]'))); $this->view->boards = array(); if ($boards) { foreach ($boards as $board) { $this->view->boards[] = array('board_id' => $board['board_id'], 'title' => $board['title']); } } //////////// Categories //////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_status' => 1)); foreach ($categories as $category) { $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']); $this->view->categories[] = $category; } $this->view->popup_main_box = $this->view->render('repin', 'pin'); $this->view->is_article = $pin_info['is_article'] ? 'true' : 'false'; if ($request->isPost()) { $result = Model_Pins::create(array('title' => $pin_info['title'], 'from' => $pin_info['from'], 'image' => $this->view->media, 'is_video' => $pin_info['is_video'] ? 'true' : 'false', 'is_article' => $pin_info['is_article'] ? 'true' : 'false', 'description' => $request->getPost('message'), 'price' => $request->getPost('price'), 'board_id' => $request->getPost('board_id'), 'via' => $pin_info['user_id'], 'repin_from' => $pin_info['pin_id'], 'from_repin' => $pin_info['from'])); if ($result) { $this->view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result); $this->view->popup_main_box = $this->view->render('success', 'addpin'); //add history Model_History::addHistory($pin_info['user_id'], Model_History::REPIN, $result); if ($pin_info['user']['email_interval'] == 1 && $pin_info['user']['repins_email']) { $this->view->user_info = $pin_info['user']; $this->view->profile_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')); $this->view->full_name = JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]'); $this->view->text_email = $this->translate('repin your'); $this->view->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin_id); Model_Email::send($pin_info['user']['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('repin your pin'), $this->view->render('repin_pin', 'mail')); } } } $this->setViewChange('index'); if ($request->isXmlHttpRequest()) { $this->noViewRenderer(true); echo $this->view->popup_main_box; $this->view->is_popup = true; } else { $this->view->pins_details = $this->view->popup_main_box; $this->view->is_popup = false; $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'pin/left_part'); } }
public function action_delete_history($id = false) { if ($order_history = Model_History::find_one_by_id($id)) { try { if ($order_history->delete()) { \Messages::success('Order history event successfully deleted.'); } else { \Messages::error('<strong>' . 'There was an error while trying to delete order history event.' . '</strong>'); } } catch (\Database_Exception $e) { \Messages::error('<strong>' . 'There was an error while trying to delete order history event.' . '</strong>'); } } else { \Messages::error('<strong>' . 'There is no order history event with this ID.' . '</strong>'); } \Response::redirect(\Input::referrer(\Uri::admin('current'))); }
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 pinMediaCallbackAction() { $request = $this->getRequest(); if (JO_Session::get('user[user_id]')) { $media = Model_Instagram::getMedia($request->getPost('media_id')); if ($media) { if ($media['user_id'] == JO_Session::get('user[user_id]')) { $result = Model_Pins::create(array('title' => $media['title'], 'from' => $media['from'], 'image' => $media['media'], 'description' => $media['title'], 'board_id' => JO_Session::get('instagram_media[board_id]'))); if ($result) { Model_Instagram::setPinMedia($media['media_id'], $result); Model_History::addHistory(JO_Session::get('user[user_id]'), Model_History::ADDPIN, $result); $session_user = JO_Session::get('user[user_id]'); $group = Model_Boards::isGroupBoard($request->getPost('board_id')); if ($group) { $users = explode(',', $group); foreach ($users as $user_id) { if ($user_id != $session_user) { $user_data = Model_Users::getUser($user_id); if ($user_data && $user_data['email_interval'] == 1 && $user_data['groups_pin_email']) { $this->view->user_info = $user_data; $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->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result); $board_info = Model_Boards::getBoard($request->getPost('board_id')); if ($board_info) { $this->view->board_title = $board_info['title']; $this->view->board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']); } Model_Email::send($user_data['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('added new pin to a group board'), $this->view->render('group_board', 'mail')); } } } } $this->view->ok = true; } else { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } else { $this->view->error = $this->translate('Private media!'); } } else { $this->view->error = $this->translate('Media not found!'); } } else { $this->view->location = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); } echo $this->renderScript('json'); }
public function agendaAction() { $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; } if (isset($_POST['token']) && $_POST['token'] == md5($_POST['userId'])) { $_SESSION['token'] = $_POST['token']; JO_Session::set('token', $_POST['token']); Model_Users::editAgenda($request->getPost('agenda')); $data = Model_Users::followersUsers($_POST['userId']); if ($data) { foreach ($data as $key => $user) { //add history Model_History::addHistory($user["user_id"], Model_History::COMMENTUSER, $request->getPost('agenda')); } } $return = array('agenda' => $request->getPost('agenda')); } else { //no existe la sesión / no existe el dato recibido por post / el token no es igual. $return = array('error' => 401, 'description' => $this->translate('wrong token')); } 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); }
public static function deleteBalance($balance_id) { $db = JO_Db::getDefaultAdapter(); $row = self::getBalance($balance_id); if (!$row) { return; } $aff = $db->delete('deposit', array('id = ?' => (int) $balance_id)); if ($aff) { $db->update(Model_Users::getPrefixDB() . 'users', array('deposit' => new JO_Db_Expr('deposit - ' . (int) $row['deposit']), 'total' => new JO_Db_Expr('total - ' . (int) $row['deposit'])), array('user_id = ?' => (int) $row['user_id'])); $translate = JO_Translate::getInstance(); Model_History::add($translate->translate('[Delete from admin ' . ($row['paid'] == 'true' ? '"paid"' : '"not paid"') . '] Deposit from') . ' ' . WM_Currency::format($row['deposit']), $balance_id, $row['user_id']); } return $balance_id; }
public function createAction() { $request = $this->getRequest(); // if(!$request->isXmlHttpRequest()) { // $this->forward('error', 'error404'); // } if ($request->isPost()) { if (JO_Session::get('user[user_id]')) { if (trim($request->getPost('newboard'))) { if (trim($request->getPost('newboard')) != $this->translate('Nombre de la carpeta') && trim($request->getPost('newboard')) != $this->translate('Create New Board')) { if (trim($request->getPost('category_id'))) { $data = Model_Boards::createBoard(array('title' => trim($request->getPost('newboard')), 'category_id' => $request->getPost('category_id'), 'friends' => $request->getPost('friends'))); if ($data) { if (is_array($request->getPost('friends'))) { foreach ($request->getPost('friends') as $fr) { $this->view->uinfo = Model_Users::getUser($fr); $this->view->board_href = $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $data['board_id']); $this->view->board_name = trim($request->getPost('newboard')); $this->view->author_href = $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')); $this->view->author_name = JO_Session::get('firstname') . ' ' . JO_Session::get('lastname'); // print_R(JO_Session::getAll()); $result = Model_Email::send($this->view->uinfo['email'], JO_Registry::get('noreply_mail'), $this->translate('You have been invited to pin on ' . trim($request->getPost('newboard'))), $this->view->render('board_invite', 'mail')); } } Model_History::addHistory(0, Model_History::ADDBOARD, 0, $data['board_id']); $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $data['board_id']); $this->view->data = $data; } else { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } else { $this->view->error = $this->translate('Debe seleccionar una categoría para la carpeta'); } } else { $this->view->error = $this->translate('Board name must not be empty!'); } } else { $this->view->error = $this->translate('Board name must not be empty!'); } } else { $this->view->error = 'error login'; } echo $this->renderScript('json'); } else { $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A'); $this->view->avatar = $avatar['image']; $this->view->fullname = JO_Session::get('user[fullname]'); $this->view->userhref = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')); $this->view->friends_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends'); $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create'); //////////// Categories //////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_status' => 1)); foreach ($categories as $category) { $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']); $this->view->categories[] = $category; } $this->view->popup_main_box = $this->view->render('popup_form', 'boards'); $this->setViewChange('form'); if ($request->isXmlHttpRequest()) { $this->view->popup = true; echo $this->view->popup_main_box; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'layout/left_part'); } } }