public function actionIndex() { $model = new Users('search'); $model->unsetAttributes(); if (isset($_GET['Users'])) { $model->setAttributes($_GET['Users']); } $dataProvider = $model->search(); $this->render('//users/index', array('dataProvider' => $dataProvider, 'model' => $model)); }
public function actionIndex() { $model = new Users("search"); $model->unsetAttributes(); if (isset($_GET['Users'])) { $model->attributes = $_GET['Users']; } $data = $model->search(); $this->render("index", ["dataProvider" => $data, "model" => $model]); }
public function actionIndex() { $dataProvider = new CActiveDataProvider('Users'); $model = new Users('search'); if (!Yii::app()->request->isAjaxRequest && !Yii::app()->request->getParam('ajax')) { $this->render('list', ['dataProvider' => $dataProvider, 'model' => $model]); } else { $model->setAttributes(Yii::app()->request->getParam('Users')); $dataProvider = $model->search(); $this->renderPartial('_list', ['dataProvider' => $dataProvider, 'model' => $model]); } }
switch ($type) { // search in articles default: case 'articles': case 'images': $values['items'] = Articles::search($search, 0, 30, 'feed'); break; // search in files // search in files case 'files': $values['items'] = Files::search($search, 0, 30, 'feed'); break; // search in users // search in users case 'users': $values['items'] = Users::search($search, 1.0, 30, 'feed'); break; } // make a text include_once 'codec.php'; include_once 'rss_codec.php'; $result = rss_Codec::encode($values); $status = @$result[0]; $text = @$result[1]; // handle the output correctly render_raw('text/xml; charset=' . $context['charset']); // actual transmission except on a HEAD request if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') { echo $text; } // the post-processing hook
// search in sections if ($items = Sections::search_in_section($section_id, $boolean_search, $offset, $bucket)) { $result = array_merge($result, $items); } // global search if (!$section_id) { // search in categories if ($items = Categories::search($boolean_search, $offset, $bucket)) { $result = array_merge($result, $items); } // search in files if ($items = Files::search($boolean_search, $offset, $bucket)) { $result = array_merge($result, $items); } // search in users if ($items = Users::search($boolean_search, $offset, $bucket)) { $result = array_merge($result, $items); } } // compare scores of two items function compare_scores($a, $b) { if ($a[0] < $b[0]) { return 1; } if ($a[0] == $b[0]) { return 0; } return -1; } // sort the full array of results
// some input is mandatory if (!isset($_REQUEST['term']) || !$_REQUEST['term']) { Safe::header('Status: 400 Bad Request', TRUE, 400); die(i18n::s('Request is invalid.')); } // just for sanity $_REQUEST['term'] = preg_replace(FORBIDDEN_IN_NAMES, '_', $_REQUEST['term']); // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); die(i18n::s('You are not allowed to perform this operation.')); } // we return some text $output = ''; // look for matching items $items = Users::search($_REQUEST['term'], 1.0, 50, 'complete'); // build an unordered list if (count($items)) { $output .= '['; $i = 0; foreach ($items as $label => $more) { if ($i > 0) { $output .= ','; } $i++; $output .= '{"value":"' . $label . '","label":"' . $more . '"}'; } $output .= ']'; } // allow for data compression render_raw('application/json; charset=' . $context['charset']);
/** * Check whether the username exists. **/ public function actionCheckUsername() { $username = isset($_POST['username']) ? $_POST['username'] : ''; $user = new Users(); $user->username = $username; $provider = $user->search(); $provider->getData(true); $success = $provider->itemCount; echo "{success: {$success}}"; }
} // a search form for users if (!$search) { $search = i18n::s('Look for some user'); } $context['text'] .= '<form method="get" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form">' . '<p>' . '<input type="text" name="search" size="40" value="' . encode_field($search) . '" onfocus="this.value=\'\'" maxlength="128" />' . ' ' . Skin::build_submit_button(i18n::s('Go')) . '</p>' . "</form>\n"; // the script used for form handling at the browser Page::insert_script(' func' . 'tion validateDocumentPost(container) {' . "\n" . ' if(!container.search.value) {' . "\n" . ' alert("' . i18n::s('Please type something to search for.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . ' }' . "\n" . "\n" . '$("#search").focus();' . "\n"); // nothing found yet $no_result = TRUE; // search in users $box = array(); $box['title'] = ''; $box['text'] = ''; $cap = 0; if ($items = Users::search($search, 1.0, USERS_PER_PAGE + 1, 'full')) { // link to next page if greater than USERS_PER_PAGE $cap = count($items); // limit the number of boxes displayed if ($cap > USERS_PER_PAGE) { @array_splice($items, USERS_PER_PAGE); } } // we have found some articles if ($cap || $page > 1) { $no_result = FALSE; } // actually render the html if (@count($box['bar'])) { $box['text'] .= Skin::build_list($box['bar'], 'menu_bar'); }
protected final function process_request() { // Process // if ($this->request_noun === REQUEST_NOUN_USERS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { Users::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'search' && $this->http_method === HTTP_METHOD_GET) { // Search // Users::search($this->inputter, $this->outputter); } else { if ($this->request_verb === 'lookup' && $this->http_method === HTTP_METHOD_GET) { // Lookup // Users::lookup($this->inputter, $this->outputter); } else { $this->invalid_process_verb(); } } } } else { if ($this->request_noun === REQUEST_NOUN_FRIENDS) { if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Friends::_list($this->inputter, $this->outputter); } else { if ($this->request_verb === 'ids' && $this->http_method === HTTP_METHOD_GET) { // User IDs // Friends::ids($this->inputter, $this->outputter); } else { $this->invalid_process_verb(); } } } else { if ($this->request_noun === REQUEST_NOUN_FOLLOWERS) { if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Followers::_list($this->inputter, $this->outputter); } else { if ($this->request_verb === 'ids' && $this->http_method === HTTP_METHOD_GET) { // User IDs // Followers::ids($this->inputter, $this->outputter); } else { $this->invalid_process_verb(); } } } else { if ($this->request_noun === REQUEST_NOUN_IN_PRODUCT_PROMOTIONS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { // In Product Promotion ID // InProductPromotions::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // InProductPromotions::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // InProductPromotions::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // In Product Promotion ID // InProductPromotions::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { $this->invalid_process_verb(); } } } } } else { if ($this->request_noun === REQUEST_NOUN_INVITATIONS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { Invitations::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // Invitations::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // Invitations::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // Invitation ID // Invitations::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'incoming') { // Incoming // if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Invitations::incoming_list($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'outgoing') { // Outgoing // if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Invitations::outgoing_list($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { $this->invalid_process_verb(); } } } } } } } else { if ($this->request_noun === REQUEST_NOUN_EVENT_OCCURRENCES) { // Event Occurrences // if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { EventOccurrences::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // EventOccurrences::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // EventOccurrences::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // Event Occurrence ID // EventOccurrences::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'list') { // List // if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'event' && $this->http_method === HTTP_METHOD_GET) { // Created // EventOccurrences::list_event($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { $this->invalid_process_verb(); } } } } } } else { if ($this->request_noun === REQUEST_NOUN_PHOTOS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { // Photo ID // Photos::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // Photos::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // Photos::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // Photo ID // Photos::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Photos::_list($this->inputter, $this->outputter); } else { $this->invalid_process_verb(); } } } } } } else { if ($this->request_noun === REQUEST_NOUN_ALBUMS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { // Album ID // Albums::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // Albums::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // Albums::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // Album ID // Albums::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Albums::_list($this->inputter, $this->outputter); } else { $this->invalid_process_verb(); } } } } } } else { if ($this->request_noun === REQUEST_NOUN_SEARCH) { if ($this->http_method === HTTP_METHOD_GET) { if ($this->request_verb === 'list') { // Search // Search::search_list($this->inputter, $this->outputter); } } } else { if ($this->request_noun === REQUEST_NOUN_FOLLOWINGS) { if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Followings::_list($this->inputter, $this->outputter); } else { if ($this->request_verb === 'ids' && $this->http_method === HTTP_METHOD_GET) { // User IDs // Followings::ids($this->inputter, $this->outputter); } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // Followings::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy' && $this->http_method === HTTP_METHOD_POST) { // User IDs // Followings::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_verb(); } } } } } else { if ($this->request_noun === REQUEST_NOUN_ACCOUNT) { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { Account::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { Account::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy' && $this->http_method === HTTP_METHOD_DELETE) { // Destroy // if (isset($this->inputter->additional_uri_arguments[0]) && count($this->inputter->additional_uri_arguments) === 1) { Account::destroy($this->inputter, $this->outputter); } else { // Throw error, identification is required // $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, ERROR_CODE_VALIDATION_PROPERTY_NOT_SET, 'A user identification is required.'); $this->outputter->print_error($error); } } else { if ($this->request_verb === 'authenticate' && $this->http_method === HTTP_METHOD_POST) { Account::authenticate($this->inputter, $this->outputter); } else { if ($this->request_verb === 'unauthenticate' && $this->http_method === HTTP_METHOD_POST) { Account::unauthenticate($this->inputter, $this->outputter); } else { $this->invalid_process_verb(); } } } } } } else { if ($this->request_noun === REQUEST_NOUN_EVENTS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_POST) { Events::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // Events::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // Events::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // Event ID // Events::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'attend' && $this->http_method === HTTP_METHOD_POST) { // Attend // Events::attend($this->inputter, $this->outputter); } else { if ($this->request_verb === 'search' && $this->http_method === HTTP_METHOD_GET) { // Search // Events::search($this->inputter, $this->outputter); } else { if ($this->request_verb === 'list') { // List // if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'event_type' && $this->http_method === HTTP_METHOD_GET) { // Event Type // Events::list_event_type($this->inputter, $this->outputter); } else { if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'created' && $this->http_method === HTTP_METHOD_GET) { // Created // Events::list_created($this->inputter, $this->outputter); } else { if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'invited' && $this->http_method === HTTP_METHOD_GET) { // Invited // Events::list_invited($this->inputter, $this->outputter); } else { if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'nearby' && $this->http_method === HTTP_METHOD_GET) { // Nearby // Events::list_nearby($this->inputter, $this->outputter); } else { if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'popular' && $this->http_method === HTTP_METHOD_GET) { // Popular // Events::list_popular($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } } } } } else { $this->invalid_process_verb(); } } } } } } } } else { if ($this->request_noun === REQUEST_NOUN_LOCATIONS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { // Location ID // Locations::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // Locations::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // Locations::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // Location ID // Locations::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { $this->invalid_process_verb(); } } } } } else { if ($this->request_noun === REQUEST_NOUN_TICKETS) { if ($this->request_verb === 'show') { // Show // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) { // Ticket ID // Tickets::show($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) { // Create // Tickets::create($this->inputter, $this->outputter); } else { if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) { // Update // Tickets::update($this->inputter, $this->outputter); } else { if ($this->request_verb === 'destroy') { // Destroy // if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) { // Ticket ID // Tickets::destroy($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { if ($this->request_verb === 'outgoing') { // Outgoing // if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'list' && $this->http_method === HTTP_METHOD_GET) { // List // Tickets::outgoing_list($this->inputter, $this->outputter); } else { $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1); } } else { $this->invalid_process_verb(); } } } } } } else { $this->invalid_process_noun(); } } } } } } } } } } } } } } }
<?php require_once 'config.php'; require 'design_head.php'; echo xhtmlMenu($user_menu, 'blog_menu'); echo '<h2>Search for users</h2>'; echo Users::search(); require 'design_foot.php';
$links = array_merge($links, array($context['url_to_root'] => i18n::s('Front page'))); $links = array_merge($links, array('sections/' => i18n::s('Site map'))); $links = array_merge($links, array('users/' => i18n::s('People'))); $links = array_merge($links, array('categories/' => i18n::s('Categories'))); $links = array_merge($links, array('search.php' => i18n::s('Search'))); $context['components']['boxes'] .= Skin::build_box(i18n::s('Navigate'), Skin::build_list($links, 'compact'), 'boxes'); // failed authentication } else { // set permanent name shown from top level Safe::setcookie('surfer_name', preg_replace('/(@.+)$/', '', $name), time() + 60 * 60 * 24 * 500, '/'); // reset the current session Surfer::reset(); // share status Logger::error(i18n::s('Failed authentication'), FALSE); // help surfer to recover if ($items =& Users::search($name, 1.0, 7, 'password')) { // display candidate profiles if (is_array($items)) { $items =& Skin::build_list($items, 'decorated'); } $context['text'] .= Skin::build_box(i18n::s('Have you lost your password?'), $items); } // ask for support $context['text'] .= Skin::build_box(i18n::s('Do you need more help?'), '<p>' . sprintf(i18n::s('Use the %s to ask for help'), Skin::build_link('query.php', i18n::s('query form'), 'shortcut')) . '</p>'); } // provide the empty form by default } elseif (!Surfer::is_logged()) { // the page title if (isset($_REQUEST['url'])) { $context['page_title'] = i18n::s('The page you requested is available only to registered members.'); }