7 class User
extends AOOSModule
{
8 public function dependencies() {
9 return array("Paginator", "Form", "Reciever");
13 * Model m1 contains information on the current user. If the user isn't logged in, the model is empty(maybe some
14 * default values later on). When the user logs in, data is fetched from the database and the model contains a
15 * single row with all of the user's information.
16 * Model m1 is also used when a new user is created. When that happens, data is inserted into a new row in the model
17 * and save is called on the model.
18 * Model m2 contains the uid and the username of all users in the database. This ensures that usernames can be
19 * pulled quickly when you have the uid of the user.
21 public function dataModelDefinition() {
23 $m1 = new AOOSModel($this->core());
24 $m1->setColumnIndex("username", "password", "email", "signature", "avatar", "active", "activationcode", "joined", "status");
25 $m1->setProperties("username", AOOSMODEL_TYPE_STRING
, AOOSMODEL_FLAG_FROM_DATABASE
, AOOSMODEL_PROP_ESCAPE|AOOSMODEL_PROP_NOHTML|AOOSMODEL_PROP_STRIP
);
26 $m1->addConstraint("username", "Match", "/[a-zA-Z0-9-_]+/");
27 $m1->addConstraint("username", "Length", 50);
28 $m1->setProperties("password", AOOSMODEL_TYPE_STRING
, AOOSMODEL_FLAG_FROM_DATABASE
, AOOSMODEL_PROP_HASH|AOOSMODEL_PROP_STRIP
);
29 $m1->setProperties("email", AOOSMODEL_TYPE_STRING
, AOOSMODEL_FLAG_FROM_DATABASE
, AOOSMODEL_PROP_ESCAPE|AOOSMODEL_PROP_NOHTML|AOOSMODEL_PROP_STRIP
);
30 $m1->addConstraint("email", "Match", "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/"); // Match email
31 $m1->setProperties("signature", AOOSMODEL_TYPE_TEXT
, AOOSMODEL_FLAG_FROM_DATABASE
, AOOSMODEL_PROP_ESCAPE|AOOSMODEL_PROP_NOHTML
);
32 $m1->addConstraint("signature", "Length", 256);
33 // XXX $m1->setProperties("avatar", AOOSMODEL_TYPE_STRING, AOOSMODEL_FLAG_FROM_DATABASE, AOOSMODEL_PROP_ESCAPE);
34 $m1->setProperties("active", AOOSMODEL_TYPE_BOOLEAN
, AOOSMODEL_FLAG_FROM_DATABASE|AOOSMODEL_FLAG_GUI_PRIVATE
);
35 $m1->setProperties("activationcode", AOOSMODEL_TYPE_INTEGER
, AOOSMODEL_FLAG_FROM_DATABASE
);
36 $m1->setProperties("joined", AOOSMODEL_TYPE_INTEGER
, AOOSMODEL_FLAG_FROM_DATABASE
, AOOSMODEL_PROP_TIME
);
37 $m1->setProperties("status", AOOSMODEL_TYPE_INTEGER
, AOOSMODEL_FLAG_FROM_DATABASE
); // AOOSMODEL_TYPE_ENUM
39 // All users. Only the most important fields are fetched here
40 $m2 = new AOOSModel($this->core());
41 $m2->setColumnIndex("uid", "username");
42 $m2->setProperties("uid", AOOSMODEL_TYPE_INTEGER
, AOOSMODEL_FLAG_FROM_DATABASE|AOOSMODEL_FLAG_PRIMARY_KEY
);
43 $m2->setProperties("username", AOOSMODEL_TYPE_STRING
, AOOSMODEL_FLAG_FROM_DATABASE|AOOSMODEL_FLAG_UNIQUE
, AOOSMODEL_PROP_ESCAPE|AOOSMODEL_PROP_NOHTML|AOOSMODEL_PROP_STRIP
);
45 $a = array("USER" => $m1, "USERLIST" => $m2);
49 public function show() {
50 $this->dataModel("USERLIST")->populate();
54 public function createUser() {
58 public function deleteUser() {
62 public function updateUser() {
66 public function activateUser() {
70 public function login() {