コード例 #1
0
	#### ACTIONS: update
	#####################################

	$actionFailure = false;

	$id = strlen($_REQUEST['id']) ? Helper::tryParseSiteId($_REQUEST['id']) : false;

	$actionSave = isset($_REQUEST['save']);
	$actionApply = isset($_REQUEST['apply']);
	$formSubmitted = ($actionSave || $actionApply) && check_bitrix_sessid();

	$returnUrl = strlen($_REQUEST['return_url']) ? $_REQUEST['return_url'] : false;

	if($userIsAdmin && !empty($_REQUEST['element']) && $formSubmitted) // form submitted, handling it
	{
		$saveAsId = Helper::tryParseSiteId($_REQUEST['element']['ID']);

		global $DB;
		$redirectUrl = false;

		try
		{
			$DB->StartTransaction();

			if($saveAsId) // existed, updating
			{
				$res = Helper::update($saveAsId, $_REQUEST['element']);
				if($res['success']) // on successfull update ...
				{
					if($actionSave)
						$redirectUrl = $returnUrl ? $returnUrl : Helper::getListUrl(); // go to the page of just created item