root/trunk/lib/model/UserPeer.php

Revision 88, 2.1 kB (checked in by fabien, 2 years ago)

updated to symfony 1.0 beta 1

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3   // include base peer class
4   require_once 'lib/model/om/BaseUserPeer.php';
5  
6   // include object class
7   include_once 'lib/model/User.php';
8
9
10 /**
11  * Skeleton subclass for performing query and update operations on the 'ask_user' table.
12  *
13  *
14  *
15  * You should add additional methods to this class to meet the
16  * application requirements.  This class will only be generated as
17  * long as it does not already exist in the output directory.
18  *
19  * @package model
20  */   
21 class UserPeer extends BaseUserPeer
22 {
23   public static function getUserFromNickname($nickname)
24   {
25     $c = new Criteria();
26     $c->add(self::NICKNAME, $nickname);
27
28     return self::doSelectOne($c);
29   }
30
31   public static function getAuthenticatedUser($nickname, $password)
32   {
33     $user = self::getUserFromNickname($nickname);
34
35     // nickname exists?
36     if ($user)
37     {
38       // password is OK?
39       if (sha1($user->getSalt().$password) == $user->getSha1Password())
40       {
41         return $user;
42       }
43     }
44
45     return null;
46   }
47
48   public static function getModeratorCandidatesCount()
49   {
50     $c = new Criteria();
51     $c->add(self::WANT_TO_BE_MODERATOR, true);
52
53     return self::doCount($c);
54   }
55
56   public static function getModeratorCandidates()
57   {
58     $c = new Criteria();
59     $c->add(self::WANT_TO_BE_MODERATOR, true);
60     $c->addAscendingOrderByColumn(self::CREATED_AT);
61
62     return self::doSelect($c);
63   }
64
65   public static function getModerators()
66   {
67     $c = new Criteria();
68     $c->add(self::IS_MODERATOR, true);
69     $c->addAscendingOrderByColumn(self::CREATED_AT);
70
71     return self::doSelect($c);
72   }
73
74   public static function getAdministrators()
75   {
76     $c = new Criteria();
77     $c->add(self::IS_ADMINISTRATOR, true);
78     $c->addAscendingOrderByColumn(self::CREATED_AT);
79
80     return self::doSelect($c);
81   }
82
83   public static function getProblematicUsersCount()
84   {
85     $c = new Criteria();
86     $c->add(self::DELETIONS, 0, Criteria::GREATER_THAN);
87
88     return self::doCount($c);
89   }
90
91   public static function getProblematicUsers()
92   {
93     $c = new Criteria();
94     $c->add(self::DELETIONS, 0, Criteria::GREATER_THAN);
95     $c->addDescendingOrderByColumn(self::DELETIONS);
96
97     return self::doSelect($c);
98   }
99 }
100
101 ?>
Note: See TracBrowser for help on using the browser.