コード例 #1
0
 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (isset($_SESSION['glpiactiveprofile'])) {
         PluginGeninventorynumberProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
     }
     if (TableExists("glpi_plugin_geninventorynumber_profiles")) {
         foreach (getAllDatasFromTable($table) as $data) {
             $profile = new self();
             foreach ($profile->getAllRights() as $right => $rights) {
                 if (!countElementsInTable('glpi_profilerights', "`profiles_id`='" . $data['profiles_id'] . "' \n                                            AND `name`='" . $rights['field'] . "'")) {
                     $profileRight = new ProfileRight();
                     $myright = array();
                     $myright['name'] = $rights['field'];
                     $myright['profiles_id'] = $data['profiles_id'];
                     if (!strcmp($data['plugin_geninventorynumber_generate'], 'w')) {
                         $myright['rights'] = CREATE;
                     }
                     if (!strcmp($data['plugin_geninventorynumber_overwrite'], 'w')) {
                         $myright['rights'] += UPDATE;
                     }
                     $profileRight->add($myright);
                 }
             }
         }
         $migration->dropTable($table);
     }
 }