action.defaultadmin.php 3.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
/**
 * DisplayAdminPanel($id, $params, $returnid, $message)
 * NOT PART OF THE MODULE API
 * 
 */

/**
 * For separated methods, you'll always want to start with the following
 * 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';
if (!isset($gCms)) exit;

16
//echo '<pre>'; print_r($params); echo '</pre>';
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

/** 
 * For separated methods, you won't be able to do permission checks in
 * 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.');
}

/**
 * After this, the code is identical to the code that would otherwise be
 * wrapped in the DisplayAdminPanel() method in the module body.
 */
 
Leif Andersson's avatar
A    
Leif Andersson committed
33
34
$groups = Group::getGroupList(); 
//echo '<pre>'; print_r($groups); echo '</pre>'; exit;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

//file_put_contents("/tmp/defaultadmin.txt",print_r($params,TRUE));
$addrDB = AddressDB::getDB();
$smarty = $this->smarty;
// echo '<pre>'; print_r($params); echo '</pre>'; 

$place = $this->CreateFormStart($id, 'defaultadmin', $returnid);
$smarty->assign('start_form', $place);
$smarty->assign('end_form', $this->CreateFormEnd());

$fields = array(
  'fornamn' => 'Förnamn',
  'efternamn' => 'Efternamn',
  'foretag' => 'Skola/Företag',
  'avdelning' => 'Avdelning',
  'adress' => 'Adress',
  );
$smarty->assign('fields',$fields);

if (isset($params['new'])) {
  $this->Redirect($id, 'add_edit', $returnid, array());
}

Leif Andersson's avatar
B    
Leif Andersson committed
58
59
60
61
if (isset($params['groupChange'])) {
  $this->Redirect($id,'editGroups',$returnid,array());
}
	
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
foreach ($fields as $key => $res) {
  $value = '';
  if (isset($params[$key])) {$value = trim($params[$key]); }
  $smarty->assign('title_'.$key,$res);
  $place = $this->CreateInputText($id,$key,$value,40);
  $smarty->assign('input_'.$key,$place);
}  
  

$place = $this->CreateInputSubmit($id, 'search', 'Sök');
$smarty->assign('searchButton',$place);

$place = $this->CreateInputSubmit($id, 'new', 'Ny post');
$smarty->assign('newButton',$place);

Leif Andersson's avatar
B    
Leif Andersson committed
77
78
$place =  $this->CreateInputSubmit($id, 'groupChange', 'Hantera grupper');
$smarty->assign('groupButton',$place);
79
80

$name = 'Grupp';
Leif Andersson's avatar
A    
Leif Andersson committed
81
82
83
84
$groupNames = array(' ' => 'None');
foreach ($groups as $group) {
  $groupNames[$group->Gruppnamn] = $group->ID;
}
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
$selected = array();
if (isset($params[$name])) $selected[] = $params[$name];
$place = $this->CreateInputSelectList($id, $name, $groupNames, 
//   $selecteditems = array(), $size = 10, $addttext = '', $multiple = false);
     $selected, 10, '', false);
$smarty->assign('selectgroup',$place);

$formValues = array(); $hiddenParameters = '';
foreach ($params as $key => $value) {
  if ($key == 'search' || $key == 'action') continue;
  if ($key == 'Grupp' && $value == 'None') continue;
  if ($key == 'module_message') continue;
  if ($value != '') {
    $formValues[$key] = $value;
    $hiddenParameters[$key] = $value;
  }
}
$Persons = array();
if (count($formValues) > 0) $Persons = Person::searchPersons($formValues);
foreach ($Persons as $person) {
  $params = array('ID' => $person->ID) + $hiddenParameters;
  $person->link = $this->CreateLink($id, 'add_edit', '', 'Visa', $params);
}

if (isset($params['module_message'])) {
   $smarty->assign('module_message',$params['module_message']);
}

$smarty->assign('Persons',$Persons);

echo $this->ProcessTemplate('adminpanel.tpl');

//echo '<pre>'; print_r($Persons); echo '</pre>';

?>