Ejemplo n.º 1
0
 /**
  * Invert field logic for given table (tl_user or tl_user_group)
  * @param   string
  */
 private function invertElements($strTable)
 {
     if ($this->Database->fieldExists('contentelements', $strTable) && !$this->Database->fieldExists('elements', $strTable)) {
         // Add the new field to the database table
         $this->Database->query("ALTER TABLE {$strTable} ADD COLUMN elements blob NULL");
         $objResult = $this->Database->execute("SELECT id, contentelements FROM {$strTable} WHERE contentelements!=''");
         while ($objResult->next()) {
             $arrElements = deserialize($objResult->contentelements);
             if (!empty($arrElements) && is_array($arrElements)) {
                 $arrElements = array_diff(CeAccess::getContentElements(), $arrElements);
                 $this->Database->prepare("UPDATE {$strTable} SET elements=? WHERE id=?")->execute(serialize($arrElements), $objResult->id);
             }
         }
         // Delete old field to make sure the runonce is not executed again
         $this->Database->execute("ALTER TABLE {$strTable} DROP contentelements");
         $this->log('Inverted access logic for content elements in ' . $strTable, __METHOD__, TL_ACCESS);
     }
 }