]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser.php
PageList enhanced and improved.
[SourceForge/phpwiki.git] / lib / WikiUser.php
1 <?php //-*-php-*-
2 rcs_id('$Id: WikiUser.php,v 1.49 2004-02-15 21:34:37 rurban Exp $');
3
4 // It is anticipated that when userid support is added to phpwiki,
5 // this object will hold much more information (e-mail,
6 // home(wiki)page, etc.) about the user.
7
8 // There seems to be no clean way to "log out" a user when using HTTP
9 // authentication. So we'll hack around this by storing the currently
10 // logged in username and other state information in a cookie.
11
12 // 2002-09-08 11:44:04 rurban
13 // Todo: Fix prefs cookie/session handling:
14 //       _userid and _homepage cookie/session vars still hold the
15 //       serialized string.
16 //       If no homepage, fallback to prefs in cookie as in 1.3.3.
17
18 define('WIKIAUTH_ANON', 0);
19 define('WIKIAUTH_BOGO', 1);     // any valid WikiWord is enough
20 define('WIKIAUTH_USER', 2);     // real auth from a database/file/server.
21
22 define('WIKIAUTH_ADMIN', 10);
23 define('WIKIAUTH_FORBIDDEN', 11); // Completely not allowed.
24
25 $UserPreferences = array(
26                          'userid'        => new _UserPreference(''), // really store this also?
27                          'passwd'        => new _UserPreference(''),
28                          'email'         => new _UserPreference(''),
29                          'emailVerified' => new _UserPreference_bool(),
30                          'notifyPages'   => new _UserPreference(''),
31                          'theme'         => new _UserPreference_theme(THEME),
32                          'lang'          => new _UserPreference_language(DEFAULT_LANGUAGE),
33                          'editWidth'     => new _UserPreference_int(80, 30, 150),
34                          'noLinkIcons'   => new _UserPreference_bool(),
35                          'editHeight'    => new _UserPreference_int(22, 5, 80),
36                          'timeOffset'    => new _UserPreference_numeric(0, -26, 26),
37                          'relativeDates' => new _UserPreference_bool()
38                          );
39
40 function WikiUserClassname() {
41     return 'WikiUser';
42 }
43
44 function UpgradeUser ($olduser, $user) {
45     if (isa($user,'WikiUser') and isa($olduser,'WikiUser')) {
46         // populate the upgraded class with the values from the old object
47         foreach (get_object_vars($olduser) as $k => $v) {
48             $user->$k = $v;     
49         }
50         $GLOBALS['request']->_user = $user;
51         return $user;
52     } else {
53         return false;
54     }
55 }
56
57 /**
58
59 */
60 class WikiUser {
61     var $_userid = false;
62     var $_level  = false;
63     var $_request, $_dbi, $_authdbi, $_homepage;
64     var $_authmethod = '', $_authhow = '';
65
66     /**
67      * Constructor.
68      * 
69      * Populates the instance variables and calls $this->_ok() 
70      * to ensure that the parameters are valid.
71      * @param mixed $userid String of username or WikiUser object.
72      * @param integer $authlevel Authorization level.
73      */
74     function WikiUser (&$request, $userid = false, $authlevel = false) {
75         $this->_request = &$request;
76         $this->_dbi = &$this->_request->getDbh();
77
78         if (isa($userid, 'WikiUser')) {
79             $this->_userid   = $userid->_userid;
80             $this->_level    = $userid->_level;
81         }
82         else {
83             $this->_userid = $userid;
84             $this->_level = $authlevel;
85         }
86         if (!$this->_ok()) {
87             // Paranoia: if state is at all inconsistent, log out...
88             $this->_userid = false;
89             $this->_level = false;
90             $this->_homepage = false;
91             $this->_authhow .= ' paranoia logout';
92         }
93         if ($this->_userid) {
94             $this->_homepage = $this->_dbi->getPage($this->_userid);
95         }
96     }
97
98     /**
99     * Get the string indicating how the user was authenticated.
100     * 
101     * Get the string indicating how the user was authenticated.
102     * Does not seem to be set - jbw
103     * @return string The method of authentication.
104     */
105     function auth_how() {
106         return $this->_authhow;
107     }
108
109     /**
110      * Invariant
111      * 
112      * If the WikiUser object has a valid authorization level and the 
113      * userid is a string returns true, else false.
114      * @return boolean If valid level and username string true, else false
115      */
116     function _ok () {
117         if ((in_array($this->_level, array(WIKIAUTH_BOGO,
118                                            WIKIAUTH_USER,
119                                            WIKIAUTH_ADMIN))
120             &&
121             (is_string($this->_userid)))) {
122             return true;
123         }
124         return false;
125     }
126
127     function UserName() {
128         return $this->_userid;
129     }
130
131     function getId () {
132         return ( $this->isSignedIn()
133                  ? $this->_userid
134                  : $this->_request->get('REMOTE_ADDR') ); // FIXME: globals
135     }
136
137     function getAuthenticatedId() {
138         return ( $this->isAuthenticated()
139                  ? $this->_userid
140                  : $this->_request->get('REMOTE_ADDR') ); // FIXME: globals
141     }
142
143     function isSignedIn () {
144         return $this->_level >= WIKIAUTH_BOGO;
145     }
146
147     function isAuthenticated () {
148         return $this->_level >= WIKIAUTH_USER;
149     }
150
151     function isAdmin () {
152         return $this->_level == WIKIAUTH_ADMIN;
153     }
154
155     function hasAuthority ($require_level) {
156         return $this->_level >= $require_level;
157     }
158
159     function AuthCheck ($postargs) {
160         // Normalize args, and extract.
161         $keys = array('userid', 'passwd', 'require_level', 'login', 'logout',
162                       'cancel');
163         foreach ($keys as $key)
164             $args[$key] = isset($postargs[$key]) ? $postargs[$key] : false;
165         extract($args);
166         $require_level = max(0, min(WIKIAUTH_ADMIN, (int)$require_level));
167
168         if ($logout)
169             return new WikiUser($this->_request); // Log out
170         elseif ($cancel)
171             return false;        // User hit cancel button.
172         elseif (!$login && !$userid)
173             return false;       // Nothing to do?
174
175         $authlevel = $this->_pwcheck($userid, $passwd);
176         if (!$authlevel)
177             return _("Invalid password or userid.");
178         elseif ($authlevel < $require_level)
179             return _("Insufficient permissions.");
180
181         // Successful login.
182         $user = new WikiUser($this->_request);
183         $user->_userid = $userid;
184         $user->_level = $authlevel;
185         return $user;
186     }
187
188     function PrintLoginForm (&$request, $args, $fail_message = false,
189                              $seperate_page = true) {
190         include_once('lib/Template.php');
191         // Call update_locale in case the system's default language is not 'en'.
192         // (We have no user pref for lang at this point yet, no one is logged in.)
193         update_locale(DEFAULT_LANGUAGE);
194         $userid = '';
195         $require_level = 0;
196         extract($args); // fixme
197
198         $require_level = max(0, min(WIKIAUTH_ADMIN, (int)$require_level));
199
200         $pagename = $request->getArg('pagename');
201         $login = new Template('login', $request,
202                               compact('pagename', 'userid', 'require_level',
203                                       'fail_message', 'pass_required'));
204         if ($seperate_page) {
205             $top = new Template('html', $request,
206                                 array('TITLE' => _("Sign In")));
207             return $top->printExpansion($login);
208         } else {
209             return $login;
210         }
211     }
212
213     /**
214      * Check password.
215      */
216     function _pwcheck ($userid, $passwd) {
217         global $WikiNameRegexp;
218
219         if (!empty($userid) && $userid == ADMIN_USER) {
220             // $this->_authmethod = 'pagedata';
221             if (defined('ENCRYPTED_PASSWD') && ENCRYPTED_PASSWD)
222                 if ( !empty($passwd)
223                      && crypt($passwd, ADMIN_PASSWD) == ADMIN_PASSWD )
224                     return WIKIAUTH_ADMIN;
225                 else
226                     return false;
227             if (!empty($passwd)) {
228                 if ($passwd == ADMIN_PASSWD)
229                   return WIKIAUTH_ADMIN;
230                 else {
231                     // maybe we forgot to enable ENCRYPTED_PASSWD?
232                     if ( function_exists('crypt')
233                          && crypt($passwd, ADMIN_PASSWD) == ADMIN_PASSWD ) {
234                         trigger_error(_("You forgot to set ENCRYPTED_PASSWD to true. Please update your /index.php"),
235                                       E_USER_WARNING);
236                         return WIKIAUTH_ADMIN;
237                     }
238                 }
239             }
240             return false;
241         }
242         // HTTP Authentication
243         elseif (ALLOW_HTTP_AUTH_LOGIN && !empty($PHP_AUTH_USER)) {
244             // if he ignored the password field, because he is already
245             // authenticated try the previously given password.
246             if (empty($passwd))
247                 $passwd = $PHP_AUTH_PW;
248         }
249
250         // WikiDB_User DB/File Authentication from $DBAuthParams
251         // Check if we have the user. If not try other methods.
252         if (ALLOW_USER_LOGIN) { // && !empty($passwd)) {
253             $request = $this->_request;
254             // first check if the user is known
255             if ($this->exists($userid)) {
256                 $this->_authmethod = 'pagedata';
257                 return ($this->checkPassword($passwd)) ? WIKIAUTH_USER : false;
258             } else {
259                 // else try others such as LDAP authentication:
260                 if (ALLOW_LDAP_LOGIN && !empty($passwd)) {
261                     if ($ldap = ldap_connect(LDAP_AUTH_HOST)) { // must be a valid LDAP server!
262                         $r = @ldap_bind($ldap); // this is an anonymous bind
263                         $st_search = "uid=$userid";
264                         // Need to set the right root search information. see ../index.php
265                         $sr = ldap_search($ldap, LDAP_BASE_DN,
266                                           "$st_search");
267                         $info = ldap_get_entries($ldap, $sr); // there may be more hits with this userid. try every
268                         for ($i = 0; $i < $info["count"]; $i++) {
269                             $dn = $info[$i]["dn"];
270                             // The password is still plain text.
271                             if ($r = @ldap_bind($ldap, $dn, $passwd)) {
272                                 // ldap_bind will return TRUE if everything matches
273                                 ldap_close($ldap);
274                                 $this->_authmethod = 'LDAP';
275                                 return WIKIAUTH_USER;
276                             }
277                         }
278                     } else {
279                         trigger_error("Unable to connect to LDAP server "
280                                       . LDAP_AUTH_HOST, E_USER_WARNING);
281                     }
282                 }
283                 // imap authentication. added by limako
284                 if (ALLOW_IMAP_LOGIN && !empty($passwd)) {
285                     $mbox = @imap_open( "{" . IMAP_AUTH_HOST . "}",
286                                         $userid, $passwd, OP_HALFOPEN );
287                     if($mbox) {
288                         imap_close($mbox);
289                         $this->_authmethod = 'IMAP';
290                         return WIKIAUTH_USER;
291                     }
292                 }
293             }
294         }
295         if ( ALLOW_BOGO_LOGIN
296              && preg_match('/\A' . $WikiNameRegexp . '\z/', $userid) ) {
297             $this->_authmethod = 'BOGO';
298             return WIKIAUTH_BOGO;
299         }
300         return false;
301     }
302
303     // Todo: try our WikiDB backends.
304     function getPreferences() {
305         // Restore saved preferences.
306
307         // I'd rather prefer only to store the UserId in the cookie or
308         // session, and get the preferences from the db or page.
309         if (!($prefs = $this->_request->getCookieVar('WIKI_PREFS2')))
310             $prefs = $this->_request->getSessionVar('wiki_prefs');
311
312         //if (!$this->_userid && !empty($GLOBALS['HTTP_COOKIE_VARS']['WIKI_ID'])) {
313         //    $this->_userid = $GLOBALS['HTTP_COOKIE_VARS']['WIKI_ID'];
314         //}
315
316         // before we get his prefs we should check if he is signed in
317         if (USE_PREFS_IN_PAGE && $this->homePage()) { // in page metadata
318             // old array
319             if ($pref = $this->_homepage->get('pref')) {
320                 //trigger_error("pref=".$pref);//debugging
321                 $prefs = unserialize($pref);
322             }
323         }
324         return new UserPreferences($prefs);
325     }
326
327     // No cookies anymore for all prefs, only the userid. PHP creates
328     // a session cookie in memory, which is much more efficient, 
329     // but not persistent. Get persistency with a homepage or DB Prefs
330     //
331     // Return the number of changed entries
332     function setPreferences($prefs, $id_only = false) {
333         if (!is_object($prefs)) {
334             $prefs = new UserPreferences($prefs);
335         }
336         // update the session and id
337         $this->_request->setSessionVar('wiki_prefs', $prefs);
338         // $this->_request->setCookieVar('WIKI_PREFS2', $this->_prefs, 365);
339         // simple unpacked cookie
340         if ($this->_userid) setcookie('WIKI_ID', $this->_userid, 365, '/');
341
342         // We must ensure that any password is encrypted.
343         // We don't need any plaintext password.
344         if (! $id_only ) {
345             if ($this->isSignedIn()) {
346                 if ($this->isAdmin())
347                     $prefs->set('passwd', '');
348                 // already stored in index.php, and it might be
349                 // plaintext! well oh well
350                 if ($homepage = $this->homePage()) {
351                     // check for page revision 0
352                     if (! $this->_dbi->isWikiPage($this->_userid)) {
353                         trigger_error(_("Your home page has not been created yet so your preferences cannot not be saved."),
354                                       E_USER_WARNING);
355                     }
356                     else {
357                         if ($this->isAdmin() || !$homepage->get('locked')) {
358                             $homepage->set('pref', serialize($prefs->_prefs));
359                             return sizeof($prefs->_prefs);
360                         }
361                         else {
362                             // An "empty" page could still be
363                             // intentionally locked by admin to
364                             // prevent its creation.
365                             //                            
366                             // FIXME: This permission situation should
367                             // probably be handled by the DB backend,
368                             // once the new WikiUser code has been
369                             // implemented.
370                             trigger_error(_("Your home page is locked so your preferences cannot not be saved.")
371                                           . " " . _("Please contact your PhpWiki administrator for assistance."),
372                                           E_USER_WARNING);
373                         }
374                     }
375                 } else {
376                     trigger_error("No homepage for user found. Creating one...",
377                                   E_USER_WARNING);
378                     $this->createHomepage($prefs);
379                     //$homepage->set('pref', serialize($prefs->_prefs));
380                     return sizeof($prefs->_prefs);
381                 }
382             } else {
383                 trigger_error("you must be signed in", E_USER_WARNING);
384             }
385         }
386         return 0;
387     }
388
389     // check for homepage with user flag.
390     // can be overriden from the auth backends
391     function exists() {
392         $homepage = $this->homePage();
393         return ($this->_userid && $homepage && $homepage->get('pref'));
394     }
395
396     // doesn't check for existance!!! hmm.
397     // how to store metadata in not existing pages? how about versions?
398     function homePage() {
399         if (!$this->_userid)
400             return false;
401         if (!empty($this->_homepage)) {
402             return $this->_homepage;
403         } else {
404             $this->_homepage = $this->_dbi->getPage($this->_userid);
405             return $this->_homepage;
406         }
407     }
408
409     // create user by checking his homepage
410     function createUser ($pref, $createDefaultHomepage = true) {
411         if ($this->exists())
412             return;
413         if ($createDefaultHomepage) {
414             $this->createHomepage($pref);
415         } else {
416             // empty page
417             include "lib/loadsave.php";
418             $pageinfo = array('pagedata' => array('pref' => serialize($pref->_pref)),
419                               'versiondata' => array('author' => $this->_userid),
420                               'pagename' => $this->_userid,
421                               'content' => _('CategoryHomepage'));
422             SavePage ($this->_request, $pageinfo, false, false);
423         }
424         $this->setPreferences($pref);
425     }
426
427     // create user and default user homepage
428     function createHomepage ($pref) {
429         $pagename = $this->_userid;
430         include "lib/loadsave.php";
431
432         // create default homepage:
433         //  properly expanded template and the pref metadata
434         $template = Template('homepage.tmpl', $this->_request);
435         $text  = $template->getExpansion();
436         $pageinfo = array('pagedata' => array('pref' => serialize($pref->_pref)),
437                           'versiondata' => array('author' => $this->_userid),
438                           'pagename' => $pagename,
439                           'content' => $text);
440         SavePage ($this->_request, $pageinfo, false, false);
441
442         // create Calender
443         $pagename = $this->_userid . SUBPAGE_SEPARATOR . _('Preferences');
444         if (! isWikiPage($pagename)) {
445             $pageinfo = array('pagedata' => array(),
446                               'versiondata' => array('author' => $this->_userid),
447                               'pagename' => $pagename,
448                               'content' => "<?plugin Calender ?>\n");
449             SavePage ($this->_request, $pageinfo, false, false);
450         }
451
452         // create Preferences
453         $pagename = $this->_userid . SUBPAGE_SEPARATOR . _('Preferences');
454         if (! isWikiPage($pagename)) {
455             $pageinfo = array('pagedata' => array(),
456                               'versiondata' => array('author' => $this->_userid),
457                               'pagename' => $pagename,
458                               'content' => "<?plugin UserPreferences ?>\n");
459             SavePage ($this->_request, $pageinfo, false, false);
460         }
461     }
462
463     function tryAuthBackends() {
464         return ''; // crypt('') will never be ''
465     }
466
467     // Auth backends must store the crypted password where?
468     // Not in the preferences.
469     function checkPassword($passwd) {
470         $prefs = $this->getPreferences();
471         $stored_passwd = $prefs->get('passwd'); // crypted
472         if (empty($prefs->_prefs['passwd']))    // not stored in the page
473             // allow empty passwords? At least store a '*' then.
474             // try other backend. hmm.
475             $stored_passwd = $this->tryAuthBackends($this->_userid);
476         if (empty($stored_passwd)) {
477             trigger_error(sprintf(_("Old UserPage %s without stored password updated with empty password. Set a password in your UserPreferences."),
478                                   $this->_userid), E_USER_NOTICE);
479             $prefs->set('passwd','*');
480             return true;
481         }
482         if ($stored_passwd == '*')
483             return true;
484         if ( !empty($passwd)
485              && crypt($passwd, $stored_passwd) == $stored_passwd )
486             return true;
487         else
488             return false;
489     }
490
491     function changePassword($newpasswd, $passwd2 = false) {
492         if (! $this->mayChangePass() ) {
493             trigger_error(sprintf("Attempt to change an external password for '%s'. Not allowed!",
494                                   $this->_userid), E_USER_ERROR);
495             return;
496         }
497         if ($passwd2 && $passwd2 != $newpasswd) {
498             trigger_error("The second password must be the same as the first to change it",
499                           E_USER_ERROR);
500             return;
501         }
502         $prefs = $this->getPreferences();
503         //$oldpasswd = $prefs->get('passwd');
504         $prefs->set('passwd', crypt($newpasswd));
505         $this->setPreferences($prefs);
506     }
507
508     function mayChangePass() {
509         // on external DBAuth maybe. on IMAP or LDAP not
510         // on internal DBAuth yes
511         if (in_array($this->_authmethod, array('IMAP', 'LDAP')))
512             return false;
513         if ($this->isAdmin())
514             return false;
515         if ($this->_authmethod == 'pagedata')
516             return true;
517         if ($this->_authmethod == 'authdb')
518             return true;
519     }
520                          }
521
522 // create user and default user homepage
523 // FIXME: delete this, not used?
524 /*
525 function createUser ($userid, $pref) {
526     global $request;
527     $user = new WikiUser ($request, $userid);
528     $user->createUser($pref);
529 }
530 */
531
532 class _UserPreference
533 {
534     function _UserPreference ($default_value) {
535         $this->default_value = $default_value;
536     }
537
538     function sanify ($value) {
539         return (string)$value;
540     }
541
542     function update ($value) {
543     }
544 }
545
546 class _UserPreference_numeric
547 extends _UserPreference
548 {
549     function _UserPreference_numeric ($default, $minval = false,
550                                       $maxval = false) {
551         $this->_UserPreference((double)$default);
552         $this->_minval = (double)$minval;
553         $this->_maxval = (double)$maxval;
554     }
555
556     function sanify ($value) {
557         $value = (double)$value;
558         if ($this->_minval !== false && $value < $this->_minval)
559             $value = $this->_minval;
560         if ($this->_maxval !== false && $value > $this->_maxval)
561             $value = $this->_maxval;
562         return $value;
563     }
564 }
565
566 class _UserPreference_int
567 extends _UserPreference_numeric
568 {
569     function _UserPreference_int ($default, $minval = false, $maxval = false) {
570         $this->_UserPreference_numeric((int)$default, (int)$minval,
571                                        (int)$maxval);
572     }
573
574     function sanify ($value) {
575         return (int)parent::sanify((int)$value);
576     }
577 }
578
579 class _UserPreference_bool
580 extends _UserPreference
581 {
582     function _UserPreference_bool ($default = false) {
583         $this->_UserPreference((bool)$default);
584     }
585
586     function sanify ($value) {
587         if (is_array($value)) {
588             /* This allows for constructs like:
589              *
590              *   <input type="hidden" name="pref[boolPref][]" value="0" />
591              *   <input type="checkbox" name="pref[boolPref][]" value="1" />
592              *
593              * (If the checkbox is not checked, only the hidden input
594              * gets sent. If the checkbox is sent, both inputs get
595              * sent.)
596              */
597             foreach ($value as $val) {
598                 if ($val)
599                     return true;
600             }
601             return false;
602         }
603         return (bool) $value;
604     }
605 }
606
607 class _UserPreference_language
608 extends _UserPreference
609 {
610     function _UserPreference_language ($default = DEFAULT_LANGUAGE) {
611         $this->_UserPreference($default);
612     }
613
614     // FIXME: check for valid locale
615     function sanify ($value) {
616         // Revert to DEFAULT_LANGUAGE if user does not specify
617         // language in UserPreferences or chooses <system language>.
618         if ($value == '' or empty($value))
619             $value = DEFAULT_LANGUAGE;
620
621         return (string) $value;
622     }
623 }
624
625 class _UserPreference_theme
626 extends _UserPreference
627 {
628     function _UserPreference_theme ($default = THEME) {
629         $this->_UserPreference($default);
630     }
631
632     function sanify ($value) {
633         if (findFile($this->_themefile($value), true))
634             return $value;
635         return $this->default_value;
636     }
637
638     function update ($newvalue) {
639         global $Theme;
640         include_once($this->_themefile($newvalue));
641         if (empty($Theme))
642             include_once($this->_themefile(THEME));
643     }
644
645     function _themefile ($theme) {
646         return "themes/$theme/themeinfo.php";
647     }
648 }
649
650 // don't save default preferences for efficiency.
651 class UserPreferences {
652     function UserPreferences ($saved_prefs = false) {
653         $this->_prefs = array();
654
655         if (isa($saved_prefs, 'UserPreferences') && $saved_prefs->_prefs) {
656             foreach ($saved_prefs->_prefs as $name => $value)
657                 $this->set($name, $value);
658         } elseif (is_array($saved_prefs)) {
659             foreach ($saved_prefs as $name => $value)
660                 $this->set($name, $value);
661         }
662     }
663
664     function _getPref ($name) {
665         global $UserPreferences;
666         if (!isset($UserPreferences[$name])) {
667             if ($name == 'passwd2') return false;
668             trigger_error("$name: unknown preference", E_USER_NOTICE);
669             return false;
670         }
671         return $UserPreferences[$name];
672     }
673
674     function get ($name) {
675         if (isset($this->_prefs[$name]))
676             return $this->_prefs[$name];
677         if (!($pref = $this->_getPref($name)))
678             return false;
679         return $pref->default_value;
680     }
681
682     function set ($name, $value) {
683         if (!($pref = $this->_getPref($name)))
684             return false;
685
686         $newvalue = $pref->sanify($value);
687         $oldvalue = $this->get($name);
688
689         // update on changes
690         if ($newvalue != $oldvalue)
691             $pref->update($newvalue);
692
693         // don't set default values to save space (in cookies, db and
694         // sesssion)
695         if ($value == $pref->default_value)
696             unset($this->_prefs[$name]);
697         else
698             $this->_prefs[$name] = $newvalue;
699     }
700
701     function pack ($nonpacked) {
702         return serialize($nonpacked);
703     }
704     function unpack ($packed) {
705         if (!$packed)
706             return false;
707         if (substr($packed,0,2) == "O:") {
708             // Looks like a serialized object
709             return unserialize($packed);
710         }
711         //trigger_error("DEBUG: Can't unpack bad UserPreferences",
712         //E_USER_WARNING);
713         return false;
714     }
715
716     function hash () {
717         return hash($this->_prefs);
718     }
719 }
720
721 // $Log: not supported by cvs2svn $
722 // Revision 1.48  2004/02/01 09:14:11  rurban
723 // Started with Group_Ldap (not yet ready)
724 // added new _AuthInfo plugin to help in auth problems (warning: may display passwords)
725 // fixed some configurator vars
726 // renamed LDAP_AUTH_SEARCH to LDAP_BASE_DN
727 // changed PHPWIKI_VERSION from 1.3.8a to 1.3.8pre
728 // USE_DB_SESSION defaults to true on SQL
729 // changed GROUP_METHOD definition to string, not constants
730 // changed sample user DBAuthParams from UPDATE to REPLACE to be able to
731 //   create users. (Not to be used with external databases generally, but
732 //   with the default internal user table)
733 //
734 // fixed the IndexAsConfigProblem logic. this was flawed:
735 //   scripts which are the same virtual path defined their own lib/main call
736 //   (hmm, have to test this better, phpwiki.sf.net/demo works again)
737 //
738 // Revision 1.47  2004/01/27 23:23:39  rurban
739 // renamed ->Username => _userid for consistency
740 // renamed mayCheckPassword => mayCheckPass
741 // fixed recursion problem in WikiUserNew
742 // fixed bogo login (but not quite 100% ready yet, password storage)
743 //
744 // Revision 1.46  2004/01/26 09:17:48  rurban
745 // * changed stored pref representation as before.
746 //   the array of objects is 1) bigger and 2)
747 //   less portable. If we would import packed pref
748 //   objects and the object definition was changed, PHP would fail.
749 //   This doesn't happen with an simple array of non-default values.
750 // * use $prefs->retrieve and $prefs->store methods, where retrieve
751 //   understands the interim format of array of objects also.
752 // * simplified $prefs->get() and fixed $prefs->set()
753 // * added $user->_userid and class '_WikiUser' portability functions
754 // * fixed $user object ->_level upgrading, mostly using sessions.
755 //   this fixes yesterdays problems with loosing authorization level.
756 // * fixed WikiUserNew::checkPass to return the _level
757 // * fixed WikiUserNew::isSignedIn
758 // * added explodePageList to class PageList, support sortby arg
759 // * fixed UserPreferences for WikiUserNew
760 // * fixed WikiPlugin for empty defaults array
761 // * UnfoldSubpages: added pagename arg, renamed pages arg,
762 //   removed sort arg, support sortby arg
763 //
764 // Revision 1.45  2003/12/09 20:00:43  carstenklapp
765 // Bugfix: The last BogoUserPrefs-bugfix prevented the admin from saving
766 // prefs into his own homepage, fixed broken logic. Tightened up BogoUser
767 // prefs saving ability by checking for true existance of homepage
768 // (previously a page revision of 0 also counted as valid, again due to
769 // somewhat flawed logic).
770 //
771 // Revision 1.44  2003/12/06 04:56:23  carstenklapp
772 // Security bugfix (minor): Prevent BogoUser~s from saving extraneous
773 // _pref object meta-data within locked pages.
774 //
775 // Previously, BogoUser~s who signed in with a (valid) WikiWord such as
776 // "HomePage" could actually save preferences into that page, even though
777 // it was already locked by the administrator. Thus, any subsequent
778 // WikiLink~s to that page would become prefixed with "that nice little"
779 // UserIcon, as if that page represented a valid user.
780 //
781 // Note that the admin can lock (even) non-existant pages as desired or
782 // necessary (i.e. any DB page whose revision==0), to prevent the
783 // arbitrary BogoUser from saving preference metadata into such a page;
784 // for example, the silly WikiName "@qmgi`Vcft_x|" (that is the
785 // \$examplechars presented in login.tmpl, in case it is not visible here
786 // in the CVS comments).
787 //
788 // http://phpwiki.sourceforge.net/phpwiki/
789 // %C0%F1%ED%E7%E9%E0%D6%E3%E6%F4%DF%F8%FC?action=lock
790 //
791 // To remove the prefs metadata from a page, the admin can use the
792 // EditMetaData plugin, enter pref as the key, leave the value box empty
793 // and then submit the change. For example:
794 //
795 // http://phpwiki.sourceforge.net/phpwiki/
796 // _EditMetaData?page=%C0%F1%ED%E7%E9%E0%D6%E3%E6%F4%DF%F8%FC
797 //
798 // (It seems a rethinking of WikiUserNew.php with its WikiUser and
799 // UserPreferences classes is in order. Ideally the WikiDB would
800 // transparently handle such a situation, perhaps BogoUser~s should
801 // simply be restricted to saving preferences into a cookie until his/her
802 // e-mail address has been verified.)
803 //
804 // Revision 1.43  2003/12/04 19:33:30  carstenklapp
805 // Bugfix: Under certain PhpWiki installations (such as the PhpWiki at
806 // SF), the user was unable to select a theme other than the server's
807 // default. (Use the more robust Theme::findFile instead of PHP's
808 // file_exists function to detect installed themes).
809 //
810 // Revision 1.42  2003/11/30 18:18:13  carstenklapp
811 // Minor code optimization: use include_once instead of require_once
812 // inside functions that might not always called.
813 //
814 // Revision 1.41  2003/11/21 21:32:39  carstenklapp
815 // Bugfix: When DEFAULT_LANGUAGE was not 'en', a user's language prefs
816 // would revert to 'en' when the default <system language> was selected
817 // in UserPreferences and the user saved his preferences. (Check for
818 // empty or blank language pref in sanify function of class
819 // _UserPreference_language and return DEFAULT_LANGUAGE if nothing or
820 // default selected in UserPreferences.)
821 //
822 // Revision 1.40  2003/11/21 16:54:58  carstenklapp
823 // Bugfix: login.tmpl was always displayed in English despite
824 // DEFAULT_LANGUAGE set in index.php. (Added call to
825 // update_locale(DEFAULT_LANGUAGE) before printing login form).
826 //
827 // Revision 1.39  2003/10/28 21:13:46  carstenklapp
828 // Security bug fix for admin password, submitted by Julien Charbon.
829 //
830 // Revision 1.38  2003/09/13 22:25:38  carstenklapp
831 // Hook for new user preference 'noLinkIcons'.
832 //
833 // Revision 1.37  2003/02/22 20:49:55  dairiki
834 // Fixes for "Call-time pass by reference has been deprecated" errors.
835 //
836 // Revision 1.36  2003/02/21 22:50:51  dairiki
837 // Ensure that language preference is a string.
838 //
839 // Revision 1.35  2003/02/16 20:04:47  dairiki
840 // Refactor the HTTP validator generation/checking code.
841 //
842 // This also fixes a number of bugs with yesterdays validator mods.
843 //
844 // Revision 1.34  2003/02/15 02:21:54  dairiki
845 // API Change!  Explicit $request argument added to contructor for WikiUser.
846 //
847 // This seemed the best way to fix a problem whereby the WikiDB
848 // was being opened twice.  (Which while being merely inefficient
849 // when using an SQL backend causes hangage when using a dba backend.)
850 //
851 // Revision 1.33  2003/01/22 03:21:40  zorloc
852 // Modified WikiUser constructor to move the DB request for the homepage to
853 // the end of the logic to prevent it from being requested and then dropped.
854 // Added more phpdoc comments.
855 //
856 // Revision 1.32  2003/01/21 07:40:50  zorloc
857 // Modified WikiUser::_ok() -- Inverted the logic so the default is to return
858 // false and to return true only in the desired condition.  Added phpdoc
859 // comments
860 //
861 // Revision 1.31  2003/01/15 05:37:20  carstenklapp
862 // code reformatting
863 //
864 // Revision 1.30  2003/01/15 04:59:27  carstenklapp
865 // Bugfix: Previously stored preferences were not loading when user
866 // signed in. (Fixed... I hope.)
867 //
868
869 // Local Variables:
870 // mode: php
871 // tab-width: 8
872 // c-basic-offset: 4
873 // c-hanging-comment-ender-p: nil
874 // indent-tabs-mode: nil
875 // End:
876 ?>