public function executeRequestConnection() { $user1 = $this->getUser()->getProfile(); $user2 = SfGuardUserProfilePeer::retrieveByUuid($this->getRequestParameter('connect')); $this->forward404Unless($user2, 'User2 not found, unable to request connections'); if ($user1->isConnected($user2->getUserId())) { $this->message = "This user is already in your network, or a request is still pending"; $this->forward404($this->message); } $result = $user1->addConnection($user2->getUserId()); if ($result == false) { $this->forward404('Error adding SoCon'); } $message = array(); $message["from"] = $user1->getUserId(); $message["to"] = $user2->getUserId(); $message["owner"] = $user2->getUserId(); $message["parent"] = null; $message["folder"] = "inbox"; $message["subject"] = $user1->getFullName() . ' has requested to add you to their network.'; $message["text"] = 'You can view, accept or decline the request by going to My Network'; $options = array(); $options["copyTo"] = "sent"; MessagePeer::sendSimpleMessage($message, $options); $user1->addHistoryEvent($user1->getFullName() . ' requested ' . $user2->getFullName() . ' to join their network.', $user1->getFullName() . ' has asked ' . $user2->getFullName() . ' to join their network.'); $user2->addHistoryEvent($user1->getFullName() . ' requested ' . $user2->getFullName() . ' to join their network.', $user1->getFullName() . ' has asked ' . $user2->getFullName() . ' to join their network.'); $this->redirect('networks/index?tab=pending'); }
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(); $c = new Criteria(); $c->addJoin(SfGuardUserPeer::ID, SfGuardUserProfilePeer::USER_ID); $c->add(SfGuardUserProfilePeer::FACEBOOK_UID, null, Criteria::ISNOTNULL); $c->add(SfGuardUserProfilePeer::NOMBRE, '', Criteria::EQUAL); $c->add(SfGuardUserPeer::IS_ACTIVE, 1); $profiles = SfGuardUserProfilePeer::doSelect($c); foreach ($profiles as $profile) { $data = VoFacebook::getData($profile->getFacebookUid()); if ($data) { echo $data->name . "\n"; $profile->setNombre($data->first_name); $profile->setApellidos($data->last_name); $profile->save(); } } }
/** * 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; }
private function usuario($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $s3 = new S3Voota(); $c = new Criteria(); $usuarios = SfGuardUserProfilePeer::doSelect($c); foreach ($usuarios as $usuario) { if ($usuario->getImagen() != '') { echo "Creating " . $usuario->getImagen() . " ...\n"; $s3->createUsuarioFromOri($usuario->getImagen()); } } }
/** * Selects a collection of SfGuardUserProfileI18n objects pre-filled with all related objects. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of SfGuardUserProfileI18n objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } SfGuardUserProfileI18nPeer::addSelectColumns($criteria); $startcol2 = SfGuardUserProfileI18nPeer::NUM_COLUMNS - SfGuardUserProfileI18nPeer::NUM_LAZY_LOAD_COLUMNS; SfGuardUserProfilePeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (SfGuardUserProfilePeer::NUM_COLUMNS - SfGuardUserProfilePeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(SfGuardUserProfileI18nPeer::ID, SfGuardUserProfilePeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseSfGuardUserProfileI18nPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = SfGuardUserProfileI18nPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = SfGuardUserProfileI18nPeer::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 { $cls = SfGuardUserProfileI18nPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); SfGuardUserProfileI18nPeer::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) { $cls = SfGuardUserProfilePeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); SfGuardUserProfilePeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (SfGuardUserProfileI18n) to the collection in $obj2 (SfGuardUserProfile) $obj2->addSfGuardUserProfileI18n($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Selects a collection of {@link SfGuardUserProfile} objects with a {@link SfGuardUserProfileI18n} translation populated. * * @param Criteria $criteria * @param string $culture * @param PropelPDO $con * @param string $join_behavior * * @return array */ public static function doSelectWithI18n(Criteria $criteria, $culture = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; if (null === $culture) { $culture = sfPropel::getDefaultCulture(); } // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } SfGuardUserProfilePeer::addSelectColumns($criteria); $startcol = SfGuardUserProfilePeer::NUM_COLUMNS - SfGuardUserProfilePeer::NUM_LAZY_LOAD_COLUMNS; SfGuardUserProfileI18nPeer::addSelectColumns($criteria); $criteria->addJoin(SfGuardUserProfilePeer::ID, SfGuardUserProfileI18nPeer::ID, $join_behavior); $criteria->add(SfGuardUserProfileI18nPeer::CULTURE, $culture); foreach (sfMixer::getCallables('BaseSfGuardUserProfile:doSelectJoin:doSelectJoin') as $sf_hook) { call_user_func($sf_hook, 'SfGuardUserProfile', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = SfGuardUserProfilePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = SfGuardUserProfilePeer::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 { $cls = SfGuardUserProfilePeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); SfGuardUserProfilePeer::addInstanceToPool($obj1, $key1); } // if $obj1 already loaded $key2 = SfGuardUserProfileI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); if ($key2 !== null) { $obj2 = SfGuardUserProfileI18nPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = SfGuardUserProfileI18nPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol); SfGuardUserProfileI18nPeer::addInstanceToPool($obj2, $key2); } // if obj2 already loaded $obj1->setSfGuardUserProfileI18nForCulture($obj2, $culture); } // if joined row was not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public function executeMore(sfWebRequest $request) { $vanity = $request->getParameter('username'); $culture = $this->getUser()->getCulture(); $this->page = $request->getParameter("page"); if ($this->page) { $this->page += 1; } else { $this->page = 1; } $c = new Criteria(); $c->add(SfGuardUserProfilePeer::VANITY, $vanity, Criteria::EQUAL); $userProfile = SfGuardUserProfilePeer::doSelectOne($c); $this->forward404Unless($userProfile); $this->user = $userProfile->getsfGuardUser(); /* $criteria = new Criteria(); $criteria->add(SfReviewPeer::IS_ACTIVE, true); //$criteria->add(SfReviewPeer::CULTURE, $culture); $criteria->add(SfReviewPeer::SF_GUARD_USER_ID , $this->user->getId()); $criteria->addDescendingOrderByColumn("IFNULL(".SfReviewPeer::MODIFIED_AT.",".SfReviewPeer::CREATED_AT.")"); $this->reviews = new sfPropelPager('SfReview', BaseSfReviewManager::NUM_REVIEWS); $this->reviews->setCriteria($criteria); if ($this->page) { $this->page += 1; $this->reviews->setPage( $this->page ); } else { $this->page = 1; } $this->reviews->init(); */ $this->reviews = SfReviewManager::getReviewsByUser($this->user->getId(), $this->f, $this->page ? $this->page : 1); }
/** * 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->id !== null) { $this->aSfGuardUserProfile = SfGuardUserProfilePeer::retrieveByPk($this->id); /* 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->addSfGuardUserProfileI18ns($this); */ } return $this->aSfGuardUserProfile; }
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'; } }
/** * 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->setNombre($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setApellidos($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setFechaNacimiento($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setPais($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setFormacion($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setResidencia($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setCreatedAt($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setVanity($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setImagen($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setCodigo($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setPapelVoota($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setMailsComentarios($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setMailsNoticias($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setMailsContacto($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setMailsSeguidor($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setNumeroSocio($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setFacebookUid($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setEmail($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setEmailHash($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setFbPublishVotos($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setFbPublishVotosOtros($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setFbPublishCambiosPerfil($arr[$keys[23]]); } if (array_key_exists($keys[24], $arr)) { $this->setFbTip($arr[$keys[24]]); } if (array_key_exists($keys[25], $arr)) { $this->setTwPublishVotos($arr[$keys[25]]); } if (array_key_exists($keys[26], $arr)) { $this->setTwPublishVotosOtros($arr[$keys[26]]); } if (array_key_exists($keys[27], $arr)) { $this->setTwPublishCambiosPerfil($arr[$keys[27]]); } if (array_key_exists($keys[28], $arr)) { $this->setTwOauthToken($arr[$keys[28]]); } if (array_key_exists($keys[29], $arr)) { $this->setTwOauthTokenSecret($arr[$keys[29]]); } if (array_key_exists($keys[30], $arr)) { $this->setAnonymous($arr[$keys[30]]); } }