예제 #1
0
파일: date.php 프로젝트: soremi/tutornavi
 public static function formatDate($time = '', $format = 'stamp', $usa = true, $offset = 0, $dst = null)
 {
     $usa = config::item('time_euro', 'system') ? false : true;
     $offset = session::item('time_zone') * 60 * 60;
     $dst = date('i') ? 3600 : 0;
     return parent::formatDate($time, $format, $usa, $offset, $dst);
 }
예제 #2
0
 public function confirm($action = '')
 {
     // Do we have necessary data?
     if (input::get('oauth_token') && input::get('oauth_verifier')) {
         // Get temporary access token
         $this->initialize(session::item('twitter', 'remote_connect', 'token'), session::item('twitter', 'remote_connect', 'secret'));
         $access = $this->twitter->getAccessToken(input::get('oauth_verifier'));
         // Do we have temporary token?
         if ($access) {
             // Get saved token
             $token = $this->getToken(0, $access['user_id']);
             // Do we have saved token or are we logging in?
             if ($token || $action == 'login' && $token) {
                 $this->users_model->login($token['user_id']);
                 router::redirect(session::item('slug') . '#home');
             } elseif (!$token || $action == 'signup') {
                 // Get user data
                 $this->initialize($access['oauth_token'], $access['oauth_token_secret']);
                 $user = $this->getUser($access['user_id']);
                 // Do we have user data?
                 if ($user && isset($user->id)) {
                     $connection = array('name' => 'twitter', 'twitter_id' => $user->id, 'token' => $access['oauth_token'], 'secret' => $access['oauth_token_secret']);
                     session::set(array('connection' => $connection), '', 'remote_connect');
                     $account = array('username' => isset($user->name) ? $user->name : '');
                     session::set(array('account' => $account), '', 'signup');
                     router::redirect('users/signup#account');
                 }
             }
         }
     }
     router::redirect('users/login');
 }
예제 #3
0
 public static function getPictures($params = array())
 {
     if (!session::permission('users_groups_browse', 'users') && !session::permission('users_types_browse', 'users')) {
         return '';
     }
     loader::model('pictures/pictures');
     $template = isset($params['template']) ? $params['template'] : 'pictures/helpers/pictures';
     $user = isset($params['user']) && $params['user'] ? $params['user'] : array();
     $userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0);
     $params['albums'] = true;
     if ($userID) {
         $params['join_columns'][] = '`p`.`user_id`=' . $userID;
     }
     if (!$userID || $userID != session::item('user_id')) {
         if ($userID) {
             $params['privacy'] = $userID;
         } else {
             $params['join_columns'][] = '`a`.`public`=1';
             $params['join_columns'][] = '`u`.`verified`=1';
             $params['join_columns'][] = '`u`.`active`=1';
             $params['join_columns'][] = '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')';
             $params['join_columns'][] = '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')';
         }
     }
     $params['limit'] = isset($params['limit']) ? $params['limit'] : 10;
     $params['order'] = isset($params['order']) ? $params['order'] : '';
     $pictures = codebreeder::instance()->pictures_model->getPictures('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params);
     view::assign(array('pictures' => $pictures, 'user' => $user, 'params' => $params), '', $template);
     return view::load($template, array(), 1);
 }
