function deleteItem($iItemID, $iAreaID) { $oFields = new BxDolPFM($iAreaID); $oFields->deleteItem($iItemID); $oCacher = new BxDolPFMCacher(); $oCacher->createCache(); }
/** * 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 loadCache($bCycle = true) { if (!file_exists($this->sCacheFile) or !($sCache = file_get_contents($this->sCacheFile)) or !($this->aCache = eval($sCache)) or !is_array($this->aCache)) { $oPFM = new BxDolPFMCacher(); if (!$oPFM->createCache()) { return false; } if ($bCycle) { //to prevent cycling return $this->loadCache(false); } else { return false; } } $this->aArea = $this->aCache[$this->iAreaID]; //load blocks $this->aBlocks = $this->aArea; //get mutual fields $this->_getCoupleMutualFields(); return true; }
function loadCache($bCycle = true) { $oCache = $GLOBALS['MySQL']->getDbCacheObject(); $this->aCache = $oCache->getData($GLOBALS['MySQL']->genDbCacheKey('sys_profile_fields')); if (null === $this->aCache || !is_array($this->aCache)) { $oPFM = new BxDolPFMCacher(); if (!$oPFM->createCache()) { return false; } if ($bCycle) { return $this->loadCache(false); } else { return false; } } $this->aArea = $this->aCache[$this->iAreaID]; //load blocks $this->aBlocks = $this->aArea; //get mutual fields $this->_getCoupleMutualFields(); return true; }
function setSearchEndAge($iMax) { if ($iMax <= 0) { return false; } $GLOBALS['MySQL']->query("update `sys_profile_fields` set `Max` = {$iMax} where `Name` = 'DateOfBirth'"); require_once BX_DIRECTORY_PATH_CLASSES . 'BxDolPFM.php'; $oCacher = new BxDolPFMCacher(); $oCacher->createCache(); return true; }
function actionRecompileProfileFields($bInstall = true) { ob_start(); $oBxDolPFMCacher = new BxDolPFMCacher(); $bResult = $oBxDolPFMCacher->createCache(); ob_get_clean(); return $bResult ? BX_DOL_INSTALLER_SUCCESS : BX_DOL_INSTALLER_FAILED; }
function deleteItem($iItemID, $iAreaID) { $oFields = new BxDolPFM($iAreaID); $oFields->deleteItem($iItemID); bx_import('BxDolInstallerUtils'); $oInstallerUtils = new BxDolInstallerUtils(); $oInstallerUtils->updateProfileFieldsHtml(); $oCacher = new BxDolPFMCacher(); $oCacher->createCache(); }