Пример #1
0
 public function queryByUser(sfGuardUser $user)
 {
     if ($user->hasPermission(myUser::CREDENTIAL_ADMIN)) {
         return $this->queryAll()->innerJoin('w.Petition p')->innerJoin('p.Campaign c')->where('p.status != ? AND c.status = ?', array(Petition::STATUS_DELETED, CampaignTable::STATUS_ACTIVE));
     }
     return $this->queryAll()->innerJoin('w.Petition p')->leftJoin('p.PetitionRights pr ON p.id = pr.petition_id and pr.user_id = ?', $user->getId())->innerJoin('p.Campaign c')->leftJoin('c.CampaignRights cr ON c.id = cr.campaign_id and cr.user_id = ?', $user->getId())->where('p.status != ? AND c.status = ?', array(Petition::STATUS_DELETED, CampaignTable::STATUS_ACTIVE))->andWhere('w.user_id = ? OR (cr.user_id = ? AND pr.user_id = ? AND cr.active = 1 AND pr.active = 1 AND (pr.admin = 1 OR pr.member = 1) AND (cr.admin = 1 OR cr.member = 1))', array($user->getId(), $user->getId(), $user->getId()));
 }
 /**
  *
  * @param sfGuardUser $user
  * @return Doctrine_Query
  */
 public function queryByMember(sfGuardUser $user, $is_member = true, $deleted_too = false)
 {
     if ($user->hasPermission(myUser::CREDENTIAL_ADMIN)) {
         return $this->queryAll($deleted_too);
     }
     if ($is_member) {
         return $this->queryAll($deleted_too)->innerJoin('c.CampaignRights cr')->andWhere('cr.user_id = ? AND cr.active = ?', array($user->getId(), 1));
     } else {
         return $this->queryAll($deleted_too)->andWhere('c.id NOT IN (SELECT cr.campaign_id FROM CampaignRights cr WHERE cr.user_id = ? AND cr.active = ?)', array($user->getId(), 1));
     }
 }
Пример #3
0
 /**
  * @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;
 }
Пример #4
0
 /**
  * @param sfGuardUser $user
  * @return array
  */
 public function getUsersInTeamIDs(sfGuardUser $user)
 {
     $ids = array();
     $ids[] = $user->getId();
     $q = $this->createQuery('u')->leftJoin('u.TeamMember tm')->where('tm.manager_id = ?', $user->getId());
     $team_manager = $this->userTeamManager($user);
     if ($team_manager) {
         $ids[] = $team_manager;
         $q->orWhere('tm.manager_id = ?', $team_manager);
     }
     $users = $q->execute();
     foreach ($users as $user) {
         $ids[] = $user->getId();
     }
     return array_unique($ids);
 }
 /**
  *
  * @param sfGuardUser $user or User ID
  * @return boolean
  * @throws Exception
  */
 public function isSelfUser($user)
 {
     if ($user instanceof sfGuardUser) {
         return $this->getGuardUser()->getId() == $user->getId();
     } elseif (is_numeric($user)) {
         return $user == $this->getGuardUser()->getId();
     }
     throw new Exception('wrong argument');
 }
Пример #6
0
 public static final function checkIfImInList(sfGuardUser $me, Doctrine_Collection $usersCollection)
 {
     foreach ($usersCollection as $user) {
         if ($user->getId() === $me->getId()) {
             return true;
         }
     }
     return false;
 }
Пример #7
0
 public function doSave($con = null)
 {
     $user = new sfGuardUser();
     $user->setUsername($this->getValue('username'));
     $user->setPassword($this->getValue('password'));
     // They must confirm their account first
     $user->setIsActive(false);
     $user->save();
     $this->userId = $user->getId();
     return parent::doSave($con);
 }
