3 class AuthorModel
extends ActiveMongo
8 function getCollectionName()
16 * - It must be unique (handled by MongoDB actually).
17 * - It can't be changed.
18 * - It must be /[a-z][a-z0-9\-\_]+/
19 * - It must be longer than 5 letters.
23 function username_filter($value, $old_value)
25 if ($old_value!=null && $value != $old_value) {
26 throw new FilterException("The username can't be changed");
29 if (!preg_match("/[a-z][a-z0-9\-\_]+/", $value)) {
30 throw new FilterException("The username is not valid");
33 if (strlen($value) < 5) {
34 throw new Exception("Username too short");
41 * When an User updates his profile, we need to
42 * make sure that every post written by him is also
43 * updated with his name and username.
49 $post = new PostModel
;
50 $post->updateAuthorInfo($this->getID());
55 $collection = & $this->_getCollection();
56 $collection->ensureIndex(array('username' => 1), array('unique'=> 1, 'background' => 1));