openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

DBVersion000028.class.php (2968B)


      1 <?php
      2 
      3 namespace cms\update\version;
      4 
      5 use database\DbVersion;
      6 use database\Column;
      7 use security\Password;
      8 
      9 /**
     10  * The permission flags are now stored in 1 bitmask-column.
     11  *
     12  * @author dankert
     13  *
     14  */
     15 class DBVersion000028 extends DbVersion
     16 {
     17     /**
     18      *
     19      */
     20     public function update()
     21     {
     22     	$table = $this->table('acl');
     23     	$table->addIndex( ['type'] );
     24 
     25         $table->column('flags'  )->type(Column::TYPE_INT)->defaultValue(1)->add();
     26 
     27         // Initial Value: Copy from element.
     28         $tableSqlName = $table->getSqlName();
     29 
     30         $updateStmt = $this->getDb()->sql(<<<SQL
     31 UPDATE $tableSqlName
     32    SET flags=1;
     33 SQL
     34         );
     35         $updateStmt->execute();
     36 
     37         $updateStmt = $this->getDb()->sql(<<<SQL
     38 UPDATE $tableSqlName
     39    SET flags=flags+2 WHERE is_write=1;
     40 SQL
     41         );
     42         $updateStmt->execute();
     43 
     44         $updateStmt = $this->getDb()->sql(<<<SQL
     45 UPDATE $tableSqlName
     46    SET flags=flags+4 WHERE is_prop=1;
     47 SQL
     48         );
     49         $updateStmt->execute();
     50 
     51         $updateStmt = $this->getDb()->sql(<<<SQL
     52 UPDATE $tableSqlName
     53    SET flags=flags+64 WHERE is_create_folder=1;
     54 SQL
     55         );
     56         $updateStmt->execute();
     57 
     58         $updateStmt = $this->getDb()->sql(<<<SQL
     59 UPDATE $tableSqlName
     60    SET flags=flags+128 WHERE is_create_file=1;
     61 SQL
     62         );
     63         $updateStmt->execute();
     64 
     65         $updateStmt = $this->getDb()->sql(<<<SQL
     66 UPDATE $tableSqlName
     67    SET flags=flags+256 WHERE is_create_link=1;
     68 SQL
     69         );
     70         $updateStmt->execute();
     71 
     72         $updateStmt = $this->getDb()->sql(<<<SQL
     73 UPDATE $tableSqlName
     74    SET flags=flags+512 WHERE is_create_page=1;
     75 SQL
     76         );
     77         $updateStmt->execute();
     78 
     79         $updateStmt = $this->getDb()->sql(<<<SQL
     80 UPDATE $tableSqlName
     81    SET flags=flags+8 WHERE is_delete=1;
     82 SQL
     83         );
     84         $updateStmt->execute();
     85 
     86         $updateStmt = $this->getDb()->sql(<<<SQL
     87 UPDATE $tableSqlName
     88    SET flags=flags+16 WHERE is_release=1;
     89 SQL
     90         );
     91         $updateStmt->execute();
     92 
     93         $updateStmt = $this->getDb()->sql(<<<SQL
     94 UPDATE $tableSqlName
     95    SET flags=flags+32 WHERE is_publish=1;
     96 SQL
     97         );
     98         $updateStmt->execute();
     99 
    100         $updateStmt = $this->getDb()->sql(<<<SQL
    101 UPDATE $tableSqlName
    102    SET flags=flags+1024 WHERE is_grant=1;
    103 SQL
    104         );
    105         $updateStmt->execute();
    106 
    107         $updateStmt = $this->getDb()->sql(<<<SQL
    108 UPDATE $tableSqlName
    109    SET flags=flags+2048 WHERE is_transmit=1;
    110 SQL
    111         );
    112         $updateStmt->execute();
    113 
    114 		$table->column('is_write'        )->drop();
    115 		$table->column('is_prop'         )->drop();
    116 		$table->column('is_create_folder')->drop();
    117 		$table->column('is_create_file'  )->drop();
    118 		$table->column('is_create_page'  )->drop();
    119 		$table->column('is_create_link'  )->drop();
    120 		$table->column('is_delete'       )->drop();
    121 		$table->column('is_release'      )->drop();
    122 		$table->column('is_publish'      )->drop();
    123 		$table->column('is_grant'        )->drop();
    124 		$table->column('is_transmit'     )->drop();
    125 	}
    126 }
    127