Documentation

Set

int
CAdvBanner::Set(
 array arFields,
 int BANNER_ID="",
 char(1) CHECK_RIGHTS="Y"
);

The Set method creates a new or modifies an existing banner. To modify an existing banner, pass the banner ID in the second parameter. Non-static method.

Parameters

ParameterDescription
arFields Array containing the banner parameters. The following array keys are possible:
  • CONTRACT_ID - contract ID (required for a new banner)
  • TYPE_SID - symbolic code of a banner type
  • STATUS_SID - symbolic status code; can be one of the following :
    • PUBLISHED - a banner is approved and published;
    • READY - a banner is still on approval;
    • REJECTED - a banner is rejected.
  • STATUS_COMMENTS - comments for the status
  • NAME - banner name
  • GROUP_SID - name of a banner group
  • ACTIVE - active state: "Y" - banner is active; "N" - banner is inactive;
  • LID - code of the site to display the banner
  • WEIGHT - banner weight
  • MAX_SHOW_COUNT - maximum shows
  • RESET_SHOW_COUNT - indicates that the shows counter is to be reset; the contract counter will decrements accordingly
  • MAX_CLICK_COUNT - maximum clicks
  • RESET_CLICK_COUNT - indicates that the clicks counter is to be reset; the contract counter will decrements accordingly
  • DATE_SHOW_FROM - the date of the first show
  • DATE_SHOW_TO - the date of the last show
  • arrIMAGE - array that describes the image to load; the following array keys are possible:
    • name - image file name
    • type - MIME type of a file (e.g.: "image/gif")
    • tmp_name - name of the temporary file on server
    • error - error code ("0" means no error)
    • size - file size
    • MODULE_ID - module identifier ("advertising")
  • IMAGE_ALT - image tooltip text
  • URL - link which is opened upon click on a banner. This field can contain the template #EVENT_GID# that is replaced upon click with the visitor ID used in the Statistics module
  • URL_TARGET - value of the target attribute of the tag <a>:
    • _blank - specifies to load the link into a new blank window. This window is not named.
    • _parent - specifies to load the link into the immediate parent of the document the link is in.
    • _self - specifies to load the link into the same window the link was clicked in.
    • _top - specifies to load the link into the full body of the window.
  • CODE - HTML code of the banner, or banner text
  • CODE_TYPE - type of the banner code: "text" for plain text; "html" for HTML;
  • STAT_EVENT_1 - event type identifier "event1" (for registration in the Statistics module)
  • STAT_EVENT_2 - event type identifier "event2"
  • STAT_EVENT_3 - auxiliary event type identifier "event3". The identifiers event1, event2, event3 allow the following templates:
    • #BANNER_NAME# - banner name
    • #BANNER_ID# - banner ID
    • #CONTRACT_ID# - contract ID
    • #TYPE_SID# - banner type
  • FOR_NEW_GUEST - if set to "Y", the banner is to be shown to new visitors solely; if "N", the banner is shown to all visitors
  • COMMENTS - banner comments
  • arrSHOW_PAGE - array of pages and sections of the site where the banner is allowed to be shown
  • arrNOT_SHOW_PAGE - array of pages and sections of the site where the banner is disallowed to be shown
  • arrCOUNTRY - array of two-character country codes. Describes countries whose visitors the banner is allowed to be shown to.
  • arrSTAT_ADV - array of the advertising campaign identifiers. Describes campaigns whose visitors, both direct and returned, the banner is allowed to be shown to.
  • arrWEEKDAY - array with days of week and time when the banner is to be displayed. The following keys are possible:
    • SUNDAY - array of hours when the banner is to be displayed on Sunday (0-23)
    • MONDAY - on Monday
    • TUESDAY - on Tuesday
    • WEDNESDAY - on Wednesday
    • THURSDAY - on Thursday
    • FRIDAY - on Friday
    • SATURDAY - on Saturday
  • SEND_EMAIL - indicates that the e-mail message is to be sent to contract owners upon change of the banner status.
