if($userIsAdmin && !empty($_REQUEST['element']) && $formSubmitted) // form submitted, handling it { $saveAsId = intval($_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 // $actionApply : do nothing } } else // new or copyed item { $res = Helper::add($_REQUEST['element']); if($res['success']) // on successfull add ... { if($actionSave)
##################################### global $DB; if($lAdmin->EditAction() && $userIsAdmin) { foreach($FIELDS as $id => $arFields) { $DB->StartTransaction(); if(!$lAdmin->IsUpdated($id)) // if there were no data change on this row - do nothing with it continue; try { $res = Helper::update($id, $arFields); if(!empty($res['errors'])) { foreach($res['errors'] as &$error) $error = ' '.$error; unset($error); throw new Main\SystemException(implode(',<br />', $res['errors'])); } } catch(Main\SystemException $e) { // todo: do smth $lAdmin->AddUpdateError(Loc::getMessage('SALE_LOCATION_L_ITEM_SAVE_ERROR', array('#ITEM#' => $id)).": <br />".$e->getMessage().'<br />', $id); $DB->Rollback();