示例#1
0
 public function indexAction()
 {
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $percents = Model_Percents::getAll();
     $this->view->percents = array();
     if ($percents) {
         foreach ($percents as $percent) {
             $this->view->percents[] = array('id' => $percent['id'], 'percent' => $percent['percent'], 'from' => WM_Currency::format($percent['from']), 'to' => WM_Currency::format($percent['to']));
         }
     }
 }
示例#2
0
 public function indexAction()
 {
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $payments = Model_Membership::getAll();
     $this->view->payments = array();
     if ($payments) {
         foreach ($payments as $payment) {
             $payment['price'] = WM_Currency::format($payment['price']);
             $this->view->payments[] = $payment;
         }
     }
 }
 public function indexAction()
 {
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     if ($this->session->get('error_permision')) {
         $this->view->error_permision = $this->session->get('error_permision');
         $this->session->clear('error_permision');
     }
     $default_currency = WM_Currency::getCurrencyCode();
     $this->view->currency = array();
     $currencies = Model_Currency::getCurrencies();
     if ($currencies) {
         foreach ($currencies as $currency) {
             $currency['is_set'] = $default_currency == $currency['code'];
             $currency['format'] = WM_Currency::format(1, $currency['code'], 1);
             $this->view->currency[] = $currency;
         }
     }
     $this->view->default_currency = WM_Currency::getCurrencyCode();
 }
示例#4
0
文件: Items.php 项目: noikiy/PD
 public static function returnViewIndex($item, $view_name = 'index')
 {
     if (!isset($item['module']) || !$item['module']) {
         return;
     }
     $view = JO_View::getInstance();
     if (!isset($item['no_items'])) {
         static $results = array();
         $model_images = new Helper_Images();
         $request = JO_Request::getInstance();
         if (mb_strlen($item['name'], 'UTF-8') > 35) {
             $item['name'] = JO_Utf8::mb_cut_text($item['name'], 0, 35, ' ');
         }
         $item['price'] = WM_Currency::format($item['price']);
         switch ($view_name) {
             case 'category':
                 $height = JO_Registry::forceGet($item['module'] . '_items_preview_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
                 /* CATEGORIES */
                 $cats = array();
                 $categories = Model_Categories::getCategoriesByIds($item['categories']);
                 foreach ($categories as $v) {
                     $cats[] = array('name' => $v['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=categories&category_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name'])));
                 }
                 $item['categories'] = $cats;
                 break;
             case 'downloads':
                 $height = JO_Registry::forceGet($item['module'] . '_items_preview_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
                 $item['rate'] = Model_Items::isRate($item['id']);
                 break;
             default:
                 $height = JO_Registry::forceGet($item['module'] . '_items_thumb_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_thumb_width'), $height);
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
         }
         $item['href'] = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
         $item['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']));
     }
     $view->item = $item;
     return $view->renderByModule('single_items/' . $view_name, 'items', $item['module']);
 }
示例#5
0
 public function editAction()
 {
     //		var_dump( htmlspecialchars('⚐') );exit;
     $request = $this->getRequest();
     $pin_id = $request->getRequest('pin_id');
     // 		$pin_info = Model_Pins::getPin($pin_id);
     $pin_info = new Model_Pins_Pin($pin_id);
     if (!$pin_info->count() || $pin_info->data['pin_user_id'] != JO_Session::get('user[user_id]')) {
         $this->forward('error', 'error404');
     }
     $pin_info = $pin_info->data;
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         if ($pin_info['pin_from']) {
             $validate->_set_rules($request->getPost('from'), $this->translate('Link'), 'not_empty;min_length[3];domain');
         } else {
             if (trim($request->getPost('from'))) {
                 $validate->_set_rules($request->getPost('from'), $this->translate('Link'), 'not_empty;min_length[3];domain');
             }
         }
         $data = $request->getPost();
         if ($validate->_valid_form()) {
             $edit = new Model_Pins_Edit($pin_id, $request->getPost());
             $this->redirect(WM_Router::pinAction($pin_info['pin_pin_id']));
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
         foreach ($data as $k => $v) {
             if (isset($pin_info['pin_' . $k])) {
                 $pin_info['pin_' . $k] = $v;
             }
         }
     }
     $pin_info['images'] = Helper_Uploadimages::pinThumbs($pin_info);
     if ($pin_info['pin_gift']) {
         $pin_info['price_formated'] = WM_Currency::format($pin_info['pin_price']);
     } else {
         $pin_info['price_formated'] = '';
         $pin_info['pin_price'] = 0;
     }
     $pin_info['href'] = WM_Router::pinAction($pin_info['pin_pin_id']);
     $this->view->pin_info = $pin_info;
     $view->get_user_friends = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
     $boards = new Model_Boards_BoardsWithShared(array('filter_user_id' => JO_Session::get('user[user_id]')));
     $this->view->boards = array();
     if ($boards->count()) {
         foreach ($boards as $board) {
             $this->view->boards[] = array('board_id' => $board['board_board_id'], 'title' => $board['board_title']);
         }
     }
     ///////////////// Extension on edit //////////////////
     $this->view->form_extensions = array();
     $extensions = Model_Extensions::getByMethod('pin_oneditform');
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $this->view->form_extensions[] = array('html' => $this->view->callChildren('modules_' . $ext . '_oneditform'), 'view' => $this->view->callChildrenView('modules_' . $ext . '_oneditform'), 'key' => $ext);
         }
     }
     $this->view->pin_delete = WM_Router::pinAction($pin_id, 'delete');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#6
0
文件: Users.php 项目: noikiy/PD
 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;
 }
示例#7
0
 private function getForm()
 {
     $request = $this->getRequest();
     $url = '';
     if ($request->getQuery('filter_id')) {
         $url .= '&filter_id=' . $request->getQuery('filter_id');
     }
     if ($request->getQuery('filter_name')) {
         $url .= '&filter_name=' . $request->getQuery('filter_name');
     }
     if ($request->getQuery('filter_username')) {
         $url .= '&filter_username='******'filter_username');
     }
     if ($request->getQuery('filter_price')) {
         $url .= '&filter_price=' . $request->getQuery('filter_price');
     }
     if ($request->getQuery('filter_sales')) {
         $url .= '&filter_sales=' . $request->getQuery('filter_sales');
     }
     if ($request->getQuery('filter_profit')) {
         $url .= '&filter_profit=' . $request->getQuery('filter_profit');
     }
     if ($request->getQuery('filter_free_request')) {
         $url .= '&filter_free_request=' . $request->getQuery('filter_free_request');
     }
     if ($request->getQuery('filter_free_file')) {
         $url .= '&filter_free_file=' . $request->getQuery('filter_free_file');
     }
     if ($request->getQuery('filter_weekly')) {
         $url .= '&filter_weekly=' . $request->getQuery('filter_weekly');
     }
     if ($request->getQuery('sort')) {
         $url .= '&sort=' . $request->getQuery('sort');
     }
     if ($request->getQuery('order')) {
         $url .= '&order=' . $request->getQuery('order');
     }
     if ($request->getQuery('page')) {
         $url .= '&page=' . $request->getQuery('page');
     }
     $id = $request->getQuery('id');
     $info = Model_Items::getItem($id);
     if (!$info) {
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/queueitems/?' . $url);
     }
     $this->view->cancel = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/queueitems/?' . $url;
     $model_images = new Model_Images();
     $this->view->info = $info;
     $this->view->price_f = WM_Currency::format($info['suggested_price']);
     $this->view->categories = Model_Categories::getCategoriesFromParentByModule(0, $info['module']);
     $cats_module = Model_Categories::getCategories(array('filter_sub_of' => 0, 'filter_module' => $info['module'], 'filter_concat' => true));
     $where_attr = '';
     if ($cats_module) {
         $tmp = array();
         foreach ($cats_module as $c) {
             $tmp[] = "categories LIKE '%," . $c . ",%'";
         }
         if ($tmp) {
             $where_attr = implode(' OR ', $tmp);
         }
     }
     $this->view->attributes_list = array();
     $attr_cat = Model_Attributes::getAttributes(array(), $where_attr);
     if ($attr_cat) {
         foreach ($attr_cat as $row => $attr) {
             $attr_list = Model_Attributes::getAttributes(array('filter_sub_of' => $attr['id']));
             if ($attr_list) {
                 $this->view->attributes_list[$row] = $attr;
                 $this->view->attributes_list[$row]['items'] = $attr_list;
             }
         }
     }
     if ($request->getPost('name')) {
         $this->view->name = $request->getPost('name');
     } else {
         $this->view->name = $info['name'];
     }
     if ($request->getPost('description')) {
         $this->view->description = $request->getPost('description');
     } else {
         $this->view->description = $info['description'];
     }
     if ($request->getPost('price')) {
         $this->view->price = $request->getPost('price');
     } else {
         $this->view->price = '';
     }
     if ($request->getPost('category_id')) {
         $this->view->category_id = $request->getPost('category_id');
     } else {
         $this->view->category_id = Model_Items::getItemCategory($id);
     }
     if ($request->getPost('attributes')) {
         $this->view->attributes = $request->getPost('attributes');
     } else {
         $this->view->attributes = Model_Items::getItemAttributes($id);
     }
     if ($request->getPost('tags')) {
         $this->view->tags = $request->getPost('tags');
     } else {
         $this->view->tags = Model_Items::getItemTags($id);
     }
     if ($request->getPost('free_file')) {
         $this->view->free_file = $request->getPost('free_file');
     } else {
         $this->view->free_file = $info['free_file'];
     }
     if ($request->getPost('demo_url')) {
         $this->view->demo_url = $request->getPost('demo_url');
     } else {
         $this->view->demo_url = $info['demo_url'];
     }
     if ($request->getPost('weekly_from')) {
         $this->view->weekly_from = $request->getPost('weekly_from');
     } else {
         $this->view->weekly_from = '';
     }
     if ($request->getPost('weekly_to')) {
         $this->view->weekly_to = $request->getPost('weekly_to');
     } else {
         $this->view->weekly_to = '';
     }
 }
示例#8
0
 private function getForm()
 {
     $request = $this->getRequest();
     $id = $request->getQuery('id');
     $info = Model_Users::getWithdraw($id);
     if (!$info) {
         $url = '';
         if ($this->getRequest()->getQuery('page')) {
             $url = '?page=' . $this->getRequest()->getQuery('page');
         }
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/gainpayingup/' . $url);
     }
     $this->view->page_num = $this->getRequest()->getRequest('page', 1);
     $info['earning_formated'] = WM_Currency::format($info['earning']);
     $info['earning'] = WM_Currency::format($info['earning'], false);
     $date = new JO_Date($info['datetime'], 'dd MM yy');
     $info['datetime'] = $date->toString();
     $this->view->info = $info;
 }