예제 #4
0
 public function set($plugin, $keyword, $replace = array(), $pageTitle = true)
 {
     if (!($data = $this->cache->item('core_meta_tags_' . $plugin . '_' . session::item('language')))) {
         $data = array();
         $result = $this->db->query("SELECT * FROM `:prefix:core_meta_tags` WHERE `plugin`=?", array($plugin))->result();
         foreach ($result as $tags) {
             $data[$tags['keyword']]['title'] = $tags['meta_title_' . session::item('language')];
             $data[$tags['keyword']]['description'] = $tags['meta_description_' . session::item('language')];
             $data[$tags['keyword']]['keywords'] = $tags['meta_keywords_' . session::item('language')];
         }
         $this->cache->set('core_meta_tags_' . $plugin . '_' . session::item('language'), $data, 60 * 60 * 24 * 30);
     }
     foreach ($replace as $section => $array) {
         foreach ($array as $k => $v) {
             $k = '[' . $section . '.' . $k . ']';
             if (is_array($v)) {
                 $v = count($v) == 1 ? current($v) : implode(',', $v);
             }
             $data[$keyword]['title'] = utf8::str_replace($k, $v, $data[$keyword]['title']);
             $data[$keyword]['description'] = utf8::str_replace($k, $v, $data[$keyword]['description']);
             $data[$keyword]['keywords'] = utf8::str_replace($k, $v, $data[$keyword]['keywords']);
         }
     }
     if (isset($data[$keyword])) {
         if ($pageTitle) {
             view::setTitle($data[$keyword]['title']);
         } else {
             view::setMetaTitle($data[$keyword]['title']);
         }
         view::setMetaDescription($data[$keyword]['description']);
         view::setMetaKeywords($data[$keyword]['keywords']);
     }
 }
예제 #5
0
 public function invoices()
 {
     // Get page
     $page = is_numeric(input::get('page')) && input::get('page') > 0 ? input::get('page') : 1;
     // Parameters
     $params = array('join_columns' => array('`t`.`user_id`=' . session::item('user_id')));
     // Process query string
     $qstring = $this->parseQuerystring(config::item('invoices_per_page', 'billing'), session::item('total_transactions'));
     // Get invoices
     $invoices = array();
     if (session::item('total_transactions')) {
         $invoices = $this->transactions_model->getTransactions($params['join_columns'], '', $qstring['limit']);
     } else {
         view::setInfo(__('no_invoices_user', 'billing_transactions'));
     }
     // Set pagination
     $config = array('base_url' => config::siteURL('billing/invoices?'), 'total_items' => session::item('total_transactions'), 'items_per_page' => config::item('invoices_per_page', 'billing'), 'current_page' => $page, 'uri_segment' => 'page');
     $pagination = loader::library('pagination', $config, null);
     // Assign vars
     view::assign(array('invoices' => $invoices, 'pagination' => $pagination));
     // Set title
     view::setTitle(__('invoices', 'billing_transactions'));
     // Load view
     view::load('billing/invoices');
 }
예제 #6
0
파일: login.php 프로젝트: soremi/tutornavi
 protected function _authUser()
 {
     // Create rules
     $rules = array('email' => array('label' => __('email', 'users'), 'rules' => array('trim', 'required', 'max_length' => 255, 'callback__is_valid_login')), 'password' => array('label' => __('password', 'users'), 'rules' => array('trim', 'required', 'min_length' => 4, 'max_length' => 128)), 'remember' => array('label' => __('remember_me', 'users'), 'rules' => 'intval'));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get user
     if (!($user = $this->users_model->getUser(input::post('email'), false, false))) {
         validate::setFieldError('email', __((strpos(input::post('email'), '@') === false ? 'username' : 'email') . '_invalid', 'users_signup'));
         return false;
     }
     // Verify password
     if (!$this->users_model->verifyPassword(input::post('password'), $user['password'], $user['user_id'])) {
         validate::setFieldError('password', __('password_invalid', 'users_signup'));
         return false;
     }
     // Is email verified?
     if (!$user['verified']) {
         view::setError(__('user_not_verified', 'users_signup'));
         return false;
     }
     // Is account active?
     if (!$user['active'] || $user['group_id'] == config::item('group_cancelled_id', 'users')) {
         view::setError(__('user_not_active', 'users_signup'));
         return false;
     }
     // Log the user in
     $this->users_model->login($user['user_id'], input::post('remember'), $user);
     router::redirect(config::item('login_redirect', 'users') == 'profile' ? session::item('slug') : config::item('login_redirect', 'users'));
 }
예제 #7
0
파일: users.php 프로젝트: soremi/tutornavi
 public static function getBlockedUser($userID, $self = false)
 {
     if (!users_helper::isLoggedin()) {
         return false;
     } elseif ($userID == session::item('user_id')) {
         return false;
     }
     return codebreeder::instance()->users_blocked_model->getUser($userID, $self);
 }
