function OnProductCatalogHandler($ID, $arFields)
{
    Bitrix\Main\Loader::includeModule('iblock');
    Bitrix\Main\Loader::includeModule('catalog');
    define('IBLOCK_ID_PRODUCTS', 2);
    define('IBLOCK_ID_OFFERS', 3);
    $query = new \Bitrix\Main\Entity\Query(Bitrix\Iblock\ElementTable::getEntity());
    $query->setSelect(array("ID", "IBLOCK_ID"))->setFilter(array("ID" => $ID))->setOrder(array("ID" => "ASC"));
    $resElement = $query->exec()->fetch();
    if ($resElement['IBLOCK_ID'] == IBLOCK_ID_PRODUCTS) {
        CIBlockElement::SetPropertyValuesEx($ID, $resElement['IBLOCK_ID'], array("AVAILABLE_QUANTITY_CATALOG" => $arFields['QUANTITY']));
    } elseif ($resElement['IBLOCK_ID'] == IBLOCK_ID_OFFERS) {
        //1
        $rsElementOffer = CIBlockElement::GetList(array(), array("ID" => $ID), false, false, array("ID", "IBLOCK_ID", 'NAME', "PROPERTY_CML2_LINK"))->fetch();
        $resElemOfferProduct = (int) $rsElementOffer['PROPERTY_CML2_LINK_VALUE'];
        //2
        $resOffersCML2 = CIBlockElement::GetList(array(), array("PROPERTY_CML2_LINK" => $resElemOfferProduct, 'IBLOCK_ID' => IBLOCK_ID_OFFERS), false, false, array("ID", "IBLOCK_ID", 'NAME'));
        //3
        $arrOffersIDs = array();
        while ($res = $resOffersCML2->fetch()) {
            $arrOffersIDs[] = $res['ID'];
        }
        //4
        $availQuant = array();
        foreach ($arrOffersIDs as $k => $v) {
            $ar_res_cat = CCatalogProduct::GetList(array("ID" => "DESC"), array("ID" => (int) $v), false, false, array("ID", "QUANTITY", 'ELEMENT_IBLOCK_ID', 'ELEMENT_NAME'))->fetch();
            $availQuant[] = $ar_res_cat['QUANTITY'];
        }
        //5
        $minAvailQuant = (int) min($availQuant);
        //6
        $resUpdateSCU = CIBlockElement::SetPropertyValuesEx($resElemOfferProduct, IBLOCK_ID_PRODUCTS, array("AVAILABLE_QUANTITY_CATALOG" => $minAvailQuant));
    }
}
예제 #2
0
파일: functions.php 프로젝트: kudin/crm
function trackStartedTask($stopStartedTask = true)
{
    CModule::IncludeModule('iblock');
    $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => TASKS_IBLOCK_ID, 'ACTIVE' => 'Y', "PROPERTY_PROGRAMMER" => CUser::GetID(), "PROPERTY_STATUS" => STATUS_LIST_WORK), false, false, array('ID', 'NAME', 'PROPERTY_PROJECT', 'PROPERTY_STATUS_DATE'));
    if ($taskArr = $res->Fetch()) {
        if ($stopStartedTask) {
            CIBlockElement::SetPropertyValuesEx($taskArr['ID'], TASKS_IBLOCK_ID, array('STATUS' => STATUS_LIST_PAUSE));
        }
        $link = TASKS_LIST_URL . $taskArr["PROPERTY_PROJECT_VALUE"] . '/' . $taskArr['ID'] . '/';
        $date = new DateTime($taskArr["PROPERTY_STATUS_DATE_VALUE"]);
        $curdate = new DateTime();
        $diff = $date->diff($curdate);
        $h = $diff->format('%h');
        $i = $diff->format('%i');
        if ($h || $i) {
            $timingText = '';
            if ($h) {
                $timingText = "{$h} ч, ";
            }
            if ($i) {
                $timingText = $timingText . "{$i} мин. ";
            }
            $decTime = $h + $i / 60;
            $decTime = round($decTime, 2);
            $el = new CIBlockElement();
            if ($el->Add(array("DATE_ACTIVE_FROM" => ConvertTimeStamp(time(), "SHORT"), "MODIFIED_BY" => CUser::GetID(), "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => TRACKING_IBLOCK_ID, "NAME" => 'Без названия' . ' (' . $decTime . 'ч.)', "ACTIVE" => "Y", "PROPERTY_VALUES" => array("HOURS" => $decTime, "TASK" => $taskArr['ID'])))) {
                crmEntitiesHelper::recalcTaskTracking($taskArr['ID']);
                ToolTip::Add("+ {$timingText} в трекер задачи \"<a target=\"_blank\" href=\"{$link}\">{$taskArr['ID']} {$taskArr['NAME']}</a>\"");
            } else {
                ToolTip::AddError($el->LAST_ERROR);
            }
        }
    }
}
예제 #3
0
 public static function updateIBlockProperty($ID, $TYPE, $arMessage, $arTopic = array())
 {
     if ($ID > 0 && $arMessage["PARAM1"] != "IB" && IsModuleInstalled("iblock")) {
         $arTopic = empty($arTopic) ? CForumTopic::GetByID($arMessage["TOPIC_ID"]) : $arTopic;
         if (!empty($arTopic) && $arTopic["XML_ID"] == "IBLOCK_" . $arMessage["PARAM2"] && CModule::IncludeModule("iblock")) {
             CIBlockElement::SetPropertyValuesEx($arMessage["PARAM2"], 0, array("FORUM_MESSAGE_CNT" => array("VALUE" => CForumMessage::GetList(array(), array("TOPIC_ID" => $arMessage["TOPIC_ID"], "APPROVED" => "Y", "!PARAM1" => "IB"), true), "DESCRIPTION" => "")));
         }
     }
 }
예제 #4
0
function reCalculateCommentsCnt($itemID)
{
    $res = CIBlockElement::GetList(array("DATE_CREATE" => "DESC"), array("PROPERTY_ITEM" => $itemID, "IBLOCK_ID" => COption::GetOptionString('comments', 'iblock'), "ACTIVE" => "Y"), false, false, array('ID', 'IBLOCK_ID'));
    while ($ar_fields = $res->GetNext()) {
        $n++;
        // ай пока что через пень-колоду
    }
    global $CACHE_MANAGER;
    $CACHE_MANAGER->ClearByTag('iblock_id_9');
    // абы што
    CIBlockElement::SetPropertyValuesEx($itemID, false, array('COMMNETS_CNT' => $n));
}
예제 #5
0
function UpdateBreedParent() {
	global $intBlockID, $USER, $intRootSection;
	$intAdvertID = intval($_REQUEST['advert_id']);
	$intParentMthID = intval($_REQUEST['parent_mth_id']);
	$intParentFthID = intval($_REQUEST['parent_fth_id']);
	
	if ($intAdvertID && ($intParentMthID || $intParentFthID)) {
		$objE = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $intBlockID, 'ID' => $intAdvertID, 'SECTION_ID' => $intRootSection, 'INCLUDE_SUBSECTIONS' => 'Y', 'ACTIVE' => 'Y'));
		if ($arrAdvertA = $objE->GetNext()) {
			if (intval($arrAdvertA['IBLOCK_SECTION_ID']) && ($arrAdvertA['CREATED_BY'] == $USER->GetID() || $USER->IsAdmin())) {
				// Проапдейтим родителей
				if ($intParentMthID) CIBlockElement::SetPropertyValuesEx($intParentMthID, false, array('BREED' => intval($arrAdvertA['IBLOCK_SECTION_ID'])));
				if ($intParentFthID) CIBlockElement::SetPropertyValuesEx($intParentFthID, false, array('BREED' => intval($arrAdvertA['IBLOCK_SECTION_ID'])));
			}//\\ if
		}//\\ if
	}//\\ if
}//\\UpdateBreedParent
예제 #6
0
     foreach ($arResult["PostToShow"]["GRATS"] as $arGrat) {
         if (ToLower($arGrat["XML_ID"]) == ToLower($_POST["GRAT_TYPE"])) {
             $arGratFromPOST = $arGrat;
             break;
         }
     }
     foreach ($_POST["GRAT"]["U"] as $code) {
         if (preg_match('/^U(\\d+)$/', $code, $matches)) {
             $arUsersFromPOST[] = $matches[1];
         }
     }
     if ($arGratFromPOST && $arUsersFromPOST) {
         $el = new CIBlockElement();
         $new_grat_element_id = $el->Add(array("IBLOCK_ID" => $honour_iblock_id, "DATE_ACTIVE_FROM" => ConvertTimeStamp(), "NAME" => str_replace("#GRAT_NAME#", $arGratFromPOST["VALUE"], GetMessage("BLOG_GRAT_IBLOCKELEMENT_NAME"))), false, false);
         if ($new_grat_element_id > 0) {
             CIBlockElement::SetPropertyValuesEx($new_grat_element_id, $honour_iblock_id, array("USERS" => $arUsersFromPOST, "GRATITUDE" => array("VALUE" => $arGratFromPOST["ID"])));
             CBlogPost::Update($newID, array("DETAIL_TEXT_TYPE" => "text", "UF_GRATITUDE" => $new_grat_element_id));
         }
     }
 }
 CBlogPostCategory::DeleteByPostID($newID);
 foreach ($CATEGORYtmp as $v) {
     CBlogPostCategory::Add(array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $newID, "CATEGORY_ID" => $v));
 }
 $DB->Query("UPDATE b_blog_image SET POST_ID=" . $newID . " WHERE BLOG_ID=" . $arBlog["ID"] . " AND POST_ID=0", true);
 $bHasImg = false;
 $bHasTag = false;
 $bHasProps = false;
 $bHasOnlyAll = false;
 if (!empty($CATEGORYtmp)) {
     $bHasTag = true;
예제 #7
0
 public static function updateIBlockProperty($ID, $TYPE, $arMessage)
 {
     if ($ID > 0 && $arMessage["PARAM1"] != "IB" && !empty($arMessage["PARAM2"]) && CModule::IncludeModule("iblock")) {
         CIBlockElement::SetPropertyValuesEx($arMessage["PARAM2"], 0, array("FORUM_MESSAGE_CNT" => array("VALUE" => CForumMessage::GetList(array(), array("TOPIC_ID" => $arMessage["TOPIC_ID"], "APPROVED" => "Y", "!PARAM1" => "IB"), true), "DESCRIPTION" => "")));
     }
 }
예제 #8
0
 /**
  * Insert database row
  *
  * @param $fields
  * @return mixed
  */
 protected function insertRow($fields)
 {
     $bxIb = new \CIBlockElement();
     $fields['IBLOCK_ID'] = $this->iblockId();
     $res = $bxIb->Add($fields);
     if (!$res) {
         throw new SaveException($bxIb->LAST_ERROR);
     }
     if ($this->fileProperties) {
         foreach ($this->fileProperties ?: array() as $propertyName) {
             $this->applyFilesToRow($propertyName, $fields[$propertyName], $res);
             unset($fields[$propertyName]);
         }
     }
     \CIBlockElement::SetPropertyValuesEx($res, $this->iblockId(), $fields);
     return $res;
 }
예제 #9
0
 function InviteGuests($ID, $arCalendarEvent, $arGuests, $arParams)
 {
     $arParams["prop"]["PARENT"] = $ID;
     $iblockId = $this->userIblockId;
     $userId = $arParams['userId'];
     $fullUrl = $arParams['fullUrl'];
     $pathToUserCalendar = $arParams['pathToUserCalendar'];
     $ownerName = $GLOBALS['USER']->GetFullName();
     $arGuestConfirm = array();
     $bExchange = CEventCalendar::IsExchangeEnabled() && $arParams['ownerType'] == 'USER';
     $loc = '';
     if (isset($arParams["prop"]["LOCATION"]) && strlen($arParams["prop"]["LOCATION"]) > 0) {
         $arLoc = CEventCalendar::ParseLocation($arParams["prop"]["LOCATION"]);
         if (!$arLoc['mrid'] || !$arLoc['mrevid']) {
             $loc = $arLoc['str'];
         } else {
             $MR = CEventCalendar::GetMeetingRoomById(array('RMiblockId' => $arParams['RMiblockId'], 'RMPath' => $arParams['RMPath'], 'id' => $arLoc['mrid'], 'VMiblockId' => $arParams['VMiblockId'], 'VMPath' => $arParams['VMPath'], 'VMPathDetail' => $arParams['VMPathDetail']));
             if ($MR) {
                 if ($arLoc['mrid'] == $arParams['VMiblockId'] && strlen($arParams['VMPath']) > 0) {
                     $url = (CMain::IsHTTPS() ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $arParams['VMPathDetail'];
                     $loc = "[url=" . str_replace(array("#id#", "#conf_id#"), array($arLoc['mrid'], $arLoc['mrevid']), $url) . "]" . $MR['NAME'] . "[/url]";
                 } elseif (strlen($arParams['RMPath']) > 0) {
                     $url = (CMain::IsHTTPS() ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $arParams['RMPath'];
                     $loc = "[url=" . str_replace("#id#", $arLoc['mrid'], $url) . "]" . $MR['NAME'] . "[/url]";
                 } else {
                     $loc = $MR['NAME'];
                 }
             }
         }
     }
     //Guests
     $arAllGuests = array();
     foreach ($arGuests as $guest_id) {
         $guest_id = intval($guest_id);
         if ($guest_id > 0) {
             $arAllGuests[$guest_id] = $guest_id;
         }
     }
     //Find old guests. For new event (or only owner) - it's empty array
     if ($arParams['bNew']) {
         $arOldGuests = array();
     } else {
         $arOldGuests = CECEvent::GetGuests($arParams['userIblockId'], $ID, array('bCheckOwner' => true, 'ownerType' => $arParams['ownerType'], 'bHostIsAbsent' => CECEvent::HostIsAbsent($arParams['iblockId'], $ID), 'DontReturnOnlyOwner' => true));
     }
     // Get guests
     $arParams["prop"]["PRIVATE"] = '';
     // Collect all new guests
     $arNewGuests = array();
     //And existing ones in order to update if event changed
     $arUpdGuests = array();
     foreach ($arAllGuests as $guest_id) {
         if (!array_key_exists($guest_id, $arOldGuests)) {
             $rsUser = CUser::GetList($o, $b, array("ID_EQUAL_EXACT" => $guest_id));
             $arUser = $rsUser->Fetch();
             if ($arUser) {
                 $arUser["FULL_NAME"] = CEventCalendar::GetFullUserName($arUser);
                 $arNewGuests[$guest_id] = $arUser;
             }
         } else {
             $arUpdGuests[$guest_id] = $arOldGuests[$guest_id];
         }
     }
     //Create child events for new guests
     foreach ($arNewGuests as $guest_id => $arGuest) {
         $guestSection = CEventCalendar::GetSectionIDByOwnerId($guest_id, 'USER', $iblockId);
         $guestCalendarId = false;
         $arGuestCalendars = array();
         $res = null;
         $bForOwner = false;
         if ($guest_id == $userId) {
             // it's owner
             if ($this->ownerType == 'USER') {
                 continue;
             }
             $bForOwner = true;
         }
         if (!$guestSection) {
             $guestSection = CEventCalendar::CreateSectionForOwner($guest_id, "USER", $iblockId);
         } else {
             //Section is out there
             //so we have chance to get guests calendar
             if ($this->bCache) {
                 $cachePath = $this->cachePath . $iblockId . "/calendars/" . $guest_id . "/4guests/";
                 $cacheId = 'g_' . $guestSection . '_' . $iblockId . '_' . $guest_id;
                 $cacheTime = 2592000;
                 // 1 month
                 $cache = new CPHPCache();
                 if ($cache->InitCache($cacheTime, $cacheId, $cachePath)) {
                     $res = $cache->GetVars();
                     $arGuestCalendars = $res['calendars'];
                 }
             }
             if (!$this->bCache || empty($res['calendars'])) {
                 $arGuestCalendars = $this->GetCalendars(array('sectionId' => $guestSection, 'iblockId' => $iblockId, 'ownerType' => 'USER', 'ownerId' => $guest_id, 'bOwner' => true, 'forExport' => true, 'bOnlyID' => true));
                 if ($this->bCache) {
                     $cache->StartDataCache($cacheTime, $cacheId, $cachePath);
                     $cache->EndDataCache(array("calendars" => $arGuestCalendars));
                 }
             }
             if (count($arGuestCalendars) > 0) {
                 $arUserSet = CEventCalendar::GetUserSettings(array('static' => true, 'userId' => $guest_id));
                 if ($arUserSet && isset($arUserSet['MeetCalId']) && in_array($arUserSet['MeetCalId'], $arGuestCalendars)) {
                     $guestCalendarId = intVal($arUserSet['MeetCalId']);
                 } else {
                     $guestCalendarId = $arGuestCalendars[0];
                 }
             }
         }
         $eventId = $this->SaveEvent(array('bOwner' => true, 'ownerType' => "USER", 'ownerId' => $guest_id, 'iblockId' => $iblockId, 'bNew' => true, 'name' => $arParams['name'], 'desc' => $arParams['desc'], 'calendarId' => $guestCalendarId, 'sectionId' => $guestSection, 'dateFrom' => $arParams["dateFrom"], 'dateTo' => $arParams["dateTo"], 'prop' => $arParams["prop"], "CONFIRMED" => $bForOwner ? 'Y' : 'Q', "notDisplayCalendar" => true, "bCheckPermissions" => false, 'isMeeting' => true));
         $arGuestConfirm[$guest_id] = $bForOwner ? 'Y' : 'Q';
         // Send message
         if (!$bForOwner) {
             CEventCalendar::SendInvitationMessage(array('type' => "invite", 'email' => $arGuest["EMAIL"], 'name' => $arParams['name'], "from" => $arParams["dateFrom"], "to" => $arParams["dateTo"], "location" => $loc, "pathToUserCalendar" => $pathToUserCalendar, "meetingText" => $arParams['meetingText'], "guestId" => $guest_id, "guestName" => $arGuest["FULL_NAME"], "userId" => $userId, "eventId" => $eventId, "ownerName" => $ownerName));
         }
     }
     //Delete child events if guest was deleted from the list
     $obElement = new CIBlockElement();
     $arDeletedUsers = array();
     foreach ($arOldGuests as $guest_id => $arOldEvent) {
         if ($guest_id == $userId) {
             continue;
         }
         if (!array_key_exists($guest_id, $arAllGuests)) {
             $res = CECEvent::Delete(array('id' => $arOldEvent["ID"], 'iblockId' => $iblockId, 'ownerType' => "USER", 'ownerId' => $guest_id, 'userId' => $userId, 'bJustDel' => true));
             if ($res !== true) {
                 return $this->ThrowError(strlen($res) > 0 ? $res : GetMessage('EC_EVENT_DEL_ERROR'));
             }
             $arDeletedUsers[] = $arOldEvent["ID"];
             if ($arOldEvent["PROPERTY_VALUES"]["CONFIRMED"] != "N") {
                 // Send message
                 CEventCalendar::SendInvitationMessage(array('type' => "cancel", 'email' => $arOldEvent["CREATED_BY"]["EMAIL"], 'name' => $arOldEvent['NAME'], "from" => $arOldEvent["ACTIVE_FROM"], "to" => $arOldEvent["ACTIVE_TO"], "desc" => $arOldEvent['DETAIL_TEXT'], "pathToUserCalendar" => $pathToUserCalendar, "guestId" => $guest_id, "guestName" => $arOldEvent["CREATED_BY"]["FULL_NAME"], "userId" => $userId, "ownerName" => $ownerName));
             }
         }
     }
     // Update info
     if (count($arUpdGuests) > 0) {
         $arCalendarEventProps = $arCalendarEvent["PROPERTY_VALUES"];
         unset($arCalendarEvent["PROPERTY_VALUES"]);
         //Check if we have to update child events
         foreach ($arUpdGuests as $guest_id => $arOldEvent) {
             if ($guest_id == $userId && $this->ownerType == 'USER') {
                 continue;
             }
             $bReinvite = false;
             $bCH_from = CEventCalendar::TrimTime($arOldEvent["ACTIVE_FROM"]) != CEventCalendar::TrimTime($arCalendarEvent["ACTIVE_FROM"]);
             $bCH_to = CEventCalendar::TrimTime($arOldEvent["ACTIVE_TO"]) != CEventCalendar::TrimTime($arCalendarEvent["ACTIVE_TO"]);
             $bTimeChanged = $bCH_from || $bCH_to;
             $bCH_name = $arOldEvent["NAME"] != $arCalendarEvent["NAME"];
             $bCH_desc = $arOldEvent["DETAIL_TEXT"] != $arCalendarEvent["DETAIL_TEXT"];
             $bFieldsChanged = $bCH_name || $bCH_desc;
             $bCH_loc = $arOldEvent["PROPERTY_VALUES"]["LOCATION"] != $arCalendarEventProps["LOCATION"];
             $bCH_repeat = $arOldEvent["PROPERTY_VALUES"]["PERIOD_TYPE"] != $arCalendarEventProps["PERIOD_TYPE"] || $arOldEvent["PROPERTY_VALUES"]["PERIOD_COUNT"] != $arCalendarEventProps["PERIOD_COUNT"] || $arOldEvent["PROPERTY_VALUES"]["EVENT_LENGTH"] != $arCalendarEventProps["EVENT_LENGTH"] || $arOldEvent["PROPERTY_VALUES"]["PERIOD_ADDITIONAL"] != $arCalendarEventProps["PERIOD_ADDITIONAL"];
             $bCH_imp = $arOldEvent["PROPERTY_VALUES"]["IMPORTANCE"] != $arCalendarEventProps["IMPORTANCE"];
             $bCH_meettxt = $arOldEvent["PROPERTY_VALUES"]["MEETING_TEXT"] != $arCalendarEventProps["MEETING_TEXT"]['VALUE']['TEXT'];
             $bPropertyChanged = $bCH_repeat || $bCH_loc || $bCH_meettxt || $bCH_imp;
             if (count($arParams['reinviteParamsList']) > 0) {
                 $bReinvite = in_array('name', $arParams['reinviteParamsList']) && $bCH_name;
                 if (!$bReinvite) {
                     $bReinvite = in_array('desc', $arParams['reinviteParamsList']) && $bCH_desc;
                 }
                 if (!$bReinvite) {
                     $bReinvite = in_array('from', $arParams['reinviteParamsList']) && $bCH_from;
                 }
                 if (!$bReinvite) {
                     $bReinvite = in_array('to', $arParams['reinviteParamsList']) && $bCH_to;
                 }
                 if (!$bReinvite) {
                     $bReinvite = in_array('location', $arParams['reinviteParamsList']) && $bCH_loc;
                 }
                 if (!$bReinvite) {
                     $bReinvite = in_array('guest_list', $arParams['reinviteParamsList']) && (count($arDeletedUsers) > 0 || count($arNewGuests) > 0);
                 }
                 if (!$bReinvite) {
                     $bReinvite = in_array('repeating', $arParams['reinviteParamsList']) && $bCH_repeat;
                 }
                 if (!$bReinvite) {
                     $bReinvite = in_array('importance', $arParams['reinviteParamsList']) && $bCH_imp;
                 }
                 if (!$bReinvite) {
                     $bReinvite = in_array('meet_text', $arParams['reinviteParamsList']) && $bCH_meettxt;
                 }
             }
             if ($bTimeChanged || $bFieldsChanged || $bPropertyChanged) {
                 if ($guest_id != $userId) {
                     if ($bReinvite) {
                         $arCalendarEventProps["CONFIRMED"] = CEventCalendar::GetConfirmedID($iblockId, "Q");
                         $arGuestConfirm[$guest_id] = 'Q';
                     }
                     $arFields = array("ACTIVE_FROM" => $arCalendarEvent["ACTIVE_FROM"], "ACTIVE_TO" => $arCalendarEvent["ACTIVE_TO"], "NAME" => $arCalendarEvent["NAME"], "DETAIL_TEXT" => $arCalendarEvent["DETAIL_TEXT"], "DETAIL_TEXT_TYPE" => 'html');
                     // If it's EXCHANGE - we try to save event to exchange
                     if ($bExchange) {
                         foreach ($arCalendarEventProps as $prKey => $prVal) {
                             $arFields["PROPERTY_" . $prKey] = $prVal;
                         }
                         $calendarXmlId = CECCalendar::GetExchangeXmlId($arOldEvent["IBLOCK_ID"], $arOldEvent['IBLOCK_SECTION_ID']);
                         if (strlen($calendarXmlId) > 0 && $calendarXmlId !== 0) {
                             $eventModLabel = CECEvent::GetExchModLabel($arOldEvent["IBLOCK_ID"], $arOldEvent["ID"]);
                             $eventXmlId = CECEvent::GetExchangeXmlId($arOldEvent["IBLOCK_ID"], $arOldEvent["ID"]);
                             $exchRes = CDavExchangeCalendar::DoUpdateItem($guest_id, $eventXmlId, $eventModLabel, $arFields);
                             if (!is_array($exchRes) || !array_key_exists("XML_ID", $exchRes)) {
                                 return CEventCalendar::ThrowError(CEventCalendar::CollectExchangeErros($exchRes));
                             }
                             // It's ok, we successfuly save event to exchange calendar - and save it to DB
                             $arFields['XML_ID'] = $exchRes['XML_ID'];
                             //$arFields['PROPERTY_VALUES']['BXDAVEX_LABEL'] = $exchRes['MODIFICATION_LABEL'];
                             $arCalendarEventProps['BXDAVEX_LABEL'] = $exchRes['MODIFICATION_LABEL'];
                         }
                     }
                     $obElement = new CIBlockElement();
                     $obElement->SetPropertyValuesEx($arOldEvent["ID"], $arOldEvent["IBLOCK_ID"], $arCalendarEventProps, array("DoNotValidateLists" => true));
                     if ($bTimeChanged || $bFieldsChanged) {
                         $obElement->Update($arOldEvent["ID"], $arFields, false);
                     }
                 }
                 // Send message
                 if ($guest_id != $userId) {
                     CEventCalendar::SendInvitationMessage(array('type' => "change", 'email' => $arOldEvent["CREATED_BY"]["EMAIL"], 'name' => $arOldEvent['NAME'], "from" => $arOldEvent["ACTIVE_FROM"], "to" => $arOldEvent["ACTIVE_TO"], "location" => $loc, "meetingText" => $arParams['meetingText'], "pathToUserCalendar" => $pathToUserCalendar, "guestId" => $guest_id, "guestName" => $arOldEvent["CREATED_BY"]["FULL_NAME"], "userId" => $userId, "eventId" => $arOldEvent["ID"], "ownerName" => $ownerName));
                 }
             }
         }
     }
     $this->ClearCache($this->cachePath . 'events/' . $iblockId . '/');
     return $arGuestConfirm;
 }
예제 #10
0
        if (!$bPermissions) {
            $lAdmin->AddGroupError(GetMessage("IBEL_A_UPDERR3") . " (ID:" . $ID . ")", $ID);
            continue;
        }

        switch ($_REQUEST['action']) {
            case "properties":
                $arUpdate = array();
                foreach($fields as $code => $field) {
                    if($_REQUEST[$code]) {
                        $arUpdate[$code] = $_REQUEST[$code];
                    }
                }  
                foreach ($props as $prop) {
                    if($_REQUEST['props'][$prop["ID"]]) { 
                        CIBlockElement::SetPropertyValuesEx($ID, $IBLOCK_ID, array($prop["ID"] => $_REQUEST['props'][$prop["ID"]]));
                    } 
                } 
                if($bCatalog && $_REQUEST['base_price_multiplier'] && isset($_REQUEST['base_price_add']) ) {
                            $arr = CPrice::GetBasePrice($ID);
                            $price = $arr["PRICE"];  
                            $price = $price * $_REQUEST['base_price_multiplier']; 
                            $price = $price + $_REQUEST['base_price_add'];
                            CPrice::SetBasePrice($ID, $price, $arr["CURRENCY"]); 
                        }
                if(count($arUpdate)) { 
                    $el = new CIBlockElement;  
                    $el->Update($ID, $arUpdate);
                }
                break;
            case "delete":
예제 #11
0
파일: class.php 프로젝트: ASDAFF/gpbitrix
/**
 * @param $id ID заказа
 * @param $val статус оплаты Y или N
 * функция после подтверждения оплаты
 * изменяет статус объявления на VIP
 */

function OnPayads($id,$val)
{
    // Если оплата Y
    if($val == 'Y')
    {
        //SendEmailPartnerByOrder($id, "SALE_ORDER_PAIDPARTNER");
        $dbBasketItems = CSaleBasket::GetList(
            array("PRICE" => "DESC"),
            array(
                "ORDER_ID" => $id
            ),
            false,
            false,
            array("ID", "NAME")
        );

        while ($arBasketItems = $dbBasketItems->Fetch())
        {

            $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arBasketItems["ID"]));
            if($arProp = $dbProp -> GetNext())
            {

                $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arBasketItems["ID"]));
                if($arProp = $dbProp -> GetNext())
                {

                    if($arProp['CODE']=='TEST_VIP'){
                        $status_true=true;
                        $ELEMENT_ID = intval($arProp['VALUE']);
                        $PROPERTY_CODE = "VIPORDERCHECK";
                        $PROPERTY_VALUE = "Y";
                        if (CModule::IncludeModule("iblock"))
                            CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, false, array($PROPERTY_CODE => $PROPERTY_VALUE));

                    }
                    if($arProp['CODE']=='TEST_ADSUP'){
                        $status_true=true;
                        $ELEMENT_ID = intval($arProp['VALUE']);
                        $PROPERTY_CODE = "ADSUP";
                        $PROPERTY_VALUE = "Y";
                        if (CModule::IncludeModule("iblock")){
                            //CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, false, array($PROPERTY_CODE => $PROPERTY_VALUE));
                            $el = new CIBlockElement;
                            $el->Update($ELEMENT_ID, Array('TIMESTAMP_X' => true,"ACTIVE_FROM"=>date("d.m.Y H:i:s")));
                        }

                    }
                }
            }
        }
        if($status_true){
            CSaleOrder::StatusOrder($id, "Y");
        }else{
            CSaleOrder::StatusOrder($id, "P");
        }


    }
}
예제 #12
0
                $rsPath = GetIBlockSectionPath($arFields["IBLOCK_ID"], $arFields["IBLOCK_SECTION_ID"]);
                while ($arPath = $rsPath->GetNext()) {
                    $arrPath[] = array("ID" => $arPath["ID"], "NAME" => $arPath["NAME"]);
                }
                $res = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], array(), array("ID" => $prop_id));
                $update = 0;
                $arRes = array();
                while ($arRes = $res->GetNext()) {
                    if ($arRes["VALUE"] != $arrPath[0]["NAME"]) {
                        $update = 1;
                    }
                }
                if ($update > 0) {
                    $arUpdateProps[$prop_id] = 2985;
                    if (count($arUpdateProps) > 0) {
                        CIBlockElement::SetPropertyValuesEx($arFields["ID"], $arFields["IBLOCK_ID"], $arUpdateProps);
                    }
                }
            }
        }
        $lastID = intval($arFields["ID"]);
    }
    $rsLeftBorder = CIBlockElement::GetList(array("ID" => "ASC"), array("IBLOCK_ID" => $BID, "<=ID" => $lastID));
    $leftBorderCnt = $rsLeftBorder->SelectedRowsCount();
    $rsAll = CIBlockElement::GetList(array("ID" => "ASC"), array("IBLOCK_ID" => $BID));
    $allCnt = $rsAll->SelectedRowsCount();
    $p = round(100 * $leftBorderCnt / $allCnt, 2);
    echo 'CurrentStatus = Array(' . $p . ',"' . ($p < 100 ? '&lastid=' . $lastID : '') . '","Обрабатываю запись с ID #' . $lastID . '");';
    die;
}
$clean_test_table = '<table id="result_table" cellpadding="0" cellspacing="0" border="0" width="100%" class="internal">' . '<tr class="heading">' . '<td>Текущее действие</td>' . '<td width="1%"> </td>' . '</tr>' . '</table>';
예제 #13
0
    $ibprop->Update($arProperty["THEME"], $arFields);
    if ($lang == 'ru') {
        $arThemeElement = array("277" => array("254", "253"), "256" => array("259", "258", "255"));
    } elseif ($lang == 'en') {
        $arThemeElement = array("161" => array("1", "8", "92"), "163" => array("169", "88", "89", "93"));
    } elseif ($lang == 'de') {
        $arThemeElement = array("161" => array("35", "88", "77"), "163" => array("38", "83", "82", "166"));
    }
    foreach ($arThemeElement as $ThemeID => $ThemeElements) {
        $rsElemetTheme = CIBlockElement::GetList(array("show_counter" => "desc"), array("XML_ID" => $ThemeID, "IBLOCK_ID" => $iblockIDTheme));
        if ($arElemetTheme = $rsElemetTheme->Fetch()) {
            $elementIDTheme = $arElemetTheme["ID"];
            foreach ($ThemeElements as $ElementID) {
                $rsElemet = CIBlockElement::GetList(array("show_counter" => "desc"), array("XML_ID" => $ElementID, "IBLOCK_ID" => $iblockID), false, false, array("ID"));
                if ($arElemet = $rsElemet->Fetch()) {
                    CIBlockElement::SetPropertyValuesEx($arElemet["ID"], $iblockID, array("THEME" => $elementIDTheme));
                }
            }
        }
    }
}
$arProperty = array();
$dbProperty = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $iblockID));
while ($arProp = $dbProperty->Fetch()) {
    $arProperty[$arProp["CODE"]] = $arProp["ID"];
}
WizardServices::IncludeServiceLang("news.php", $lang);
CUserOptions::SetOption("form", "form_element_" . $iblockID, array('tabs' => 'edit1--#--' . GetMessage("WZD_OPTION_NEWS_1") . '--,--ACTIVE_FROM--#--' . GetMessage("WZD_OPTION_NEWS_3") . '--,--NAME--#--' . GetMessage("WZD_OPTION_NEWS_5") . '--,--CODE--#--' . GetMessage("WZD_OPTION_NEWS_11") . '--,--PREVIEW_PICTURE--#--' . GetMessage("WZD_OPTION_NEWS_4") . '--,--PROPERTY_' . $arProperty['MAIN'] . '--#--' . GetMessage("WZD_OPTION_NEWS_9") . '--,--PROPERTY_' . $arProperty['PARTMAIN'] . '--#--' . GetMessage("WZD_OPTION_NEWS_8") . '--,--PROPERTY_' . $arProperty['LINK_SOURCE'] . '--#--' . GetMessage("WZD_OPTION_NEWS_6") . '--,--PROPERTY_' . $arProperty['THEME'] . '--#--' . GetMessage("WZD_OPTION_NEWS_7") . '--,--PREVIEW_TEXT--#--' . GetMessage("WZD_OPTION_NEWS_15") . '--,--DETAIL_TEXT--#--' . GetMessage("WZD_OPTION_NEWS_10") . '--,--SECTIONS--#--' . GetMessage("WZD_OPTION_NEWS_13") . '--;--'));
CUserOptions::SetOption("list", "tbl_iblock_list_" . md5($iblockType . "." . $iblockID), array('columns' => 'NAME,ACTIVE,DATE_ACTIVE_FROM', 'by' => 'timestamp_x', 'order' => 'desc', 'page_size' => '20'));
CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/news/index.php", array("NEWS_IBLOCK_ID" => $iblockID));
CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "/themes/index.php", array("NEWS_IBLOCK_ID" => $iblockID));
예제 #14
0
				CIBlockElement::SetPropertyValuesEx(intval($elementId), IBLOCK_CATALOGUE, array("C_TO_EDIT_FLAG" => 809));
				// Ответственный контент-менеджер
				CIBlockElement::SetPropertyValuesEx(intval($elementId), IBLOCK_CATALOGUE, array("C_MANAGER" => intval($_GET["set-content-manager"])));
				// Комментарий к доработкам
				CIBlockElement::SetPropertyValuesEx(intval($elementId), IBLOCK_CATALOGUE, array("C_COMMENT" => $_GET["to-edit-comment"]));
			}
			
			echo '<p class="success-text">Отправлено на редактирование позиций: '.count($_GET["check"]).'<br />Ответственный: '.$arUsersAll[$_GET["set-content-manager"]].'</p>';
		}
	}
	
	// Если кликнули Принять (снять галочку «на доработку»)
	if (isset($_GET["add-to-completed"]) && !empty($_GET["add-to-completed"]))
	{
		if (empty($_GET["check"]))
		{
			echo '<p class="warning-text">Необходимо выбрать позиции к принятию</p>';
		}
		else 
		{
			// Для каждого элеметна установим флаг отправки на редактирование и назначим ответственного
			foreach ($_GET["check"] as $elementId)
			{
				// Галочка на редактирование
				CIBlockElement::SetPropertyValuesEx(intval($elementId), IBLOCK_CATALOGUE, array("C_TO_EDIT_FLAG" => false));
			}
			
			echo '<p class="success-text">Принято позиций: '.count($_GET["check"]).'</p>';
		}
	}