Пример #8
0
 public function createUser(array $guard_tab, $ei_user_tab)
 {
     $new_guard = new sfGuardUser();
     $new_guard->setId($guard_tab['id']);
     $new_guard->setUsername($guard_tab['username']);
     $new_guard->setFirstName($guard_tab['first_name']);
     $new_guard->setLastName($guard_tab['last_name']);
     $new_guard->setEmailAddress($guard_tab['email_address']);
     $new_guard->setPassword($guard_tab['password']);
     $new_guard->save();
     /* Création du EiUser */
     EiUserTable::createUser($ei_user_tab, $new_guard->getId());
     return $new_guard;
 }
Пример #9
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $user = new sfGuardUser();
     $user->setUsername($arguments['username']);
     $user->setPassword($arguments['password']);
     $user->save();
     $profile = new Profile();
     $profile->setNickname($arguments['nickname']);
     $profile->setEmail($arguments['email']);
     $profile->setSfGuardUserId($user->getId());
     $profile->save();
     $this->logSection('crew', sprintf('Create user "%s"', $arguments['username']));
 }
 public function doSave($con = null)
 {
     if ($this->isNew) {
         $user = new sfGuardUser();
         $user->setUsername($this->getValue('username'));
         $user->setPassword($this->getValue('password'));
         $user->setEmailAddress($this->getValue('email'));
         $user->addGroupByName(sfConfig::get('app_user_default_group'));
         // They must confirm their account first
         $user->setIsActive(false);
         $user->save();
         $this->getObject()->setUserId($user->getId());
     }
     return parent::doSave($con);
 }
 public function createItem(EiScenario $ei_scenario, EiDelivery $ei_delivery, EiTicket $ei_ticket, sfGuardUser $guard_user, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     $stmt = $conn->prepare("INSERT INTO ei_package_scenario_conflict (ei_scenario_id,delivery_id,package_id, package_ref,resolved_date,resolved_author,created_at,updated_at) " . "VALUES (:ei_scenario_id,:delivery_id,:package_id, :package_ref,:resolved_date,:resolved_author,:created_at,:updated_at) " . "ON DUPLICATE KEY UPDATE ei_scenario_id=ei_scenario_id, delivery_id=delivery_id, package_id=:package_id,package_ref=:package_ref");
     $stmt->bindValue("ei_scenario_id", $ei_scenario->getId());
     $stmt->bindValue("delivery_id", $ei_delivery->getId());
     $stmt->bindValue("package_id", $ei_ticket->getTicketId());
     $stmt->bindValue("package_ref", $ei_ticket->getTicketRef());
     $stmt->bindValue("resolved_date", date('Y-m-d H:i:s'));
     $stmt->bindValue("resolved_author", $guard_user->getId());
     $stmt->bindValue("created_at", date('Y-m-d H:i:s'));
     $stmt->bindValue("updated_at", date('Y-m-d H:i:s'));
     $stmt->execute(array());
 }
Пример #12
0
 protected function create_sf_user($fbProfile)
 {
     try {
         //die('creating');
         //doctrine, create record in sf_guard_user
         $NewFacebookUser = new sfGuardUser();
         $NewFacebookUser->first_name = $fbProfile['first_name'];
         $NewFacebookUser->last_name = $fbProfile['last_name'];
         $NewFacebookUser->email_address = $fbProfile['email'];
         $NewFacebookUser->username = $fbProfile['email'];
         $NewFacebookUser->save();
         $NewFacebookUser->setPassword('test');
         $NewFacebookUser->save();
         //get id
         $id = $NewFacebookUser->getId();
         //this part has been replace with a mysql trigger
         /*
                     //ensure id isn't already used, autoincremenet problem
                     $q = Doctrine_Query::create()
                     ->select("*")
                     ->from("RidAccounts")
                     //->where("email = ?", $this->user->getEmailAddress())
                     ->where("id = ?", $id)    
                     ->setHydrationMode(Doctrine::HYDRATE_ARRAY);
         
                     $results = $q->execute();
         
                     if(count($results) > 0) { die('id already used' . __LINE__ . __FILE__); }
                     
                     
                     //doctrine, create record in RidAccounts
                     $NewFacebookUserAccount = new RidAccounts();
                     $NewFacebookUserAccount->id = $id;
                     $NewFacebookUserAccount->first_name = $fbProfile['first_name'];
                     $NewFacebookUserAccount->last_name = $fbProfile['last_name'];
                     $NewFacebookUserAccount->email = $fbProfile['email'];
                     $NewFacebookUserAccount->save();
         */
         return $id;
     } catch (Exception $e) {
         echo $e->getType() . "<br />";
         echo $e->getMessage() . "<br />";
         sfContext::getInstance()->getLogger()->debug($e->getType());
         sfContext::getInstance()->getLogger()->debug($e->getMessage());
         die(__FILE__ . __LINE__);
     }
 }
