From 4a27b517fc52dde60e5c1837860e4785317490a6 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Tue, 15 Feb 2011 17:06:09 +0000 Subject: improved wiki --- .../Application/Controllers/BaseController.php | 6 ++ .../Application/Controllers/HistoryController.php | 59 ++++++++++++++++- .../Application/Controllers/LastController.php | 2 +- .../Application/Controllers/WikiController.php | 76 +++++++++++++++++++++- 4 files changed, 136 insertions(+), 7 deletions(-) (limited to 'h-source/Application/Controllers') diff --git a/h-source/Application/Controllers/BaseController.php b/h-source/Application/Controllers/BaseController.php index 29d0642..5340954 100644 --- a/h-source/Application/Controllers/BaseController.php +++ b/h-source/Application/Controllers/BaseController.php @@ -25,6 +25,7 @@ class BaseController extends Controller protected $lang; protected $ismoderator = false; + protected $isadmin = false; protected $querySanitized = true; protected $token = 'token'; @@ -59,6 +60,7 @@ class BaseController extends Controller $data['islogged'] = 'no'; $data['token'] = 'token'; $data['ismoderator'] = false; + $data['isadmin'] = false; if ($this->s['registered']->status['status'] === 'logged') { @@ -66,8 +68,12 @@ class BaseController extends Controller $data['islogged'] = 'yes'; $data['token'] = $this->s['registered']->status['token']; $this->token = $data['token']; + $data['ismoderator'] = in_array('moderator',$this->s['registered']->status['groups']) ? true : false; $this->ismoderator = $data['ismoderator']; + + $data['isadmin'] = in_array('admin',$this->s['registered']->status['groups']) ? true : false; + $this->isadmin = $data['isadmin']; } $data['lang'] = 'en'; diff --git a/h-source/Application/Controllers/HistoryController.php b/h-source/Application/Controllers/HistoryController.php index cc4b3d0..2154a0e 100644 --- a/h-source/Application/Controllers/HistoryController.php +++ b/h-source/Application/Controllers/HistoryController.php @@ -84,6 +84,26 @@ class HistoryController extends BaseController 'error_string' => 'Error: the issue is already closed', ), + + 'pageblock' => array( + + 'action' => 'pageblock', + 'check_status' => 'no', + 'to_status' => 'yes', + 'exec_string' => 'The wiki page has been blocked. Just reload the page', + 'error_string' => 'Error: the wiki page is already blocked', + + ), + + 'pageunblock' => array( + + 'action' => 'pageunblock', + 'check_status' => 'yes', + 'to_status' => 'no', + 'exec_string' => 'The wiki page is no more blocked. Just reload the page', + 'error_string' => 'Error: the wiki page is already un-blocked', + + ), ); @@ -143,7 +163,17 @@ class HistoryController extends BaseController 'group' => 'moderator', ), - + + 'page' => array( + + 'clean_type' => 'page', + 'model_name' => 'WikiModel', + 'id_name' => 'id_wiki', + 'field_name' => 'blocked', + 'actions' => array('pageblock','pageunblock'), + 'group' => 'admin', + + ), ); public function __construct($model, $controller, $queryString) @@ -184,6 +214,16 @@ class HistoryController extends BaseController { $this->generic($lang, $token, 'close'); } + + public function pageblock($lang = 'en', $token = '') + { + $this->generic($lang, $token, 'pageblock'); + } + + public function pageunblock($lang = 'en', $token = '') + { + $this->generic($lang, $token, 'pageunblock'); + } protected function generic($lang = 'en', $token = '', $action = 'hide') { @@ -232,7 +272,7 @@ class HistoryController extends BaseController { //hide the message $model->values = array($clean['field_name'] => $this->strings[$action]['to_status']); - $model->update($clean['id']); + $model->pUpdate($clean['id']); if ($model->queryResult) { @@ -289,6 +329,10 @@ class HistoryController extends BaseController $data['object'] = 'user'; $data['box_class'] = 'details_of_actions_inner_user'; break; + case 'page': + $data['object'] = 'wiki page'; + $data['box_class'] = 'details_of_actions_inner_user'; + break; case 'issue': $data['object'] = 'issue'; $data['box_class'] = 'details_of_actions_inner_user'; @@ -301,7 +345,16 @@ class HistoryController extends BaseController $data['res'] = $this->m['HistoryModel']->select()->where(array('id'=>$clean['id'],'type'=>$clean['type'],'gr'=>$clean['group']))->send(); - $data['md_action'] = array('hide'=>'hidden','show'=>'restored','block'=>'blocked','unblock'=>'un-blocked','open'=>'opened again','close'=>'closed'); + $data['md_action'] = array( + 'hide' => 'hidden', + 'show' => 'restored', + 'block' => 'blocked', + 'unblock' => 'un-blocked', + 'open' => 'opened again', + 'close' => 'closed', + 'pageblock' => 'blocked', + 'pageunblock' => 'un-blocked', + ); $this->append($data); $this->load('viewall'); diff --git a/h-source/Application/Controllers/LastController.php b/h-source/Application/Controllers/LastController.php index c357c1a..6fe66a2 100644 --- a/h-source/Application/Controllers/LastController.php +++ b/h-source/Application/Controllers/LastController.php @@ -29,7 +29,7 @@ class LastController extends BaseController $this->model('HistoryModel'); - $data['title'] = 'last - '.Website::$generalName; + $data['title'] = gtext('last modifications').' - '.Website::$generalName; $this->append($data); $this->setArgKeys(array('page:forceNat'=>1)); diff --git a/h-source/Application/Controllers/WikiController.php b/h-source/Application/Controllers/WikiController.php index 1c4c154..65a615a 100644 --- a/h-source/Application/Controllers/WikiController.php +++ b/h-source/Application/Controllers/WikiController.php @@ -100,6 +100,8 @@ class WikiController extends BaseController { if ($this->m['UsersModel']->isBlocked($this->s['registered']->status['id_user'])) $this->redirect('my/home/'.$this->lang,2,'your account has been blocked..'); + + if ($this->m['WikiModel']->isBlocked($clean['id_wiki'])) $this->redirect('wiki/page/'.$this->lang,2,'this page has been blocked..'); $deleted = $this->m['WikiModel']->select("wiki.deleted")->where(array("id_wiki"=>$clean['id_wiki']))->limit(1)->toList('wiki.deleted')->send(); @@ -161,7 +163,8 @@ class WikiController extends BaseController $clean['title_clean'] = sanitizeAll($title_clean); $data['isDeleted'] = 'no'; - + $data['isBlocked'] = false; + if (isset($title_clean)) { $res = $this->m['WikiModel']->select()->where(array('title_clean'=>$clean['title_clean']))->orderBy('id_wiki desc')->limit(1)->send(); @@ -172,6 +175,7 @@ class WikiController extends BaseController $data['tree_name'] = $res[0]['wiki']['title']; $data['title'] = $res[0]['wiki']['title'] . ' - ' . Website::$generalName; $data['isDeleted'] = $res[0]['wiki']['deleted']; + $data['isBlocked'] = $this->m['WikiModel']->isBlocked($res[0]['wiki']['id_wiki']); if ( count($res) < 2 ) { @@ -205,11 +209,14 @@ class WikiController extends BaseController { $this->redirect('wiki/page/'.$this->lang.'/Main-Page'); } + + $data['md_javascript'] = "moderator_dialog(\"pageblock\",\"page\");moderator_dialog(\"pageunblock\",\"page\");"; $this->append($data); $this->load($viewFile); $this->load('bottom_left'); + $this->load('moderator_dialog'); $this->right(); } @@ -225,6 +232,7 @@ class WikiController extends BaseController $clean['id'] = (int)$id; $data['id'] = $clean['id']; $data['tree_name'] = $this->m['WikiModel']->getTheModelName($clean['id']); + $data['isBlocked'] = $this->m['WikiModel']->isBlocked($clean['id']); $data['title'] = 'history - '.Website::$generalName; @@ -285,6 +293,7 @@ class WikiController extends BaseController if (count($data['table']) > 0) { $data['id_wiki'] = (int)$data['table'][0]['wiki_revisions']['id_wiki']; + $data['isDeleted'] = $this->m['WikiModel']->isDeleted($data['id_wiki']); $data['tree_name'] = $this->m['WikiModel']->getTheModelName($data['id_wiki']); $data['tree'] = $this->getSpecPageLink() . " » " . $this->getViewLink($data['tree_name'])." » " . $this->getHistoryLink($data['id_wiki']) . " » ".gtext('Revision'); @@ -400,8 +409,9 @@ class WikiController extends BaseController if ($this->s['registered']->status['status'] === 'logged') { - if ($this->m['UsersModel']->isBlocked($this->s['registered']->status['id_user'])) $this->redirect('my/home/'.$this->lang,2,'your account has been blocked..'); + + if ($this->m['WikiModel']->isBlocked($clean['id_wiki'])) $this->redirect('wiki/page/'.$this->lang,2,'this page has been blocked..'); if (isset($_POST['confirmAction'])) { @@ -442,6 +452,7 @@ class WikiController extends BaseController $clean['id_wiki'] = (int)$id_wiki; $data['id_wiki'] = $clean['id_wiki']; $data['tree_name'] = $this->m['WikiModel']->getTheModelName($clean['id_wiki']); + $data['isBlocked'] = $this->m['WikiModel']->isBlocked($clean['id_wiki']); $data['tree'] = $this->getSpecPageLink() . " » " . $this->getViewLink($data['tree_name'])." » ".gtext('Talk'); if (isset($_POST['insertAction'])) @@ -449,6 +460,8 @@ class WikiController extends BaseController if ($this->s['registered']->status['status'] === 'logged') { if ($this->m['UsersModel']->isBlocked($this->s['registered']->status['id_user'])) $this->redirect('my/home/'.$this->lang,2,'your account has been blocked..'); + + if ($this->m['WikiModel']->isBlocked($clean['id_wiki'])) $this->redirect('wiki/page/'.$this->lang,2,'this page has been blocked..'); $this->m['WikitalkModel']->values['created_by'] = $this->s['registered']->status['id_user']; $this->m['WikitalkModel']->values['id_wiki'] = $clean['id_wiki']; @@ -476,7 +489,64 @@ class WikiController extends BaseController $this->load('talk'); $this->load('moderator_dialog'); $this->right(); -// $this->loadViewAll('talk,moderator_dialog'); + } + + public function pages($lang = 'en') + { + $data['title'] = gtext('list of pages').' - '.Website::$generalName; + + $this->setArgKeys(array('page:forceNat'=>1)); + + $this->shift(1); + + $this->helper('Pages','wiki/pages/'.$this->lang,'page'); + + $this->m['WikiModel']->clear()->select()->where(array('-deleted'=>'no'))->orderBy('id_wiki desc'); + + $recordNumber = $this->m['WikiModel']->rowNumber(); + $page = $this->viewArgs['page']; + + $this->m['WikiModel']->limit = $this->h['Pages']->getLimit($page,$recordNumber,30); + + $data['table'] = $this->m['WikiModel']->send(); + + $data['pageList'] = $this->h['Pages']->render($page-7,15); + + $this->append($data); + $this->load('pages'); + $this->right(); + } + + //print all the modifications to the wiki + public function modifications($lang = 'en') + { + $data['title'] = gtext('last modifications').' - '.Website::$generalName; + + $this->setArgKeys(array('page:forceNat'=>1)); + + $this->shift(1); + + $whereClauseArray = array( + 'gr' => 'registered', + 'type' => 'wiki', + ); + + $this->helper('Pages','wiki/modifications/'.$this->lang,'page'); + + $this->m['HistoryModel']->clear()->select()->where($whereClauseArray)->orderBy('id_history desc'); + + $recordNumber = $this->m['HistoryModel']->rowNumber(); + $page = $this->viewArgs['page']; + + $this->m['HistoryModel']->limit = $this->h['Pages']->getLimit($page,$recordNumber,30); + + $data['table'] = $this->m['HistoryModel']->send(); + + $data['pageList'] = $this->h['Pages']->render($page-7,15); + + $this->append($data); + $this->load('modifications'); + $this->right(); } protected function getViewLink($ne_name) -- cgit v1.2.3