From d8e1f81df2e40574c0e685910bf99407f7e66017 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Wed, 13 Jul 2011 15:28:30 +0000 Subject: administrators can permanently delete a device page - part 1 --- .../Application/Controllers/BaseController.php | 6 +-- .../Application/Controllers/GenericController.php | 2 +- .../Application/Controllers/HistoryController.php | 57 ++++++++++++++++++---- .../Application/Controllers/SpecialController.php | 2 +- h-source/Application/Include/languages.php | 3 +- h-source/Application/Include/myFunctions.php | 4 ++ h-source/Application/Models/HardwareModel.php | 5 ++ h-source/Application/Models/HistoryModel.php | 1 + h-source/Application/Views/top_left.php | 24 ++++++--- 9 files changed, 81 insertions(+), 23 deletions(-) (limited to 'h-source/Application') diff --git a/h-source/Application/Controllers/BaseController.php b/h-source/Application/Controllers/BaseController.php index 02db21d..f40d45f 100644 --- a/h-source/Application/Controllers/BaseController.php +++ b/h-source/Application/Controllers/BaseController.php @@ -135,14 +135,14 @@ class BaseController extends Controller $data['language_links'] = $this->buildLanguageLinks($this->lang); $data['lastModif'] = $this->m['HistoryModel'] - ->select() + ->clear()->select() ->inner('hardware') ->on('hardware.id_hard=history.id') - ->where(array('type'=>'hardware','gr'=>'registered','approved'=>'yes')) + ->where(array('type'=>'hardware','gr'=>'registered','deleted'=>'no')) ->orderBy('id_history desc') ->limit(5) ->send(); - + $this->append($data); $this->load('right'); } diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index a5dd24c..2e7a45b 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -487,7 +487,7 @@ class GenericController extends BaseController $data['tree'] = null; $data['isDeleted'] = false; - $data['md_javascript'] = "moderator_dialog(\"devicehide\",\"device\");moderator_dialog(\"deviceshow\",\"device\");moderator_dialog(\"deviceapprove\",\"device_app\");"; + $data['md_javascript'] = "moderator_dialog(\"devicehide\",\"device\");moderator_dialog(\"deviceshow\",\"device\");moderator_dialog(\"deviceapprove\",\"device_app\");moderator_dialog(\"deviceclear\",\"device_cl\");"; if ($this->mod->checkType($clean['id_hard'])) { diff --git a/h-source/Application/Controllers/HistoryController.php b/h-source/Application/Controllers/HistoryController.php index 3b6e1d2..a3421a9 100644 --- a/h-source/Application/Controllers/HistoryController.php +++ b/h-source/Application/Controllers/HistoryController.php @@ -32,7 +32,8 @@ class HistoryController extends BaseController 'page' => 'wiki page', 'page_del' => 'wiki page', 'device' => 'device page', - 'device_app' => 'device page', + 'device_app' => 'device page', + 'device_cl' => 'device page', ); public static $actionTable = array( @@ -49,6 +50,7 @@ class HistoryController extends BaseController 'devicehide' => 'hide', 'deviceshow' => 'show', 'deviceapprove' => 'approve', + 'deviceclear' => 'perm deleted', ); protected $strings = array( @@ -182,7 +184,17 @@ class HistoryController extends BaseController 'error_string' => 'Error: the device page is already approved', ), - + + 'deviceclear' => array( + + 'action' => 'deviceclear', + 'check_status' => 'no', + 'to_status' => 'yes', + 'exec_string' => 'The device page has been permanently deleted. Just reload the page', + 'error_string' => 'Error: the device page has already been permanently deleted', +// 'method' => 'oupdate', + + ), ); protected $types = array( @@ -266,7 +278,7 @@ class HistoryController extends BaseController ), - //page blocked or not + //device page blocked or not 'device' => array( 'clean_type' => 'device', @@ -275,11 +287,11 @@ class HistoryController extends BaseController 'field_name' => '-deleted', 'actions' => array('devicehide','deviceshow'), 'group' => 'admin', - 'types_to_show' => 'device_app,device', + 'types_to_show' => 'device_app,device,device_cl', ), - //page blocked or not + //device page approved 'device_app' => array( 'clean_type' => 'device_app', @@ -290,7 +302,18 @@ class HistoryController extends BaseController 'group' => 'admin', ), - + + //device page cleared + 'device_cl' => array( + + 'clean_type' => 'device_cl', + 'model_name' => 'HardwareModel', + 'id_name' => 'id_hard', + 'field_name' => 'cleared', + 'actions' => array('deviceclear'), + 'group' => 'admin', + + ), ); public function __construct($model, $controller, $queryString) @@ -366,6 +389,11 @@ class HistoryController extends BaseController { $this->generic($lang, $token, 'deviceapprove'); } + + public function deviceclear($lang = 'en', $token = '') + { + $this->generic($lang, $token, 'deviceclear'); + } protected function generic($lang = 'en', $token = '', $action = 'hide') { @@ -389,7 +417,7 @@ class HistoryController extends BaseController $message = $this->request->post('message',''); $modelName = 'error'; - + if (array_key_exists($type,$this->types)) { if (in_array($action,$this->types[$type]['actions'])) @@ -406,8 +434,10 @@ class HistoryController extends BaseController $this->model($modelName); $model = $this->m[$modelName]; - $count = $model->select()->where(array($clean['id_name'] => $clean['id'],$clean['field_name'] => $this->strings[$action]['check_status']))->rowNumber(); + $model->select()->where(array($clean['id_name'] => $clean['id'],$clean['field_name'] => $this->strings[$action]['check_status'])); + $count = $model->rowNumber(); + if ($count > 0) { if (eg_strlen($message) < 500) @@ -417,7 +447,15 @@ class HistoryController extends BaseController //hide the message $model->values = array($clean['field_name'] => $this->strings[$action]['to_status']); - $model->pUpdate($clean['id']); + + if (isset($this->strings[$action]['method'])) + { + call_user_func(array($model, $this->strings[$action]['method']),$clean['id']); + } + else + { + $model->pUpdate($clean['id']); + } if ($model->queryResult) { @@ -533,6 +571,7 @@ class HistoryController extends BaseController 'devicehide' => 'hidden', 'deviceshow' => 'restored', 'deviceapprove' => 'approved', + 'deviceclear' => 'permanently deleted', ); $this->append($data); diff --git a/h-source/Application/Controllers/SpecialController.php b/h-source/Application/Controllers/SpecialController.php index 6ef632a..db3975b 100644 --- a/h-source/Application/Controllers/SpecialController.php +++ b/h-source/Application/Controllers/SpecialController.php @@ -104,7 +104,7 @@ class SpecialController extends BaseController $whereClauseArray = array( 'gr' => 'registered', 'type' => 'hardware', - 'approved' => 'yes', + 'deleted' => 'no', ); $this->helper('Pages','special/'.$this->action.'/'.$this->lang,'page'); diff --git a/h-source/Application/Include/languages.php b/h-source/Application/Include/languages.php index 2dd8d1c..37d88ad 100644 --- a/h-source/Application/Include/languages.php +++ b/h-source/Application/Include/languages.php @@ -241,7 +241,8 @@ class Lang /*0203*/"approve the device page" => "approva la pagina del dispositivo", /*0204*/"This device page has not been approved yet" => "La pagina del dispositivo non รจ ancora stata approvata", /*0205*/"Device pages that have to be approved" => "Pagine di dispositivi da approvare", - /*0206*/"The device page has to be approved by an administrator of the website" => "La pagina del dispositivo deve essere approvata da un amministratore del sito" + /*0206*/"The device page has to be approved by an administrator of the website" => "La pagina del dispositivo deve essere approvata da un amministratore del sito", + /*0207*/"permanently delete the device page" => "cancella definitivamente la pagina", ), 'es' => array ( diff --git a/h-source/Application/Include/myFunctions.php b/h-source/Application/Include/myFunctions.php index 4876676..1505512 100644 --- a/h-source/Application/Include/myFunctions.php +++ b/h-source/Application/Include/myFunctions.php @@ -4712,6 +4712,10 @@ function goToModeratedItem( $row = array() ) $hardInfo = getHardwareInfoFromId($row['id']); $url = $hardInfo['controller'].'/view/'.Lang::$current.'/'.$row['id'].'/'.encodeUrl($hardInfo['model']); break; + case 'device_cl': + $hardInfo = getHardwareInfoFromId($row['id']); + $url = $hardInfo['controller'].'/view/'.Lang::$current.'/'.$row['id'].'/'.encodeUrl($hardInfo['model']); + break; } return 'http://'.DOMAIN_NAME.'/'.$url; } diff --git a/h-source/Application/Models/HardwareModel.php b/h-source/Application/Models/HardwareModel.php index d19cfbd..a1aa01b 100644 --- a/h-source/Application/Models/HardwareModel.php +++ b/h-source/Application/Models/HardwareModel.php @@ -72,6 +72,11 @@ class HardwareModel extends Model_Map { parent::__construct(); } + public function oupdate($id) + { + return $this->pUpdate($id); + } + public function pUpdate($id) { if (isset($this->values['approved'])) diff --git a/h-source/Application/Models/HistoryModel.php b/h-source/Application/Models/HistoryModel.php index daeda1f..4e345ed 100644 --- a/h-source/Application/Models/HistoryModel.php +++ b/h-source/Application/Models/HistoryModel.php @@ -28,6 +28,7 @@ class HistoryModel extends Model_Tree { $this->_where=array( 'approved' => 'hardware', + 'deleted' => 'hardware', ); $this->orderBy = 'history.id_history'; diff --git a/h-source/Application/Views/top_left.php b/h-source/Application/Views/top_left.php index 73e8f80..08674c8 100644 --- a/h-source/Application/Views/top_left.php +++ b/h-source/Application/Views/top_left.php @@ -31,22 +31,30 @@
- - - - "> - - - + + + - "> + + + "> + + + + + "> + + + "> + "> +
device
-- cgit v1.2.3