コード例 #1
0
 public function applySnapshot($data, $dbVersion = null)
 {
     $iblockData = $this->handleNullValues($data['iblock']);
     $typeData = $this->handleNullValues($data['type']);
     $res = new ApplyResult();
     $type = new \CIBlockType();
     if (!\CIBlockType::GetByID($typeData['ID'])->Fetch()) {
         $res->setSuccess($type->Add($typeData));
     } else {
         $res->setSuccess($type->Update($typeData['ID'], $typeData));
     }
     if (!$res->isSuccess()) {
         return $res->setMessage($type->LAST_ERROR);
     }
     $extId = $iblockData['ID'];
     if ($dbVersion) {
         $id = $this->getCurrentVersionId($extId, $dbVersion);
     } else {
         $id = $extId;
     }
     if (!$dbVersion && !IblockTable::getById($id)->fetch()) {
         $addRes = IblockTable::add(array('ID' => $id, 'IBLOCK_TYPE_ID' => $typeData['ID'], 'NAME' => 'add'));
         if (!$addRes->isSuccess()) {
             throw new \Exception('add iblock error ' . implode(', ', $addRes->getErrorMessages()));
         }
     }
     $iblock = new \CIBlock();
     if ($id && ($currentData = IblockTable::getById($id)->fetch())) {
         $iblockData['PICTURE'] = $currentData['PICTURE'];
         $res->setSuccess((bool) $iblock->Update($id, $iblockData));
     } else {
         unset($iblockData['PICTURE']);
         $res->setSuccess((bool) ($id = $iblock->Add($iblockData)));
         $this->registerCurrentVersionId($id, $this->getReferenceValue($extId, $dbVersion));
     }
     $res->setId($id);
     return $res->setMessage($iblock->LAST_ERROR);
 }
コード例 #2
0
 /**
  * @param string $id
  * @param array $arFields
  *
  * @throws MigrationException
  */
 protected function updateIBlockType($id, array $arFields)
 {
     if (!$this->iBlockTypeGateway->Update($id, $arFields)) {
         throw new MigrationException($this->iBlockTypeGateway->LAST_ERROR);
     }
 }
コード例 #3
0
    }
    if (empty($arTypesToShow)) {
        $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
    } else {
        $arFilter["=ID"] = $arTypesToShow;
    }
}
// Editing handling (rights check should be done!)
if ($USER->IsAdmin() && $lAdmin->EditAction()) {
    foreach ($FIELDS as $ID => $arFields) {
        if (!$lAdmin->IsUpdated($ID)) {
            continue;
        }
        $DB->StartTransaction();
        $obBlocktype = new CIBlockType();
        $res = $obBlocktype->Update($ID, $arFields);
        if (!$res) {
            $lAdmin->AddUpdateError(GetMessage("IBLOCK_TYPE_ADMIN_ERR_SAVE") . " ("" . htmlspecialcharsbx($ID) . ""): " . $obBlocktype->LAST_ERROR, $ID);
            $DB->Rollback();
        }
        $DB->Commit();
    }
}
if ($USER->IsAdmin() && ($arID = $lAdmin->GroupAction())) {
    if ($_REQUEST['action_target'] == 'selected') {
        $rsData = CIBlockType::GetList($arOrder, $arFilter);
        while ($arRes = $rsData->Fetch()) {
            $arID[] = $arRes['ID'];
        }
    }
    foreach ($arID as $ID) {
コード例 #4
0
ファイル: types.php プロジェクト: spas-viktor/books
}
if (!CModule::IncludeModule("iblock")) {
    return;
}
COption::SetOptionString('iblock', 'use_htmledit', 'Y');
$arTypes = array(array("ID" => "photos", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 100, "LANG" => array()), array("ID" => "news", "SECTIONS" => "Y", "IN_RSS" => "Y", "SORT" => 200, "LANG" => array()), array("ID" => "services", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 300, "LANG" => array()), array("ID" => "photos", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 100, "LANG" => array()), array("ID" => "job", "SECTIONS" => "Y", "IN_RSS" => "N", "SORT" => 400, "LANG" => array()));
$arLanguages = array();
$rsLanguage = CLanguage::GetList($by, $order, array());
while ($arLanguage = $rsLanguage->Fetch()) {
    $arLanguages[] = $arLanguage["LID"];
}
$iblockType = new CIBlockType();
foreach ($arTypes as $arType) {
    $dbType = CIBlockType::GetList(array(), array("=ID" => $arType["ID"]));
    if ($dbType->Fetch()) {
        $iblockType->Update($arType["ID"], array("SECTIONS" => "Y"));
    } else {
        foreach ($arLanguages as $languageID) {
            WizardServices::IncludeServiceLang("type.php", $languageID);
            $code = strtoupper($arType["ID"]);
            $arType["LANG"][$languageID]["NAME"] = GetMessage($code . "_TYPE_NAME");
            $arType["LANG"][$languageID]["ELEMENT_NAME"] = GetMessage($code . "_ELEMENT_NAME");
            if ($arType["SECTIONS"] == "Y") {
                $arType["LANG"][$languageID]["SECTION_NAME"] = GetMessage($code . "_SECTION_NAME");
            }
        }
        $iblockType->Add($arType);
    }
}
?>
 
コード例 #5
0
ファイル: type.php プロジェクト: techart/bitrix.tao
 /**
  * @throws \TAOUpdateTypeException
  */
 protected static function updateType($data)
 {
     global $DB;
     $DB->StartTransaction();
     $o = new \CIBlockType();
     $res = $o->Update($data['ID'], $data);
     if (!$res) {
         $DB->Rollback();
         throw new \TAOUpdateTypeException("Error update type " . $data['ID']);
     } else {
         $DB->Commit();
     }
 }
コード例 #6
0
ファイル: Coded.php プロジェクト: marvin255/bxmigrate
 /**
  * @param string $name
  */
 protected function IblockTypeUpdate($data)
 {
     global $DB;
     if (empty(trim($data['ID']))) {
         throw new \Exception('You must set iblock type ID');
     }
     $name = trim($data['ID']);
     $res = \CIBlockType::GetList([], ['=ID' => $name]);
     if ($ob = $res->Fetch()) {
         $ib = new \CIBlockType();
         $DB->StartTransaction();
         $id = $ib->Update($ob['ID'], $data);
         if ($id) {
             $DB->Commit();
             echo "Update {$name} iblock type\r\n";
         } else {
             $DB->Rollback();
             throw new \Exception("Can't create {$name} iblock type");
         }
     } else {
         throw new \Exception("Iblock type don't exists");
     }
     return $id;
 }