예제 #8
0
파일: types.php 프로젝트: soremi/tutornavi
 public function getTypes($escape = true)
 {
     // Get user types
     $types = $this->db->query("SELECT * FROM `:prefix:users_types` ORDER BY order_id ASC")->result();
     foreach ($types as $index => $type) {
         $types[$index]['name'] = $escape ? text_helper::entities($type['name_' . session::item('language')]) : $type['name_' . session::item('language')];
     }
     return $types;
 }
예제 #9
0
 public function __construct()
 {
     parent::__construct();
     // Is user logged in?
     if (users_helper::isLoggedin() && strtolower(uri::segment(3)) != 'out') {
         router::redirect(session::item('slug'));
     }
     loader::model('users/authentication', array(), 'users_authentication_model');
 }
예제 #10
0
파일: plans.php 프로젝트: soremi/tutornavi
 public function getPlans($active = true, $escape = true)
 {
     // Get plans
     $plans = $this->db->query("SELECT * FROM `:prefix:billing_plans` " . ($active ? "WHERE `active`=1" : "") . " ORDER BY `order_id` ASC")->result();
     foreach ($plans as $index => $plan) {
         $plans[$index]['name'] = $escape ? text_helper::entities($plan['name_' . session::item('language')]) : $plan['name_' . session::item('language')];
         $plans[$index]['description'] = $escape ? text_helper::entities($plan['description_' . session::item('language')]) : $plan['description_' . session::item('language')];
     }
     return $plans;
 }
예제 #11
0
 public function getFriend($userID, $active = true)
 {
     if (($user = config::item('u' . $userID, '_users_cache_friends')) === false) {
         $user = $this->db->query("SELECT `user_id`, `friend_id`, `post_date`, `active`\n\t\t\t\tFROM `:prefix:users_friends`\n\t\t\t\tWHERE (`user_id`=? AND `friend_id`=? OR `user_id`=? AND `friend_id`=?) LIMIT 1", array(session::item('user_id'), $userID, $userID, session::item('user_id')))->row();
         config::set(array('u' . $userID => $user), '', '_users_cache_friends');
     }
     if ($active && (!isset($user['active']) || !$user['active'])) {
         return array();
     }
     return $user;
 }
예제 #12
0
 public function usersSettingsPrivacyOptions($settings, $user = array())
 {
     if (config::item('timeline_active', 'timeline') && isset($settings['privacy_timeline'])) {
         $settings['privacy_timeline']['items']['timeline_classified_post'] = __('timeline_classified_post', 'users_privacy');
         $settings['privacy_timeline']['rules']['callback__parse_config_array']['items'][] = 'timeline_classified_post';
         if ($user && (!isset($user['config']['timeline_classified_post']) || $user['config']['timeline_classified_post']) || !$user && (session::item('timeline_classified_post', 'config') === false || session::item('timeline_classified_post', 'config'))) {
             $settings['privacy_timeline']['value']['timeline_classified_post'] = 1;
         }
     }
     return $settings;
 }
예제 #13
0
파일: pages.php 프로젝트: soremi/tutornavi
 public function getPages($parentID, $fields = false, $columns = array(), $items = array(), $order = false, $params = array())
 {
     // Sorting
     if (!$order) {
         $order = '`p`.`data_title_' . session::item('language') . '` ASC';
         $order = '`p`.`order_id` ASC';
     }
     // Get pages
     $pages = $this->fields_model->getRows('page', false, $fields, $columns, $items, $order, 1000, $params);
     return $pages;
 }
예제 #14
0
 public function usersSettingsNotificationsOptions($settings, $user = array())
 {
     if (config::item('messages_active', 'messages')) {
         $settings['general']['items']['notify_messages'] = __('notify_messages', 'users_notifications');
         $settings['general']['rules']['callback__parse_config_array']['items'][] = 'notify_messages';
         if ($user && (!isset($user['config']['notify_messages']) || $user['config']['notify_messages']) || !$user && (session::item('notify_messages', 'config') === false || session::item('notify_messages', 'config'))) {
             $settings['general']['value']['notify_messages'] = 1;
         }
     }
     return $settings;
 }
