public function results() { if (!input::get('search_id')) { $this->index(); return; } // Parameters $params = array('join_columns' => array('`u`.`verified`=1', '`u`.`active`=1', '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')', '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')'), 'join_items' => array()); // Process filters $params = $this->parseCounters($params); // Process query string $qstring = $this->parseQuerystring($params['max']); // Get users $users = array(); if ($params['total']) { $users = $this->users_model->getUsers('in_list', isset($params['values']['type_id']) ? $params['values']['type_id'] : 0, $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']); } // Get fields $fields = $this->fields_model->getFields('users', isset($params['values']['type_id']) ? $params['values']['type_id'] : 0, 'view', 'in_list'); // Set pagination $config = array('base_url' => config::siteURL('users/results?' . $qstring['url']), 'total_items' => $params['total'], 'max_items' => config::item('max_search_results', 'system'), 'items_per_page' => config::item('users_per_page', 'users'), 'current_page' => $qstring['page'], 'uri_segment' => 'page'); $pagination = loader::library('pagination', $config, null); // Assign vars view::assign(array('users' => $users, 'fields' => $fields, 'pagination' => $pagination)); // Set meta tags $this->metatags_model->set('users', 'users_search_results'); // Set title view::setTitle(__('search_results', 'system'), false); // Assign actions view::setAction('users?' . substr($qstring['url'], 0, -1), __('search_modify', 'system'), array('class' => 'icon-text icon-users-search-edit')); // Load view view::load('users/index'); }
public function add() { // Get URI vars $slugID = urldecode(utf8::trim(uri::segment(4))); // Do we have a slug ID? if ($slugID == '') { error::show404(); } // Get user if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) { error::show404(); } // Is this a self request if ($user['user_id'] == session::item('user_id')) { router::redirect($user['slug']); } elseif (!in_array($user['group_id'], session::permission('users_groups_browse', 'users')) || !in_array($user['type_id'], session::permission('users_types_browse', 'users'))) { view::noAccess(); } // Does blocked user exist? if ($blocked = $this->users_blocked_model->getUser($user['user_id'], true)) { view::setError(__('user_duplicate', 'users_blocked')); router::redirect($user['slug']); } // Block user $this->users_blocked_model->addUser($user['user_id']); // Success view::setInfo(__('user_blocked', 'users_blocked')); //router::redirect($user['slug']); router::redirect('users/blocked'); }
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); }
public function savePictureFile($fileID, $adID, $ad, $extra = array()) { // Basic picture data $picture = array('file_id' => $fileID, 'ad_id' => $adID, 'user_id' => session::item('user_id'), 'post_date' => date_helper::now(), 'active' => session::permission('pictures_approve', 'classifieds') ? 1 : 9, 'order_id' => $ad['total_pictures'] + $ad['total_pictures_i'] + 1); // Do we have extras? if ($extra) { // Merge extras $picture = array_merge($picture, $extra); } // Save picture $pictureID = $this->db->insert('classifieds_pictures_data', $picture); // Do we have picture ID? if ($pictureID) { // Update album's counter $column = $picture['active'] == 1 ? 'total_pictures' : 'total_pictures_i'; $this->db->query("UPDATE `:prefix:classifieds_data` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? AND `ad_id`=? LIMIT 1", array(session::item('user_id'), $adID)); // Does album have a cover? if (!$ad['picture_id']) { // Update ad cover $this->classifieds_model->updatePicture($adID, $pictureID); } // Action hook hook::action('classifieds/pictures/insert', $pictureID, $picture); } return $pictureID; }
public static function getTimeline($user = array(), $privacy = 2, $template = 'timeline/helpers/timeline') { loader::model('timeline/timeline'); // Get actions $actions = codebreeder::instance()->timeline_model->getActions($user ? $user['user_id'] : 0, true, 0, config::item('actions_per_page', 'timeline')); $ratings = array(); // Do we have actions and are we logged in? if ($actions && users_helper::isLoggedin()) { foreach ($actions as $action) { if ($action['rating']) { $ratings[$action['relative_resource']][] = $action['item_id']; } else { $ratings['timeline'][] = $action['action_id']; } } // Load votes and like models loader::model('comments/votes'); loader::model('comments/likes'); // Get likes and votes $likes = codebreeder::instance()->likes_model->getMultiLikes($ratings); $votes = codebreeder::instance()->votes_model->getMultiVotes($ratings); $ratings = $likes + $votes; } // Can we post messages? $post = session::permission('messages_post', 'timeline') && codebreeder::instance()->users_model->getPrivacyAccess($user['user_id'], $privacy, false) ? true : false; view::assign(array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), '', $template); // Update comments pagination config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments'); return view::load($template, array(), 1); }
public static function getComments($resource, $userID, $itemID, $total, $privacy = 2, $post = true, $info = true, $static = false) { // Can we post comments? $post = $post && session::permission('comments_view', 'comments') && session::permission('comments_post', 'comments') ? true : false; if ($userID) { $post = $privacy && codebreeder::instance()->users_model->getPrivacyAccess($userID, $privacy, false) ? true : false; } loader::controller('comments'); echo codebreeder::instance()->comments->browse($resource, $itemID, $total, 1, $post, $info, $static); }
public function __construct() { parent::__construct(); if (!config::item('feedback_active', 'feedback')) { error::show404(); } elseif (!session::permission('feedback_access', 'feedback')) { view::noAccess(); } loader::model('feedback/feedback'); }
public function index() { if (session::permission('users_manage', 'users')) { loader::controller('cp/users'); $this->users->browse(); } else { view::noAccess(false); // Load view view::load('cp/home'); } }
public function __construct() { parent::__construct(); // Does user have permission to access this plugin? if (!session::permission('settings_manage', 'users')) { view::noAccess(); } view::setCustomParam('section', 'users'); view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'users', 'items')); view::setTrail('cp/users', __('users', 'system_navigation')); }
public function __construct() { parent::__construct(); // Does user have permission to access this plugin? if (!session::permission('plans_manage', 'billing')) { view::noAccess(); } view::setCustomParam('section', 'billing'); view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'billing', 'items')); loader::model('billing/plans'); view::setTrail('cp/billing/transactions', __('billing', 'system_navigation')); view::setTrail('cp/billing/plans', __('billing_plans', 'system_navigation')); }
public function __construct() { parent::__construct(); // Does user have permission to access this plugin? if (!session::permission('languages_manage', 'system')) { view::noAccess(); } view::setCustomParam('section', 'system'); view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'system', 'items', 'system/languages', 'items')); loader::model('system/languages'); view::setTrail('cp/system/config/system', __('system', 'system_navigation')); view::setTrail('cp/system/languages/', __('system_languages', 'system_navigation')); }
public function __construct() { parent::__construct(); // Does user have permission to access this plugin? if (!session::permission('newsletters_manage', 'newsletters')) { view::noAccess(); } view::setCustomParam('section', 'content'); view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'content', 'items', 'content/newsletters', 'items')); view::setTrail('cp/system/plugins', __('content', 'system_navigation')); view::setTrail('cp/content/newsletters', __('newsletters', 'system_navigation')); loader::model('newsletters/newsletters', array(), 'newsletters_model'); }
public function __construct() { parent::__construct(); // Does user have permission to access this plugin? if (!session::permission('counters_manage', 'utilities')) { view::noAccess(); } view::setCustomParam('section', 'system'); view::setCustomParam('options', config::item('cp_top_nav', 'lists', 'system', 'items', 'system/utilities', 'items')); loader::model('utilities/counters', array(), 'recalculate_model'); view::setTrail('cp/system/config/system', __('system', 'system_navigation')); view::setTrail('cp/utilities/counters', __('utilities_counters', 'system_navigation')); }
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; }
public function submit() { // Does user have permission to submit reports? if (!session::permission('reports_post', 'reports')) { view::setError(__('no_action', 'system')); view::load('system/elements/blank', array('autoclose' => true)); return false; } $resource = uri::segment(3); $itemID = uri::segment(4); if (!$resource || !($resourceID = config::item('resources', 'core', $resource, 'resource_id')) || !config::item('resources', 'core', $resource, 'report')) { view::setError(__('resource_invalid', 'system')); view::load('system/elements/blank', array('autoclose' => true)); return false; } if (!$itemID || !is_numeric($itemID) || $itemID < 0) { view::setError(__('item_invalid', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Does this item exist? if (!($userID = $this->reports_model->getUserID($resource, $itemID))) { view::setError(__('item_invalid', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Did we report this already? if ($this->reports_model->isReported($resourceID, $itemID)) { view::setError(__('report_exists', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Get subjects $subjects = array(); $data = $this->reports_subjects_model->getSubjects(false, true); foreach ($data as $subject) { $subjects[$subject['subject_id']] = $subject['name']; } $subjects = $subjects ? array('' => __('select', 'system')) + $subjects : $subjects; // Assign vars view::assign(array('subjects' => $subjects)); // Process form values if (input::post('do_submit_report')) { $this->_submitReport($resource, $resourceID, $userID, $itemID, $subjects); } // Set title view::setTitle(__('report_submit', 'reports')); // Load view view::load('report/index'); }
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; }
public function __construct() { parent::__construct(); // Does user have permission to access this plugin? if (!session::permission('license_manage', 'system')) { view::noAccess(); } view::setCustomParam('section', 'help'); view::setCustomParam('options', array('help/license' => array('name' => __('help_license', 'system_navigation'), 'uri' => 'help/license', 'keyword' => 'help/license', 'attr' => array('help license'), 'items' => array()))); loader::model('system/license'); view::setTrail('cp/help/license', __('help', 'system_navigation')); view::setTrail('cp/help/license', __('help_license', 'system_navigation')); // Check if demo mode is enabled if (input::demo(1, 'cp/system/config/system')) { return false; } }
public static function showBanner($group, $banner = '') { if (!config::item('plugins', 'core', 'banners') || !session::permission('banners_show', 'banners')) { return ''; } loader::model('banners/banners'); $banner = codebreeder::instance()->banners_model->getBanner($banner, $group); if (!$banner || input::protocol() == 'https' && !$banner['secure_mode']) { return ''; } if ($banner['count_views']) { codebreeder::instance()->banners_model->updateViews($banner['banner_id']); } if ($banner['count_clicks']) { $banner['code'] = '<div style="display:block" onclick="$(\'#banner_id_' . $banner['banner_id'] . '\').attr(\'src\',\'' . html_helper::siteURL('banners/click/' . $banner['banner_id']) . '\');return true;">' . $banner['code'] . '<img src="' . html_helper::baseURL('assets/images/banners/blank.gif') . '" border="0" style="width:0px;height:0px;" alt="" id="banner_id_' . $banner['banner_id'] . '" /></div>'; } return $banner['code']; }
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'); }
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; }
public function savePictureFile($fileID, $albumID, $album, $extra = array()) { // Basic picture data $picture = array('file_id' => $fileID, 'album_id' => $albumID, 'user_id' => session::item('user_id'), 'post_date' => date_helper::now(), 'active' => session::permission('pictures_approve', 'pictures') ? 1 : 9, 'order_id' => $album['total_pictures'] + $album['total_pictures_i'] + 1); // Do we have extras? if ($extra) { // Merge extras $picture = array_merge($picture, $extra); } // Save picture $pictureID = $this->db->insert('pictures_data', $picture); // Do we have picture ID? if ($pictureID) { // Update album's counter $column = $picture['active'] == 1 ? 'total_pictures' : 'total_pictures_i'; $this->db->query("UPDATE `:prefix:pictures_albums_data` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? AND `album_id`=? LIMIT 1", array(session::item('user_id'), $albumID)); $this->db->query("UPDATE `:prefix:users` SET `{$column}`=`{$column}`+1 WHERE `user_id`=? LIMIT 1", array(session::item('user_id'))); // Does album have a cover? if (!$album['picture_id']) { // Update album cover $this->pictures_albums_model->updateCover($albumID, $pictureID); } // Did we have any activity in the past hour? if (session::item('timeline_picture_post', 'config') === false || session::item('timeline_picture_post', 'config')) { if ($action = timeline_helper::get('picture_post', session::item('user_id'), $albumID, 12)) { $counter = isset($action['params']['count']) ? $action['params']['count'] + 1 : 1; // Update activity timeline_helper::update($action['action_id'], 'picture_post', session::item('user_id'), $albumID, $picture['active'], false, array('count' => $counter), $action['attachments'] < 5 ? $fileID : false); } else { // Save activity timeline_helper::save('picture_post', session::item('user_id'), $albumID, $picture['active'], $album['privacy'], array('count' => 1), $fileID); } } // Action hook hook::action('pictures/insert', $pictureID, $picture); } return $pictureID; }
public function postMessage($items, $users) { $stream = array(); loader::model('timeline/messages', array(), 'timeline_messages_model'); $params = array('select_users' => false); // Get messages $columns = array('`m`.`message_id` IN (' . implode(',', array_keys($items)) . ')'); $messages = codebreeder::instance()->timeline_messages_model->getMessages(0, $columns, false, count($items), $params); foreach ($items as $itemID => $data) { if (isset($messages[$itemID]) && isset($users[$messages[$itemID]['user_id']]) && isset($users[$messages[$itemID]['poster_id']])) { foreach ($data as $actionID => $item) { $stream[$itemID][$actionID]['html'] = view::load('timeline/timeline/message', array('user' => $users[$messages[$itemID]['user_id']], 'poster' => $users[$messages[$itemID]['poster_id']], 'message' => $messages[$itemID], 'params' => $item['params']), true); $stream[$itemID][$actionID]['rating']['total_votes'] = $messages[$itemID]['total_votes']; $stream[$itemID][$actionID]['rating']['total_score'] = $messages[$itemID]['total_score']; $stream[$itemID][$actionID]['rating']['total_rating'] = $messages[$itemID]['total_rating']; $stream[$itemID][$actionID]['rating']['total_likes'] = $messages[$itemID]['total_likes']; $stream[$itemID][$actionID]['rating']['type'] = config::item('timeline_rating', 'timeline'); $stream[$itemID][$actionID]['comments']['total_comments'] = $messages[$itemID]['total_comments']; $stream[$itemID][$actionID]['comments']['post'] = session::permission('comments_view', 'comments') && session::permission('comments_post', 'comments') ? true : false; } } } return $stream; }
public function login() { if (users_helper::isLoggedin() && session::permission('site_access_cp', 'system')) { if (uri::segment(4) == 'spy' && uri::segment(5) && is_numeric(uri::segment(5)) && uri::segment(5) > 0) { if (!input::demo(1, 'cp/users') && $this->users_model->login(uri::segment(5), 0, array(), true)) { router::redirect(session::item('slug')); } } router::redirect('cp'); } if (uri::segment(4) == 'license' && !input::demo(0, '', false)) { // Set title view::setTitle(__('license_change', 'system_license')); } else { // Set title view::setTitle(__('login', 'system_navigation')); } // Process form values if (input::post('do_login')) { $this->_doLogin(); } // Load view view::load('cp/users/login'); }
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']; }
public function add() { // Is user loggedin ? if (!users_helper::isLoggedin()) { router::redirect('users/login'); } // Get URI vars $slugID = urldecode(utf8::trim(uri::segment(4))); // Do we have a slug ID? if ($slugID == '') { error::show404(); } // Get user if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) { error::show404(); } elseif ($user['user_id'] == session::item('user_id')) { router::redirect($user['slug']); } // Does user have permission to view this user group/type? if (!in_array($user['group_id'], session::permission('users_groups_browse', 'users')) || !in_array($user['type_id'], session::permission('users_types_browse', 'users'))) { view::noAccess(); } // Did we block this user or did they block us? if (config::item('blacklist_active', 'users') && ($blocked = $this->users_blocked_model->getUser($user['user_id']))) { if ($blocked['user_id'] == session::item('user_id')) { view::setError(__('user_blocked', 'users')); } else { view::setError(__('user_blocked_self', 'users')); } // Load view router::redirect($user['slug']); } // Does friend exist? if ($friend = $this->users_friends_model->getFriend($user['user_id'], false)) { // Is request already approved? if ($friend['active']) { view::setInfo(__('friend_active', 'users_friends')); } elseif ($friend['user_id'] == session::item('user_id')) { view::setError(__('friend_duplicate', 'users_friends')); } else { view::setError(__('friend_duplicate_self', 'users_friends')); } router::redirect($user['slug']); } // Add friend request $this->users_friends_model->addFriend($user['user_id']); // Send friend request email if (!isset($user['config']['notify_friends_request']) || $user['config']['notify_friends_request']) { // Create email replacement tags $tags = array(); foreach (session::section('session') as $key => $value) { $tags['from.' . $key] = $value; } $tags = array_merge($tags, $user); $tags['friends_link'] = config::siteURL('users/friends/confirm/' . session::item('slug_id')); loader::library('email'); $this->email->sendTemplate('users_friend_request', $user['email'], $tags, $user['language_id']); } // Success view::setInfo(__('friend_requested', 'users_friends')); router::redirect($user['slug']); }
protected function parseCounters($params = array(), $type = 'index') { // Assign vars view::assign(array('filters' => array(), 'values' => array())); // Do we have permission to search? if (session::permission('albums_search', 'pictures')) { // Get fields $filters = $this->fields_model->getFields('pictures', 1, 'edit', 'in_search', true); // Set extra fields $filters[] = array('name' => __('search_keyword', 'system'), 'type' => 'text', 'keyword' => 'q'); // Assign vars view::assign(array('filters' => $filters)); // Did user submit the filter form? if (input::post_get('do_search') && session::permission('albums_search', 'pictures')) { $values = array(); $params['total'] = $params['max'] = 0; // Check extra keyword $keyword = utf8::trim(input::post_get('q')); if ($keyword) { $params['join_columns'][] = $this->search_model->prepareValue($keyword, 'a', array('data_title', 'data_description')); $values['q'] = $keyword; } // Search albums $searchID = $this->search_model->searchData('picture_album', $filters, $params['join_columns'], $values); // Do we have any search terms? if ($searchID == 'no_terms') { view::setError(__('search_no_terms', 'system')); } elseif ($searchID == 'no_results') { view::setError(__('search_no_results', 'system')); return $params; } else { switch ($type) { case 'user': router::redirect('pictures/user/' . uri::segment(4) . '?search_id=' . $searchID); break; case 'manage': router::redirect('pictures/manage?search_id=' . $searchID); break; default: router::redirect('pictures?search_id=' . $searchID); break; } } } // Do we have a search ID? if (!input::post_get('do_search') && input::get('search_id')) { // Get search if (!($search = $this->search_model->getSearch(input::get('search_id')))) { view::setError(__('search_expired', 'system')); switch ($type) { case 'user': router::redirect('pictures/user/' . uri::segment(4)); break; case 'manage': router::redirect('pictures/manage'); break; default: router::redirect('pictures'); break; } } // Set results $params['join_columns'] = $search['conditions']['columns']; $params['join_items'] = $search['conditions']['items']; $params['values'] = $search['values']; $params['total'] = $search['results']; $params['max'] = config::item('max_search_results', 'system') && config::item('max_search_results', 'system') < $params['total'] ? config::item('max_search_results', 'system') : $params['total']; // Assign vars view::assign(array('values' => $search['values'])); } } if (!input::get('search_id')) { // Count albums if ($type == 'manage' && !$params['total'] || $type != 'manage' && !($params['total'] = $this->counters_model->countData('picture_album', 0, 0, $params['join_columns'], $params['join_items'], $params))) { if ($type == 'manage') { view::setInfo(__('no_albums_self', 'pictures')); } else { view::setInfo(__('no_albums', 'pictures')); } } $params['max'] = $params['total']; } return $params; }
public function index() { // Get URI vars if (!($location = uri::getURI())) { $this->home(); return; } elseif ($location == 'site/offline') { $this->offline(); return; } // Get page if (!($page = $this->pages_model->getPage($location, 'in_view', array('replace' => true))) || !session::permission('site_access_cp', 'system') && !$page['active']) { error::show404(); } // Set page ID $pageID = $page['page_id']; // Do we have views enabled? if (config::item('page_views', 'pages')) { // Update views counter $this->pages_model->updateViews($pageID); } // Load ratings if (config::item('page_rating', 'pages') == 'stars') { // Load votes model loader::model('comments/votes'); // Get votes $page['user_vote'] = $this->votes_model->getVote('page', $pageID); } elseif (config::item('page_rating', 'pages') == 'likes') { // Load likes model loader::model('comments/likes'); // Get likes $page['user_vote'] = $this->likes_model->getLike('page', $pageID); } // Assign vars view::assign(array('pageID' => $pageID, 'page' => $page)); // Set title view::setTitle($page['data_title']); // Set meta tags view::setMetaDescription($page['data_meta_description']); view::setMetaKeywords($page['data_meta_keywords']); // Do we need to build a trail? if ($page['trail']) { if ($page['parent_id']) { $parents = $this->pages_model->getParents($page['parent_id']); foreach ($parents as $parent) { view::setTrail($parent['location'], $parent['data_title']); } if ($parents) { // Set trail view::setTrail($location, $page['data_title']); } } else { // Set trail view::setTrail($page['location'], $page['data_title']); } } // Do we have a custom file name? if ($page['file_name']) { // Load custom view view::load($page['file_name']); } else { // Load default view view::load('pages/view'); } }
public static function getUsers($params = array()) { if (!session::permission('users_groups_browse', 'users') && !session::permission('users_types_browse', 'users')) { return ''; } $template = isset($params['template']) ? $params['template'] : 'users/helpers/users'; $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'] : '`u`.`join_date` DESC'; $users = codebreeder::instance()->users_model->getUsers('in_list', 0, $params['join_columns'], array(), $params['order'], $params['limit'], $params); view::assign(array('users' => $users, 'params' => $params), '', $template); return view::load($template, array(), 1); }
<?php echo html_helper::anchor($list['uri'], $list['name'], $list['attr']); ?> <?php echo session::item('total_visitors_new') ? html_helper::anchor('users/visitors/manage', '+' . session::item('total_visitors_new'), array('class' => 'badge small info')) : ''; ?> </li> <?php } ?> <?php break; case 'users/cp': ?> <?php if (session::permission('site_access_cp', 'system')) { ?> <li><?php echo html_helper::anchor($list['uri'], $list['name'], $list['attr']); ?> </li> <?php } ?> <?php break; case 'messages/manage': ?> <?php if (config::item('messages_active', 'messages')) { ?>
?> <?php echo html_helper::anchor('classifieds/pictures/rotate/' . $picture['ad_id'] . '/' . $picture['picture_id'] . '/left', __('picture_rotate_left', 'system_files'), array('class' => 'rotate left')); ?> <?php echo html_helper::anchor('classifieds/pictures/rotate/' . $picture['ad_id'] . '/' . $picture['picture_id'] . '/right', __('picture_rotate_right', 'system_files'), array('class' => 'rotate right')); ?> <?php echo html_helper::anchor('classifieds/pictures/delete/' . $picture['ad_id'] . '/' . $picture['picture_id'], __('picture_delete', 'classifieds'), array('class' => 'delete', 'data-html' => __('picture_delete?', 'classifieds'), 'data-role' => 'confirm')); ?> </li> <?php } ?> <?php if (config::item('reports_active', 'reports') && users_helper::isLoggedin() && $picture['user_id'] != session::item('user_id') && session::permission('reports_post', 'reports')) { ?> <li class="report"> <?php echo html_helper::anchor('report/submit/classified_picture/' . $pictureID, __('report', 'system'), array('data-role' => 'modal', 'data-display' => 'iframe', 'data-title' => __('report', 'system'))); ?> </li> <?php } ?> </ul> </footer> </article>