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