本文整理汇总了PHP中UserQuery类的典型用法代码示例。如果您正苦于以下问题:PHP UserQuery类的具体用法?PHP UserQuery怎么用?PHP UserQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getCurrentUser
public static function getCurrentUser()
{
if (self::checkIfAuthenticated()) {
$query = new UserQuery();
$user = $query->findPk($_SESSION[self::$SESSION_USER_ID]);
return $user;
} else {
return null;
}
}
开发者ID:pcmasteratings,项目名称:site,代码行数:10,代码来源:Auth.php
示例2: getSubordinate
/**
* Returns a subordinate user by ID.
*
* @param string|int $userId The subordinate user's ID or full login name.
* @param PropelPDO $con Optional. The database connection to use.
* Default is NULL.
* @throws Exception
* @return User
*/
public function getSubordinate($userId, PropelPDO $con = null)
{
$query = new UserQuery();
$user = is_numeric($userId) ? $query->findOneById($userId, $con) : $query->findOneByFQN($userId, $con);
if ($user === null) {
throw new Exception('Invalid user ID ' . $userId . '.');
}
$thisAccountId = (string) $this->getAccountId();
if ($thisAccountId === '' or (string) $user->getAccountId() !== $thisAccountId or !$this->isAdmin() and (string) $user->getDomainId() !== (string) $this->getManagerOf()) {
throw new Exception('The selected user #' . $userId . ' (account #' . $user->getAccountId() . ') is not assigned to user "' . $this->getFQN($con) . '" (account #' . $thisAccountId . ').');
}
return $user;
}
开发者ID:dapepe,项目名称:tymio,代码行数:22,代码来源:User.php
示例3: create
/**
* Returns a new UserQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param UserQuery|Criteria $criteria Optional Criteria to build the query from
*
* @return UserQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof UserQuery) {
return $criteria;
}
$query = new UserQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
开发者ID:eddypre,项目名称:Quirofano,代码行数:22,代码来源:BaseUserQuery.php
示例4: setUser
protected function setUser($reddit_id, $name)
{
$query = new UserQuery();
$users = $query->findByRedditID($reddit_id);
$user = null;
if ($users->count() == 0) {
$user = new User();
$user->setUsername($name);
$user->setRedditID($reddit_id);
$user->save();
} else {
$user = $users->getFirst();
}
$_SESSION[Auth::$SESSION_USER_ID] = $user->getId();
}
开发者ID:nirkbirk,项目名称:site,代码行数:15,代码来源:AAuthProvider.php
示例5: getUser
public static function getUser()
{
if (isset($_SESSION['user']) && $_SESSION['user'] != '' && ($user = UserQuery::create()->findOneByUUID($_SESSION['user']))) {
return $user;
}
return null;
}
开发者ID:sohelrana820,项目名称:pst-stack,代码行数:7,代码来源:App.php
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$project_service = $this->getProjectService();
if ($user_name = $input->getOption('user-name')) {
if (!($user = UserQuery::create()->findOneByUsername($user_name))) {
$this->logError('Пользователь с именем ' . $user_name . ' не найден');
die;
} else {
$project_list = $project_service->getProjectList($user, true, false, true);
}
} else {
$project_list = $project_service->getProjectsAll(true, false, true);
}
if (count($project_list)) {
foreach ($project_list as $project) {
/** @var Project $project */
$this->log($project->getTitle());
$project_bad_links = $project->getLinks(true, true);
//TODO: далее собираем плохие ссылки в одну кучу и отправляем письмо
if (count($project_bad_links)) {
}
}
} else {
$this->log('со всеми проектами всё ок');
}
}
开发者ID:0x2f8f,项目名称:checkpage,代码行数:27,代码来源:CheckReminderCommand.php
示例7: getQuery
function getQuery($user)
{
global $app;
$sort = $app->request()->params('sort', '');
$query = UserQuery::create()->leftJoin('User.Chart')->withColumn('COUNT(Chart.Id)', 'NbCharts')->groupBy('User.Id')->filterByDeleted(false);
$q = $app->request()->params('q');
if ($q) {
$query->where('email LIKE "%' . $q . '%" OR name LIKE "%' . $q . '%"');
}
if (!$user->isSysAdmin()) {
$query->filterByRole('sysadmin', Criteria::NOT_EQUAL);
}
switch ($sort) {
case 'name':
$query->orderByName('asc');
break;
case 'email':
$query->orderByEmail('asc');
break;
case 'charts':
$query->orderBy('NbCharts', 'desc');
break;
case 'created_at':
$query->orderBy('createdAt', 'desc');
break;
}
return $query;
}
开发者ID:rwardhan,项目名称:datawrapper-1,代码行数:28,代码来源:plugin.php
示例8: authenticate
/**
* Authenticates this user and signs them in, if the API key or session is valid
*
* Overridden because currently sfAltumoPlugin's version is specific to ApiUser.
* @todo that behavior needs to be changed and updated on applications that rely on it.
*
* @param sfActions $action
* @return void
* @throws Exception if validation fails.
*/
public function authenticate()
{
//require SSL, if applicable
$this->assertSslApiRequest();
//authenticate via the API key, if provided
$api_key = $this->getHttpRequestHeader('Authorization', null);
if (!is_null($api_key)) {
if (preg_match('/\\s*Basic\\s+(.*?)\\s*$/im', $api_key, $regs)) {
$api_key = $regs[1];
$user = \UserQuery::create()->filterByActive(true)->filterByApiKey($api_key)->findOne();
if (!$user) {
throw new \Exception('Unknown or inactive user.');
}
$sf_guard_user = $user->getsfGuardUser();
if ($sf_guard_user->getIsActive()) {
\sfContext::getInstance()->getUser()->signIn($sf_guard_user, false);
return;
} else {
throw new \Exception('Unknown or inactive user.');
}
} else {
throw new \Exception('API key format not recognized');
}
}
//try to authenticate via the session, if the api key was not provided
if (is_null($api_key)) {
$sf_user = sfContext::getInstance()->getUser();
if (!$sf_user || !$sf_user->isAuthenticated()) {
throw new \Exception('Your session is not valid for API usage.');
}
} else {
throw new \Exception('Please provide either a valid session or valid API key.');
}
}
开发者ID:homer6,项目名称:blank_altumo,代码行数:44,代码来源:ApiRequest.php
示例9: executeDelete
public function executeDelete(sfWebRequest $request)
{
$request->checkCSRFProtection();
$User = UserQuery::create()->findPk($request->getParameter('id'));
$this->forward404Unless($User, sprintf('Object User does not exist (%s).', $request->getParameter('id')));
$User->delete();
$this->redirect('user/index');
}
开发者ID:eddypre,项目名称:Quirofano,代码行数:8,代码来源:actions.class.php
示例10: emailExists
public function emailExists()
{
$user = UserQuery::create()->findOneByEmail($this->getEmail());
if ($user) {
return true;
}
return false;
}
开发者ID:amandaaurita,项目名称:hackapuc2015,代码行数:8,代码来源:User.php
示例11: getNewEntityForm
protected function getNewEntityForm()
{
$form = new Curry_Form(array('action' => url('', $_GET), 'method' => 'post', 'elements' => array('path' => array('filebrowser', array('label' => 'File/Folder path', 'required' => true, 'description' => 'If you want to specify a folder, type the public path without a trailing slash (e.g. images/site).', 'filebrowserOptions' => array('local' => false))), 'owner_id' => array('select', array('label' => 'Owner', 'multiOptions' => UserQuery::create()->find()->toKeyValue('UserId', 'Name'), 'value' => User::getUser()->getUserRoleId(), 'required' => true)), 'oread' => array('checkbox', array('label' => 'Read', 'value' => true)), 'owrite' => array('checkbox', array('label' => 'Write', 'value' => true)), 'rread' => array('checkbox', array('label' => 'Read', 'value' => true)), 'rwrite' => array('checkbox', array('label' => 'Write', 'value' => true)), 'wread' => array('checkbox', array('label' => 'Read', 'value' => true)), 'wwrite' => array('checkbox', array('label' => 'Write', 'value' => true)))));
$form->addDisplayGroup(array('oread', 'owrite'), 'grpOwner', array('legend' => 'Owner permissions', 'class' => 'advanced'));
$form->addDisplayGroup(array('rread', 'rwrite'), 'grpRole', array('legend' => 'Role permissions', 'class' => 'advanced'));
$form->addDisplayGroup(array('wread', 'wwrite'), 'grpWorld', array('legend' => 'World permissions', 'class' => 'advanced'));
$form->addElement('submit', 'save', array('label' => 'Save'));
return $form;
}
开发者ID:josedsilva,项目名称:curry-managedfile,代码行数:9,代码来源:Tools.php
示例12: testAvailableEmailAddress
/**
* Determines whether the provided $email_address is available to be used.
* This is a case-insensitive match.
*
* @param string $email_address
* @throws \Exception //if email address format is invalid
* @return boolean
*/
public static function testAvailableEmailAddress($email_address, $exception_message = null)
{
$email_address = \Altumo\Validation\Emails::assertEmailAddress($email_address, $exception_message);
$email_address = strtolower($email_address);
$count = UserQuery::create()->usesfGuardUserQuery()->filterByUsername($email_address)->endUse()->count();
if ($count === 0) {
return true;
} else {
return false;
}
}
开发者ID:homer6,项目名称:sfAltumoPlugin,代码行数:19,代码来源:UserPeer.php
示例13: dashboard
public function dashboard($app, $page)
{
// returns a CSV from a MySQL resultset
function res2csv($rs)
{
$csv = "";
$keys = array();
$results = array();
foreach ($rs as $r) {
if (count($keys) == 0) {
foreach ($r as $key => $val) {
if (is_string($key)) {
$keys[] = $key;
}
}
$csv = implode(";", $keys) . "\\n";
}
$results[] = $r;
}
$results = array_reverse($results);
foreach ($results as $r) {
$values = array();
foreach ($keys as $key) {
$values[] = $r[$key];
}
$csv .= implode(";", $values) . "\\n";
}
return $csv;
}
$con = Propel::getConnection();
$data = array();
$publised_sql = 'SELECT DATE_FORMAT(published_at, \'%Y-%m-%d\') pub_date, COUNT(*) pub_count FROM `chart` WHERE last_edit_step = 5 GROUP BY pub_date ORDER BY `pub_date` DESC LIMIT 1,90';
$publised_week_sql = 'SELECT DATE_FORMAT(published_at, \'%Y-w%u\') pub_date, COUNT(*) pub_count FROM `chart` WHERE last_edit_step = 5 GROUP BY pub_date ORDER BY `pub_date` DESC LIMIT 1,26';
$user_signups_sql = 'SELECT DATE_FORMAT(created_at, \'%Y-%m-%d\') create_date, COUNT(*) user_count FROM `user` GROUP BY create_date ORDER BY `create_date` DESC LIMIT 1,90';
$numUsers = UserQuery::create()->filterByDeleted(false)->count();
$numUsersPending = UserQuery::create()->filterByDeleted(false)->filterByRole(UserPeer::ROLE_PENDING)->count();
$numUsersActivated = UserQuery::create()->filterByDeleted(false)->filterByRole(UserPeer::ROLE_EDITOR)->count();
$numUsersDeleted = UserQuery::create()->filterByDeleted(true)->count();
$users_csv = "Type;Count\\nPending;{$numUsersPending}\\nActivated;{$numUsersActivated}\\nDeleted;{$numUsersDeleted}";
$numCharts = ChartQuery::create()->filterByDeleted(false)->count();
$numChartsUpload = ChartQuery::create()->filterByLastEditStep(array('max' => 1))->filterByDeleted(false)->count();
$numChartsDescribe = ChartQuery::create()->filterByLastEditStep(2)->filterByDeleted(false)->count();
$numChartsVisualize = ChartQuery::create()->filterByLastEditStep(3)->filterByDeleted(false)->count();
$numChartsPublished = ChartQuery::create()->filterByLastEditStep(array('min' => 4))->filterByDeleted(false)->count();
$charts_csv = "LastEditStep;Count\\nUpload;{$numChartsUpload}\\nDescribe;{$numChartsDescribe}\\nVisualize;{$numChartsVisualize}\\nPublish;{$numChartsPublished}\\n";
$charts_by_type_csv = res2csv($con->query('SELECT type, COUNT(*) FROM chart WHERE deleted = 0 GROUP BY type;'));
$charts_by_type_csv = str_replace('-chart', '', $charts_by_type_csv);
$page = array_merge($page, array('num_users' => $numUsers, 'num_users_activated' => $numUsersActivated, 'num_charts' => $numCharts, 'num_charts_published' => $numChartsPublished, 'published_csv' => res2csv($con->query($publised_sql)), 'published_week_csv' => res2csv($con->query($publised_week_sql)), 'users_csv' => $users_csv, 'charts_edit_step_csv' => $charts_csv, 'charts_by_type_csv' => $charts_by_type_csv, 'created_csv' => res2csv($con->query('SELECT DATE_FORMAT(created_at, \'%Y-%m-%d\') pub_date, COUNT(*) pub_count FROM `chart` GROUP BY pub_date ORDER BY `pub_date` DESC LIMIT 1,90')), 'created_weekly_csv' => res2csv($con->query('SELECT DATE_FORMAT(created_at, \'%Y-w%u\') pub_date, COUNT(*) pub_count FROM `chart` GROUP BY pub_date ORDER BY `pub_date` DESC LIMIT 1,26')), 'user_signups_csv' => res2csv($con->query($user_signups_sql)), 'linechart' => DatawrapperVisualization::get('line-chart'), 'columnchart' => DatawrapperVisualization::get('column-chart'), 'donutchart' => DatawrapperVisualization::get('donut-chart'), 'chartLocale' => 'en-US'));
$app->render('plugins/admin-dashboard/admin-dashboard.twig', $page);
}
开发者ID:elaOnMars,项目名称:datawrapper,代码行数:50,代码来源:plugin.php
示例14: index
public function index()
{
$user = UserQuery::create();
$this->usuarios = $user->find();
// Initialize Propel with the runtime configuration
Session::set('myDbName', 'dokeos_0001');
Propel::init(APP_PATH . 'config/propel/dokeos-conf.php');
$foro = ForumForumQuery::create();
$this->foros = $foro->find();
Session::set('myDbName', 'dokeos_main');
Propel::init(APP_PATH . 'config/propel/dokeos-conf.php');
$user = UserQuery::create();
$this->usuarios2 = $user->find();
}
开发者ID:raulito1500,项目名称:mdokeos,代码行数:14,代码来源:index_controller.php
示例15: _checkInviteTokenAndExec
function _checkInviteTokenAndExec($token, $func)
{
if (!empty($token)) {
$user = UserQuery::create()->findOneByActivateToken($token);
if ($user && $user->getRole() != 'pending') {
$func($user);
} else {
// this is not a valid token!
$page['alert'] = array('type' => 'error', 'message' => __('The invitation token is invalid.'));
global $app;
$app->redirect('/');
}
}
}
开发者ID:Halfnhav4,项目名称:datawrapper,代码行数:14,代码来源:activate.php
示例16: resetRequest
public function resetRequest($sUserNameOrPassword, $bForce)
{
if ($sUserNameOrPassword === '') {
throw new LocalizedException('flash.login.username_or_email_required');
}
$oUser = UserQuery::create()->filterByUsername($sUserNameOrPassword)->findOne();
$bShowUserName = false;
if ($oUser === null) {
$oUser = UserQuery::create()->filterByEmail($sUserNameOrPassword)->findOne();
$bShowUserName = true;
}
if ($oUser) {
LoginManager::sendResetMail($oUser, $bShowUserName, null, $bForce);
}
}
开发者ID:rapila,项目名称:cms-base,代码行数:15,代码来源:LoginWindowWidgetModule.php
示例17: setUser
protected function setUser($reddit_id, $name)
{
$query = new UserQuery();
$users = $query->findByRedditID($reddit_id);
$user = null;
if ($users->count() == 0) {
$user = new User();
$user->setUsername($name);
$user->setRedditID($reddit_id);
$user->save();
} else {
$user = $users->getFirst();
}
if ($user->getBanned()) {
// We block banned users by just not letting them log in
session_destroy();
return null;
} else {
$_SESSION[Auth::$SESSION_USER_ID] = $user->getId();
//Record login
UserAccess::addUserEvent($user, $_SERVER['REMOTE_ADDR'], UserAccessType::login);
return $user;
}
}
开发者ID:pcmasteratings,项目名称:site,代码行数:24,代码来源:AAuthProvider.php
示例18: initUser
/**
* initializes a new user or creates a guest user if not logged in
*/
protected function initUser()
{
if (isset($_SESSION['dw-user-id']) && (isset($_SESSION['persistent']) || isset($_SESSION['last_action_time']))) {
if (isset($_SESSION['persistent']) && $_SESSION['persistent'] || isset($_SESSION['last_action_time']) && time() - $_SESSION['last_action_time'] < 1800) {
$this->user = UserQuery::create()->limit(1)->findPK($_SESSION['dw-user-id']);
$_SESSION['last_action_time'] = time();
}
}
if (empty($this->user)) {
// create temporary guest user for this session
$user = new User();
$user->setEmail('[email protected]');
$user->setRole('guest');
$user->setLanguage(self::getBrowserLocale());
$this->user = $user;
}
}
开发者ID:elaOnMars,项目名称:datawrapper,代码行数:20,代码来源:DatawrapperSession.php
示例19: setAccountSuspensionAndDeletionStatus
/**
* @param $suspensionInDays
* @param $softDelete
* @param $userId
* @return bool
*/
public static function setAccountSuspensionAndDeletionStatus($suspensionInDays, $softDelete, $userId)
{
if ($suspensionInDays > 0) {
$suspensionTime = time() + $suspensionInDays * 60 * 60 * 24;
} else {
$suspensionTime = null;
}
// FYI "on" is what a checkbox delivers by default when submitted. Didn't know that for a long time :)
$delete = $softDelete == "on" ? 1 : 0;
$user = UserQuery::create()->findPk($userId);
$user->setUserSuspensionTimestamp($suspensionTime);
$user->setUserDeleted($delete);
$user->save();
if ($user) {
Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_SUSPENSION_DELETION_STATUS'));
return true;
}
return true;
}
开发者ID:KyleGoslan,项目名称:Huge-Propel,代码行数:25,代码来源:AdminModel.php
示例20: initializeRootPage
private static function initializeRootPage()
{
$oRootPage = new Page();
$oRootPage->makeRoot();
$oRootPage->setName('root');
$oRootPage->setIsInactive(false);
$oRootPage->setPageType('default');
$oRootPage->setTemplateName(null);
$oFirstUser = UserQuery::create()->findOne();
$oFirstUserId = $oFirstUser !== null ? $oFirstUser->getId() : 0;
$oRootPage->setCreatedBy($oFirstUserId);
$oRootPage->setUpdatedBy($oFirstUserId);
$sPageString = new PageString();
$sPageString->setLanguageId(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, 'de'));
$sPageString->setPageTitle('Home');
$sPageString->setIsInactive(false);
$oRootPage->addPageString($sPageString);
$oRootPage->save();
return $oRootPage;
}
开发者ID:rapila,项目名称:cms-base,代码行数:20,代码来源:PagesAdminModule.php
注:本文中的UserQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论