Latest known source (v3.0.4)
This commit is contained in:
parent
a8ceae6314
commit
c1232ecf36
|
@ -0,0 +1 @@
|
|||
====== @NAME@ (@USER@) ======
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
//AUTHOR James Lin
|
||||
//Version 3.0.4
|
||||
|
||||
if (!defined('DOKU_INC')) die();
|
||||
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
|
||||
|
||||
require_once (DOKU_PLUGIN . 'action.php');
|
||||
require_once (DOKU_PLUGIN . '/acl/admin.php');
|
||||
|
||||
class action_plugin_userhomepage extends DokuWiki_Action_Plugin
|
||||
{
|
||||
private $userHomePagePath = '';
|
||||
private $userHomePageTemplate = '';
|
||||
private $home_wiki_page = '';
|
||||
private $home_wiki_ns = '';
|
||||
private $doku_page_path = '';
|
||||
private $home_page_template = '';
|
||||
|
||||
function init()
|
||||
{
|
||||
global $conf;
|
||||
require_once (DOKU_INC.'inc/search.php');
|
||||
if($_SERVER['REMOTE_USER']!=null)
|
||||
{
|
||||
//$this->doku_page_path = DOKU_INC . 'data/pages';
|
||||
$this->doku_page_path = $conf['datadir'];
|
||||
$this->home_page_template = DOKU_INC . $this->getConf('templatepath');
|
||||
if ($this->getConf('group_by_name'))
|
||||
{
|
||||
// people:g:gme']li8600
|
||||
$this->home_wiki_ns = cleanID($this->getConf('users_namespace').':'.strtolower(substr($this->homeNamespace(), 0, 1)).':'. $this->homeNamespace());
|
||||
}
|
||||
else
|
||||
{
|
||||
// people:gli8600
|
||||
$this->home_wiki_ns = cleanID($this->getConf('users_namespace').':'. $this->homeNamespace());
|
||||
}
|
||||
// people:gli8600:start.txt
|
||||
$this->home_wiki_page= cleanID($this->home_wiki_ns . ':' . $this->homePage());
|
||||
}
|
||||
}
|
||||
|
||||
//draws a home link, used by calls from main.php in template folder
|
||||
function homeButton()
|
||||
{
|
||||
$this->init();
|
||||
if ($_SERVER['REMOTE_USER']!=null)
|
||||
{
|
||||
echo '<form class="button btn_show" method="post" action="doku.php?id='.$this->home_wiki_page.'"><input class="button" type="submit" value="Home"/></form>';
|
||||
}
|
||||
}
|
||||
|
||||
//draws a home button, used by calls from main.php in template folder
|
||||
function homeLink()
|
||||
{
|
||||
$this->init();
|
||||
if ($_SERVER['REMOTE_USER']!=null)
|
||||
{
|
||||
echo '<a href="doku.php?id='.$this->home_wiki_page.'">Home</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function homeNamespace() {
|
||||
if ( $this->getConf('use_name_string')) {
|
||||
global $INFO;
|
||||
$raw_string = $INFO['userinfo']['name'];
|
||||
//james_lin
|
||||
return $raw_string;
|
||||
} else {
|
||||
//gli8600
|
||||
return strtolower($_SERVER['REMOTE_USER']);
|
||||
};
|
||||
}
|
||||
|
||||
function homePage() {
|
||||
if ( $this->getConf('use_start_page')) {
|
||||
global $conf;
|
||||
return $conf['start'];
|
||||
} else {
|
||||
return $this->homeNamespace();
|
||||
};
|
||||
}
|
||||
|
||||
function _template() {
|
||||
global $INFO;
|
||||
$content = io_readFile($this->home_page_template, false);
|
||||
$name = $INFO['userinfo']['name'];
|
||||
$user = strtolower($_SERVER['REMOTE_USER']);
|
||||
$content = str_replace('@NAME@',$name,$content);
|
||||
$content = str_replace('@USER@',$user,$content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
function page_template(&$event, $param)
|
||||
{
|
||||
$this->init();
|
||||
if($this->home_wiki_page && $this->home_wiki_page == $event->data[0]) {
|
||||
if(!$event->result) // FIXME: another template applied?
|
||||
$event->result = $this->_template();
|
||||
$event->preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function redirect(&$event, $param)
|
||||
{
|
||||
global $conf;
|
||||
global $INFO;
|
||||
|
||||
if (($_SERVER['REMOTE_USER']!=null)&&($_REQUEST['do']=='login'))
|
||||
{
|
||||
$this->init();
|
||||
$id = $this->home_wiki_page;
|
||||
|
||||
//check if page not exists, create it
|
||||
if (!page_exists($id) && !checklock($id) && !checkwordblock())
|
||||
{
|
||||
// set acl's if requested
|
||||
if ( $this->getConf('set_permissions') == 1 )
|
||||
{
|
||||
$acl = new admin_plugin_acl();
|
||||
$ns = cleanID($this->home_wiki_ns.':'.$this->homePage());
|
||||
$acl->_acl_add($ns, '@ALL', (int)$this->getConf('set_permissions_others'));
|
||||
$acl->_acl_add($ns, strtolower($_SERVER['REMOTE_USER']), AUTH_DELETE);
|
||||
}
|
||||
if (!$this->getConf('edit_before_create'))
|
||||
{
|
||||
//writes the user info to page
|
||||
lock($id);
|
||||
saveWikiText($id,$this->_template(),$lang['created']);
|
||||
unlock($id);
|
||||
}
|
||||
// redirect to edit home page
|
||||
send_redirect(wl($id, array("do" => ($this->getConf('edit_before_create'))?"edit":"show"), false, "&"));
|
||||
}
|
||||
// if the user was at a specific page, then don't redirect to personal page.
|
||||
if (($_REQUEST['id']==$conf['start'])||(!isset($_REQUEST['id'])))
|
||||
{
|
||||
send_redirect(wl($id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getInfo()
|
||||
{
|
||||
return array
|
||||
(
|
||||
'name' => 'User Home Page',
|
||||
'email' => 'guanfenglin@gmail.com',
|
||||
'date' => '04/12/2008',
|
||||
'author' => 'James GuanFeng Lin, Mikhail I. Izmestev, Daniel Stonier',
|
||||
'desc' => 'auto redirects users to <create> their homepage',
|
||||
'url' => ''
|
||||
);
|
||||
}
|
||||
|
||||
function register(&$controller)
|
||||
{
|
||||
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'redirect',array());
|
||||
$controller->register_hook('HTML_PAGE_FROMTEMPLATE', 'BEFORE', $this, 'page_template',array());
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
$conf['set_permissions'] = true; // configure acl's
|
||||
$conf['set_permissions_others'] = '0';
|
||||
$conf['use_name_string'] = false; // use name string instead of login string for the user's ns
|
||||
$conf['use_start_page'] = true; // use state page instead of namespace string for home page
|
||||
$conf['templatepath'] = 'lib/plugins/userhomepage/_template.txt'; // the location of the template file
|
||||
$conf['users_namespace'] = 'people'; // namespace storing the user namespaces
|
||||
$conf['group_by_name'] = true; // use the first character of name to group people
|
||||
$conf['edit_before_create'] = true; // allow users to edit their home pages before create
|
||||
?>
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
$meta['use_name_string'] = array('onoff'); // use name string instead of login string for the user's namespace
|
||||
$meta['use_start_page'] = array('onoff'); // use start page instead of namespace string for home page
|
||||
$meta['set_permissions'] = array('onoff'); // configure permissions
|
||||
$meta['set_permissions_others'] = array('multichoice','_choices'=>array('0','1','2','4','8','16')); // if enable set permission, what permission for other people?
|
||||
$meta['templatepath'] = array('string','_pattern' => '/^(|[a-zA-Z\-]+)$/'); // the location of the template file
|
||||
$meta['users_namespace'] = array('string','_pattern' => '/^(|[a-zA-Z\-:]+)$/'); // the namespace containing user directories
|
||||
$meta['group_by_name'] = array('onoff'); // group people by the first character of name
|
||||
$meta['edit_before_create'] = array('onoff'); // allow users to edit their home page before create.
|
||||
?>
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* English language file for the configuration manager
|
||||
*
|
||||
* @author: Daniel Stonier <d.stonier@gmail.com>
|
||||
*/
|
||||
$lang['set_permissions'] = "Configure acl's to permit user full access to their home namespace.";
|
||||
$lang['use_name_string'] = "Use names strings for the user's namespace (alt. login strings).";
|
||||
$lang['use_start_page'] = "Use the wiki's start page string instead of the user's namespace string for the home page.";
|
||||
$lang['templatepath'] = "Doku relative path to the template file.";
|
||||
$lang['users_namespace'] = "Namespace under which user namespaces are created.";
|
||||
$lang['set_permissions_others'] = "If set permission enabled, what permission for other people?";
|
||||
$lang['set_permissions_others_o_0'] = 'None';
|
||||
$lang['set_permissions_others_o_1'] = 'Read';
|
||||
$lang['set_permissions_others_o_2'] = 'Edit';
|
||||
$lang['set_permissions_others_o_4'] = 'Create';
|
||||
$lang['set_permissions_others_o_8'] = 'Upload';
|
||||
$lang['set_permissions_others_o_16'] = 'Delete';
|
||||
$lang['group_by_name'] = "Group home pages by the first character of user name?";
|
||||
$lang['edit_before_create'] = "Allow users to edit their home pages before create";
|
||||
?>
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Korean language file for the configuration manager
|
||||
*
|
||||
* @author: 이재영 <jakan2@gmail.com>
|
||||
*/
|
||||
$lang['set_permissions'] = "홈 네임스페이스에 대한 모든 권한을 갖도론 acl을 설정하세요.";
|
||||
$lang['use_name_string'] = "Use names strings for the user's namespace (alt. login strings).";
|
||||
$lang['use_start_page'] = "Use the wiki's start page string instead of the user's namespace string for the home page.";
|
||||
$lang['templatepath'] = "템플릿화일들이 존재하는 Doku 의 경로를 알려주세요.";
|
||||
$lang['users_namespace'] = "사용자 네임스페이스가 있는 네임스페이스.";
|
||||
?>
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Russian language file for the configuration manager
|
||||
*
|
||||
* @author: Mikhail I. Izmestev <izmmishao5@gmail.com>
|
||||
*/
|
||||
$lang['set_permissions'] = "Устанавливать пользователю полные права доступа к домашней странице.";
|
||||
$lang['use_name_string'] = "Использовать полное имя для неймспейса пользователя (иначе будет использоваться логин).";
|
||||
$lang['use_start_page'] = "Использовать имя стартовой страницы вместо имени пользователя для домашней страницы.";
|
||||
$lang['templatepath'] = "Относительный путь до файла шаблона.";
|
||||
$lang['users_namespace'] = "Неймспейс где будут создаваться неймспейсы пользователей.";
|
||||
$lang['set_permissions_others'] = "Какие права доступа устанавливать для остальных пользователей?";
|
||||
$lang['set_permissions_others_o_0'] = 'Замечание';
|
||||
$lang['set_permissions_others_o_1'] = 'Чтение';
|
||||
$lang['set_permissions_others_o_2'] = 'Правка';
|
||||
$lang['set_permissions_others_o_4'] = 'Создание';
|
||||
$lang['set_permissions_others_o_8'] = 'Загрузка файлов';
|
||||
$lang['set_permissions_others_o_16'] = 'Удаление';
|
||||
$lang['group_by_name'] = "Группировать неймспейсы пользователей по первой букве имени?";
|
||||
$lang['edit_before_create'] = "Редактировать домашнюю страницу, но не создавать её.";
|
Loading…
Reference in New Issue