public function executeEdit(sfWebRequest $request) { //Get user Id $userId = $this->getUser()->getGuardUser()->getId(); $sf_guard_user = sfGuardUserTable::getInstance()->findOneById($userId); $this->form = new sfGuardUserForm($sf_guard_user); }
public function save(Doctrine_Connection $conn = null) { if (is_null($this->_get('username')) && is_null($this->_get('email_address'))) { return; //throw new sfException('Cannot save User with null username and email!'); } if ($this->isNew() && sfGuardUserTable::getIfValidatedUserHasUsername($this->_get('username'))) { throw new sfException('Cannot save user. This username has already been validated with another user.'); } if (!$this->isNew() && in_array('is_validated', $this->_modified) && !$this->_get('is_validated')) { /* The user has been un-validated, probably due to changing their * Reddit validation key by username or password. We need to send * them an email about it. */ $parameters = array('user_id' => $this->getIncremented()); $prefer_html = $this->getPreferHtml(); $address = $this->getEmailAddress(); $name = $this->getPreferredName() ? $this->getPreferredName() : $this->getFullName(); $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage('ChangeRedditKey', $this->getPreferredLanguage()); $subject = $email->generateSubject($parameters); $body = $email->generateBodyText($parameters, $prefer_html); $from = sfConfig::get('app_email_address', ProjectConfiguration::getApplicationName() . ' <' . ProjectConfiguration::getApplicationEmailAddress() . '>'); AppMail::sendMail($address, $from, $subject, $body, $prefer_html ? $body : null); $this->addLoginMessage('You have changed information relating to your Reddit user and will need to validate your Reddit username again. Please see your email for more information.'); } parent::save($conn); }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true); $context = sfContext::createInstance($applicationConfig); // Go to the Subreddit and obtain the past few keys. $reddit_location = $options['subreddit']; $reddit = new RedditObject($reddit_location); $quiet = (bool) $options['quiet']; if (!$quiet) { echo "Obtaining the most recent comments from {$reddit_location}..."; } $reddit->appendData(); $found_keys = count($reddit->getComments()); if (!$quiet) { echo "\nFound {$found_keys} keys. Updating keys in the database..."; } ValidationTable::getInstance()->storeNewKeys($reddit->getComments()); // Now that new keys are stored in the database we need to update all applicable users $users = sfGuardUserTable::getInstance()->getUsersToBeValidated(); $updated = sfGuardUserTable::getInstance()->validateUsers($users); if (!$quiet) { echo "\nSending emails..."; } foreach ($users as $user_id) { $sf_user = $context->getUser(); $sf_user->setApiUserId($user_id); $sf_user->sendMail('RedditValidationSucceeded'); } if (!$quiet) { echo "\n{$updated} users validated and email sent.\n"; } }
public function setDynamicRules() { $context = $this->getContext(); $user = $context->getUser(); $request = $context->getRequest(); $module = $request->getParameter('module'); $action = $request->getParameter('action'); $cache = false; $lifetime = 0; $withLayout = false; //the following actions will not be hard cached when access is restricted to admins only $nuclearCachingExceptions = array('sfGuardAuth' => array('signin' => true), 'home' => array('contact' => true, 'join' => true, 'confirmed' => true, 'requested' => true, 'joined' => true, 'confirmEmail' => true, 'chat' => true)); //if access is restricted to admins only, pages not in the home module will be cached for a week if (sfConfig::get('app_login_admin_only') == 'on' && (!$user->isAuthenticated() || !sfGuardUserTable::isAdmin($user->getGuardUser()->id)) && !isset($nuclearCachingExceptions[$module][$action])) { $cache = true; $withLayout = true; $lifetime = self::WEEK_LIFETIME; } elseif ($lifetime = self::$alwaysCached[$module][$action]) { $cache = true; $withLayout = $request->isXmlHttpRequest() || !$user->isAuthenticated(); } elseif (!$user->isAuthenticated() && ($lifetime = self::$outsideCached[$module][$action])) { $cache = true; $withLayout = true; } elseif ($user->isAuthenticated() && ($lifetime = self::$insideCached[$module][$action])) { $cache = true; $withLayout = false; } if ($cache) { $context->getViewCacheManager()->addCache($module, $action, array('withLayout' => $withLayout, 'lifeTime' => $lifetime)); } }
public function getUserReserve() { if (isset($userReserve)) { return $userReserve; } return $userReserve = sfGuardUserTable::getInstance()->getUserById($this->getIdUserReserve())->fetchOne(); }
public function postValidateForm($validator, $values) { if (isset($values['promo_code'])) { $promo_code = PromoCodeTable::getInstance()->findOneByCode($values['promo_code']); if (!$promo_code) { throw new sfValidatorError($validator, 'Promotion Code is invalid'); } else { $values['account_type'] = $promo_code->account_type; } } /** @var sfGuardUser $user */ $user = sfGuardUserTable::getInstance()->createQuery('u')->where('u.email_address = ?', $values['email_address'])->fetchOne(); if ($user && $values['password']) { if ($user->getIsActive() && $user->checkPassword($values['password'])) { sfContext::getInstance()->getUser()->signIn($user); sfContext::getInstance()->getController()->redirect('/project'); } else { throw new sfValidatorError($validator, 'The email and/or password is invalid'); } } $email = $values['email_address']; $domain = strtolower(substr($email, strpos($email, '@') + 1)); if (DomainTable::getInstance()->findOneBy('name', $domain)) { $error = new sfValidatorError($validator, 'That looks like a personal email address. Please use your company email.'); throw new sfValidatorErrorSchema($validator, array('email_address' => $error)); } return $values; }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $applicationConfig = sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true); $context = sfContext::createInstance($applicationConfig); $one_day_users = sfGuardUserTable::getInstance()->getOneDayEmailReminders(); $one_week_users = sfGuardUserTable::getInstance()->getOneWeekEmailReminders(); $quiet = (bool) $options['quiet']; if (!$quiet) { echo "Sending one-day reminder emails to " . count($one_day_users) . " users..."; } foreach ($one_day_users as $user) { $sf_user = $context->getUser(); $sf_user->setApiUserId($user->getIncremented()); $sf_user->sendMail('RegisterOneDay'); } if (!$quiet) { echo "\nSending one-week reminder emails to " . count($one_week_users) . " users..."; } foreach ($one_week_users as $user) { $sf_user = $context->getUser(); $sf_user->setApiUserId($user->getIncremented()); $sf_user->sendMail('RegisterOneWeek'); } if (!$quiet) { echo "\n"; } }
static function clearUserCacheById($id) { if (!self::isCacheEnabled()) { return null; } $name = sfGuardUserTable::getPublicNameById($id); return self::clearUserCacheByName($name); }
public function executeImportTrello(sfWebRequest $request) { $this->external_ids = array(); $external_decisions = DecisionTable::getInstance()->createQuery('d')->select('d.external_id')->where('d.external_id IS NOT NULL')->andWhereIn('d.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($this->getUser()->getGuardUser()))->fetchArray(); foreach ($external_decisions as $external_decision) { $this->external_ids[] = $external_decision['external_id']; } }
public function executeIndex(sfWebRequest $request) { if ($this->getUser()->isAuthenticated() && $this->getUser()->getGuardUser()->account_type != 'Trial') { $this->getUser()->setFlash('notice', 'You are already registered and signed in!'); $this->redirect('/project'); } if ($this->getUser()->isAuthenticated()) { $user = $this->getUser()->getGuardUser(); $user->email_address = ''; $user->account_type = 'Free'; $this->form = new sfGuardRegisterForm($user); } else { $this->form = new sfGuardRegisterForm(); if ($this->getUser()->getAttribute('google_token')) { $google_token = json_decode($this->getUser()->getAttribute('google_token')); $browser = new sfWebBrowser(array(), null, array('ssl_verify_host' => false, 'ssl_verify' => false)); $result = $browser->get('https://www.googleapis.com/oauth2/v1/userinfo?access_token=' . $google_token->access_token); if ($result->getResponseCode() == 200) { $response_text = json_decode($result->getResponseText()); if (property_exists($response_text, 'email')) { $user_exists = sfGuardUserTable::getInstance()->createQuery('u')->where('email_address = ?', $response_text->email)->fetchOne(); if (is_object($user_exists)) { $this->getUser()->setAttribute('google_token', null); if ($user_exists->is_active) { $this->getUser()->signIn($user_exists); $this->redirect('/project'); } else { $this->getUser()->setFlash('notice', 'Check your e-mail! You should verify your email address.'); $this->redirect('@sf_guard_signin'); } } $this->getUser()->setAttribute('google_token_info', array($response_text->email => array('given_name' => $response_text->given_name, 'family_name' => $response_text->family_name))); $this->form->setDefault('email_address', $response_text->email); // $this->form->getWidget('email_address')->setAttribute('readonly', 'readonly'); } } } } if ($request->isMethod('post')) { $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $user = $this->form->save(); $google_token_info = $this->getUser()->getAttribute('google_token_info'); $this->getUser()->setAttribute('google_token', null); $this->getUser()->setAttribute('google_token_info', null); if (is_array($google_token_info) && array_key_exists($user->email_address, $google_token_info)) { $user->first_name = $google_token_info[$user->email_address]['given_name']; $user->last_name = $google_token_info[$user->email_address]['family_name']; $user->is_active = true; @$user->save(); $this->getUser()->signIn($user); $this->redirect('/project'); } else { $this->sendConfirmationEmail($user); } } } }
public function verifyUnique($validator, $values) { if (sfGuardUserTable::getInstance()->findOneBy('email_address', $values['email_address'])) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url')); $error = new sfValidatorError($validator, 'You are already registered, maybe you <a href="' . url_for('@sf_guard_forgot_password') . '">Forgot the password</a>?'); throw new sfValidatorErrorSchema($validator, array('email_address' => $error)); } return $values; }
public function executeList() { $filter_form = new FilterUserForm(); $filter_form->bindSelf('user'); $this->form = $filter_form; $page = isset($this->page) ? $this->page : 1; $query = $filter_form->filter(sfGuardUserTable::getInstance()->queryAll($this->getUser()->isSuperAdmin())); $this->users = new policatPager($query, $page, 'user_pager', array(), true, 20); }
public function executeSearch($request) { $page = $request->getParameter('page', 1); $num = $request->getParameter('num', 20); $this->query = $request->getParameter('query'); $s = new LsSphinxClient($page, $num); $s->setFilter('visible_to_user_ids', array_unique(array(0, sfGuardUserTable::getCurrentUserId()))); $this->note_pager = NoteTable::getSphinxPager($s, $this->query, Doctrine::HYDRATE_ARRAY); }
/** * @param sfGuardUser $user */ private function load_data(sfGuardUser $user) { $rows = $this->createQuery('il')->whereIn('il.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($user))->fetchArray(); $this->data = array(); foreach ($rows as $row) { $this->data[$row['type']] = array('singular' => $row['singular'], 'plural' => $row['plural']); } $this->loaded = true; }
public function configure() { $this->widgetSchema->setFormFormatterName('bootstrapInline'); $this->widgetSchema->setNameFormat('resign_officer[%s]'); $campaign = $this->getOption(self::OPTION_CAMPAIGN); $query = sfGuardUserTable::getInstance()->queryAdminsByCampaign($campaign); $this->setWidget('new', new sfWidgetFormDoctrineChoice(array('model' => 'sfGuardUser', 'query' => $query, 'method' => 'getFullName', 'label' => 'please select new one'))); $this->setValidator('new', new sfValidatorDoctrineChoice(array('model' => 'sfGuardUser', 'query' => $query))); }
public function executeListExportCsv(sfWebRequest $request) { $this->pDomainProfiles = DomainProfileTable::getInstance()->createQuery()->orderBy('created_at DESC')->execute(); $this->pOtherUsers = sfGuardUserTable::getInstance()->createQuery()->from('SfGuardUser s')->leftJoin('s.DomainProfiles d')->where('d.id IS NULL')->execute(); $this->setLayout('csv'); $this->getResponse()->clearHttpHeaders(); $this->getResponse()->setHttpHeader("Content-Type", 'text/plain'); $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename=DomainProfiles-' . date("Y-m-d") . '.txt;'); }
public function executeSignin($request) { $user = $this->getUser(); if ($user->isAuthenticated()) { return $this->redirect('@homepage'); } if ($request->getParameter('no_layout')) { $this->setLayout(false); } $this->form = new LoginForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('signin')); if ($this->form->isValid()) { $values = $this->form->getValues(); //check that email has been confirmed $profile = Doctrine::getTable('sfGuardUserProfile')->findOneByEmail($values['username']); if (!$profile->is_confirmed) { $request->setError('', "This email address hasn't been confirmed; check your inbox for an email with a confirmation link"); $this->getUser()->setAuthenticated(false); return sfView::SUCCESS; } if (!$profile->User->is_active) { $request->setError('', "This account is disabled; contact the system administrator"); $this->getUser()->setAuthenticated(false); return sfView::SUCCESS; } //if logins restricted to admins only, check that they have admin powers if (sfConfig::get('app_login_admin_only') == 'on') { if (!sfGuardUserTable::isAdmin($profile->user_id)) { $request->setError('', "Login has been disabled for non-administrators. Please try again later."); $this->getUser()->setAuthenticated(false); return sfView::SUCCESS; } } $remember = isset($values['remember']); $this->getUser()->signIn($values['user'], $remember); if (!($signinUrl = $request->getParameter('referer'))) { $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signinUrl', $user->getReferer($request->getReferer())); } $url = LsRouting::generateUrlForRedirect($signinUrl); return $this->redirect('' != $url ? $url : '@homepage'); } } else { if ($request->isXmlHttpRequest()) { $this->getResponse()->setHeaderOnly(true); $this->getResponse()->setStatusCode(401); return sfView::NONE; } $user->setReferer($request->getReferer()); $module = sfConfig::get('sf_login_module'); if ($this->getModuleName() != $module) { return $this->redirect($module . '/' . sfConfig::get('sf_login_action')); } } }
public function configure() { unset($this['lft'], $this['rgt'], $this['level'], $this['root_id'], $this['user_id'], $this['created_at'], $this['updated_at'], $this['folder_id'], $this['external_id']); $this->setValidator('name', new sfValidatorDecisionName(array('max_length' => 255, 'required' => true, 'user_id' => $this->getObject()->user_id, 'decision_id' => $this->getObject()->id))); if ($this->getOption('type') == 'edit') { unset($this['type_id'], $this['template_id']); } else { $this->widgetSchema['template_id'] = new sfWidgetFormChoice(array('choices' => array())); if (isset($this->getObject()->user_id) && !empty($this->getObject()->user_id)) { $this->widgetSchema['type_id']->setOption('query', DecisionTypeTable::getInstance()->createQuery('t')->innerJoin('t.Users u')->where('u.id = ?', $this->getObject()->user_id)); } else { $this->widgetSchema['type_id']->setOption('query', DecisionTypeTable::getInstance()->createQuery('t')); } $this->widgetSchema->setLabel('template_id', 'Template name'); // One response is for dashboard by default if ($this->getObject()->Response->count() > 1) { $this->widgetSchema['template_id']->setAttribute('disabled', 'disabled'); $this->widgetSchema->setHelp('template_id', 'Remove all responses first'); } $this->validatorSchema['template_id']->setOption('required', false); } $this->widgetSchema['upload'] = new laWidgetFileUpload(array('module_partial' => 'decision/import')); $this->widgetSchema['assigned_to']->setOption('query', sfGuardUserTable::getInstance()->getUsersInTeamQuery($this->getObject()->getUser())); $this->widgetSchema['objective'] = new laWidgetFormCKEditor(array('config' => array('height' => '250px'))); $this->validatorSchema['assigned_to']->setOption('query', sfGuardUserTable::getInstance()->getUsersInTeamQuery($this->getObject()->getUser())); /** @var sfWidget $widget */ foreach ($this->widgetSchema->getFields() as $widget) { $widget->setAttribute('class', 'form-control autosave'); } /* Get all tags and create input field */ $tags = array(); foreach ($this->getObject()->getTagDecision() as $tag) { $tags[] = $tag->Tag->name; } $this->widgetSchema['tags'] = new sfWidgetFormInputText(array(), array('value' => implode(',', $tags), 'class' => 'tags_input', 'data-role' => 'tagsinput')); $start_date_native = $this->getObject()->getStartDate(); $end_date_native = $this->getObject()->getEndDate(); $end_data = new DateTime($this->getObject()->getEndDate()); $start_date = new DateTime($this->getObject()->getStartDate()); $this->widgetSchema['start_date'] = new sfWidgetFormInputText(array(), array('value' => '', 'data-value' => !empty($start_date_native) && $start_date_native !== '0000-00-00 00:00:00' ? $start_date->format('Y/m/j') : '')); $this->widgetSchema['end_date'] = new sfWidgetFormInputText(array(), array('value' => '', 'data-value' => !empty($end_date_native) && $end_date_native !== '0000-00-00 00:00:00' ? $end_data->format('Y/m/j') : '')); $this->widgetSchema['color'] = new sfWidgetFormSelect(array('choices' => array('#FFFFFF' => '#FFFFFF', '#CCCCCC' => '#CCCCCC', '#A0522D' => '#A0522D', '#CD5C5C' => '#CD5C5C', '#FF4500' => '#FF4500', '#008B8B' => '#008B8B', '#B8860B' => '#B8860B', '#32CD32' => '#32CD32', '#FFD700' => '#FFD700', '#48D1CC' => '#48D1CC', '#87CEEB' => '#87CEEB', '#FF69B4' => '#FF69B4', '#87CEFA' => '#87CEFA', '#6495ED' => '#6495ED', '#DC143C' => '#DC143C', '#FF8C00' => '#FF8C00', '#C71585' => '#C71585', '#000000' => '#000000'))); if ($this->isNew()) { $this->widgetSchema['assigned_to']->setDefault($this->getObject()->getUser()->getId()); $now = new DateTime(); $this->widgetSchema['start_date']->setDefault($now->format('Y/m/j')); $this->widgetSchema['start_date']->setAttribute('data-value', $now->format('Y/m/j')); $now = $now->modify('+1 month'); $this->widgetSchema['end_date']->setDefault($now->format('Y/m/j')); $this->widgetSchema['end_date']->setAttribute('data-value', $now->format('Y/m/j')); } $this->disableCSRFProtection(); }
public function configure() { parent::configure(); $this->useFields(array('name', 'enable_advanced', 'users_list')); $user_list_options = array('model' => 'sfGuardUser', 'order_by' => array('first_name', 'ASC'), 'renderer_class' => 'izarusWidgetFormBootstrapSelectDoubleList', 'renderer_options' => array('label_unassociated' => 'No asociados', 'label_associated' => 'Asociados')); if (method_exists(sfGuardUserTable::getInstance(), 'AdvancedLayoutList')) { $user_list_options['table_method'] = 'AdvancedLayoutList'; } $this->widgetSchema['users_list'] = new sfWidgetFormDoctrineChoice($user_list_options); $this->widgetSchema->setLabels(array('name' => 'Nombre', 'enable_advanced' => 'Personalización Activada', 'users_list' => 'Usuarios con este permiso')); $this->widgetSchema->setHelps(array('enable_advanced' => 'Si está activada esta opción entonces será posible utilizar este permiso como Perfil de Acceso.')); }
public function getUserResponse(sfGuardUser $user) { $request = $this->getRequest(); if ($user->is_super_admin && $request->hasParameter('user_id')) { $request_user = sfGuardUserTable::getInstance()->find($request->getParameter('user_id')); if ($request_user) { return array('status' => 'success', 'result' => array('user_id' => $request_user->id, 'email' => $request_user->email_address, 'account_type' => $request_user->account_type)); } else { return array('status' => 'error', 'error' => 'User not found'); } } return array('status' => 'success', 'result' => array('user_id' => $user->id, 'email' => $user->email_address, 'account_type' => $user->account_type)); }
public function postUp() { $types = DecisionTypeTable::getInstance()->findAll(); $users = sfGuardUserTable::getInstance()->findAll(); foreach ($types as $type) { foreach ($users as $user) { $userType = new UserDecisionType(); $userType->Type = $type; $userType->User = $user; $userType->save(); } } }
public function executeUser($request) { $id = $request->getParameter("id"); $user = sfGuardUserTable::getInstance()->retrieveByUsernameOrEmailAddress($id); $this->forward404Unless($user); $hosts = array(); foreach ($user->getDomainProfiles() as $domain_profile) { $hosts[] = $domain_profile->getUrl(); } $lDm = MongoManager::getStatsDM(); $this->activities = $lDm->createQueryBuilder("Documents\\AnalyticsActivity")->field("host")->in($hosts)->sort(array("date" => -1))->limit(10)->getQuery()->execute(); $this->user = $user; $this->setLayout("atom_layout"); }
public function executeVerify(sfWebRequest $request) { $key = $request->getParameter('key'); $user = sfGuardUserTable::getInstance()->findOneBy('email_authorization_key', $key); $this->forward404Unless($key && $user); $user->setIsAuthorized(true); $user->setAuthorizedAt(date('Y-m-d H:i:s')); $user->save(); $this->getUser()->setApiUserId($user->getIncremented()); $this->getUser()->sendMail('RegisterRedditPost'); $this->getUser()->setFlash('notice', 'Your email address has been validated! While you can technically log in you can\'t yet do much of anything. You should have one final email waiting for you with your final instructions to get you started.'); $this->getUser()->setFlash('email_link', $user->getEmailAddress()); $this->redirect('@sf_guard_signin'); }
public function configure() { unset($this['lft'], $this['rgt'], $this['level'], $this['root_id'], $this['decision_id'], $this['files_list'], $this['created_at'], $this['updated_at'], $this['created_by'], $this['updated_by'], $this['type_id'], $this['item_id']); $this->widgetSchema['notes'] = $this->widgetSchema['additional_info'] = new laWidgetFormCKEditor(array('config' => array('height' => '75px'))); $this->widgetSchema['upload'] = new laWidgetFileUpload(); $this->widgetSchema['work_progress'] = new sfWidgetFormInputRange(array('min' => 0, 'max' => 100)); /** @var sfWidget $widget */ foreach ($this->widgetSchema->getFields() as $widget) { $widget->setAttribute('class', 'form-control'); } /* Get all tags and create input field */ $tags = array(); foreach ($this->getObject()->getTagAlternative() as $tag) { $tags[] = $tag->Tag->name; } $this->widgetSchema['tags'] = new sfWidgetFormInputText(array(), array('value' => implode(',', $tags), 'class' => 'tags_input', 'data-role' => 'tagsinput')); /* Create field with relations */ $related_alternatives_choices = array(); if ($this->getOption('user')) { foreach (AlternativeTable::getInstance()->getListForUser($this->getOption('user')->getGuardUser()) as $alternative) { $related_alternatives_choices[$alternative->getId()] = $alternative->getName() . ' (' . $alternative->getDecision()->getName() . ')'; } } unset($related_alternatives_choices[$this->getObject()->getId()]); $related_alternatives_default = array(); foreach ($this->getObject()->getAlternativeRelation() as $related_alternative) { $related_alternatives_default[] = $related_alternative->to_id; } $this->widgetSchema['related_alternatives'] = new sfWidgetFormSelectMany(array('choices' => $related_alternatives_choices)); $this->widgetSchema['related_alternatives']->setDefault($related_alternatives_default); $notify_date_native = $this->getObject()->getNotifyDate(); $due_date_native = $this->getObject()->getDueDate(); $due_data = new DateTime($this->getObject()->getDueDate()); $notify_date = new DateTime($this->getObject()->getNotifyDate()); $this->widgetSchema['notify_date'] = new sfWidgetFormInputText(array(), array('value' => '', 'data-value' => !empty($notify_date_native) && $notify_date_native !== '0000-00-00 00:00:00' ? $notify_date->format('Y/m/j') : '')); $this->widgetSchema['due_date'] = new sfWidgetFormInputText(array(), array('value' => '', 'data-value' => !empty($due_date_native) && $due_date_native !== '0000-00-00 00:00:00' ? $due_data->format('Y/m/j') : '')); if ($this->getOption('user')) { $assigned_to = array('' => ''); $team_users = sfGuardUserTable::getInstance()->getUsersInTeamQuery($this->getOption('user')->getGuardUser())->execute(); foreach ($team_users as $team_user) { $assigned_to[$team_user->getId()] = $team_user->getUserName(); } $this->widgetSchema['assigned_to'] = new sfWidgetFormChoice(array('choices' => $assigned_to), array('class' => 'form-control')); if ($this->getObject()->isNew()) { $this->widgetSchema['assigned_to']->setDefault($this->getOption('user')->getGuardUser()->getId()); } } $this->disableCSRFProtection(); }
/** * Try to login with the CAS server */ public function login() { sfCAS::initPhpCAS(); phpCAS::forceAuthentication(); $username = phpCAS::getUser(); $data = sfGuardUserTable::getInstance()->findOneBy('username', $username); if (!$data || $data->getPassword() == NULL && !$data->getIsActive()) { $data = $this->registerUser($username, $data); } if ($data) { $this->signin($data, false); } else { die('Unauthorized.'); } }
public function isValid() { $valid = parent::isValid(); if ($valid) { $values = $this->getValues(); $this->user = sfGuardUserTable::getInstance()->findOneBy('email_address', $values['email_address']); if ($this->user) { return true; } else { return false; } } else { return false; } }
function user_pic($user, $size = 'small', $htmlOptions = array()) { //profile object needed to get internal url if (!$user['Profile']) { $user['Profile'] = LsDoctrineQuery::create()->from('sfGuardUserProfile p')->where('p.user_id = ?', $user['id'])->setHydrationMode(Doctrine::HYDRATE_ARRAY)->fetchOne(); } if ($fn = $user['Profile']['filename']) { $str = $size . DIRECTORY_SEPARATOR . $fn; } else { $str = 'system' . DIRECTORY_SEPARATOR . 'user.png'; } $htmlOptions = array_merge(array('alt' => $user['Profile']['public_name'], 'style' => 'border: 0;'), $htmlOptions); $link = link_to(image_tag($str, $htmlOptions), sfGuardUserTable::getInternalUrl($user)); return $link; }
/** * @param sfGuardUser $user * @param string $type * @return mixed|string|void */ public function getForUserJSON(sfGuardUser $user, $type = 'project') { /** @var Folder[] $folders */ $query = $this->createQuery('f'); if ($type == 'project') { $query->leftJoin('f.Decisions d'); } else { $query->leftJoin('f.Roadmaps r'); } $query->leftJoin('f.User u')->leftJoin('u.TeamMember tm')->whereIn('f.user_id', sfGuardUserTable::getInstance()->getUsersInTeamIDs($user))->andWhere('f.type = ?', $type); $folders = $query->execute(); $result = array(); foreach ($folders as $folder) { $result[] = $folder->getRowData($type); } return json_encode($result); }
public function executeRecordSample() { $model = isset($this->model) ? $this->model : get_class($this->record); $this->actions = array(array('text' => 'see all', 'url' => $this->more_uri ? $this->more_uri : $this->record->getInternalUrl('notes'))); if ($this->getUser()->isAuthenticated()) { $class = $model == 'LsList' ? 'List' : $model; $this->actions[] = array('text' => 'write a note', 'url' => 'home/notes?compose=1&' . strtolower($class) . '_id=' . $this->record['id']); $this->actions[] = array('text' => 'note all', 'credential' => 'editor', 'url' => 'home/notes?compose=1&analysts=1&' . strtolower($class) . '_id=' . $this->record['id']); } $attribute = strtolower($model) . '_ids'; $s = new LsSphinxClient(1, 5); $s->setFilter($attribute, array($this->record['id'])); if (!($currentUserId = sfGuardUserTable::getCurrentUserId())) { $currentUserId = 0; } $s->setFilter('visible_to_user_ids', array_unique(array(0, $currentUserId))); $this->notes = NoteTable::getSphinxRecords($s, null, Doctrine::HYDRATE_ARRAY); }
public function executeResetRequest(sfRequest $request) { $user = $this->getUser(); if ($user->isAuthenticated()) { $guardUser = $this->getUser()->getGuardUser(); $this->forward404Unless($guardUser); return $this->resetRequestBody($guardUser); } else { $this->form = $this->newForm('sfApplyResetRequestForm'); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('sfApplyResetRequest')); if ($this->form->isValid()) { $user = sfGuardUserTable::retrieveByUsername($this->form->getValue('username')); return $this->resetRequestBody($user); } } } }