本文整理汇总了PHP中UserQuery类的典型用法代码示例。如果您正苦于以下问题:PHP UserQuery类的具体用法?PHP UserQuery怎么用?PHP UserQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
示例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;
}
示例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();
}
示例5: getUser
public static function getUser()
{
if (isset($_SESSION['user']) && $_SESSION['user'] != '' && ($user = UserQuery::create()->findOneByUUID($_SESSION['user']))) {
return $user;
}
return null;
}
示例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('со всеми проектами всё ок');
}
}
示例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;
}
示例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.');
}
}
示例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');
}
示例10: emailExists
public function emailExists()
{
$user = UserQuery::create()->findOneByEmail($this->getEmail());
if ($user) {
return true;
}
return false;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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();
}
示例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('/');
}
}
}