Documentation

Set

mixed
CFormStatus::Set(
 array fields,
 mixed status_id = false,
 string check_rights = "Y"
)

The method Set adds a new status or modifies the existing one. Returns the ID of the modified or added status on success, or false otherwise.

Parameters

fields Array of values which accept the following keys:
  • FORM_ID* - the webform ID;
  • TITLE* - status title;
  • C_SORT - sort order;
  • ACTIVE - active state flag. The following values are possible:
    • Y - the answer is active;
    • N - the answer is inactive (by default).
  • DESCRIPTION - status description;
  • CSS - name of the CSS class to display the status title;
  • HANDLER_OUT - path relative to the root to the handler called when changing this result statusto another;
  • HANDLER_IN - path relative to the rootto the handler called when changing a result status to this;
  • DEFAULT_VALUE - flag indicating the status is default. The following values are possible:
    • Y - status is default;
    • N - status is not default (by default).
  • arPERMISSION_VIEW* - array containing the ID's of user groups having the permission "View results in this status";
  • arPERMISSION_MOVE* - array containing the ID's of user groups having the permission "Change results to this status";
  • arPERMISSION_EDIT* - array containing the ID's of user groups having the permission "Edit results in this status";
  • arPERMISSION_DELETE* - array containing the ID's of user groups having the permission "Delete results in this status".

* - required.
* - these arrays may have values of "0"which means the result creator.
status_id The ID of the modified status.
Optional. False by default (adds a new status).
check_rights Flag specifying the current user permissions should be checked. One of the following values is possible:
  • Y - permissions should be checked;
  • N - no checks need to be performed.
To modify a status or create a new one, you should have the permission [30] Full access for the form specified in fields["FORM_ID"].

Optional. "Y" by default which means the permissions should be checked.

See Also

Example



<?
$FORM_ID = 4; // The web form ID

$arFields = array(
    "FORM_ID"             => $FORM_ID,               // The web form ID
    "C_SORT"              => 100,                    // sort order
    "ACTIVE"              => "Y",                    // status is active
    "TITLE"               => "Published",            // status title
    "DESCRIPTION"         => "Final status",         // status description
    "CSS"                 => "statusgreen",          // CSS class
    "HANDLER_OUT"         => "",                     // handler
    "HANDLER_IN"          => "",                     // handler
    "DEFAULT_VALUE"       => "N",                    // not default
    "arPERMISSION_VIEW"   => array(2),               // view permission for all
    "arPERMISSION_MOVE"   => array(),                // move permission for admins only
    "arPERMISSION_EDIT"   => array(),                // edit permission for admins
    "arPERMISSION_DELETE" => array(),                // delete permission for admins only
);

$NEW_ID = CFormStatus::Set($arFields);
if ($NEW_ID>0) echo "The ID=".$NEW_ID has been added;
else // error
{
    // display the error description
    global $strError;
    echo $strError;
}
?>
© «Bitrix24», 2001-2024