public function install()
 {
     $status = array();
     // Create database field table
     $status[] = Symphony::Database()->query("CREATE TABLE `tbl_fields_dynamictextgroup` (\n\t\t\t\t\t`id` int(11) unsigned NOT NULL auto_increment,\n\t\t\t\t\t`field_id` int(11) unsigned NOT NULL,\n\t\t\t\t\t`fieldcount` tinyint(1),\n\t\t\t\t\t`schema` varchar(255),\n        \t  \t\tPRIMARY KEY  (`id`),\n\t\t\t  \t\tKEY `field_id` (`field_id`)\n\t\t\t\t)");
     // Create stage
     $status[] = Stage::install();
     // Report status
     if (in_array(false, $status, true)) {
         return false;
     } else {
         return true;
     }
 }
Пример #2
0
 /**
  * @see http://symphony-cms.com/learn/api/2.2/toolkit/extension/#update
  */
 public function update($previousVersion)
 {
     $status = array();
     // Prior version 2.0
     if (version_compare($previousVersion, '2.0', '<')) {
         // Update existing entries
         $fields = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` from `tbl_fields_datetime`");
         foreach ($fields as $field) {
             // New database schema
             $status[] = Symphony::Database()->query("ALTER TABLE `tbl_entries_data_{$field}`\n\t\t\t\t\t\t MODIFY `start` datetime NOT NULL,\n\t\t\t\t\t\t MODIFY `end` datetime NOT NULL");
             // Don't allow empty end dates
             $status[] = Symphony::Database()->query("UPDATE `tbl_entries_data_{$field}`\n\t\t\t\t\t\t SET `end` = `start`\n\t\t\t\t\t\t WHERE `end` = 'none'\n\t\t\t\t\t\t OR `end` = '0000-00-00 00:00'");
         }
         // Get table columns
         $columns = Symphony::Database()->fetchCol('Field', "SHOW COLUMNS FROM `tbl_fields_datetime`");
         // Remove allow multiple setting
         if (in_array('allow_multiple_dates', $columns)) {
             $status[] = Symphony::Database()->query("ALTER TABLE `tbl_fields_datetime` DROP `allow_multiple_dates`");
         }
         // Add time setting
         if (!in_array('time', $columns)) {
             $status[] = Symphony::Database()->query("ALTER TABLE `tbl_fields_datetime` ADD `time` tinyint(1) DEFAULT '1'");
         }
         // Add range setting
         if (!in_array('range', $columns)) {
             $status[] = Symphony::Database()->query("ALTER TABLE `tbl_fields_datetime` ADD `range` tinyint(1) DEFAULT '1'");
         }
         // Modify prepopulation setting
         $status[] = Symphony::Database()->query("ALTER TABLE `tbl_fields_datetime` MODIFY `prepopulate` tinyint(1) DEFAULT '1'");
         // Correctly store old 'no' values
         $status[] = Symphony::Database()->query("UPDATE tbl_fields_datetime\n\t\t\t\t\t SET `prepopulate` = 0 WHERE `prepopulate` > 1");
         // Create stage
         $status[] = Stage::install();
     }
     // Prior version 2.4
     if (version_compare($previousVersion, '2.4', '<')) {
         // Move language codes to configuration
         Symphony::Configuration()->set('english', $this->languages['english'], 'datetime');
         Symphony::Configuration()->set('german', $this->languages['german'], 'datetime');
         Administration::instance()->saveConfig();
     }
     // Report status
     if (in_array(false, $status, true)) {
         return false;
     } else {
         return true;
     }
 }