public function executePassword() { $this->form = new RequestPasswordForm(); if ($this->getRequest()->isMethod('get')) { return; } $this->form->bind($this->getRequest()->getParameter('form')); if (!$this->form->isValid()) { return; } $email = $this->form->getValue('email'); $password = substr(md5(rand(100000, 999999)), 0, 6); $sfGuardUserProfile = sfGuardUserProfilePeer::retrieveByEmail($email); $sfGuardUser = $sfGuardUserProfile->getSfGuardUser(); $sfGuardUser->setPassword($password); try { $connection = new Swift_Connection_SMTP('mail.sis-nav.com', 25); $connection->setUsername('*****@*****.**'); $connection->setPassword('gahve123'); $mailer = new Swift($connection); $message = new Swift_Message('Request Password'); $mailContext = array('email' => $email, 'password' => $password, 'username' => $sfGuardUser->getUsername(), 'full_name' => $sfGuardUserProfile->getFirstName()); $message->attach(new Swift_Message_Part($this->getPartial('mail/requestPasswordHtmlBody', $mailContext), 'text/html')); $message->attach(new Swift_Message_Part($this->getPartial('mail/requestPasswordTextBody', $mailContext), 'text/plain')); $mailer->send($message, $email, '*****@*****.**'); $mailer->disconnect(); } catch (Exception $e) { $mailer->disconnect(); } $sfGuardUser->save(); $this->getUser()->setFlash('info', 'A new password is sent to your email.'); $this->forward('site', 'message'); }
public function executeUpdate() { $task = TaskPeer::retrieveByUuid($this->getRequestParameter('task')); $this->forward404Unless($task); $this->forward404Unless($task->isAuthorized($this->getUser()->getId()), 'User not authorized to edit tasks for this project'); $project = $task->getProject(); $task->setName($this->getRequestParameter('name')); $task->setDescription($this->getRequestParameter('description')); if ($this->getRequestParameter('begin')) { list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('begin'), $this->getUser()->getCulture()); $task->setBegin("{$y}-{$m}-{$d}"); } if ($this->getRequestParameter('finish')) { list($d, $m, $y) = sfI18N::getDateForCulture($this->getRequestParameter('finish'), $this->getUser()->getCulture()); $task->setFinish("{$y}-{$m}-{$d}"); } $task->setStatus($this->getRequestParameter('status', sfConfig::get('app_task_status_open'))); $task->setPriority($this->getRequestParameter('priority')); $task->clearUsers(); $user = sfGuardUserProfilePeer::retrieveByUuid($this->getRequestParameter('task_user')); $task->addUser($user->getUserId()); $task->save(); $this->task = $task; $this->project = $project; $this->setTemplate('show'); return $this->redirect('project/showTask?tab=tasks&task=' . $task->getUuid()); }
public function executeSitemap() { $sitemap = new sfDefaultSitemap(); $projects = ProjectPeer::doSelect(new Criteria()); $priority = '0.3'; $freq = 'weekly'; foreach ($projects as $project) { $item = new sfSitemapItem(); $item->initialize(array('loc' => '@show_project?project=' . $project->getSlug(), 'lastmod' => $project->getUpdatedAt(), 'changeFreq' => $freq, 'piority' => $priority)); $sitemap->addItem($item); } $members = sfGuardUserProfilePeer::doSelect(new Criteria()); foreach ($members as $member) { $item = new sfSitemapItem(); $item->initialize(array('loc' => '@show_user?user='******'lastmod' => $member->getUpdatedAt(), 'changeFreq' => $freq, 'piority' => $priority)); $sitemap->addItem($item); } $features = SuggestedFeaturePeer::doSelect(new Criteria()); $freq = 'daily'; foreach ($features as $feature) { $item = new sfSitemapItem(); $item->initialize(array('loc' => '@show_feature?feature=' . $feature->getUuid(), 'lastmod' => $feature->getUpdatedAt(), 'changeFreq' => $freq, 'piority' => $priority)); $sitemap->addItem($item); } $this->sitemap = $sitemap; }
public function execute(&$value, &$error) { if (sfGuardUserProfilePeer::retrieveByFullName($value) == null) { $error = $this->getParameter('user_error'); $error = "*Sorry, we can't seem to find this user. Maybe you meant someone else?"; return false; } return true; }
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; }
public function executeConfirmation($request) { $key = $request->getParameter('key'); if ($key) { $user_profile = sfGuardUserProfilePeer::retrieveByActivationKey($key); if ($user_profile) { $user = sfGuardUserPeer::retrieveByPK($user_profile->getUserId()); $user->setIsActive(true); $user->save(); $this->getUser()->setFlash('info', 'Your account has been activated.'); $this->forward('site', 'message'); } } $this->getUser()->setFlash('error', 'Activation link is not valid.'); $this->forward('site', 'message'); }
/** * Prepare the email message. */ public function processEmail() { $this->count = 1; $mail = new Swift_Message(); $mail->setContentType('text/plain'); $mail->setCharset('utf-8'); if ($this->getOption('use_complete_template', true)) { $mail->setBody(sprintf(<<<EOF ------ %s - %s ------ %s ------ EOF , $this->options['name'], $this->options['email'], $this->options['message'])); } else { $mail->setBody($this->options['message']); } $mail->setSender(array(sfPlop::get('sf_plop_messaging_from_email') => sfPlop::get('sf_plop_messaging_from_name'))); $mail->setFrom(array($this->options['email'] => $this->options['name'])); if ($this->getOption('copy')) { $mail->setCc(array($this->options['email'] => $this->options['name'])); $this->count++; } if (is_integer($this->getOption('receiver'))) { $receiver = sfGuardUserProfilePeer::retrieveByPK($this->getOption('receiver')); if ($receiver) { $mail->setTo(array($receiver->getEmail() => $receiver->getFullName())); } else { $mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name'))); } } else { $mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name'))); } if ($this->getOption('subject')) { $mail->setSubject($this->getOption('subject')); } else { $mail->setSubject(sfPlop::get('sf_plop_messaging_subject')); } $this->mail = $mail; }
public function validateApply() { // Extend me to validate your own stuff if ($this->getRequest()->getMethod() == sfRequest::POST) { $email = $this->getRequestParameter('email'); $email2 = $this->getRequestParameter('email2'); $username = $this->getRequestParameter('username'); if ($email !== $email2) { $this->logMessage("Emails don't match", 'info'); $this->getRequest()->setError('email', "Email addresses do not match."); return false; } $password = $this->getRequestParameter('password'); $password2 = $this->getRequestParameter('password2'); if ($password !== $password2) { $this->logMessage("Passwords don't match", 'info'); $this->getRequest()->setError('password', "Passwords do not match."); return false; } if (sfGuardUserPeer::retrieveByUsername($username)) { // TODO: efficient username suggest-o-matic ala Accountify $this->getRequest()->setError('username', "Sorry, that username is already in use. Please select another."); return false; } if (!preg_match("/^[\\w\\ \\.\\-]+\$/", $username)) { $this->getRequest()->setError('username', "Sorry, usernames may contain only letters, numbers, underscores, spaces, periods and dashes."); return false; } $c = new Criteria(); $c->add(sfGuardUserProfilePeer::EMAIL, $email); $match = sfGuardUserProfilePeer::doSelectOne($c); if ($match) { $this->logMessage("Email in use", 'info'); $this->getRequest()->setError('email', "Sorry, that email address is already associated with an account. Click on \"I forgot my password\" if you need to retrieve your password."); return false; } } $this->logMessage("Validate function succeeded", 'info'); return true; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(sfGuardUserProfilePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(sfGuardUserProfilePeer::DATABASE_NAME); $criteria->add(sfGuardUserProfilePeer::ID, $pks, Criteria::IN); $objs = sfGuardUserProfilePeer::doSelect($criteria, $con); } return $objs; }
include_once "../../config/ProjectConfiguration.class.php"; $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true); $sfContext = sfContext::createInstance($configuration); $sfContext->dispatch(); $res = ldap_connect("ldaps://ldap.tufts.edu/", 636); $anon = ldap_bind($res); if (!$anon) { echo ldap_error($res) . "\n"; exit; } $users = sfGuardUserPeer::doSelect(new Criteria()); foreach ($users as $u) { if (strpos($u->getUserName(), "@tufts.edu") !== false) { $c = new Criteria(); $c->add(sfGuardUserProfilePeer::USER_ID, $u->getId()); $profile = sfGuardUserProfilePeer::doSelectOne($c); $result = ldap_search($res, "dc=tufts,dc=edu", "mail=" . $u->getUserName()); $info = ldap_get_entries($res, $result); if ($info["count"]) { echo $info[0]["uid"][0] . "\n"; $profile->setEmail(trim($u->getUserName())); $profile->save(); $u->setUserName(trim($info[0]["uid"][0])); $u->save(); } else { echo $u->getUserName() . " not found! \n"; $profile->setEmail(""); $profile->save(); } } }
public function voteUp($user_id) { $user = sfGuardUserProfilePeer::retrieveByUserId($user_id); if ($user == null) { return false; } $this->setPoints($this->getPoints() + $user->getUserVotingPoints()); $this->save(); if ($this->getPoints() > sfConfig::get('app_project_application_approval_threshold')) { $this->CommunityApprove(); } }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = sfGuardUserPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related sfGuardUserProfile objects $criteria = new Criteria(sfGuardUserProfilePeer::DATABASE_NAME); $criteria->add(sfGuardUserProfilePeer::USER_ID, $obj->getId()); $affectedRows += sfGuardUserProfilePeer::doDelete($criteria, $con); // delete related Advice objects $criteria = new Criteria(AdvicePeer::DATABASE_NAME); $criteria->add(AdvicePeer::USER_ID, $obj->getId()); $affectedRows += AdvicePeer::doDelete($criteria, $con); // delete related sfGuardUserPermission objects $criteria = new Criteria(sfGuardUserPermissionPeer::DATABASE_NAME); $criteria->add(sfGuardUserPermissionPeer::USER_ID, $obj->getId()); $affectedRows += sfGuardUserPermissionPeer::doDelete($criteria, $con); // delete related sfGuardUserGroup objects $criteria = new Criteria(sfGuardUserGroupPeer::DATABASE_NAME); $criteria->add(sfGuardUserGroupPeer::USER_ID, $obj->getId()); $affectedRows += sfGuardUserGroupPeer::doDelete($criteria, $con); // delete related sfGuardRememberKey objects $criteria = new Criteria(sfGuardRememberKeyPeer::DATABASE_NAME); $criteria->add(sfGuardRememberKeyPeer::USER_ID, $obj->getId()); $affectedRows += sfGuardRememberKeyPeer::doDelete($criteria, $con); } return $affectedRows; }
public function executeUserToken(sfWebRequest $request) { $this->forward404Unless($request->getParameter('token'), 'horari', 'index'); $this->profile = sfGuardUserProfilePeer::activateProfileByToken($request->getParameter('token')); }
public function executeSignin($request) { $this->op = $request->getParameter('op'); //echo $this->op; //die; $dialog = $request->getParameter('dialog', false); /* IF FB CONNECT */ if ($this->op == 'fbc' && ($facebook_uid = VoFacebook::getUid())) { //echo "FBC";die; $c = new Criteria(); $c->addJoin(SfGuardUserProfilePeer::USER_ID, SfGuardUserPeer::ID); $c->add(SfGuardUserProfilePeer::FACEBOOK_UID, $facebook_uid); $sfGuardUser = SfGuardUserPeer::doSelectOne($c); if (!$sfGuardUser instanceof sfGuardUser) { // Comprobación de que no existe ya el usuario con ese username (bug #734) $c = new Criteria(); $c->add(sfGuardUserPeer::USERNAME, 'Facebook_' . $facebook_uid); $existingUser = sfGuardUserPeer::doSelectOne($c); if ($existingUser) { $existingUser->setUsername('Facebook_' . $facebook_uid . '-' . time()); $existingUser->save(); } $sfGuardUser = new sfGuardUser(); $sfGuardUser->setUsername('Facebook_' . $facebook_uid); $sfGuardUser->save(); $voProfile = $sfGuardUser->getProfile(); $vanityUrl = SfVoUtil::encodeVanity('Facebook_' . $facebook_uid); $voProfile->setFacebookUid($facebook_uid); if (!$voProfile->getNombre()) { $data = VoFacebook::getData($voProfile->getFacebookUid()); $voProfile->setNombre($data->first_name); $voProfile->setApellidos($data->last_name); } $c2 = new Criteria(); $c2->add(SfGuardUserProfilePeer::VANITY, "{$vanityUrl}%", Criteria::LIKE); $usuariosLikeMe = SfGuardUserProfilePeer::doSelect($c2); $counter = 0; foreach ($usuariosLikeMe as $usuarioLikeMe) { if (preg_match("/^Facebook_{$facebook_uid}-([0-9]*)/i", $usuarioLikeMe->getVanity(), $matches)) { $curIdx = $matches[1]; if ($curIdx > $counter) { $counter = $curIdx + 1; } } else { $counter++; } } $voProfile->setVanity("{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}")); $voProfile->setMailsComentarios(0); $voProfile->setMailsNoticias(0); $voProfile->setMailsContacto(0); $voProfile->setMailsSeguidor(0); $voProfile->save(); } $this->getUser()->signin($sfGuardUser, false); $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $this->getUser()->getReferer('@homepage')); $this->redirect($signinUrl); } /* FI FB CONNECT */ $this->registrationform = new RegistrationForm(); $this->signinform = new SigninForm(); if ($request->isMethod('post') && !$dialog) { // Register if ($this->op == 'r') { $this->registrationform = new RegistrationForm(); $this->registrationform->bind($request->getParameter('registration')); if ($this->registrationform->isValid()) { $user = new sfGuardUser(); $user->setUsername($this->registrationform->getValue('username')); $user->setPassword($this->registrationform->getValue('password')); $user->setIsActive(0); $user->setCreatedAt(time()); $c = new Criteria(); $c->add(sfGuardUserPeer::USERNAME, $user->getUsername()); sfGuardUserPeer::doInsert($user); $user = sfGuardUserPeer::doSelect($c); if (count($user) == 1) { $profile = $user[0]->getProfile(); $profile->setNombre($this->registrationform->getValue('nombre')); $profile->setApellidos($this->registrationform->getValue('apellidos')); $profile->setPresentacion($this->registrationform->getValue('presentacion')); $profile->setAnonymous($this->registrationform->getValue('anonymous')); $profile->setCodigo(util::generateUID()); /* Generar vanity */ if ($profile->getVanity() == '') { $vanityUrl = SfVoUtil::encodeVanity($profile->getNombre() . "-" . $profile->getApellidos()); $c2 = new Criteria(); $c2->add(SfGuardUserProfilePeer::VANITY, "{$vanityUrl}%", Criteria::LIKE); $c2->add(SfGuardUserProfilePeer::ID, $user[0]->getId(), Criteria::NOT_EQUAL); $usuariosLikeMe = SfGuardUserProfilePeer::doSelect($c2); $counter = 0; foreach ($usuariosLikeMe as $usuarioLikeMe) { $counter++; } $profile->setVanity("{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}")); } /* Fin Generar vanity */ sfGuardUserProfilePeer::doInsert($profile); $this->sendWelcome($user[0]); $this->user = $user[0]; return "Registered"; } } /* else { $this->getUser()->setFlash('notice_type', 'error', false); $this->getUser()->setFlash('notice', sfVoForm::getFormNotValidMessage(), false); } */ } else { $r = new SigninForm(); $r->bind($request->getParameter('signin')); if ($r->isValid()) { $r->addPostValidation(); $r->bind($request->getParameter('signin')); if ($r->isValid()) { $this->doSignin($request, $this->op); } } /* else { $this->getUser()->setFlash('notice_type', 'error', false); $this->getUser()->setFlash('notice', sfVoForm::getFormNotValidMessage(), false); } */ $this->signinform = $r; } } $this->title = sfContext::getInstance()->getI18N()->__('Acceso usuarios', array()); $this->title .= ' - Voota'; $this->response->setTitle($this->title); if ($this->op == 'fb') { return 'FB'; } }
/** * Get the associated sfGuardUserProfile object * * @param PropelPDO Optional Connection object. * @return sfGuardUserProfile The associated sfGuardUserProfile object. * @throws PropelException */ public function getsfGuardUserProfile(PropelPDO $con = null) { if ($this->asfGuardUserProfile === null && $this->user_id !== null) { $c = new Criteria(sfGuardUserProfilePeer::DATABASE_NAME); $c->add(sfGuardUserProfilePeer::ID, $this->user_id); $this->asfGuardUserProfile = sfGuardUserProfilePeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->asfGuardUserProfile->addJobNotess($this); */ } return $this->asfGuardUserProfile; }
/** * Executes showTodo action * */ public function executeShowTodo() { $this->forward404Unless($this->profile = sfGuardUserProfilePeer::retrieveByUuid($this->getRequestParameter('user')), 'User not found'); $this->forward404Unless($this->todo = ToDoPeer::retrieveByUserIdSlug($this->profile->getUserId(), $this->getRequestParameter('todo')), 'Todo not found by user_id:slug, [' . $this->profile->getUserId() . ']:[' . $this->getRequestParameter('todo') . ']'); $this->forward404Unless($this->todo->getOwnerId() == $this->getUser()->getId(), 'Owner doesn\'t match current user'); }
public function clonePositionAcceptApplicant($position_uuid, $user_uuid) { // retrieve desired position $position_old = ProjectPositionPeer::retrieveByUuid($position_uuid); // clone position $position = $position_old->copy(); // clear uuid so it will regenerate a unique one, save $position->setUuid(NULL); $position->setFilled(true); $position->save(); // grab desired user $user = sfGuardUserProfilePeer::retrieveByUuid($user_uuid); // remove applicant from old position $positionUser = ProjectUserPeer::retrieveByPositionIdUserId($position_old->getId(), $user->getUserId()); if ($positionUser == null) { sfContext::getInstance()->getLogger()->info('Old PositionUser not found, unable to clone and accept applicant'); return false; } $positionUser->delete(); // build a new positionUser object $positionUser = new ProjectUser(); $positionUser->setPositionId($position->getId()); $positionUser->setUserId($user->getUserId()); $positionUser->setStatus(1); // Status(1): Accepted $positionUser->save(); if ($position == null || $user == null || $positionUser == null) { sfContext::getInstance()->getLogger()->info('Position, user, or PositionUser not found, unable to accept applicant'); return false; } // Assign user to members group $user = $user->getSfGuardUser(); $this->addUserToGroup($user, 'members'); return true; }
/** * Returns the number of related sfGuardUserProfile objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related sfGuardUserProfile objects. * @throws PropelException */ public function countsfGuardUserProfiles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(sfGuardUserPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collsfGuardUserProfiles === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(sfGuardUserProfilePeer::USER_ID, $this->id); $count = sfGuardUserProfilePeer::doCount($criteria, false, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(sfGuardUserProfilePeer::USER_ID, $this->id); if (!isset($this->lastsfGuardUserProfileCriteria) || !$this->lastsfGuardUserProfileCriteria->equals($criteria)) { $count = sfGuardUserProfilePeer::doCount($criteria, false, $con); } else { $count = count($this->collsfGuardUserProfiles); } } else { $count = count($this->collsfGuardUserProfiles); } } return $count; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = sfGuardUserProfilePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setUserId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setUuid($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setCampusId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setDepartmentId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setSubdepartmentId($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setFirstName($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setLastName($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setTitle($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setGender($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setAbout($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setPrimaryEmail($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setPicture($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setRating($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setRatingCount($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setPrivacyLevel($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setPrivateKey($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setKarma($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setVersion($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setIsApproved($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setToken($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setUpdatedAt($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setDeletedAt($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setCreatedAt($arr[$keys[23]]); } }
public function getsfGuardUserProfilesJoinSubdepartment($criteria = null, $con = null) { include_once 'lib/model/om/BasesfGuardUserProfilePeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collsfGuardUserProfiles === null) { if ($this->isNew()) { $this->collsfGuardUserProfiles = array(); } else { $criteria->add(sfGuardUserProfilePeer::USER_ID, $this->getId()); $this->collsfGuardUserProfiles = sfGuardUserProfilePeer::doSelectJoinSubdepartment($criteria, $con); } } else { $criteria->add(sfGuardUserProfilePeer::USER_ID, $this->getId()); if (!isset($this->lastsfGuardUserProfileCriteria) || !$this->lastsfGuardUserProfileCriteria->equals($criteria)) { $this->collsfGuardUserProfiles = sfGuardUserProfilePeer::doSelectJoinSubdepartment($criteria, $con); } } $this->lastsfGuardUserProfileCriteria = $criteria; return $this->collsfGuardUserProfiles; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = sfGuardUserProfilePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setUserTypeId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setUserId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setEmail($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setFirstName($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setLastName($arr[$keys[5]]); } }
public function executeAjaxAssignTaskUsers() { $task = TaskPeer::retrieveByUuid($this->getRequestParameter('task')); $user_ids = $this->getRequestParameter('taskusers', array()); $this->forward404Unless($task, 'Task not found, unable to assign users'); $this->output = ''; $users = array(); // TODO: send message to alert users if they have been added or removed from task // TODO: make sure users passed is correct $task->clearUsers(); foreach ($user_ids as $user_id) { $user = sfGuardUserProfilePeer::retrieveByUuid($user_id); $this->logMessage('assigning task-user [' . $task->getName() . ']:[' . $user->getFullName() . ']'); $task->addUser($user); } $this->task = $task; $this->projectUsers = $this->task->getProject()->getApprovedUsers(); //$this->setTemplate('ajaxGenericOutput'); }
/** * Selects a collection of Log objects pre-filled with all related objects except MessageType. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Log objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptMessageType(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } LogPeer::addSelectColumns($c); $startcol2 = LogPeer::NUM_COLUMNS - LogPeer::NUM_LAZY_LOAD_COLUMNS; sfGuardUserProfilePeer::addSelectColumns($c); $startcol3 = $startcol2 + (sfGuardUserProfilePeer::NUM_COLUMNS - sfGuardUserProfilePeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(LogPeer::SF_GUARD_USER_PROFILE_ID), array(sfGuardUserProfilePeer::USER_ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = LogPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = LogPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = LogPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); LogPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined sfGuardUserProfile rows $key2 = sfGuardUserProfilePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = sfGuardUserProfilePeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = sfGuardUserProfilePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); sfGuardUserProfilePeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Log) to the collection in $obj2 (sfGuardUserProfile) $obj2->addLog($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public function executeForgotPasswordText() { sfPropelApprovableBehavior::disable(); $this->user = sfGuardUserProfilePeer::retrieveByUuid($this->getRequest()->getAttribute('user_id')); sfPropelApprovableBehavior::disable(); $this->token = $this->user->getsfGuardUser()->getToken(); $this->user = $this->user->getUuid(); }
public function countsfGuardUserProfiles($criteria = null, $distinct = false, $con = null) { include_once 'lib/model/om/BasesfGuardUserProfilePeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(sfGuardUserProfilePeer::USER_ID, $this->getId()); return sfGuardUserProfilePeer::doCount($criteria, $distinct, $con); }
public static function retrieveByActivationKey($key) { $c = new Criteria(); $c->add(sfGuardUserProfilePeer::ACTIVATION_KEY, $key); return sfGuardUserProfilePeer::doSelectOne($c); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this UserType is new, it will return * an empty collection; or if this UserType has previously * been saved, it will retrieve related sfGuardUserProfiles from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in UserType. */ public function getsfGuardUserProfilesJoinsfGuardUser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(UserTypePeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collsfGuardUserProfiles === null) { if ($this->isNew()) { $this->collsfGuardUserProfiles = array(); } else { $criteria->add(sfGuardUserProfilePeer::USER_TYPE_ID, $this->id); $this->collsfGuardUserProfiles = sfGuardUserProfilePeer::doSelectJoinsfGuardUser($criteria, $con, $join_behavior); } } else { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(sfGuardUserProfilePeer::USER_TYPE_ID, $this->id); if (!isset($this->lastsfGuardUserProfileCriteria) || !$this->lastsfGuardUserProfileCriteria->equals($criteria)) { $this->collsfGuardUserProfiles = sfGuardUserProfilePeer::doSelectJoinsfGuardUser($criteria, $con, $join_behavior); } } $this->lastsfGuardUserProfileCriteria = $criteria; return $this->collsfGuardUserProfiles; }
/** * Selects a collection of Client objects pre-filled with all related objects. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Client objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { foreach (sfMixer::getCallables('BaseClientPeer:doSelectJoinAll:doSelectJoinAll') as $callable) { call_user_func($callable, 'BaseClientPeer', $c, $con); } $c = clone $c; // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ClientPeer::addSelectColumns($c); $startcol2 = ClientPeer::NUM_COLUMNS - ClientPeer::NUM_LAZY_LOAD_COLUMNS; sfGuardUserProfilePeer::addSelectColumns($c); $startcol3 = $startcol2 + (sfGuardUserProfilePeer::NUM_COLUMNS - sfGuardUserProfilePeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(ClientPeer::USER_ID), array(sfGuardUserProfilePeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ClientPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ClientPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = ClientPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); ClientPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined sfGuardUserProfile rows $key2 = sfGuardUserProfilePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = sfGuardUserProfilePeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = sfGuardUserProfilePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); sfGuardUserProfilePeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Client) to the collection in $obj2 (sfGuardUserProfile) $obj2->addClient($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = sfGuardUserProfilePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setUserId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setFirstName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setLastName($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setBirthday($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setEmail($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCity($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setImage($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setDescrypt($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setLevel($arr[$keys[9]]); } }