Example #1
0
 function payload()
 {
     $root = new CXMLCreator("soap:Envelope");
     $root->setAttribute("xmlns:soap", BX_SOAP_ENV);
     $root->setAttribute(BX_SOAP_XSI_PREFIX, BX_SOAP_SCHEMA_INSTANCE);
     $root->setAttribute(BX_SOAP_XSD_PREFIX, BX_SOAP_SCHEMA_DATA);
     $root->setAttribute(BX_SOAP_ENC_PREFIX, BX_SOAP_ENC);
     $header = new CXMLCreator("soap:Header");
     $root->addChild($header);
     foreach ($this->Headers as $hx) {
         $header->addChild($hx);
     }
     // add the body
     $body = new CXMLCreator("soap:Body");
     foreach ($this->BodyAttributes as $attribute => $value) {
         $body->setAttribute($attribute, $value);
     }
     // add the request
     $request = new CXMLCreator($this->Name);
     $request->setAttribute("xmlns", $this->Namespace);
     // add the request parameters
     $param = null;
     foreach ($this->Parameters as $parameter => $value) {
         unset($param);
         $param = CXMLCreator::encodeValueLight($parameter, $value);
         if ($param == false) {
             ShowError("Error enconding data for payload");
         }
         $request->addChild($param);
     }
     $body->addChild($request);
     $root->addChild($body);
     return CXMLCreator::getXMLHeader() . $root->getXML();
 }
 function ShowRawResponse($valueEncoded, $wrapEnvelope = false)
 {
     global $APPLICATION;
     if ($wrapEnvelope) {
         // $valueEncoded class of CXMLCreator
         $root = new CXMLCreator("soap:Envelope");
         $root->setAttribute("xmlns:soap", BX_SOAP_ENV);
         // add the body
         $body = new CXMLCreator("soap:Body");
         $body->addChild($valueEncoded);
         $root->addChild($body);
         $valueEncoded = $root;
     }
     $payload = CXMLCreator::getXMLHeader() . $valueEncoded->getXML();
     header("SOAPServer: BITRIX SOAP");
     header("Content-Type: text/xml; charset=\"UTF-8\"");
     Header("Content-Length: " . (defined('BX_UTF') && BX_UTF == 1 && function_exists('mb_strlen') ? mb_strlen($payload, 'latin1') : strlen($payload)));
     $APPLICATION->RestartBuffer();
     $this->RawPayloadData = $payload;
     echo $payload;
 }
Example #3
0
 function payload()
 {
     $root = new CXMLCreator("soap:Envelope");
     $root->setAttribute("xmlns:soap", BX_SOAP_ENV);
     // add the body
     $body = new CXMLCreator("soap:Body");
     // Check if it's a fault
     if (is_object($this->Value) && ToUpper(get_class($this->Value)) == 'CSOAPFAULT') {
         $fault = new CXMLCreator("soap:Fault");
         $faultCodeNode = new CXMLCreator("faultcode");
         $faultCodeNode->setData($this->Value->faultCode());
         $fault->addChild($faultCodeNode);
         $faultStringNode = new CXMLCreator("faultstring");
         $faultStringNode->setData($this->Value->faultString());
         $fault->addChild($faultStringNode);
         if ($this->Value->detail) {
             $fault->addChild($this->Value->detail());
         }
         $body->addChild($fault);
     } else {
         // add the request
         $responseName = $this->Name . "Response";
         $response = new CXMLCreator($responseName);
         $response->setAttribute("xmlns", $this->Namespace);
         if (!isset($this->typensVars[$this->Name]["output"]) or !count($this->typensVars[$this->Name]["output"])) {
             if (count($this->typensVars)) {
                 $GLOBALS['APPLICATION']->ThrowException("payload() can't find output type declaration.", "SoapRespnose::payload()");
                 return;
             } else {
                 //print_r($this->Value);
                 //die();
                 // EncodeLight
                 $value = CXMLCreator::encodeValueLight($this->ValueName, $this->Value);
             }
             $response->addChild($value);
         } else {
             //$return = new CXMLCreator($returnType);
             $valueEncoder = new CSOAPCodec();
             $valueEncoder->setTypensVars($this->typensVars);
             foreach ($this->typensVars[$this->Name]["output"] as $returnType => $returnParam) {
                 if (!$returnType) {
                     $GLOBALS['APPLICATION']->ThrowException("payload() can't find output type declaration for {$this->Name}.", "SoapRespnose::payload()");
                     return;
                 }
                 $valueEncoder->setOutputVars($this->Name);
                 $value = $valueEncoder->encodeValue($returnType, isset($this->Value[$returnType]) ? $this->Value[$returnType] : $this->Value);
                 $response->addChild($value);
             }
             //AddM
         }
         $body->addChild($response);
     }
     $root->addChild($body);
     //AddMessage2Log($root->getXML());
     return CXMLCreator::getXMLHeader() . $root->getXML();
 }
