dc0fca641cf9fb1e358d0c3cbd55c5b10aab07da
[atutor.git] / mods / wiki / plugins / edit / authorname.php
1 <?php
2 /*
3    Adds an input box on the edit/ page, that allows users to set an
4    author name individually. Would allow to override the username
5    string, if one was already set by ProtectedMode plugins (but of
6    course this is no permission problem).
7    
8    NOTE: we need to incorporate some password awareness in here, so
9    this can be used, even if user/prof extensions are present and
10    certain usernames were registered already (pw in name HomePages).
11 */
12
13
14 define("EWIKI_UP_AUTHOR_NAME", "author_name");
15
16
17 #-- <input>
18 $ewiki_plugins["edit_form_append"][] = "ewiki_aedit_authorname";
19 function ewiki_aedit_authorname($id, &$data, $action) {
20
21    $var = EWIKI_UP_AUTHOR_NAME;
22    return(ewiki_t(<<< EOT
23 <br />
24  _{set the AuthorName to} <input size="20" name="$var" value="$GLOBALS[ewiki_author]">
25 <br />
26 EOT
27    ));
28 }
29
30
31 #-- store as cookie (for 1 month)
32 if ($uu = @$_REQUEST[EWIKI_UP_AUTHOR_NAME]) {
33    $uu = trim($uu);
34    if (!strpos($uu, "://")) {
35       $ewiki_author = $uu;
36    }
37    if ($_COOKIE[EWIKI_UP_AUTHOR_NAME] != $ewiki_author) {
38       setcookie(EWIKI_UP_AUTHOR_NAME, $ewiki_author, time()+2500000);
39    }
40 }
41
42 ?>