/**
  * Function migrate profiles custom fields;
  * 
  * @return : (string) operation result;
  */
 function getMigration()
 {
     // set new status;
     $this->setResultStatus('Profiles custom fields transfer now');
     mysql_query('SET NAMES utf8', $this->rOldDb);
     //-- get old table structure --//
     $sQuery = "DESCRIBE `Profiles`";
     $rResult = mysql_query($sQuery, $this->rOldDb);
     while ($aRow = mysql_fetch_assoc($rResult)) {
         $this->aOldProfileTable[$aRow['Field']] = array('Type' => $aRow['Type'], 'Null' => $aRow['Null'], 'Key' => $aRow['Key'], 'Default' => $aRow['Default'], 'Extra' => $aRow['Extra']);
     }
     //--
     //-- get new table structure --//
     $sQuery = "DESCRIBE `Profiles`";
     $aRow = $this->oMigrationModule->_oDb->getAll($sQuery);
     foreach ($aRow as $iKey => $aItems) {
         $this->aNewProfileTable[$aItems['Field']] = array('Type' => $aItems['Type'], 'Null' => $aItems['Null'], 'Key' => $aItems['Key'], 'Default' => $aItems['Default'], 'Extra' => $aItems['Extra']);
     }
     //--
     //-- compare the recived array --//
     foreach ($this->aOldProfileTable as $sKey => $aItems) {
         if (array_key_exists($sKey, $this->aNewProfileTable) || in_array($sKey, $this->aFiltered)) {
             unset($this->aOldProfileTable[$sKey]);
         }
     }
     //--
     //-- alter new table --//
     foreach ($this->aOldProfileTable as $sKey => $aItems) {
         // define dafault value;
         $sDefault = $aItems['Default'] ? "DEFAULT '{$aItems['Default']}'" : '';
         $sNull = $aItems['Null'] == 'NO' ? 'NOT NULL' : '';
         $sQuery = "\r\n               \t\tALTER TABLE `Profiles` ADD `{$sKey}` {$aItems['Type']} {$sNull} {$sDefault}\r\n               ";
         // add new field
         $this->oMigrationModule->_oDb->query($sQuery);
         // transfer  into sys_profile_fields
         $this->_transferProfileFields($sKey);
         // transfer  into sys_pre_values
         $this->_transferPreValues($sKey);
         $this->iTransffered++;
     }
     //--
     //-- transfer all data --//
     $this->_transformData();
     //--
     //-- Recompile all needed cache files --//
     bx_import('BxDolInstallerUtils');
     $oInstallerUtils = new BxDolInstallerUtils();
     $oInstallerUtils->updateProfileFieldsHtml();
     $oCacher = new BxDolPFMCacher();
     $oCacher->createCache();
     $this->compilePreValues();
     //--
     // set as finished;
     $this->setResultStatus('All profiles custom fields were transferred (' . $this->iTransffered . ' items)');
     return MIGRATION_SUCCESSFUL;
 }
function createNewItem()
{
    $oFields = new MlClonetwoPSFM(1);
    $iNewID = $oFields->createNewField();
    bx_import('BxDolInstallerUtils');
    $oInstallerUtils = new BxDolInstallerUtils();
    $oInstallerUtils->updateProfileFieldsHtml();
    header('Content-Type:text/javascript');
    echo '{id:' . $iNewID . '}';
}
Exemple #3
0
function deleteItem($iItemID, $iAreaID)
{
    $oFields = new BxDolPFM($iAreaID);
    $oFields->deleteItem($iItemID);
    bx_import('BxDolInstallerUtils');
    $oInstallerUtils = new BxDolInstallerUtils();
    $oInstallerUtils->updateProfileFieldsHtml();
    $oCacher = new BxDolPFMCacher();
    $oCacher->createCache();
}