action.add_edit_Group.php 2.49 KB
Newer Older
1
2
3
4
<?php
if (!isset($gCms)) exit;
//echo '<pre>'; print_r($params); echo '</pre>';

Leif Andersson's avatar
Leif Andersson committed
5
6
7
8
9
10
11
12
13
14
$ID='';
$paramKeys = array_keys($params);
$print = 'print_';
foreach ($paramKeys as $key) {
  $pos = strpos($key,$print);
  if ($pos === false) continue;
  $ID = substr($key,strlen($print));
  $this->Redirect($id, 'printGroup', $returnid, array('ID'=>$ID));
  return;
}
15
16
17
if (isset($params['back'])) {
  $this->Redirect($id, 'defaultadmin', $returnid, array());
}
18
19
20
21
if (! $this->CheckPermission('Use ReglerAddress')) {
  return $this->DisplayErrorPage($id, $params, $returnid,
				 'ReglerAddress access denied.');
}
22
//require_once 'lib/class.Group.php';
23
24
25
26
27
28
29
30

if (isset($params['cancelUpdate'])) {
  $paramsB = array(); 
  $this->Redirect($id, 'editGroups', $returnid, $paramsB);
  return;
}

if (isset($params['submit'])) {
31
32
  $record = new Groups($params);
  //echo '<pre>'; print_r($record); echo '</pre>';
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  $record->updateRecord();
  $paramsB['module_message'] = 'Gruppen ändrad';
  $this->Redirect($id, 'editGroups', $returnid, $paramsB);
  return;
}



$smarty = $this->smarty;
$smarty->assign('headline','Hantera grupp ');

$paramKeys = array_keys($params);
$ch = 'change_';
foreach ($paramKeys as $key) {
  $pos = strpos($key,$ch);
  if ($pos === false) continue;
  $ID = substr($key,strlen($ch));
  break;
}
if (isset($params['new'])){
53
  $group = new Groups();
54
55
  $ID = '';
} else {
56
  $group = new Groups($ID);
57
58
59
60
61
}

$place = $this->CreateFormStart($id, 'add_edit_Group', $returnid);
$smarty->assign('start_form', $place);
$smarty->assign('end_form', $this->CreateFormEnd());
62
$fields = Groups::$groupFields;
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

$smarty->assign('title_ID','ID');
$smarty->assign('value_ID',$ID);
$smarty->assign('title_Gruppnamn','Gruppnamn');
$place = $this->CreateInputText($id,'Gruppnamn',$group->Gruppnamn,30);
$smarty->assign('input_Gruppnamn',$place);
$smarty->assign('title_GruppInfo', 'Grupp info');
$place = $this->CreateTextArea(false,$id,$group->GruppInfo,'GruppInfo',
				 'width:auto; height:auto;','','','',30,3);
$place = str_replace('class','style', $place);
$smarty->assign('text_'.'GruppInfo',$place);

$place = $this->CreateInputSubmit($id, 'submit', 'Uppdatera');
$smarty->assign('submitButton',$place);

$place = $this->CreateInputSubmit($id, 'cancelUpdate', 'Avbryt');
$smarty->assign('cancelButton',$place);

if (isset($ID)) {
   $place = $this->CreateInputHidden($id, 'ID',$ID);
   $smarty->assign('hidden',$place);
}
$smarty->assign('Group',$group);

//echo '<pre>'; print_r($group); echo '</pre>';
echo $this->ProcessTemplate('groupEditOnePanel.tpl');  
  

?>