예제 #15
0
 public function getUser($userID, $self = false)
 {
     if (($user = config::item('u' . $userID, '_users_cache_blacklist')) === false) {
         $user = $this->db->query("SELECT `user_id`, `blocked_id`, `post_date`\n\t\t\t\tFROM `:prefix:users_blocked`\n\t\t\t\tWHERE `user_id`=? AND `blocked_id`=? " . (!$self ? "OR `user_id`=? AND `blocked_id`=?" : "") . " LIMIT 1", array(session::item('user_id'), $userID, $userID, session::item('user_id')))->row();
         if (!$self) {
             config::set(array('u' . $userID => $user), '', '_users_cache_blacklist');
         }
     }
     if ($self && (!isset($user['user_id']) || $user['blocked_id'] != $userID)) {
         return array();
     }
     return $user;
 }
예제 #16
0
파일: users.php 프로젝트: soremi/tutornavi
 public function usersSettingsNotificationsOptions($settings, $user = array())
 {
     if (config::item('friends_active', 'users')) {
         foreach (array('notify_friends_request', 'notify_friends_accept') as $keyword) {
             $settings['general']['items'][$keyword] = __($keyword, 'users_notifications');
             $settings['general']['rules']['callback__parse_config_array']['items'][] = $keyword;
             if ($user && (!isset($user['config'][$keyword]) || $user['config'][$keyword]) || !$user && (session::item($keyword, 'config') === false || session::item($keyword, 'config'))) {
                 $settings['general']['value'][$keyword] = 1;
             }
         }
     }
     return $settings;
 }
예제 #17
0
 public function saveAdData($adID, $userID, $adOld, $fields, $extra = array())
 {
     // Is this a new ad?
     if (!$adID) {
         $extra['post_date'] = date_helper::now();
     }
     // Do we have user ID?
     if ($userID) {
         $extra['active'] = session::permission('ads_approve', 'classifieds') ? 1 : 9;
         $extra['user_id'] = $userID;
     }
     // Save ad
     if (!($newAdID = $this->fields_model->saveValues('classified_ad', $adID, $adOld, $fields, $extra))) {
         return 0;
     }
     // Is this a new ad?
     if (!$adID && $userID) {
         $column = $extra['active'] == 1 ? 'total_classifieds' : 'total_classifieds_i';
         $this->db->query("UPDATE `:prefix:users` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? LIMIT 1", array($userID));
     }
     // Did ad status change?
     if ($adID && $extra['active'] != $adOld['active']) {
         // Did we approve this ad?
         if ($extra['active'] == 1) {
             $this->db->query("UPDATE `:prefix:users` SET `total_classifieds`=`total_classifieds`+1, `total_classifieds_i`=`total_classifieds_i`-1 WHERE `user_id`=? LIMIT 1", array($adOld['user_id']));
         } elseif ($adID && $adOld['active'] == 1) {
             $this->db->query("UPDATE `:prefix:users` SET `total_classifieds`=`total_classifieds`-1, `total_classifieds_i`=`total_classifieds_i`+1 WHERE `user_id`=? LIMIT 1", array($adOld['user_id']));
         }
     }
     if (!$adID) {
         // Deduct credits?
         if (config::item('credits_active', 'billing') && session::permission('ads_credits', 'classifieds')) {
             loader::model('billing/credits');
             $this->credits_model->removeCredits(session::item('user_id'), session::permission('ads_credits', 'classifieds'));
         }
     }
     if ($adID) {
         // Update timeline action
         timeline_helper::update(true, 'classified_ad_post', $adOld['user_id'], $newAdID, $extra['active']);
         // Action hook
         hook::action('classifieds/update', $newAdID, $extra);
     } else {
         // Save timeline action
         if (session::item('timeline_classified_post', 'config') === false || session::item('timeline_classified_post', 'config')) {
             timeline_helper::save('classified_ad_post', $userID, $newAdID, $extra['active']);
         }
         // Action hook
         hook::action('classifieds/insert', $newAdID, $extra);
     }
     return $newAdID;
 }
