"Fossies" - the Fresh Open Source Software Archive

Member "4.6.1/db/migrations/101_step00246_blubber.php" (8 Apr 2021, 5131 Bytes) of package /linux/www/studip-4.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 
    3 class Step00246Blubber extends Migration
    4 {
    5 
    6 
    7     function description()
    8     {
    9         return 'install Blubber as core-plugin';
   10     }
   11 
   12     function up()
   13     {
   14         $db = DBManager::get();
   15         $db->exec("
   16             CREATE TABLE IF NOT EXISTS `blubber` (
   17                 `topic_id` varchar(32) NOT NULL DEFAULT '',
   18                 `parent_id` varchar(32) NOT NULL DEFAULT '',
   19                 `root_id` varchar(32) NOT NULL DEFAULT '',
   20                 `context_type` enum('public','private','course') NOT NULL DEFAULT 'public',
   21                 `name` varchar(255) DEFAULT NULL,
   22                 `description` text,
   23                 `mkdate` int(20) NOT NULL DEFAULT '0',
   24                 `chdate` int(20) NOT NULL DEFAULT '0',
   25                 `author_host` varchar(255) DEFAULT NULL,
   26                 `Seminar_id` varchar(32) NOT NULL DEFAULT '',
   27                 `user_id` varchar(32) NOT NULL DEFAULT '',
   28                 `external_contact` tinyint(4) NOT NULL DEFAULT '0',
   29                 PRIMARY KEY (`topic_id`),
   30                 KEY `root_id` (`root_id`),
   31                 KEY `Seminar_id` (`Seminar_id`),
   32                 KEY `parent_id` (`parent_id`),
   33                 KEY `chdate` (`chdate`),
   34                 KEY `mkdate` (`mkdate`),
   35                 KEY `user_id` (`user_id`,`Seminar_id`)
   36             ) ENGINE=MyISAM;
   37         ");
   38         //Spezialevents, bisher nur für Löschen von Beiträgen verwendet
   39         $db->exec("
   40             CREATE TABLE IF NOT EXISTS `blubber_events_queue` (
   41                 `event_type` varchar(32) NOT NULL,
   42                 `item_id` varchar(32) NOT NULL,
   43                 `mkdate` int(11) NOT NULL,
   44                 PRIMARY KEY (`event_type`,`item_id`,`mkdate`),
   45                 KEY `item_id` (`item_id`)
   46             ) ENGINE=MyISAM
   47         ");
   48         //Blubberautoren, die nicht in Stud.IP angemeldet sind wie anonyme
   49         $db->exec("
   50             CREATE TABLE IF NOT EXISTS `blubber_external_contact` (
   51                 `external_contact_id` varchar(32) NOT NULL,
   52                 `mail_identifier` varchar(256) DEFAULT NULL,
   53                 `contact_type` varchar(16) NOT NULL DEFAULT 'anonymous',
   54                 `name` varchar(256) NOT NULL,
   55                 `data` text,
   56                 `chdate` bigint(20) NOT NULL,
   57                 `mkdate` bigint(20) NOT NULL,
   58                 PRIMARY KEY (`external_contact_id`),
   59                 KEY `mail_identifier` (`mail_identifier`),
   60                 KEY `contact_type` (`contact_type`)
   61             ) ENGINE=MyISAM
   62         ");
   63         $db->exec("
   64             CREATE TABLE IF NOT EXISTS `blubber_follower` (
   65                 `studip_user_id` varchar(32) NOT NULL,
   66                 `external_contact_id` varchar(32) NOT NULL,
   67                 `left_follows_right` tinyint(1) NOT NULL,
   68                 KEY `studip_user_id` (`studip_user_id`),
   69                 KEY `external_contact_id` (`external_contact_id`)
   70             ) ENGINE=MyISAM
   71         ");
   72         //Rechte für private Blubber
   73         $db->exec("
   74             CREATE TABLE IF NOT EXISTS `blubber_mentions` (
   75                 `topic_id` varchar(32) NOT NULL,
   76                 `user_id` varchar(32) NOT NULL,
   77                 `external_contact` tinyint(4) NOT NULL DEFAULT '0',
   78                 `mkdate` int(11) NOT NULL,
   79                 UNIQUE KEY `unique_users_per_topic` (`topic_id`,`user_id`,`external_contact`),
   80                 KEY `topic_id` (`topic_id`),
   81                 KEY `user_id` (`user_id`)
   82             ) ENGINE=MyISAM
   83         ");
   84 
   85         $old_blubber = $db->query(
   86             "SELECT * FROM plugins WHERE pluginclassname = 'Blubber' " .
   87         "")->fetch(PDO::FETCH_ASSOC);
   88         
   89         if ($old_blubber) {
   90             //Umschreiben des Ortes von Blubber
   91             $db->exec("
   92                 UPDATE plugins SET pluginpath = 'core/Blubber' WHERE pluginclassname = 'Blubber'
   93             ");
   94             if ($old_blubber['pluginpath'] !== "core/Blubber") {
   95                 @rmdirr($GLOBALS['PLUGINS_PATH']."/".$old_blubber['pluginpath']);
   96             }
   97             $db->exec("
   98                 INSERT IGNORE INTO blubber (`topic_id`,`parent_id`,`root_id`,`context_type`,`name`,`description`,`mkdate`,`chdate`,`author_host`,`Seminar_id`,`user_id`,`external_contact`)
   99                     SELECT `topic_id`,`parent_id`,`root_id`,'course',`name`,`description`,`mkdate`,`chdate`,`author_host`,`Seminar_id`,`user_id`,0
  100                     FROM px_topics
  101             ");
  102         } else {
  103             //Installieren des Plugins
  104             $db->exec("
  105                 INSERT INTO plugins
  106                 SET pluginclassname = 'Blubber',
  107                     pluginpath = 'core/Blubber',
  108                     pluginname = 'Blubber',
  109                     plugintype = 'StandardPlugin,SystemPlugin',
  110                     enabled = 'yes',
  111                     navigationpos = '1'
  112             ");
  113             $plugin_id = $db->lastInsertId();
  114             $db->exec("
  115                 INSERT IGNORE INTO roles_plugins (roleid, pluginid)
  116                     SELECT roleid, ".$db->quote($plugin_id)." FROM roles WHERE system = 'y'
  117             ");
  118         }
  119     }
  120 
  121     function down()
  122     {
  123     }
  124 }