Example #4
0
	public function UpdateListItems($listName, $updates)
	{
		global $USER;

		$arStatusValues = array_flip($this->arStatusValues);
		$arPriorityValues = array_flip($this->arPriorityValues);

		if (!$listName_original = CIntranetUtils::checkGUID($listName))
			return new CSoapFault('Data error', 'Wrong GUID - '.$listName);

		$obResponse = new CXMLCreator('Results');

		$listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
		$arSections = CCalendarSect::GetList(array('arFilter' => array('XML_ID' => $listName_original)));
		if (!$arSections || !is_array($arSections[0]))
			return new CSoapFault(
				'List not found',
				'List with '.$listName.' GUID not found'
			);
		$arSection = $arSections[0];

		$bGroup = $arSection['CAL_TYPE'] == 'group';
		$calType = $arSection['CAL_TYPE'];
		$ownerId = $arSection['OWNER_ID'];

		if ($bGroup)
		{
			CModule::IncludeModule('socialnetwork');
			$arGroupTmp = CSocNetGroup::GetByID($arSection['SOCNET_GROUP_ID']);
			if ($arGroupTmp["CLOSED"] == "Y")
				if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y")
					return new CSoapFault('Cannot modify archive group calendar', 'Cannot modify archive group calendar');
		}

		$obBatch = $updates->children[0];
		$atrONERROR = $obBatch->getAttribute('OnError');
		$atrDATEINUTC = $obBatch->getAttribute('DateInUtc');
		$atrPROPERTIES = $obBatch->getAttribute('Properties');

		$arChanges = $obBatch->children;

		$arResultIDs = array();
		$dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL');
		$arResponseRows = array();
		$arReplicationIDs = array();
		$userId = (is_object($USER) && $USER->GetID()) ? $USER->GetID() : 1;

		foreach ($arChanges as $obMethod)
		{
			$arData = array('_command' => $obMethod->getAttribute('Cmd'));

			foreach ($obMethod->children as $obField)
			{
				$name = $obField->getAttribute('Name');
				if ($name == 'MetaInfo')
					$name .= '_'.$obField->getAttribute('Property');

				$arData[$name] = $obField->content;
			}

			if ($arData['_command'] == 'Delete')
			{
				$obRes = new CXMLCreator('Result');
				$obRes->setAttribute('ID', $obMethod->getAttribute('ID').','.$arData['_command']);
				$obRes->setAttribute('List', $listName);
				$obRes->addChild($obNode = new CXMLCreator('ErrorCode'));

				$res = CCalendar::DeleteEvent($arData['ID']);
				if ($res === true)
					$obNode->setData('0x00000000');
				else
					$obNode->setData('0x81020014');

				/*
					0x00000000 - ok
					0x81020015 - data conflict
					0x81020014 - generic error such as invalid value for Field
					0x81020016 - item does not exist
				*/

				$obResponse->addChild($obRes);
			}
			elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update')
			{
				$q = ToLower($arData['Description']);
				if (($pos = strrpos($q, '</body>')) !== false) $arData['Description'] = substr($arData['Description'], 0, $pos);
				if (($pos = strpos($q, '<body>')) !== false) $arData['Description'] = substr($arData['Description'], $pos + 6);

				$arData['Description'] = str_replace('</DIV>', "\r\n</DIV>", $arData['Description']);
				$arData['Description'] = str_replace(array("&#10;", "&#13;"), "", $arData['Description']);
				$arData['Description'] = preg_replace("/<![^>]*>/", '', $arData['Description']);
				//$arData['Description'] = strip_tags($arData['Description']);
				$arData['Description'] = trim($arData['Description']);

				$arData['Location'] = trim($arData['Location']);

				if (isset($arData['EventDate']))
				{
					$arData['EventDate'] = $this->__makeTS($arData['EventDate']);
					$arData['EndDate'] = $this->__makeTS($arData['EndDate']) + ($arData['fAllDayEvent'] ? -86340 : 0);
					$TZBias = intval(date('Z', $arData['EventDate']));
				}

				$arData['EventType'] = intval($arData['EventType']);

				if ($arData['EventType'] == 2)
					$arData['EventType'] = 0;

				if ($arData['EventType'] > 2 /* || ($arData['EventType'] == 1 && !$arData['RecurrenceData'])*/)
					return new CSoapFault(
						'Unsupported event type',
						'Event type unsupported'
					);

				$arData['fRecurrence'] = intval($arData['fRecurrence']);
				$arData['RRULE'] = '';

				$id = $arData['_command'] == 'New' ? 0 : intVal($arData['ID']);
				if ($arData['RecurrenceData'])
				{
					//$xmlstr = $arData['XMLTZone'];
					//$arData['XMLTZone'] = new CDataXML();
					//$arData['XMLTZone']->LoadString($xmlstr);

					$xmlstr = $arData['RecurrenceData'];
					$obRecurData = new CDataXML();
					$obRecurData->LoadString($xmlstr);

/*
<recurrence>
		<rule>
			<firstDayOfWeek>mo</firstDayOfWeek>
			<repeat>
				<weekly mo='TRUE' tu='TRUE' th='TRUE' sa='TRUE' weekFrequency='1' />
			</repeat>
			<repeatForever>FALSE</repeatForever>
		</rule>
</recurrence>
<deleteExceptions>true</deleteExceptions>
*/

					$obRecurRule = $obRecurData->tree->children[0]->children[0];
					$obRecurRepeat = $obRecurRule->children[1];
					$obNode = $obRecurRepeat->children[0];

					$arData['RRULE'] = array();
					switch($obNode->name)
					{
						case 'daily':
							// hack. we have no "work days" daily recurence
							if ($obNode->getAttribute('weekday') == 'TRUE')
							{
								$arData['RRULE']['FREQ'] = 'WEEKLY';
								$arData['RRULE']['BYDAY'] = 'MO,TU,WE,TH,FR';
								$arData['RRULE']['INTERVAL'] = 1;
							}
							else
							{
								$arData['RRULE']['FREQ'] = 'DAILY';
								$arData['RRULE']['INTERVAL'] = $obNode->getAttribute('dayFrequency');
							}

							$time_end = strtotime(
								date(date('Y-m-d', $arData['EventDate']).' H:i:s', $arData['EndDate'])
							);

							$arData['DT_LENGTH'] = $time_end - $arData['EventDate'];
						break;

						case 'weekly':
							$arData['RRULE']['FREQ'] = 'WEEKLY';
							$arData['RRULE']['BYDAY'] = '';

							$arWeekDays = array('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su');
							foreach ($arWeekDays as $day => $value)
							{
								if ($obNode->getAttribute($value))
									$arData['RRULE']['BYDAY'][] = strtoupper($value);
							}

							$arData['RRULE']['BYDAY'] = implode(',', $arData['RRULE']['BYDAY']);
							$arData['RRULE']['INTERVAL'] = $obNode->getAttribute('weekFrequency');

							$time_end = strtotime(date(date('Y-m-d', $arData['EventDate']).' H:i:s', $arData['EndDate']));

							$arData['DT_LENGTH'] = $time_end - $arData['EventDate'];
						break;

						case 'monthly':
							$arData['RRULE']['FREQ'] = 'MONTHLY';
							$arData['RRULE']['INTERVAL'] = $obNode->getAttribute('monthFrequency');
							$time_end = strtotime(date(date('Y-m', $arData['EventDate']).'-d H:i:s', $arData['EndDate']));

							$arData['DT_LENGTH'] = $time_end - $arData['EventDate'];
						break;

						case 'yearly':
							$arData['RRULE']['FREQ'] = 'YEARLY';
							$arData['RRULE']['INTERVAL'] = $obNode->getAttribute('yearFrequency');

							$time_end = strtotime(date(date('Y', $arData['EventDate']).'-m-d H:i:s', $arData['EndDate']));

							$arData['DT_LENGTH'] = $time_end - $arData['EventDate'];
						break;
					}

					if ($arData['DT_LENGTH'] == 0 && isset($arData['RRULE']['FREQ']))
						$arData['DT_LENGTH'] = 86400;

					$obWhile = $obRecurRule->children[2];
					if ($obWhile->name == 'repeatForever')
					{
						$arData['EndDate'] = MakeTimeStamp('');
					}
					elseif ($obWhile->name == 'windowEnd')
					{
						$arData['EndDate'] = $this->__makeTS($obWhile->textContent());
						$arData['RRULE']['UNTIL'] = ConvertTimeStamp($arData['EndDate'], 'FULL');
					}
				}
				elseif($arData['fRecurrence'] == -1 && $id > 0)
				{
					$arData['RRULE'] = -1;
				}

				if (isset($arData['EventDate']))
				{
					$skipTime = $arData['fAllDayEvent'] ? 'Y' : 'N';
					$TZBias = $arData['fAllDayEvent'] ? 0 : $TZBias;
					$arData['EventDate'] += $TZBias;
					$arData['EndDate'] += $TZBias;

//					$arData["DT_FROM"] = ConvertTimeStamp($arData['EventDate'], 'FULL');
//					$arData["DT_TO"] = ConvertTimeStamp($arData['EndDate'], 'FULL');
				}
				else
				{
					$arData["DT_FROM"] = -1;
					$arData["DT_TO"] = -1;
				}

				// fields
				$arFields = array(
					"ID" => $id,
					'CAL_TYPE' => $calType,
					'OWNER_ID' => $ownerId,
					'CREATED_BY' => $userId,
					'DT_FROM_TS' => $arData['EventDate'],
					'DT_TO_TS' => $arData['EndDate'],
					'DT_SKIP_TIME' => $skipTime,
//					"DT_FROM" => $arData["DT_FROM"],
//					"DT_TO" => $arData["DT_TO"],
					'NAME' => $arData['Title'],
					'DESCRIPTION' => CCalendar::ParseHTMLToBB($arData['Description']),
					'SECTIONS' => array($arSection['ID']),
					'ACCESSIBILITY' => $arStatusValues[$arData['MetaInfo_BusyStatus']],
					'IMPORTANCE' => $arPriorityValues[$arData['MetaInfo_Priority']],
					'RRULE' => $arData['RRULE'],
					'LOCATION' => CCalendar::UnParseTextLocation($arData['Location'])
				);

				if (isset($arData['DT_LENGTH']) && $arData['DT_LENGTH'] > 0)
					$arFields['DT_LENGTH'] = $arData['DT_LENGTH'];

				$EventID = CCalendar::SaveEvent(
					array(
						'arFields' => $arFields,
						'fromWebservice' => true
					)
				);

				if ($EventID)
				{
					// dirty hack
					$arReplicationIDs[$EventID] = $arData['MetaInfo_ReplicationID'];

					$arResponseRows[$EventID] = new CXMLCreator('Result');
					$arResponseRows[$EventID]->setAttribute('ID', $obMethod->getAttribute('ID').','.$arData['_command']);
					$arResponseRows[$EventID]->setAttribute('List', $listName);

					$arResponseRows[$EventID]->addChild($obNode = new CXMLCreator('ErrorCode'));
					$obNode->setData('0x00000000');
					//$arResponseRows[$EventID]->setAttribute('Version', 3);
				}
			}
		}

		$userId = (is_object($USER) && $USER->GetID()) ? $USER->GetID() : 1;
		$fetchMeetings = CCalendar::GetMeetingSection($userId) == $arSection['ID'];
		$arEvents = CCalendarEvent::GetList(
			array(
				'arFilter' => array(
					'CAL_TYPE' => $calType,
					'OWNER_ID' => $ownerId,
					'SECTION' => $arSection['ID'],
					//'INCLUDE_INVITINGS' => 'N'
				),
				'getUserfields' => false,
				'parseRecursion' => false,
				'fetchAttendees' => false,
				'fetchMeetings' => $fetchMeetings,
				'userId' => $userId
			)
		);

		foreach ($arEvents as $key => $event)
		{
			if ($arResponseRows[$event['ID']])
			{
				$obRow = $this->__getRow($event, $listName, $last_change = 0);
				$obRow->setAttribute('xmlns:z', "#RowsetSchema");
				if ($arReplicationIDs[$event['ID']])
					$obRow->setAttribute('MetaInfo_ReplicationID', $arReplicationIDs[$event['ID']]);

				$arResponseRows[$event['ID']]->addChild($obRow);
			}
			$obResponse->addChild($arResponseRows[$event['ID']]);
		}
		return array('UpdateListItemsResult' => $obResponse);
	}
Example #5
0
 public static function __createFromDOM($domNode)
 {
     $result = new CXMLCreator($domNode->name);
     $result->setData($domNode->content);
     if (is_array($domNode->attributes)) {
         foreach ($domNode->attributes as $attrDomNode) {
             $result->setAttribute($attrDomNode->name, $attrDomNode->content);
         }
     }
     if (is_array($domNode->children)) {
         foreach ($domNode->children as $domChild) {
             $result->addChild(CXMLCreator::__createFromDOM($domChild));
         }
     }
     return $result;
 }