?>
예제 #15
0
                $user = new CUser();
                $password = randString(7);
                $arFields = array("NAME" => $arFileds["first_name"], "LAST_NAME" => $arFileds["last_name"], "EMAIL" => $arFileds["email"], "LOGIN" => $arFileds["email"], "PERSONAL_BIRTHDAY" => str_replace("/", ".", $arFileds["birthday"]), "LID" => "ru", "ACTIVE" => "Y", "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password, "PERSONAL_PHOTO" => CFile::MakeFileArray("http://graph.facebook.com/" . $arFileds["id"] . "/picture?type=large"));
                $ID = $user->Add($arFields);
            }
        }
        // Тут пользователь должен быть полюбому
        // Авторизуем его
        $userRes = new CUser();
        $userRes->Authorize($ID);
    }
    //Получаем друзей пользователя Фэйсбука
    $fUrl = "https://graph.facebook.com/me/friends?access_token={$fb_token}";
    $fResponse = file_get_contents($fUrl);
    $FriendsData = json_decode($fResponse);
    $FriendsDataSerialized = serialize($FriendsData);
    $ob = CIBlockElement::GetList(array("SORT" => "ASC"), array("PROPERTY_USER" => $USER::GetId(), "IBLOCK_ID" => IB_USER_PROPS), FALSE, FALSE, array("ID", "PROPERTY_USER", "PROPERTY_LINK_NEWS", "PROPERTY_LINK_EVENT", "PROPERTY_LINK_STOK"))->Fetch();
    if ($ob) {
        CIBlockElement::SetPropertyValuesEx(intval($ob["ID"]), IB_USER_PROPS, array("TOKEN_FACEBOOK" => $fb_token, "FRIENDS_FACEBOOK" => $FriendsDataSerialized, "ID_FACEBOOK" => $arFileds["id"]));
        if ($_GET['r']) {
            $path = base64_decode($_GET['r']);
            header('Location: ' . $path);
            exit;
        }
    }
    LocalRedirect("/personal/");
}
if ($_GET['error']) {
    LocalRedirect($_SESSION['SOC_SERV_ATTACH_REDIRECT_PAGE']);
}
//LocalRedirect("/personal/safety/?vk=ok");
예제 #16
0
파일: init.php 프로젝트: kudin/crm
 public static function recalcTaskTime($taskId)
 {
     CModule::IncludeModule('iblock');
     $summ = 0;
     $arSelect = array("ID", "IBLOCK_ID", "PROPERTY_CALC");
     $arFilter = array("IBLOCK_ID" => TASKS_IBLOCK_ID, 'ACTIVE' => 'Y', 'ID' => $taskId);
     $res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
     if ($item = $res->GetNext()) {
         $summ += $item['PROPERTY_CALC_VALUE'];
         $commentres = CIBlockElement::GetList(array(), array("PROPERTY_TASK" => $taskId, "IBLOCK_ID" => COMMENTS_IBLOCK_ID, "ACTIVE" => "Y", "PROPERTY_STATUS" => STATUS_COMMENT_CONFIRM), false, false, array('ID', 'IBLOCK_ID', 'PROPERTY_STATUS', 'PROPERTY_CALC'));
         while ($comment = $commentres->GetNext()) {
             $summ += $comment['PROPERTY_CALC_VALUE'];
         }
         CIBlockElement::SetPropertyValuesEx($taskId, TASKS_IBLOCK_ID, array('CALC_COMMENTS' => $summ));
     }
     return $summ;
 }
         $arFields["VALUES"][] = array(
             "VALUE" => $value,
             "DEF" => "N",
             "SORT" => "100"
        );   
     } 
     $ibp = new CIBlockProperty;
     if(!$ibp->Update($PROPERTY_ID, $arFields)) { 
         ShowError($ibp->LAST_ERROR);
     } else {
         $db_enum_list = CIBlockProperty::GetPropertyEnum($PROPERTY_ID, Array(), Array("IBLOCK_ID" => $IBLOCK_ID));
         while($ar_enum_list = $db_enum_list->GetNext()) {
             $propNameToId[$ar_enum_list['VALUE']] = $ar_enum_list['ID'];
         }
         foreach($_SESSION['PROP_VALUES'] as $elementId => $value) {
             CIBlockElement::SetPropertyValuesEx($elementId, $IBLOCK_ID, array($PROPERTY_ID => $propNameToId[$value]));
         } 
     } 
     echo 'Готово'; 
     break;
 default: ?>
     <script>
         $(function () {
             $(document).on('change', '[name="IBLOCK_ID"]', function () {
                 var iblockSelect = $(this);
                 var propsSelect = $('[name=PROPERTY_ID]');
                 $.getJSON('/bitrix/tools/iblocktools/getiblockprops.php',
                         {iblock_id: iblockSelect.val()},
                         function (propsList) {
                             propsSelect.html('');
                             if (propsList != null) {
예제 #18
0
 public static function SetProperty($pkodadulo, $propname, $pvalue)
 {
     $spkodadulo = trim(strval($pkodadulo));
     $arFilter = array("IBLOCK_ID" => 82, "NAME" => $spkodadulo);
     $ibRes = CIBlockElement::GetList(array(), $arFilter);
     if ($ob = $ibRes->GetNextElement()) {
         $arFlds = $ob->GetFields();
         $curID = $arFlds["ID"];
         $ar = array($propname => $pvalue);
         CIBlockElement::SetPropertyValuesEx($curID, 82, $ar);
     }
 }
예제 #19
0
 * User:        Олег
 * Data:        11.06.12 22:56
 * Site: http://sForge.ru
 **/
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
$tableID = (int) $_POST["tableID"];
$name = $_POST["name"];
$count = (int) $_POST["count"];
$price_group = (int) $_POST["price_group"];
if (trim($name) == "" || $count == 0 || $price_group == 0) {
    die(json_encode(array("errors" => "ok")));
}
global $USER;
$userID = $USER->GetID();
$Club = Club::getOBonTheUserID($USER->GetID());
$table = $Club->table()->getInfo($tableID, array("arSelect" => array("PROPERTY_PRICE_GROUP")));
$el = new CIBlockElement();
$arLoadProductArray = array("MODIFIED_BY" => $USER->GetID(), "NAME" => trim($name));
if (intval($table["ID"]) > 0) {
    $res = $el->Update(intval($table["ID"]), $arLoadProductArray);
    CIBlockElement::SetPropertyValuesEx(intval($table["ID"]), IB_TABLE_ID, array("COUNT" => $count, "PRICE_GROUP" => $price_group));
} else {
    die(json_encode(array("errors" => "ok")));
}
if ($res) {
    //TODO нужно наверно написать отдельную функцию для получения ценовой группы
    $table = $Club->table()->getInfo($tableID, array("arSelect" => array("PROPERTY_PRICE_GROUP")));
    die(json_encode(array("message" => "ok", "table" => array("name" => trim($name), "count" => $count, "price_group" => $table['PROPERTY_PRICE_GROUP']["PROPERTY_PRICE_VALUE"]))));
}
die(json_encode(array("errors" => "ok")));
예제 #20
0
 protected function _Sync($arService, $row, &$arQueue)
 {
     $IBLOCK_ID = $arService['IBLOCK_ID'];
     if (!is_array($arQueue)) {
         $arQueue = array();
     }
     $arFields = array('IBLOCK_ID' => $IBLOCK_ID, 'XML_ID' => $row['UniqueId']);
     $arProperties = array();
     foreach ($arService['FIELDS'] as $fld) {
         $arValue = self::_SyncGetValueByType(array('FIELD' => $fld, 'VALUE' => $row[$fld['SP_FIELD']], 'ROW' => $row, 'SP_LIST_ID' => $arService['SP_LIST_ID']), $arQueue);
         if (null !== $arValue['VALUE']) {
             if ($arValue['PROPERTY']) {
                 $arProperties[$arValue['PROPERTY']] = $arValue['VALUE'];
             } else {
                 $arFields[$arValue['FIELD']] = $arValue['VALUE'];
             }
         }
     }
     $ib = new CIBlockElement();
     $dbRes = CIBlockElement::GetList(array('id' => 'asc'), array('IBLOCK_ID' => $IBLOCK_ID, 'XML_ID' => $arFields['XML_ID'], "CHECK_PERMISSIONS" => "N"), false, false, array('ID'));
     CIntranetSharepoint::$bUpdateInProgress = true;
     $bVersionConflict = false;
     if ($arRes = $dbRes->Fetch()) {
         $bNew = false;
         if (false && $arService['PRIORITY'] == 'B') {
             if ($version = CIntranetSharepointLog::ItemUpdated($IBLOCK_ID, $arRes['ID'])) {
                 if ($row['owshiddenversion'] > $version) {
                     $bVersionConflict = true;
                     // we won't allow changes from SP until pushing our changes onto it.
                     $ID = false;
                 }
             }
         }
         $arProperties['OWSHIDDENVERSION'] = intval($row['owshiddenversion']);
         if (!$bVersionConflict) {
             $ib->Update($ID = $arRes['ID'], $arFields);
             CIntranetSharepointLog::ItemUpdatedClear($IBLOCK_ID, $ID);
         }
     } else {
         $bNew = true;
         $ID = $ib->Add($arFields);
     }
     CIntranetSharepoint::$bUpdateInProgress = false;
     if (!$ID) {
         if (!$bVersionConflict) {
             $GLOBALS['APPLICATION']->ThrowException($ib->LAST_ERROR);
         }
     } else {
         if (count($arProperties) > 0) {
             CIBlockElement::SetPropertyValuesEx($ID, $IBLOCK_ID, $arProperties, $bNew ? array('NewElement' => true) : array());
         }
     }
     return $ID;
 }
예제 #21
0
파일: create.php 프로젝트: dayAlone/MyQube
     }
 }
 if ($_REQUEST['debug']) {
     var_dump($fields);
 }
 foreach ($fields as $key => $field) {
     $props[strtoupper($key)] = $field;
 }
 if ($fields['type'] && $fields['horizont'] && $fields['vertical']) {
     $number = getNumber($fields['horizont'], $fields['vertical']);
     $props['NUMBER'] = $number;
     $src = $_SERVER["DOCUMENT_ROOT"] . '/group/u_creative/images/email/' . $fields['type'] . '/' . $fields['type'] . '_design_dev_' . $fields['horizont'] . '_' . $fields['vertical'] . '.jpg';
     $raw = new CIBlockElement();
     $raw->Update($current['ID'], array('PREVIEW_PICTURE' => CFile::MakeFileArray($src)));
 }
 CIBlockElement::SetPropertyValuesEx($current['ID'], false, $props);
 if ($fields['email'] && $fields['phone'] && $fields['address']) {
     // Для отладки
     //CIBlockElement::Delete($ID);
     $raw = new CIBlockElement();
     $raw->Update($current['ID'], array("IBLOCK_SECTION_ID" => $sections['success']));
     $str = date("d.m.Y H:i:s") . ";" . $ID . ";" . $number . ";" . $fields['size'] . ";" . $fields['type'] . ";" . $USER->GetFullName() . ";+7" . preg_replace('/[^0-9]/', '', $fields['phone']) . ";доставка;" . $fields['address'] . ";new;\n";
     $dir = $_SERVER["DOCUMENT_ROOT"] . '/group/u_creative/orders/';
     $file = $dir . $ID . '.csv';
     // Письмо менеджеру
     if (!file_exists($dir)) {
         mkdir($dir, 0777);
     }
     file_put_contents($file, $str);
     $mail = new PHPMailer();
     $mail->isHTML(true);
예제 #22
0
    $arFilter = array("IBLOCK_CODE" => "color_theme", "CODE" => "template_color_theme");
    $res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
    while ($ob = $res->GetNextElement()) {
        $arFields = $ob->GetFields();
        $element_id = $arFields['ID'];
        $iblock_id = $arFields['IBLOCK_ID'];
        $arProps = $ob->GetProperties();
    }
    $property_enums = CIBlockPropertyEnum::GetList(array("DEF" => "DESC", "SORT" => "ASC"), array("IBLOCK_ID" => $iblock_id, "CODE" => "COLOR"));
    while ($enum_fields = $property_enums->GetNext()) {
        if ($enum_fields['XML_ID'] == $_POST['template_color_theme']) {
            $property_enum_id = intval($enum_fields['ID']);
        }
    }
    if ($element_id > 0 && $property_enum_id > 0) {
        CIBlockElement::SetPropertyValuesEx($element_id, false, array('COLOR' => $property_enum_id));
    }
}
$arSelect = array("ID", "IBLOCK_ID", "NAME", "PROPERTY_COLOR");
$arFilter = array("IBLOCK_CODE" => "color_theme", "CODE" => "template_color_theme");
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
while ($ob = $res->GetNextElement()) {
    $arProps = $ob->GetProperties();
}
if (strlen($arProps['COLOR']['VALUE_XML_ID']) > 0) {
    $template_color_theme = $arProps['COLOR']['VALUE_XML_ID'];
}
if (isset($template_color_theme) && strlen($template_color_theme) > 0) {
    switch ($template_color_theme) {
        case 'red':
            ?>
예제 #23
0
파일: ajax.php 프로젝트: vladimir1593/test1
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
if (!CModule::IncludeModule("iblock") || !$USER->IsAuthorized()) {
    exit;
}
global $USER;
$elId = intval($_REQUEST['id']);
$userId = $USER->GetID();
$iblockId = CIBlockElement::GetIBlockByID($elId);
if ($elId > 0) {
    $db_props = CIBlockElement::GetProperty($iblockId, $elId, array("id" => "asc"), array("CODE" => "LIKE"));
    $propLikeValue = array();
    while ($prop = $db_props->GetNext()) {
        $propLikeValue[] = $prop['VALUE'];
    }
    $key = array_search($userId, $propLikeValue);
    if ($key !== false) {
        unset($propLikeValue[$key]);
        echo 0;
    } else {
        $propLikeValue[] = $userId;
        echo 1;
    }
    if (count($propLikeValue) <= 0) {
        $propLikeValue = '';
    }
    CIBlockElement::SetPropertyValuesEx($elId, $iblockId, array('LIKE' => $propLikeValue));
}
예제 #24
0
                         $arRes[$i] = '';
                     }
                 }
                 if ($arIBlockProperty[$cur_prop_id]["MULTIPLE"] == "Y") {
                     if (!isset($arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id]) || !is_array($arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id]) || !in_array(trim($arRes[$i]), $arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id])) {
                         $arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id][] = is_array($arRes[$i]) ? $arRes[$i] : trim($arRes[$i]);
                     }
                     $PROP[$cur_prop_id] = $arIBlockPropertyValue[$PRODUCT_ID][$cur_prop_id];
                 } else {
                     $PROP[$cur_prop_id][] = is_array($arRes[$i]) ? $arRes[$i] : trim($arRes[$i]);
                 }
             }
         }
     }
     if (!empty($PROP)) {
         CIBlockElement::SetPropertyValuesEx($PRODUCT_ID, $IBLOCK_ID, $PROP);
         \Bitrix\Iblock\PropertyIndex\Manager::updateElementIndex($IBLOCK_ID, $PRODUCT_ID);
     }
 }
 if ('' == $strErrorR && $bIBlockIsCatalog) {
     $arLoadOfferArray = array("ID" => $PRODUCT_ID);
     foreach ($arAvailPriceFields_names as $key => $value) {
         $ind = -1;
         for ($i_tmp = 0; $i_tmp < $NUM_FIELDS; $i_tmp++) {
             if (${"field_" . $i_tmp} == $key) {
                 $ind = $i_tmp;
                 break;
             }
         }
         if ($ind > -1) {
             $arLoadOfferArray[$value["field"]] = trim($arRes[$ind]);
예제 #25
0
                 $arProperties["vote_sum"] = array("VALUE" => 0);
             }
         }
         if ($res && !array_key_exists("rating", $arProperties)) {
             $res = $obProperty->Add(array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => "rating", "CODE" => "rating"));
             if ($res) {
                 $arProperties["rating"] = array("VALUE" => 0);
             }
         }
         if ($res) {
             $arProperties["vote_count"]["VALUE"] = intval($arProperties["vote_count"]["VALUE"]) + 1;
             $arProperties["vote_sum"]["VALUE"] = intval($arProperties["vote_sum"]["VALUE"]) + $RATING;
             //rating = (SUM(vote)+31.25) / (COUNT(*)+10)
             $arProperties["rating"]["VALUE"] = round(($arProperties["vote_sum"]["VALUE"] + 31.25 / 5 * $arParams["MAX_VOTE"]) / ($arProperties["vote_count"]["VALUE"] + 10), 2);
             $DB->StartTransaction();
             CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, $arParams["IBLOCK_ID"], array("vote_count" => array("VALUE" => $arProperties["vote_count"]["VALUE"], "DESCRIPTION" => $arProperties["vote_count"]["DESCRIPTION"]), "vote_sum" => array("VALUE" => $arProperties["vote_sum"]["VALUE"], "DESCRIPTION" => $arProperties["vote_sum"]["DESCRIPTION"]), "rating" => array("VALUE" => $arProperties["rating"]["VALUE"], "DESCRIPTION" => $arProperties["rating"]["DESCRIPTION"])));
             $DB->Commit();
             $this->ClearResultCache(array($USER->GetGroups(), 1));
             $this->ClearResultCache(array($USER->GetGroups(), 0));
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $arParams["IBLOCK_ID"]);
             }
         }
     }
 }
 //27*
 //Нам нет необходимости делать редирект для обновления данных
 //в аякс режиме
 //да и не приведет это ни к чему
 if ($_REQUEST["AJAX_CALL"] != "Y") {
     LocalRedirect(!empty($_REQUEST["back_page"]) ? $_REQUEST["back_page"] : $APPLICATION->GetCurPageParam());
예제 #26
0
 public function UpdateDocument($documentId, $arFields)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
     $arFieldsPropertyValues = array();
     $dbResult = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"), false, false, array("ID", "IBLOCK_ID"));
     $arResult = $dbResult->Fetch();
     if (!$arResult) {
         throw new Exception("Element is not found");
     }
     $arDocumentFields = self::GetDocumentFields("iblock_" . $arResult["IBLOCK_ID"]);
     $arKeys = array_keys($arFields);
     foreach ($arKeys as $key) {
         if (!array_key_exists($key, $arDocumentFields)) {
             continue;
         }
         $arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
         if ($arDocumentFields[$key]["Type"] == "user") {
             $ar = array();
             foreach ($arFields[$key] as $v1) {
                 if (substr($v1, 0, strlen("user_")) == "user_") {
                     $ar[] = substr($v1, strlen("user_"));
                 } else {
                     $a1 = self::GetUsersFromUserGroup($v1, $documentId);
                     foreach ($a1 as $a11) {
                         $ar[] = $a11;
                     }
                 }
             }
             $arFields[$key] = $ar;
         } elseif ($arDocumentFields[$key]["Type"] == "select") {
             $realKey = substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_" ? substr($key, strlen("PROPERTY_")) : $key;
             $arV = array();
             $db = CIBlockProperty::GetPropertyEnum($realKey, false, array("IBLOCK_ID" => $arResult["IBLOCK_ID"]));
             while ($ar = $db->GetNext()) {
                 $arV[$ar["XML_ID"]] = $ar["ID"];
             }
             foreach ($arFields[$key] as &$value) {
                 if (array_key_exists($value, $arV)) {
                     $value = $arV[$value];
                 }
             }
         } elseif ($arDocumentFields[$key]["Type"] == "file") {
             foreach ($arFields[$key] as &$value) {
                 $value = CFile::MakeFileArray($value);
             }
         } elseif ($arDocumentFields[$key]["Type"] == "S:HTML") {
             foreach ($arFields[$key] as &$value) {
                 $value = array("VALUE" => $value);
             }
         }
         if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
             if (count($arFields[$key]) > 0) {
                 $a = array_values($arFields[$key]);
                 $arFields[$key] = $a[0];
             } else {
                 $arFields[$key] = null;
             }
         }
         if (substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_") {
             $realKey = substr($key, strlen("PROPERTY_"));
             $arFieldsPropertyValues[$realKey] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
             unset($arFields[$key]);
         }
     }
     if (count($arFieldsPropertyValues) > 0) {
         $arFields["PROPERTY_VALUES"] = $arFieldsPropertyValues;
     }
     $iblockElement = new CIBlockElement();
     if (count($arFields["PROPERTY_VALUES"]) > 0) {
         $iblockElement->SetPropertyValuesEx($documentId, $arResult["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]);
     }
     unset($arFields["PROPERTY_VALUES"]);
     $res = $iblockElement->Update($documentId, $arFields, false, true, true);
     if (!$res) {
         throw new Exception($iblockElement->LAST_ERROR);
     }
 }
예제 #27
0
 /**
  * @param int $iblockID
  * @param int $elementID
  * @param int|string $propCode
  * @param int $action
  * @param string $description
  * @throws RequestError
  * @return bool
  */
 public function saveToIBProp($iblockID, $elementID, $propCode, $action = self::F_IB_IMG_PROP_APPEND, $description = '')
 {
     if (true !== $this->_bRequestSuccess && true !== $this->_bDownloadSuccess) {
         return false;
     }
     $arProp = array();
     $arErr = array();
     if (is_numeric($propCode)) {
         $propID = intval($propCode);
         $propCode = Tools::getPropCodeById($iblockID, $propID, $arProp, $arErr);
         if ($propCode === false) {
             throw new RequestError('', RequestError::E_BX_FILE_PROP_NOT_FOUND);
         }
     } else {
         $propID = Tools::getPropIdByCode($iblockID, $propCode, $arProp, $arErr);
         if ($propID === false) {
             throw new RequestError('', RequestError::E_BX_FILE_PROP_NOT_FOUND);
         }
     }
     if ($arProp['PROPERTY_TYPE'] != 'F') {
         throw new RequestError('', RequestError::E_BX_FILE_PROP_WRONG_TYPE);
     }
     if ($this->_ID === null) {
         $this->_ID = static::generateID();
     }
     if (!CheckDirPath(OBX_DOC_ROOT . static::DOWNLOAD_FOLDER . '/' . $this->_ID)) {
         throw new RequestError('', RequestError::E_PERM_DENIED);
     }
     $downloadFileRelPath = $this->getDownloadFilePath(false);
     if ($this->_bDownloadSuccess) {
         $arFile = \CFile::MakeFileArray($downloadFileRelPath);
     } elseif ($this->_bRequestSuccess) {
         $this->saveToFile($downloadFileRelPath);
         $arFile = \CFile::MakeFileArray($downloadFileRelPath);
     }
     $arFile['name'] = $this->_originalName . '.' . $this->_originalExt;
     if (is_string($description) && !empty($description)) {
         $arFile['description'] = $description;
     }
     switch ($action) {
         case self::F_IB_IMG_PROP_REPLACE:
             \CIBlockElement::SetPropertyValuesEx($elementID, $iblockID, array($arProp['ID'] => $arFile));
             break;
         case self::F_IB_IMG_PROP_APPEND:
             \CIBlockElement::SetPropertyValues($elementID, $iblockID, $arFile, $arProp['ID']);
             break;
     }
     return true;
 }
예제 #28
0
 public function saveToIBProp($iblockID, $elementID, $propCode, $action = self::F_IB_IMG_PROP_APPEND)
 {
     if (true !== $this->_bRequestsComplete && true !== $this->_bDownloadsComplete) {
         return false;
     }
     $arProp = array();
     $arErr = array();
     if (is_numeric($propCode)) {
         $propID = intval($propCode);
         $propCode = Tools::getPropCodeById($iblockID, $propID, $arProp, $arErr);
         if ($propCode === false) {
             return false;
         }
     } else {
         $propID = Tools::getPropIdByCode($iblockID, $propCode, $arProp, $arErr);
         if ($propID === false) {
             return false;
         }
     }
     if (!empty($arErr)) {
         return false;
     }
     if ($arProp['PROPERTY_TYPE'] != 'F') {
         return false;
     }
     if ($arProp['MULTIPLE'] != 'Y') {
         return false;
     }
     $arFileList = array();
     /** @var Request $Request */
     foreach ($this->_arRequestList as $Request) {
         if ($Request->isDownloadSuccess()) {
             $downloadFileRelPath = $Request->getDownloadFilePath(false);
             $arFile = \CFile::MakeFileArray($downloadFileRelPath);
             if (!empty($arFile)) {
                 $arFileList[] = $arFile;
             }
         }
     }
     if (!empty($arFileList)) {
         switch ($action) {
             case self::F_IB_IMG_PROP_REPLACE:
                 \CIBlockElement::SetPropertyValuesEx($elementID, $iblockID, array($arProp['ID'] => $arFileList));
                 break;
             case self::F_IB_IMG_PROP_APPEND:
                 \CIBlockElement::SetPropertyValues($elementID, $iblockID, $arFileList, $arProp['ID']);
                 break;
         }
     }
     return true;
 }
예제 #29
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule("iblock");
$arLoadProductArray = array("READ" => 1);
$m = intval(str_replace("friend_comment_", "", $_GET["id"]));
CIBlockElement::SetPropertyValuesEx($m, 12, $arLoadProductArray);
예제 #30
-1
                if (!$lastId) {
                    throw new Exception($iblockElement->LAST_ERROR);
                }
            }
            $property = new CIBlockProperty();
            $property->Update($idProperty, array('LINK_IBLOCK_ID' => $handbookIblockId));
            break;
    }
    $iblockElement = new CIBlockElement();
    $valuesToElements = array();
    foreach ($propertyValues as $propertyValue) {
        $variantIdId = $list[$propertyValue['value']];
        $valuesToElements[$propertyValue['id_element']][] = $variantIdId;
    }
    foreach ($valuesToElements as $elementId => $elementValues) {
        $iblockElement->SetPropertyValuesEx($elementId, $idIBlock, array($idProperty => $elementValues));
    }
    return true;
};
if ($_POST['apply'] == 'Применить') {
    $iblockID = intval($_POST['selectIblocks']);
    $propertyID = intval($_POST['selectProperties']);
    $newTypeIBlock = $_POST['new-type-property-info-block'];
    $conversionResult = $conversionProperty($propertyID, $iblockID, $newTypeIBlock);
    $conversionResult && CAdminNotify::Add(array('MESSAGE' => 'Конвертация прошла успешно', 'TAG' => 'save_property_notify', 'MODULE_ID' => 'ws.tools', 'ENABLE_CLOSE' => 'Y'));
    !$conversionResult && CAdminNotify::Error(array('MESSAGE' => 'Конвертация не прошла успешно', 'TAG' => 'save_property_notify_error', 'MODULE_ID' => 'ws.tools', 'ENABLE_CLOSE' => 'Y'));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$jsParams = array();
$types = array();
$rsTypes = \Bitrix\Iblock\TypeLanguageTable::getList(array('filter' => array('LANGUAGE_ID' => LANG)));