1<?php 2/** 3 * Plugin USERS PAGE AUTOCREATE 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Vladimir Psyukalov <pedagog@pisem.net> 7 */ 8 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11 12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once(DOKU_PLUGIN.'action.php'); 14require_once(DOKU_PLUGIN.'acl/admin.php'); 15 16class action_plugin_userspagecreate extends DokuWiki_Action_Plugin { 17 18 /** 19 * return some info 20 */ 21 function getInfo(){ 22 return array( 23 'author' => 'Vladimir Psyukalov', 24 'email' => 'pedagog@palitra.info', 25 'date' => '2008-08-07', 26 'name' => 'User page autocreate (v0.1.0)', 27 'desc' => 'User page autocreate after register', 28 'url' => 'https://www.dokuwiki.org/plugin:userspagecreate', 29 ); 30 } 31 32 /** 33 * register the eventhandlers 34 */ 35 function register(&$controller){ 36 $controller->register_hook('ACTION_ACT_PREPROCESS', 37 'AFTER', 38 $this, 39 'action_act_preprocess_after', 40 array()); 41 42 $controller->register_hook('DOKUWIKI_STARTED', 43 'BEFORE', 44 $this, 45 'dokuwiki_started_before', 46 array()); 47 48 $controller->register_hook('RENDERER_CONTENT_POSTPROCESS', 49 'AFTER', 50 $this, 51 'renderer_content_postprocess_after', 52 array()); 53 54 55 56 } 57 function renderer_content_postprocess_after(&$event, $param){ 58 global $INFO; 59 $event->data[1]=preg_replace('{class="\w+" title="'.$INFO['usersnamespace'].':}si','class="wikiuser" title="'.$INFO['usersnamespace'].':',$event->data[1]); 60 } 61 function dokuwiki_started_before(&$event, $param){ 62 global $INFO; 63 $INFO['usersnamespace']=preg_replace('{^[:/]?(.+?)[:/]?$}','\1',$this->getConf('usersnamespace')); 64 } 65 66 function action_act_preprocess_after(&$event, $param){ 67 global $MSG; 68 global $INFO; 69 global $lang; 70 71 if ($event->data=='login' and isset($MSG)) { 72 $flagOK=0; 73 foreach($MSG as $msg) { 74 if ( $msg['lvl']=='success' 75 and ( $msg['msg']==$lang['regsuccess'] 76 or $msg['msg']==$lang['regsuccess2'])) { 77 $flagOK=1; 78 } 79 } 80 if ($flagOK==1) { 81 $INFO['userinfo']['name']=$_POST['fullname']; 82 $INFO['userinfo']['mail']=$_POST['email']; 83 $_SERVER['REMOTE_USER']=$_POST['login']; 84 /* $pageName=':'.$INFO['usersnamespace'].':'.$_SERVER['REMOTE_USER']; */ 85 $pageName= .$INFO['usersnamespace'].':'.$_SERVER['REMOTE_USER']; 86 87 $data = array($pageName); 88 $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); 89 if ($text == '') { 90 $text = '===== '.$INFO['userinfo']['name'].' ====='; 91 } 92 saveWikiText($pageName,con('',$text,'',1),$lang['created'],''); 93 $a=new admin_plugin_acl(); 94 $a->_acl_add($pageName, $_SERVER['REMOTE_USER'], 2); 95 } 96 } 97 } 98} 99 100function mytpl_userhtmllink($user){ 101 global $INFO; 102 global $auth; 103 $userdata=$auth->getUserData($user); 104 return '<a href="'.wl($INFO['usersnamespace'].':'.$user).'">'.htmlspecialchars($userdata['name']).'</a>'; 105} 106 107function mytpl_userinfo(){ 108 global $lang; 109 global $INFO; 110 if($_SERVER['REMOTE_USER']){ 111 print $lang['loggedinas'].': '.mytpl_userhtmllink($_SERVER['REMOTE_USER']); 112 return true; 113 } 114 return false; 115} 116 117function mytpl_pageinfo(){ 118 global $conf; 119 global $lang; 120 global $INFO; 121 global $REV; 122 global $ID; 123 124 // return if we are not allowed to view the page 125 if (!auth_quickaclcheck($ID)) { return; } 126 127 // prepare date and path 128 $fn = $INFO['filepath']; 129 if(!$conf['fullpath']){ 130 if($REV){ 131 $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); 132 }else{ 133 $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); 134 } 135 } 136 $fn = utf8_decodeFN($fn); 137 $date = strftime($conf['dformat'],$INFO['lastmod']); 138 139 // print it 140 if($INFO['exists']){ 141 print $fn; 142 print ' · '; 143 print $lang['lastmod']; 144 print ': '; 145 print $date; 146 if($INFO['editor']){ 147 print ' '.$lang['by'].' '; 148 print mytpl_userhtmllink($INFO['editor']); 149 }else{ 150 print ' ('.$lang['external_edit'].')'; 151 } 152 if($INFO['locked']){ 153 print ' · '; 154 print $lang['lockedby']; 155 print ': '; 156 print $INFO['locked']; 157 } 158 return true; 159 } 160 return false; 161} 162 163/* 164if you want see link to userpage to revisions and recent page then change file html.php 165 166// string 436 (replace string) 167// print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):htmlspecialchars($INFO['editor']); 168 print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):mytpl_userhtmllink($INFO['editor']); 169 170// string 480 (replace string) 171// print htmlspecialchars($info['user']); 172 print mytpl_userhtmllink($info['user']); 173 174// string 575 (replace string) 175// print htmlspecialchars($recent['user']); 176 print mytpl_userhtmllink($recent['user']); 177 178if you want see link in toolbar in signature change file toolbar.php and use @USERPAGE@ in parameter signature 179// string 201 (insert new string) 180 $sig = str_replace('@USERPAGE@',$INFO['usersnamespace'].':'.$_SERVER['REMOTE_USER'],$sig); 181 182*/ 183