Example #6
0
 function GetListItemChangesSinceToken($listName, $viewFields = '', $query = '', $rowLimit = 0, $changeToken = '')
 {
     global $APPLICATION, $USER;
     if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     if (!$USER->IsAdmin() && (!defined("IS_EXTRANET") || IS_EXTRANET != "Y")) {
         $rsUsers = CUser::GetList($by = "id", $order = "asc", array("ID" => $USER->GetID()), array("SELECT" => array("UF_DEPARTMENT")));
         if ($arUser = $rsUsers->Fetch()) {
             if (intval($arUser["UF_DEPARTMENT"][0]) > 0) {
                 $bUserIntranet = true;
             }
         }
         if (!$bUserIntranet) {
             return new CSoapFault('Data error', 'User has no permissions to read intranet contacts');
         }
     }
     $listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
     $arFilter = array('ACTIVE' => 'Y');
     $page = 1;
     $bUpdateFields = false;
     $tsLastFieldsChange = COption::GetOptionString('intranet', 'ws_contacts_last_fields_change', false);
     $this->bGetImages = COption::GetOptionString('intranet', 'ws_contacts_get_images', 'Y') == 'Y';
     if (strlen($changeToken) > 0) {
         if ($pos = strpos($changeToken, ';')) {
             list($newChangeToken, $page, $last_change) = explode(';', $changeToken);
             $page++;
             $changeToken = $newChangeToken;
         }
         $arFilter['TIMESTAMP_X_1'] = ConvertTimeStamp($changeToken, 'FULL');
         if (!$arFilter['TIMESTAMP_X_1']) {
             return new CSoapFault('Params error', 'Wrong changeToken: ' . $changeToken);
         }
         if ($tsLastFieldsChange !== false && $tsLastFieldsChange > $changeToken) {
             $bUpdateFields = true;
         }
     }
     if (CModule::IncludeModule('extranet') && defined("IS_EXTRANET") && IS_EXTRANET == "Y") {
         $arFilter["GROUPS_ID"] = array(COption::GetOptionInt("extranet", "extranet_group"));
     }
     if (!CModule::IncludeModule('extranet') || defined("IS_EXTRANET") && IS_EXTRANET == "Y" && defined("IS_EMPLOYEES") && IS_EMPLOYEES == "Y" || (!defined("IS_EXTRANET") || IS_EXTRANET != "Y")) {
         $arFilter["!UF_DEPARTMENT"] = false;
     } else {
         $arFilter["UF_DEPARTMENT"] = false;
     }
     // it's needed to check is current user an intranet user if he requested intranet script
     $arListParams = array("SELECT" => array("UF_DEPARTMENT"));
     if ($rowLimit > 0) {
         $arListParams["NAV_PARAMS"] = array("nPageSize" => $rowLimit, "bShowAll" => false, "iNumPage" => $page);
     }
     $obUsers = CUser::GetList($by = 'id', $order = 'asc', $arFilter, $arListParams);
     if (!isset($last_change)) {
         $last_change = 0;
     }
     $data = new CXMLCreator('listitems');
     $data->setAttribute('MinTimeBetweenSyncs', 0);
     $data->setAttribute('RecommendedTimeBetweenSyncs', 180);
     $data->setAttribute('TimeStamp', $this->__makeDateTime());
     $data->setAttribute('EffectivePermMask', 'FullMask');
     $data->addChild($obChanges = new CXMLCreator('Changes'));
     if ((!$changeToken || $bUpdateFields) && $page <= 1) {
         $arGetListResult = $this->GetList($listName);
         $obChanges->addChild($arGetListResult['GetListResult']);
     }
     //TODO: the next thing is to do something like this for all deleted events.
     //$obChanges->addChild($obId = new CXMLCreator('Id'));
     //$obId->setAttribute('ChangeType', 'Delete');
     //$obId->setData('702');
     //<Id ChangeType="Delete">14</Id>
     $data->addChild($obData = new CXMLCreator('rs:data'));
     $counter = 0;
     if (CModule::IncludeModule('extranet') && defined("IS_EXTRANET") && IS_EXTRANET == "Y") {
         $arUsersInMyGroupsID = CExtranet::GetMyGroupsUsers(CExtranet::GetExtranetSiteID());
         $arPublicUsersID = CExtranet::GetPublicUsers();
     }
     while ($arUser = $obUsers->Fetch()) {
         if (CModule::IncludeModule('extranet') && !CExtranet::IsExtranetAdmin()) {
             if (defined("IS_EXTRANET") && IS_EXTRANET == "Y" && (!in_array($arUser["ID"], $arUsersInMyGroupsID) && !in_array($arUser["ID"], $arPublicUsersID) || $arUser["ID"] == $USER->GetID())) {
                 continue;
             }
         }
         if (is_array($arUser['UF_DEPARTMENT']) && count($arUser['UF_DEPARTMENT']) > 0) {
             if ($this->arDepartmentsCache[$arUser['UF_DEPARTMENT'][0]]) {
                 $arUser['WORK_COMPANY'] = $this->arDepartmentsTopCache[$arUser['UF_DEPARTMENT'][0]];
                 $arUser['UF_DEPARTMENT'] = $this->arDepartmentsCache[$arUser['UF_DEPARTMENT'][0]];
             } else {
                 $dbRes = CIBlockSection::GetByID($arUser['UF_DEPARTMENT'][0]);
                 if ($arRes = $dbRes->Fetch()) {
                     if (!defined("IS_EXTRANET") || IS_EXTRANET != "Y" || defined("IS_EMPLOYEES") && IS_EMPLOYEES == "Y") {
                         $arUser['DEPARTMENT'] = $this->arDepartmentsCache[$arUser['UF_DEPARTMENT'][0]] = $arRes['NAME'];
                     }
                     // this case crashes inner cache of top departments
                     //if (!$arUser['WORK_COMPANY'])
                     //{
                     if ($top_section = CIntranetUtils::GetIBlockTopSection($arUser['UF_DEPARTMENT'])) {
                         $dbRes = CIBlockSection::GetByID($top_section);
                         if ($arRes = $dbRes->Fetch()) {
                             $arUser['WORK_COMPANY'] = $this->arDepartmentsTopCache[$arUser['UF_DEPARTMENT'][0]] = $arRes['NAME'];
                         }
                     }
                     //}
                     if (!defined("IS_EXTRANET") || IS_EXTRANET != "Y" || defined("IS_EMPLOYEES") && IS_EMPLOYEES == "Y") {
                         $arUser['UF_DEPARTMENT'] = $arUser['DEPARTMENT'];
                     }
                 }
             }
         }
         // if (!$bGetImages)
         // $arUser['PERSONAL_PHOTO'] = 0;
         $counter++;
         $obData->addChild($this->__getRow($arUser, $listName, $last_change));
     }
     //$last_change = time();
     $obData->setAttribute('ItemCount', $counter);
     $data->setAttribute('xmlns:rs', 'urn:schemas-microsoft-com:rowset');
     $data->setAttribute('xmlns:z', '#RowsetSchema');
     if ($bUpdateFields && $tsLastFieldsChange) {
         $last_change = $tsLastFieldsChange;
     }
     if ($last_change > 0) {
         if ($rowLimit && $obUsers->NavPageCount > 1 && $obUsers->NavPageCount > $page) {
             $last_change = intval($changeToken) . ';' . $page . ';' . $last_change;
             $obChanges->setAttribute('MoreChanges', 'TRUE');
         } else {
             $last_change += 1;
         }
         $obChanges->setAttribute('LastChangeToken', $last_change);
     }
     return array('GetListItemChangesSinceTokenResult' => $data);
 }
Example #7
0
 protected static function GetCurrencyList()
 {
     $ar = CCrmCurrencyHelper::PrepareListItems();
     $CXMLCreatorR = new CXMLCreator('CHOISES');
     foreach ($ar as $key => $value) {
         $CXMLCreator = new CXMLCreator('CHOISE', true);
         $CXMLCreator->setAttribute('id', $key);
         $CXMLCreator->setData($value);
         $CXMLCreatorR->addChild($CXMLCreator);
     }
     return $CXMLCreatorR;
 }
Example #8
0
 protected static function GetSourceList()
 {
     $ar = CCrmStatus::GetStatusListEx('SOURCE');
     $CXMLCreatorR = new CXMLCreator('CHOISES');
     foreach ($ar as $key => $value) {
         $CXMLCreator = new CXMLCreator('CHOISE', true);
         $CXMLCreator->setAttribute('id', $key);
         $CXMLCreator->setData($value);
         $CXMLCreatorR->addChild($CXMLCreator);
     }
     return $CXMLCreatorR;
 }
Example #9
0
 function createWSDL()
 {
     global $xsd_simple_type;
     if (!$this->classes or !count($this->classes)) {
         return 0;
     }
     foreach ($this->classes as $class => $methods) {
         $pbs = array();
         ksort($methods);
         foreach ($methods as $method => $components) {
             if ($components["type"] == "public") {
                 $this->__createMessage($method, $components["output"], $components["input"]);
                 $pbs[$class][$method]["documentation"] = $components["description"];
                 $pbs[$class][$method]["input"] = $components["input"];
                 $pbs[$class][$method]["output"] = $components["output"];
             }
         }
         $this->__createPortType($pbs);
         $this->__createBinding($pbs);
         $this->__createService($pbs);
         //AddMessage2Log(mydump($this->portTypes));
     }
     //echo '<pre>'; print_r($this); echo '</pre>';
     // add types
     if (is_array($this->typensDefined) && count($this->typensDefined) > 0) {
         $types = new CXMLCreator("wsdl:types");
         $xsdSchema = new CXMLCreator("xsd:schema");
         $xsdSchema->setAttribute("elementFormDefault", "qualified");
         $xsdSchema->setAttribute("targetNamespace", $this->targetNamespace);
         foreach ($this->typensDefined as $typensDefined) {
             $xsdtype = "element";
             if (isset($this->typensXSDType[$typensDefined])) {
                 $xsdtype = "type";
             }
             if ($xsdtype == "element") {
                 $elroot = new CXMLCreator("xsd:element");
                 $elroot->setAttribute("name", $typensDefined);
             }
             $complexType = new CXMLCreator("xsd:complexType");
             if ($xsdtype == "type") {
                 $complexType->setAttribute("name", $typensDefined);
             }
             $all = new CXMLCreator("xsd:sequence");
             if (isset($this->typensVars[$typensDefined]) and is_array($this->typensVars[$typensDefined])) {
                 //commented by Sigurd;
                 //ksort($this->typensVars[$typensDefined]);
                 foreach ($this->typensVars[$typensDefined] as $varName => $varType) {
                     // check minOccurs|maxOccurs here!
                     $element = new CXMLCreator("xsd:element");
                     $element->setAttribute("minOccurs", 0);
                     if (is_array($varType) and isset($varType["maxOccurs"])) {
                         $element->setAttribute("maxOccurs", $varType["maxOccurs"]);
                     } else {
                         $element->setAttribute("maxOccurs", 1);
                     }
                     if (is_array($varType) and isset($varType["nillable"])) {
                         $element->setAttribute("nillable", $varType["nillable"]);
                     }
                     $element->setAttribute("name", $varName);
                     if (is_array($varType)) {
                         $varType = $varType["varType"];
                     }
                     if ($varType == 'any') {
                         $any = new CXMLCreator('xsd:any');
                         $sequence = new CXMLCreator('xsd:sequence');
                         $sequence->addChild($any);
                         $element->addChild($sequence);
                         $complexType->setAttribute('mixed', "true");
                     } else {
                         $varType = isset($xsd_simple_type[$varType]) ? "xsd:" . $xsd_simple_type[$varType] : "tns:" . $varType;
                         $element->setAttribute("type", $varType);
                     }
                     $all->addChild($element);
                 }
             }
             $complexType->addChild($all);
             if ($xsdtype == "element") {
                 $elroot->addChild($complexType);
                 $xsdSchema->addChild($elroot);
             } else {
                 $xsdSchema->addChild($complexType);
             }
         }
         $types->addChild($xsdSchema);
         $this->WSDLXML->addChild($types);
     }
     // adding messages
     foreach ($this->messages as $message) {
         $this->WSDLXML->addChild($message);
     }
     // adding port types
     foreach ($this->portTypes as $portType) {
         $this->WSDLXML->addChild($portType);
     }
     // adding bindings
     foreach ($this->bindings as $binding) {
         $this->WSDLXML->addChild($binding);
     }
     // adding services
     $s = new CXMLCreator("wsdl:service");
     $s->setAttribute("name", $this->serviceName);
     foreach ($this->services as $service) {
         $s->addChild($service);
     }
     $this->WSDLXML->addChild($s);
     $this->WSDL = "<?xml version='1.0' encoding='UTF-8'?>\n";
     //$this->WSDL .= "<!-- WSDL file generated by BITRIX WSDLCreator (http://www.bitrix.ru) -->\n";
     $this->WSDL .= $this->WSDLXML->getXML();
 }
