Commit 60a94dba authored by Leif Andersson's avatar Leif Andersson
Browse files

Alla användare kan läsa, bara 'Use ReglerAddress' kan skriva.

parent ba584ae3
......@@ -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
......
......@@ -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');
......
......@@ -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'])) {
......
......@@ -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');
......
<?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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment