public function actionUp($type, $id) { $ret_val = false; $existing = new Rating(); $existing->queryOptions['user_id'] = \Yii::$app->user->getId(); $existing->queryOptions['remote_type'] = $type; $existing->queryOptions['remote_id'] = $id; switch ($existing->exists()) { case false: $model = new Rating(['remote_type' => $type, 'remote_id' => $id]); $model->save(); break; default: $existing = new Rating(); $existing->queryOptions['remote_type'] = $type; $existing->queryOptions['remote_id'] = $id; $count = $existing->getCount(); switch (1) { case $count < Users::find()->count(): $ret_val = true; break; } break; } $this->renderResponse($ret_val); }
public function indexAction() { $this->view->users = Users::find(); $user = new Users(); $user->id = 3; $user->save(); }
/** * 修改个人信息 */ function actionChangeInfo() { $this->_pathway->addStep('个人信息'); $currentUser = $this->_app->currentUser(); $user = Users::find()->getById($currentUser['id']); $form = new Form_User(url('admin::usercenter/changeInfo')); $form->element('username')->set('readonly', 'true'); $form->remove('password'); $form->element('group_id')->items = Groups::find('id=?', $user->group_id)->order('weight desc')->getAll()->toHashMap('id', 'name'); $form->element('level_id')->items = Levels::find('weight=?', $user->level_id)->order('weight desc')->getAll()->toHashMap('weight', 'name'); $form->remove('enabled'); $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden', 'value' => $currentUser['id'])); if ($this->_context->isPOST() && $form->validate($_POST)) { try { $user->changeProps($form->values()); $user->save(); return "{msg:'编辑成功'}"; } catch (QDB_ActiveRecord_ValidateFailedException $ex) { $form->invalidate($ex); } } else { $form->import($user); } $form->add(QForm::ELEMENT, 'reg_at', array('_ui' => 'textbox', '_label' => '注册时间', 'value' => date('Y-m-d', $user->register_at), 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'reg_ip', array('_ui' => 'textbox', '_label' => '注册IP', 'value' => $user->register_ip, 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'log_at', array('_ui' => 'textbox', '_label' => '最后登录时间', 'value' => $user->login_at == 0 ? '0000-00-00' : date('Y-m-d', $user->login_at), 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'log_ip', array('_ui' => 'textbox', '_label' => '最后登录IP', 'value' => $user->login_ip, 'class' => 'txt w200', 'readonly' => 'true')); $form->add(QForm::ELEMENT, 'log_count', array('_ui' => 'textbox', '_label' => '登录次数', 'value' => $user->login_count, 'class' => 'txt w200', 'readonly' => 'true')); $this->_view['form'] = $form; }
public function groupsAction() { $this->view->title = "Sending Groups - "; $this->view->selectmenu = "mgroups"; $groups = Users::aggregate(array('$group' => array('_id' => '$group'))); $this->view->kel = $groups['result']; if ($this->request->isPost()) { $groups = $this->request->getPost('group'); $responses = ''; foreach ($groups as $group) { $userslist = Users::find(array(array('group' => $group))); $rcpt = ""; foreach ($userslist as $user) { if (!$rcpt) { $rcpt = $user->num; } else { $rcpt = $rcpt . ',' . $user->num; } } $response = $this->smsweb->sendSMS($rcpt, $this->request->getPost('msg')); $responses = $responses . "\n" . $response; } return $this->dispatcher->forward(array('action' => 'sent', 'params' => array($this->view->title, $this->view->selectmenu, $responses))); } }
/** * Index action */ public function indexAction() { $numberPage = 1; $list = Users::find(); $paginator = new Paginator(array("data" => $list, "limit" => 10, "page" => $numberPage)); $this->view->page = $paginator->getPaginate(); }
public static function login() { // get posted data $post = Input::post(array('user', 'pass', 'remember')); $errors = array(); if (empty($post['user'])) { $errors[] = 'Please enter your username'; } if (empty($post['pass'])) { $errors[] = 'Please enter your password'; } if (empty($errors)) { // find user if ($user = Users::find(array('username' => $post['user']))) { // check password if (crypt($post['pass'], $user->password) != $user->password) { $errors[] = 'Incorrect details'; } } else { $errors[] = 'Incorrect details'; } } if (count($errors)) { Notifications::set('error', $errors); return false; } // if we made it this far that means we have a winner Session::set('user', $user); return true; }
/** * The add action */ public function addAction() { $auth = $this->session->get('auth'); if ($auth) { $this->_bc->add('Add', 'awards/add'); $allEpisodes = Episodes::find(array('order' => 'air_date DESC')); $allUsers = Users::find(array('order' => 'username')); $allPlayers = Players::find(array('order' => 'active DESC, name')); $this->view->setVar('users', $allUsers); $this->view->setVar('episodes', $allEpisodes); $this->view->setVar('players', $allPlayers); if ($this->request->isPost()) { $datetime = date('Y-m-d H:i:s'); $award = new Awards(); $award->userId = $this->request->getPost('user_id', 'int'); $award->episodeId = $this->request->getPost('episode_id', 'int'); $award->playerId = $this->request->getPost('player_id', 'int'); $award->award = $this->request->getPost('award', 'int'); if (!$award->save()) { foreach ($award->getMessages() as $message) { $this->flash->error((string) $message); } } else { $this->view->disable(); $this->flash->success('Award created successfully'); $this->invalidateCache(); $this->response->redirect('awards/'); } } } }
public function destroy($id) { $users = Users::find($id); $users->delete(); Session::flash('message', 'Successfully deleted the Users!'); return Redirect::to('users'); }
public function indexAction() { $this->view->title = "Outbox - "; $this->view->selectmenu = "outbox"; $response = $this->smsweb->getCommands(); $data = str_getcsv($response, "\n"); $sendresponses = ""; print_r($response); if (!empty($response)) { foreach ($data as $jsonsms) { $sms = json_decode($jsonsms); $textpart = str_getcsv($sms->msg, "#"); $group = $textpart[0]; $msg = $textpart[1]; $userslist = Users::find(array(array('group' => $group))); $num = str_replace("+62", "0", $sms->from); $cekuserongroup = Users::find(array(array('group' => $group, 'num' => $num))); if ($userslist && $cekuserongroup) { //if group exist $rcpt = ""; foreach ($userslist as $user) { if (!$rcpt) { $rcpt = $user->num; } else { $rcpt = $rcpt . ',' . $user->num; } } $sendresponse = $this->smsweb->sendSMS($rcpt, $msg); } $sendresponses = $sendresponses . "\n" . $sendresponse; } } $this->view->response = $sendresponses; }
private function getUsersList() { $model = Users::find()->where(['status' => 1])->all(); foreach ($model as $data) { $user[$data->id] = ['id' => $data->id, 'username' => $data->login, 'password' => $data->password, 'authKey' => 'test' . $data->id . 'key', 'accessToken' => $data->id . '-token']; } return $user; }
public function finduser() { $this->model('Users'); $user = new Users(); $user->id = 1; $user->find(); echo $user->FirstName . ' ' . $user->LastName; }
/** * Finds user by username * * @param string $username * @return static|null */ public static function findByUsername($username) { $dbuser = Users::find()->where(["username" => $username])->one(); if (!count($dbuser)) { return null; } return new static($dbuser); }
/** * @param array $params */ public function testAction() { $users = Users::find(); if ($users) { foreach ($users as $user) { echo $user->name . '-' . $user->email . PHP_EOL; } } }
public function listAction() { $this->view->users = Users::find(); //ECHO '<pre>'; //print_r(get_class_methods($users)); //print_r($users->toArray()); //echo '</pre>'; echo $this->view->render("users/list"); }
public static function getById($id) { foreach (Users::find() as $u) { if ($u->id == $id) { return $u; } } return false; }
public function indexAction() { $this->view->title = "Peringkat "; $this->view->selectmenu = "outbox"; $user = Users::find(array("sort" => array("pungutan" => 1), "limit" => 5)); $lama = Users::find(array("sort" => array("lama" => 1), "limit" => 5)); $this->view->response = $user; $this->view->lama = $lama; }
/** * Finds user by username * * @param string $username * @return static|null */ public static function findByUsername($username) { $users = Users::find()->where("active=:active", ["active" => 1])->andWhere("username=:username", [":username" => $username])->all(); foreach ($users as $user) { if (strcasecmp($user->username, $username) === 0) { return new static($user); } } return null; }
public static function findByUsername($username) { $users = Users::find()->Where("nombre_usuario=:nombre_usuario", [":nombre_usuario" => $username])->all(); foreach ($users as $user) { if (strcasecmp($user->nombre_usuario, $username) === 0) { return new static($user); } } return null; }
public function indexAction() { $data = array(); $data["menu"] = "Responden"; $data["menu_desc"] = "pengaturan pengisi kuesioner (responden)"; $data["menu_icon_class"] = "ion ion-ios-people"; //Fetch all active respondent records $respondenRs = Users::find(array("id_role = :responden_role_id: AND active = true", "bind" => array("responden_role_id" => Roles::findFirstByName("Respondent")->getIdRole()))); $this->view->setVars(array("data" => $data, "respondenRs" => $respondenRs)); }
public function getUser() { $users = Users::find(); foreach ($users as $u) { if ((int) $u->id === (int) $this->users_id) { return $u; } } return false; }
public function __construct($entity = null, $attrs = null) { parent::__construct($entity, $attrs); $results = array(); $users = Users::find(); foreach ($users as $u) { $results[$u->id] = $u->name; } $user_select = new SelectField('user', $results, array('class' => 'form-control')); //$user_select->setId('user'); $this->add($user_select); }
public function listUserAction() { $usersArray = []; $this->view->disable(); $users = Users::find(['columns' => 'id, firstName, lastName, email, gender, details, hobby, fileName']); foreach ($users as $user) { $user->hobby = empty($user->hobby) ? [] : unserialize($user->hobby); $usersArray[] = $user; } $this->response->setJsonContent($usersArray); $this->response->setStatusCode(200, "OK"); $this->response->send(); }
public function put_index() { $data = file_get_contents('php://input'); $temp = json_decode($data); $new = Users::find($temp->id); $new->id = $temp->id; $new->first_name = $temp->first_name; $new->last_name = $temp->last_name; $new->birth_date = $temp->birth_date; $new->save(); $array = array('success' => 'true'); $json = json_encode($array); return $json; }
function render() { $currentUser = MyApp::instance()->currentUser(); $category = array(); if ($currentUser['group_id'] == 1) { $category = Category::find('enabled=1')->order('weight desc')->getAll(); } else { $user = Users::find()->getById($currentUser['id']); $category = $user->group->categorys; } $this->_view['title'] = $this->title; $this->_view['category'] = $category; return $this->_fetchView(dirname(__FILE__) . '/category_view'); }
public function edit($id) { // find user if (($user = Users::find(array('id' => $id))) === false) { return Response::redirect($this->admin_url . '/users'); } // process post request /*if(Input::method() == 'POST') { if(Users::update($id)) { // redirect path return Response::redirect($this->admin_url . '/users/edit/' . $id); } }*/ Template::render('users/edit', array('user' => $user)); }
/** * Mobile Validation Key */ public static function isValidMobileKey($_time, $_key) { $_key1 = 'Tu6ehUya'; $_key2 = 'c5CHuxUq'; $_key3 = 'nuDrEk2c'; $_id = substr($_key, 0, strpos($_key, '/')); $user = new Users(); if ($rowset = $user->find($_id)) { $row = $rowset->current(); $_keyBuilded = $_key1 . Sydney_Tools_Datetime::getDateYear($_time) . Sydney_Tools_Datetime::getDateSeconds($_time) . $row->password . Sydney_Tools_Datetime::getDateDay($_time) . Sydney_Tools_Datetime::getDateMinute($_time) . $_key2 . Sydney_Tools_Datetime::getDateMonth($_time) . $row->login . $_key3; $row = $rowset->current(); if ($_id . '/' . sha1($_keyBuilded) === $_key) { return $row; } } return false; }
public function get_data_for_dashboard() { $userid = Users::where('id', '=', Session::get('user_id'))->first()->id; $data['user'] = Users::find(Session::get('user_id')); $data['komunitas'] = Komunitas::orderBy('avg_rate', 'DESC')->take(5)->get(); $data['rekomen'] = $this->predict->recommendation($userid); $data['rating'] = $this->rating->count_rate_row_by_id($userid); $data['cek'] = $this->predict->has_recommendation($userid); $data['rand'] = Komunitas::orderByRaw("RAND()")->take(5)->get(); // $data['test'] = $this->komunitas->get_recommendation($userid); // $data['komunitas'] = $this->komunitas->get_initial_recommendation(); $data['acara'] = Acara::where('tanggal', '>=', DB::raw('CURDATE()'))->take(4)->orderBy('tanggal', 'ASC')->get(); // $count = Komunitas::where('id_kategori', '=', 1)->count(); $allkom = $this->predict->has_recommendation($userid); //var_dump($allkom); //var_dump($data['test']); return View::make('dashboard', $data); }
public static function login() { // verify Csrf token if (Csrf::verify(Input::post('token')) === false) { Notifications::set('error', 'Invalid token'); return false; } // get posted data $post = Input::post(array('user', 'pass', 'remember')); $errors = array(); // remove white space $post = array_map('trim', $post); if (empty($post['user'])) { $errors[] = Lang::line('users.missing_login_username', 'Please enter your username'); } if (empty($post['pass'])) { $errors[] = Lang::line('users.missing_login_password', 'Please enter your password'); } if (empty($errors)) { // find user if ($user = Users::find(array('username' => $post['user']))) { // check password if (Hash::check($post['pass'], $user->password) === false) { $errors[] = 'Incorrect details'; } } else { $errors[] = 'Incorrect details'; } } if (count($errors)) { Notifications::set('error', $errors); return false; } // if we made it this far that means we have a winner Session::set('user', $user); // avoid session fixation vulnerability // https://www.owasp.org/index.php/Session_fixation Session::regenerate(); return true; }
/** * Searches for users */ public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Criteria::fromInput($this->di, "Users", $_POST); $this->persistent->parameters = $query->getParams(); } else { $numberPage = $this->request->getQuery("page", "int"); } $parameters = $this->persistent->parameters; if (!is_array($parameters)) { $parameters = array(); } $parameters["order"] = "id"; $users = Users::find($parameters); if (count($users) == 0) { $this->flash->notice("The search did not find any users"); return $this->dispatcher->forward(array("controller" => "users", "action" => "index")); } $paginator = new Paginator(array("data" => $users, "limit" => 10, "page" => $numberPage)); $this->view->page = $paginator->getPaginate(); }
public function initialize() { $this->params = (object) []; $auth = $this->session->get('auth'); if (!$auth) { return $this->dispatcher->forward(array('controller' => 'login', 'action' => 'index')); } else { $this->view->role = 'Users'; } foreach ($this->request->get() as $key => $value) { $this->params->{$key} = $value; } $this->params->limit = 10; $this->params->all_pages = 0; $this->params->offset = 0; if (!isset($this->params->page)) { $this->params->page = 1; } $this->params->next = $this->params->page + 1; $this->view->params = $this->params; $this->auth = $this->session->get('auth'); $this->view->auth = $this->auth; $authors = Users::find(['level = 16 and id_reg=' . $this->auth->id_reg])->toArray(); $list_author = []; foreach ($authors as $author) { if ($this->auth->id != $author->id) { $list_author[] = ["id" => $author['id'], "name" => $author['name'], "username" => $author['username'], "id_reg" => $author['id_reg']]; } } if ($this->auth->id_reg == $this->auth->id) { array_push($list_author, ["id" => $this->auth->id, "name" => $this->auth->name, "username" => $this->auth->username, "id_reg" => $this->auth->id_reg]); } else { $author = Users::findFirst(['id_reg=' . $this->auth->id_reg])->toArray(); array_push($list_author, ["id" => $author['id'], "name" => $author['name'], "username" => $author['username'], "id_reg" => $author['id_reg']]); } $this->view->authors = $list_author; }