Пример #13
0
 public function executeApply()
 {
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         $username = $this->getRequestParameter('username');
         $password = $this->getRequestParameter('password');
         $sfGuardUser = new sfGuardUser();
         $sfGuardUser->setUsername($username);
         $sfGuardUser->setPassword($password);
         // Not until confirmed
         $sfGuardUser->setIsActive(false);
         $profile = $sfGuardUser->getProfile();
         $this->populateProfileSettings($profile);
         $sfGuardUser->save();
         $profile->save();
         $this->setFlash('sfApplyPlugin_id', $sfGuardUser->getId(), false);
         $this->sendEmail('sfApply', 'sendValidate');
         return 'After';
     }
 }
 /**
  * Serialize the form into the database.
  **/
 public function save($con = null)
 {
     if (!is_null($this->getValue("photographer_id"))) {
         $p = $this->getObject();
     } else {
         $sfUser = new sfGuardUser();
         $sfUser->setUsername($this->getValue("email"));
         $sfUser->setPassword($this->getValue("password"));
         $sfUser->save();
         if (strpos($this->getValue("name"), " ") !== false) {
             list($firstName, $lastName) = explode(" ", $this->getValue("name"));
         } else {
             $firstName = "";
             $lastName = "";
         }
         $sfProfile = new sfGuardUserProfile();
         $sfProfile->setUserTypeId(sfConfig::get("app_user_type_photographer"));
         $sfProfile->setUserId($sfUser->getId());
         $sfProfile->setEmail($this->getValue("email"));
         $sfProfile->setFirstName($firstName);
         $sfProfile->setLastName($lastName);
         $sfProfile->save();
         $p = new Photographer();
         $p->setUserId($sfProfile->getId());
     }
     $p->setName($this->getValue("name"));
     $p->setEmail($this->getValue("email"));
     $p->setPhone($this->getValue("phone"));
     $p->setAffiliation($this->getValue("affiliation"));
     $p->setWebsite($this->getValue("website"));
     $p->setDescription($this->getValue("description"));
     $p->setBillingAddress($this->getValue("billing_info"));
     $p->save();
     if ($this->getValue("reset_password")) {
         $user = $p->getsfGuardUserProfile()->getsfGuardUser();
         $user->setPassword($this->getValue("password"));
         $user->save();
     }
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $peticion = $form->save();
         $newUser = new sfGuardUser();
         $newUser->setUsername($form->getObject()->getUsername());
         $newUser->setFirstName($form->getObject()->getFirstName());
         $newUser->setLastName($form->getObject()->getLastName());
         $newUser->setSexo($form->getObject()->getSexo());
         $newUser->setDireccion($form->getObject()->getDireccion());
         $newUser->setTelefono($form->getObject()->getTelefono());
         $newUser->setTelefonoMovil($form->getObject()->getTelefonoMovil());
         $newUser->setEmailAddress($form->getObject()->getEmailAddress());
         $newUser->setPassword($form->getObject()->getPassword());
         try {
             $newUser->save();
             $peticion->delete();
             $this->redirect('sfGuardUser/editagregar?id=' . $newUser->getId());
         } catch (Exception $e) {
             $this->redirect('peticion/edit?id=' . $peticion->getId());
         }
     }
 }
