public function action_edit() { $this->template->scripts['footer'] = array('js/oc-panel/edit_profile.js'); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit profile'))); // $this->template->title = $user->name; //$this->template->meta_description = $user->name;//@todo phpseo $user = Auth::instance()->get_user(); $this->template->bind('content', $content); $this->template->content = View::factory('oc-panel/profile/edit', array('user' => $user, 'custom_fields' => Model_UserField::get_all())); if ($this->request->post()) { $user->name = core::post('name'); $user->description = core::post('description'); $user->email = core::post('email'); $user->subscriber = core::post('subscriber', 0); //$user->seoname = $user->gen_seo_title(core::post('name')); $user->last_modified = Date::unix2mysql(); //modify custom fields foreach ($this->request->post() as $custom_field => $value) { if (strpos($custom_field, 'cf_') !== FALSE) { $user->{$custom_field} = $value; } } try { $user->save(); Alert::set(Alert::SUCCESS, __('You have successfully changed your data')); } catch (Exception $e) { //throw 500 throw HTTP_Exception::factory(500, $e->getMessage()); } $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } }
public function action_new() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('New field'))); $this->template->title = __('New Custom Field for Users'); if ($_POST) { if (count(Model_UserField::get_all(FALSE)) > 65) { Alert::set(Alert::ERROR, __('You have reached the maximum number of custom fields allowed.')); HTTP::redirect(Route::url('oc-panel', array('controller' => 'userfields', 'action' => 'index'))); } $name = URL::title(Core::post('name')); if (strlen($name) >= 60) { $name = Text::limit_chars($name, 60, ''); } $field = new Model_UserField(); try { $options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE, 'show_profile' => Core::post('show_profile') == 'on' ? TRUE : FALSE, 'show_register' => Core::post('show_register') == 'on' ? TRUE : FALSE, 'admin_privilege' => Core::post('admin_privilege') == 'on' ? TRUE : FALSE); if ($field->create($name, Core::post('type'), Core::post('values'), $options)) { Core::delete_cache(); Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name)); } else { Alert::set(Alert::ERROR, sprintf(__('Field %s already exists'), $name)); } } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } HTTP::redirect(Route::url('oc-panel', array('controller' => 'userfields', 'action' => 'index'))); } $this->template->content = View::factory('oc-panel/pages/userfields/new'); }
/** * Automatically executed before the widget action. Can be used to set * class properties, do authorization checks, and execute other custom code. * * @return void */ public function before() { if ($this->custom != FALSE) { $fields = Model_UserField::get_all(); $this->custom_fields = $fields; } }
public function action_edit() { $this->template->scripts['footer'] = array('js/oc-panel/edit_profile.js'); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit profile'))); // $this->template->title = $user->name; //$this->template->meta_description = $user->name;//@todo phpseo $user = Auth::instance()->get_user(); $this->template->bind('content', $content); $this->template->content = View::factory('oc-panel/profile/edit', array('user' => $user, 'custom_fields' => Model_UserField::get_all())); if ($this->request->post()) { //change elastic email status, he was subscribed but not anymore if (Core::config('email.elastic_listname') != '' and $user->subscriber == 1 and core::post('subscriber', 0) == 0) { ElasticEmail::unsubscribe(Core::config('email.elastic_listname'), $user->email); } elseif (Core::config('email.elastic_listname') != '' and $user->subscriber == 0 and core::post('subscriber', 0) == 1) { ElasticEmail::subscribe(Core::config('email.elastic_listname'), $user->email, $user->name); } $user->name = core::post('name'); $user->description = core::post('description'); $user->email = core::post('email'); $user->subscriber = core::post('subscriber', 0); //$user->seoname = $user->gen_seo_title(core::post('name')); $user->last_modified = Date::unix2mysql(); //modify custom fields foreach ($this->request->post() as $custom_field => $value) { if (strpos($custom_field, 'cf_') !== FALSE) { $user->{$custom_field} = $value; } } if (core::post('cf_vatnumber') and core::post('cf_vatcountry')) { if (!euvat::verify_vies(core::post('cf_vatnumber'), core::post('cf_vatcountry'))) { Alert::set(Alert::ERROR, __('Invalid EU Vat Number, please verify number and country match')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } } try { $user->save(); Alert::set(Alert::SUCCESS, __('You have successfully changed your data')); } catch (Exception $e) { //throw 500 throw HTTP_Exception::factory(500, $e->getMessage()); } $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit'))); } }
/** * This function will upgrade DB that didn't existed in versions prior to 2.5.1 */ public function action_251() { //CF users searchable admin privilege option to false if didnt exists $cf_users = Model_UserField::get_all(); foreach ($cf_users as $name => $options) { $modified = FALSE; if (!isset($options['searchable'])) { $options['searchable'] = FALSE; $modified = TRUE; } if (!isset($options['admin_privilege'])) { $options['admin_privilege'] = FALSE; $modified = TRUE; } if ($modified === TRUE) { $field = new Model_UserField(); $field->update($name, $options['values'] ? implode(',', $options['values']) : null, $options); } } //change latitude/longitude data type length try { DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "ads` CHANGE `latitude` `latitude` FLOAT(10, 6) NULL DEFAULT NULL")->execute(); } catch (exception $e) { } try { DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "ads` CHANGE `longitude` `longitude` FLOAT(10, 6) NULL DEFAULT NULL")->execute(); } catch (exception $e) { } try { DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "locations` CHANGE `latitude` `latitude` FLOAT(10, 6) NULL DEFAULT NULL")->execute(); } catch (exception $e) { } try { DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "locations` CHANGE `longitude` `longitude` FLOAT(10, 6) NULL DEFAULT NULL")->execute(); } catch (exception $e) { } // set to NULL latitude and longitude ads with longitude and longitude equal to 0 try { DB::query(Database::UPDATE, "UPDATE " . self::$db_prefix . "ads SET latitude=NULL, longitude=NULL WHERE latitude='0' AND longitude='0'")->execute(); } catch (exception $e) { } //messages status try { DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "messages` ADD `status_to` tinyint(1) NOT NULL DEFAULT '0'")->execute(); } catch (exception $e) { } try { DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "messages` ADD `status_from` tinyint(1) NOT NULL DEFAULT '0'")->execute(); } catch (exception $e) { } //do something with status to migrate to status_from try { DB::query(Database::UPDATE, "UPDATE `" . self::$db_prefix . "messages` SET `status_from`=`status` , `status_to`=`status`")->execute(); } catch (exception $e) { } try { DB::query(Database::UPDATE, "ALTER TABLE `" . self::$db_prefix . "messages` DROP `status`")->execute(); } catch (exception $e) { } //new configs $configs = array(array('config_key' => 'measurement', 'group_name' => 'general', 'config_value' => 'metric'), array('config_key' => 'leave_alert', 'group_name' => 'advertisement', 'config_value' => '1')); Model_Config::config_array($configs); }
/** * * Loads a basic list info * @param string $view template to render */ public function action_export($view = NULL) { if (class_exists('Model_Ad')) { //the name of the file that user will download $file_name = $this->_orm_model . '_export.csv'; //name of the TMP file $output_file = tempnam('/tmp', $file_name); //instance of the crud $users = ORM::Factory($this->_orm_model); //writting $output = fopen($output_file, 'w'); //header of the csv $header = array('id_user', 'name', 'seoname', 'email', 'description', 'num_ads', 'image', 'last_login', 'last_modified', 'created', 'ipaddress', 'status'); foreach (Model_UserField::get_all(FALSE) as $key => $value) { $header[] = $key; } //header of the CSV fputcsv($output, $header); //getting all the users $users = $users->find_all(); //each element foreach ($users as $user) { fputcsv($output, array('id_user' => $user->id_user, 'name' => $user->name, 'seoname' => $user->seoname, 'email' => $user->email, 'description' => $user->description, 'num_ads' => $user->ads->count_all(), 'image' => $user->get_profile_image(), 'last_login' => $user->last_login, 'last_modified' => $user->last_modified, 'created' => $user->created, 'ipaddress' => long2ip($user->last_ip), 'status' => $user->status) + $user->custom_columns(FALSE, FALSE)); } fclose($output); //returns the file to the browser as attachement and deletes the TMP file Response::factory()->send_file($output_file, $file_name, array('delete' => TRUE)); } else { return parent::export(); } }
<div class="control mr-30"> <input type="text" id="search" name="search" class="form-control" value="<?php echo core::request('search'); ?> " placeholder="<?php echo __('Search'); ?> "> </div> </div> <?php if (Theme::get('premium') == 1) { ?> <!-- Fields coming from user custom fields feature --> <?php foreach (Model_UserField::get_all() as $name => $field) { ?> <?php if (isset($field['searchable']) and $field['searchable']) { ?> <div class="form-group"> <?php $cf_name = 'cf_' . $name; ?> <?php if ($field['type'] == 'select' or $field['type'] == 'radio') { $select = array('' => $field['label']); foreach ($field['values'] as $select_name) { $select[$select_name] = $select_name; } } else {
public function action_advanced_search() { if (Theme::get('infinite_scroll')) { $this->template->scripts['footer'][] = '//cdn.jsdelivr.net/jquery.infinitescroll/2.0b2/jquery.infinitescroll.js'; $this->template->scripts['footer'][] = 'js/listing.js'; } if (core::config('general.auto_locate') or core::config('advertisement.map')) { Theme::$scripts['async_defer'][] = '//maps.google.com/maps/api/js?libraries=geometry,places&v=3&key=' . core::config("advertisement.gm_api_key") . '&callback=initLocationsGMap'; } $this->template->scripts['footer'][] = 'js/jquery.toolbar.js'; $this->template->scripts['footer'][] = 'js/sort.js'; //template header $this->template->title = __('Advanced Search'); $this->template->meta_description = __('Search in') . ' ' . core::config('general.site_name'); //breadcrumbs Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default'))); Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title)); $pagination = NULL; $ads = NULL; $res_count = NULL; $user = $this->user ? $this->user : NULL; if ($this->request->query()) { // variables $search_advert = core::get('title'); $search_loc = core::get('location'); // filter by each variable $ads = new Model_Ad(); //if sort by distance if ((core::request('sort', core::config('advertisement.sort_by')) == 'distance' or core::request('userpos') == 1) and Model_User::get_userlatlng()) { $ads->select(array(DB::expr('degrees(acos(sin(radians(' . $_COOKIE['mylat'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $_COOKIE['mylat'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $_COOKIE['mylng'] . ' - `longitude`))))) * 111.321'), 'distance'))->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL); } // early filter $ads = $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql()); } if (core::request('userpos') == 1 and Model_User::get_userlatlng()) { if (is_numeric(Core::cookie('mydistance')) and Core::cookie('mydistance') <= 500) { $location_distance = Core::config('general.measurement') == 'imperial' ? Num::round(Core::cookie('mydistance') * 1.60934) : Core::cookie('mydistance'); } else { $location_distance = Core::config('general.measurement') == 'imperial' ? Num::round(Core::config('advertisement.auto_locate_distance') * 1.60934) : Core::config('advertisement.auto_locate_distance'); } $ads->where(DB::expr('degrees(acos(sin(radians(' . $_COOKIE['mylat'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $_COOKIE['mylat'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $_COOKIE['mylng'] . ' - `longitude`))))) * 111.321'), '<=', $location_distance); } if (!empty($search_advert) or core::get('search') !== NULL and strlen(core::get('search')) >= 3) { // if user is using search from header if (core::get('search')) { $search_advert = core::get('search'); } if (core::config('general.search_by_description') == TRUE) { $ads->where_open()->where('title', 'like', '%' . $search_advert . '%')->or_where('description', 'like', '%' . $search_advert . '%')->where_close(); } else { $ads->where('title', 'like', '%' . $search_advert . '%'); } } //cf filter arrays $cf_fields = array(); $cf_user_fields = array(); foreach ($this->request->query() as $name => $field) { if (isset($field) and $field != NULL) { // get by prefix cf if (strpos($name, 'cf_') !== FALSE and array_key_exists(str_replace('cf_', '', $name), Model_Field::get_all())) { $cf_fields[$name] = $field; //checkbox when selected return string 'on' as a value if ($field == 'on') { $cf_fields[$name] = 1; } elseif (empty($field)) { $cf_fields[$name] = NULL; } } elseif (strpos($name, 'cfuser_') !== FALSE and array_key_exists(str_replace('cfuser_', '', $name), Model_UserField::get_all())) { $name = str_replace('cfuser_', 'cf_', $name); $cf_user_fields[$name] = $field; //checkbox when selected return string 'on' as a value if ($field == 'on') { $cf_user_fields[$name] = 1; } elseif (empty($field)) { $cf_user_fields[$name] = NULL; } } } } $category = NULL; $location = NULL; if (core::config('general.search_multi_catloc') and Theme::$is_mobile === FALSE) { //filter by category if (is_array(core::get('category'))) { $cat_siblings_ids = array(); foreach (core::get('category') as $cat) { if ($cat !== NULL) { $category = new Model_Category(); $category->where('seoname', '=', $cat)->cached()->limit(1)->find(); if ($category->loaded()) { $cat_siblings_ids = array_merge($cat_siblings_ids, $category->get_siblings_ids()); } } } if (count($cat_siblings_ids) > 0) { $ads->where('id_category', 'IN', $cat_siblings_ids); } } //filter by location if (is_array(core::get('location'))) { $loc_siblings_ids = array(); foreach (core::get('location') as $loc) { if ($loc !== NULL) { $location = new Model_location(); $location->where('seoname', '=', $loc)->cached()->limit(1)->find(); if ($location->loaded()) { $loc_siblings_ids = array_merge($loc_siblings_ids, $location->get_siblings_ids()); } } } if (count($loc_siblings_ids) > 0) { $ads->where('id_location', 'IN', $loc_siblings_ids); } } } else { if (core::get('category') !== NULL) { $category = new Model_Category(); $category->where('seoname', is_array(core::get('category')) ? 'in' : '=', core::get('category'))->cached()->limit(1)->find(); if ($category->loaded()) { $ads->where('id_category', 'IN', $category->get_siblings_ids()); } } $location = NULL; //filter by location if (core::get('location') !== NULL) { $location = new Model_location(); $location->where('seoname', is_array(core::get('location')) ? 'in' : '=', core::get('location'))->cached()->limit(1)->find(); if ($location->loaded()) { $ads->where('id_location', 'IN', $location->get_siblings_ids()); } } } //filter by price(s) if (is_numeric($price_min = str_replace(',', '.', core::get('price-min')))) { // handle comma (,) used in some countries for prices $price_min = (double) $price_min; } // round((float)$price_min,2) if (is_numeric($price_max = str_replace(',', '.', core::get('price-max')))) { // handle comma (,) used in some countries for prices $price_max = (double) $price_max; } // round((float)$price_max,2) if (is_numeric($price_min) and is_numeric($price_max)) { // swap 2 values if ($price_min > $price_max) { $aux = $price_min; $price_min = $price_max; $price_max = $aux; unset($aux); } $ads->where('price', 'BETWEEN', array($price_min, $price_max)); } elseif (is_numeric($price_min)) { $ads->where('price', '>=', $price_min); } elseif (is_numeric($price_max)) { $ads->where('price', '<=', $price_max); } //filter by CF ads if (count($cf_fields) > 0) { foreach ($cf_fields as $key => $value) { //filter by range if (array_key_exists(str_replace('cf_', '', $key), Model_Field::get_all()) and Model_Field::get_all()[str_replace('cf_', '', $key)]['type'] == 'range') { $cf_min = isset($value[0]) ? $value[0] : NULL; $cf_max = isset($value[1]) ? $value[1] : NULL; if (is_numeric($cf_min = str_replace(',', '.', $cf_min))) { // handle comma (,) used in some countries $cf_min = (double) $cf_min; } if (is_numeric($cf_max = str_replace(',', '.', $cf_max))) { // handle comma (,) used in some countries $cf_max = (double) $cf_max; } if (is_numeric($cf_min) and is_numeric($cf_max)) { // swap 2 values if ($cf_min > $cf_max) { $aux = $cf_min; $cf_min = $cf_max; $cf_max = $aux; unset($aux); } $ads->where($key, 'BETWEEN', array($cf_min, $cf_max)); } elseif (is_numeric($cf_min)) { // only min cf has been provided $ads->where($key, '>=', $cf_min); } elseif (is_numeric($cf_max)) { // only max cf has been provided $ads->where($key, '<=', $cf_max); } } elseif (is_numeric($value)) { $ads->where($key, '=', $value); } elseif (is_string($value)) { $ads->where($key, 'like', '%' . $value . '%'); } elseif (is_array($value)) { if (!empty($value = array_filter($value))) { $ads->where($key, 'IN', $value); } } } } //filter by user if (count($cf_user_fields) > 0) { $users = new Model_User(); foreach ($cf_user_fields as $key => $value) { if (is_numeric($value)) { $users->where($key, '=', $value); } elseif (is_string($value)) { $users->where($key, 'like', '%' . $value . '%'); } elseif (is_array($value)) { if (!empty($value = array_filter($value))) { $ads->where($key, 'IN', $value); } } } $users = $users->find_all(); if ($users->count() > 0) { $ads->where('id_user', 'in', $users->as_array()); } else { $ads->where('id_user', '=', 0); } } // count them for pagination $res_count = $ads->count_all(); if ($res_count > 0) { // pagination module $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('advertisement.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'category' => $category !== NULL ? $category->seoname : NULL)); Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->offset)); /** * order depending on the sort parameter */ switch (core::request('sort', core::config('advertisement.sort_by'))) { //title z->a case 'title-asc': $ads->order_by('title', 'asc')->order_by('published', 'desc'); break; //title a->z //title a->z case 'title-desc': $ads->order_by('title', 'desc')->order_by('published', 'desc'); break; //cheaper first //cheaper first case 'price-asc': $ads->order_by('price', 'asc')->order_by('published', 'desc'); break; //expensive first //expensive first case 'price-desc': $ads->order_by('price', 'desc')->order_by('published', 'desc'); break; //featured //featured case 'featured': $ads->order_by('featured', 'desc')->order_by('published', 'desc'); break; //rating //rating case 'rating': $ads->order_by('rate', 'desc')->order_by('published', 'desc'); break; //favorited //favorited case 'favorited': $ads->order_by('favorited', 'desc')->order_by('published', 'desc'); break; //distance //distance case 'distance': if (Model_User::get_userlatlng() and core::config('general.auto_locate')) { $ads->order_by('distance', 'asc')->order_by('published', 'asc'); } break; //oldest first //oldest first case 'published-asc': $ads->order_by('published', 'asc'); break; //newest first //newest first case 'published-desc': default: $ads->order_by('published', 'desc'); break; } //we sort all ads with few parameters $ads = $ads->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); } else { $ads = NULL; } } $this->template->bind('content', $content); $this->template->content = View::factory('pages/ad/advanced_search', array('ads' => $ads, 'categories' => Model_Category::get_as_array(), 'order_categories' => Model_Category::get_multidimensional(), 'locations' => Model_Location::get_as_array(), 'order_locations' => Model_Location::get_multidimensional(), 'pagination' => $pagination, 'user' => $user, 'fields' => Model_Field::get_all(), 'total_ads' => $res_count)); }
/** * returns a list with custom field values of this user * @param boolean $show_profile only those fields that needs to be displayed on the user profile show_profile===TRUE * @param boolean $hide_admin hide those fields that are reserved for the admin hide_admin===TRUE * @return array else false */ public function custom_columns($show_profile = FALSE, $hide_admin = TRUE) { if ($this->loaded()) { //custom fields config, label, name and order $cf_config = Model_UserField::get_all($hide_admin === TRUE ? TRUE : FALSE, FALSE); if (!isset($cf_config)) { return array(); } //getting the custom fields this uaser has and his value $active_custom_fields = array(); foreach ($this->_table_columns as $value) { //we want only those that are custom fields if (strpos($value['column_name'], 'cf_') !== FALSE) { $cf_name = str_replace('cf_', '', $value['column_name']); $cf_column_name = $value['column_name']; $cf_value = $this->{$cf_column_name}; if (isset($cf_value) and isset($cf_config->{$cf_name})) { //formating the value depending on the type switch ($cf_config->{$cf_name}->type) { case 'checkbox': $cf_value = $cf_value ? 'checkbox_' . $cf_value : NULL; break; case 'radio': $cf_value = isset($cf_config->{$cf_name}->values[$cf_value - 1]) ? $cf_config->{$cf_name}->values[$cf_value - 1] : NULL; break; case 'date': $cf_value = Date::format($cf_value, core::config('general.date_format')); break; } //should it be added to the profile? if ($show_profile == TRUE and isset($cf_config->{$cf_name}->show_profile)) { //only to the profile if ($cf_config->{$cf_name}->show_profile == TRUE) { $active_custom_fields[$cf_name] = $cf_value; } } else { $active_custom_fields[$cf_name] = $cf_value; } } } } // sorting using json order $user_custom_vals = array(); foreach ($cf_config as $name => $value) { if (isset($active_custom_fields[$name])) { $user_custom_vals[$value->label] = $active_custom_fields[$name]; } } return $user_custom_vals; } return array(); }
public function action_index() { $db_prefix = Database::instance('default')->table_prefix(); //include num of ads so we can filter, sort and display next to each user $query_count = '(SELECT count(id_ad) FROM ' . $db_prefix . 'ads WHERE id_user='******'user.id_user AND status=' . Model_Ad::STATUS_PUBLISHED . ')'; $users = new Model_User(); $users->select(array(DB::expr($query_count), 'ads_count'))->where('status', '=', Model_User::STATUS_ACTIVE); //search filter if (core::request('search') !== NULL and strlen(core::request('search')) >= 3) { $search = core::request('search'); $users->where_open()->where('name', 'like', '%' . $search . '%')->or_where('description', 'like', '%' . $search . '%')->where_close(); } //cf filter foreach (array_merge($_POST, $_GET) as $name => $value) { //value set and is a CF if (isset($value) and $value != NULL and strpos($name, 'cf_') !== FALSE and array_key_exists(str_replace('cf_', '', $name), Model_UserField::get_all())) { //checkbox when selected return string 'on' as a value $value = $value == 'on' ? 1 : $value; if (is_numeric($value)) { $users->where($name, '=', $value); } elseif (is_string($value)) { $users->where($name, 'like', '%' . $value . '%'); } } } $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $users->count_all(), 'items_per_page' => core::config('advertisement.advertisements_per_page'))); /** * order depending on the sort parameter */ switch (core::request('sort')) { //num of ads desc case 'ads-asc': $users->order_by('ads_count', 'asc')->order_by('created', 'desc'); break; //num of ads desc //num of ads desc case 'ads-desc': $users->order_by('ads_count', 'desc')->order_by('created', 'desc'); break; //name z->a //name z->a case 'name-asc': $users->order_by('name', 'asc')->order_by('created', 'desc'); break; //name a->z //name a->z case 'name-desc': $users->order_by('name', 'desc')->order_by('created', 'desc'); break; //rating //rating case 'rating': $users->order_by('rate', 'desc')->order_by('created', 'desc'); break; //oldest first //oldest first case 'created-asc': $users->order_by('created', 'asc'); break; //newest first //newest first case 'created-desc': default: $users->order_by('created', 'desc'); break; } $users = $users->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); //if home page is the users if (($landing = json_decode(core::config('general.landing_page'))) != NULL and $landing->controller == 'user' and $landing->action == 'index' and (isset($pagination) and $pagination->current_page == 1)) { //only show site title $this->template->title = NULL; // if we have site description lets use that ;) if (core::config('general.site_description') != '') { $this->template->meta_description = core::config('general.site_description'); } } else { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default'))); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Users'))); $this->template->title = __('Users search'); } if (Theme::get('infinite_scroll')) { $this->template->scripts['footer'][] = '//cdn.jsdelivr.net/jquery.infinitescroll/2.0b2/jquery.infinitescroll.js'; $this->template->scripts['footer'][] = 'js/users.js'; } $this->template->content = View::factory('pages/user/list', array('users' => $users, 'pagination' => $pagination)); }