Changeset 107 for devel/www/temp/transform.php
- Timestamp:
- Sep 14, 2008, 5:54:37 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/www/temp/transform.php
r102 r107 129 129 $Output = ''; 130 130 131 // Init User table from users 131 // Clear previous content 132 $this->Database->query('TRUNCATE TABLE PermissionOperation'); 133 $this->Database->query('TRUNCATE TABLE PermissionGroup'); 134 $this->Database->query('TRUNCATE TABLE PermissionGroupAssignment'); 135 $this->Database->query('TRUNCATE TABLE PermissionUserAssignment'); 132 136 $this->Database->query('TRUNCATE TABLE User'); 133 137 $this->Database->query('TRUNCATE TABLE Subject'); 134 138 139 // Init permission groups 140 $this->Database->insert('PermissionGroup', array('Description' => 'Ostatní')); 141 $PermissionGroupOthers = $this->Database->insert_id; 142 $this->Database->insert('PermissionGroup', array('Description' => 'Členové sítě')); 143 $PermissionGroupMembers = $this->Database->insert_id; 144 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupMembers, 'GroupOrOperation' => $PermissionGroupOthers, 'Type' => 'Group')); 145 echo($this->Database->LastQuery); 146 $this->Database->insert('PermissionGroup', array('Description' => 'Zástupci za domácnost')); 147 $PermissionGroupSubjects = $this->Database->insert_id; 148 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $PermissionGroupMembers, 'Type' => 'Group')); 149 $this->Database->insert('PermissionGroup', array('Description' => 'Správci sítě')); 150 $PermissionGroupNetworkAdmins = $this->Database->insert_id; 151 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group')); 152 $this->Database->insert('PermissionGroup', array('Description' => 'Systémoví administrátoři')); 153 $PermissionGroupAdmin = $this->Database->insert_id; 154 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupAdmin, 'GroupOrOperation' => $PermissionGroupNetworkAdmins, 'Type' => 'Group')); 155 156 // Init permission operations 157 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Display', 'Item' => 'Item')); 158 $OperationId = $this->Database->insert_id; 159 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 160 161 $DbResult = $this->Database->select('news_category', 'id, permission'); 162 while($DbRow = $DbResult->fetch_array()) 163 { 164 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Insert', 'Item' => 'Group', 'ItemId' => $DbRow['id'])); 165 $OperationIdInsert = $this->Database->insert_id; 166 $this->Database->insert('PermissionOperation', array('Module' => 'News', 'Operation' => 'Display', 'Item' => 'Group', 'ItemId' => $DbRow['id'])); 167 $OperationIdDisplay = $this->Database->insert_id; 168 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationIdDisplay, 'Type' => 'Operation')); 169 if($DbRow['permission'] == 1) 170 { 171 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOoperation' => $OperationIdInsert, 'Type' => 'Operation')); 172 } else 173 { 174 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationIdInsert, 'Type' => 'Operation')); 175 } 176 } 177 178 $this->Database->insert('PermissionOperation', array('Module' => 'Chat', 'Operation' => 'Display')); 179 $OperationId = $this->Database->insert_id; 180 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupOthers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 181 182 $this->Database->insert('PermissionOperation', array('Module' => 'Share', 'Operation' => 'Display')); 183 $OperationId = $this->Database->insert_id; 184 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupMembers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 185 186 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'DisplaySubjectState')); 187 $OperationId = $this->Database->insert_id; 188 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupSubjects, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 189 190 $this->Database->insert('PermissionOperation', array('Module' => 'EatingPlace', 'Operation' => 'Edit')); 191 $OperationId = $this->Database->insert_id; 192 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupMembers, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 193 194 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'Manage')); 195 $OperationId = $this->Database->insert_id; 196 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 197 198 $this->Database->insert('PermissionOperation', array('Module' => 'Network', 'Operation' => 'Edit')); 199 $OperationId = $this->Database->insert_id; 200 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 201 202 $this->Database->insert('PermissionOperation', array('Module' => 'Finance', 'Operation' => 'SubjectList')); 203 $OperationId = $this->Database->insert_id; 204 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 205 206 $this->Database->insert('PermissionOperation', array('Module' => 'Log', 'Operation' => 'Show')); 207 $OperationId = $this->Database->insert_id; 208 $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation')); 209 210 // Init User table from users 135 211 $DbResult = $this->Database->select('users', '*'); 136 212 while($DbRow = $DbResult->fetch_array()) 137 213 { 138 214 $this->Database->insert('User', array('Id' => $DbRow['id'], 'Name' => $DbRow['nick'], 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'PhoneNumber' => $DbRow['phone'], 'Password' => substr(sha1(strtoupper($DbRow['nick'])), 0, 7), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0)); 215 $UserId = $this->Database->insert_id; 216 if($DbRow['id'] == 1) 217 { 218 $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupAdmin, 'Type' => 'Group')); 219 } else 139 220 if($DbRow['role'] == 2) 140 221 { 141 222 $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'], 'FamilyMemberCount' => $DbRow['family'], 'MapPositionX' => $DbRow['PositionX'], 'MapPositionY' => $DbRow['PositionY'], 'NetworkSegment' => $DbRow['network_segment'], 'InternetTariffCurrentMonth' => $DbRow['inet_tarif_now'], 'InternetTariffNextMonth' => $DbRow['inet_tarif_next'], 'MembershipDate' => $DbRow['membership_date'])); 142 } 223 $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group')); 224 } else 225 $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupMembers, 'Type' => 'Group')); 143 226 } 144 227 228 // Insert anonymous user 145 229 $this->Database->insert('User', array('Name' => 'Anonym', 'Password' => 'dsafafdfadfs', 'Locked' => 0)); 146 $Output .= $this->Database->insert_id; 147 230 $Output .= 'Anonymní uživatel: '.$this->Database->insert_id.'</ br>'; 231 $AnonymousUserId = $this->Database->insert_id; 232 $this->Database->insert('PermissionUserAssignment', array('User' => $AnonymousUserId, 'GroupOrOperation' => $PermissionGroupOthers, 'Type' => 'Group')); 233 234 // Init subjects open time 148 235 $this->SubjectOpenTime(); 149 236 … … 151 238 //$this->Database->query('TRUNCATE TABLE ChatHistory'); 152 239 //$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`)'); 240 241 153 242 return($Output); 154 243 }
Note:
See TracChangeset
for help on using the changeset viewer.