/**
  * Handle database upgrade for the published field in tl_metamodel_dcasetting.
  *
  * Introduced: version 1.0.1
  *
  * If the field 'published' does not exist in tl_metamodel_dcasetting,
  * it will get created and all rows within that table will get initialized to 1
  * to have the prior behaviour back (everything was being published before then).
  *
  * @return void
  */
 protected static function upgradeDcaSettingsPublished()
 {
     $objDB = self::DB();
     if (!$objDB->fieldExists('published', 'tl_metamodel_dcasetting', true)) {
         // create the column in the database and copy the data over.
         MetaModelTableManipulation::createColumn('tl_metamodel_dcasetting', 'published', 'char(1) NOT NULL default \'\'');
         // Publish everything we had so far.
         $objDB->execute('UPDATE tl_metamodel_dcasetting SET published=1;');
     }
 }
示例#2
0
 /**
  * called by tl_metamodel.tableName onsave_callback.
  * prefixes the table name with mm_ if not provided by the user as such.
  * Checks if the table name is legal to the DB.
  *
  * @param string        $strTableName the table name for the table.
  * @param DataContainer $objDC        the DataContainer which called us.
  *
  * @return string the table name $strTableName.
  */
 public function tableNameOnSaveCallback($strTableName, DC_General $objDC)
 {
     // See #49
     $strTableName = strtolower($strTableName);
     // force mm_ prefix.
     if (substr($strTableName, 0, 3) !== 'mm_') {
         $strTableName = 'mm_' . $strTableName;
     }
     MetaModelTableManipulation::checkTablename($strTableName);
     return $strTableName;
 }
 /**
  * Renames the underlying database structure for this field.
  *
  * @param string $strNewColumnName The new column name.
  *
  * @return void
  */
 public function renameColumn($strNewColumnName)
 {
     MetaModelTableManipulation::checkColumnName($strNewColumnName);
     if ($this->getColName() && Database::getInstance()->fieldExists($this->getColName(), $this->getMetaModel()->getTableName(), true)) {
         MetaModelTableManipulation::renameColumn($this->getMetaModel()->getTableName(), $this->getColName(), $strNewColumnName, $this->getSQLDataType());
     } else {
         $strBackupColName = $this->getColName();
         $this->set('colname', $strNewColumnName);
         $this->createColumn();
         $this->set('colname', $strBackupColName);
     }
 }