From c1232ecf36c29010ffb45b508a34da55803d7ec7 Mon Sep 17 00:00:00 2001 From: Simon DELAGE Date: Sat, 30 Aug 2014 13:23:38 +0200 Subject: [PATCH] Latest known source (v3.0.4) --- _template.txt | 1 + action.php | 163 +++++++++++++++++++++++++++++++++++++++++++ conf/default.php | 10 +++ conf/metadata.php | 10 +++ lang/en/settings.php | 21 ++++++ lang/ko/settings.php | 12 ++++ lang/ru/settings.php | 20 ++++++ 7 files changed, 237 insertions(+) create mode 100644 _template.txt create mode 100644 action.php create mode 100644 conf/default.php create mode 100644 conf/metadata.php create mode 100644 lang/en/settings.php create mode 100644 lang/ko/settings.php create mode 100644 lang/ru/settings.php diff --git a/_template.txt b/_template.txt new file mode 100644 index 0000000..98838f6 --- /dev/null +++ b/_template.txt @@ -0,0 +1 @@ +====== @NAME@ (@USER@) ====== diff --git a/action.php b/action.php new file mode 100644 index 0000000..6a0c042 --- /dev/null +++ b/action.php @@ -0,0 +1,163 @@ +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 '
'; + } + } + + //draws a home button, used by calls from main.php in template folder + function homeLink() + { + $this->init(); + if ($_SERVER['REMOTE_USER']!=null) + { + echo 'Home'; + } + } + + 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 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()); + } +} +?> diff --git a/conf/default.php b/conf/default.php new file mode 100644 index 0000000..8eb0085 --- /dev/null +++ b/conf/default.php @@ -0,0 +1,10 @@ + diff --git a/conf/metadata.php b/conf/metadata.php new file mode 100644 index 0000000..4a28ba3 --- /dev/null +++ b/conf/metadata.php @@ -0,0 +1,10 @@ +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. +?> diff --git a/lang/en/settings.php b/lang/en/settings.php new file mode 100644 index 0000000..d763ad2 --- /dev/null +++ b/lang/en/settings.php @@ -0,0 +1,21 @@ + + */ +$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"; +?> diff --git a/lang/ko/settings.php b/lang/ko/settings.php new file mode 100644 index 0000000..9869c36 --- /dev/null +++ b/lang/ko/settings.php @@ -0,0 +1,12 @@ + + */ +$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'] = "사용자 네임스페이스가 있는 네임스페이스."; +?> diff --git a/lang/ru/settings.php b/lang/ru/settings.php new file mode 100644 index 0000000..291f37f --- /dev/null +++ b/lang/ru/settings.php @@ -0,0 +1,20 @@ + + */ +$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'] = "Редактировать домашнюю страницу, но не создавать её.";