예제 #18
0
파일: blogs.php 프로젝트: soremi/tutornavi
 public function saveBlogData($blogID, $userID, $blogOld, $fields, $extra = array())
 {
     // Is this a new blog?
     if (!$blogID) {
         $extra['post_date'] = date_helper::now();
     }
     // Do we have user ID?
     if ($userID) {
         $extra['active'] = session::permission('blogs_approve', 'blogs') ? 1 : 9;
         $extra['user_id'] = $userID;
     }
     // Save blog
     if (!($newBlogID = $this->fields_model->saveValues('blog', $blogID, $blogOld, $fields, $extra))) {
         return 0;
     }
     // Is this a new blog?
     if (!$blogID && $userID) {
         $column = $extra['active'] == 1 ? 'total_blogs' : 'total_blogs_i';
         $this->db->query("UPDATE `:prefix:users` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? LIMIT 1", array($userID));
     }
     // Did blog status change?
     if ($blogID && $extra['active'] != $blogOld['active']) {
         // Did we approve this blog?
         if ($extra['active'] == 1) {
             $this->db->query("UPDATE `:prefix:users` SET `total_blogs`=`total_blogs`+1, `total_blogs_i`=`total_blogs_i`-1 WHERE `user_id`=? LIMIT 1", array($blogOld['user_id']));
         } elseif ($blogID && $blogOld['active'] == 1) {
             $this->db->query("UPDATE `:prefix:users` SET `total_blogs`=`total_blogs`-1, `total_blogs_i`=`total_blogs_i`+1 WHERE `user_id`=? LIMIT 1", array($blogOld['user_id']));
         }
     }
     // Did we add a new blog or privacy setting changed?
     if (!$blogID || $extra['privacy'] != $blogOld['privacy']) {
         // Clean up counters
         $this->counters_model->deleteCounters('user', $blogID ? $blogOld['user_id'] : $userID);
     }
     if ($blogID) {
         // Update timeline action
         timeline_helper::update(true, 'blog_post', $blogOld['user_id'], $newBlogID, $extra['active'], $extra['privacy']);
         // Action hook
         hook::action('blogs/update', $newBlogID, $extra);
     } else {
         // Save timeline action
         if (session::item('timeline_blog_post', 'config') === false || session::item('timeline_blog_post', 'config')) {
             timeline_helper::save('blog_post', $userID, $newBlogID, $extra['active'], $extra['privacy']);
         }
         // Action hook
         hook::action('blogs/insert', $newBlogID, $extra);
     }
     return $newBlogID;
 }
예제 #19
0
 public function recent()
 {
     // Load view
     if (input::isAjaxRequest()) {
         // Get notices
         $notices = $this->timeline_notices_model->getNotices(session::item('user_id'), 0, 5);
         $output = view::load('timeline/notices/recent', array('notices' => $notices), true);
         // Dow we have new notifications?
         if (session::item('total_notices_new')) {
             // Reset new notifications counter
             $this->timeline_notices_model->resetCounter();
         }
         view::ajaxResponse($output);
     }
 }
예제 #20
0
 public function getPictureSiblings($userID, $adID, $orderID, $totalPictures)
 {
     $previousPicture = $nextPicture = array();
     // Is this the first picture?
     if ($orderID > 1) {
         // Get previous picture
         $previousPicture = $this->db->query("SELECT `p`.`picture_id`, `p`.`data_description` FROM `:prefix:classifieds_pictures_data` AS `p`\n\t\t\t\tWHERE `p`.`ad_id`=? AND `p`.`order_id`<? " . ($userID != session::item('user_id') ? "AND `p`.`active`=1" : "") . "\n\t\t\t\tORDER BY `order_id` DESC LIMIT 1", array($adID, $orderID))->row();
     }
     // Is this the last picture?
     if ($orderID < $totalPictures) {
         // Get next picture
         $nextPicture = $this->db->query("SELECT `p`.`picture_id`, `p`.`data_description` FROM `:prefix:classifieds_pictures_data` AS `p`\n\t\t\t\tWHERE `p`.`ad_id`=? AND `p`.`order_id`>? " . ($userID != session::item('user_id') ? "AND `p`.`active`=1" : "") . "\n\t\t\t\tORDER BY `order_id` ASC LIMIT 1", array($adID, $orderID))->row();
     }
     return array($previousPicture, $nextPicture);
 }