示例#9
0
文件: Pin.php 项目: noikiy/amatteur
 public static function returnHtmlDetail($pin, $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($pin['pin_id']);
     if ($next_pin) {
         $view->next_navigation_pin = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $next_pin['pin_id']);
     }
     $prev_pin = Model_Pins::getPrevPin($pin['pin_id']);
     if ($prev_pin) {
         $view->prev_navigation_pin = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $prev_pin['pin_id']);
     }
     $image = call_user_func(array(self::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B');
     if ($image) {
         $pin['thumb'] = $image['image'];
         $pin['thumb_width'] = $image['width'];
         $pin['thumb_height'] = $image['height'];
         $pin['original_image'] = $image['original'];
     } else {
         JO_Action::getInstance()->forward('error', 'error404');
     }
     $image = call_user_func(array(self::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_D');
     if ($image) {
         $pin['popup'] = $image['image'];
         $pin['popup_width'] = $image['width'];
         $pin['popup_height'] = $image['height'];
         $pin['original_image'] = $image['original'];
     } else {
         JO_Action::getInstance()->forward('error', 'error404');
     }
     $pin_description = self::descriptionFix($pin['description']);
     $pin['real_description'] = self::descriptionFix($pin['description']);
     $pin['description'] = self::descriptionFix($pin['description']);
     $pin['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
     $pin['pinmarklet_href'] = WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_pinmarklet'));
     $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']);
     $view->author = $pin['user'];
     $avatar = Helper_Uploadimages::avatar($pin['user'], '_A');
     $view->author['avatar'] = $avatar['image'];
     $view->author['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_id']);
     $view->comments = array();
     if ($pin['latest_comments']) {
         foreach ($pin['latest_comments'] as $key => $comment) {
             if (!isset($comment['user']['store'])) {
                 unset($pin['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_Pins::commentIsReported($comment['comment_id'])) {
                 $comment['report'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&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'] || JO_Session::get('user[user_id]') == $pin['board_data']['user_id']) {
                     $comment['delete'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $comment['comment_id']);
                 }
             }
             $view->comments[] = $comment;
         }
     }
     $view->via = array();
     $view->via_repin = array();
     if ($pin['via'] && $pin['user_via']) {
         $view->via = array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['via']), 'fullname' => $pin['user_via']['fullname']);
     }
     $view->replin_info = false;
     if ($request->isXmlHttpRequest()) {
         $view->target_repin = false;
         if ($pin['repin_from']) {
             $pin_repin = Model_Pins::getPin($pin['repin_from']);
             if ($pin_repin) {
                 $view->source = array();
                 $view->source['source'] = $pin_repin['board'];
                 $pin['from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_id'] . '&board_id=' . $pin_repin['board_id']);
                 $view->target_repin = true;
             } else {
                 $view->source = Model_Source::getSource($pin['source_id']);
             }
         } else {
             $view->source = Model_Source::getSource($pin['source_id']);
         }
     } else {
         $view->source = Model_Source::getSource($pin['source_id']);
         if ($pin['repin_from']) {
             $repina = Model_Pins::getPin($pin['repin_from']);
             if ($repina) {
                 $view->replin_info = array('pin_href' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['repin_from']), 'profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $repina['user_id']), 'fullname' => $repina['user']['fullname']);
             }
         }
     }
     if ($pin['from'] && !preg_match('/^https?:\\/\\//', $pin['from'])) {
         $pin['from'] = 'http://' . $pin['from'];
     }
     if ($pin['from_repin'] && !preg_match('/^https?:\\/\\//', $pin['from_repin'])) {
         $pin['from_repin'] = 'http://' . $pin['from_repin'];
     }
     $pin['onto_board'] = $pin['onto_board2'] = array();
     $pin['originally_pinned'] = $pin['originally_pinned2'] = array();
     if ($request->isXmlHttpRequest()) {
         $pin['onto_board'] = self::getBoardPins($pin['board_id']);
         $pin['originally_pinned'] = self::getOriginallyPinned($pin['via'] ? $pin['via'] : $pin['user_id']);
     } else {
         $pin['onto_board2'] = self::getBoardPins($pin['board_id']);
         $pin['originally_pinned2'] = self::getOriginallyPinned($pin['via'] ? $pin['via'] : $pin['user_id']);
     }
     if ($view->source && $request->isXmlHttpRequest()) {
         $pin['source_pins'] = self::getSourcePins($pin['source_id']);
     } else {
         $pin['source_pins'] = array();
     }
     $pin['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $pin['board_id']));
     $pin['userIsFollow'] = Model_Users::isFollowUser($pin['user_id']);
     if ($pin['via']) {
         $pin['userViaIsFollow'] = Model_Users::isFollowUser($pin['via']);
     } else {
         $pin['userViaIsFollow'] = Model_Users::isFollowUser($pin['user_id']);
     }
     $pin['userFollowIgnore'] = $pin['user_id'] == JO_Session::get('user[user_id]');
     $pin['userViaFollowIgnore'] = ($pin['via'] ? $pin['via'] : $pin['user_id']) == JO_Session::get('user[user_id]');
     $view->follow = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $pin['user_id'] . '&board_id=' . $pin['board_id']);
     $view->follow_user = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_id']);
     if ($pin['via']) {
         $view->follow_user_via = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['via']);
     } else {
         $view->follow_user_via = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['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 = $pin['user_id'] != JO_Session::get('user[user_id]');
     } else {
         $view->enable_follow = false;
     }
     if (JO_Session::get('user[user_id]')) {
         $pin['url_like'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=like&pin_id=' . $pin['pin_id']);
         $pin['url_repin'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=repin&pin_id=' . $pin['pin_id']);
         $pin['url_comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=comment&pin_id=' . $pin['pin_id']);
         $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=comment&pin_id=' . $pin['pin_id']);
         $pin['edit'] = JO_Session::get('user[user_id]') == $pin['user_id'] ? WM_Router::create($request->getBaseUrl() . '?controller=pin&action=edit&pin_id=' . $pin['pin_id']) : false;
     } else {
         $pin['url_like'] = $pin['url_repin'] = $pin['url_comment'] = $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=landing');
         $pin['edit'] = false;
     }
     $likes = self::getPinLikes($pin['pin_id']);
     $pin['likes'] = $likes['data'];
     $pin['likes_total'] = $likes['total'];
     $pin['repins'] = self::getRePins($pin['pin_id']);
     $pin['pinIsReported'] = Model_Pins::pinIsReported($pin['pin_id']);
     $date_dif = array_shift(WM_Date::dateDiff($pin['date_added'], time()));
     $pin['date_dif'] = $date_dif;
     $view->loged = JO_Session::get('user[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 ($pin['is_video']) {
         $auto = new Helper_AutoEmbed();
         if ($pin['repin_from'] && $auto->parseUrl($pin['from_repin'])) {
             $auto->setWidth('100%');
             $auto->setHeight('350');
             $pin['video_code'] = $auto->getEmbedCode();
             $attr = $auto->getObjectAttribs();
             $pin['thumb_width'] = $attr['width'];
             $pin['thumb_height'] = $attr['height'];
         } else {
             if ($auto->parseUrl($pin['from'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['video_code'] = $auto->getEmbedCode();
                 $attr = $auto->getObjectAttribs();
                 $pin['thumb_width'] = $attr['width'];
                 $pin['thumb_height'] = $attr['height'];
             } else {
                 $pin['is_video'] = false;
             }
         }
     } else {
         $auto = new Helper_AutoEmbed();
         if ($pin['repin_from'] && $auto->parseUrl($pin['from_repin'])) {
             $auto->setWidth('100%');
             $auto->setHeight('350');
             $pin['video_code'] = $auto->getEmbedCode();
             $attr = $auto->getObjectAttribs();
             $pin['thumb_width'] = $attr['width'];
             $pin['thumb_height'] = $attr['height'];
             $pin['is_video'] = true;
         } else {
             if ($auto->parseUrl($pin['from'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['video_code'] = $auto->getEmbedCode();
                 $attr = $auto->getObjectAttribs();
                 $pin['thumb_width'] = $attr['width'];
                 $pin['thumb_height'] = $attr['height'];
                 $pin['is_video'] = true;
             } else {
                 $pin['is_video'] = false;
             }
         }
     }
     $view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
     $view->login_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&next=' . urlencode($pin['href']));
     Model_Pins::updateViewed($pin['pin_id']);
     JO_Layout::getInstance()->meta_title = $pin['board'] . ' - ' . strip_tags(html_entity_decode($pin_description));
     JO_Layout::getInstance()->placeholder('pin_url', $view->replin_info ? $view->replin_info['pin_href'] : $view->pin_url);
     JO_Layout::getInstance()->placeholder('pin_description', $pin_description);
     $params = array();
     $params['content'] = html_entity_decode($pin['description'] . ' ' . $pin['board'], 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', $pin['thumb']);
     JO_Layout::getInstance()->placeholder('board_title', $pin['board']);
     $view->banners = array();
     if ($banners) {
         foreach ($banners as $banner1) {
             foreach ($banner1 as $e) {
                 $e['html'] = html_entity_decode($e['html']);
                 $view->banners[] = $e;
             }
         }
     }
     $view->pin = $pin;
     return $view->render('pinBoxDetail', 'pin');
 }
示例#10
0
 public static function formatPinData($pin, $detail = false)
 {
     static $model_images = null, $request = null;
     if ($model_images === null) {
         $model_images = new Helper_Images();
     }
     if ($request === null) {
         $request = JO_Request::getInstance();
     }
     ///////////////////////////////////// PIN INFO /////////////////////////////////////
     $pin['pin_id'] = $pin['pin_pin_id'];
     $pin['image'] = $pin['pin_image'];
     //url's
     $pin['pin_url_embed'] = WM_Router::pinAction($pin['pin_pin_id'], 'embed');
     if (!JO_Session::get('user[user_id]')) {
         $login_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         if (Helper_Config::get('enable_free_registration')) {
             //$login_url = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=register' );
         }
         $pin['pin_url_email'] = $pin['pin_url_report'] = $pin['pin_url_like'] = $pin['pin_url_repin'] = $pin['pin_url_comment'] = $login_url;
         $pin['pin_edit'] = false;
     } else {
         $pin['pin_url_email'] = WM_Router::pinAction($pin['pin_pin_id'], 'email');
         $pin['pin_url_report'] = WM_Router::pinAction($pin['pin_pin_id'], 'report');
         $pin['pin_url_like'] = WM_Router::pinAction($pin['pin_pin_id'], 'like');
         $pin['pin_url_repin'] = WM_Router::pinAction($pin['pin_pin_id'], 'repin');
         $pin['pin_url_comment'] = WM_Router::pinAction($pin['pin_pin_id']);
         $pin['pin_edit'] = JO_Session::get('user[user_id]') == $pin['pin_user_id'] ? WM_Router::pinAction($pin['pin_pin_id'], 'edit') : false;
     }
     //$pin['pin_description'] = self::descriptionFix($pin['pin_description']);
     $pin['pin_href'] = WM_Router::pinAction($pin['pin_pin_id']);
     if ($pin['pin_gift']) {
         $pin['pin_price_formated'] = WM_Currency::format($pin['pin_price']);
     } else {
         $pin['pin_price_formated'] = 0;
     }
     //return all image sizes
     $pin['pin_thumbs'] = Helper_Uploadimages::pinThumbs($pin);
     //array_merge($pin, Helper_Uploadimages::pinThumbs($pin));
     $date_dif = array_shift(WM_Date::dateDiff($pin['pin_date_added'], time()));
     $pin['pin_date_dif'] = $date_dif;
     /* URL'S*/
     $pin['pin_onto_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['board_user_id'] . '&board_id=' . $pin['board_board_id']);
     ////follow urls
     $pin['board_follow_href'] = $pin['user_follow_href'] = $pin['via_follow_href'] = false;
     if (JO_Session::get('user[user_id]') ? $pin['board_user_id'] != JO_Session::get('user[user_id]') : false) {
         $pin['board_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $pin['board_user_id'] . '&board_id=' . $pin['board_board_id']);
     }
     if (JO_Session::get('user[user_id]') ? $pin['user_user_id'] != JO_Session::get('user[user_id]') : false) {
         $pin['user_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_user_id']);
     }
     if ($pin['via_user_id']) {
         if (JO_Session::get('user[user_id]') ? $pin['via_user_id'] != JO_Session::get('user[user_id]') : false) {
             $pin['via_follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['via_user_id']);
         }
     } else {
         if (JO_Session::get('user[user_id]') ? $pin['user_user_id'] != JO_Session::get('user[user_id]') : false) {
             $pin['via_follow_href'] = $pin['user_follow_href'];
         }
     }
     if ($detail) {
         $pin['pin_next_href'] = '';
         if (isset($pin['pin_next']) && $pin['pin_next']) {
             $pin['pin_next_href'] = WM_Router::pinAction($pin['pin_next']);
         }
         $pin['pin_prev_href'] = '';
         if (isset($pin['pin_prev']) && $pin['pin_prev']) {
             $pin['pin_prev_href'] = WM_Router::pinAction($pin['pin_prev']);
         }
     }
     if (Helper_Config::get('config_comments_list') && !$detail && $pin['pin_comments']) {
         $latest_comments = Model_Comments::getLatestComments2($pin['pin_latest_comments']);
         $pin['pin_latest_comments'] = array();
         $user_id = JO_Session::get('user[user_id]');
         $is_admin = JO_Session::get('user[is_admin]');
         $is_developer = JO_Session::get('user[is_developer]');
         foreach ($latest_comments as $key => $comment) {
             $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $comment['avatar'], 'store' => $comment['store'], 'user_id' => $comment['user_id']));
             $enable_delete = false;
             if ($is_admin) {
                 $enable_delete = true;
             } elseif ($is_developer) {
                 $enable_delete = true;
             } elseif ($user_id == $comment['user_id']) {
                 $enable_delete = true;
             } elseif ($comment['pin_user_id'] == $user_id) {
                 $enable_delete = true;
             }
             $delete = false;
             if ($enable_delete) {
                 $delete = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $comment['comment_id']);
             }
             $pin['pin_latest_comments'][] = array('user' => array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $comment['user_id']), 'avatars' => $user_avatars, 'fullname' => $comment['fullname']), 'comment' => $comment['comment'], 'delete' => $delete);
         }
     } else {
         $pin['pin_latest_comments'] = array();
     }
     $pin['pin_video_code'] = false;
     if ($detail) {
         if ($pin['pin_is_video']) {
             $auto = new Helper_AutoEmbed();
             if ($pin['pin_repin_from'] && $auto->parseUrl($pin['pin_from_repin'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['pin_video_code'] = $auto->getEmbedCode();
             } else {
                 if ($auto->parseUrl($pin['pin_from'])) {
                     $auto->setWidth('100%');
                     $auto->setHeight('350');
                     $pin['pin_video_code'] = $auto->getEmbedCode();
                 } else {
                     $pin['pin_is_video'] = false;
                 }
             }
         } else {
             $auto = new Helper_AutoEmbed();
             if ($pin['pin_repin_from'] && $auto->parseUrl($pin['pin_from_repin'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['pin_video_code'] = $auto->getEmbedCode();
                 $pin['pin_is_video'] = true;
             } else {
                 if ($auto->parseUrl($pin['pin_from'])) {
                     $auto->setWidth('100%');
                     $auto->setHeight('350');
                     $pin['pin_video_code'] = $auto->getEmbedCode();
                     $pin['pin_is_video'] = true;
                 } else {
                     $pin['pin_is_video'] = false;
                 }
             }
         }
         $pin['pin_gallery'] = array();
         $gallery = new Model_Pins_Gallery($pin['pin_pin_id']);
         if ($gallery->count()) {
             foreach ($gallery->data as $gal) {
                 $pin['pin_gallery'][] = Helper_Uploadimages::pinThumbs(array('pin_pin_id' => $gal['pin_id'], 'pin_store' => $gal['store'], 'gallery_id' => $gal['gallery_id'], 'pin_image' => $gal['image']));
             }
         }
     }
     ///////////////////////////////////// AUTHOR INFO /////////////////////////////////////
     //return author all images
     $user_data = array('avatar' => $pin['user_avatar'], 'store' => $pin['user_store'], 'user_id' => $pin['user_user_id']);
     foreach ($pin as $k => $v) {
         if (strpos($k, 'user_avatar_') === 0) {
             $user_data[$k] = $v;
         }
     }
     $pin['user_avatars'] = Helper_Uploadimages::userAvatars($user_data);
     $pin['user_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_user_id']);
     ///////////////////////////////////// VIA INFO /////////////////////////////////////
     $pin['via_profile'] = array();
     if ($pin['via_user_id']) {
         $via_avatars = Helper_Uploadimages::userAvatars(array('avatar' => $pin['via_avatar'], 'store' => $pin['via_store'], 'user_id' => $pin['via_user_id']));
         $pin['via_profile'] = array('avatars' => $via_avatars, 'profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['via_user_id']), 'fullname' => $pin['via_fullname']);
     }
     ///////////////////////////////////// SELF INFO /////////////////////////////////////
     $pin['self_profile'] = false;
     if (JO_Session::get('user[user_id]')) {
         $user_avatars = Helper_Uploadimages::userAvatars(array('avatar' => JO_Session::get('user[avatar]'), 'store' => JO_Session::get('user[store]'), 'user_id' => JO_Session::get('user[user_id]')));
         $pin['self_profile']['avatars'] = $user_avatars;
         $pin['self_profile']['fullname'] = JO_Session::get('user[fullname]');
         $pin['self_profile']['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
     }
     ///////////////////////////////////// SOURCE INFO /////////////////////////////////////
     $pin['pin_source'] = array();
     $pin['pin_target_repin'] = false;
     if ($detail) {
         if ($pin['pin_repin_from']) {
             $pin_repin = new Model_Pins_Pin($pin['pin_repin_from']);
             if ($pin_repin->count()) {
                 $pin_repin = $pin_repin->data;
                 $pin['pin_source']['source'] = $pin_repin['board_title'];
                 $pin['pin_from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_user_id'] . '&board_id=' . $pin_repin['board_board_id']);
                 $pin['pin_target_repin'] = true;
             } else {
                 $source = new Model_Sources_Source($pin['pin_source_id']);
                 if ($source->count()) {
                     $pin['pin_source']['source'] = $source['source'];
                 }
             }
         } else {
             $source = new Model_Sources_Source($pin['pin_source_id']);
             if ($source->count()) {
                 $pin['pin_source']['source'] = $source['source'];
             }
         }
     }
     ///for mobile
     $pin['mobile_upload'] = false;
     if ($pin['pin_from'] == 'Mobile') {
         $pin['pin_from'] = '';
         $pin['mobile_upload'] = true;
     }
     return $pin;
 }
示例#11
0
 public function editAction()
 {
     //		var_dump( htmlspecialchars('⚐') );exit;
     $request = $this->getRequest();
     $pin_id = $request->getRequest('pin_id');
     $pin_info = Model_Pins::getPin($pin_id);
     if (!$pin_info || $pin_info['user_id'] != JO_Session::get('user[user_id]')) {
         $this->forward('error', 'error404');
     }
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         if ($pin_info['from']) {
             $validate->_set_rules($request->getPost('from'), $this->translate('Link'), 'not_empty;min_length[3];domain');
         }
         $data = $request->getPost();
         if ($validate->_valid_form()) {
             Model_Pins::editPin($pin_id, $request->getPost());
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin_info['pin_id']));
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
         foreach ($data as $k => $v) {
             if (isset($pin_info[$k])) {
                 $pin_info[$k] = $v;
             }
         }
     }
     $image = Helper_Uploadimages::pin($pin_info, '_B');
     if ($image) {
         $pin_info['thumb'] = $image['image'];
         $pin_info['thumb_width'] = $image['width'];
         $pin_info['thumb_height'] = $image['height'];
     } else {
         $pin_info['thumb'] = '';
         $pin_info['thumb_width'] = 0;
         $pin_info['thumb_height'] = 0;
     }
     if ($pin_info['gift']) {
         $pin_info['price_formated'] = WM_Currency::format($pin_info['price']);
     } else {
         $pin_info['price_formated'] = '';
         $pin_info['price'] = 0;
     }
     $pin_info['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin_info['pin_id']);
     $this->view->pin_info = $pin_info;
     $view->get_user_friends = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
     $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']);
         }
     }
     $this->view->pin_delete = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=delete&pin_id=' . $pin_id);
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'pin/left_part');
 }
示例#12
0
 public function formAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user_id')) {
         JO_Session::set('msg_error', $this->translate('You must be logged to upload an item'));
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
     if (JO_Session::get('quiz') != 'true') {
         JO_Session::set('msg_error', $this->translate('In order to upload your files for sale first you have to pass our quiz.'));
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=quiz'));
     }
     if ($request->getRequest('form')) {
         $category_id = $request->getRequest('form');
     }
     $redir_link = WM_Router::create($request->getBaseUrl() . '?controller=upload');
     if (!$category_id) {
         $this->redirect($redir_link);
     }
     $this->getLayout()->meta_title = $this->translate('Item upload');
     $this->getLayout()->meta_description = $this->translate('Item upload');
     $mainCategories = Model_Categories::getMain();
     $cnt = count($mainCategories);
     for ($i = 0; $i < $cnt; $i++) {
         $mainCategories[$i]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=upload&action=get_categories&category_id=' . $mainCategories[$i]['id']);
     }
     $category_info = Model_Categories::get($category_id);
     $has_category = JO_Array::multi_array_search($mainCategories, 'id', $category_id);
     if (!$category_info) {
         JO_Session::set('msg_error', $this->translate('You have choosen a non existing category'));
         $this->redirect($redir_link);
     } elseif (empty($has_category)) {
         JO_Session::set('msg_error', $this->translate('You have choosen a non existing category'));
         $this->redirect($redir_link);
     }
     if (JO_Session::get('msg_error')) {
         $this->view->error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     if (JO_Session::get('data')) {
         $this->view->d = JO_Session::get('data');
         JO_Session::clear('data');
     }
     $fileTypes = JO_Registry::get('upload_theme');
     $types = '';
     if ($fileTypes) {
         foreach ($fileTypes as $type) {
             $tp = explode(',', $type);
             foreach ($tp as $t) {
                 $types .= '*.' . $t . ';';
             }
         }
     }
     $this->view->sel_category = $category_id;
     $this->view->mainCategories = $mainCategories;
     $allCategories = Model_Categories::getWithChilds();
     $categoriesSelect = Model_Categories::generateSelect($allCategories, $category_id, $category_id);
     if ($categoriesSelect) {
         $categories = explode('|', $categoriesSelect);
         foreach ($categories as $category) {
             if (!empty($category)) {
                 $c = explode('>', $category);
                 $this->view->categoriesSelect[] = array('id' => $c[0], 'name' => trim($c[1]));
             }
         }
     }
     $this->view->fileTypes = $types;
     $this->view->attributes = Model_Attributes::getAllWithCategories("attributes_categories.categories LIKE '%," . (int) $category_id . ",%'");
     $fileTypes_allow = JO_Registry::get('upload_theme');
     $allow_archives = array();
     if (isset($fileTypes_allow['archives'])) {
         $ew = explode(',', $fileTypes_allow['archives']);
         foreach ($ew as $ar) {
             $allow_archives[] = '.' . strtolower($ar);
         }
     }
     $allow_images = array();
     if (isset($fileTypes_allow['images'])) {
         $ew = explode(',', $fileTypes_allow['images']);
         foreach ($ew as $ar) {
             $allow_images[] = '.' . strtolower($ar);
         }
     }
     $this->view->uploaded_files = JO_Session::get('uploaded_files');
     $this->view->uploaded_arhives = JO_Session::get('uploaded_arhives');
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Upload')));
     $user = Model_Users::getByUsername(JO_Session::get('username'));
     $this->view->author_header = Helper_Author::authorHeader($user);
     $this->view->action_upload = WM_Router::create($request->getBaseUrl() . '?controller=upload&action=upload');
     $this->view->autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=items&action=auto');
     $this->view->total_sales_cnt = JO_Session::get('sales');
     $this->view->total_balance = WM_Currency::format(JO_Session::get('total'));
     $this->view->percent = Model_Percentes::getPercentRow($user);
     $help = Model_Pages::get(JO_Registry::forceGet('page_upload_item'));
     if ($help) {
         $this->view->page_upload_item = array('name' => $help['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id'] . '&name=' . WM_Router::clearName($help['name'])));
     }
     $this->view->file_upload = WM_Router::create($request->getBaseUrl() . '?module=themes&controller=upload&action=doupload');
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
示例#13
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) {
         new Model_Users_Edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
         JO_Session::clear('category_id');
         $template = Model_Notification::getTemplate('welcome');
         if ($template) {
             $template_data = array('user_id' => JO_Session::get('user[user_id]'), 'user_firstname' => JO_Session::get('user[firstname]'), 'user_lastname' => JO_Session::get('user[lastname]'), 'user_fullname' => JO_Session::get('user[fullname]'), 'user_username' => JO_Session::get('user[username]'), 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
             if (!$template['title']) {
                 $template['title'] = $this->translate('Welcome to ${site_name}!');
             }
             $title = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data);
             $body = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data);
             Model_Email::send(JO_Session::get('user[email]'), Helper_Config::get('noreply_mail'), $title, $body);
         }
     }
     $this->view->show_landing = !Helper_Config::get('enable_free_registration');
     $this->getLayout()->placeholder('site_name', Helper_Config::get('site_name'));
     $this->view->site_name = Helper_Config::get('site_name');
     $this->view->meta_title = Helper_Config::get('meta_title');
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(Helper_Config::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (Helper_Config::get('site_logo') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . Helper_Config::get('site_logo');
     }
     ///global metas
     if (!JO_Layout::getInstance()->placeholder('header_metas')) {
         $to_title = '';
         if (JO_Session::get('user[user_id]')) {
             $to_title = JO_Session::get('user[fullname]') . ' / ';
         }
         $this->getLayout()->placeholder('title', $to_title . Helper_Config::get('meta_title'));
         JO_Layout::getInstance()->placeholder('header_metas', $this->view->callChildren('layout/header_metas', array('meta_title' => Helper_Config::get('meta_title'), 'meta_description' => Helper_Config::get('meta_description'), 'meta_keywords' => Helper_Config::get('meta_keywords'), 'site_logo' => $this->view->site_logo)));
     }
     if (Helper_Config::get('favicon') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('favicon'))) {
         $this->getLayout()->placeholder('favicon', $request->getBaseUrl() . 'uploads' . Helper_Config::get('favicon'));
     }
     $this->getLayout()->placeholder('site_logo', $this->view->site_logo);
     $this->view->show_header_invate = !JO_Session::get('user[user_id]');
     $this->view->controller_open = $request->getController();
     //==== brand =====//
     $this->view->show_brand = false;
     /*if( JO_Registry::get('license_powered_check') == 'false' && Helper_Config::get('config_hide_brand') ) {
     			$this->view->show_brand = false;
     		}*/
     ////////// CURRENCY
     //autoupdate currency if set
     if (Helper_Config::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
     }
     //////////// Categories ////////////
     $this->view->categories = array();
     $this->view->category_active = false;
     $categories = Model_Categories::getCategories(array('filter_status' => 1));
     foreach ($categories as $category) {
         $category['href'] = WM_Router::create($request->getBaseUrl() . '?controller=category&category_id=' . $category['category_id']);
         $category['active'] = $category['category_id'] == $request->getRequest('category_id');
         if ($category['active']) {
             $this->view->category_active = $category['title'];
         } else {
         }
         $this->view->categories[] = $category;
     }
     ////////////////////////////// USER MENU ///////////////////////////
     $this->view->is_loged = JO_Session::get('user[user_id]');
     if ($this->view->is_loged) {
         $model_images = new Helper_Images();
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $this->view->self_avatar = Helper_Uploadimages::userAvatars(JO_Session::get('user'));
         $this->view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $this->view->is_loged);
         $this->view->self_firstname = JO_Session::get('user[firstname]');
         $this->view->logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
         $this->view->user_pins = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged);
         $this->view->user_pins_likes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged . '&filter=likes');
         $this->view->settings = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     $this->view->landing = WM_Router::create($request->getBaseUrl() . '?controller=landing');
     $this->view->registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register');
     ////////////////////////////// GIFTS ///////////////////////////
     $this->view->gifts = WM_Router::create($request->getBaseUrl() . '?controller=gifts');
     $this->view->giftSums = array();
     $sums = Model_Gifts::getAll();
     foreach ($sums as $sum) {
         if ($sum['price_from'] || $sum['price_to']) {
             $title = WM_Currency::format($sum['price_from']);
             $url = '';
             if ($sum['price_to']) {
                 $title .= ' - ';
                 $title .= WM_Currency::format($sum['price_to']);
                 $url = '&price_to=' . $sum['price_to'];
             } else {
                 $title .= '+';
             }
             $this->view->giftSums[] = array('title' => $title, 'href' => WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=' . $sum['price_from'] . $url));
         }
     }
     //////////// Video ////////////
     $this->view->video_url = WM_Router::create($request->getBaseUrl() . '?controller=videos');
     //////////// Popular ////////////
     $this->view->popular_url = WM_Router::create($request->getBaseUrl() . '?controller=popular');
     //////////// ALL PINS ////////////
     $this->view->all_url = WM_Router::create($request->getBaseUrl() . '?controller=all');
     ////////////////////////////// SEARCH ///////////////////////////
     //$this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     if ($request->getAction() != 'index' && $request->getController() == 'search') {
         $with_action = $request->getAction();
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction());
     } else {
         $with_action = 0;
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     }
     $this->view->search_autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete');
     if (strpos($this->view->search, '?') !== false) {
         $this->view->show_hidden = true;
         $this->view->with_action = $with_action;
     }
     $this->view->keywords = $request->issetQuery('q') ? $request->getQuery('q') : $this->translate('Search');
     ////////////////////////////// ADD PIN ///////////////////////////
     $this->view->addPin = WM_Router::create($request->getBaseUrl() . '?controller=addpin');
     ////////////////////////////// user ignore search engine ///////////////////////////
     if ($request->getRequest('user_id')) {
         $user_info = Model_Users::getUser($request->getRequest('user_id'));
         if ($user_info && $user_info['dont_search_index']) {
             $this->getLayout()->placeholder('inhead', '<meta name="robots" content="noindex"/>');
         }
     }
     ////////////////////////////// ABOUT MENU ///////////////////////////
     $about_menu = Model_Pages::getMenu(0);
     $this->view->about_menu = array();
     foreach ($about_menu as $row => $page) {
         $class = '';
         if ($row == 0) {
             $class .= ' first';
         } else {
             if (count($about_menu) - 1 == $row) {
                 $class .= ' last';
             }
         }
         if ($page['page_id'] == -1) {
             $has = true;
         } else {
             if ($page['status']) {
                 if (isset($has) && $has) {
                     $class .= " group";
                     $has = false;
                 }
                 $this->view->about_menu[] = array('class' => trim($class), 'title' => $page['title'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page['page_id']));
             }
             $has = false;
         }
     }
     ////////////////////////////// NEW PASSWORD ///////////////////////////
     $this->view->show_new_password = false;
     if (JO_Session::get('user[user_id]') && JO_Session::get('user[email]') != JO_Session::get('user[new_email]')) {
         /*switch(true) {
         			case 'index' == $request->getController():
         			case 'all' == $request->getController():
         			case 'category' == $request->getController():
         			case 'videos' == $request->getController():
         			case 'popular' == $request->getController():
         			case 'gifts' == $request->getController():
         				$this->view->show_new_password = true;
         			break;
         		}*/
         $this->view->show_new_password = true;
     }
     ////////////////////////////// Board category ///////////////////////////
     if (($board_info = JO_Registry::forceGet('board_category_change')) instanceof ArrayObject) {
         $this->view->board_category_change = array('title' => $board_info['board_title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board_info['board_user_id'] . '&board_id=' . $board_info['board_board_id']));
     }
     ///////////////////// invate menu user /////////////////////////////
     $methodsforinvates = $this->view->callChildrenView('invates/methodsforinvates');
     $this->view->methodsforinvates = (array) $methodsforinvates->user_invate_friends;
     ///////////////////// extra metatags /////////////////////////////
     $extra_metas = '';
     $extra_metas_get = Model_Extensions::getByMethod('extra_metas');
     foreach ($extra_metas_get as $id => $mod) {
         $extra_metas .= $this->view->callChildren('modules_' . $mod . '_extrametas');
     }
     if ($extra_metas) {
         JO_Layout::getInstance()->placeholder('header_metas', $extra_metas);
     }
 }
示例#14
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if ($this->getLayout()->meta_title) {
         $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . JO_Registry::get('meta_title'));
     } else {
         $this->getLayout()->placeholder('title', JO_Registry::get('meta_title'));
     }
     if ($this->getLayout()->meta_description) {
         $this->getLayout()->placeholder('description', $this->getLayout()->meta_description);
     } else {
         $this->getLayout()->placeholder('description', JO_Registry::get('meta_description'));
     }
     if ($this->getLayout()->meta_keywords) {
         $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords);
     } else {
         $this->getLayout()->placeholder('keywords', JO_Registry::get('meta_keywords'));
     }
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(JO_Registry::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads/' . JO_Registry::get('site_logo'))) {
         $this->view->site_logo = JO_Registry::get('site_logo');
     }
     $this->view->home_action = $request->getBaseUrl();
     $this->getCategories();
     $this->view->menuPages = Model_Pages::getPagesMenu();
     if (isset($this->view->menuPages[0])) {
         foreach ($this->view->menuPages[0] as $k => $v) {
             $this->view->menuPages[0][$k]['href'] = $v['url'] ? $v['url'] : WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name']));
             if (isset($this->view->menuPages[$v['id']])) {
                 foreach ($this->view->menuPages[$v['id']] as $r => $t) {
                     $this->view->menuPages[$v['id']][$r]['href'] = $t['url'] ? $t['url'] : WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $t['id'] . '&name=' . WM_Router::clearName($t['name']));
                 }
             }
         }
     }
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     }
     if (JO_Session::get('msg_error')) {
         $this->view->msg_error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     $this->view->recent_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=recent');
     $this->view->top_sellers_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=popular');
     $this->view->feature_href = WM_Router::create($request->getBaseUrl() . '?controller=categories&action=featured');
     $this->view->collections_href = WM_Router::create($request->getBaseUrl() . '?controller=collections');
     $this->view->top_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=top');
     $this->view->all_authors_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=authors');
     $this->view->search = WM_Router::create($request->getBaseUrl() . '?controller=search');
     ////////// CURRENCY
     //autoupdate currency if set
     if (JO_Registry::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
         $currencies = WM_Currency::getCurrencies();
         $this->view->currencies = array();
         if ($currencies) {
             foreach ($currencies as $currency) {
                 $currency['active'] = $currency['code'] == WM_Currency::getCurrencyCode();
                 $this->view->currencies[] = $currency;
             }
         }
     }
     ///////// LANGUAGES
     $languages = WM_Locale::getLanguages();
     if ($languages && count($languages) > 1) {
         $this->view->languages = array();
         $config_language_id = JO_Registry::get('config_language_id');
         foreach ($languages as $language) {
             if ($language['language_id'] == $config_language_id) {
                 $this->view->current_language = array('name' => $language['name'], 'id' => $language['language_id'], 'image' => 'data/themes/images/flags/' . $language['image']);
             } else {
                 $this->view->languages[] = array('name' => $language['name'], 'id' => $language['language_id'], 'image' => 'data/themes/images/flags/' . $language['image']);
             }
         }
     }
     $username = JO_Session::get('username');
     if ($username) {
         $this->view->user = Model_Users::getUser(JO_Session::get('user_id'));
         $this->view->user['total'] = WM_Currency::format($this->view->user['total']);
         $ind = 0;
         $this->view->options = array(array('name' => $this->view->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('My Account'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Downloads'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=downloads'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Collections'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Deposit'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=deposit'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Dashboard'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=dashboard'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Upload'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=upload'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Earnings'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=earnings'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Statement'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=statement'), 'css' => 'icon-' . ++$ind), array('name' => $this->view->translate('Withdrawal'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=withdrawal'), 'css' => 'icon-' . ++$ind));
         $this->view->user_logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
     } else {
         $this->view->user_registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=registration');
         $this->view->user_login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         $this->view->user_lost_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=lost_username');
         $this->view->user_reset_password = WM_Router::create($request->getBaseUrl() . '?controller=users&action=reset_password');
     }
     $threads = Model_Forum::getAll();
     if ($threads) {
         $this->view->forum_link = WM_Router::create($request->getBaseUrl() . '?controller=forum');
         $this->view->threads = array();
         foreach ($threads as $thread) {
             $this->view->threads[] = array('name' => $thread['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum&action=thread/' . $thread['id'] . '&name=' . WM_Router::clearName($thread['name'])));
         }
     }
     $facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret')));
     $this->view->facebook_link = $facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=callback_facebook'), 'req_perms' => JO_Registry::forceGet('facebook_req_perms'), 'scope' => JO_Registry::forceGet('facebook_req_perms')));
     $this->view->children = array();
     $this->view->children['extensions_top'] = 'extensions/top';
     //	$this->view->children['extensions_topmiddle'] = 'extensions/topmiddle';
 }