Пример #16
0
 public function findMineUncomplete(sfGuardUser $user)
 {
     $q = Doctrine_Query::create()->select('p.*')->addSelect('(SELECT count(*) FROM Task t1 WHERE t1.story_id = s.id WHERE t1.status <> \'done\') as count_tasks')->from('Project p')->leftJoin('p.Iterations i')->leftJoin('i.Stories s')->leftJoin('p.Manager m')->where('p.status = ?', 'enabled')->andWhere('m.id = ?', $user->getId())->having('count_tasks > 0');
     return $q->execute();
 }
Пример #17
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      sfGuardUser $value A sfGuardUser object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(sfGuardUser $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #18
0
 /**
  * Exclude object from result
  *
  * @param     sfGuardUser $sfGuardUser Object to remove from the list of results
  *
  * @return    sfGuardUserQuery The current query, for fluid interface
  */
 public function prune($sfGuardUser = null)
 {
     if ($sfGuardUser) {
         $this->addUsingAlias(sfGuardUserPeer::ID, $sfGuardUser->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Returns a list of NotificationConfiguration created by the given user.
  *
  * @param sfGuardUser $user
  *
  * @return array of NotificationConfiguration
  */
 public static function retrieveByUser(sfGuardUser $user)
 {
     $criteria = new Criteria(self::DATABASE_NAME);
     $criteria->add(self::USER_ID, $user->getId(), Criteria::EQUAL);
     return self::doSelect($criteria);
 }
Пример #20
0
 /**
  * Signs in the user on the application.
  *
  * @param sfGuardUser $user The sfGuardUser id
  * @param boolean $remember Whether or not to remember the user
  * @param Doctrine_Connection $con A Doctrine_Connection object
  */
 public function signIn($user, $auth_key = null, $con = null)
 {
     // signin
     $this->setApiUserid($user->getId());
     $this->setAuthenticated(true);
     $this->clearCredentials();
     $this->addCredentials($user->getAllPermissionNames());
     // save last login
     $user->setLastLogin(date('Y-m-d H:i:s'));
     $user->save($con);
     // Set login messages
     $message = array();
     foreach ($user->getUndisplayedLoginMessages() as $message) {
         $messages[] = $message->getMessage();
         $message->setDisplayed(true);
         $message->save();
     }
     if (count($message) > 0) {
         $this->setFlash('login', $messages);
     }
     // remember?
     if ($auth_key) {
         $this->setApiAuthkey($auth_key);
         $api_key = sfConfig::get('app_web_app_api_key');
         $api = ApiKeyTable::getInstance()->findOneBy('api_key', $api_key);
         $auth_key = sfGuardUserAuthKeyTable::getInstance()->getMostRecentValidByApiKeyIdAndAuthKey($api->getIncremented(), $auth_key);
         $expires = strtotime($auth_key->getExpiresAt());
         // make key as a cookie
         $remember_cookie = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember');
         sfContext::getInstance()->getResponse()->setCookie($remember_cookie, $auth_key->getAuthKey(), $expires);
     }
 }
 /**
  * Signs in the user on the application.
  *
  * @param sfGuardUser $user The sfGuardUser id
  * @param boolean $remember Whether or not to remember the user
  * @param Doctrine_Connection $con A Doctrine_Connection object
  */
 public function signIn($user, $remember = false, $con = null)
 {
     // signin
     $this->setAttribute('user_id', $user->getId(), 'sfGuardSecurityUser');
     $this->setAuthenticated(true);
     $this->clearCredentials();
     $this->addCredentials($user->getAllPermissionNames());
     // save last login
     $user->setLastLogin(date('Y-m-d H:i:s'));
     $user->save($con);
     // remember?
     if ($remember) {
         $expiration_age = sfConfig::get('app_sf_guard_plugin_remember_key_expiration_age', 15 * 24 * 3600);
         // remove old keys
         Doctrine::getTable('sfGuardRememberKey')->createQuery()->delete()->where('created_at < ?', date('Y-m-d H:i:s', time() - $expiration_age))->execute();
         // remove other keys from this user
         Doctrine::getTable('sfGuardRememberKey')->createQuery()->delete()->where('user_id = ?', $user->getId())->execute();
         // generate new keys
         $key = $this->generateRandomKey();
         // save key
         $rk = new sfGuardRememberKey();
         $rk->setRememberKey($key);
         $rk->setsfGuardUser($user);
         $rk->setIpAddress($_SERVER['REMOTE_ADDR']);
         $rk->save($con);
         // make key as a cookie
         $remember_cookie = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember');
         sfContext::getInstance()->getResponse()->setCookie($remember_cookie, $key, time() + $expiration_age);
     }
 }
Пример #22
0
 /**
  * Filter the query by a related sfGuardUser object
  *
  * @param     sfGuardUser|PropelCollection $sfGuardUser The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CommentQuery The current query, for fluid interface
  */
 public function filterBysfGuardUserRelatedByCheckUserId($sfGuardUser, $comparison = null)
 {
     if ($sfGuardUser instanceof sfGuardUser) {
         return $this->addUsingAlias(CommentPeer::CHECK_USER_ID, $sfGuardUser->getId(), $comparison);
     } elseif ($sfGuardUser instanceof PropelCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CommentPeer::CHECK_USER_ID, $sfGuardUser->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterBysfGuardUserRelatedByCheckUserId() only accepts arguments of type sfGuardUser or PropelCollection');
     }
 }
 /**
  *
  * @param sfGuardUser $user
  * @return Doctrine_Query
  */
 public function queryByUser(sfGuardUser $user)
 {
     return $this->createQuery('cr')->where('cr.user_id = ?', $user->getId())->leftJoin('cr.Campaign c')->select('cr.*, c.*');
 }
Пример #24
0
 public function transformJobs()
 {
     $statusHash = array();
     $statusObjects = StatusPeer::doSelect(new Criteria());
     foreach ($statusObjects as $s) {
         $statusHash[$s->getState()] = $s->getId();
     }
     $this->jobKeys = array();
     $dom = DOMDocument::load("tuftsph_jm2db.xml");
     $jobs = $dom->getElementsByTagName("jobs");
     $total = $jobs->length;
     $count = 1;
     $jobList = array();
     foreach ($jobs as $job) {
         $jid = 0;
         $childNodes = $job->childNodes;
         $j = new Job();
         $del = new Delivery();
         $jid = 1;
         $startTime = null;
         $shootStart = null;
         $shootEnd = null;
         $endTime = null;
         $notes = "";
         $photog = 0;
         $slug = "";
         $childNodes = $job->childNodes;
         foreach ($childNodes as $child) {
             switch ($child->nodeName) {
                 case "id":
                     $jid = $child->textContent;
                     break;
                 case "shoot_name":
                     $j->setEvent($child->textContent);
                     break;
                 case "shoot_date":
                     $j->setDate($child->textContent);
                     break;
                 case "shoot_startT":
                     $startTime = $child->textContent;
                     break;
                 case "shoot_start":
                     $shootStart = $child->textContent;
                     break;
                 case "shoot_endT":
                     $endTime = $child->textContent;
                     break;
                 case "shoot_end":
                     $shootEnd = $child->textContent;
                     break;
                 case "shoot_duedate":
                     $j->setDueDate($child->textContent);
                     break;
                 case "submitted_at":
                     $j->setCreatedAt($child->textContent);
                     break;
                 case "requester_address":
                     $j->setStreet($child->textContent);
                     break;
                 case "requester_campus":
                     $j->setCity($child->textContent);
                     break;
                 case "requester_name":
                     $j->setContactName($child->textContent);
                     break;
                 case "requester_email":
                     $j->setContactEmail($child->textContent);
                     break;
                 case "requester_phone":
                     $j->setContactPhone($child->textContent);
                     break;
                 case "internal_notes":
                     $notes .= $child->textContent . "<br/>";
                     break;
                 case "billing_notes":
                     $notes .= $child->textContent . "<br/>";
                     break;
                 case "estimate":
                     $j->setEstimate($child->textContent);
                     break;
                 case "billing_acctnum":
                     $j->setAcctNum($child->textContent);
                     break;
                 case "billing_deptid":
                     $j->setDeptId($child->textContent);
                     break;
                 case "billing_grantid":
                     $j->setGrantId($child->textContent);
                     break;
                 case "shoot_directions":
                     $j->setOther($child->textContent);
                     break;
                 case "status":
                     $j->setStatusId($statusHash[$child->textContent]);
                     break;
                 case "photog_id":
                     $photog = $child->textContent;
                     break;
                 case "delivery_pubname":
                     $del->setPubName($child->textContent);
                     break;
                 case "delivery_pubtype":
                     $del->setPubType($child->textContent);
                     break;
                 case "delivery_other":
                     $del->setOther($child->textContent);
                     break;
                 case "delivery_format":
                     break;
                 case "delivery_color":
                     $del->setColor($child->textContent);
                     break;
                 case "delivery_format":
                     $del->setFormat($child->textContent);
                     break;
                 case "delivery_size":
                     $del->setSize($child->textContent);
                     break;
                 case "delivery_method":
                     $del->setMethod($child->textContent);
                     break;
                 case "delivery_special":
                     $del->setInstructions($child->textContent);
                     break;
                 case "slug":
                     $slug = $child->textContent;
                     break;
                 case "#text":
                 default:
                     break;
             }
         }
         if (is_null($endTime)) {
             $endTime = $shootEnd;
         }
         if (is_null($startTime)) {
             $startTime = $shootStart;
         }
         if ($j->getCity() == "Boston") {
             $j->setZip("02101");
         } else {
             $j->setZip("02155");
         }
         $j->setNotes($notes);
         $j->setState("Massachusetts");
         list($hour, $min, $sec) = explode(":", $endTime);
         list($shour, $smin, $ssec) = explode(":", $startTime);
         $t = new DateTime();
         $t->setTime($hour, $min, $sec);
         $j->setEndTime($t);
         $t = new DateTime();
         $t->setTime($shour, $smin, $ssec);
         $j->setStartTime($t);
         $j->addTag($slug);
         if (isset($this->jobProjectKeys[$jid])) {
             $j->setProjectId($this->projectKeys[$this->jobProjectKeys[$jid]]);
         }
         while (count($jobList) - 1 != $jid) {
             $jobList[] = false;
         }
         $jobList[intval($jid)] = array("job" => $j, "del" => $del, "photog" => $photog);
     }
     for ($i = 1; $i < count($jobList); $i++) {
         sleep(1);
         $obj = $jobList[$i];
         $c = new Criteria();
         $c->add(JobPeer::ID, $i);
         if (JobPeer::doCount($c) > 0) {
             continue;
         }
         echo $i . "/" . $total . "\n";
         // keep the ids lined up
         if ($obj == false) {
             $myJob = new Job();
             try {
                 $myJob->save();
             } catch (Exception $ex) {
                 echo $ex->getMessage();
             }
             $myJob->delete();
         } else {
             $j = $obj["job"];
             $del = $obj["del"];
             $photog = $obj["photog"];
             try {
                 $j->save();
             } catch (Exception $ex) {
                 echo $ex->getMessage();
                 echo $ex->getTraceAsString();
             }
             $del->setJobId($j->getId());
             $del->save();
             $this->jobKeys[$jid] = $j->getId();
             if ($photog) {
                 $jp = new JobPhotographer();
                 $jp->setPhotographerId($this->photogKeys[$photog]);
                 $jp->setJobId($j->getId());
                 try {
                     $jp->save();
                 } catch (Exception $ex) {
                     echo $ex->getMessage();
                 }
             }
             // add the requester as a client
             $c = new Criteria();
             $c->add(sfGuardUserPeer::USERNAME, $j->getContactEmail());
             if (ClientPeer::doCount($c) == 0 && trim(strlen($j->getContactEmail())) != 0) {
                 $user = new sfGuardUser();
                 $user->setUsername($j->getContactEmail());
                 $user->setPassword("admin");
                 $user->save();
                 $userProfile = new sfGuardUserProfile();
                 $userProfile->setUserId($user->getId());
                 $userProfile->setUserTypeId(sfConfig::get("app_user_type_client"));
                 $userProfile->save();
                 $clientProfile = new Client();
                 $clientProfile->setUserId($userProfile->getId());
                 $clientProfile->setName($j->getContactName());
                 $clientProfile->setEmail($j->getContactEmail());
                 $clientProfile->setPhone($j->getContactPhone());
                 $clientProfile->save();
                 $jobClient = new JobClient();
                 $jobClient->setClientId($clientProfile->getId());
                 $jobClient->setJobId($j->getId());
                 $jobClient->save();
             }
         }
         $count += 1;
     }
 }
Пример #25
0
 /**
  * Declares an association between this object and a sfGuardUser object.
  *
  * @param      sfGuardUser $v
  * @return     Logs The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setsfGuardUserRelatedByCheckBy(sfGuardUser $v = null)
 {
     if ($v === null) {
         $this->setCheckBy(NULL);
     } else {
         $this->setCheckBy($v->getId());
     }
     $this->asfGuardUserRelatedByCheckBy = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the sfGuardUser object, it will not be re-added.
     if ($v !== null) {
         $v->addLogsRelatedByCheckBy($this);
     }
     return $this;
 }
Пример #26
0
 public function findMostActive(sfGuardUser $user, $limit)
 {
     $q = Doctrine_Query::create()->select('s.*')->addSelect('(SELECT count(*) FROM WorkingUnit w1 WHERE w1.task_id = t.id and w1.user_id = u.id) as count_working_units')->addSelect('(SELECT count(*) FROM Task t1 WHERE t1.story_id = s.id) as count_tasks')->from('Story s')->where('u.id  = ?', $user->getId())->andWhere('w.user_id  = ?', $user->getId())->leftJoin('s.Tasks t')->leftJoin('t.WorkingUnits w')->leftJoin('w.User u')->having('count_working_units > 0')->orderBy('count_working_units DESC')->addOrderBy('count_tasks DESC');
     return $q->execute();
 }
 /**
  *
  * @param Campaign $campaign
  * @return Doctrine_Query
  */
 public function queryByCampaignAndUser(Campaign $campaign, sfGuardUser $user, MailingList $existing = null, $active_only = false)
 {
     $query = $this->queryByCampaign($campaign, $active_only)->leftJoin('ml.TargetListRights tr');
     if ($existing) {
         return $query->andWhere('(tr.user_id = ? AND tr.active = 1) OR ml.id = ?', array($user->getId(), $existing->getId()));
     } else {
         return $query->andWhere('tr.user_id = ? AND tr.active = 1', $user->getId());
     }
 }
Пример #28
0
 /**
  * Declares an association between this object and a sfGuardUser object.
  *
  * @param      sfGuardUser $v
  * @return     sfGuardUserPermission The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setsfGuardUser(sfGuardUser $v = null)
 {
     if ($v === null) {
         $this->setUserId(NULL);
     } else {
         $this->setUserId($v->getId());
     }
     $this->asfGuardUser = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the sfGuardUser object, it will not be re-added.
     if ($v !== null) {
         $v->addsfGuardUserPermission($this);
     }
     return $this;
 }
 /**
  * Создать sfGuardUserPermission
  */
 public function makeGuardUserPermission(sfGuardUser $user, sfGuardPermission $permission, $save = false, array $props = array())
 {
     $defaultProps = array('user_id' => $user->getId(), 'permission_id' => $permission->getId());
     $props = array_merge($defaultProps, $props);
     return $this->makeModel('sfGuardUserPermission', $props, $save);
 }
Пример #30
0
 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());
 }