Arbit - project tracking

PHPillow - PHP CouchDB connector

Browse source code

File: / src/ classes/ view/ user.php

Type
text/plain text/plain
Last Author
kore
Version
159
Line Rev. Author Source
1 1 kore <?php
2 kore /**
3 2 kore * phpillow CouchDB backend
4 1 kore *
5 2 kore * This file is part of phpillow.
6 1 kore *
7 3 kore * phpillow is free software; you can redistribute it and/or modify it under
8 kore * the terms of the GNU Lesser General Public License as published by the Free
9 kore * Software Foundation; version 3 of the License.
10 1 kore *
11 3 kore * phpillow is distributed in the hope that it will be useful, but WITHOUT ANY
12 kore * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 kore * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 kore * more details.
15 1 kore *
16 3 kore * You should have received a copy of the GNU Lesser General Public License
17 kore * along with phpillow; if not, write to the Free Software Foundation, Inc., 51
18 kore * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 1 kore *
20 kore * @package Core
21 4 kore * @version $Revision: 159 $
22 3 kore * @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
23 1 kore */
24 kore
25 kore /**
26 kore * Wrapper for user views
27 kore *
28 kore * @package Core
29 4 kore * @version $Revision: 159 $
30 3 kore * @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
31 1 kore */
32 4 kore class phpillowUserView extends phpillowView
33 1 kore {
34 kore /**
35 kore * View functions to be registered on the server
36 kore *
37 kore * @var array
38 kore */
39 kore protected $viewDefinitions = array(
40 kore // Add plain view on all users
41 kore 'all' => 'function( doc )
42 kore {
43 kore if ( doc.type == "user" )
44 kore {
45 6 kore emit( null, doc._id );
46 1 kore }
47 kore }',
48 kore // Add view for all users indexed by their login name
49 kore 'user' => 'function( doc )
50 kore {
51 kore if ( doc.type == "user" )
52 kore {
53 6 kore emit( doc.login, doc._id );
54 1 kore }
55 kore }',
56 kore // Add view for unregistered users waiting for activation
57 kore 'unregistered' => 'function( doc )
58 kore {
59 kore if ( doc.type == "user" &&
60 kore doc.valid !== "0" &&
61 kore doc.valid !== "1" )
62 kore {
63 6 kore emit( doc.valid, doc._id );
64 1 kore }
65 kore }',
66 kore );
67 kore
68 kore /**
69 94 kore * Create a new instance of the document class
70 kore *
71 kore * Create a new instance of the statically called document class.
72 kore * Implementing this method should only be required when using PHP 5.2 and
73 kore * lower, otherwise the class can be determined using LSB.
74 kore *
75 kore * Do not pass a parameter to this method, this is only used to maintain
76 kore * the called class information for PHP 5.2 and lower.
77 kore *
78 kore * @param mixed $docType
79 159 kore * @return phpillowUserView
80 94 kore */
81 kore public static function createNew( $docType = null )
82 kore {
83 kore return parent::createNew( $docType === null ? __CLASS__ : $docType );
84 kore }
85 kore
86 kore /**
87 1 kore * Get name of view
88 159 kore *
89 1 kore * Get name of view
90 159 kore *
91 1 kore * @return string
92 kore */
93 94 kore protected function getViewName()
94 1 kore {
95 kore return 'users';
96 kore }
97 kore }
98 kore