BANNER_ID Banner ID. If omitted, a new banner is created.
CHECK_RIGHTS Indicates to check the current user permissions. If "Y", permissions are checked before the creation or modification of a banner. If set to "N", the method creates or modifies a banner disregarding permissions.

Returned value

Returns the ID of a new or modified banner.

Example


// This code adds a new banner or modifies the existing one
<?
if ((strlen($save)>0 || strlen($apply)>0) && $REQUEST_METHOD=="POST")
{
    InitBVar($SEND_EMAIL);
    $arrIMAGE_ID = $HTTP_POST_FILES["IMAGE_ID"];
    $arrIMAGE["MODULE_ID"] = "advertising";
    $arrIMAGE_ID["del"] = ${"IMAGE_ID_del"};
    $arrWEEKDAY = array(
        "SUNDAY"    => $arrSUNDAY,
        "MONDAY"    => $arrMONDAY,
        "TUESDAY"   => $arrTUESDAY,
        "WEDNESDAY" => $arrWEDNESDAY,
        "THURSDAY"  => $arrTHURSDAY,
        "FRIDAY"    => $arrFRIDAY,
        "SATURDAY"  => $arrSATURDAY
        );
    if ($action=="view" && $isAbsAdmin)
    {
         $arFields = array(
            "STATUS_SID"        => $STATUS_SID,
            "STATUS_COMMENTS"   => $STATUS_COMMENTS
            );
    }
    else
    {
         $arFields = array(
            "CONTRACT_ID"       => $CONTRACT_ID,
            "TYPE_SID"          => $TYPE_SID,
            "STATUS_SID"        => $STATUS_SID,
            "STATUS_COMMENTS"   => $STATUS_COMMENTS,
            "NAME"              => $NAME,
            "GROUP_SID"         => $GROUP_SID,
            "ACTIVE"            => $ACTIVE,
            "LID"               => $LID,
            "WEIGHT"            => $WEIGHT,
            "MAX_SHOW_COUNT"    => $MAX_SHOW_COUNT,
            "RESET_SHOW_COUNT"  => $RESET_SHOW_COUNT,
            "MAX_CLICK_COUNT"   => $MAX_CLICK_COUNT,
            "RESET_CLICK_COUNT" => $RESET_CLICK_COUNT,
            "DATE_SHOW_FROM"    => $DATE_SHOW_FROM,
            "DATE_SHOW_TO"      => $DATE_SHOW_TO,
            "arrIMAGE_ID"       => $arrIMAGE_ID,
            "IMAGE_ALT"         => $IMAGE_ALT,
            "URL"               => $URL,
            "URL_TARGET"        => $URL_TARGET,
            "CODE"              => $CODE,
            "CODE_TYPE"         => $CODE_TYPE,
            "STAT_EVENT_1"      => $STAT_EVENT_1,
            "STAT_EVENT_2"      => $STAT_EVENT_2,
            "STAT_EVENT_3"      => $STAT_EVENT_3,
            "FOR_NEW_GUEST"     => $FOR_NEW_GUEST,
            "COMMENTS"          => $COMMENTS,
            "arrSHOW_PAGE"      => split("[\n\r]",$SHOW_PAGE),
            "arrNOT_SHOW_PAGE"  => split("[\n\r]",$NOT_SHOW_PAGE),
            "arrCOUNTRY"        => $arrCOUNTRY,
            "arrSTAT_ADV"       => $arrSTAT_ADV,
            "arrWEEKDAY"        => $arrWEEKDAY,
            "SEND_EMAIL"        => $SEND_EMAIL
            );
    }
    if ($ID = CAdvBanner::Set($arFields, $ID))
    {
        if (strlen($strError) <= 0)
        {
             if (strlen($save) > 0)
                 LocalRedirect("adv_banner_list.php?lang=".LANG);
             else
                 LocalRedirect(
                     "adv_banner_edit.php?ID=".$ID."&CONTRACT_ID=".$CONTRACT_ID."=".LANG."&action=".$action);
        }
    }
    $DB->PrepareFields("b_adv_banner");
}
?>
© «Bitrix24», 2001-2024
Up