コード例 #1
0
 /**
  * This is a symfony workaround. As soon as someone logs in check if they are in the DB.
  * If they aren't just insert them so they can authenticate.
  *
  * @param sfWebRequest $request
  */
 public function executeSignin($request)
 {
     if ($request->isMethod("post")) {
         $form = new sfGuardFormSignin();
         $username = $request->getParameter($form->getName() . "[username]");
         $c = new Criteria();
         $c->add(sfGuardUserPeer::USERNAME, $username);
         $res = sfGuardUserPeer::doCount($c);
         // if they dont exist in the db then stick them in so LDAP works
         if ($res == 0) {
             $u = new sfGuardUser();
             $u->setUsername($username);
             $u->save();
             $u->getProfile();
         }
     }
     parent::executeSignin($request);
 }
コード例 #2
0
ファイル: SfVoCounter.class.php プロジェクト: voota/voota
 public static function countUsers()
 {
     $cache = sfcontext::getInstance()->getViewCacheManager() ? sfcontext::getInstance()->getViewCacheManager()->getCache() : false;
     if ($cache) {
         $key = md5("users_counter");
         $data = unserialize($cache->get($key));
     } else {
         $data = false;
     }
     if (!$data) {
         //$user = sfContext::getInstance()->getUser();
         //$culture = $user->getCulture();
         $cuser = new Criteria();
         $cuser->add(sfGuardUserPeer::IS_ACTIVE, 1);
         $data = sfGuardUserPeer::doCount($cuser);
         if ($cache) {
             $cache->set($key, serialize($data), 360);
         }
     }
     return $data;
 }