示例#15
0
    public function daily_summary_mailAction()
    {
        $this->noViewRenderer(true);
        $request = $this->getRequest();
        $users = Model_Users::getDailySummary();
        if ($users) {
            $domain = $request->getDomain();
            $mail = new JO_Mail();
            if (JO_Registry::get('mail_smtp')) {
                $mail->setSMTPParams(JO_Registry::forceGet('mail_smtp_host'), JO_Registry::forceGet('mail_smtp_port'), JO_Registry::forceGet('mail_smtp_user'), JO_Registry::forceGet('mail_smtp_password'));
            }
            $mail->setFrom('no-reply@' . $domain);
            $not_template = Model_Notification::getNotification('daily_summary');
            foreach ($users as $user) {
                $user['to_date'] = WM_Date::format($user['to_date'], 'Y-mm-dd H:i');
                $user['from_date'] = WM_Date::format($user['from_date'], 'Y-mm-dd H:i');
                if ($not_template) {
                    $title = $not_template['title'];
                    $html = html_entity_decode($not_template['template'], ENT_QUOTES, 'utf-8');
                    $html = str_replace('{USERNAME}', $user['username'], $html);
                    $html = str_replace('{SALES}', $user['cnt'], $html);
                    $html = str_replace('{SUM}', WM_Currency::format($user['daily_sum']), $html);
                    $html = str_replace('{TO_DATE}', $user['to_date'], $html);
                    $html = str_replace('{FROM_DATE}', $user['from_date'], $html);
                } else {
                    $title = "[" . $domain . "] " . $this->translate('Daily summary');
                    $html = nl2br($this->translate('Daily summary') . '
					
					 from ' . $user['from_date'] . ' to ' . $user['to_date'] . '		
					 Sales: ' . $user['cnt'] . ', Receive money: ' . WM_Currency::format($user['daily_sum']) . '
					 
					 ===============================================================================================
					 
					 ' . JO_Registry::forceGet('meta_title') . '
					');
                }
                $mail->setSubject($title);
                $mail->setHTML($html);
                $mail->send(array($user['email']), JO_Registry::get('mail_smtp') ? 'smtp' : 'mail');
            }
        }
    }
示例#16
0
 private function getForm()
 {
     $request = $this->getRequest();
     $url = '';
     if ($request->getQuery('filter_id')) {
         $url .= '&filter_id=' . $request->getQuery('filter_id');
     }
     if ($request->getQuery('filter_name')) {
         $url .= '&filter_name=' . $request->getQuery('filter_name');
     }
     if ($request->getQuery('filter_username')) {
         $url .= '&filter_username='******'filter_username');
     }
     if ($request->getQuery('filter_price')) {
         $url .= '&filter_price=' . $request->getQuery('filter_price');
     }
     if ($request->getQuery('filter_sales')) {
         $url .= '&filter_sales=' . $request->getQuery('filter_sales');
     }
     if ($request->getQuery('filter_profit')) {
         $url .= '&filter_profit=' . $request->getQuery('filter_profit');
     }
     if ($request->getQuery('filter_free_request')) {
         $url .= '&filter_free_request=' . $request->getQuery('filter_free_request');
     }
     if ($request->getQuery('filter_free_file')) {
         $url .= '&filter_free_file=' . $request->getQuery('filter_free_file');
     }
     if ($request->getQuery('filter_weekly')) {
         $url .= '&filter_weekly=' . $request->getQuery('filter_weekly');
     }
     if ($request->getQuery('sort')) {
         $url .= '&sort=' . $request->getQuery('sort');
     }
     if ($request->getQuery('order')) {
         $url .= '&order=' . $request->getQuery('order');
     }
     if ($request->getQuery('page')) {
         $url .= '&page=' . $request->getQuery('page');
     }
     $id = $request->getQuery('id');
     $info = Model_Items::getItemUpdate($id);
     if (!$info) {
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/queueupdateditems/?' . $url);
     }
     $this->view->cancel = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/queueupdateditems/?' . $url;
     if ($info['thumbnail']) {
         $model_images = new Model_Images();
         $info['thumbnail'] = $model_images->resize($info['thumbnail'], JO_Registry::forceGet($info['module'] . '_items_thumb_width'), JO_Registry::forceGet($info['module'] . '_items_thumb_height'), true);
         if ((int) JO_Registry::get($info['module'] . '_items_preview_width') && (int) JO_Registry::get($info['module'] . '_items_preview_height')) {
             $info['theme_preview_thumbnail'] = $model_images->resize($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_width'), JO_Registry::forceGet($info['module'] . '_items_preview_height'), true);
         } elseif ((int) JO_Registry::get($info['module'] . '_items_preview_width')) {
             $info['theme_preview_thumbnail'] = $model_images->resizeWidth($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_width'));
         } elseif ((int) JO_Registry::get($info['module'] . '_items_preview_height')) {
             $info['theme_preview_thumbnail'] = $model_images->resizeHeight($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_height'));
         } else {
             $info['theme_preview_thumbnail'] = false;
         }
     }
     $this->view->info = $info;
     $this->view->price_f = WM_Currency::format($info['suggested_price']);
     $this->view->categories = Model_Categories::getCategoriesFromParentByModule(0, $info['module']);
     $cats_module = Model_Categories::getCategories(array('filter_sub_of' => 0, 'filter_module' => $info['module'], 'filter_concat' => true));
     $category = Model_Categories::getParentCategoryByItem($info['id'], true);
     $category = trim($category['categories'], ',');
     $this->view->attributes_list = Model_Attributes::getAllWithCategories("attributes_categories.categories LIKE '%," . (int) $category . ",%'");
     if ($request->getPost('name')) {
         $this->view->name = $request->getPost('name');
     } else {
         $this->view->name = $info['name'];
     }
     if ($request->getPost('description')) {
         $this->view->description = $request->getPost('description');
     } else {
         $this->view->description = $info['description'];
     }
     if ($request->getPost('price')) {
         $this->view->price = $request->getPost('price');
     } else {
         $this->view->price = $info['price'];
     }
     if ($request->getPost('category_id')) {
         $this->view->category_id = $request->getPost('category_id');
     } else {
         $this->view->category_id = Model_Items::getItemCategory($id);
     }
     if ($request->getPost('attributes')) {
         $this->view->attributes = $request->getPost('attributes');
     } else {
         $this->view->attributes = Model_Items::getItemAttributes($id);
     }
     if ($request->getPost('tags')) {
         $this->view->tags = $request->getPost('tags');
     } else {
         $this->view->tags = Model_Items::getItemTagsUpdate($id);
         //    		$this->view->tags = Model_Items::getItemTags($id);
     }
     if ($request->getPost('free_file')) {
         $this->view->free_file = $request->getPost('free_file');
     } else {
         $this->view->free_file = $info['free_file'];
     }
     if ($request->getPost('demo_url')) {
         $this->view->demo_url = $request->getPost('demo_url');
     } else {
         $this->view->demo_url = $info['demo_url'];
     }
     if ($request->getPost('weekly_from')) {
         $this->view->weekly_from = $request->getPost('weekly_from');
     } else {
         $this->view->weekly_from = '';
     }
     if ($request->getPost('weekly_to')) {
         $this->view->weekly_to = $request->getPost('weekly_to');
     } else {
         $this->view->weekly_to = '';
     }
 }
示例#17
0
 public function indexAction()
 {
     $request = $this->getRequest();
     if ($request->getQuery('from')) {
         $this->view->from = $request->getQuery('from');
     } else {
         $date = new JO_Date(null, 'yy-mm-01');
         $this->view->from = $date->toString();
     }
     if ($request->getQuery('to')) {
         $this->view->to = $request->getQuery('to');
     } else {
         $date = new JO_Date(null, 'yy-mm-t');
         $this->view->to = $date->toString();
     }
     $reportData = Model_Reports::getReport($this->view->from, $this->view->to);
     $depositData = Model_Reports::getDeposits($this->view->from, $this->view->to);
     $withdrawData = Model_Reports::getWithdraws($this->view->from, $this->view->to);
     $data = array();
     foreach ($reportData as $date => $v) {
         $data[$date] = array();
     }
     foreach ($depositData as $date => $v) {
         $data[$date] = array();
     }
     foreach ($withdrawData as $date => $v) {
         $data[$date] = array();
     }
     foreach ($data as $k => $v) {
         if (isset($reportData[$k])) {
             $data[$k]['total'] = $reportData[$k]['total'];
             $data[$k]['receive'] = $reportData[$k]['receive'];
             $data[$k]['referal'] = $reportData[$k]['referal'];
             $data[$k]['win'] = $reportData[$k]['win'];
             $data[$k]['total_for'] = WM_Currency::format($reportData[$k]['total']);
             $data[$k]['receive_for'] = WM_Currency::format($reportData[$k]['receive']);
             $data[$k]['referal_for'] = WM_Currency::format($reportData[$k]['referal']);
             $data[$k]['win_for'] = WM_Currency::format($reportData[$k]['win']);
         } else {
             $data[$k]['total'] = 0;
             $data[$k]['receive'] = 0;
             $data[$k]['referal'] = 0;
             $data[$k]['win'] = 0;
             $data[$k]['total_for'] = WM_Currency::format(0);
             $data[$k]['receive_for'] = WM_Currency::format(0);
             $data[$k]['referal_for'] = WM_Currency::format(0);
             $data[$k]['win_for'] = WM_Currency::format(0);
         }
         if (isset($depositData[$k])) {
             $data[$k]['deposit'] = $depositData[$k]['deposit'];
             $data[$k]['deposit_for'] = WM_Currency::format($depositData[$k]['deposit']);
         } else {
             $data[$k]['deposit'] = 0;
             $data[$k]['deposit_for'] = WM_Currency::format(0);
         }
         if (isset($withdrawData[$k])) {
             $data[$k]['withdraw'] = $withdrawData[$k]['amount'];
             $data[$k]['withdraw_for'] = WM_Currency::format($withdrawData[$k]['amount']);
         } else {
             $data[$k]['withdraw'] = 0;
             $data[$k]['withdraw_for'] = WM_Currency::format(0);
         }
     }
     $this->view->reports = $data;
 }
示例#18
0
 private function getForm()
 {
     $request = $this->getRequest();
     $url = '';
     if ($request->getQuery('filter_id')) {
         $url .= '&filter_id=' . $request->getQuery('filter_id');
     }
     if ($request->getQuery('filter_name')) {
         $url .= '&filter_name=' . $request->getQuery('filter_name');
     }
     if ($request->getQuery('filter_username')) {
         $url .= '&filter_username='******'filter_username');
     }
     if ($request->getQuery('filter_price')) {
         $url .= '&filter_price=' . $request->getQuery('filter_price');
     }
     if ($request->getQuery('filter_sales')) {
         $url .= '&filter_sales=' . $request->getQuery('filter_sales');
     }
     if ($request->getQuery('filter_profit')) {
         $url .= '&filter_profit=' . $request->getQuery('filter_profit');
     }
     if ($request->getQuery('filter_free_request')) {
         $url .= '&filter_free_request=' . $request->getQuery('filter_free_request');
     }
     if ($request->getQuery('filter_free_file')) {
         $url .= '&filter_free_file=' . $request->getQuery('filter_free_file');
     }
     if ($request->getQuery('filter_weekly')) {
         $url .= '&filter_weekly=' . $request->getQuery('filter_weekly');
     }
     if ($request->getQuery('sort')) {
         $url .= '&sort=' . $request->getQuery('sort');
     }
     if ($request->getQuery('order')) {
         $url .= '&order=' . $request->getQuery('order');
     }
     if ($request->getQuery('page')) {
         $url .= '&page=' . $request->getQuery('page');
     }
     $id = $request->getQuery('id');
     $info = Model_Items::getItemUpdate($id);
     if (!$info) {
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/queueupdateditems/?' . $url);
     }
     $this->view->cancel = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/queueupdateditems/?' . $url;
     $model_images = new Model_Images();
     $info['thumbnail'] = $model_images->resize($info['thumbnail'], JO_Registry::forceGet($info['module'] . '_items_thumb_width'), JO_Registry::forceGet($info['module'] . '_items_thumb_height'), true);
     if ((int) JO_Registry::get($info['module'] . '_items_preview_width') && (int) JO_Registry::get($info['module'] . '_items_preview_height')) {
         $info['theme_preview_thumbnail'] = $model_images->resize($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_width'), JO_Registry::forceGet($info['module'] . '_items_preview_height'), true);
     } elseif ((int) JO_Registry::get($info['module'] . '_items_preview_width')) {
         $info['theme_preview_thumbnail'] = $model_images->resizeWidth($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_width'));
     } elseif ((int) JO_Registry::get($info['module'] . '_items_preview_height')) {
         $info['theme_preview_thumbnail'] = $model_images->resizeHeight($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_height'));
     } else {
         $info['theme_preview_thumbnail'] = false;
     }
     $this->view->info = $info;
     $this->view->price_f = WM_Currency::format($info['suggested_price']);
     $this->view->categories = Model_Categories::getCategoriesFromParentByModule(0, $info['module']);
     $cats_module = Model_Categories::getCategories(array('filter_sub_of' => 0, 'filter_module' => $info['module'], 'filter_concat' => true));
     $where_attr = '';
     if ($cats_module) {
         $tmp = array();
         foreach ($cats_module as $c) {
             $tmp[] = "categories LIKE '%," . $c . ",%'";
         }
         if ($tmp) {
             $where_attr = implode(' OR ', $tmp);
         }
     }
     $this->view->attributes_list = array();
     $attr_cat = Model_Attributes::getAttributes(array(), $where_attr);
     if ($attr_cat) {
         foreach ($attr_cat as $row => $attr) {
             $attr_list = Model_Attributes::getAttributes(array('filter_sub_of' => $attr['id']));
             if ($attr_list) {
                 $this->view->attributes_list[$row] = $attr;
                 $this->view->attributes_list[$row]['items'] = $attr_list;
             }
         }
     }
     if ($request->getPost('name')) {
         $this->view->name = $request->getPost('name');
     } else {
         $this->view->name = $info['name'];
     }
     if ($request->getPost('description')) {
         $this->view->description = $request->getPost('description');
     } else {
         $this->view->description = $info['description'];
     }
     if ($request->getPost('price')) {
         $this->view->price = $request->getPost('price');
     } else {
         $this->view->price = $info['price'];
     }
     if ($request->getPost('category_id')) {
         $this->view->category_id = $request->getPost('category_id');
     } else {
         $this->view->category_id = Model_Items::getItemCategory($id);
     }
     if ($request->getPost('attributes')) {
         $this->view->attributes = $request->getPost('attributes');
     } else {
         $this->view->attributes = Model_Items::getItemAttributes($id);
     }
     if ($request->getPost('tags')) {
         $this->view->tags = $request->getPost('tags');
     } else {
         //    		$this->view->tags = Model_Items::getItemTagsUpdate($id);
         $this->view->tags = Model_Items::getItemTags($id);
     }
     if ($request->getPost('free_file')) {
         $this->view->free_file = $request->getPost('free_file');
     } else {
         $this->view->free_file = $info['free_file'];
     }
     if ($request->getPost('demo_url')) {
         $this->view->demo_url = $request->getPost('demo_url');
     } else {
         $this->view->demo_url = $info['demo_url'];
     }
     if ($request->getPost('weekly_from')) {
         $this->view->weekly_from = $request->getPost('weekly_from');
     } else {
         $this->view->weekly_from = '';
     }
     if ($request->getPost('weekly_to')) {
         $this->view->weekly_to = $request->getPost('weekly_to');
     } else {
         $this->view->weekly_to = '';
     }
     if ($request->getPost('default_price')) {
         $this->view->default_price = $request->getPost('default_price');
     } else {
         $this->view->default_price = '';
     }
     /* sizes */
     $prices = Model_Items_Image::getPriceItem($id);
     $sizes = Model_Sizes::getAll();
     $this->view->sizes = array();
     if ($sizes) {
         $filesize = false;
         if ($info['main_file'] && file_exists(BASE_PATH . '/uploads/' . $info['main_file'])) {
             $info_file = getimagesize(BASE_PATH . '/uploads/' . $info['main_file']);
             $filesize = $info_file[0] * $info_file[1];
         }
         foreach ($sizes as $k => $size) {
             $price = isset($prices[$size['id']]) ? $prices[$size['id']] : '';
             if ($filesize && $size['size'] * 1000000 <= $filesize) {
                 $size['post_price'] = $request->issetPost('price[' . $size['id'] . ']') ? $request->getPost('price[' . $size['id'] . ']') : $price;
                 $size['size'] = round($size['size'], 2);
                 $this->view->sizes[$k] = $size;
                 $this->view->default_price = $this->view->default_price ? $this->view->default_price : ($size['post_price'] == $info['price'] ? $size['id'] : '');
             }
         }
         if (!$this->view->default_price) {
             foreach ($sizes as $k => $size) {
                 if ($filesize && $size['size'] * 1000000 <= $filesize) {
                     $this->view->default_price = $size['id'];
                     break;
                 }
             }
         }
     }
 }
示例#19
0
 public function sendWeeklyAction()
 {
     $request = $this->getRequest();
     $this->view->base_href = $request->getBaseUrl();
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->on_facebook = JO_Registry::get('config_on_facebook');
     $this->view->site_logo = $this->view->base_href . 'data/images/logo.png';
     if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('site_logo'))) {
         $this->view->site_logo = $this->view->base_href . 'uploads' . JO_Registry::get('site_logo');
     }
     $this->view->settings = WM_Router::create($this->view->base_href . '?controller=prefs');
     $goodies = Model_Pages::getPage(JO_Registry::get('page_goodies'));
     if ($goodies) {
         //$this->view->pin_it = WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_goodies'));
         $this->view->pin_it = 'http://amatteur.com/apps';
     }
     $this->view->pages = array();
     $page = Model_Pages::getPage(JO_Registry::get('page_privacy_policy'));
     if ($page) {
         $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy')));
     }
     $page = Model_Pages::getPage(JO_Registry::get('page_terms'));
     if ($page) {
         $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy')));
     }
     $histories = Model_History::getHistoryToday(array('week_range' => WM_Date::x_week_range($this->now)));
     $no_avatar = JO_Registry::get('no_avatar');
     if ($histories) {
         $model_images = new Helper_Images();
         /* BOARDS */
         $this->view->popular_bards = array();
         $populars = Model_Boards::getBoards(array('start' => 0, 'limit' => 6, 'sort' => 'DESC', 'order' => 'boards.total_views', 'where' => new JO_Db_Expr('pins > 4')));
         if ($populars) {
             foreach ($populars as $board) {
                 $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
                 $board['thumbs'] = array();
                 $get_big = false;
                 for ($i = 0; $i < 5; $i++) {
                     $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false;
                     if ($image) {
                         if ($get_big) {
                             $size = '_A';
                         } else {
                             $size = '_C';
                             $get_big = true;
                         }
                         $data_img = call_user_func(array(Helper_Pin::formatUploadModule($board['pins_array'][$i]['store']), 'getPinImage'), $board['pins_array'][$i], $size);
                         if ($data_img) {
                             $board['thumbs'][] = $data_img['image'];
                         } else {
                             $board['thumbs'][] = false;
                         }
                     } else {
                         $board['thumbs'][] = false;
                     }
                 }
                 $board['user'] = Model_Users::getUser($board['user_id']);
                 $board['user']['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $board['user_id']);
                 $avatar = Helper_Uploadimages::avatar($board['user'], '_A');
                 $board['user']['avatar'] = $avatar['image'];
                 $this->view->popular_bards[] = $board;
             }
         }
         /* VIDEO */
         //			$this->view->video = array();
         //			$video = Model_Pins::getPins(array(
         //				'start' => 0,
         //				'limit' => 1,
         //				'filter_is_video' => 1
         //			));
         //
         //			if($video) {
         //				foreach($video AS $pin) {
         //					$pin['thumb'] = $model_images->resizeWidth($pin['image'], 194);
         //					$pin['thumb_width'] = $model_images->getSizes('width');
         //					$pin['thumb_height'] = $model_images->getSizes('height');
         //					$pin['description'] = Helper_Pin::descriptionFix($pin['description']);
         //					$pin['href'] = WM_Router::create( $request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id'] );
         //
         //				}
         //			}
         /* HISTORY */
         foreach ($histories as $history) {
             if (!isset($history['store'])) {
                 continue;
             }
             $avatar = Helper_Uploadimages::avatar($history, '_B');
             $history['avatar'] = $avatar['image'];
             $history['user_followers'] = WM_Router::create($this->view->base_href . '?controller=users&action=followers&user_id=' . $history['user_id']);
             $history['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $history['user_id']);
             $history['history_comments_total'] = count($history['history_comments']);
             $history['history_follow_total'] = count($history['history_follow']);
             $history['history_like_total'] = count($history['history_like']);
             $history['history_repin_total'] = count($history['history_repin']);
             $history['history_event_total'] = count($history['history_event']);
             /////comments
             if ($history['history_comments_total']) {
                 foreach ($history['history_comments'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_comments'][$k]['avatar'] = $avatar['image'];
                     $history['history_comments'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             /////follow
             if ($history['history_follow_total']) {
                 foreach ($history['history_follow'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_follow'][$k]['avatar'] = $avatar['image'];
                     $history['history_follow'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             /////like
             if ($history['history_like_total']) {
                 foreach ($history['history_like'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_like'][$k]['avatar'] = $avatar['image'];
                     $history['history_like'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             /////repin
             if ($history['history_repin_total']) {
                 foreach ($history['history_repin'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::avatar($v, '_A');
                     $history['history_repin'][$k]['avatar'] = $avatar['image'];
                     $history['history_repin'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             ////events
             if ($history['history_event_total']) {
                 foreach ($history['history_event'] as $k => $v) {
                     if (!isset($v['store'])) {
                         continue;
                     }
                     $avatar = Helper_Uploadimages::event($v, '_A');
                     $history['history_event'][$k]['avatar'] = $avatar['image'];
                     $history['history_event'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']);
                 }
             }
             $this->view->events = array();
             $this->view->event = array();
             $dataEvents = array('filter_cron' => $history['user_id']);
             $events = Model_Events::getEvents($dataEvents);
             if ($events) {
                 foreach ($events as $key => $event) {
                     $href = "";
                     $view = JO_View::getInstance();
                     $view->loged = JO_Session::get('user[user_id]');
                     $model_images = new Helper_Images();
                     $avatar = Helper_Uploadimages::avatar($event, '_B');
                     $event['avatar'] = $avatar['image'];
                     $event['thumbs'] = $avatar['image'];
                     $event["sport_category"] = Model_Boards::getCategoryTitle($event["sport_category"]);
                     $data = array('filter_user_id' => $event["user_id"]);
                     $users = Model_Users::getUsers($data);
                     if ($users) {
                         $event['fullname'] = $users[0]["fullname"];
                         $event['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']);
                         $href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $event['user_id']);
                     }
                     //$view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=boxeventdetail&event_id=' . $event['event_id']);
                     $view->boxeventdetail = WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']);
                     $this->view->event[] = $event;
                     $view->event = $event;
                     $this->view->events[] = $view->render('boxEvent', 'events');
                 }
             }
             /* PINS */
             $likes = Model_History::getHistory(array('history_action' => Model_History::LIKEPIN, 'start' => 0, 'limit' => 30), 'from_user_id', $history['user_id']);
             $history['pins_likes'] = array();
             if ($likes) {
                 $temp = array();
                 foreach ($likes as $like) {
                     $temp[$like['pin_id']] = $like['pin_id'];
                 }
                 if ($temp) {
                     $pins = Model_Pins::getPins(array('start' => 0, 'limit' => 9, 'filter_id_in' => implode(',', $temp)));
                     if ($pins) {
                         foreach ($pins as $pin) {
                             $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B');
                             if ($image) {
                                 $pin['thumb'] = $image['image'];
                                 $pin['thumb_width'] = $image['width'];
                                 $pin['thumb_height'] = $image['height'];
                             } else {
                                 continue;
                             }
                             $pin['description'] = Helper_Pin::descriptionFix($pin['description']);
                             $pin['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
                             $pin['onto_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['user_id'] . '&board_id=' . $pin['board_id']);
                             $pin['price_formated'] = WM_Currency::format($pin['price']);
                             $avatar = Helper_Uploadimages::avatar($pin['user'], '_A');
                             $pin['user']['avatar'] = $avatar['image'];
                             $pin['user']['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $pin['user_id']);
                             $pin['via_profile'] = array();
                             if ($pin['via'] && $pin['user_via']) {
                                 $pin['via_profile'] = array('profile' => WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $pin['via']), 'fullname' => $pin['user_via']['fullname']);
                             }
                             $history['pins_likes'][] = $pin;
                         }
                     }
                 }
             }
             $this->view->history = $history;
             $html = $this->view->render('sendWeekly', 'crons');
             Model_Email::send($history['email'], JO_Registry::get('noreply_mail'), sprintf($this->translate('Weekly %s'), $this->view->site_name), $html);
         }
     }
 }
示例#20
0
 public function editAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user_id')) {
         JO_Session::set('msg_error', $this->translate('You must be logged to access that page'));
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
     $itemID = $request->getRequest('edit');
     $item = Model_Items::get($itemID);
     if (JO_Session::get('user_id') != $item['user_id']) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])));
     }
     $this->getLayout()->meta_title = $item['name'];
     $this->getLayout()->meta_description = substr(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, 'utf-8')), 0, 255);
     $this->view->item_link = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $faqs_data = Model_Faq::getAll($itemID);
     if (JO_Session::get('user_id') == $item['user_id'] || $faqs_data) {
         $this->view->faq_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=faq&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     if (JO_Session::get('user_id') == $item['user_id']) {
         $this->view->edit_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=edit&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
         $this->view->delete_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=delete&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     }
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username')))), array('name' => $item['name'], 'href' => $this->view->item_link), array('name' => $this->translate('Edit')));
     $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
     $categories = Model_Categories::getMain();
     if ($categories) {
         foreach ($categories as $category) {
             $this->view->categories[] = array('id' => $category['id'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=upload&action=get_categories&category_id=' . $category['id']), 'name' => $category['name']);
         }
     }
     $this->view->mainCategories = $categories;
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     } elseif (JO_Session::get('msg_error')) {
         $this->view->error = JO_Session::get('msg_error');
         $data = JO_Session::get('data');
         JO_Session::clear('msg_error');
         JO_Session::clear('data');
     }
     $this->view->sel_category = isset($data) ? $data['category_id'] : reset($item['categories'][0]);
     $allCategories = Model_Categories::getWithChilds();
     $this->view->categoriesSelect = array();
     $categoriesSelect = Model_Categories::generateSelect($allCategories, $this->view->sel_category, $this->view->sel_category);
     if ($categoriesSelect) {
         $categories = explode('|', $categoriesSelect);
         foreach ($categories as $category) {
             if (!empty($category)) {
                 $c = explode('>', $category);
                 $this->view->categoriesSelect[] = array('id' => $c[0], 'name' => $c[1]);
             }
         }
     }
     $this->view->attributes = Model_Attributes::getAllWithCategories("attributes_categories.categories LIKE '%," . (int) $this->view->sel_category . ",%'");
     $this->view->total_sales_cnt = JO_Session::get('sales');
     $this->view->total_balance = WM_Currency::format(JO_Session::get('total'));
     $user = array('user_id' => JO_Session::get('user_id'), 'sold' => JO_Session::get('sold'));
     $this->view->percent = Model_Percentes::getPercentRow($user);
     if (isset($data)) {
         $item['name'] = $data['name'];
         $item['description'] = $data['description'];
         $item['theme_preview'] = $data['theme_preview'];
         $item['theme_preview_zip'] = $data['theme_preview_zip'];
         $item['main_file'] = $data['main_file'];
         $item['reviewer_comment'] = $data['reviewer_comment'];
         $item['attributes'] = $data['attributes'];
         isset($data['source_license']) && ($item['source_license'] = $data['source_license']);
         isset($data['free_request']) && ($item['free_file'] = true);
     }
     $item['suggested_price'] = isset($data['suggested_price']) ? $data['suggested_price'] : $item['price'];
     $item['selected_categories'] = isset($data['category']) ? $data['category'] : JO_Array::multi_array_to_single_uniq($item['categories']);
     $item['selected_attributes'] = isset($data['attributes']) ? JO_Array::multi_array_to_single_uniq($data['attributes']) : JO_Array::multi_array_to_single_uniq($item['attributes']);
     $item['selected_tags'] = isset($data['tags']) ? $data['tags'] : implode(', ', JO_Array::multi_array_to_single_uniq($item['tags']));
     $help = Model_Pages::get(JO_Registry::forceGet('page_upload_item'));
     if ($help) {
         $this->view->page_upload_item = array('name' => $help['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id']));
     }
     $this->view->uploaded_files = JO_Session::get('uploaded_files');
     $this->view->uploaded_arhives = JO_Session::get('uploaded_arhives');
     $this->view->file_upload = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=upload&action=doupload');
     $this->view->action_upload = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=doedit');
     $this->view->d = $item;
     $this->view->autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=items&action=auto');
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
示例#21
0
 public function balanceAction()
 {
     $this->view->page_num = $this->getRequest()->getQuery('page');
     $this->view->user_id = $balance_id = $this->getRequest()->getQuery('id');
     $request = $this->getRequest();
     $url = '';
     if ($request->getQuery('sort')) {
         $url .= '&sort=' . $request->getQuery('sort');
     }
     if ($request->getQuery('order')) {
         $url .= '&order=' . $request->getQuery('order');
     }
     if ($request->getQuery('page')) {
         $url .= '&page=' . $request->getQuery('page');
     }
     if ($request->getQuery('filter_id')) {
         $url .= '&filter_id=' . $request->getQuery('filter_id');
     }
     if ($request->getQuery('filter_username')) {
         $url .= '&filter_username='******'filter_username');
     }
     if ($request->getQuery('filter_total')) {
         $url .= '&filter_total=' . $request->getQuery('filter_total');
     }
     if ($request->getQuery('filter_sales')) {
         $url .= '&filter_sales=' . $request->getQuery('filter_sales');
     }
     if ($request->getQuery('filter_sold')) {
         $url .= '&filter_sold=' . $request->getQuery('filter_sold');
     }
     if ($request->getQuery('filter_web_profit2')) {
         $url .= '&filter_web_profit2=' . $request->getQuery('filter_web_profit2');
     }
     if ($request->getQuery('filter_commission')) {
         $url .= '&filter_commission=' . $request->getQuery('filter_commission');
     }
     if ($request->getQuery('filter_items')) {
         $url .= '&filter_items=' . $request->getQuery('filter_items');
     }
     if ($request->getQuery('filter_referals')) {
         $url .= '&filter_referals=' . $request->getQuery('filter_referals');
     }
     if ($request->getQuery('filter_referal_money')) {
         $url .= '&filter_referal_money=' . $request->getQuery('filter_referal_money');
     }
     if ($request->getQuery('filter_featured_author')) {
         $url .= '&filter_featured_author=' . $request->getQuery('filter_featured_author');
     }
     if ($request->getQuery('id')) {
         $url .= '&id=' . $request->getQuery('id');
     }
     $user_info = Model_Users::getUser($balance_id);
     if (!$user_info) {
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/users/?' . $url);
     }
     $this->view->createBalans = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/users/createBalance/?' . $url;
     $this->view->back_href = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/users/?' . $url;
     $this->view->username = $user_info['username'];
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $this->view->balances = array();
     $balances = Model_Users::getBalances($balance_id);
     if ($balances) {
         foreach ($balances as $balance) {
             $last_login_datetime = new JO_Date($balance['datetime'], 'dd MM yy');
             $balance['datetime'] = $last_login_datetime->toString();
             $balance['deposit'] = WM_Currency::format($balance['deposit']);
             $balance['edit'] = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/users/editBalance/?bid=' . $balance['id'] . $url;
             $this->view->balances[] = $balance;
         }
     }
 }
示例#22
0
 public function indexAction()
 {
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $request = $this->getRequest();
     $this->view->page_num = $page = $request->getRequest('page', 1);
     $this->view->sort = $request->getRequest('sort', 'DESC');
     $this->view->order = $request->getRequest('order', 'i.id');
     $this->view->filter_id = $request->getQuery('filter_id');
     $this->view->filter_name = $request->getQuery('filter_name');
     $this->view->filter_username = $request->getQuery('filter_username');
     $this->view->filter_price = $request->getQuery('filter_price');
     $this->view->filter_sales = $request->getQuery('filter_sales');
     $this->view->filter_profit = $request->getQuery('filter_profit');
     $this->view->filter_free_request = $request->getQuery('filter_free_request');
     $this->view->filter_free_file = $request->getQuery('filter_free_file');
     $this->view->filter_weekly = $request->getQuery('filter_weekly');
     $this->view->filter_user_id = $request->getQuery('filter_user_id');
     $this->view->filter_web_profit = $request->getQuery('filter_web_profit');
     $this->view->filter_refferals = $request->getQuery('filter_refferals');
     $url = '';
     if ($this->view->filter_id) {
         $url .= '&filter_id=' . $this->view->filter_id;
     }
     if ($this->view->filter_name) {
         $url .= '&filter_name=' . $this->view->filter_name;
     }
     if ($this->view->filter_username) {
         $url .= '&filter_username='******'&filter_user_id=' . $this->view->filter_user_id;
     }
     if ($this->view->filter_price) {
         $url .= '&filter_price=' . $this->view->filter_price;
     }
     if ($this->view->filter_sales) {
         $url .= '&filter_sales=' . $this->view->filter_sales;
     }
     if ($this->view->filter_profit) {
         $url .= '&filter_profit=' . $this->view->filter_profit;
     }
     if ($this->view->filter_free_request) {
         $url .= '&filter_free_request=' . $this->view->filter_free_request;
     }
     if ($this->view->filter_free_file) {
         $url .= '&filter_free_file=' . $this->view->filter_free_file;
     }
     if ($this->view->filter_weekly) {
         $url .= '&filter_weekly=' . $this->view->filter_weekly;
     }
     $url1 = '';
     if ($this->view->sort) {
         $url1 .= '&sort=' . $this->view->sort;
     }
     if ($this->view->order) {
         $url1 .= '&order=' . $this->view->order;
     }
     $url2 = '&page=' . $page;
     $data = array('start' => $page * JO_Registry::get('admin_limit') - JO_Registry::get('admin_limit'), 'limit' => JO_Registry::get('admin_limit'), 'sort' => $this->view->sort, 'order' => $this->view->order, 'filter_id' => $this->view->filter_id, 'filter_name' => $this->view->filter_name, 'filter_username' => $this->view->filter_username, 'filter_price' => $this->view->filter_price, 'filter_sales' => $this->view->filter_sales, 'filter_profit' => $this->view->filter_profit, 'filter_free_request' => $this->view->filter_free_request, 'filter_free_file' => $this->view->filter_free_file, 'filter_weekly' => $this->view->filter_weekly, 'filter_user_id' => $this->view->filter_user_id, 'filter_web_profit' => $this->view->filter_web_profit, 'filter_refferals' => $this->view->filter_refferals, 'filter_status' => 'active');
     $this->view->items = array();
     $items = Model_Items::getItems($data);
     if ($items) {
         foreach ($items as $item) {
             $this->view->items[] = array('id' => $item['id'], 'user_id' => $item['user_id'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&item_id=' . $item['id']), 'name' => $item['name'], 'username' => $item['username'], 'name' => $item['name'], 'price' => WM_Currency::format($item['price']), 'sales' => $item['sales'], 'receive' => WM_Currency::format($item['sum_receive']), 'profit' => WM_Currency::format($item['earning']), 'web_profit' => WM_Currency::format($item['web_profit']), 'web_profit2' => WM_Currency::format($item['web_profit2']), 'has_referral_sum' => $item['referral_sum'], 'referral_sum' => WM_Currency::format($item['referral_sum']), 'free_request' => $item['free_request'] == 'true', 'free_file' => $item['free_file'] == 'true', 'weekly_from' => $item['weekly_from'] != '0000-00-00' ? JO_Date::getInstance($item['weekly_from'], 'dd.mm.yy', true)->toString() : '', 'weekly_to' => $item['weekly_to'] != '0000-00-00' ? JO_Date::getInstance($item['weekly_to'], 'dd.mm.yy', true)->toString() : '', 'comments' => $item['comments'], 'edit' => $request->getModule() . '/items/edit/?m=' . $item['module'] . '&id=' . $item['id'] . $url . $url1 . $url2, 'comments_href' => $request->getModule() . '/items/comments/?id=' . $item['id'] . $url . $url1 . $url2);
         }
     }
     $this->view->sort = strtolower($this->view->sort);
     $this->view->sort_id = $request->getModule() . '/items/?order=i.id&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_name = $request->getModule() . '/items/?order=i.name&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_username = $request->getModule() . '/items/?order=u.username&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_price = $request->getModule() . '/items/?order=i.price&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_sales = $request->getModule() . '/items/?order=i.sales&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_earning = $request->getModule() . '/items/?order=i.earning&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_free_request = $request->getModule() . '/items/?order=i.free_request&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_free_file = $request->getModule() . '/items/?order=i.free_file&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_web_profit = $request->getModule() . '/items/?order=web_profit2&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_referral_sum = $request->getModule() . '/items/?order=referral_sum&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $total_records = Model_Items::getTotalItems($data);
     $this->view->total_pages = ceil($total_records / JO_Registry::get('admin_limit'));
     $this->view->total_rows = $total_records;
     $pagination = new Model_Pagination();
     $pagination->setLimit(JO_Registry::get('admin_limit'));
     $pagination->setPage($page);
     $pagination->setTotal($total_records);
     $pagination->setUrl($this->getRequest()->getModule() . '/items/?page={page}' . $url . $url1);
     $this->view->pagination = $pagination->render();
 }
示例#23
0
 public function membershipAction()
 {
     $request = $this->getRequest();
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $this->view->page_num = $page = $request->getRequest('page', 1);
     $this->view->sort = strtolower($request->getRequest('sort', 'ASC'));
     $this->view->order = $request->getRequest('order', 'm.datetime');
     $this->view->filter_id = $request->getQuery('filter_id');
     $this->view->filter_username = $request->getQuery('filter_username');
     $this->view->filter_price = $request->getQuery('filter_price');
     $this->view->filter_extended = $request->getQuery('filter_datetime');
     $url = '';
     if ($this->view->filter_id) {
         $url .= '&filter_id=' . $this->view->filter_id;
     }
     if ($this->view->filter_username) {
         $url .= '&filter_username='******'&filter_price=' . $this->view->filter_price;
     }
     $url1 = '';
     if ($this->view->sort) {
         $url1 .= '&sort=' . $this->view->sort;
     }
     if ($this->view->order) {
         $url1 .= '&order=' . $this->view->order;
     }
     $url2 = '&page=' . $page;
     $this->view->sort_id = $request->getModule() . '/orders/membership/?order=m.id&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_username = $request->getModule() . '/orders/membership/?order=u.username&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_price = $request->getModule() . '/orders/membership/?order=m.amount&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $this->view->sort_datetime = $request->getModule() . '/orders/membership/?order=m.datetime&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2;
     $data = array('sort' => $this->view->sort, 'order' => $this->view->order, 'filter_id' => $this->view->filter_id, 'filter_username' => $this->view->filter_username, 'filter_price' => $this->view->filter_price);
     $this->view->items = array();
     $items = Model_Membership::getNoPaid($data);
     if ($items) {
         $total_records = count($items);
         $limit = JO_Registry::get('admin_limit');
         $this->view->total_pages = ceil($total_records / $limit);
         $this->view->total_rows = $total_records;
         $pagination = new Model_Pagination();
         $pagination->setLimit($limit);
         $pagination->setPage($page);
         $pagination->setTotal($total_records);
         $pagination->setUrl($this->getRequest()->getModule() . '/orders/membership/?page={page}' . $url . $url1);
         $this->view->pagination = $pagination->render();
         $start = $page * $limit - $limit;
         if ($start > $total_records) {
             $page = max(ceil($total_records / $limit), 1);
             $start = $page * $limit - $limit;
         } elseif ($start < 0) {
             $start = 0;
         }
         $items = array_slice($items, $start, $limit);
         foreach ($items as $item) {
             $item['amounte'] = WM_Currency::format($item['amount']);
             $this->view->items[] = $item;
         }
     }
     $this->view->order_link = WM_Router::create($request->getBaseUrl() . '?controller=admin/orders&action=index');
     $this->view->deposit_link = WM_Router::create($request->getBaseUrl() . '?controller=admin/orders&action=deposit');
     $this->view->membership_link = WM_Router::create($request->getBaseUrl() . '?controller=admin/orders&action=membership');
 }
示例#24
0
文件: Deposit.php 项目: noikiy/PD
 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']);
     }
 }
示例#25
0
 private function getForm()
 {
     $request = $this->getRequest();
     $url = '';
     if ($request->getQuery('filter_id')) {
         $url .= '&filter_id=' . $request->getQuery('filter_id');
     }
     if ($request->getQuery('filter_name')) {
         $url .= '&filter_name=' . $request->getQuery('filter_name');
     }
     if ($request->getQuery('filter_username')) {
         $url .= '&filter_username='******'filter_username');
     }
     if ($request->getQuery('filter_user_id')) {
         $url .= '&filter_user_id=' . $request->getQuery('filter_user_id');
     }
     if ($request->getQuery('filter_price')) {
         $url .= '&filter_price=' . $request->getQuery('filter_price');
     }
     if ($request->getQuery('filter_sales')) {
         $url .= '&filter_sales=' . $request->getQuery('filter_sales');
     }
     if ($request->getQuery('filter_profit')) {
         $url .= '&filter_profit=' . $request->getQuery('filter_profit');
     }
     if ($request->getQuery('filter_free_request')) {
         $url .= '&filter_free_request=' . $request->getQuery('filter_free_request');
     }
     if ($request->getQuery('filter_free_file')) {
         $url .= '&filter_free_file=' . $request->getQuery('filter_free_file');
     }
     if ($request->getQuery('filter_weekly')) {
         $url .= '&filter_weekly=' . $request->getQuery('filter_weekly');
     }
     if ($request->getQuery('sort')) {
         $url .= '&sort=' . $request->getQuery('sort');
     }
     if ($request->getQuery('order')) {
         $url .= '&order=' . $request->getQuery('order');
     }
     if ($request->getQuery('page')) {
         $url .= '&page=' . $request->getQuery('page');
     }
     $id = $request->getQuery('id');
     $info = Model_Items::getItem($id);
     if (!$info) {
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/items/?' . $url);
     }
     $this->view->cancel = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/items/?' . $url;
     $model_images = new Model_Images();
     $info['thumbnail'] = $model_images->resize($info['thumbnail'], JO_Registry::forceGet($info['module'] . '_items_thumb_width'), JO_Registry::forceGet($info['module'] . '_items_thumb_height'), true);
     if ((int) JO_Registry::get($info['module'] . '_items_preview_width') && (int) JO_Registry::get($info['module'] . '_items_preview_height')) {
         $info['theme_preview_thumbnail'] = $model_images->resize($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_width'), JO_Registry::forceGet($info['module'] . '_items_preview_height'), true);
     } elseif ((int) JO_Registry::get($info['module'] . '_items_preview_width')) {
         $info['theme_preview_thumbnail'] = $model_images->resizeWidth($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_width'));
     } elseif ((int) JO_Registry::get($info['module'] . '_items_preview_height')) {
         $info['theme_preview_thumbnail'] = $model_images->resizeHeight($info['theme_preview_thumbnail'], JO_Registry::forceGet($info['module'] . '_items_preview_height'));
     } else {
         $info['theme_preview_thumbnail'] = false;
     }
     $this->view->info = $info;
     $this->view->price_f = WM_Currency::format($info['suggested_price']);
     $this->view->categories = Model_Categories::getCategoriesFromParentByModule(0, $info['module']);
     $cats_module = Model_Categories::getCategories(array('filter_sub_of' => 0, 'filter_module' => $info['module'], 'filter_concat' => true));
     $where_attr = '';
     if ($cats_module) {
         $tmp = array();
         foreach ($cats_module as $c) {
             $tmp[] = "categories LIKE '%," . $c . ",%'";
         }
         if ($tmp) {
             $where_attr = implode(' OR ', $tmp);
         }
     }
     $this->view->attributes_list = array();
     $attr_cat = Model_Attributes::getAttributes(array(), $where_attr);
     if ($attr_cat) {
         foreach ($attr_cat as $row => $attr) {
             $attr_list = Model_Attributes::getAttributes(array('filter_sub_of' => $attr['id']));
             if ($attr_list) {
                 $this->view->attributes_list[$row] = $attr;
                 $this->view->attributes_list[$row]['items'] = $attr_list;
             }
         }
     }
     //var_dump($this->view->attributes_list);
     if ($request->getPost('name')) {
         $this->view->name = $request->getPost('name');
     } else {
         $this->view->name = $info['name'];
     }
     if ($request->getPost('description')) {
         $this->view->description = $request->getPost('description');
     } else {
         $this->view->description = $info['description'];
     }
     if ($request->getPost('price')) {
         $this->view->price = $request->getPost('price');
     } else {
         $this->view->price = $info['price'];
     }
     if ($request->getPost('category_id')) {
         $this->view->category_id = $request->getPost('category_id');
     } else {
         $this->view->category_id = Model_Items::getItemCategory($id);
     }
     if ($request->getPost('attributes')) {
         $this->view->attributes = $request->getPost('attributes');
     } else {
         $this->view->attributes = Model_Items::getItemAttributes($id);
     }
     if ($request->getPost('tags')) {
         $this->view->tags = $request->getPost('tags');
     } else {
         $this->view->tags = Model_Items::getItemTags($id);
     }
     if ($request->getPost('free_file')) {
         $this->view->free_file = $request->getPost('free_file');
     } else {
         $this->view->free_file = $info['free_file'];
     }
     if ($request->getPost('demo_url')) {
         $this->view->demo_url = $request->getPost('demo_url');
     } else {
         $this->view->demo_url = $info['demo_url'];
     }
     if ($request->getPost('weekly_from')) {
         $this->view->weekly_from = $request->getPost('weekly_from');
     } else {
         if ($info['weekly_from'] != '0000-00-00') {
             $this->view->weekly_from = JO_Date::getInstance($info['weekly_from'], 'dd.mm.yy', true)->toString();
         } else {
             $this->view->weekly_from = '';
         }
     }
     if ($request->getPost('weekly_to')) {
         $this->view->weekly_to = $request->getPost('weekly_to');
     } else {
         if ($info['weekly_to'] != '0000-00-00') {
             $this->view->weekly_to = JO_Date::getInstance($info['weekly_to'], 'dd.mm.yy', true)->toString();
         } else {
             $this->view->weekly_to = '';
         }
     }
 }
示例#26
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $this->view->base_url = $request->getBaseUrl();
     #LINKS FOR HEAD PARTS IN BOX
     $this->view->finance_href = $request->getModule() . '/reports/';
     $this->view->sales_href = $request->getModule() . '/orders/';
     $this->view->users_href = $request->getModule() . '/users/';
     $this->view->approval_href = $request->getModule() . '/queueitems/';
     $this->view->queue_href = $request->getModule() . '/queueupdateditems/';
     $this->view->contacts_href = $request->getModule() . '/contacts/';
     $this->view->gainpayingup_href = $request->getModule() . '/gainpayingup/';
     $this->view->tags_href = $request->getModule() . '/tags/?filter_visible=false';
     #LOAD ORDERS COUNT
     $this->view->total = Model_Orders::getSalesStatus();
     if ($this->view->total) {
         $this->view->total['total_f'] = WM_Currency::format($this->view->total['total']);
     }
     $ref = Model_Orders::getSalesStatus(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ", 'referal');
     $sales = Model_Orders::getSalesStatus(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     if ($sales) {
         if ($ref) {
             $sales['referal'] = $ref['receive'];
         } else {
             $sales['referal'] = 0;
         }
         $sales['win'] = floatval($sales['total']) - floatval($sales['receive']) - floatval($sales['referal']);
         $sales['total_f'] = WM_Currency::format($sales['total']);
         $sales['receive_f'] = WM_Currency::format($sales['receive']);
         $sales['referal_f'] = WM_Currency::format($sales['referal']);
         $sales['win_f'] = WM_Currency::format($sales['win']);
     }
     $this->view->sales = $sales;
     unset($ref);
     $ref = Model_Orders::getSalesStatus("", 'referal');
     $sales = Model_Orders::getSalesStatus("");
     if ($sales) {
         if ($ref) {
             $sales['referal'] = $ref['receive'];
         } else {
             $sales['referal'] = 0;
         }
         $sales['win'] = floatval($sales['total']) - floatval($sales['receive']) - floatval($sales['referal']);
         $sales['total_f'] = WM_Currency::format($sales['total']);
         $sales['receive_f'] = WM_Currency::format($sales['receive']);
         $sales['referal_f'] = WM_Currency::format($sales['referal']);
         $sales['win_f'] = WM_Currency::format($sales['win']);
     }
     $this->view->sales2 = $sales;
     unset($ref);
     #LOAD USERS COUNT
     $this->view->users = array();
     $this->view->users['month'] = Model_Users::getUsersCount(" `register_datetime` > '" . date('Y-m') . "-01 00:00:00' AND `status` = 'activate' ");
     $this->view->users['total'] = Model_Users::getUsersCount(" `status` = 'activate' ");
     $this->view->topAuthors = array();
     $topAuthors = Model_Users::getAll(0, 5, " `status` = 'activate' ", "`sales` DESC");
     if ($topAuthors) {
         $percentsClass = new Model_Percents();
         foreach ($topAuthors as $user) {
             $user['deposit'] = WM_Currency::format($user['deposit']);
             $user['earning'] = WM_Currency::format($user['earning']);
             $user['total'] = WM_Currency::format($user['total']);
             $user['sold'] = WM_Currency::format($user['sold']);
             $user['referal_money'] = WM_Currency::format($user['referal_money']);
             $comision = $percentsClass->getPercentRow($user['user_id']);
             $user['commission'] = round($comision['percent']);
             $user['sum'] = Model_Balance::getTotalUserBalanceByType($user['user_id']);
             $user['web_profit'] = WM_Currency::format($user['web_profit']);
             $user['web_profit2'] = WM_Currency::format($user['web_profit2']);
             $user['has_referral_sum'] = $user['referral_sum'];
             $user['referral_sum'] = WM_Currency::format($user['referral_sum']);
             $user['edit_href'] = $request->getModule() . '/users/edite/?id=' . $user['user_id'];
             $user['balance_href'] = $request->getModule() . '/users/balance/?id=' . $user['user_id'];
             $this->view->topAuthors[] = $user;
         }
     }
     #LOAD WITHDRAW
     $this->view->withdraw = array();
     $this->view->withdraw['no'] = Model_Deposit::getWithdrawCount(" `paid` = 'false' AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     if ($this->view->withdraw['no']) {
         $this->view->withdraw['no']['total_f'] = WM_Currency::format($this->view->withdraw['no']['total']);
     }
     $this->view->withdraw['paid'] = Model_Deposit::getWithdrawCount(" `paid` = 'true' AND `paid_datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     if ($this->view->withdraw['paid']) {
         $this->view->withdraw['paid']['total_f'] = WM_Currency::format($this->view->withdraw['paid']['total']);
     }
     #LOAD THEMES
     $this->view->items = Model_Items::getItems(array('filter_status' => 'queue', 'start' => 0, 'limit' => 5));
     $this->view->updated_items = Model_Items::getItems(array('filter_update' => true, 'start' => 0, 'limit' => 5));
     #LOAD LAST REQUEST
     $this->view->contacts = array();
     $contacts = Model_Contacts::getContacts(array('filter_answer_datetime' => '0000-00-00', 'start' => 0, 'limit' => 5));
     if ($contacts) {
         foreach ($contacts as $contact) {
             $data = new JO_Date($contact['datetime'], 'dd MM yy');
             $contact['datetime'] = $data->toString();
             $contact['has_response'] = $contact['answer_datetime'] != '0000-00-00 00:00:00';
             if ($contact['answer_datetime'] != '0000-00-00 00:00:00') {
                 $data = new JO_Date($contact['answer_datetime'], 'dd MM yy');
                 $contact['answer_datetime'] = $data->toString();
             } else {
                 $contact['answer_datetime'] = '';
             }
             $this->view->contacts[] = $contact;
         }
     }
     #Withdrawals
     $this->view->withdraws = array();
     $withdraws = Model_Users::getWithdraws(array('start' => 0, 'limit' => 5));
     if ($withdraws) {
         foreach ($withdraws as $withdraw) {
             $withdraw['earning'] = WM_Currency::format($withdraw['earning']);
             $date = new JO_Date($withdraw['datetime'], 'dd MM yy');
             $withdraw['datetime'] = $date->toString();
             if ($withdraw['paid'] == 'true') {
                 $date = new JO_Date($withdraw['paid_datetime'], 'dd MM yy');
                 $withdraw['paid_datetime'] = $date->toString();
             } else {
                 $withdraw['paid_datetime'] = '';
             }
             $withdraw['amount'] = WM_Currency::format($withdraw['amount']);
             $this->view->withdraws[] = $withdraw;
         }
     }
     #TAGS NO ACTIVE
     $this->view->tags = Model_Tags::getTags(array('filter_visible' => 'false', 'start' => 0, 'limit' => 20));
     #DRAW GRAPHCS
     $referal_sum = Model_Orders::getSalesStatusByDay(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ", 'referal');
     $sales_sum = Model_Orders::getSalesStatusByDay(" AND `datetime` > '" . date('Y-m') . "-01 00:00:00' ");
     $referal_money = array();
     $sales_money = array();
     $user_money = array();
     $win_money = array();
     $sales_num = array();
     $referal_num = array();
     $days = array();
     //		for($i=1; $i<= date('t'); $i++) {
     //			if(isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)])) {
     //				$referal_money[] = number_format($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], 2, '.', '');
     //			} else {
     //				$referal_money[] = 0;
     //			}
     //			if(isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)])) {
     //				$sales_money[] = number_format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'], 2, '.', '');
     //				$user_money[] = number_format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], 2, '.', '');
     //				if(isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'])) {
     //					$sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = $referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'];
     //				}
     //				if(!isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'])) {
     //					$sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = 0;
     //				}
     //				$sales_num[] = $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['num'];
     //				$win_money[] = number_format( floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal']), 2, '.', '');
     //			} else {
     //				$sales_money[] = 0;
     //				$user_money[] = 0;
     //				$win_money[] = 0;
     //				$sales_num[] = 0;
     //			}
     //			$days[] = $i;
     //		}
     for ($i = 1; $i <= date('t'); $i++) {
         if (isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)])) {
             $referal_money[] = array(WM_Currency::format($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']), (double) WM_Currency::format($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], '', '', false));
         } else {
             $referal_money[] = array(WM_Currency::format(0), 0);
         }
         if (isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['num'])) {
             $referal_num[] = array($i, $referal_sum[date("Y-m-") . sprintf('%02d', $i)]['num']);
         } else {
             $referal_num[] = array($i, 0);
         }
         if (isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)])) {
             $sales_money[] = array(WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total']), (double) WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'], '', '', false));
             $user_money[] = array(WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']), (double) WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'], '', '', false));
             if (isset($referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'])) {
                 $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = $referal_sum[date("Y-m-") . sprintf('%02d', $i)]['receive'];
             }
             if (!isset($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'])) {
                 $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'] = 0;
             }
             $sales_num[] = array($i, $sales_sum[date("Y-m-") . sprintf('%02d', $i)]['num']);
             $win_money[] = array(WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'] - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal'])), (double) WM_Currency::format($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['total'] - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['receive']) - floatval($sales_sum[date("Y-m-") . sprintf('%02d', $i)]['referal']), '', '', false));
         } else {
             $sales_money[] = array(WM_Currency::format(0), 0);
             $user_money[] = array(WM_Currency::format(0), 0);
             $win_money[] = array(WM_Currency::format(0), 0);
             $sales_num[] = array($i, 0);
         }
         $days[] = $i;
     }
     $new_array = array();
     $new_array[] = array('name' => $this->translate('Total'), 'data' => $sales_money);
     $new_array[] = array('name' => $this->translate('User\'s profit'), 'data' => $user_money);
     $new_array[] = array('name' => $this->translate('Net total'), 'data' => $win_money);
     $new_array[] = array('name' => $this->translate('Referent'), 'data' => $referal_money);
     $new_array2 = array();
     $new_array2[] = array('name' => $this->translate('Referent'), 'data' => $referal_num);
     $new_array2[] = array('name' => $this->translate('Sales'), 'data' => $sales_num);
     $this->view->finance_array = JO_Json::encode($new_array);
     $this->view->sales_array = JO_Json::encode($new_array2);
     $this->view->days = JO_Json::encode($days);
     $this->view->currency = WM_Currency::getCurrency();
 }