439050b1ba2f8cde631408e6799300d6cc2776dd
[atutor.git] / mods / wiki / plugins / auth-liveuser / liveuser_conf.php
1 <?php
2
3 /**
4  * Copyright (c) 2003, The Burgiss Group, LLC
5  * This source code is part of eWiki LiveUser Plugin.
6  *
7  * eWiki LiveUser Plugin is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or (at your
10  * option) any later version.
11  *
12  * eWiki LiveUser Plugin is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with Wiki LiveUser Plugin; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 require_once('DB.php');
23
24 /* constant definitions of liveuser entities should be inserted here. primarily,
25  * only area and right constants are necessary. constants for entities made
26  * after the setup script (e.g. during plugin usage), may also be added here
27  * as the need arises.
28  */
29 /*
30  * prefix for internal database table names
31  */
32 define('LW_PREFIX', 'liveuser_plugin');
33
34 /*
35  * min/max length of randomly generated passwords.
36  */ 
37 define('LW_PASSWORD_LEN_MIN', 7);
38 define('LW_PASSWORD_LEN_MAX', 10);
39
40 /*
41  * the liveuserBaseRings array is used internally to denote base action levels,
42  * which will be used in assigning permissions. the liveuserPermRings array links
43  * ewiki actions to a qualified base ring. the lowest ring level (admin) is 0,
44  * and all rings should be at least 0.
45  */
46 $liveuserBaseRings = array('view' => 4, 'forum' => 3, 'edit' => 2, 'manage' => 1, 'admin' => 0);
47 $liveuserPermRings = array('view'        => $liveuserBaseRings['view'],
48                            'info'        => $liveuserBaseRings['view'],
49                            'links'       => $liveuserBaseRings['view'],
50                            'extodo'      => $liveuserBaseRings['view'],
51                            'expolicy'    => $liveuserBaseRings['view'],
52                            'search'        => $liveuserBaseRings['view'],
53                            'diff'        => $liveuserBaseRings['view'],
54                            'calendar'    => $liveuserBaseRings['view'],
55                            'binary-cache'  => $liveuserBaseRings['view'],
56                            'binary-get'    => $liveuserBaseRings['view'],
57                            'sitemap'        => $liveuserBaseRings['view'],
58                            'like'           => $liveuserBaseRings['view'],
59                            'addpost'     => $liveuserBaseRings['forum'],
60                            'addthread'   => $liveuserBaseRings['forum'],
61                            'edit'        => $liveuserBaseRings['edit'],
62                            'fetchback'   => $liveuserBaseRings['edit'],  
63                            'attachments' => $liveuserBaseRings['edit'],
64                            'wikidump'       => $liveuserBaseRings['view'],
65                            'updformatheader'=> $liveuserBaseRings['manage'],
66                            'manage'      => $liveuserBaseRings['manage'],
67                            'binary-upload' => $liveuserBaseRings['manage'],
68                            'admin'       => $liveuserBaseRings['admin']);
69
70 /*
71  * the following arrays will be used to filter displayed permission names when
72  * editing a page. any permission names not cross-listed in liveuserPublicPerms
73  * will be kept hidden (and thus cannot be assigned). any permission names
74  * additionally listed in liveuserDefaultPerms will be selected in the form
75  * by default.
76  */
77 $liveuserPublicPerms = array('Staff');
78 $liveuserDefaultPermsView = array('Staff');
79 $liveuserDefaultPermsEdit = array('Staff');
80
81 /*
82  * database configuration. the liveuserDSN variable should be set to a valid DSN
83  * string according to PEAR::DB specifications.
84  * <http://pear.php.net/manual/en/package.database.db.intro-dsn.php>
85  *
86  * (mysql is the type for mysql databases)
87  */
88 $liveuserDSN = 'type://username:password@server/database';
89
90 /*
91  * the following array contains liveuser configuration parameters.
92  */
93 $liveuserConfig = array('session'        => array('name' => 'PHPSESSID', 'varname' => 'loginInfo'),
94                         'login'          => array('method' => 'post', 'username' => 'username', 'password' => 'password', 'force' => false),
95                         'logout'         => array('destroy' => true),
96                         'autoInit'       => true,
97                         'authContainers' => array(0 => array('name' => 'eWiki',
98                                                              'type' => 'DB',
99                                                              'dsn' => $liveuserDSN,
100                                                              'loginTimeout' => 0,
101                                                              'expireTime' => 43200,
102                                                              'idleTime' => 7200,
103                                                              'allowDuplicateHandles' => 0,
104                                                              'authTable' => 'liveuser_users',
105                                                              'passwordEncryptionMode' => 'MD5'
106                                                              )
107                                                   ),
108                         'permContainer'  => array('type' => 'DB_Complex',
109                                                   'dsn' => $liveuserDSN,                                                                
110                                                   'prefix' => 'liveuser_'
111                                                   )
112                        );
113
114 /*
115  * The following PEAR error handler may be set to globally handle errors generated
116  * by PEAR classes. It provides debug/backtrace output for user-level PHP errors.
117  * If used, PHP should be set not to display internal error messages to clients.
118  *
119  * @param object err PEAR error object 
120  */
121 function _liveuser_error_handler($err) {        
122   $log = $err->toString();
123   if(function_exists('debug_backtrace')){
124         // remove first step from backtrace (this function call), and parse remaining stack trace
125         $trace = debug_backtrace();
126         array_shift($trace);
127         foreach ($trace as $step) {
128                 $log .= "\n";
129                 if (isset($step['file'])) $log .= $step['file'].':';
130                 if (isset($step['line'])) $log .= $step['line'].' ';
131                 if (isset($step['function'])) {
132                         $log .= $step['function'].'(';
133                         if (isset($step['args'])) {
134                                 $args = '';
135                                 foreach ($step['args'] as $arg) { $args .= '\''.$arg.'\','; }
136                                 $log .= rtrim($args,',');
137                         }
138                         $log .= ') ';
139                 }
140         }
141   }
142         error_log($log."\n", 0);
143         exit('<p>An internal error has occurred. Please consult the error logs for additional information</p>');
144 }
145
146 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, '_liveuser_error_handler');
147 $liveuserDB  =& DB::connect($liveuserDSN);
148 $liveuserDB->setFetchMode(DB_FETCHMODE_ASSOC);
149
150 ?>