本文整理汇总了PHP中Model_User::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_User::select方法的具体用法?PHP Model_User::select怎么用?PHP Model_User::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_User
的用法示例。
在下文中一共展示了Model_User::select方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cIndex
/**
* 用户列表
*/
public function cIndex()
{
$this->_modelUser = $this->getGlobal('model/User', 'Model_User');
$requestClass = RegistryRequest::getInstance();
$requestClass->absInt($requestClass->get('page'));
$sqlSearch = $this->_modelUser->getFindClass();
$sqlSearch->set_tableName($this->_modelUser->tName());
$sqlSearch->addConditions($requestClass->get('search_where'));
$sqlSearch->setPageLimit($requestClass->get('page'), config('PAGE_SIZE'));
$sqlSearch->set_orderBy('id desc');
$sql = $sqlSearch->createSql();
$dataList = $this->_modelUser->select($sql, 'id');
$conditions = $sqlSearch->get_conditions();
$this->assign('dataList', $dataList);
loadCore('help/Page');
$page = new Page(array('total' => $this->_modelUser->findCount($conditions), 'perpage' => config('PAGE_SIZE')));
$this->assign('pageBox', $page->show());
$this->display(VIEW_PAGE);
}
示例2: _getUserData
/**
* Store the user's profile data in the database, if it doesn't exist yet.
* @param Zend_Oauth_Token_Access $accesstoken
* @return Void
*/
protected function _getUserData(Zend_Service_Twitter $twitterService, $twitterUserId)
{
$twitterUserData = $twitterService->users->show($twitterUserId);
$userColumns = $this->_mapProperties((array) $twitterUserData->toValue());
$userModel = new Model_User();
$userConditions = $userModel->select()->from($userModel->getName(), $this->_getSessionColumns());
$model = new Model_AuthTwitter();
$model->bindModel('Model_User', array('conditions' => $userConditions, 'rule' => 'User'));
$userData = $model->fetchRow($model->select()->where('twitter_uid = ?', $twitterUserId));
if (!$userData || !$userData->Model_User) {
$userData = $model->createNew($twitterUserId, $userColumns);
} else {
$model->getObserver('Authenticatable')->updateLoginStats($userData->user_id);
$userData = $userData->Model_User;
}
return $userData;
}
示例3: _getUserData
protected function _getUserData($accessToken)
{
$profileData = $this->_getLinkedInInstance()->get(self::LINKED_IN_PROFILE_QUERY);
$newUserData = $this->_mapProperties($profileData);
$userModel = new Model_User();
$userConditions = $userModel->select()->from($userModel->getName(), $this->_getSessionColumns());
$model = new Model_AuthLinkedin();
$model->bindModel('Model_User', array('conditions' => $userConditions, 'rule' => 'User'));
$userData = $model->fetchRow($model->select()->where('linkedin_uid = ?', $profileData['id']));
if (!$userData || !$userData->Model_User) {
$userData = $model->createNew($profileData['id'], $newUserData)->toArray();
// Make sure only the session columns remain
$userData = array_intersect_key($userData, array_fill_keys($this->_getSessionColumns(), null));
} else {
$model->getObserver('Authenticatable')->updateLoginStats($userData->user_id);
$userData = $userData->Model_User;
}
return $userData;
}
示例4: _getUserData
/**
* Store the user's profile data in the database, if it doesn't exist yet.
* @param String $id The openid
* @param Array $props The properties fetched thru Sreg
* @return Void
*/
protected function _getUserData($id, array $props)
{
$ini = Zend_Registry::get('config');
$sessionColumns = Zend_Db_Select::SQL_WILDCARD;
if (!empty($ini->auth->login->sessionColumns)) {
$sessionColumns = $ini->auth->login->sessionColumns;
$sessionColumns = explode(',', $sessionColumns);
}
$userModel = new Model_User();
$userConditions = $userModel->select()->from($userModel->getName(), $sessionColumns);
$model = new Model_AuthOpenId();
$model->bindModel('Model_User', array('conditions' => $userConditions));
$userData = $model->fetchRow($model->select()->where('openid = ?', $id));
if (!$userData || !$userData->Model_User) {
$userData = $model->createNew($id, $this->_mapProperties($props));
} else {
$model->getObserver('Authenticatable')->updateLoginStats($userData->user_id);
$userData = $userData->Model_User;
}
return $userData->getPrimaryKey();
}
示例5: validateemailAction
/**
* Validate email address. In scenarios where users receive an email validation email,
* this action is used to validate the address.
*
* @return void
*/
public function validateemailAction()
{
$this->view->title = __('activate email page title');
$auth = Garp_Auth::getInstance();
$authVars = $auth->getConfigValues();
$request = $this->getRequest();
$activationCode = $request->getParam('c');
$activationEmail = $request->getParam('e');
$emailValidColumn = $authVars['validateemail']['email_valid_column'];
if (!$activationEmail || !$activationCode) {
throw new Zend_Controller_Action_Exception('Invalid request.', 404);
}
$userModel = new Model_User();
// always collect fresh data for this one
$userModel->setCacheQueries(false);
$activationCodeClause = 'MD5(CONCAT(' . $userModel->getAdapter()->quoteIdentifier($authVars['validateemail']['token_column']) . ',' . 'MD5(email),' . 'MD5(' . $userModel->getAdapter()->quote($authVars['salt']) . '),' . 'MD5(id)' . ')) = ?';
$select = $userModel->select()->where($activationCodeClause, $activationCode)->where('MD5(email) = ?', $activationEmail);
$user = $userModel->fetchRow($select);
if (!$user) {
$this->view->error = __('invalid email activation code');
} else {
$user->{$emailValidColumn} = 1;
if (!$user->save()) {
$this->view->error = __('activate email error');
} elseif ($auth->isLoggedIn()) {
// If the user is currently logged in, update the cookie
$method = $auth->getStore()->method;
$userData = $auth->getUserData();
// Sanity check: is the user that has just validated his email address
// the currently logged in user?
if ($userData['id'] == $user->id) {
$userData[$emailValidColumn] = 1;
$auth->store($userData, $method);
}
}
$this->view->user = $user;
}
}
示例6: _getPasswordlessModel
protected function _getPasswordlessModel()
{
$authPwlessModel = new Model_AuthPasswordless();
$userModel = new Model_User();
$userConditions = $userModel->select()->from($userModel->getName(), Garp_Auth::getInstance()->getSessionColumns());
$authPwlessModel->bindModel('Model_User', array('conditions' => $userConditions, 'rule' => 'User'));
return $authPwlessModel;
}
示例7: action_index
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=' . $db_prefix . '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));
}
示例8: _getUserData
/**
* Store the user's profile data in the database, if it doesn't exist yet.
* @param Array $facebookData The profile data received from Facebook
* @return Void
*/
protected function _getUserData(array $facebookData)
{
$uid = $facebookData['id'];
$ini = Zend_Registry::get('config');
$sessionColumns = Zend_Db_Select::SQL_WILDCARD;
if (!empty($ini->auth->login->sessionColumns)) {
$sessionColumns = $ini->auth->login->sessionColumns;
$sessionColumns = explode(',', $sessionColumns);
}
$userModel = new Model_User();
$userConditions = $userModel->select()->from($userModel->getName(), $sessionColumns);
$model = new Model_AuthFacebook();
$model->bindModel('Model_User', array('conditions' => $userConditions, 'rule' => 'User'));
$userData = $model->fetchRow($model->select()->where('facebook_uid = ?', $uid));
if (!$userData || !$userData->Model_User) {
$userData = $model->createNew(array('facebook_uid' => $uid, 'access_token' => $facebookData['access_token']), $this->_mapProperties($facebookData));
} else {
$model->getObserver('Authenticatable')->updateLoginStats($userData->user_id, array('access_token' => $facebookData['access_token']));
$userData = $userData->Model_User;
}
return $userData;
}
示例9: getUserAct
/**
* 获取指定控制器或方法用户所拥有的
* @param string $actId
*/
public function getUserAct($actValue)
{
$this->_modelUser = $this->_getGlobalData('Model_User', 'object');
$users = $this->_modelUser->select("select * from {$this->_modelUser->tName()} where act like '%{$actValue}%'");
return $this->getTtwoArrConvertOneArr($users, 'Id', 'nick_name');
}
示例10: _getUserData
/**
* Store the user's profile data in the database, if it doesn't exist yet.
* @param Zend_Oauth_Token_Access $accessToken
* @return Void
*/
protected function _getUserData(Zend_Oauth_Token_Access $accessToken)
{
$authVars = $this->_getAuthVars();
$token = $accessToken->getToken();
$tokenSecret = $accessToken->getTokenSecret();
$vimeoService = new Garp_Service_Vimeo_Pro($authVars->consumerKey, $authVars->consumerSecret, $token, $tokenSecret);
$userDataFromVimeo = $vimeoService->people->getInfo($token);
$id = $userDataFromVimeo['id'];
$ini = Zend_Registry::get('config');
$sessionColumns = Zend_Db_Select::SQL_WILDCARD;
if (!empty($ini->auth->login->sessionColumns)) {
$sessionColumns = $ini->auth->login->sessionColumns;
$sessionColumns = explode(',', $sessionColumns);
}
$userModel = new Model_User();
$userConditions = $userModel->select()->from($userModel->getName(), $sessionColumns);
$model = new Model_AuthVimeo();
$model->bindModel('Model_User', array('conditions' => $userConditions));
$userData = $model->fetchRow($model->select()->where('vimeo_id = ?', $id));
if (!$userData || !$userData->Model_User) {
$userData = $model->createNew($id, $accessToken, $this->_mapProperties($userDataFromVimeo));
} else {
$model->getObserver('Authenticatable')->updateLoginStats($userData->user_id);
$userData = $userData->Model_User;
}
return $userData;
}
示例11: mapFriends
/**
* Find friends of logged in user and map to local friends table.
* @param Array $config
* @return Bool Success
*/
public function mapFriends(array $config)
{
$config = $config instanceof Garp_Util_Configuration ? $config : new Garp_Util_Configuration($config);
$config->obligate('bindingModel')->obligate('user_id')->setDefault('accessToken', $this->getAccessToken());
if (!$config['accessToken']) {
// Find the auth record
$authModel = new Model_AuthFacebook();
$authRow = $authModel->fetchRow($authModel->select()->where('user_id = ?', $config['user_id']));
if (!$authRow || !$authRow->access_token) {
return false;
}
// Use the stored access token to create a user session. Me() in the FQL ahead will contain the user's Facebook ID.
// Note that the access token is available for a very limited time. Chances are it's not valid anymore.
$accessToken = $authRow->access_token;
}
try {
$this->_client->setAccessToken($config['accessToken']);
// Find the friends' Facebook UIDs
$friends = $this->_client->api(array('method' => 'fql.query', 'query' => 'SELECT uid2 FROM friend WHERE uid1 = me()'));
// Find local user records
$userModel = new Model_User();
$userTable = $userModel->getName();
$authFbModel = new Model_AuthFacebook();
$authFbTable = $authFbModel->getName();
$fbIds = '';
$friendCount = count($friends);
foreach ($friends as $i => $friend) {
$fbIds .= $userModel->getAdapter()->quote($friend['uid2']);
if ($i < $friendCount - 1) {
$fbIds .= ',';
}
}
$friendQuery = $userModel->select()->setIntegrityCheck(false)->from($userTable, array('id'))->join($authFbTable, $authFbTable . '.user_id = ' . $userTable . '.id', array())->where('facebook_uid IN (' . $fbIds . ')')->order($userTable . '.id');
$localUsers = $userModel->fetchAll($friendQuery);
$localUserCount = count($localUsers);
// Insert new friendships into binding model
$bindingModel = new $config['bindingModel']();
$insertSql = 'INSERT IGNORE INTO ' . $bindingModel->getName() . ' (user1_id, user2_id) VALUES ';
foreach ($localUsers as $i => $localUser) {
$insertSql .= '(' . $localUser->id . ',' . $config['user_id'] . '),';
$insertSql .= '(' . $config['user_id'] . ',' . $localUser->id . ')';
if ($i < $localUserCount - 1) {
$insertSql .= ',';
}
}
$result = $bindingModel->getAdapter()->query($insertSql);
// Clear cache manually, since the table isn't updated thru conventional paths.
Garp_Cache_Manager::purge($bindingModel);
return !!$result;
} catch (Exception $e) {
return false;
}
}
示例12: _userIndex
/**
* 用户主界面
*/
private function _userIndex()
{
$this->_loadCore('Help_SqlSearch');
$this->_loadCore('Help_Page');
$helpSqlSearch = new Help_SqlSearch();
$helpSqlSearch->set_tableName($this->_modelUser->tName());
if ($_GET['department_id']) {
$helpSqlSearch->set_conditions("department_id={$_GET['department_id']}");
$this->_view->assign('selectedDepartmentId', $_GET['department_id']);
}
if ($_GET['org_id'] != '') {
$helpSqlSearch->set_conditions("org_id={$_GET['org_id']}");
$this->_view->assign('selectedOrgId', $_GET['org_id']);
}
if ($_GET['user_name']) {
$helpSqlSearch->set_conditions("user_name like '{$_GET['user_name']}%'");
$this->_view->assign('selectedUserName', $_GET['user_name']);
}
if ($_GET['nick_name']) {
$nickName = urldecode($_GET['nick_name']);
$helpSqlSearch->set_conditions("nick_name like '%{$nickName}%'");
$this->_view->assign('selectedNickName', $nickName);
}
$helpSqlSearch->set_orderBy('status desc,date_updated desc');
$helpSqlSearch->setPageLimit($_GET['page'], PAGE_SIZE);
$conditions = $helpSqlSearch->get_conditions();
$sql = $helpSqlSearch->createSql();
$dataList = $this->_modelUser->select($sql);
$helpPage = new Help_Page(array('total' => $this->_modelUser->findCount($conditions), 'perpage' => PAGE_SIZE));
$departmentList = $this->_getGlobalData('department');
$departmentList = Model::getTtwoArrConvertOneArr($departmentList, 'Id', 'name');
$orgList = $this->_getGlobalData('org');
$orgList = Model::getTtwoArrConvertOneArr($orgList, 'Id', 'name');
$rolesList = $this->_modelRoles->findAll();
$rolesList = $this->_modelRoles->getTtwoArrConvertOneArr($rolesList, 'role_value', 'role_name');
if ($dataList) {
foreach ($dataList as &$value) {
$value['word_department'] = $departmentList[$value['department_id']];
$value['word_org_id'] = $value['org_id'] ? $orgList[$value['org_id']] : '暂无组别';
//转换角色为中文显示
if ($value['roles']) {
$value['roles'] = explode(',', $value['roles']);
$value['word_roles'] = array();
foreach ($value['roles'] as $tmpRolesList) {
array_push($value['word_roles'], $rolesList[$tmpRolesList]);
}
$value['word_roles'] = implode(',', $value['word_roles']);
} else {
$value['word_roles'] = '暂无角色';
}
$value['date_created'] = date('Y-m-d H:i', $value['date_created']);
$value['date_updated'] = date('Y-m-d H:i', $value['date_updated']);
$value['url_operator_manage'] = Tools::url(CONTROL, 'UserSetup', array('Id' => $value['Id'], 'doaction' => 'managerOperator'));
$value['url_edit'] = Tools::url(CONTROL, ACTION, array('Id' => $value['Id'], 'doaction' => 'edit'));
$value['url_del'] = Tools::url(CONTROL, ACTION, array('Id' => $value['Id'], 'user_name' => $value['user_name'], 'doaction' => 'del'));
$value['url_Initialize'] = Tools::url(CONTROL, ACTION, array('user_name' => $value['user_name'], 'doaction' => 'initialize'));
$value['url_clear_order'] = Tools::url(CONTROL, 'UserClearOrder', array('user_id' => $value['Id']));
$value['url_clear_quality_check'] = Tools::url(CONTROL, 'ClearQualityCheck', array('user_id' => $value['Id']));
$value['url_close'] = Tools::url(CONTROL, ACTION, array('user_id' => $value['Id'], 'doaction' => 'close', 'status' => $value['status']));
$value['url_act'] = Tools::url(CONTROL, ACTION, array('user_id' => $value['Id'], 'doaction' => 'act'));
$value['word_status'] = $value['status'] ? '<font color="#00CC00">启用</font>' : '<font color="#FF0000">停用</font>';
$actList = explode(',', $value['act']);
$value['act_count'] = end($actList) ? count($actList) : 0;
}
$this->_view->assign('dataList', $dataList);
}
$orgList['0'] = '未分组';
$orgList[''] = '所有';
$this->_view->assign('selectOrgList', $orgList);
$departmentList[''] = '所有';
$this->_view->assign('selectDepartmentList', $departmentList);
$this->_view->assign('pageBox', $helpPage->show());
$this->_view->set_tpl(array('body' => 'User/UserIndex.html'));
$this->_utilMsg->createNavBar();
$this->_view->display();
}
示例13: make
/**
* Make an existing user admin
*
* @param array $args
* @return void
*/
public function make(array $args = array())
{
$userModel = new Model_User();
if (!empty($args)) {
$id = $args[0];
} else {
$id = Garp_Cli::prompt('What is the id or email address of the user?');
}
$select = $userModel->select();
if (is_numeric($id)) {
$filterColumn = 'id';
} else {
$filterColumn = 'email';
}
$select->where($filterColumn . ' = ?', $id);
$user = $userModel->fetchRow($select);
if (!$user) {
Garp_Cli::errorOut('Error: could not find user with ' . $filterColumn . ' ' . $id);
} else {
$user->role = 'admin';
if ($user->save()) {
// For completeness sake, check if the user has an AuthLocal
// record. We disregard the fact wether the user already has any
// of the other Auth- records.
$authLocalModel = new Model_AuthLocal();
$authLocalRecord = $authLocalModel->fetchRow($authLocalModel->select()->where('user_id = ?', $user->id));
if (!$authLocalRecord) {
$newAuthLocalData = array('password' => trim(Garp_Cli::prompt('Choose a password:')), 'user_id' => $user->id);
$authLocalModel->insert($newAuthLocalData);
}
Garp_Cli::lineOut('User with ' . $filterColumn . ' ' . $id . ' is now administrator');
} else {
Garp_Cli::errorOut('Error: could not make user with ' . $filterColumn . ' ' . $id . ' administrator');
}
}
}