diff --git a/action.add_edit_Group.php b/action.add_edit_Group.php index eb42f0c4e6851f835c1f29010b0fe5faac275a60..8bc150a49c772da90bcf1d2b6ef45ac046d8b1eb 100644 --- a/action.add_edit_Group.php +++ b/action.add_edit_Group.php @@ -12,12 +12,14 @@ foreach ($paramKeys as $key) { $this->Redirect($id, 'printGroup', $returnid, array('ID'=>$ID)); return; } - +if (isset($params['back'])) { + $this->Redirect($id, 'defaultadmin', $returnid, array()); +} if (! $this->CheckPermission('Use ReglerAddress')) { return $this->DisplayErrorPage($id, $params, $returnid, 'ReglerAddress access denied.'); } -require_once 'lib/class.Group.php'; +//require_once 'lib/class.Group.php'; if (isset($params['cancelUpdate'])) { $paramsB = array(); @@ -26,8 +28,8 @@ if (isset($params['cancelUpdate'])) { } if (isset($params['submit'])) { - $record = new Group($params); - echo '<pre>'; print_r($record); echo '</pre>'; + $record = new Groups($params); + //echo '<pre>'; print_r($record); echo '</pre>'; $record->updateRecord(); $paramsB['module_message'] = 'Gruppen ändrad'; $this->Redirect($id, 'editGroups', $returnid, $paramsB); @@ -48,16 +50,16 @@ foreach ($paramKeys as $key) { break; } if (isset($params['new'])){ - $group = new Group(); + $group = new Groups(); $ID = ''; } else { - $group = new Group($ID); + $group = new Groups($ID); } $place = $this->CreateFormStart($id, 'add_edit_Group', $returnid); $smarty->assign('start_form', $place); $smarty->assign('end_form', $this->CreateFormEnd()); -$fields = Group::$groupFields; +$fields = Groups::$groupFields; $smarty->assign('title_ID','ID'); $smarty->assign('value_ID',$ID); diff --git a/action.changeGroups.php b/action.changeGroups.php index 4641b8d1c67fc5a6ce1fa4973f55557fc55eb0d1..413811761af757c4a3c541b2e06519284532a136 100644 --- a/action.changeGroups.php +++ b/action.changeGroups.php @@ -6,7 +6,7 @@ if (! $this->CheckPermission('Use ReglerAddress')) { return $this->DisplayErrorPage($id, $params, $returnid, 'ReglerAddress access denied.'); } -require_once 'lib/class.Group.php'; +//require_once 'lib/class.Group.php'; if (isset($params['back'])) { $paramsB = array(); @@ -29,18 +29,18 @@ $smarty->assign('headline',$headline); if (isset($params['setMember'])) { $GroupID = $params['nonmembers']; - Group::setMember($ID,$GroupID); - Group::setMailLists(); + Groups::setMember($ID,$GroupID); + Groups::setMailLists(); } if (isset($params['unsetMember'])) { $GroupID = $params['members']; - Group::UnsetMember($ID,$GroupID); - Group::setMailLists(); + Groups::UnsetMember($ID,$GroupID); + Groups::setMailLists(); } -$members = Group::getMembers($ID); -$nonmembers = Group::getNonMembers($ID); +$members = Groups::getMembers($ID); +$nonmembers = Groups::getNonMembers($ID); // echo '<pre>'; print_r($nonmembers); echo '</pre>'; diff --git a/action.defaultadmin.php b/action.defaultadmin.php index fe850de5136909e84c7f4a033ba60a292a2c6750..7cdf7848226ad2359709d93e97c387304f72019f 100644 --- a/action.defaultadmin.php +++ b/action.defaultadmin.php @@ -10,7 +10,7 @@ * line which check to make sure that method was called from the module * API, and that everything's safe to continue: */ -require_once 'lib/class.Group.php'; +// require_once 'lib/class.Group.php'; if (!isset($gCms)) exit; //echo '<pre>'; print_r($params); echo '</pre>'; @@ -30,10 +30,9 @@ $canChangeRecord = $this->CheckPermission('Use ReglerAddress'); * wrapped in the DisplayAdminPanel() method in the module body. */ -$groups = Group::getGroupList(); +$groups = Groups::getGroupList(); //echo '<pre>'; print_r($groups); echo '</pre>'; exit; -//file_put_contents("/tmp/defaultadmin.txt",print_r($params,TRUE)); $addrDB = AddressDB::getDB(); $smarty = $this->smarty; // echo '<pre>'; print_r($params); echo '</pre>'; diff --git a/action.editGroups.php b/action.editGroups.php index ba7a4365b15b8b19b2ccfb973e8ee2101c8c8a1c..68c70e58ecc8fa8e44e753372523bd293b00a74b 100644 --- a/action.editGroups.php +++ b/action.editGroups.php @@ -1,7 +1,7 @@ <?php if (!isset($gCms)) exit; //echo '<pre>'; print_r($params); echo '</pre>'; -require_once 'lib/class.Group.php'; +//require_once 'lib/class.Group.php'; $canChangeRecord = $this->CheckPermission('Use ReglerAddress'); /* if (! $this->CheckPermission('Use ReglerAddress')) { */ @@ -16,7 +16,7 @@ $place = $this->CreateFormStart($id, 'add_edit_Group', $returnid); $smarty->assign('start_form', $place); $smarty->assign('end_form', $this->CreateFormEnd()); -$groups = Group::GetGroupList(); +$groups = Groups::GetGroupList(); foreach ($groups as $group) { if ($canChangeRecord) { $group->change = $this->CreateInputSubmit($id, 'change_'.$group->ID, @@ -26,6 +26,9 @@ foreach ($groups as $group) { } $group->print = $this->CreateInputSubmit($id, 'print_'.$group->ID, 'Skriv ut'); } +$place = $this->CreateInputSubmit($id, 'back', 'Tillbaka'); +$smarty->assign('backButton',$place); + if ($canChangeRecord) { $place = $this->CreateInputSubmit($id, 'new', 'Lägg till grupp'); } else { diff --git a/lib/class.Group.php b/lib/class.Groups.php similarity index 95% rename from lib/class.Group.php rename to lib/class.Groups.php index 874b04b2ab0f21e8cd09bc8c59594348d8a4a209..56e65a0aae6b085a15c96fad0b7328b6085bf68d 100644 --- a/lib/class.Group.php +++ b/lib/class.Groups.php @@ -1,6 +1,6 @@ <?php -class Group { +class Groups { private static $queryList = <<<EOS select ID, Gruppnamn, GruppInfo from Grupper order by Gruppnamn @@ -33,7 +33,8 @@ EOS; EOS; - public static $groupFields = array('ID', 'Gruppnamn', 'GruppInfo'); + //public static $groupFields = array('ID', 'Gruppnamn', 'GruppInfo'); + public static $groupFields; private static $buttonFields = array('change','print'); private static $instance; @@ -41,6 +42,10 @@ EOS; private static $list = array(); public function __construct($param = NULL) { + global $gCms; if (!isset($gCms)) exit; + if (!isset(self::$groupFields)) { + self::$groupFields = AddressDB::getFields('Grupper'); + } foreach (self::$groupFields as $field) {$this->$field = '';} foreach (self::$buttonFields as $field) {$this->$field = '';} if (is_null($param)) return; @@ -100,7 +105,7 @@ EOS; } public static function getGroupList() { - if (count(self::$list) > 0) return $list; + if (count(self::$list) > 0) return self::$list; global $gCms; if (!isset($gCms)) exit; $c = __CLASS__; $db = AddressDB::getDB(); diff --git a/templates/groupEditPanel.tpl b/templates/groupEditPanel.tpl index fbe1f684bb87bcaa54118fc1893231c41d3d20d2..b85cbc44cde0657056b6312efe5ad0d273264737 100644 --- a/templates/groupEditPanel.tpl +++ b/templates/groupEditPanel.tpl @@ -12,7 +12,8 @@ <td>{$group->print}</td></tr> {/foreach} {/if} -<tr><td colspan="5" style="text-align: center;">{$newButton}</td></tr> +<tr><td colspan="5" style="text-align: center;">{$newButton} + {$backButton}</td></tr> </tbody></table> {if isset($hidden)}{$hidden}{/if} {$end_form}