diff --git a/ReglerAddress.module.php b/ReglerAddress.module.php index 518d0cdd1c73ed59bf3d95890938ae67f8aec37e..08fb21e521be43324385cac682548408761185d4 100644 --- a/ReglerAddress.module.php +++ b/ReglerAddress.module.php @@ -117,10 +117,8 @@ class ReglerAddress extends CMSModule * VisibleToAdminUser() * @return bool True if this module is shown to current user */ - function VisibleToAdminUser() { - return $this->CheckPermission('Use ReglerAddress'); - } - + function VisibleToAdminUser() { return True; } + /** * GetDependencies() * @return hash Hash of other modules this module depends on diff --git a/action.add_edit.php b/action.add_edit.php index 0a0d54de2205fa60f2fa7798b08df5ee7cffbe12..346e1bc68e004b929ff781fb1172e5416766ace4 100644 --- a/action.add_edit.php +++ b/action.add_edit.php @@ -2,10 +2,9 @@ if (!isset($gCms)) exit; //echo '<pre>'; print_r($params); echo '</pre>'; -if (! $this->CheckPermission('Use ReglerAddress')) { - return $this->DisplayErrorPage($id, $params, $returnid, - 'ReglerAddress access denied.'); -} +$canChangeRecord = False; + +if ($this->CheckPermission('Use ReglerAddress')) {$canChangeRecord = True; } $fields = array( 'ID', 'Fornamn', 'Efternamn', 'Titel', 'Personnummer', 'SkolaForetag', @@ -48,7 +47,7 @@ $smarty = $this->smarty; $headline = $person->Fornamn . ' ' .$person->Efternamn; if (strlen($headline) == 1) $headline = $person->SkolaForetag; -$headline = 'Redigera adress: ' . $headline; +if ($canChangeRecord) { $headline = 'Redigera adress: ' . $headline; } $smarty->assign('headline',$headline); @@ -60,7 +59,11 @@ $smarty->assign('end_form', $this->CreateFormEnd()); foreach ($simpleFields as $key => $name) { $smarty->assign('title_'.$key,$name); - $place = $this->CreateInputText($id,$key,$person->$key,30); + if ($canChangeRecord) { + $place = $this->CreateInputText($id,$key,$person->$key,30); + } else { + $place = $person->$key; + } $smarty->assign('input_'.$key,$place); } $smarty->assign('title_Andrad','Ändrad'); @@ -68,9 +71,13 @@ $smarty->assign('value_Andrad', $person->Andrad); foreach ($areaFields as $key => $name) { $smarty->assign('title_'.$key,$name); - $place = $this->CreateTextArea(false,$id,$person->$key,$key, - 'width:auto; height:auto;','','','',30,3); - $place = str_replace('class','style', $place); + if ($canChangeRecord) { + $place = $this->CreateTextArea(false,$id,$person->$key,$key, + 'width:auto; height:auto;','','','',30,3); + $place = str_replace('class','style', $place); + } else { + $place = $person->$key; + } $smarty->assign('text_'.$key,$place); } @@ -82,7 +89,7 @@ $place = $this->CreateInputSelectList($id, $name, $grupper, array(), 5, '', false); $smarty->assign('select_Grupper', $place); -if ($ID) { +if ($ID && $canChangeRecord) { $place = $this->CreateInputSubmit($id, 'doGroups', 'Ändra grupper'); } else { $place = ''; @@ -100,8 +107,11 @@ foreach (Person::$firstFields as $field) { $place .= $this->CreateInputHidden($id, 'oldEpost',$epost); $smarty->assign('hidden',$place); - -$place = $this->CreateInputSubmit($id, 'submit', 'Uppdatera'); +if ($canChangeRecord) { + $place = $this->CreateInputSubmit($id, 'submit', 'Uppdatera'); +} else { + $place = ''; +} $smarty->assign('submitButton',$place); $place = $this->CreateInputSubmit($id, 'cancelUpdate', 'Avbryt'); diff --git a/action.changeDatabase.php b/action.changeDatabase.php index b3289438762add7326155833a534cf6a7cf083b9..7db93afb157f76c5b9af4ddeef4f826ae6d827d0 100644 --- a/action.changeDatabase.php +++ b/action.changeDatabase.php @@ -4,6 +4,21 @@ require_once 'lib/class.Group.php'; if (!isset($gCms)) exit; //echo '<pre>'; print_r($params); echo '</pre>'; exit; +if (isset($params['cancelUpdate'])) { + $paramsB = array(); + foreach (Person::$firstFields as $field) { + if (isset($params[$field])) { + $paramsB[$field] = $params[$field]; + } + } + if ($this->CheckPermission('Use ReglerAddress')) { + $paramsB['module_message'] = 'Adressändring avbruten'; + } + $this->Redirect($id, 'defaultadmin', $returnid, $paramsB); + return; +} + + if (! $this->CheckPermission('Use ReglerAddress')) { return $this->DisplayErrorPage($id, $params, $returnid, 'ReglerAddress access denied.'); @@ -21,17 +36,6 @@ if (isset($params['doGroups'])) { } -if (isset($params['cancelUpdate'])) { - $paramsB = array(); - foreach (Person::$firstFields as $field) { - if (isset($params[$field])) { - $paramsB[$field] = $params[$field]; - } - } - $paramsB['module_message'] = 'Adressändring avbruten'; - $this->Redirect($id, 'defaultadmin', $returnid, $paramsB); - return; -} if (isset($params['submit'])) { diff --git a/action.defaultadmin.php b/action.defaultadmin.php index 1eaf183efa809cb581c163c45fce7dfd6e759f31..fe850de5136909e84c7f4a033ba60a292a2c6750 100644 --- a/action.defaultadmin.php +++ b/action.defaultadmin.php @@ -20,11 +20,11 @@ if (!isset($gCms)) exit; * the DoAction method, so you'll need to do them as needed in your * method: */ -if (! $this->CheckPermission('Use ReglerAddress')) { - return $this->DisplayErrorPage($id, $params, $returnid, - 'ReglerAddress access denied.'); -} - +/* if (! $this->CheckPermission('Use ReglerAddress')) { */ +/* return $this->DisplayErrorPage($id, $params, $returnid, */ +/* 'ReglerAddress access denied.'); */ +/* } */ +$canChangeRecord = $this->CheckPermission('Use ReglerAddress'); /** * After this, the code is identical to the code that would otherwise be * wrapped in the DisplayAdminPanel() method in the module body. @@ -71,7 +71,11 @@ foreach ($fields as $key => $res) { $place = $this->CreateInputSubmit($id, 'search', 'Sök'); $smarty->assign('searchButton',$place); -$place = $this->CreateInputSubmit($id, 'new', 'Ny post'); +if ($canChangeRecord) { + $place = $this->CreateInputSubmit($id, 'new', 'Ny post'); +} else { + $place = ''; +} $smarty->assign('newButton',$place); $place = $this->CreateInputSubmit($id, 'groupChange', 'Hantera grupper'); diff --git a/action.editGroups.php b/action.editGroups.php index 8a18dd62e357ec98426ece8a54424baee11e8801..ba7a4365b15b8b19b2ccfb973e8ee2101c8c8a1c 100644 --- a/action.editGroups.php +++ b/action.editGroups.php @@ -1,12 +1,13 @@ <?php if (!isset($gCms)) exit; //echo '<pre>'; print_r($params); echo '</pre>'; - -if (! $this->CheckPermission('Use ReglerAddress')) { - return $this->DisplayErrorPage($id, $params, $returnid, - 'ReglerAddress access denied.'); -} require_once 'lib/class.Group.php'; +$canChangeRecord = $this->CheckPermission('Use ReglerAddress'); + +/* if (! $this->CheckPermission('Use ReglerAddress')) { */ +/* return $this->DisplayErrorPage($id, $params, $returnid, */ +/* 'ReglerAddress access denied.'); */ +/* } */ $smarty = $this->smarty; $smarty->assign('headline','Grupphantering'); @@ -17,10 +18,19 @@ $smarty->assign('end_form', $this->CreateFormEnd()); $groups = Group::GetGroupList(); foreach ($groups as $group) { - $group->change = $this->CreateInputSubmit($id, 'change_'.$group->ID, 'Ändra'); + if ($canChangeRecord) { + $group->change = $this->CreateInputSubmit($id, 'change_'.$group->ID, + 'Ändra'); + } else { + $group->change = ''; + } $group->print = $this->CreateInputSubmit($id, 'print_'.$group->ID, 'Skriv ut'); } -$place = $this->CreateInputSubmit($id, 'new', 'Lägg till grupp'); +if ($canChangeRecord) { + $place = $this->CreateInputSubmit($id, 'new', 'Lägg till grupp'); +} else { + $place = ''; +} $smarty->assign('newButton',$place); $smarty->assign('Groups',$groups);