source: www/temp/transform.php@ 174

Last change on this file since 174 was 174, checked in by george, 16 years ago
  • Přesunuto: Složka devel přejmenována na branches.
File size: 18.6 KB
Line 
1<?php
2
3//$SessionDisable = true;
4include('../global.php');
5
6class Transform extends Page
7{
8 var $FullTitle = 'Transformace databéze';
9 var $ShortTitle = 'Transformace';
10
11 var $Subjects = array(
12 'Jednota' => array(
13 'Notice' => '',
14 'LastUpdateTime' => '2008-07-04',
15 'Intervals' => array(
16 array('DayOfWeek' => 0, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
17 array('DayOfWeek' => 0, 'Index' => 1, 'OpenTime' => '14:00:00', 'CloseTime' => '16:30:00'),
18 array('DayOfWeek' => 1, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
19 array('DayOfWeek' => 2, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
20 array('DayOfWeek' => 2, 'Index' => 1, 'OpenTime' => '14:00:00', 'CloseTime' => '16:30:00'),
21 array('DayOfWeek' => 3, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
22 array('DayOfWeek' => 3, 'Index' => 1, 'OpenTime' => '14:00:00', 'CloseTime' => '16:30:00'),
23 array('DayOfWeek' => 4, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '12:00:00'),
24 array('DayOfWeek' => 4, 'Index' => 1, 'OpenTime' => '13:30:00', 'CloseTime' => '16:30:00'),
25 array('DayOfWeek' => 5, 'Index' => 0, 'OpenTime' => '6:00:00', 'CloseTime' => '10:30:00'),
26 ),
27 ),
28 'Pošta' => array(
29 'Notice' => 'Schránka se vybírá v pracovní dny v 7:45 a 15:30',
30 'LastUpdateTime' => '2009-02-18',
31 'Intervals' => array(
32 array('DayOfWeek' => 0, 'Index' => 0, 'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
33 array('DayOfWeek' => 0, 'Index' => 1, 'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
34 array('DayOfWeek' => 1, 'Index' => 0, 'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
35 array('DayOfWeek' => 1, 'Index' => 1, 'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
36 array('DayOfWeek' => 2, 'Index' => 0, 'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
37 array('DayOfWeek' => 2, 'Index' => 1, 'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
38 array('DayOfWeek' => 3, 'Index' => 0, 'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
39 array('DayOfWeek' => 3, 'Index' => 1, 'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
40 array('DayOfWeek' => 4, 'Index' => 0, 'OpenTime' => '8:00:00', 'CloseTime' => '9:30:00'),
41 array('DayOfWeek' => 4, 'Index' => 1, 'OpenTime' => '14:30:00', 'CloseTime' => '15:30:00'),
42 ),
43 ),
44 'Obecní úřad' => array(
45 'Notice' => 'Zdroj <a href="http://www.zdechov.cz/pages/main.php?pg=obecniurad&cat=1">www.zdechov.cz</a>',
46 'LastUpdateTime' => '2008-07-07',
47 'Intervals' => array(
48 array('DayOfWeek' => 0, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
49 array('DayOfWeek' => 0, 'Index' => 1, 'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
50 array('DayOfWeek' => 1, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
51 array('DayOfWeek' => 1, 'Index' => 1, 'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
52 array('DayOfWeek' => 2, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
53 array('DayOfWeek' => 2, 'Index' => 1, 'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
54 array('DayOfWeek' => 3, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
55 array('DayOfWeek' => 3, 'Index' => 1, 'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
56 array('DayOfWeek' => 4, 'Index' => 0, 'OpenTime' => '7:00:00', 'CloseTime' => '11:00:00'),
57 array('DayOfWeek' => 4, 'Index' => 1, 'OpenTime' => '11:30:00', 'CloseTime' => '14:00:00'),
58 ),
59 ),
60 'Svijanská pivnice' => array(
61 'Notice' => '',
62 'LastUpdateTime' => '2009-02-16',
63 'Intervals' => array(
64 array('DayOfWeek' => 0, 'Index' => 0, 'OpenTime' => '15:00:00', 'CloseTime' => '22:00:00'),
65 array('DayOfWeek' => 1, 'Index' => 0, 'OpenTime' => '15:00:00', 'CloseTime' => '22:00:00'),
66 array('DayOfWeek' => 2, 'Index' => 0, 'OpenTime' => '15:00:00', 'CloseTime' => '22:00:00'),
67 array('DayOfWeek' => 3, 'Index' => 0, 'OpenTime' => '15:00:00', 'CloseTime' => '23:00:00'),
68 array('DayOfWeek' => 4, 'Index' => 0, 'OpenTime' => '15:00:00', 'CloseTime' => '23:00:00'),
69 array('DayOfWeek' => 5, 'Index' => 0, 'OpenTime' => '10:30:00', 'CloseTime' => '22:00:00'),
70 ),
71 ),
72 'Knihovna' => array(
73 'Notice' => '',
74 'LastUpdateTime' => '2004-08-20',
75 'Intervals' => array(
76 array('DayOfWeek' => 4, 'Index' => 0, 'OpenTime' => '14:30:00', 'CloseTime' => '17:00:00'),
77 ),
78 ),
79 'Koliba' => array(
80 'Notice' => '',
81 'LastUpdateTime' => '2008-04-29',
82 'Intervals' => array(
83 array('DayOfWeek' => 2, 'Index' => 0, 'OpenTime' => '14:00:00', 'CloseTime' => '22:00:00'),
84 array('DayOfWeek' => 3, 'Index' => 0, 'OpenTime' => '14:00:00', 'CloseTime' => '22:00:00'),
85 array('DayOfWeek' => 4, 'Index' => 0, 'OpenTime' => '14:00:00', 'CloseTime' => '27:00:00'),
86 array('DayOfWeek' => 5, 'Index' => 0, 'OpenTime' => '14:00:00', 'CloseTime' => '27:00:00'),
87 array('DayOfWeek' => 6, 'Index' => 0, 'OpenTime' => '14:00:00', 'CloseTime' => '21:00:00'),
88 ),
89 ),
90 'Hospoda Kasino' => array(
91 'Notice' => '',
92 'LastUpdateTime' => '2008-07-04',
93 'Intervals' => array(
94 array('DayOfWeek' => 0, 'Index' => 0, 'OpenTime' => '16:00:00', 'CloseTime' => '21:00:00'),
95 array('DayOfWeek' => 1, 'Index' => 0, 'OpenTime' => '16:00:00', 'CloseTime' => '21:00:00'),
96 array('DayOfWeek' => 2, 'Index' => 0, 'OpenTime' => '17:00:00', 'CloseTime' => '21:00:00'),
97 array('DayOfWeek' => 3, 'Index' => 0, 'OpenTime' => '17:00:00', 'CloseTime' => '21:00:00'),
98 array('DayOfWeek' => 4, 'Index' => 0, 'OpenTime' => '16:00:00', 'CloseTime' => '24:00:00'),
99 array('DayOfWeek' => 5, 'Index' => 0, 'OpenTime' => '14:00:00', 'CloseTime' => '24:00:00'),
100 array('DayOfWeek' => 6, 'Index' => 0, 'OpenTime' => '10:00:00', 'CloseTime' => '21:00:00'),
101 ),
102 ),
103 );
104
105 function SubjectOpenTime()
106 {
107 //$this->Database->query('DELETE FROM `Subject` WHERE `Subject`.`Id` = (SELECT `Subject` FROM `SubjectOpenTime`)');
108 $this->Database->query('TRUNCATE TABLE `SubjectOpenTime`');
109 $this->Database->query('TRUNCATE TABLE `SubjectOpenTimeInterval`');
110 foreach($this->Subjects as $SubjectName => $Subject)
111 {
112 $this->Database->insert('Subject', array('Name' => $SubjectName));
113 $Subject['Id'] = $this->Database->insert_id;
114 $this->Database->insert('SubjectOpenTime', array('Notice' => $Subject['Notice'], 'UpdateTime' => $Subject['LastUpdateTime'], 'Subject' => $Subject['Id']));
115 foreach($Subject['Intervals'] as $TimeInterval)
116 {
117 $TimeInterval['Subject'] = $Subject['Id'];
118 $TimeInterval['OpenTime'] = '0000-01-0'.($TimeInterval['DayOfWeek'] + 1).' '.$TimeInterval['OpenTime'];
119 $TimeInterval['CloseTime'] = '0000-01-0'.($TimeInterval['DayOfWeek'] + 1).' '.$TimeInterval['CloseTime'];
120 unset($TimeInterval['DayOfWeek']);
121 unset($TimeInterval['Index']);
122 $this->Database->insert('SubjectOpenTimeInterval', $TimeInterval);
123 }
124 }
125 }
126
127 function Show()
128 {
129 $Output = '';
130 die();
131
132 // Clear previous content
133 $this->Database->query('TRUNCATE TABLE PermissionOperation');
134 $this->Database->query('TRUNCATE TABLE PermissionGroup');
135 $this->Database->query('TRUNCATE TABLE PermissionGroupAssignment');
136 $this->Database->query('TRUNCATE TABLE PermissionUserAssignment');
137 $this->Database->query('TRUNCATE TABLE User');
138 $this->Database->query('TRUNCATE TABLE Subject');
139 $this->Database->query('TRUNCATE TABLE Member');
140
141 // Init permission groups
142 $this->Database->insert('PermissionGroup', array('Description' => 'Ostatní'));
143 $PermissionGroupOthers = $this->Database->insert_id;
144 $this->Database->insert('PermissionGroup', array('Description' => 'Registrovaní uživatelé'));
145 $PermissionGroupRegistred = $this->Database->insert_id;
146 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $PermissionGroupOthers, 'Type' => 'Group'));
147//echo($this->Database->LastQuery);
148 $this->Database->insert('PermissionGroup', array('Description' => 'Zástupci za domácnost'));
149 $PermissionGroupSubjects = $this->Database->insert_id;
150 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $PermissionGroupRegistred, 'Type' => 'Group'));
151$this->Database->insert('PermissionGroup', array('Description' => 'Správci sítě'));
152 $PermissionGroupNetworkAdmins = $this->Database->insert_id;
153 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group'));
154 $this->Database->insert('PermissionGroup', array('Description' => 'Systémoví administrátoři'));
155 $PermissionGroupAdmin = $this->Database->insert_id;
156 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupAdmin, 'GroupOrOperation' => $PermissionGroupNetworkAdmins, 'Type' => 'Group'));
157
158 // Init permission operations
159 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Display', 'Item' => 'Item'));
160 $OperationId = $this->Database->insert_id;
161 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
162
163 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Insert', 'Item' => ''));
164 $OperationId = $this->Database->insert_id;
165 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
166
167 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Display', 'Item' => 'Item'));
168 $OperationId = $this->Database->insert_id;
169 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
170
171 $DbResult = $this->Database->select('news_category', 'id, permission');
172 while($DbRow = $DbResult->fetch_array())
173 {
174 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Insert', 'Item' => 'Group', 'ItemId' => $DbRow['id']));
175 $OperationIdInsert = $this->Database->insert_id;
176 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Display', 'Item' => 'Group', 'ItemId' => $DbRow['id']));
177 $OperationIdDisplay = $this->Database->insert_id;
178 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationIdDisplay, 'Type' => 'Operation'));
179 if($DbRow['permission'] == 0)
180 {
181 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationIdInsert, 'Type' => 'Operation'));
182 } else
183 {
184 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationIdInsert, 'Type' => 'Operation'));
185 }
186 }
187
188 $this->Database->insert('PermissionOperation', array('Module' => 'Chat', 'Operation' => 'Display'));
189 $OperationId = $this->Database->insert_id;
190 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
191
192 $this->Database->insert('PermissionOperation', array('Module' => 'Share', 'Operation' => 'Display'));
193 $OperationId = $this->Database->insert_id;
194 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupRegistred, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
195
196 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'DisplaySubjectState'));
197 $OperationId = $this->Database->insert_id;
198 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
199
200 $this->Database->insert('PermissionOperation', array('Module' => 'EatingPlace', 'Operation' => 'Edit'));
201 //$OperationId = $this->Database->insert_id;
202 //$this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupMembers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
203
204 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'Manage'));
205 $OperationId = $this->Database->insert_id;
206 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
207
208 $this->Database->insert('PermissionOperation', array('Module' => 'Network', 'Operation' => 'Edit'));
209 $OperationId = $this->Database->insert_id;
210 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
211
212 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'SubjectList'));
213 $OperationId = $this->Database->insert_id;
214 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
215
216 $this->Database->insert('PermissionOperation', array('Module' => 'Network', 'Operation' => 'Administration'));
217 $OperationId = $this->Database->insert_id;
218 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
219
220 $this->Database->insert('PermissionOperation', array('Module' => 'Log', 'Operation' => 'Show'));
221 $OperationId = $this->Database->insert_id;
222 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
223
224 $this->Database->insert('PermissionOperation', array('Module' => 'Network', 'Operation' => 'RegistredHostList'));
225 $OperationId = $this->Database->insert_id;
226 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
227
228 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'TradingStatus'));
229 $OperationId = $this->Database->insert_id;
230 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupAdmin, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
231
232 // Init User table from users
233 $DbResult = $this->Database->select('users_old', '*');
234 while($DbRow = $DbResult->fetch_array())
235 {
236 if($DbRow['role'] == 0)
237 {
238 $this->Database->insert('Subject', array('Id' => $DbRow['id'], 'Name' => $DbRow['subject_name'], 'AddressStreet' => $DbRow['street'], 'AddressTown' => $DbRow['town'], 'AddressPSC' => $DbRow['psc'], 'IC' => $DbRow['ico'], 'DIC' => $DbRow['dic'], 'MapPositionX' => $DbRow['PositionX'], 'MapPositionY' => $DbRow['PositionY']));
239 } else
240 if($DbRow['role'] == 1)
241 {
242 //$Password = sha1(strtoupper($DbRow['nick']));
243 $Password = substr(sha1(mt_rand(0, 1000000)), 0, 10);
244 $this->Database->insert('User', array('Id' => $DbRow['id'], 'Name' => $DbRow['nick'], 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'PhoneNumber' => $DbRow['phone'], 'Password' => sha1($Password), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0, 'InitPassword' => $Password, 'Nick' => $DbRow['nick']));
245 $UserId = $this->Database->insert_id;
246 $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupRegistred, 'Type' => 'Group'));
247 } else
248 if($DbRow['role'] == 2)
249 {
250 $this->Database->insert('Subject', array('Id' => $DbRow['id'], 'Name' => $DbRow['subject_name'], 'AddressStreet' => $DbRow['street'], 'AddressTown' => $DbRow['town'], 'AddressPSC' => $DbRow['psc'], 'IC' => $DbRow['ico'], 'DIC' => $DbRow['dic'], 'MapPositionX' => $DbRow['PositionX'], 'MapPositionY' => $DbRow['PositionY']));
251 $SubjectId = $this->Database->insert_id;
252 $this->Database->insert('Member', array('Id' => $DbRow['id'], 'Subject' => $SubjectId, 'FamilyMemberCount' => $DbRow['family'], 'NetworkSegment' => $DbRow['network_segment'], 'InternetTariffCurrentMonth' => $DbRow['inet_tarif_now'], 'InternetTariffNextMonth' => $DbRow['inet_tarif_next'], 'MembershipDate' => $DbRow['membership_date'], 'MemberState' => 0, 'BillingPeriod' => $DbRow['BillingPeriod']));
253 $MemberId = $this->Database->insert_id;
254 $Password = substr(sha1(mt_rand(0, 1000000)), 0, 10);
255 $this->Database->insert('User', array('Id' => $DbRow['id'], 'Name' => $DbRow['nick'], 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'PhoneNumber' => $DbRow['phone'], 'Password' => sha1($Password), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0, 'Member' => $MemberId, 'InitPassword' => $Password, 'Nick' => $DbRow['nick']));
256 $UserId = $this->Database->insert_id;
257 $this->Database->update('Member', 'Id='.$MemberId, array('ResponsibleUser' => $UserId));
258 if($DbRow['id'] == 1) $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupAdmin, 'Type' => 'Group'));
259 else $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group'));
260 }
261 }
262
263 // Insert anonymous user
264 $this->Database->insert('User', array('Name' => 'Anonym', 'Password' => 'dsafafdfadfs', 'Locked' => 0));
265 $Output .= 'Anonymní uživatel: '.$this->Database->insert_id.'</ br>';
266 $AnonymousUserId = $this->Database->insert_id;
267 $this->Database->insert('PermissionUserAssignment', array('User' => $AnonymousUserId, 'GroupOrOperation' => $PermissionGroupOthers, 'Type' => 'Group'));
268
269 // Init subjects open time
270 $this->SubjectOpenTime();
271
272 // Import chat messages history
273 //$this->Database->query('TRUNCATE TABLE ChatHistory');
274 //$this->Database->query('INSERT INTO ChatHistory (SELECT id as Id, nick as Nick, text as Text, time as Time, color as Color, roomname as RoomName, roomtype as RoomType, "" as Host FROM `sunrisechat_history`)');
275
276
277 return($Output);
278 }
279}
280
281$System->AddModule(new Transform());
282$System->Modules['Transform']->GetOutput();
283
284?>
Note: See TracBrowser for help on using the repository browser.