CAdvContract::Set
int CAdvContract::Set( array arFields, int CONTRACT_ID="", char(1) CHECK_RIGHTS="Y" );
The method Set creates a new contract, or modifies the existing one if a valid contract ID is passed in the second parameter. Returns the ID of the created contract, or the ID of the modified contract.
Parameters
- arFields
- An array of the contract parameters. The following keys are possible
in this array:
- ACTIVE - active state flag: if "Y", the contract is active, if "N" the contract is inactive;
- NAME - contract name;
- DESCRIPTION - contract description;
- ADMIN_COMMENTS - administrative comment;
- WEIGHT - contract weight (priority);
- SORT - sort order;
- MAX_SHOW_COUNT - the maximum total number of all the contract banner shows;
- MAX_CLICK_COUNT - the maximum total number of all the contract banner clicks;
- DATE_SHOW_FROM - the date banner shows commenced;
- DATE_SHOW_TO - the date banner shows stopped;
- DEFAULT_STATUS_SID - the default status for creating new banners; it is also set when the visual aspect of the existing ones becomes modified. The following values are possible:
- PUBLISHED - the banner is approved and published;
- READY - the banner is being reviewed;
- REJECTED - the banner is rejected.
- arrSHOW_PAGE - array of pages and sections of the site on which contract banners are to be shown;
- arrNOT_SHOW_PAGE - array of pages and sections of the site on which contract banners cannot be shown;
- arrTYPE - array of available banner types;
- arrWEEKDAY - array describing time and days of week for the banner show. The following keys are possible in this array:
- SUNDAY - array of hours on which the banner is to be shown on Sunday (0-23);
- MONDAY - the same on Monday;
- TUESDAY - on Tuesday;
- WEDNESDAY - on Wednesday;
- THURSDAY - on Thursday;
- FRIDAY - on Friday;
- SATURDAY - on Saturday.
- arrUSER_VIEW - array of the ID of users who can view parameters, banners and charts of a contract;
- arrUSER_ADD - array of the ID of users who can view contract parameters and manage banners;
- arrUSER_EDIT - array of the ID of users who can edit header and description of a contract, assign permissions and manage banners.
- CONTRACT_ID
- The ID of an existing contract. If omitted, a new contract is created.
- CHECK_RIGHTS
- Flag indicating that the current user permissions should be checked. If "Y", the current user permissions should be checked. If "N", a contract can be created and modified disregarding the current user permissions.
Example
// The following example adds a new contract // or modifies the existing one: <? if ((strlen($save)>0 || strlen($apply)>0) && $REQUEST_METHOD=="POST") { $arrWEEKDAY = array( "SUNDAY" => $arrSUNDAY, "MONDAY" => $arrMONDAY, "TUESDAY" => $arrTUESDAY, "WEDNESDAY" => $arrWEDNESDAY, "THURSDAY" => $arrTHURSDAY, "FRIDAY" => $arrFRIDAY, "SATURDAY" => $arrSATURDAY ); $arFields = array( "ACTIVE" => $ACTIVE, "NAME" => $NAME, "DESCRIPTION" => $DESCRIPTION, "ADMIN_COMMENTS" => $ADMIN_COMMENTS, "WEIGHT" => $WEIGHT, "SORT" => $SORT, "MAX_SHOW_COUNT" => $MAX_SHOW_COUNT, "MAX_CLICK_COUNT" => $MAX_CLICK_COUNT, "DATE_SHOW_FROM" => $DATE_SHOW_FROM, "DATE_SHOW_TO" => $DATE_SHOW_TO, "DEFAULT_STATUS_SID" => $DEFAULT_STATUS_SID, "arrSHOW_PAGE" => split("[\n\r]",$SHOW_PAGE), "arrNOT_SHOW_PAGE" => split("[\n\r]",$NOT_SHOW_PAGE), "arrTYPE" => $arrTYPE, "arrWEEKDAY" => $arrWEEKDAY, "arrUSER_VIEW" => $arrUSER_VIEW, "arrUSER_ADD" => $arrUSER_ADD, "arrUSER_EDIT" => $arrUSER_EDIT ); if ($ID = CAdvContract::Set($arFields, $ID)) { if (strlen($strError)<=0) { if (strlen($save) > 0) LocalRedirect("adv_contract_list.php?lang=".LANG); else LocalRedirect("adv_contract_edit.php?ID=".$ID."〈=".LANG); } } $DB->PrepareFields("b_adv_contract"); } ?>
© «Bitrix24», 2001-2024