public function executeLog_in(sfWebRequest $request)
 {
     $user = $request->getParameter('txtUsuarioLogin');
     $password = $request->getParameter('txtPasswordLogin');
     $lib = new practil_lib();
     $url = $lib->url_practil_login($user, $password);
     $respuesta_login = file_get_contents($url);
     $decode = json_decode($respuesta_login);
     $this->getUser()->setAttribute('s_pk_practil_associate_account', null);
     if ($decode->{'success'}) {
         $criteria = new Criteria();
         $criteria->add(UserScPeer::PROFILE, $decode->{'pkaccount'});
         $current_user = UserScPeer::doSelectOne($criteria);
         if (is_object($current_user)) {
             $this->getUser()->setAuthenticated(true);
             $this->getUser()->setAttribute(sfConfig::get('app_session_current_user'), $current_user);
             $this->getUser()->setAttribute(sfConfig::get('app_session_current_user_name'), $decode->{'name'});
             return $this->redirect('@homepage');
         } else {
             return $this->redirect('@homepage');
         }
     } else {
         if ($decode->{'code'} == "p-10004") {
             $this->token = md5($decode->{'code'});
             $this->user = $user;
             $this->getUser()->setAttribute('s_pk_practil_associate_account', $decode->{'tokenpk'});
             return 'Practil';
         } else {
             return $this->redirect('@homepage');
         }
     }
 }
 public function return_user_id($profile = null)
 {
     if ($profile != null) {
         $criterio_busqueda_profile = new Criteria();
         $criterio_busqueda_profile->add(UserScPeer::PROFILE, $profile);
         $user = UserScPeer::doSelectOne($criterio_busqueda_profile);
         if (is_object($user)) {
             return $user;
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
 /**
  * Get the associated UserSc object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     UserSc The associated UserSc object.
  * @throws     PropelException
  */
 public function getUserSc(PropelPDO $con = null)
 {
     if ($this->aUserSc === null && $this->user_id !== null) {
         $this->aUserSc = UserScPeer::retrieveByPk($this->user_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->aUserSc->addTreeUsers($this);
         		 */
     }
     return $this->aUserSc;
 }
 /**
  * Selects a collection of TreeSc objects pre-filled with all related objects except PeriodoSc.
  *
  * @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 TreeSc objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptPeriodoSc(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     TreeScPeer::addSelectColumns($criteria);
     $startcol2 = TreeScPeer::NUM_COLUMNS - TreeScPeer::NUM_LAZY_LOAD_COLUMNS;
     UserScPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (UserScPeer::NUM_COLUMNS - UserScPeer::NUM_LAZY_LOAD_COLUMNS);
     GrupoTrabajoScPeer::addSelectColumns($criteria);
     $startcol4 = $startcol3 + (GrupoTrabajoScPeer::NUM_COLUMNS - GrupoTrabajoScPeer::NUM_LAZY_LOAD_COLUMNS);
     UserScPeer::addSelectColumns($criteria);
     $startcol5 = $startcol4 + (UserScPeer::NUM_COLUMNS - UserScPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(TreeScPeer::USER_ID, UserScPeer::ID, $join_behavior);
     $criteria->addJoin(TreeScPeer::GRUPO_TRABAJO_ID, GrupoTrabajoScPeer::ID, $join_behavior);
     $criteria->addJoin(TreeScPeer::RESPONSABLE_ID, UserScPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseTreeScPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = TreeScPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = TreeScPeer::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 = TreeScPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             TreeScPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined UserSc rows
         $key2 = UserScPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserScPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserScPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserScPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (TreeSc) to the collection in $obj2 (UserSc)
             $obj2->addTreeScRelatedByUserId($obj1);
         }
         // if joined row is not null
         // Add objects for joined GrupoTrabajoSc rows
         $key3 = GrupoTrabajoScPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = GrupoTrabajoScPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $cls = GrupoTrabajoScPeer::getOMClass(false);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 GrupoTrabajoScPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (TreeSc) to the collection in $obj3 (GrupoTrabajoSc)
             $obj3->addTreeSc($obj1);
         }
         // if joined row is not null
         // Add objects for joined UserSc rows
         $key4 = UserScPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = UserScPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $cls = UserScPeer::getOMClass(false);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 UserScPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (TreeSc) to the collection in $obj4 (UserSc)
             $obj4->addTreeScRelatedByResponsableId($obj1);
         }
         // if joined row is 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 = UserScPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setEmail($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setProfile($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setPassword($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setFlag($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setTokenSession($arr[$keys[6]]);
     }
 }
 /**
  * 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(UserScPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(UserScPeer::DATABASE_NAME);
         $criteria->add(UserScPeer::ID, $pks, Criteria::IN);
         $objs = UserScPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * Selects a collection of GrupoTrabajoSc 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 GrupoTrabajoSc 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);
     }
     GrupoTrabajoScPeer::addSelectColumns($criteria);
     $startcol2 = GrupoTrabajoScPeer::NUM_COLUMNS - GrupoTrabajoScPeer::NUM_LAZY_LOAD_COLUMNS;
     UserScPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (UserScPeer::NUM_COLUMNS - UserScPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(GrupoTrabajoScPeer::OWNER_ID, UserScPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseGrupoTrabajoScPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = GrupoTrabajoScPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = GrupoTrabajoScPeer::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 = GrupoTrabajoScPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             GrupoTrabajoScPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined UserSc rows
         $key2 = UserScPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = UserScPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = UserScPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 UserScPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (GrupoTrabajoSc) to the collection in $obj2 (UserSc)
             $obj2->addGrupoTrabajoSc($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
 private function executeHuman_execute($group_humman)
 {
     $group_humman_id = $group_humman->getId();
     $criterio = new Criteria();
     $criterio->add(DetalleGrupoTrabajoScPeer::GRUPO_ID, $group_humman_id);
     $list_group = DetalleGrupoTrabajoScPeer::doSelect($criterio);
     $criterio->clear();
     $criterio->add(QuestionHumanScPeer::GRUPO_ID, $group_humman_id);
     $criterio->add(QuestionHumanScPeer::FLAG, 2);
     $list_question = QuestionHumanScPeer::doSelect($criterio);
     if (count($list_group) > 0) {
         //primero vamos a generar las preguntas que estan por defecto
         foreach ($list_group as $row) {
             if ($row->getUserId() != null) {
                 $list_down = $this->executeLevel_down($row->getUserSc(), $row->getGrupoTrabajoSc());
                 if (count($list_down) > 0) {
                     foreach ($list_down as $user) {
                         if (count($list_question) > 0) {
                             $headQuestion = new HeadEvaluaciones();
                             $headQuestion->setCreateAt(time());
                             $headQuestion->setUpdateAt(time());
                             $headQuestion->setUserId($row->getUserId());
                             $headQuestion->setFlag(1);
                             $headQuestion->save();
                             foreach ($list_question as $question) {
                                 $beanQuestion = new EvaluacionesUser();
                                 $beanQuestion->setQuestionId($question->getId());
                                 $beanQuestion->setTypeQuestion(2);
                                 $beanQuestion->setEvaluated($user->getUserId());
                                 $beanQuestion->setHeadId($headQuestion->getId());
                                 $beanQuestion->setFlag(1);
                                 $beanQuestion->setRespuesta(0);
                                 $beanQuestion->save();
                             }
                         }
                     }
                 }
             }
         }
         //ahora level superior!!
         //vamos verificar si tiene activado la opcion
         if ($group_humman->getHumanHigher() == 'on') {
             foreach ($list_group as $row2) {
                 if ($row->getUserId() != null) {
                     $boss_id = $this->executeLevel_top($row2->getUserSc(), $row2->getGrupoTrabajoSc());
                     if ($boss_id != null) {
                         $user2 = UserScPeer::retrieveByPK($boss_id);
                         if (is_object($user2)) {
                             if (count($list_question) > 0) {
                                 $headQuestion = new HeadEvaluaciones();
                                 $headQuestion->setCreateAt(time());
                                 $headQuestion->setUpdateAt(time());
                                 $headQuestion->setUserId($row2->getUserId());
                                 $headQuestion->setFlag(1);
                                 $headQuestion->save();
                                 foreach ($list_question as $question) {
                                     $beanQuestion = new EvaluacionesUser();
                                     $beanQuestion->setQuestionId($question->getId());
                                     $beanQuestion->setTypeQuestion(3);
                                     $beanQuestion->setEvaluated($user2->getId());
                                     $beanQuestion->setHeadId($headQuestion->getId());
                                     $beanQuestion->setFlag(1);
                                     $beanQuestion->setRespuesta(0);
                                     $beanQuestion->save();
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //por ultimo vamos a ver la auto evaluacion
         //eso para despues....
     }
 }