예제 #21
0
파일: plans.php 프로젝트: soremi/tutornavi
 public function checkout()
 {
     // Get URI vars
     $planID = (int) uri::segment(4);
     $gatewayID = uri::segment(5);
     // Get plan
     if (!$planID || !($plan = $this->plans_model->getPlan($planID, false)) || !$plan['active']) {
         view::setError(__('no_plan', 'billing_plans'));
         router::redirect('billing/plans');
     }
     $retval = $this->process($gatewayID, session::item('user_id'), 'plans', $planID, $plan['name'], $plan['price'], '', 'billing/plans');
     if (!$retval) {
         router::redirect('billing/plans/payment/' . $planID);
     }
 }
예제 #22
0
 public function getSubjects($escape = true, $active = false)
 {
     // Get subjects
     $subjects = $this->db->query("SELECT * FROM `:prefix:reports_subjects` " . ($active ? "WHERE `active`=1" : "") . " ORDER BY `order_id` ASC")->result();
     foreach ($subjects as $index => $subject) {
         if ($escape) {
             foreach (config::item('languages', 'core', 'keywords') as $language) {
                 $subject['name_' . $language] = text_helper::entities($subject['name_' . $language]);
             }
         }
         $subject['name'] = $subject['name_' . session::item('language')];
         $subjects[$index] = $subject;
     }
     return $subjects;
 }
예제 #23
0
 public function checkout()
 {
     // Get URI vars
     $packageID = (int) uri::segment(4);
     $gatewayID = uri::segment(5);
     // Get package
     if (!$packageID || !($package = $this->credits_model->getPackage($packageID)) || !$package['active']) {
         view::setError(__('no_package', 'billing_credits'));
         router::redirect('billing/credits');
     }
     // Set package name
     $name = __('credits_info', 'billing_credits', array('%s' => $package['credits']));
     $retval = $this->process($gatewayID, session::item('user_id'), 'credits', $packageID, $name, $package['price'], '', 'billing/credits');
     if (!$retval) {
         router::redirect('billing/credits/payment/' . $packageID);
     }
 }
예제 #24
0
 public function getTemplates($escape = true, $status = false)
 {
     // Get templates
     $templates = $this->db->query("SELECT * FROM `:prefix:messages_templates` " . ($status ? "WHERE `active`=1" : "") . " ORDER BY `order_id` ASC")->result();
     foreach ($templates as $index => $template) {
         if ($escape) {
             foreach (config::item('languages', 'core', 'keywords') as $language) {
                 $template['name_' . $language] = text_helper::entities($template['name_' . $language]);
                 $template['subject_' . $language] = text_helper::entities($template['subject_' . $language]);
                 $template['message_' . $language] = text_helper::entities($template['message_' . $language]);
             }
         }
         $template['name'] = $template['name_' . session::item('language')];
         $template['subject'] = $template['subject_' . session::item('language')];
         $template['message'] = $template['message_' . session::item('language')];
         $templates[$index] = $template;
     }
     return $templates;
 }
