4 * Copyright (c) 2003, The Burgiss Group, LLC
5 * This source code is part of eWiki LiveUser Plugin.
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.
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
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
22 require_once('DB.php');
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
30 * prefix for internal database table names
32 define('LW_PREFIX', 'liveuser_plugin');
35 * min/max length of randomly generated passwords.
37 define('LW_PASSWORD_LEN_MIN', 7);
38 define('LW_PASSWORD_LEN_MAX', 10);
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.
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']);
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
77 $liveuserPublicPerms = array('Staff');
78 $liveuserDefaultPermsView = array('Staff');
79 $liveuserDefaultPermsEdit = array('Staff');
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>
86 * (mysql is the type for mysql databases)
88 $liveuserDSN = 'type://username:password@server/database';
91 * the following array contains liveuser configuration parameters.
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),
97 'authContainers' => array(0 => array('name' => 'eWiki',
99 'dsn' => $liveuserDSN,
101 'expireTime' => 43200,
103 'allowDuplicateHandles' => 0,
104 'authTable' => 'liveuser_users',
105 'passwordEncryptionMode' => 'MD5'
108 'permContainer' => array('type' => 'DB_Complex',
109 'dsn' => $liveuserDSN,
110 'prefix' => 'liveuser_'
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.
119 * @param object err PEAR error object
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();
127 foreach ($trace as $step) {
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'])) {
135 foreach ($step['args'] as $arg) { $args .= '\''.$arg.'\','; }
136 $log .= rtrim($args,',');
142 error_log($log."\n", 0);
143 exit('<p>An internal error has occurred. Please consult the error logs for additional information</p>');
146 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, '_liveuser_error_handler');
147 $liveuserDB =& DB::connect($liveuserDSN);
148 $liveuserDB->setFetchMode(DB_FETCHMODE_ASSOC);