Ejemplo n.º 1
0
 function WF_IsLocked($ID, &$locked_by, &$date_lock)
 {
     if (CIBlockElement::WF_GetLockStatus($ID, $locked_by, $date_lock) == "red") {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
if (isset($_REQUEST["ACTION"]) && in_array($_REQUEST["ACTION"], array("LOCK", "UNLOCK"))) {
    if (!check_bitrix_sessid()) {
        $APPLICATION->RestartBuffer();
        CUtil::PhpToJSObject(array("result" => "reload"));
        die;
    }
    $options = array("element_id" => $arParams["ELEMENT_ID"], "scope" => "exclusive", "type" => "write", "owner" => $GLOBALS["USER"]->GetLogin());
    if ($_REQUEST["ACTION"] === "LOCK") {
        $res = $ob->LOCK($options);
        $success = intval($res) === 200;
    } elseif ($_REQUEST["ACTION"] === "UNLOCK") {
        $res = $ob->UNLOCK($options);
        $success = intval($res) === 204;
    }
    $res = array();
    $res["LOCK_STATUS"] = CIBlockElement::WF_GetLockStatus($arParams["ELEMENT_ID"], $res['WF_LOCKED_BY'], $res['WF_DATE_LOCK']);
    $lockTill = FormatDate(array("today" => "H:i", "" => preg_replace('/:s$/', '', $DB->DateFormatToPHP(CSite::GetDateFormat("FULL")))), MakeTimeStamp($res['WF_DATE_LOCK']) + 60 * intval(COption::GetOptionString("workflow", "MAX_LOCK_TIME", "60")));
    $status = '';
    if ($res["LOCK_STATUS"] != "green") {
        if ($res['WF_LOCKED_BY'] == $USER->GetID()) {
            $res['LOCKED_USER_NAME'] = $USER->GetFormattedName(false);
        } else {
            $rUser = $USER->GetByID($res["WF_LOCKED_BY"]);
            $arUser = $rUser->Fetch();
            $res['LOCKED_USER_NAME'] = $arUser["NAME"] . (strlen($arUser["NAME"]) <= 0 || strlen($arUser["LAST_NAME"]) <= 0 ? "" : " ") . $arUser["LAST_NAME"];
        }
        $status .= '<div class="element-status-' . $res['LOCK_STATUS'] . '">';
        if ($res['LOCK_STATUS'] == "yellow") {
            $status .= '[' . GetMessage("IBLOCK_YELLOW_MSG", array('#DATE#' => $lockTill)) . ']';
        } else {
            $status .= '[' . GetMessage("IBLOCK_RED_MSG", array('#NAME#' => htmlspecialcharsbx($res['LOCKED_USER_NAME']))) . ']';
Ejemplo n.º 3
0
    /** @var \Bitrix\Disk\File $diskFile */
    $diskFile = \Bitrix\Disk\File::load(array('XML_ID' => $arResult['ELEMENT']['ID']), array('STORAGE'));
    if ($diskFile) {
        LocalRedirect(\Bitrix\Disk\Driver::getInstance()->getUrlManager()->getPathFileDetail($diskFile));
    }
}
$ob->_get_file_info_arr($arResult["ELEMENT"]);
$arResult["WRITEABLE"] = $arResult['ELEMENT']['SHOW']['EDIT'];
if (in_array($arParams["ACTION"], array("EDIT", "PULL")) && $arParams["DOCUMENT_LOCK"] != "N") {
    CIBlockElement::WF_Lock($arParams["ELEMENT_ID"], $ob->workflow == "workflow");
    /**
     * This part of code is necessary because info about element is got
     * already but information about locking is absent. We can not lock
     * element until check all rulles.
     */
    $arResult["ELEMENT"]["LOCK_STATUS"] = CIBlockElement::WF_GetLockStatus($arParams["ELEMENT_ID"], $arResult['ELEMENT']['WF_LOCKED_BY'], $arResult['ELEMENT']['WF_DATE_LOCK']);
}
/********************************************************************
				Default params
********************************************************************/
CJSCore::Init(array('viewer'));
__prepare_item_info($arResult["ELEMENT"], $arParams);
$arResult["ELEMENT"]['URL']['THIS'] = $ob->_uencode($arResult["ELEMENT"]['URL']['THIS'], array("utf8" => "Y", "convert" => $arParams["CONVERT"]));
$arError = array();
$bVarsFromForm = false;
$CHILD_ID = 0;
/************** Parent element *************************************/
$arResult["ELEMENT_ORIGINAL"] = array();
if (intVal($arResult["ELEMENT"]["WF_PARENT_ELEMENT_ID"]) > 0 && $arResult["ELEMENT"]["WF_PARENT_ELEMENT_ID"] != $arParams["ELEMENT_ID"]) {
    $db_res = CIBlockElement::GetList(array(), array("ID" => $arResult["ELEMENT"]["WF_PARENT_ELEMENT_ID"], "SHOW_NEW" => "Y"));
    if ($db_res && ($obElement = $db_res->GetNextElement())) {
Ejemplo n.º 4
0
 function DELETE($options)
 {
     $options["~path"] = $this->_udecode($options["path"]);
     WDUnpackCookie();
     if (isset($options['path'])) {
         $arPath = explode('/', $options['path']);
         // ms excel tries to create and delete ~\$FileName.xls
         $basename = array_pop($arPath);
         $basename = $this->CorrectName($this->_udecode($basename));
         array_push($arPath, $basename);
         $options['path'] = implode('/', $arPath);
     }
     if (!empty($options["~path"]) && $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] == $options["~path"]) {
         $this->IsDir($options);
         $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] = "";
         WDPackCookie();
         if (intVal($this->arParams["element_id"]) > 0) {
             $this->_ib_elm_delete($this->arParams["element_id"]);
             return "204 No Content";
         }
         return "404 Not Found";
     } else {
         $this->IsDir($options);
         //symlink logic
         list($contextType, $contextEntityId) = $this->getContextData();
         //we can't forward delete symlink. Only delete symlink section.
         $sectionData = $this->getSectionDataForLinkAnalyze($this->arParams['is_dir'] ? $this->arParams['dir_array']['ID'] : $this->arParams['element_array']['IBLOCK_SECTION_ID'], array(), false);
         if (CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData)) {
             //we don't enable symlink mode, because we move to real trash
             $parentSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData);
             if ($parentSectionData) {
                 $linkWebdav = new self($parentSectionData[self::UF_LINK_IBLOCK_ID], $this->base_url . $this->_path, array('ROOT_SECTION_ID' => $parentSectionData[self::UF_LINK_ROOT_SECTION_ID]));
                 return $linkWebdav->DELETE($options);
             } else {
                 return "404 Not Found";
             }
         }
         if (!$this->CheckWebRights("DELETE", array('action' => 'delete', 'arElement' => $this->arParams), false)) {
             return $this->ThrowAccessDenied(__LINE__);
         }
         $resLock = array();
         $lockedBy = $lockedDate = null;
         $resLock["LOCK_STATUS"] = CIBlockElement::WF_GetLockStatus($this->arParams["item_id"], $lockedBy, $lockedDate);
         if ($resLock['LOCK_STATUS'] == 'red' && !$GLOBALS['USER']->CanDoOperation('webdav_change_settings')) {
             return $this->ThrowAccessDenied(__LINE__);
         }
         //delete symlink. Not move to trash
         if (!empty($this->arParams['dir_array'][self::UF_LINK_SECTION_ID])) {
             $options['force'] = true;
         }
         if (!isset($options['force']) && ($this->arParams["is_dir"] === true || intval($this->arParams["element_id"]) > 0)) {
             if ($trashID = $this->GetMetaID("TRASH")) {
                 $item_id = $this->arParams['item_id'];
                 $arSectionsChain = array();
                 $bRootFounded = empty($this->arRootSection) ? true : false;
                 foreach (CWebDavSymlinkHelper::getNavChain($this->IBLOCK_ID, $this->arParams['parent_id']) as $res) {
                     if (!$bRootFounded && $res["ID"] == $this->arRootSection["ID"]) {
                         $bRootFounded = true;
                         continue;
                     }
                     if (!$bRootFounded) {
                         continue;
                     }
                     $arSectionsChain[] = $res["ID"];
                 }
                 if ($item_id == $trashID && $this->arParams["is_dir"]) {
                     if ($this->CheckWebRights("DESTROY", array('action' => 'destroy', 'arElement' => $this->arParams), false)) {
                         if (isset($this->attributes['user_id']) && $this->attributes['user_id'] == $GLOBALS['USER']->GetID()) {
                             //now we clean own bin so simple, so fast
                             $this->runCleaningTrash($trashID);
                         } else {
                             //old cleaning. So-so
                             $this->_delete_section($options["section_id"]);
                         }
                         $this->GetMetaID('TRASH');
                         // create
                         return "204 No Content";
                     } else {
                         return $this->ThrowAccessDenied(__LINE__);
                     }
                 } elseif (!in_array($trashID, $arSectionsChain) && strpos($this->arParams['file_name'], "_\$") !== 0) {
                     return $this->_move_to_trash($options);
                 }
             } else {
                 return "404 Not Found";
             }
         }
         $this->IsDir($options);
         if (!$this->CheckWebRights("DESTROY", array('action' => 'destroy', 'arElement' => $this->arParams), false)) {
             return $this->ThrowAccessDenied(__LINE__);
         }
         if ($this->arParams["is_dir"] === true) {
             if ($this->check_creator) {
                 return $this->ThrowAccessDenied(__LINE__);
             }
             if ($this->_delete_section($options["section_id"]) === true && !empty($this->arParams['dir_array'][self::UF_LINK_SECTION_ID]) && $this->attributes['user_id']) {
                 if (!empty($this->attributes['user_id'])) {
                     CWebDavDiskDispatcher::sendChangeStatus($this->attributes['user_id'], 'delete_symlink');
                 }
                 \Bitrix\Webdav\FolderInviteTable::deleteByFilter(array('=INVITE_USER_ID' => $this->attributes['user_id'], '=IS_APPROVED' => true, '=IBLOCK_ID' => $this->arParams['dir_array'][self::UF_LINK_IBLOCK_ID], '=SECTION_ID' => $this->arParams['dir_array'][self::UF_LINK_SECTION_ID]));
             }
         } elseif (intVal($this->arParams["element_id"]) > 0) {
             CWebDavDiskDispatcher::addElementForDeletingMark($this->arParams['element_array'], null, false);
             $el = new CIBlockElement();
             $this->_onEvent('Delete', $this->arParams["element_id"]);
             if ($this->_ib_elm_delete($this->arParams["element_id"])) {
                 CWebDavDiskDispatcher::markDeleteBatch();
                 CWebDavDiskDispatcher::sendEventToOwners($this->arParams['element_array'], null, 'force_delete_element');
             } else {
                 CWebDavDiskDispatcher::clearDeleteBatch();
             }
         } else {
             return "404 Not Found";
         }
         if ($_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] == $options["~path"]) {
             $_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] = "";
         }
     }
     return "204 No Content";
 }