/** * @depends testNotifierExists * @depends testConcreteNotificationExists */ public function testNotify() { /* @var $user sfGuardUser */ $user = sfGuardUserPeer::retrieveByUsername('Username'); $this->assertInstanceOf('sfGuardUser', $user); /* @var $type NotificationType */ $type = NotificationTypePeer::retrieveByName('SimpleFile'); $this->assertInstanceOf('NotificationType', $type); $criteria = new Criteria(NotificationConfigurationPeer::DATABASE_NAME); $criteria->add(NotificationConfigurationPeer::NAME, 'Sample Configuration for SimpleFile'); $criteria->add(NotificationConfigurationPeer::NOTIFICATION_TYPE_ID, $type->getId()); $criteria->add(NotificationConfigurationPeer::USER_ID, $user->getId()); /* @var $configuration NotificationConfiguration */ $configuration = NotificationConfigurationPeer::doSelectOne($criteria); $this->assertInstanceOf('NotificationConfiguration', $configuration); $this->assertTrue($configuration->hasAttribute('filename')); $notification = new TestConcreteNotification(); $notification->setNotificationConfiguration($configuration); $data = array('Simple array', 'to put into a file.'); $notification->notify($data); $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'simple_notifications.log'; $content = file($filename); $this->assertEquals($data, unserialize($content[0])); unlink($filename); }
protected function doClean($values) { $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : ''; $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : ''; $remember = isset($values[$this->getOption('rememeber_checkbox')]) ? $values[$this->getOption('rememeber_checkbox')] : ''; $session_user = sfContext::getInstance()->getUser(); // user exists? if ($user = sfGuardUserPeer::retrieveByUsername($username)) { // password is ok? if ($user->checkPassword($password)) { /* Added for sfGuardSecurity */ $this->checkForceRedirectPasswordChange($user); $session_user->setAttribute('sf_guard_secure_plugin_login_failure_detected', 0); /* end */ return array_merge($values, array('user' => $user)); } } if ($this->getOption('check_login_failure')) { /* Added for sfGuardSecurity */ sfGuardLoginFailure::trackFailure($username); $this->checkSecurityAttack($username); /* end */ } if ($this->getOption('throw_global_error')) { throw new sfValidatorError($this, 'invalid'); } throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid'))); }
/** * @see sfValidatorBase */ protected function doClean($values) { // only validate if username and password are both present if (isset($values[$this->getOption('username_field')]) && isset($values[$this->getOption('password_field')])) { $username = $values[$this->getOption('username_field')]; $password = $values[$this->getOption('password_field')]; // user exists? if ($user = sfGuardUserPeer::retrieveByUsername($username)) { // password is ok? if ($user->getIsActive()) { if (Configuration::get('ldap_enabled', false)) { if (authLDAP::checkPassword($username, $password)) { return array_merge($values, array('user' => $user)); } } elseif ($user->checkPassword($password)) { return array_merge($values, array('user' => $user)); } } } elseif (Configuration::get('ldap_enabled', false) && Configuration::get('ldap_create_user', false) && authLDAP::checkPassword($username, $password)) { $user = new sfGuardUser(); $user->setUsername($username); $user->save(); $profile = new Profile(); $profile->setSfGuardUserId($user->getId()); $profile->save(); return array_merge($values, array('user' => $user)); } if ($this->getOption('throw_global_error')) { throw new sfValidatorError($this, 'invalid'); } throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid'))); } // assume a required error has already been thrown, skip validation return $values; }
public static function retrieveByUsername($value) { $user = sfGuardUserPeer::retrieveByUsername($value); if ($user != null) { return $user->getProfile(); } return null; }
/** * Executes this filter. * * @param sfFilterChain $filterChain A sfFilterChain instance */ public function execute($filterChain) { if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { sfContext::getInstance()->getUser()->signin(sfGuardUserPeer::retrieveByUsername('fabriceb')); } else { sfFacebook::requireLogin(); } parent::execute($filterChain); }
public function execute(&$value, &$error) { sfPropelApprovableBehavior::disable(); if (sfGuardUserPeer::retrieveByUsername($value) != null) { $error = $this->getParameter('user_unique_error', "*This email is already registered with us. Did you need to <strong>reset your password</strong>?"); return false; } return true; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $user = sfGuardUserPeer::retrieveByUsername($arguments['username']); if (!$user) { throw new sfCommandException(sprintf('User "%s" does not exist.', $arguments['username'])); } $user->addPermissionByName($arguments['permission']); $this->logSection('guard', sprintf('Add permission %s to user %s', $arguments['permission'], $arguments['username'])); }
public function execute(&$value, &$error) { sfPropelApprovableBehavior::disable(); if (sfGuardUserPeer::retrieveByUsername($value) == false) { $error = $this->getParameter('user_error'); $error = "Sorry, couldn't find {$value} in our records - probably means no one signed up using this name."; return false; } return true; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $user = sfGuardUserPeer::retrieveByUsername($arguments['username']); if (!$user) { throw new sfCommandException(sprintf('User "%s" does not exist.', $arguments['username'])); } $user->setIsSuperAdmin(true); $user->save(); $this->logSection('guard', sprintf('Promote user %s as a super administrator', $arguments['username'])); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $user = sfGuardUserPeer::retrieveByUsername($arguments['username']); if (!$user) { throw new sfCommandException(sprintf('User "%s" does not exist.', $arguments['username'])); } $user->setPassword($arguments['password']); $user->save(); $this->logSection('guard', sprintf('Password changed successfully for user %s', $arguments['username'])); }
public function save($con = null) { if ($this->getUserId() == null) { if (sfContext::getInstance()->getUser()->isAuthenticated()) { $this->setUserId(sfContext::getInstance()->getUser()->getId()); } else { $user = sfGuardUserPeer::retrieveByUsername('admin'); $this->setUserId($user->getId()); } } parent::save(); }
public function executeViewProfile() { $username = $this->getRequestParameter('username'); $this->user = sfGuardUserPeer::retrieveByUsername($username); $c = new Criteria(); $c->add(SnippetPeer::USER_ID, $this->user->getId()); $c->add(SnippetPeer::DRAFT, false); $this->snippet_count = SnippetPeer::doCount($c); $this->pager = new sfPropelPager('Snippet', sfConfig::get('app_pager', 10)); $this->pager->setCriteria($c); $this->pager->setPage($this->getRequestParameter('page', 1)); $this->pager->init(); }
public function execute(&$value, &$error) { $password_field = $this->getParameterHolder()->get('password_field'); $password = $this->getContext()->getRequest()->getParameter($password_field); $remember = false; $remember_field = $this->getParameterHolder()->get('remember_field'); $remember = $this->getContext()->getRequest()->getParameter($remember_field); $username = $value; $authMessage = ''; $TEST_MODE = sfConfig::get('app_stKerberosPlugin_skip_auth', false); if ($TEST_MODE !== true && !extension_loaded('krb5')) { if (!@dl('krb5.so')) { $error = "{netid_auth} krb5 extension unavailable"; if (sfConfig::get('sf_logging_enabled')) { sfContext::getInstance()->getLogger()->alert($error); } return false; } } if ($TEST_MODE === true && !extension_loaded('krb5')) { $kerb_constants = array('KRB5_OK', 'KRB5_NOTOK', 'KRB5_BAD_PASSWORD', 'KRB5_BAD_USER'); foreach ($kerb_constants as $k => $v) { define($v, 100 + $k); // arbitrarily assign a value to each constant } } // netid_auth will set authMessage with an error message // and may also set protected loginAs variable if (KRB5_OK === $this->netid_auth($username, $password, $authMessage)) { // get or retrieve the sf_guard user associated with this kerberos username $user = sfGuardUserPeer::retrieveByUsername($username); if ($user) { $this->getContext()->getUser()->signIn($user, $remember); // If this is an admin user and they logged in with two usernames, // reauthenticate as that second username. if ($this->loginAs !== false && $this->getContext()->getUser()->hasCredential(array('admin'), false)) { $otherUser = sfGuardUserPeer::retrieveByUsername($this->loginAs); if ($otherUser) { $this->getContext()->getUser()->signIn($otherUser, false); } } } else { // if there is no user create one $user = $this->createUserAndProfile($username); $this->getContext()->getUser()->signin($user, $remember); } return true; } $error = $this->getParameterHolder()->get('username_error', $authMessage); return false; }
public static function retrieveUserByEmail($email) { sfContext::getInstance()->getLogger()->info('checking to see if [' . $email . '] is a username...'); $user = sfGuardUserPeer::retrieveByUsername($email); if ($user != null) { return $user; } sfContext::getInstance()->getLogger()->info('checking to see if [' . $email . '] is in any contacts...'); $user = sfGuardUserProfilePeer::retrieveByEmail($email); if ($user != null) { return $user->getsfGuardUser(); } return $user; }
/** * @see sfValidatorBase */ protected function doClean($value) { $clean = $value; mysfLog::log($this, "{$clean}"); // check for active user if (sfGuardUserPeer::retrieveByUsername($clean, true)) { throw new sfValidatorError($this, 'used', array('value' => $value)); } // check for not active user if (sfGuardUserPeer::retrieveByUsername($clean, false)) { throw new sfValidatorError($this, 'used', array('value' => $value)); } return $clean; }
public function refreshCredentials() { $user = sfContext::getInstance()->getUser(); if ($user->isAuthenticated()) { $this->setAttribute('user_id', $user->getId(), 'sfGuardSecurityUser'); $this->setAuthenticated(true); $this->clearCredentials(); $this->addCredentials($user->getAllPermissionNames()); $this->clearCredentials(); $this->addCredentials($this->getAllPermissionNames()); $this->initialize($this->getContext()); $myUsername = $this->getUsername(); $this->signOut(); $user = sfGuardUserPeer::retrieveByUsername($myUsername); sfContext::getInstance()->getUser()->signIn($user); } }
protected function doClean($values) { $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : ''; $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : ''; $remember = isset($values[$this->getOption('rememeber_checkbox')]) ? $values[$this->getOption('rememeber_checkbox')] : ''; // user exists? if ($user = sfGuardUserPeer::retrieveByUsername($username)) { // password is ok? if ($user->checkPassword($password)) { return array_merge($values, array('user' => $user)); } } if ($this->getOption('throw_global_error')) { throw new sfValidatorError($this, 'invalid'); } throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid'))); }
protected function execute($arguments = array(), $options = array()) { $this->createContextInstance(); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); /** @var $connection PropelPDO */ $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $username = '******'; $date_from = '2013-11-23 00:00:00'; $date_to = '2013-11-23 23:59:59'; $class = 'CourseSubjectStudentMark'; /** @var $user sfGuardSecurityUser */ $user = sfContext::getInstance()->getUser(); $sf_user = sfGuardUserPeer::retrieveByUsername($username); $user->signin($sf_user, false); $connection->beginTransaction(); try { $c = new Criteria(); $c->add(ncChangeLogEntryPeer::CLASS_NAME, $class); $c->add(ncChangeLogEntryPeer::USERNAME, $username); $cri = $c->getNewCriterion(ncChangeLogEntryPeer::CREATED_AT, $date_from, Criteria::GREATER_EQUAL); $cri->addAnd($c->getNewCriterion(ncChangeLogEntryPeer::CREATED_AT, $date_to, Criteria::LESS_EQUAL)); $c->add($cri); $cambios = ncChangeLogEntryPeer::doSelect($c, $connection); /** @var $nc_change_log_entry ncChangeLogEntry */ foreach ($cambios as $nc_change_log_entry) { $obj = unserialize(base64_decode($nc_change_log_entry->getChangesDetail())); if (isset($obj['changes']) && isset($obj['changes']['mark'])) { $old = $obj['changes']['mark']['raw']['old']; $new = $obj['changes']['mark']['raw']['new']; $id = $obj['pk']; $mark = CourseSubjectStudentMarkPeer::retrieveByPK($id, $connection); $mark->setMark($old); $mark->save($connection); } } $connection->commit(); } catch (Exception $e) { $connection->rollBack(); $this->log($e->getMessage()); $this->log($e->getTraceAsString()); } }
public function execute(&$value, &$error) { $password_field = $this->getParameterHolder()->get('password_field'); $password = $this->getContext()->getRequest()->getParameter($password_field); $remember = false; $remember_field = $this->getParameterHolder()->get('remember_field'); $remember = $this->getContext()->getRequest()->getParameter($remember_field); $username = $value; $user = sfGuardUserPeer::retrieveByUsername($username); // user exists? if ($user) { // password is ok? if ($user->checkPassword($password)) { $this->getContext()->getUser()->signIn($user, $remember); return true; } } $error = $this->getParameterHolder()->get('username_error'); return false; }
/** * @see sfValidatorBase */ protected function doClean($values) { // only validate if username and password are both present if (isset($values[$this->getOption('username_field')]) && isset($values[$this->getOption('password_field')])) { $username = $values[$this->getOption('username_field')]; $password = $values[$this->getOption('password_field')]; // user exists? if ($user = sfGuardUserPeer::retrieveByUsername($username)) { // password is ok? if ($user->checkPassword($password)) { return array_merge($values, array('user' => $user)); } } if ($this->getOption('throw_global_error')) { throw new sfValidatorError($this, 'invalid'); } throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid'))); } // assume a required error has already been thrown, skip validation return $values; }
public function executeUserReports($request) { $username = $request->getParameter('username'); $this->forward404Unless($username); $user = sfGuardUserPeer::retrieveByUsername($username); $this->forward404Unless($user); $this->pager = ReportPeer::findByUserAndPublic($user->getId(), true, $request->getParameter('page', 1), 10); $this->setTemplate('listMyReports'); }
public function executeRegister() { $campus = CampusPeer::retrieveByEmail($this->getRequestParameter('register_email')); $department = DepartmentPeer::retrieveByUuid($this->getRequestParameter('department')); //$subdepartment = SubdepartmentPeer::retrieveByName('cognitive neuroscience'); if ($campus == null) { $campus = CampusPeer::retrieveByEmail("@public"); $this->logMessage("Campus was null, now set to ({$campus})"); } $this->forward404Unless($campus, 'campus not found'); $this->forward404Unless($department, 'department not found'); //$this->forward404Unless($subdepartment, 'subdepartment not found'); $user = new sfGuardUser(); // TODO: Implement form validation in validate.yml $user->setUsername($this->getRequestParameter('register_email')); $user->setPassword($this->getRequestParameter('register_password')); $user->save(); $this->user = $user->toArray(); $this->logMessage('USER_ARRAY: ' . print_r($this->user, true)); $this->username = $this->user['Username']; $this->logMessage('USER_NAME_VAR: ' . $this->username); sfPropelApprovableBehavior::disable(); $this->getRequest()->setAttribute('user_id', $user->getId()); $this->logMessage('Set user_id in attributes: [' . $user->getId() . ']:[' . $this->getRequest()->getAttribute('user_id') . ']'); //$temp_email = $this->sendEmail('messages', 'confirmRegistrationEmail'); // Generate a UUID for the user profile, done upon saving it $profile = $user->getProfile(); $profile->setUserId($user->getId()); $profile->setCampusId($campus->getId()); $profile->setDepartmentId($department->getId()); $profile->setFirstName($this->getRequestParameter('first_name')); $profile->setLastName($this->getRequestParameter('last_name')); $profile->setNoPicture(); $profile->setTitle('student'); $profile->setGender(sfConfig::get('app_profile_unknown')); //$profile->setSubdepartmentId($subdepartment->getId()); $profile->save(); $profile->getPrimaryContactInfo(); $profile->addHistoryEvent($profile->getFullName() . ' has joined the Cothink community.', "We would like to welcome you to Cothink, we know you'll work to make the world a better place!"); $profile->addKarma(sfConfig::get('app_karma_join_site_points')); // $register_email = $this->sendEmail('messages', 'sendConfirmRegistrationEmail'); sfPropelApprovableBehavior::disable(); $this->user = sfGuardUserPeer::retrieveByUsername('*****@*****.**'); /* $this->logMessage("Sending email confirmation"); $conn = new Swift_Connection_SMTP( sfConfig::get('mod_sfswiftmailer_smtp_host', 'localhost') ); // Need auth for SMTP $conn->setUsername( sfConfig::get('mod_sfswiftmailer_smtp_user') ); $conn->setPassword( sfConfig::get('mod_sfswiftmailer_smtp_pass') ); $mailer = new Swift($conn); // Get our message bodies $htmlBody = $this->getPresentationFor('messages', 'confirmRegistrationHtml'); $textBody = $this->getPresentationFor('messages', 'confirmRegistrationText'); //Create a message $message = new Swift_Message("Thank you for joining the Cothink community. Please confirm your email address to complete registration."); //Add some "parts" $message->attach(new Swift_Message_Part($textBody)); $message->attach(new Swift_Message_Part($htmlBody, "text/html")); // Send out our mailer $mailer->send($message, $this->username, '*****@*****.**'); $mailer->disconnect(); $this->logMessage("Email confirmation sent"); //return sfView:: SUCCESS; */ //return $this->redirect('user/pleaseConfirm?user='******'Username'])); return $this->redirect("@show_user_profile?user=" . $profile->getUuid()); }
<?php /** * Teste la sauvegarde d'équipes dans le backend * @author fabriceb * @since Feb 16, 2009 fabriceb */ include dirname(__FILE__) . '/../bootstrap/unit10.php'; //$app='frontend'; //include(dirname(__FILE__).'/../bootstrap/functional.php'); $sfGuardUser = sfGuardUserPeer::retrieveByUsername('test', false); if ($sfGuardUser) { $sfGuardUser->delete(); } $sfGuardUser = sfGuardUserPeer::retrieveByUsername('Facebook_9999999999', false); if ($sfGuardUser) { $sfGuardUser->delete(); } $t = new lime_test(5, new lime_output_color()); $t->diag('sfFacebookPropelGuardAdapter Tests'); $t->diag('sfFacebook::getGuardAdapter()->getProfilePeerClassName Test'); $t->is(sfFacebook::getGuardAdapter()->getProfilePeerClassName(), sfConfig::get('app_sf_guard_plugin_profile_class') . 'Peer'); $t->diag('sfFacebook::getGuardAdapter()->getSfGuardUserByFacebookUid Test'); $sfGuardUser = new sfGuardUser(); $sfGuardUser->setUsername('test'); sfFacebook::getGuardAdapter()->setUserFacebookUid($sfGuardUser, 9999999999.0); try { $con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME); $con->begin(); $sfGuardUser->save(); $sfGuardUser->getProfile()->save();
/** * Executes zebSandbox action * */ public function executeZebSandbox() { $this->forward404Unless($this->project_app = ProjectApplicationPeer::retrieveByPk('26')); $this->user = sfGuardUserPeer::retrieveByUsername('*****@*****.**'); }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $this->createContextInstance(); $username = '******'; $user = sfContext::getInstance()->getUser(); $sf_user = sfGuardUserPeer::retrieveByUsername($username); $user->signin($sf_user, false); $new_career_school_year_2014 = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK(8), SchoolYearPeer::retrieveCurrent()); $old_career_school_year_2013 = CareerSchoolYearPeer::retrieveByPk(21); $new_career_school_year_2013 = CareerSchoolYearPeer::retrieveByPk(22); $old_career_school_year_2014 = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear(CareerPeer::retrieveByPK(4), SchoolYearPeer::retrieveCurrent()); $last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear(SchoolYearPeer::retrieveCurrent()); // ---------------------------------------------------------------------------------------------- // // Alumnos que promueven 6to deben seguir en el plan viejo $this->log('1 -Alumnos que promueven 6to deben seguir en el plan viejo'); $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $old_career_school_year_2013->getId()); $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true); $c->add(StudentCareerSchoolYearPeer::YEAR, 6); $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED); $students_to_old_career_school_years = StudentCareerSchoolYearPeer::doSelect($c); try { $connection->beginTransaction(); foreach ($students_to_old_career_school_years as $socsy) { $shift = $socsy->getStudent()->getShiftForSchoolYear($last_year_school_year); if (!$socsy->getStudent()->getIsRegistered($old_career_school_year_2014->getSchoolYear())) { $socsy->getStudent()->registerToSchoolYear($old_career_school_year_2014->getSchoolYear(), $shift, $connection); } } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } // ---------------------------------------------------------------------------------------------- // // 2 - Resto de los alumnos que no son del CBFE van al plan nuevo en el año que les corresponda $this->log('2 - Resto de los alumnos que no son del CBFE van al plan nuevo en el año que les corresponda'); try { $connection->beginTransaction(); // con este criteria voy a excluir a los que aprueban 6to y deben ir a 7mo del plan viejo $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, $old_career_school_year_2013->getId()); $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true); $c->add(StudentCareerSchoolYearPeer::YEAR, 6); $c->add(StudentCareerSchoolYearPeer::STATUS, StudentCareerSchoolYearStatus::APPROVED); $c->clearSelectColumns(); $c->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID); $stmt = StudentCareerSchoolYearPeer::doSelectStmt($c); $students_to_old_career_school_years_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); // con este criteria voy a excluir a los que son del CBFE $c = new Criteria(); $c->add(StudentCareerSchoolYearPeer::CAREER_SCHOOL_YEAR_ID, 23); $c->add(StudentCareerSchoolYearPeer::IS_PROCESSED, true); $c->clearSelectColumns(); $c->addSelectColumn(StudentCareerSchoolYearPeer::STUDENT_ID); $stmt = StudentCareerSchoolYearPeer::doSelectStmt($c); $student_cbfe_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); // al total le saco $students_to_old_career_school_years_ids y los // student_cbfe_ids $c = new Criteria(); //$c = StudentCareerSchoolYearPeer::retrieveLastYearStudentNotGraduatedCriteria($new_career_school_year_2014); $c->add(StudentCareerSchoolYearPeer::YEAR, 7, Criteria::NOT_EQUAL); $c->addJoin(StudentCareerSchoolYearPeer::STUDENT_ID, StudentPeer::ID, Criteria::INNER_JOIN); $c->add(StudentPeer::ID, array_merge($students_to_old_career_school_years_ids, $student_cbfe_ids), Criteria::NOT_IN); $students = StudentPeer::doSelectActive($c); foreach ($students as $student) { $shift = $student->getShiftForSchoolYear($last_year_school_year); if (!$student->getIsRegistered($new_career_school_year_2014->getSchoolYear()) && $shift) { $slcsy = $student->getLastStudentCareerSchoolYear(); $slcs = $student->getLastCareerStudent(); if ($slcsy->getStatus() == StudentCareerSchoolYearStatus::APPROVED) { $start_year = $slcsy->getYear() + 1; } else { $start_year = $slcsy->getYear(); } if ($slcs->getCareerId() != $new_career_school_year_2014->getCareerId()) { $student->registerToCareer($new_career_school_year_2014->getCareer(), null, null, $start_year, $connection); $sys = new SchoolYearStudent(); $sys->setStudentId($student->getId()); $sys->setSchoolYearId($new_career_school_year_2014->getSchoolYear()->getId()); $sys->setShift($shift); $sys->save($connection); $this->verify($student, $new_career_school_year_2014, $connection); } else { $sys = new SchoolYearStudent(); $sys->setStudentId($student->getId()); $sys->setSchoolYearId($new_career_school_year_2014->getSchoolYear()->getId()); $sys->setShift($shift); $sys->save($connection); $this->verify($student, $new_career_school_year_2014, $connection); } if (!is_null($shift)) { $shift->clearAllReferences(true); } $student->clearAllReferences(true); unset($student); unset($shift); } StudentPeer::clearInstancePool(); unset($students); } $connection->commit(); } catch (PropelException $e) { $connection->rollBack(); throw $e; } }
public function validateResetRequest() { if ($this->getRequest()->getMethod() == sfRequest::POST) { $username = $this->getRequestParameter('username'); $this->sfGuardUser = sfGuardUserPeer::retrieveByUsername($username); if (!$this->sfGuardUser) { $this->getRequest()->setError('username', 'There is no account with that username.'); return false; } if (!$this->sfGuardUser->getIsActive()) { $this->getRequest()->setError('username', 'That account has not been activated.'); return false; } } return true; }