예제 #25
0
 public function manage()
 {
     // Does user have permission to view visitors?
     if (!session::permission('users_visitors_browse', 'users')) {
         view::noAccess();
     }
     // Assign user from session to variable
     $user = session::section('session');
     // Get fields
     $fields = array();
     foreach (config::item('usertypes', 'core', 'keywords') as $categoryID => $keyword) {
         $fields[$categoryID] = $this->fields_model->getFields('users', $categoryID, 'view', 'in_list');
     }
     // Parameters
     $params = array('total' => session::permission('users_visitors_limit', 'users') && session::permission('users_visitors_limit', 'users') < $user['total_visitors'] ? session::permission('users_visitors_limit', 'users') : $user['total_visitors'], 'profiles' => true);
     // Process query string
     $qstring = $this->parseQuerystring($params['total']);
     // Get visitors
     $visitors = array();
     if ($params['total']) {
         $visitors = $this->users_visitors_model->getVisitors(session::item('user_id'), $qstring['order'], $qstring['limit'], $params);
     } else {
         view::setInfo(__('no_visitors', 'users_visitors'));
     }
     // Set pagination
     $config = array('base_url' => config::siteURL('users/visitors/manage?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => config::item('visitors_per_page', 'users'), 'current_page' => $qstring['page'], 'uri_segment' => 'page');
     $pagination = loader::library('pagination', $config, null);
     // Assign vars
     view::assign(array('user' => $user, 'visitors' => $visitors, 'fields' => $fields, 'pagination' => $pagination));
     // Dow we have new visitors?
     if (session::item('total_visitors_new')) {
         // Reset new visitors counter
         $this->users_visitors_model->resetCounter();
     }
     // Set title
     view::setTitle(__('my_visitors', 'system_navigation'));
     // Set trail
     view::setTrail(session::item('slug'), __('my_profile', 'system_navigation'));
     view::setTrail('users/visitors/manage', __('users_visitors', 'system_navigation'));
     // Load view
     view::load('users/visitors/manage');
 }
예제 #26
0
 public function usersSettingsAccountOptions($settings, $user = array())
 {
     if (input::isCP()) {
         if (uri::segment(3) == 'edit') {
             loader::helper('array');
             $expiration = array('name' => __('expire_date', 'users_account'), 'keyword' => 'expire_date', 'type' => 'date', 'value' => $user ? $user['expire_date'] : 0, 'rules' => array('valid_date'), 'select' => true);
             $credits = array('name' => __('credits_current', 'users_account'), 'keyword' => 'total_credits', 'type' => 'number', 'value' => $user ? $user['total_credits'] : 0, 'rules' => array('required' => 1, 'min_value' => 0));
             $settings = array_helper::spliceArray($settings, 'group_id', $credits, 'total_credits');
             $settings = array_helper::spliceArray($settings, 'group_id', $expiration, 'expire_date');
         }
     } else {
         if (config::item('subscriptions_active', 'billing')) {
             $settings['subscription'] = array('name' => __('plan_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => config::item('usergroups', 'core', session::item('group_id')) . (session::item('expire_date') ? ' (' . __('expire_date', 'users_account') . ': ' . date_helper::formatDate(session::item('expire_date'), 'date') . ')' : '') . (session::permission('plans_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/plans', __('plan_change', 'users_account')) : ''));
         }
         if (config::item('credits_active', 'billing')) {
             $settings['credits'] = array('name' => __('credits_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => session::item('total_credits') . (session::permission('credits_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/credits', __('credits_purchase', 'users_account')) : ''));
         }
     }
     return $settings;
 }
예제 #27
0
 public function confirm($action = '')
 {
     $this->initialize();
     // Get facebook user ID
     $facebookID = $this->facebook->getUser();
     // Do we have facebook user ID?
     if ($facebookID) {
         // Get saved token
         $token = $this->getToken(0, $facebookID);
         // Do we have saved token or are we logging in?
         if ($token || $action == 'login' && $token) {
             $this->users_model->login($token['user_id']);
             router::redirect(session::item('slug') . '#home');
         } elseif (!$token || $action == 'signup') {
             // Get user data and token
             $user = $this->getUser();
             $token = $this->facebook->getAccessToken();
             // Do we have user data and token?
             if ($user && $token) {
                 $connection = array('name' => 'facebook', 'facebook_id' => $facebookID, 'token' => $token);
                 session::set(array('connection' => $connection), '', 'remote_connect');
                 if (!session::item('account', 'signup')) {
                     $account = array('email' => isset($user['email']) ? $user['email'] : '', 'username' => isset($user['username']) ? $user['username'] : '');
                     session::set(array('account' => $account), '', 'signup');
                 }
                 if (!session::item('profile', 'signup')) {
                     $profile = array();
                     if (isset($user['gender'])) {
                         $profile['data_gender'] = $user['gender'] == 'male' ? 1 : 0;
                     }
                     if (isset($user['birthday'])) {
                         $profile['data_birthday'] = substr($user['birthday'], -4) . substr($user['birthday'], 0, 2) . substr($user['birthday'], 3, 2);
                     }
                     session::set(array('profile' => $profile), '', 'signup');
                 }
                 router::redirect('users/signup#account');
             }
         }
     }
     router::redirect('users/login');
 }
예제 #28
0
 public static function getAds($params = array())
 {
     loader::model('classifieds/classifieds');
     $template = isset($params['template']) ? $params['template'] : 'classifieds/helpers/classifieds';
     $user = isset($params['user']) && $params['user'] ? $params['user'] : array();
     $userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0);
     if ($userID) {
         $params['join_columns'][] = '`a`.`user_id`=' . $userID;
     }
     if (!$userID || $userID != session::item('user_id')) {
         if ($userID) {
             $params['join_columns'][] = '`a`.`post_date`>' . (date_helper::now() - config::item('ad_expiration', 'classifieds') * 60 * 60 * 24);
         } else {
             $params['join_columns'][] = '`u`.`active`=1';
         }
     }
     $params['limit'] = isset($params['limit']) ? $params['limit'] : 10;
     $params['order'] = isset($params['order']) ? $params['order'] : '';
     $ads = codebreeder::instance()->classifieds_model->getAds('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params);
     view::assign(array('ads' => $ads, 'user' => $user, 'params' => $params), '', $template);
     return view::load($template, array(), 1);
 }
예제 #29
0
파일: users.php 프로젝트: soremi/tutornavi
 public function action($action, $actionID = false)
 {
     // Check if demo mode is enabled
     if (input::demo(1, 'cp/users')) {
         return false;
     }
     // Get URI vars
     $userID = $actionID ? $actionID : (int) uri::segment(4);
     // Get user
     if (!$userID || !($user = $this->users_model->getUser($userID))) {
         view::setError(__('no_user', 'users'));
         router::redirect('cp/users');
     }
     // Make sure we're not trying to decline ourselves
     if ($userID != session::item('user_id')) {
         switch ($action) {
             case 'approve':
             case 'approve_email':
                 if ($this->users_model->toggleUserStatus($userID, $user, 1) && $action == 'approve_email') {
                     loader::library('email');
                     $this->email->sendTemplate('users_account_welcome', $user['email'], $user, $user['language_id']);
                 }
                 $str = __('user_approved', 'users');
                 break;
             case 'decline':
             case 'decline_email':
                 if ($this->users_model->toggleUserStatus($userID, $user, 0) && $action == 'decline_email') {
                     loader::library('email');
                     $this->email->sendTemplate('users_account_declined', $user['email'], $user, $user['language_id']);
                 }
                 $str = __('user_declined', 'users');
                 break;
             case 'verify':
                 $this->users_model->toggleVerifiedStatus($userID, $user, 1);
                 $str = __('user_verified', 'users');
                 break;
             case 'unverify':
                 $this->users_model->toggleVerifiedStatus($userID, $user, 0);
                 $str = __('user_unverified', 'users');
                 break;
             case 'delete':
                 $this->users_model->deleteUser($userID, $user);
                 $str = __('user_deleted', 'users');
                 break;
         }
     } else {
         $str = '';
     }
     // Is this an action call?
     if ($actionID) {
         return;
     }
     // Process query string
     $qstring = $this->parseQuerystring();
     // Success
     view::setInfo($str);
     router::redirect('cp/users?' . $qstring['url'] . 'page=' . $qstring['page']);
 }
예제 #30
0
 public function countRecentComments()
 {
     $time = date_helper::now() - session::permission('comments_delay_time', 'comments') * (session::permission('comments_delay_type', 'comments') == 'minutes' ? 60 : 3600);
     $comments = $this->db->query("SELECT COUNT(*) AS `totalrows`\n\t\t\tFROM `:prefix:core_comments`\n\t\t\tWHERE `poster_id`=? AND `post_date`>?", array(session::item('user_id'), $time))->row();
     return $comments['totalrows'];
 }