Changeset 154 for www/temp/transform.php


Ignore:
Timestamp:
Feb 16, 2009, 7:54:34 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Postupné odstraňování odkazů na tabulku users.
  • Upraveno: Některé stránky přepracovány do nového zobrazovacího systému.
  • Přidáno: Tabulka Subject rozdělena na tabulky Subject a Member. Transformační skript upraven.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/temp/transform.php

    r153 r154  
    136136    $this->Database->query('TRUNCATE TABLE User');
    137137    $this->Database->query('TRUNCATE TABLE Subject');
     138    $this->Database->query('TRUNCATE TABLE Member');
    138139
    139140    // Init permission groups
     
    208209    $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
    209210
     211    $this->Database->insert('PermissionOperation', array('Module' => 'Network', 'Operation' => 'Administration'));
     212    $OperationId = $this->Database->insert_id;
     213    $this->Database->insert('PermissionGroupAssignment', array('Group' => $PermissionGroupNetworkAdmins, 'GroupOrOperation' => $OperationId, 'Type' => 'Operation'));
     214
    210215    $this->Database->insert('PermissionOperation', array('Module' => 'Log', 'Operation' => 'Show'));
    211216    $OperationId = $this->Database->insert_id;
     
    220225    while($DbRow = $DbResult->fetch_array())
    221226    {
    222       $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, 70), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0));
    223       $UserId = $this->Database->insert_id;
    224       if($DbRow['id'] == 1)
    225       {
    226         $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupAdmin, 'Type' => 'Group'));
     227      if($DbRow['role'] == 0)
     228      {
     229        $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']));
     230      } else
     231      if($DbRow['role'] == 1)
     232      {
     233        $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, 70), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0));
     234        $UserId = $this->Database->insert_id;
     235        $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupMembers, 'Type' => 'Group'));
    227236      } else
    228237      if($DbRow['role'] == 2)
    229238      {
    230         $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']));
    231         $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group'));
    232       } else
    233         $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupMembers, 'Type' => 'Group'));
     239        $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']));
     240                $SubjectId = $this->Database->insert_id;
     241                $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']));
     242        $MemberId = $this->Database->insert_id;
     243        $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, 70), 'ICQ' => $DbRow['icq'], 'Email' => $DbRow['email'], 'Locked' => 0, 'Member' => $MemberId));
     244        $UserId = $this->Database->insert_id;
     245                $this->Database->update('Member', 'Id='.$MemberId, array('ResponsibleUser' => $UserId));
     246                if($DbRow['id'] == 1) $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupAdmin, 'Type' => 'Group'));
     247          else $this->Database->insert('PermissionUserAssignment', array('User' => $UserId, 'GroupOrOperation' => $PermissionGroupSubjects, 'Type' => 'Group'));
     248      }
    234249    }
    235250
Note: See TracChangeset for help on using the changeset viewer.