/[scire]/scire/settings.php
Gentoo

Contents of /scire/settings.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 173 - (show annotations) (download)
Mon Dec 11 00:51:46 2006 UTC (11 years, 10 months ago) by codeman
File size: 9278 byte(s)
adding job page settings. very similar to the other two/three

1 <?php
2 include('.lib/common.php');
3
4 $smarty->assign('leftbar', "on");
5 $leftbar_menu = array();
6 $leftbar_submenu = array();
7 $template = "settings.tpl";
8 $status = "";
9 $smarty->assign('desc', "Edit user settings.");
10
11 $themes = array();
12 array_push($themes, array('name' => 'Standard Grey', 'link' => 'std_grey'));
13 array_push($themes, array('name' => 'Light Blue', 'link' => 'light_blue'));
14 $smarty->assign('themes',$themes);
15
16 ############################################
17 ## Deal with submitted forms first.
18 if ($_POST['save_settings']) {
19 #$settings = $_SESSION['settings'];
20 foreach ($_POST as $settingname => $value) {
21 if ($settingname != "save_settings") { #SKIP
22 if (isset($_SESSION['settings'][$settingname])) {
23 if ($value != $_SESSION['settings'][$settingname]) { #The value doesn't match, we need to update.
24 #update the SESSION value.
25 $_SESSION['settings'][$settingname] = $value;
26 #writeback to the DB as well to keep in sync.
27 scire_set_setting($_SESSION['userid'], $settingname, $value);
28 }
29 } else { #New setting. store it.
30 $_SESSION['settings'][$settingname] = $value;
31 #writeback to the DB as well to keep in sync.
32 scire_add_setting($_SESSION['userid'], $settingname, $value);
33 }
34 }
35 }
36 }
37 ######################################## POST
38 if ($_POST['save_Jobs_settings']) {
39 pre_var_dump($_POST);
40 foreach ($_POST as $name => $value) {
41 if ($name == "sorton") {
42 if ($value != $_SESSION['settings']['jobs_page_sorton']) { #The value doesn't match, we need to update.
43 scire_set_setting($_SESSION['userid'], 'jobs_page_sorton', $value);
44 } else {
45 scire_add_setting($_SESSION['userid'], 'jobs_page_sorton', $value);
46 }
47 $_SESSION['settings']['jobs_page_sorton'] = $value;
48 }
49 elseif ($name == "sortdir") {
50 if ($value != $_SESSION['settings']['jobs_page_sortdir']) { #The value doesn't match, we need to update.
51 scire_set_setting($_SESSION['userid'], 'jobs_page_sortdir', $value);
52 } else {
53 scire_add_setting($_SESSION['userid'], 'jobs_page_sortdir', $value);
54 }
55 $_SESSION['settings']['jobs_page_sortdir'] = $value;
56 }
57 elseif (substr($name,0, 4) == "Jobs" and $value) {
58 $temp = substr($name,5);
59 $jobs_page_fields[$temp] = $value;
60 print "Adding field $name ... $value";
61 }
62 }
63 #Done with looping
64 pre_var_dump($jobs_page_fields);
65 asort($jobs_page_fields);
66 $keys = array_keys($jobs_page_fields);
67 $fields_string = join(',', $keys);
68
69 #print $fields_string;
70 if ($fields_string != $_SESSION['settings']['jobs_page_fields']) {
71 scire_set_setting($_SESSION['userid'], 'jobs_page_fields', $fields_string);
72 } else {
73 scire_add_setting($_SESSION['userid'], 'jobs_page_fields', $fields_string);
74 }
75 $_SESSION['settings']['jobs_page_fields'] = $fields_string;
76 }
77
78 ########################################
79 if ($_POST['save_Clients_settings']) {
80 foreach ($_POST as $name => $value) {
81 if ($name == "sorton") {
82 if ($value != $_SESSION['settings']['clients_page_sorton']) { #The value doesn't match, we need to update.
83 scire_set_setting($_SESSION['userid'], 'clients_page_sorton', $value);
84 } else {
85 scire_add_setting($_SESSION['userid'], 'clients_page_sorton', $value);
86 }
87 $_SESSION['settings']['clients_page_sorton'] = $value;
88 }
89 elseif ($name == "sortdir") {
90 if ($value != $_SESSION['settings']['clients_page_sortdir']) { #The value doesn't match, we need to update.
91 scire_set_setting($_SESSION['userid'], 'clients_page_sortdir', $value);
92 } else {
93 scire_add_setting($_SESSION['userid'], 'clients_page_sortdir', $value);
94 }
95 $_SESSION['settings']['clients_page_sortdir'] = $value;
96 }
97 elseif (substr($name,0, 7) == "Clients" and $value) {
98 $temp = substr($name,8);
99 $clients_page_fields[$temp] = $value;
100 }
101 }
102 #Done with looping
103 asort($clients_page_fields);
104 $keys = array_keys($clients_page_fields);
105 $fields_string = join(',', $keys);
106
107 #print $fields_string;
108 if ($fields_string != $_SESSION['settings']['clients_page_fields']) {
109 scire_set_setting($_SESSION['userid'], 'clients_page_fields', $fields_string);
110 } else {
111 scire_add_setting($_SESSION['userid'], 'clients_page_fields', $fields_string);
112 }
113 $_SESSION['settings']['clients_page_fields'] = $fields_string;
114 }
115 ########################################
116 if ($_POST['save_Users_settings']) {
117 foreach ($_POST as $name => $value) {
118 if ($name == "sorton") {
119 if ($value != $_SESSION['settings']['users_page_sorton']) { #The value doesn't match, we need to update.
120 scire_set_setting($_SESSION['userid'], 'users_page_sorton', $value);
121 } else {
122 scire_add_setting($_SESSION['userid'], 'users_page_sorton', $value);
123 }
124 $_SESSION['settings']['users_page_sorton'] = $value;
125 }
126 elseif ($name == "sortdir") {
127 if ($value != $_SESSION['settings']['users_page_sortdir']) { #The value doesn't match, we need to update.
128 scire_set_setting($_SESSION['userid'], 'users_page_sortdir', $value);
129 } else {
130 scire_add_setting($_SESSION['userid'], 'users_page_sortdir', $value);
131 }
132 $_SESSION['settings']['users_page_sortdir'] = $value;
133 }
134 elseif (substr($name,0, 5) == "Users" and $value) {
135 $temp = substr($name,6);
136 $users_page_fields[$temp] = $value;
137 }
138 }
139 #Done with looping
140 asort($users_page_fields);
141 $keys = array_keys($users_page_fields);
142 $fields_string = join(',', $keys);
143
144 #print $fields_string;
145 if ($fields_string != $_SESSION['settings']['users_page_fields']) {
146 scire_set_setting($_SESSION['userid'], 'users_page_fields', $fields_string);
147 } else {
148 scire_add_setting($_SESSION['userid'], 'users_page_fields', $fields_string);
149 }
150 $_SESSION['settings']['users_page_fields'] = $fields_string;
151 }
152
153
154
155 switch($_GET['View']) {
156 case "Clients":
157 $template = "settings_page.tpl";
158
159 $settings = $_SESSION['settings'];
160 $clients_setting_list = array('clients_page_fields', 'clients_page_sorton', 'clients_page_sortdir');
161 foreach ($clients_setting_list as $clients_set) {
162 if ($settings[$clients_set]) {
163 $smarty->assign($clients_set, $settings[$clients_set]);
164 }
165 }
166 $fields = get_clients_fields();
167 $smarty->assign('fields', $fields);
168
169
170 foreach (explode(',',$_SESSION['settings']['clients_page_fields']) as $key=> $curr_fieldname) {
171 $curr_list[$curr_fieldname] = ($key+1);
172 }
173 var_dump($curr_list);
174 $smarty->assign('curr_list', $curr_list);
175 $smarty->assign('sorton', $_SESSION['settings']['clients_page_sorton']);
176 $smarty->assign('sortdir', $_SESSION['settings']['clients_page_sortdir']);
177 break;
178
179 case "Users":
180 $template = "settings_page.tpl";
181
182 $settings = $_SESSION['settings'];
183 $users_setting_list = array('users_page_fields', 'users_page_sorton', 'users_page_sortdir');
184 foreach ($users_setting_list as $users_set) {
185 if ($settings[$users_set]) {
186 $smarty->assign($users_set, $settings[$users_set]);
187 }
188 }
189 $fields = get_users_fields();
190 $smarty->assign('fields', $fields);
191
192 foreach (explode(',',$_SESSION['settings']['users_page_fields']) as $key=> $curr_fieldname) {
193 $curr_list[$curr_fieldname] = ($key+1);
194 }
195 var_dump($curr_list);
196 $smarty->assign('curr_list', $curr_list);
197 $smarty->assign('sorton', $_SESSION['settings']['users_page_sorton']);
198 $smarty->assign('sortdir', $_SESSION['settings']['users_page_sortdir']);
199 break;
200
201 case "Jobs":
202 $template = "settings_page.tpl";
203 $settings = $_SESSION['settings'];
204 $jobs_setting_list = array('jobs_page_fields', 'jobs_page_sorton', 'jobs_page_sortdir');
205 foreach ($jobs_setting_list as $jobs_set) {
206 if ($settings[$jobs_set]) {
207 $smarty->assign($jobs_set, $settings[$jobs_set]);
208 }
209 }
210 $fields = get_jobs_fields();
211 $smarty->assign('fields', $fields);
212
213 foreach (explode(',',$_SESSION['settings']['jobs_page_fields']) as $key=> $curr_fieldname) {
214 $curr_list[$curr_fieldname] = ($key+1);
215 }
216 var_dump($curr_list);
217 $smarty->assign('curr_list', $curr_list);
218 $smarty->assign('sorton', $_SESSION['settings']['jobs_page_sorton']);
219 $smarty->assign('sortdir', $_SESSION['settings']['jobs_page_sortdir']);
220 break;
221
222 default: #Show users.
223
224
225 #$smarty->assign('leftbar_submenu_title', "Actions");
226 #add_leftbar($leftbar_submenu, "Create User", "user.php?Action=create");
227
228 ############################################
229 ## Deal with sorting for the query.
230 $settings = $_SESSION['settings'];
231 $main_setting_list = array('start_page', 'theme', 'language', 'notification', 'per_page', 'vacation');
232 foreach ($main_setting_list as $main_set) {
233 if ($settings[$main_set]) {
234 $smarty->assign($main_set, $settings[$main_set]);
235 }
236 }
237
238 dumper($settings);
239 break;
240 }
241
242 add_leftbar($leftbar_menu, "Main Settings", "settings.php");
243 add_leftbar($leftbar_menu, "Jobs Page", "settings.php?View=Jobs");
244 add_leftbar($leftbar_menu, "Clients Page", "settings.php?View=Clients");
245 add_leftbar($leftbar_menu, "Users Page", "settings.php?View=Users");
246 add_leftbar($leftbar_menu, "UI Permissions", "ui_permissions.php");
247 add_leftbar($leftbar_menu, "Pending Clients", "clients.php?View=Pending");
248
249 $smarty->assign('leftbar_menu', $leftbar_menu);
250 $smarty->assign('leftbar_submenu', $leftbar_submenu);
251 $smarty->assign('View', $_GET['View']);
252 $smarty->assign('Action', $_GET['Action']);
253 $smarty->assign('status', $status);
254 $smarty->display($template);
255 #var_dump($_POST);
256 ?>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20