Example #10
0
 function UpdateListItems($listName, $updates)
 {
     global $USER, $DB;
     $arPaths = array('user' => COption::GetOptionString('intranet', 'path_task_user_entry', '/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/'), 'group' => COption::GetOptionString('intranet', 'path_task_group_entry', '/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/'));
     if (!$this->__Init()) {
         return $this->error;
     }
     if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     $listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
     $obResponse = new CXMLCreator('Results');
     $obBatch = $updates->children[0];
     $atrONERROR = $obBatch->getAttribute('OnError');
     $atrDATEINUTC = $obBatch->getAttribute('DateInUtc');
     $atrPROPERTIES = $obBatch->getAttribute('Properties');
     $arChanges = $obBatch->children;
     $arResultIDs = array();
     $dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL');
     $arResponseRows = array();
     $arResponseRowsError = array();
     $arReplicationIDs = array();
     foreach ($arChanges as $obMethod) {
         $arData = array('_command' => $obMethod->getAttribute('Cmd'));
         $ID = false;
         $bUpdate = true;
         $arElement = false;
         $arSection = $this->arUsersSection;
         foreach ($obMethod->children as $obField) {
             $name = $obField->getAttribute('Name');
             if ($name == 'MetaInfo') {
                 $name .= '_' . $obField->getAttribute('Property');
             }
             $arData[$name] = $obField->content;
         }
         $obResponseRow = new CXMLCreator('Result');
         $obResponseRow->setAttribute('ID', $obMethod->getAttribute('ID') . ',' . $arData['_command']);
         $obResponseRow->setAttribute('List', $listName);
         $obResponseRow->addChild($obErrorCode = new CXMLCreator('ErrorCode'));
         if ($arData['ID'] > 0) {
             $rsElement = CTasks::GetById($arData['ID']);
             if ($rsElement && ($arElement = $rsElement->Fetch())) {
                 if (!is_array($arElement)) {
                     $obErrorCode->setData('0x81020016');
                     $bUpdate = false;
                 } else {
                     if ($arElement['taskType'] == "group") {
                         $arGroupTmp = CSocNetGroup::GetByID($arElement['ownerId']);
                         if ($arGroupTmp["CLOSED"] == "Y") {
                             if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
                                 return new CSoapFault('Cannot modify archive group task', 'Cannot modify archive group task');
                             }
                         }
                     }
                     $arElement['arParams'] = array(intval($arElement['GROUP_ID']) > 0 ? 'PATH_TO_USER_TASKS_TASK' : 'PATH_TO_GROUP_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $arElement['ID']), $arPaths[$arElement['taskType']]));
                 }
             } else {
                 $obErrorCode->setData('0x81020016');
                 $bUpdate = false;
             }
         }
         if ($bUpdate) {
             if ($arData['_command'] == 'Delete' && $arElement["CREATED_BY"] == $USER->GetID()) {
                 $arError = false;
                 if (!CTasks::Delete($arElement['ID'])) {
                     $obErrorCode->setData('0x81020014');
                 } else {
                     $obErrorCode->setData('0x00000000');
                 }
             } elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') {
                 $arData['Body'] = trim($arData['Body']);
                 $arData['Body'] = str_replace(array("&#10;", "&#13;", '&nbsp;'), "", $arData['Body']);
                 $arData['Body'] = preg_replace("/<![^>]*>/", '', $arData['Body']);
                 if (($pos = strpos($arData['Body'], '<BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], $pos + 6);
                 }
                 echo $pos . ' ';
                 if (($pos = strpos($arData['Body'], '</BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], 0, $pos);
                 }
                 echo $pos . ' ';
                 $TZBias = intval(date('Z'));
                 $arData['StartDate'] = $arData['StartDate'] ? $this->__makeTS($arData['StartDate']) + $TZBias : '';
                 $arData['DueDate'] = $arData['DueDate'] ? $this->__makeTS($arData['DueDate']) + $TZBias : '';
                 $arData['MetaInfo_DateComplete'] = $arData['MetaInfo_DateComplete'] ? $this->__makeTS($arData['EndDate']) + $TZBias : '';
                 $probablyHtmlInDescription = strpos($arData['Body'], '<') !== false && strpos($arData['Body'], '>');
                 $arFields = array('DESCRIPTION_IN_BBCODE' => $probablyHtmlInDescription ? 'N' : 'Y', 'CHANGED_BY' => $USER->GetID(), 'CHANGED_DATE' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time()), 'SITE_ID' => SITE_ID, 'TITLE' => $arData['Title'], 'START_DATE_PLAN' => $arData['StartDate'] ? ConvertTimeStamp($arData['StartDate']) : '', 'DEADLINE' => $arData['DueDate'] ? ConvertTimeStamp($arData['DueDate']) : '', 'DESCRIPTION' => $arData['Body'], 'PRIORITY' => isset($arData['Priority']) ? intval($arData['Priority']) : 1, 'DURATION_PLAN' => $arData['MetaInfo_TotalWork'] / 60, 'DURATION_FACT' => $arData['MetaInfo_ActualWork'] / 60, 'CLOSED_DATE' => $arData['MetaInfo_DateComplete'] ? ConvertTimeStamp($arData['MetaInfo_DateComplete']) : '');
                 if (in_array($arData['Status'], $this->arStatuses)) {
                     $arFields["STATUS"] = $arData['Status'];
                 }
                 if ($assigned_to = $arData['AssignedTo']) {
                     if ($USER_ID = $this->__getUser($assigned_to)) {
                         $arFields['RESPONSIBLE_ID'] = $USER_ID;
                     } else {
                         $obErrorCode->setData('0x81020054');
                         $bUpdate = false;
                     }
                 } else {
                     $arFields['RESPONSIBLE_ID'] = $USER->getId();
                 }
                 if ($bUpdate) {
                     CTimeZone::Disable();
                     $ID = 0;
                     $obTask = new CTasks();
                     $arError = false;
                     if ($arData['_command'] == 'New') {
                         if ($arFields["RESPONSIBLE_ID"] == $USER->GetID() || CTasks::IsSubordinate($arFields["RESPONSIBLE_ID"], $USER->GetID())) {
                             $arFields["STATUS"] = 2;
                         } else {
                             $arFields["STATUS"] = 1;
                         }
                         $arFields['OUTLOOK_VERSION'] = 1;
                         $arFields["CREATED_BY"] = $USER->GetID();
                         $arFields["CREATED_DATE"] = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time());
                         if ($ID = $obTask->Add($arFields)) {
                             $arReplicationIDs[$ID] = $arData['MetaInfo_ReplicationID'];
                             $obErrorCode->setData('0x00000000');
                         }
                     } else {
                         if ($arElement["CREATED_BY"] == $USER->GetID() || $arElement["RESPONSIBLE_ID"] == $USER->GetID()) {
                             if ($arElement["CREATED_BY"] != $USER->GetID()) {
                                 unset($arFields["TITLE"], $arFields["START_DATE_PLAN"], $arFields["DESCRIPTION"], $arFields["PRIORITY"], $arFields["DURATION_PLAN"], $arFields["CLOSED_DATE"]);
                                 if ($arElement["ALLOW_CHANGE_DEADLINE"] != "Y") {
                                     unset($arFields["DEADLINE"]);
                                 }
                                 if ($arElement["TASK_CONTROL"] != "Y" && $arFields["STATUS"] == 5) {
                                     $arFields["STATUS"] = 4;
                                 }
                             } elseif ($arElement["RESPONSIBLE_ID"] != $USER->GetID() && ($arFields["STATUS"] == 6 || $arFields["STATUS"] == 3)) {
                                 unset($arFields["STATUS"]);
                             }
                             $arFields['OUTLOOK_VERSION'] = $arData['owshiddenversion'];
                             if (sizeof($arFields) > 0) {
                                 if ($obTask->Update($arData['ID'], $arFields)) {
                                     $ID = $arData['ID'];
                                     $obErrorCode->setData('0x00000000');
                                 }
                             }
                         }
                     }
                     CTimeZone::Enable();
                     if (is_array($obTask->GetErrors()) && count($obTask->GetErrors()) > 0) {
                         $ID = 0;
                         $obErrorCode->setData('0x81020014');
                         $bUpdate = false;
                     } else {
                         $taskType = $arElement ? $arElement['taskType'] : 'user';
                         $ownerId = $arElement ? $arElement['ownerId'] : $USER->GetID();
                         $arParams = $arElement ? $arElement['arParams'] : array('PATH_TO_USER_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $ID), $arPaths['user']));
                     }
                 }
             }
         }
         if ($ID > 0) {
             $arResponseRows[$ID] = $obResponseRow;
         } else {
             $arResponseRowsError[] = $obResponseRow;
         }
     }
     if (sizeof($arResponseRows) > 0) {
         $dbRes = CTasks::GetList(array('ID' => 'ASC'), array('ID' => array_keys($arResponseRows), 'MEMBER' => $USER->GetID()));
         while ($arRes = $dbRes->Fetch()) {
             if ($arResponseRows[$arRes['ID']]) {
                 $rsFiles = CTaskFiles::GetList(array(), array("TASK_ID" => $arRes["ID"]));
                 $arRes["FILES"] = array();
                 while ($arFiles = $rsFiles->Fetch()) {
                     $arRes["FILES"][] = $arFiles["FILE_ID"];
                 }
                 $obRow = $this->__getRow($arRes, $listName, $last_change = 0);
                 if ($arReplicationIDs[$arRes['ID']]) {
                     $obRow->setAttribute('ows_MetaInfo_ReplicationID', $arReplicationIDs[$arRes['ID']]);
                 }
                 $obRow->setAttribute('xmlns:z', "#RowsetSchema");
                 $arResponseRows[$arRes['ID']]->addChild($obRow);
                 $obResponse->addChild($arResponseRows[$arRes['ID']]);
             }
         }
     }
     foreach ($arResponseRowsError as $obChange) {
         $obResponse->addChild($obChange);
     }
     return array('UpdateListItemsResult' => $obResponse);
 }
Example #11
0
 public function GetListItemChangesSinceToken($listName, $arParams = array())
 {
     $arMethodParams = array('listName' => $listName);
     if ($arParams['TOKEN']) {
         $arMethodParams['changeToken'] = $arParams['TOKEN'];
     }
     if ($arParams['NUM_ROWS']) {
         $arMethodParams['rowLimit'] = intval($arParams['NUM_ROWS']);
     }
     $queryOptions = new CXMLCreator('QueryOptions');
     if (isset($arParams['PAGING'])) {
         $queryOptions->addChild(CXMLCreator::createTagAttributed('Paging ListItemCollectionPositionNext="' . htmlspecialchars($arParams['PAGING']) . '"'));
     }
     $arMethodParams['queryOptions'] = $queryOptions;
     if (is_array($arParams['FIELDS'])) {
         $viewFields = new CXMLCreator('ViewFields');
         $viewFields->setAttribute('Properties', 'TRUE');
         foreach ($arParams['FIELDS'] as $fld) {
             $viewFields->addChild(CXMLCreator::createTagAttributed('FieldRef Name="' . $fld . '"'));
         }
         $arMethodParams['viewFields'] = $viewFields;
     }
     if ($this->__initialize() && $this->Call('GetListItemChangesSinceToken', $arMethodParams) && ($DOM = $this->RESPONSE->DOMDocument)) {
         $RESULT = array();
         // $fp = fopen($_SERVER['DOCUMENT_ROOT'].'/sp_client1.log', 'a');
         // fwrite($fp, $this->getRawRequest());
         // fwrite($fp, $this->getRawResponse());
         // fwrite($fp, "\n==========================================\n\n");
         // fclose($fp);
         $CHANGES = $DOM->elementsByName('Changes');
         $RESULT['MORE_ROWS'] = false;
         if (is_array($CHANGES) && count($CHANGES) > 0) {
             $CHANGES = $CHANGES[0];
             $RESULT['TOKEN'] = $CHANGES->getAttribute('LastChangeToken');
             $RESULT['MORE_ROWS'] |= $CHANGES->getAttribute('MoreChanges') == 'TRUE';
         }
         $DATA_NODE = $DOM->elementsByName('data');
         if (is_array($DATA_NODE) && count($DATA_NODE) > 0) {
             $DATA_NODE = $DATA_NODE[0];
             $RESULT['COUNT'] = $DATA_NODE->getAttribute('ItemCount');
             $RESULT['PAGING'] = $DATA_NODE->getAttribute('ListItemCollectionPositionNext');
             $RESULT['MORE_ROWS'] |= strlen($RESULT['PAGING']) > 0;
             $RESULT['DATA'] = $this->ConvertRows($DATA_NODE);
             if (count($RESULT['DATA']) <= 0) {
                 $RESULT['MORE_ROWS'] = false;
             }
         }
         return $this->GetListItemChangesSinceTokenProcessResult($RESULT);
     }
     return false;
 }
Example #12
0
 function UpdateListItems($listName, $updates)
 {
     global $USER;
     $arPaths = array('user' => COption::GetOptionString('intranet', 'path_task_user_entry', '/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/'), 'group' => COption::GetOptionString('intranet', 'path_task_group_entry', '/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/'));
     if (!$this->__Init()) {
         return $this->error;
     }
     if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     $listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
     // one more dirty hack. now for bx.
     //define('BX_INTASKS_FROM_COMPONENT', true);
     //CModule::IncludeModule('socialnetwork');
     //include($_SERVER['DOCUMENT_ROOT'].BX_PERSONAL_ROOT.'/components/bitrix/intranet.tasks/init.php');
     //include($_SERVER['DOCUMENT_ROOT'].BX_PERSONAL_ROOT.'/components/bitrix/intranet.tasks/action.php');
     $obResponse = new CXMLCreator('Results');
     $arStatusValues = array();
     $obStatus = CIBlockProperty::GetPropertyEnum('TaskStatus', array('SORT' => 'asc'), array('IBLOCK_ID' => $this->IBLOCK_ID));
     while ($arStatus = $obStatus->Fetch()) {
         $arStatusValues[$arStatus['XML_ID']] = $arStatus['ID'];
         if ($arStatus['XML_ID'] == 'NotAccepted') {
             $arStatusValues[$arStatus['VALUE']] = $arStatus['ID'];
         }
     }
     /*
     $arPriorityValues = array();
     $obPriority = CIBlockProperty::GetPropertyEnum('TaskPriority', array('SORT' => 'asc'), array('IBLOCK_ID' => $this->IBLOCK_ID));
     while ($arPriority = $obPriority->Fetch())
     	$arPriorityValues[$arPriority['XML_ID']] = $arPriority['ID'];
     */
     $arPriorityValues = array_flip($this->arProperties['TaskPriority']['VARIANTS_ID']);
     $arStatusValues = array_flip($this->arProperties['TaskStatus']['VARIANTS_ID']);
     $arStatusXML_ID = array_flip($this->arProperties['TaskStatus']['VARIANTS']);
     $obBatch = $updates->children[0];
     $atrONERROR = $obBatch->getAttribute('OnError');
     $atrDATEINUTC = $obBatch->getAttribute('DateInUtc');
     $atrPROPERTIES = $obBatch->getAttribute('Properties');
     $arChanges = $obBatch->children;
     $arResultIDs = array();
     $dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL');
     $arResponseRows = array();
     $arResponseRowsError = array();
     $arReplicationIDs = array();
     foreach ($arChanges as $obMethod) {
         $arData = array('_command' => $obMethod->getAttribute('Cmd'));
         $ID = false;
         $bUpdate = true;
         $arElement = false;
         $arSection = $this->arUsersSection;
         foreach ($obMethod->children as $obField) {
             $name = $obField->getAttribute('Name');
             if ($name == 'MetaInfo') {
                 $name .= '_' . $obField->getAttribute('Property');
             }
             $arData[$name] = $obField->content;
         }
         $obResponseRow = new CXMLCreator('Result');
         $obResponseRow->setAttribute('ID', $obMethod->getAttribute('ID') . ',' . $arData['_command']);
         $obResponseRow->setAttribute('List', $listName);
         $obResponseRow->addChild($obErrorCode = new CXMLCreator('ErrorCode'));
         if ($arData['ID'] > 0) {
             //$dbRes = CIBlockElement::GetByID($arData['ID']);
             $arElement = CIntranetTasks::GetById($arData['ID']);
             if (!is_array($arElement)) {
                 $obErrorCode->setData('0x81020016');
                 $bUpdate = false;
             } else {
                 //$arElement = $obElement->GetFields();
                 //$arElement['prop'] = $obElement->GetProperties();
                 if ($arElement['IBLOCK_SECTION_ID'] != $arSection['ID']) {
                     if (!($arSection = $this->__getSection($arElement['IBLOCK_SECTION_ID']))) {
                         return new CSoapFault('Some error', 'Unknown error with iblock sections');
                     }
                 }
                 // don't forget about depth of sections, Max has modification
                 if ($arElement['taskType'] == "group") {
                     $arGroupTmp = CSocNetGroup::GetByID($arElement['ownerId']);
                     if ($arGroupTmp["CLOSED"] == "Y") {
                         if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
                             return new CSoapFault('Cannot modify archive group task', 'Cannot modify archive group task');
                         }
                     }
                 }
                 $arElement['arParams'] = array($arElement['taskType'] == 'user' ? 'PATH_TO_USER_TASKS_TASK' : 'PATH_TO_GROUP_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $arElement['ID']), $arPaths[$arElement['taskType']]));
             }
         }
         if ($bUpdate) {
             if ($arData['_command'] == 'Delete') {
                 $arError = false;
                 if (CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_DELETE_DOCUMENT, $USER->GetID(), $arElement['ID'], array())) {
                     if (!CIntranetTasks::Delete($arElement['ID'], $arError)) {
                         $obErrorCode->setData('0x81020014');
                     } else {
                         $obErrorCode->setData('0x00000000');
                     }
                 } else {
                     $obErrorCode->setData('0x81020014');
                 }
                 /*
                 	0x00000000 - ok
                 	0x81020015 - data conflict
                 	0x81020014 - generic error such as invalid value for Field
                 	0x81020016 - item does not exist
                 */
             } elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') {
                 /*
                 $arData['Body'] = str_replace('</DIV>', "\r\n</DIV>", $arData['Body']);
                 $arData['Body'] = strip_tags($arData['Body']);
                 $arData['Body'] = trim($arData['Body']);
                 $arData['Body'] = htmlspecialcharsback($arData['Body']);
                 */
                 $arData['Body'] = trim($arData['Body']);
                 $arData['Body'] = str_replace(array("&#10;", "&#13;", '&nbsp;'), "", $arData['Body']);
                 $arData['Body'] = preg_replace("/<![^>]*>/", '', $arData['Body']);
                 if (($pos = strpos($arData['Body'], '<BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], $pos + 6);
                 }
                 echo $pos . ' ';
                 if (($pos = strpos($arData['Body'], '</BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], 0, $pos);
                 }
                 echo $pos . ' ';
                 $TZBias = intval(date('Z'));
                 $arData['StartDate'] = $arData['StartDate'] ? $this->__makeTS($arData['StartDate']) + $TZBias : '';
                 $arData['DueDate'] = $arData['DueDate'] ? $this->__makeTS($arData['DueDate']) + $TZBias : '';
                 $arData['MetaInfo_DateComplete'] = $arData['MetaInfo_DateComplete'] ? $this->__makeTS($arData['EndDate']) + $TZBias : '';
                 if ($arData['Status'] == $arStatusValues['NotAccepted']) {
                     $arData['Status'] = 'NotAccepted';
                 }
                 $arFields = array('IBLOCK_ID' => $this->IBLOCK_ID, 'IBLOCK_SECTION_ID' => $arSection['ID'], 'MODIFIED_BY' => $USER->GetID(), 'NAME' => $arData['Title'] ? $arData['Title'] : GetMessage('INTR_OUTLOOK_TASK_NO_TITLE'), 'DATE_ACTIVE_FROM' => $arData['StartDate'] ? ConvertTimeStamp($arData['StartDate']) : '', 'DATE_ACTIVE_TO' => $arData['DueDate'] ? ConvertTimeStamp($arData['DueDate']) : '', 'DETAIL_TEXT_TYPE' => 'html', 'DETAIL_TEXT' => $arData['Body'], 'PROPERTY_TaskPriority' => $arData['Priority'] ? $arPriorityValues[$arData['Priority']] : false, 'PROPERTY_TaskComplete' => $arData['PercentComplete'] * 100, 'PROPERTY_TaskSize' => $arData['MetaInfo_TotalWork'] / 60, 'PROPERTY_TaskSizeReal' => $arData['MetaInfo_ActualWork'] / 60, 'PROPERTY_TaskFinish' => $arData['MetaInfo_DateComplete'] ? ConvertTimeStamp($arData['MetaInfo_DateComplete']) : '');
                 if (false === $arFields['PROPERTY_TaskPriority']) {
                     $arPrior = array_keys($arElement['PROPERTY_TaskPriority']);
                     $arFields['PROPERTY_TaskPriority'] = $arPrior[0];
                 }
                 if ($assigned_to = $arData['AssignedTo']) {
                     if ($USER_ID = $this->__getUser($assigned_to)) {
                         $arFields['PROPERTY_TaskAssignedTo'] = $USER_ID;
                     } else {
                         $obErrorCode->setData('0x81020054');
                         $bUpdate = false;
                     }
                 }
                 if ($bUpdate) {
                     $bConfirm = false;
                     $bComplete = false;
                     if ($arData['_command'] != 'New') {
                         if (false && $arElement['PROPERTY_VERSION'] > $arData['owshiddenversion']) {
                             $obErrorCode->setData('0x81020015');
                             $bUpdate = false;
                         } else {
                             foreach ($arElement as $fld => $value) {
                                 if (substr($fld, 0, 9) == 'PROPERTY_') {
                                     if (!$arFields[$fld] && $fld != 'PROPERTY_TaskFiles') {
                                         $arFields[$fld] = $arElement[$fld];
                                     }
                                 }
                             }
                             $arFields['PROPERTY_VERSION']++;
                         }
                         $statusOld = $this->__GetTaskStatus($arElement['ID'], $arElement['IBLOCK_ID']);
                     } else {
                         $arFields['PROPERTY_VERSION'] = $arData['owshiddenversion'];
                         $statusOld = -1;
                     }
                     if (!$arFields['PROPERTY_TaskPriority']) {
                         $arFields['PROPERTY_TaskPriority'] = 2;
                     }
                     if (!$arFields['PROPERTY_TaskAssignedTo']) {
                         $arFields['PROPERTY_TaskAssignedTo'] = $USER->GetID();
                     } elseif ($arFields['PROPERTY_TaskAssignedTo'] != $USER->GetID()) {
                         $arData['Status'] = 'NotAccepted';
                     }
                     $statusNew = $arData['Status'] ? $arStatusXML_ID[$arData['Status']] : $statusOld;
                     $ID = 0;
                     if ($bUpdate) {
                         $arError = false;
                         if ($arData['_command'] == 'New') {
                             if ($ID = CIntranetTasks::Add($arFields, $arError)) {
                                 $arDocumentStates = CBPDocument::GetDocumentStates(array("intranet", "CIntranetTasksDocument", "x" . $this->IBLOCK_ID), null);
                                 $arDocumentStates = array_values($arDocumentStates);
                                 $pathTemplate = str_replace(array("#USER_ID#", "#TASK_ID#"), array($USER->GetID(), "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_user_entry", "/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/"));
                                 $arErrors = array();
                                 CBPDocument::StartWorkflow($arDocumentStates[0]["TEMPLATE_ID"], array("intranet", "CIntranetTasksDocument", $ID), array("OwnerId" => $arFields['PROPERTY_TaskAssignedTo'], "TaskType" => 'user', "PathTemplate" => $pathTemplate, "ForumId" => COption::GetOptionInt('intranet', 'task_forum_id', 0), "IBlockId" => $this->IBLOCK_ID), $arErrors);
                                 CIntranetTasks::ChangeStatus($ID, $statusNew);
                                 $arReplicationIDs[$ID] = $arData['MetaInfo_ReplicationID'];
                                 $obErrorCode->setData('0x00000000');
                             }
                         } else {
                             if (CIntranetTasks::Update($arData['ID'], $arFields, $arError)) {
                                 if ($statusOld != $statusNew) {
                                     CIntranetTasks::ChangeStatus($arData['ID'], $statusNew);
                                 }
                                 $ID = $arData['ID'];
                                 $obErrorCode->setData('0x00000000');
                             }
                         }
                         if (is_array($arError) && count($arError) > 0) {
                             $ID = 0;
                             $obErrorCode->setData('0x81020014');
                             $bUpdate = false;
                         } else {
                             $taskType = $arElement ? $arElement['taskType'] : 'user';
                             $ownerId = $arElement ? $arElement['ownerId'] : $USER->GetID();
                             $arParams = $arElement ? $arElement['arParams'] : array('PATH_TO_USER_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $ID), $arPaths['user']));
                         }
                     }
                 }
             }
         }
         if ($ID > 0) {
             $arResponseRows[$ID] = $obResponseRow;
         } else {
             $arResponseRowsError[] = $obResponseRow;
         }
     }
     $dbRes = CIntranetTasks::GetList(array('ID' => 'ASC'), array('IBLOCK_ID' => $this->IBLOCK_ID, 'ID' => array_keys($arResponseRows)));
     while ($arRes = $dbRes->Fetch()) {
         if ($arResponseRows[$arRes['ID']]) {
             $obRow = $this->__getRow($arRes, $listName, $last_change = 0);
             if ($arReplicationIDs[$arRes['ID']]) {
                 $obRow->setAttribute('ows_MetaInfo_ReplicationID', $arReplicationIDs[$arRes['ID']]);
             }
             $obRow->setAttribute('xmlns:z', "#RowsetSchema");
             $arResponseRows[$arRes['ID']]->addChild($obRow);
             $obResponse->addChild($arResponseRows[$arRes['ID']]);
         }
     }
     foreach ($arResponseRowsError as $obChange) {
         $obResponse->addChild($obChange);
     }
     return array('UpdateListItemsResult' => $obResponse);
 }
Example #13
0
 public function AddWebserviceFields(&$obFields)
 {
     $arUserFields = $this->GetUserFields($this->sEntityID, 0, LANGUAGE_ID);
     foreach ($arUserFields as $FIELD_NAME => $arUserField) {
         $defVal = '';
         if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'employee') {
             continue;
         }
         if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'enum') {
             $sType = 'int';
             if (is_callable(array($arUserField['USER_TYPE']['CLASS_NAME'], 'GetList'))) {
                 $rsEnum = call_user_func_array(array($arUserField['USER_TYPE']['CLASS_NAME'], 'GetList'), array($arUserField));
                 $obFieldValues = new CXMLCreator('CHOISES');
                 while ($ar = $rsEnum->GetNext()) {
                     $obFieldValue = new CXMLCreator('CHOISE', true);
                     $obFieldValue->setAttribute('id', $ar['ID']);
                     $obFieldValue->setData(htmlspecialcharsbx($ar['VALUE']));
                     $obFieldValues->addChild($obFieldValue);
                 }
             }
         } else {
             if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'file') {
                 $sType = 'file';
             } else {
                 if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'boolean') {
                     $sType = 'boolean';
                 } else {
                     if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'double' || $arUserField['USER_TYPE']['USER_TYPE_ID'] == 'integer') {
                         $sType = 'int';
                     } else {
                         if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'datetime') {
                             $defVal = $arUserField['SETTINGS']['DEFAULT_VALUE']['VALUE'];
                             $sType = 'datetime';
                         } else {
                             if ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'string') {
                                 $sType = 'string';
                             } else {
                                 $sType = 'string';
                             }
                         }
                     }
                 }
             }
         }
         if (empty($defVal) && isset($arUserField['SETTINGS']['DEFAULT_VALUE']) && !is_array($arUserField['SETTINGS']['DEFAULT_VALUE'])) {
             $defVal = $arUserField['SETTINGS']['DEFAULT_VALUE'];
         }
         $obField = CXMLCreator::createTagAttributed('Field id="' . $FIELD_NAME . '" name="' . htmlspecialcharsbx($arUserField['EDIT_FORM_LABEL']) . '" type="' . $sType . '" default="' . $defVal . '" require="' . ($arUserField['MANDATORY'] == 'Y' ? 'true' : 'false') . '" multy="' . ($arUserField['MULTIPLE'] == 'Y' ? 'true' : 'false') . '"', '');
         if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'enum' && $obFieldValues instanceof CXMLCreator) {
             $obField->addChild($obFieldValues);
             unset($obFieldValues);
         }
         $obFields->addChild($obField);
     }
 }
Example #14
0
 function UpdateListItems($listName, $updates)
 {
     global $USER;
     $arStatusValues = array_flip($this->arStatusValues);
     $arPriorityValues = array_flip($this->arPriorityValues);
     $arWeekDays = array_flip($this->arWeekDays);
     if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     $obResponse = new CXMLCreator('Results');
     $listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
     $obRes = CIBlockSection::GetList(array('SORT' => 'ASC'), array('XML_ID' => $listName_original));
     if (!($arSection = $obRes->Fetch())) {
         return new CSoapFault('List not found', 'List with ' . $listName . ' GUID is not found');
     }
     $bGroup = $arSection['SOCNET_GROUP_ID'] != '';
     if ($bGroup) {
         CModule::IncludeModule('socialnetwork');
         $arGroupTmp = CSocNetGroup::GetByID($arSection['SOCNET_GROUP_ID']);
         if ($arGroupTmp["CLOSED"] == "Y") {
             if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
                 return new CSoapFault('Cannot modify archive group calendar', 'Cannot modify archive group calendar');
             }
         }
     }
     $obCalendar = new CEventCalendar();
     $obCalendar->Init(array('ownerType' => $bGroup ? 'GROUP' : 'USER', 'ownerId' => $bGroup ? $arSection['SOCNET_GROUP_ID'] : (is_object($USER) && $USER->GetID() ? $USER->GetID() : false), 'bOwner' => true, 'iblockId' => $arSection['IBLOCK_ID'], 'bCache' => false));
     // dirty hack
     $arPermissions = $obCalendar->GetPermissions(array('setProperties' => true));
     $obBatch = $updates->children[0];
     $atrONERROR = $obBatch->getAttribute('OnError');
     $atrDATEINUTC = $obBatch->getAttribute('DateInUtc');
     $atrPROPERTIES = $obBatch->getAttribute('Properties');
     $arChanges = $obBatch->children;
     $arResultIDs = array();
     $dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL');
     $arResponseRows = array();
     $arReplicationIDs = array();
     foreach ($arChanges as $obMethod) {
         $arData = array('_command' => $obMethod->getAttribute('Cmd'));
         foreach ($obMethod->children as $obField) {
             $name = $obField->getAttribute('Name');
             if ($name == 'MetaInfo') {
                 $name .= '_' . $obField->getAttribute('Property');
             }
             $arData[$name] = $obField->content;
         }
         if ($arData['_command'] == 'Delete') {
             $obRes = new CXMLCreator('Result');
             $obRes->setAttribute('ID', $obMethod->getAttribute('ID') . ',' . $arData['_command']);
             $obRes->setAttribute('List', $listName);
             $obRes->addChild($obNode = new CXMLCreator('ErrorCode'));
             if (CECEvent::Delete(array('id' => $arData['ID'], 'ownerType' => $bGroup ? 'GROUP' : 'USER', 'ownerId' => $bGroup ? $arSection['SOCNET_GROUP_ID'] : (is_object($USER) && $USER->GetID() ? $USER->GetID() : false), 'bOwner' => true, 'iblockId' => $arSection['IBLOCK_ID'], 'RMiblockId' => $this->__getRMIblockID(), 'allowResMeeting' => true))) {
                 CEventCalendar::ClearCache('/event_calendar/events/' . $arSection['IBLOCK_ID'] . '/');
                 $obNode->setData('0x00000000');
             } else {
                 $obNode->setData('0x81020014');
             }
             /*
             	0x00000000 - ok
             	0x81020015 - data conflict
             	0x81020014 - generic error such as invalid value for Field
             	0x81020016 - item does not exist
             */
             $obResponse->addChild($obRes);
         } elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') {
             $q = ToLower($arData['Description']);
             if (($pos = strrpos($q, '</body>')) !== false) {
                 $arData['Description'] = substr($arData['Description'], 0, $pos);
             }
             if (($pos = strpos($q, '<body>')) !== false) {
                 $arData['Description'] = substr($arData['Description'], $pos + 6);
             }
             $arData['Description'] = str_replace('</DIV>', "\r\n</DIV>", $arData['Description']);
             $arData['Description'] = str_replace(array("&#10;", "&#13;"), "", $arData['Description']);
             $arData['Description'] = preg_replace("/<![^>]*>/", '', $arData['Description']);
             //$arData['Description'] = strip_tags($arData['Description']);
             $arData['Description'] = trim($arData['Description']);
             $arData['Location'] = trim($arData['Location']);
             $arData['EventDate'] = $this->__makeTS($arData['EventDate']);
             $arData['EndDate'] = $this->__makeTS($arData['EndDate']) + ($arData['fAllDayEvent'] ? -86340 : 0);
             $TZBias = intval(date('Z', $arData['EventDate']));
             $arData['EventType'] = intval($arData['EventType']);
             if ($arData['EventType'] == 2) {
                 $arData['EventType'] = 0;
             }
             if ($arData['EventType'] > 2) {
                 return new CSoapFault('Unsupported event type', 'Event type unsupported');
             }
             $arData['fRecurrence'] = intval($arData['fRecurrence']);
             if ($arData['RecurrenceData']) {
                 //$xmlstr = $arData['XMLTZone'];
                 //$arData['XMLTZone'] = new CDataXML();
                 //$arData['XMLTZone']->LoadString($xmlstr);
                 $xmlstr = $arData['RecurrenceData'];
                 $obRecurData = new CDataXML();
                 $obRecurData->LoadString($xmlstr);
                 /*
                 <recurrence>
                 		<rule>
                 			<firstDayOfWeek>mo</firstDayOfWeek>
                 			<repeat>
                 				<weekly mo='TRUE' tu='TRUE' th='TRUE' sa='TRUE' weekFrequency='1' />
                 			</repeat>
                 			<repeatForever>FALSE</repeatForever>
                 		</rule>
                 </recurrence>
                 <deleteExceptions>true</deleteExceptions>
                 */
                 $obRecurRule = $obRecurData->tree->children[0]->children[0];
                 $obRecurRepeat = $obRecurRule->children[1];
                 $obNode = $obRecurRepeat->children[0];
                 $arData['RecurrenceData'] = array();
                 switch ($obNode->name) {
                     case 'daily':
                         // hack. we have no "work days" daily recurence
                         if ($obNode->getAttribute('weekday') == 'TRUE') {
                             $arData['RecurrenceData']['PERIOD_TYPE'] = 'WEEKLY';
                             $arData['RecurrenceData']['PERIOD_ADDITIONAL'] = '0,1,2,3,4';
                             $arData['RecurrenceData']['PERIOD_COUNT'] = 1;
                         } else {
                             $arData['RecurrenceData']['PERIOD_TYPE'] = 'DAILY';
                             $arData['RecurrenceData']['PERIOD_COUNT'] = $obNode->getAttribute('dayFrequency');
                         }
                         $time_end = strtotime(date(date('Y-m-d', $arData['EventDate']) . ' H:i:s', $arData['EndDate']));
                         $arData['RecurrenceData']['EVENT_LENGTH'] = $time_end - $arData['EventDate'];
                         break;
                     case 'weekly':
                         $arData['RecurrenceData']['PERIOD_TYPE'] = 'WEEKLY';
                         $arData['RecurrenceData']['PERIOD_ADDITIONAL'] = '';
                         foreach ($arWeekDays as $day => $value) {
                             if ($obNode->getAttribute($day)) {
                                 $arData['RecurrenceData']['PERIOD_ADDITIONAL'] .= ($arData['RecurrenceData']['PERIOD_ADDITIONAL'] == '' ? '' : ',') . $value;
                             }
                         }
                         $arData['RecurrenceData']['PERIOD_COUNT'] = $obNode->getAttribute('weekFrequency');
                         $time_end = strtotime(date(date('Y-m-d', $arData['EventDate']) . ' H:i:s', $arData['EndDate']));
                         $arData['RecurrenceData']['EVENT_LENGTH'] = $time_end - $arData['EventDate'];
                         break;
                     case 'monthly':
                         $arData['RecurrenceData']['PERIOD_TYPE'] = 'MONTHLY';
                         $arData['RecurrenceData']['PERIOD_COUNT'] = $obNode->getAttribute('monthFrequency');
                         $time_end = strtotime(date(date('Y-m', $arData['EventDate']) . '-d H:i:s', $arData['EndDate']));
                         $arData['RecurrenceData']['EVENT_LENGTH'] = $time_end - $arData['EventDate'];
                         break;
                     case 'yearly':
                         $arData['RecurrenceData']['PERIOD_TYPE'] = 'YEARLY';
                         $arData['RecurrenceData']['PERIOD_COUNT'] = $obNode->getAttribute('yearFrequency');
                         $time_end = strtotime(date(date('Y', $arData['EventDate']) . '-m-d H:i:s', $arData['EndDate']));
                         $arData['RecurrenceData']['EVENT_LENGTH'] = $time_end - $arData['EventDate'];
                         break;
                 }
                 $obWhile = $obRule->children[2];
                 if ($obWhile->name == 'repeatForever') {
                     $arData['EndDate'] = MakeTimeStamp('');
                 } elseif ($obWhile->name == 'windowEnd') {
                     $arData['EndDate'] = $this->__makeTS($obWhile->textContent());
                 }
             }
             $TZBias = $arData['fAllDayEvent'] ? 0 : $TZBias;
             $arData['EventDate'] += $TZBias;
             $arData['EndDate'] += $TZBias;
             $arRes = array('iblockId' => $obCalendar->iblockId, 'ownerType' => $obCalendar->ownerType, 'ownerId' => $obCalendar->ownerId, 'RMiblockId' => $this->__getRMIblockID(), 'allowResMeeting' => true, 'bNew' => $arData['_command'] == 'New', 'fullUrl' => $obCalendar->fullUrl, 'userId' => $obCalendar->userId, 'pathToUserCalendar' => $obCalendar->pathToUserCalendar, 'pathToGroupCalendar' => $obCalendar->pathToGroupCalendar, 'userIblockId' => $obCalendar->userIblockId, 'calendarId' => $arSection['ID'], 'sectionId' => $arSection['IBLOCK_SECTION_ID'], 'dateFrom' => ConvertTimeStamp($arData['EventDate'], 'FULL'), 'dateTo' => ConvertTimeStamp($arData['EndDate'], 'FULL'), 'name' => $arData['Title'], 'desc' => $arData['Description'], 'prop' => array('ACCESSIBILITY' => $arStatusValues[$arData['MetaInfo_BusyStatus']], 'IMPORTANCE' => $arPriorityValues[$arData['MetaInfo_Priority']]), 'notDisplayCalendar' => true, 'location' => array('new' => CEventCalendar::ParseLocation($arData['Location'])));
             if ($arData['fRecurrence']) {
                 $arRes['prop']['PERIOD_TYPE'] = $arData['RecurrenceData']['PERIOD_TYPE'];
                 $arRes['prop']['PERIOD_COUNT'] = $arData['RecurrenceData']['PERIOD_COUNT'];
                 $arRes['prop']['EVENT_LENGTH'] = $arData['RecurrenceData']['EVENT_LENGTH'];
                 $arRes['prop']['PERIOD_ADDITIONAL'] = $arData['RecurrenceData']['PERIOD_ADDITIONAL'];
             }
             if ($arData['_command'] == 'New') {
                 $arRes['bNew'] = true;
             } else {
                 $arRes['id'] = $arData['ID'];
             }
             if (!$arRes['bNew']) {
                 if ($arOldEvent = $obCalendar->GetEvents(array('ownerType' => 'USER', 'ownerId' => $arSection['CREATED_BY'], 'bOwner' => true, 'iblockId' => $arSection['IBLOCK_ID'], 'sectionId' => $arSection['ID'], 'eventId' => $arRes['id'], 'arCalendarIds' => array($arSection['ID']), 'forExport' => true))) {
                     $arOldEvent = $arOldEvent[0];
                     $arRes['prop']['VERSION'] = $arOldEvent['VERSION'];
                     if ($arOldEvent['LOCATION']) {
                     }
                     $arRes['location']['old'] = CEventCalendar::ParseLocation($arOldEvent['LOCATION']);
                     if ($arRes['location']['old']['mrid']) {
                         $arRes['location']['new'] = 'ECMR_' . $arRes['location']['old']['mrid'];
                         $arRes['prop']['VERSION']++;
                     }
                     $bMaster = true;
                     if (is_array($arOldEvent['GUESTS']) && count($arOldEvent['GUESTS']) > 0) {
                         $arRes['GUESTS'] = array();
                         foreach ($arOldEvent['GUESTS'] as $arGuest) {
                             $arRes['GUESTS'][] = $arGuest['id'];
                         }
                     }
                     if (is_array($arOldEvent['HOST'])) {
                         $bMaster = false;
                         $arRes['prop']['PARENT'] = $arOldEvent['HOST']['parentId'];
                     }
                     if (!$bMaster) {
                         $arRes['name'] = $arOldEvent['NAME'];
                         $arRes['desc'] = $arOldEvent['DETAIL_TEXT'];
                         $arRes['dateFrom'] = $arOldEvent['DATE_FROM'];
                         $arRes['dateTo'] = $arOldEvent['DATE_TO'];
                         if (is_array($arOldEvent['PERIOD'])) {
                             $arRes['prop']['PERIOD_TYPE'] = $arOldEvent['PERIOD']['TYPE'];
                             $arRes['prop']['PERIOD_COUNT'] = $arOldEvent['PERIOD']['COUNT'];
                             $arRes['prop']['EVENT_LENGTH'] = $arOldEvent['PERIOD']['LENGTH'];
                             $arRes['prop']['PERIOD_ADDITIONAL'] = $arOldEvent['PERIOD']['DAYS'];
                         } else {
                             unset($arRes['prop']['PERIOD_TYPE']);
                             unset($arRes['prop']['PERIOD_COUNT']);
                             unset($arRes['prop']['EVENT_LENGTH']);
                             unset($arRes['prop']['PERIOD_ADDITIONAL']);
                         }
                     } else {
                         if (is_array($arOldEvent['PERIOD']) && !$arData['RecurrenceData'] && $arData['EventType'] == 1) {
                             $arRes['dateFrom'] = $arOldEvent['DATE_FROM'];
                             $arRes['dateTo'] = $arOldEvent['DATE_TO'];
                             $arRes['prop']['PERIOD_TYPE'] = $arOldEvent['PERIOD']['TYPE'];
                             $arRes['prop']['PERIOD_COUNT'] = $arOldEvent['PERIOD']['COUNT'];
                             $arRes['prop']['EVENT_LENGTH'] = $arOldEvent['PERIOD']['LENGTH'];
                             $arRes['prop']['PERIOD_ADDITIONAL'] = $arOldEvent['PERIOD']['DAYS'];
                         }
                     }
                 } else {
                     return new CSoapFault('Event not found', 'Event ' . $arRes['id'] . ' not found on server');
                 }
             }
             if (is_array($arRes['location']['old'])) {
                 $arRes['location']['old'] = $arRes['location']['old']['str'];
             }
             if (is_array($arRes['location']['new'])) {
                 $arRes['location']['new'] = $arRes['location']['new']['str'];
             }
             if ($EventID = $obCalendar->SaveEvent($arRes)) {
                 CEventCalendar::ClearCache('/event_calendar/events/' . $arRes['iblockId'] . '/');
                 // dirty hack
                 $arReplicationIDs[$EventID] = $arData['MetaInfo_ReplicationID'];
                 $arResponseRows[$EventID] = new CXMLCreator('Result');
                 $arResponseRows[$EventID]->setAttribute('ID', $obMethod->getAttribute('ID') . ',' . $arData['_command']);
                 $arResponseRows[$EventID]->setAttribute('List', $listName);
                 $arResponseRows[$EventID]->addChild($obNode = new CXMLCreator('ErrorCode'));
                 $obNode->setData('0x00000000');
                 //$arResponseRows[$EventID]->setAttribute('Version', 3);
             }
         }
     }
     $arMethodParams = array('ownerType' => 'USER', 'ownerId' => is_object($USER) && $USER->GetID() ? $USER->GetID() : false, 'iblockId' => $arSection['IBLOCK_ID'], 'sectionId' => $arSection['ID'], 'arCalendarIds' => array($arSection['ID']), 'forExport' => true, 'bLoadAll' => false, 'timestampFrom' => $dateStart);
     $arCalendarEntries = $obCalendar->GetEvents($arMethodParams);
     foreach ($arCalendarEntries as $arEntry) {
         if ($arResponseRows[$arEntry['ID']]) {
             $obRow = $this->__getRow($arEntry, $listName, $last_change = 0);
             $obRow->setAttribute('xmlns:z', "#RowsetSchema");
             if ($arReplicationIDs[$arEntry['ID']]) {
                 $obRow->setAttribute('MetaInfo_ReplicationID', $arReplicationIDs[$arEntry['ID']]);
             }
             $arResponseRows[$arEntry['ID']]->addChild($obRow);
         }
         $obResponse->addChild($arResponseRows[$arEntry['ID']]);
     }
     return array('UpdateListItemsResult' => $obResponse);
 }