Example #1
0
 }
 if ($arParams["SET_NAV_CHAIN"] == "Y") {
     $APPLICATION->AddChainItem($arBlog["NAME"], CComponentEngine::MakePathFromTemplate(htmlspecialcharsback($arParams["PATH_TO_BLOG"]), array("blog" => $arBlog["URL"], "user_id" => $arPost["AUTHOR_ID"], "group_id" => $arParams["SOCNET_GROUP_ID"])));
 }
 $cache = new CPHPCache();
 $arCacheID = array();
 $arKeys = array("MOBILE", "USE_CUT", "PATH_TO_SMILE", "ATTACHED_IMAGE_MAX_WIDTH_SMALL", "ATTACHED_IMAGE_MAX_HEIGHT_SMALL", "ATTACHED_IMAGE_MAX_WIDTH_FULL", "ATTACHED_IMAGE_MAX_HEIGHT_FULL", "POST_PROPERTY", "PATH_TO_USER", "PATH_TO_POST", "PATH_TO_GROUP", "PATH_TO_SEARCH_TAG", "IMAGE_MAX_WIDTH", "IMAGE_MAX_HEIGHT", "DATE_TIME_FORMAT", "DATE_TIME_FORMAT_S", "ALLOW_POST_CODE", "AVATAR_SIZE_COMMENT", "NAME_TEMPLATE", "SHOW_LOGIN");
 foreach ($arKeys as $param_key) {
     $arCacheID[$param_key] = array_key_exists($param_key, $arParams) ? $arParams[$param_key] : false;
 }
 $cache_id = "blog_socnet_post_" . md5(serialize($arCacheID)) . "_" . LANGUAGE_ID . "_" . $arParams["DATE_TIME_FORMAT"];
 if ($arResult["TZ_OFFSET"] != 0) {
     $cache_id .= "_" . $arResult["TZ_OFFSET"];
 }
 if (!empty($arParams["MOBILE"]) && $arParams["MOBILE"] == "Y" && CModule::IncludeModule('mobile')) {
     $imageResizeWidth = CMobileHelper::getDeviceResizeWidth();
     if ($imageResizeWidth) {
         $cache_id .= "_" . $imageResizeWidth;
     }
 }
 $cache_path = "/blog/socnet_post/" . intval($arPost["ID"] / 100) . "/" . $arPost["ID"] . "/";
 if ($arParams["CACHE_TIME"] > 0 && $cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path)) {
     $Vars = $cache->GetVars();
     $arResult["POST_PROPERTY"] = $Vars["POST_PROPERTY"];
     $arResult["Post"] = $Vars["Post"];
     $arResult["images"] = $Vars["images"];
     $arResult["Category"] = $Vars["Category"];
     $arResult["GRATITUDE"] = $Vars["GRATITUDE"];
     $arResult["POST_PROPERTIES"] = $Vars["POST_PROPERTIES"];
     $arResult["arUser"] = $Vars["arUser"];
     CBitrixComponentTemplate::ApplyCachedData($Vars["templateCachedData"]);
Example #2
0
 public static function getUFForPostForm($arParams)
 {
     $arFileData = array();
     $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($arParams["ENTITY_TYPE"], $arParams["ENTITY_ID"], LANGUAGE_ID);
     $ufCode = $arParams["UF_CODE"];
     if (!empty($arUF[$ufCode]) && !empty($arUF[$ufCode]["VALUE"])) {
         if ($arParams["IS_DISK_OR_WEBDAV_INSTALLED"]) {
             if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::IncludeModule('disk')) {
                 $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager();
                 $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
                 $userFieldManager->loadBatchAttachedObject($arUF[$ufCode]["VALUE"]);
                 foreach ($arUF[$ufCode]["VALUE"] as $attachedId) {
                     $attachedObject = $userFieldManager->getAttachedObjectById($attachedId);
                     if ($attachedObject) {
                         $file = $attachedObject->getObject();
                         $fileName = $file->getName();
                         $fileUrl = $urlManager->getUrlUfController('download', array('attachedId' => $attachedId));
                         $fileUrl = str_replace("/bitrix/tools/disk/uf.php", SITE_DIR . "mobile/ajax.php", $fileUrl);
                         $fileUrl = $fileUrl . (strpos($fileUrl, "?") === false ? "?" : "&") . "mobile_action=disk_uf_view&filename=" . $fileName;
                         if (\Bitrix\Disk\TypeFile::isImage($file) && ($realFile = $file->getFile())) {
                             $previewImageUrl = $urlManager->getUrlUfController('show', array('attachedId' => $attachedId, 'width' => 144, 'height' => 144, 'exact' => 'Y', 'signature' => \Bitrix\Disk\Security\ParameterSigner::getImageSignature($attachedId, 144, 144)));
                         } else {
                             $previewImageUrl = false;
                         }
                         $icon = CMobileHelper::mobileDiskGetIconByFilename($fileName);
                         $iconUrl = CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/' . $icon);
                         $fileFata = array('type' => $file->getExtension(), 'ufCode' => $ufCode, 'id' => $attachedId, 'extension' => $file->getExtension(), 'name' => $fileName, 'url' => $fileUrl, 'iconUrl' => $iconUrl);
                         if ($previewImageUrl) {
                             $fileFata['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                         }
                         $arFileData[] = $fileFata;
                     }
                 }
             } else {
                 $data = CWebDavIblock::getRootSectionDataForUser($GLOBALS["USER"]->GetID());
                 if (is_array($data)) {
                     $ibe = new CIBlockElement();
                     $dbWDFile = $ibe->GetList(array(), array('ID' => $arUF[$ufCode]["VALUE"], 'IBLOCK_ID' => $data["IBLOCK_ID"]), false, false, array('ID', 'IBLOCK_ID', 'PROPERTY_FILE'));
                     while ($arWDFile = $dbWDFile->Fetch()) {
                         if ($arFile = CFile::GetFileArray($arWDFile["PROPERTY_FILE_VALUE"])) {
                             if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                                 $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true);
                                 $previewImageUrl = $imageResized["src"];
                             } else {
                                 $previewImageUrl = false;
                             }
                             $fileExtension = GetFileExtension($arFile["FILE_NAME"]);
                             $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arWDFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'url' => $arFile["SRC"]);
                             if ($previewImageUrl) {
                                 $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                             }
                             $arFileData[] = $fileData;
                         }
                     }
                 }
             }
         } else {
             $dbRes = CFile::GetList(array(), array("@ID" => implode(",", $arUF[$ufCode]["VALUE"])));
             while ($arFile = $dbRes->GetNext()) {
                 if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                     $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true);
                     $previewImageUrl = $imageResized["src"];
                 } else {
                     $previewImageUrl = false;
                 }
                 $fileExtension = GetFileExtension($arFile["FILE_NAME"]);
                 $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'downloadUrl' => $arFile["SRC"]);
                 if ($previewImageUrl) {
                     $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                 }
                 $arFileData[] = $fileData;
             }
         }
     }
     return $arFileData;
 }
Example #3
0
         $log_entity_type = $arLog["ENTITY_TYPE"];
         $arListParams = strpos($log_entity_type, "CRM") === 0 && IsModuleInstalled("crm") ? array("IS_CRM" => "Y", "CHECK_CRM_RIGHTS" => "Y") : array("CHECK_RIGHTS" => "Y", "USE_SUBSCRIBE" => "N");
     } else {
         $log_id = 0;
     }
     if ($log_id > 0 && ($rsLog = CSocNetLog::GetList(array(), array("ID" => $log_id), false, false, array(), $arListParams)) && ($arLog = $rsLog->Fetch())) {
         $rsComment = CSocNetLogComments::GetList(array(), array("ID" => $comment_id), false, false, array("ID", "USER_ID", "MESSAGE"));
         if ($arComment = $rsComment->Fetch()) {
             if ($arComment["USER_ID"] == $GLOBALS["USER"]->GetId()) {
                 $arResult["CommentCanEdit"] = 'Y';
             }
             $arResult["CommentDetailText"] = htmlspecialcharsback($arComment["MESSAGE"]);
             $bDiskOrWebDavInstalled = IsModuleInstalled('disk') || IsModuleInstalled('webdav');
             $ufCode = $bDiskOrWebDavInstalled ? "UF_SONET_COM_DOC" : "UF_SONET_COM_FILE";
             $arResult["CommentUFCode"] = $ufCode;
             $arResult["CommentFiles"] = CMobileHelper::getUFForPostForm(array("ENTITY_TYPE" => "SONET_COMMENT", "ENTITY_ID" => $comment_id, "UF_CODE" => $ufCode, "IS_DISK_OR_WEBDAV_INSTALLED" => $bDiskOrWebDavInstalled));
         }
     }
 } elseif ($action == "get_comments") {
     $arResult["arComments"] = array();
     $log_tmp_id = $_REQUEST["logid"];
     $last_comment_id = intval($_REQUEST["last_comment_id"]);
     $last_comment_ts = intval($_REQUEST["last_comment_ts"]);
     if ($arLog = CSocNetLog::GetByID($log_tmp_id)) {
         $log_entity_type = $arLog["ENTITY_TYPE"];
         if (strpos($log_entity_type, "CRM") === 0 && IsModuleInstalled("crm")) {
             $arListParams = array("IS_CRM" => "Y", "CHECK_CRM_RIGHTS" => "Y");
         } else {
             $arListParams = array("CHECK_RIGHTS" => "Y", "USE_SUBSCRIBE" => "N");
         }
     } else {
Example #4
0
} else {
    $data = array('status' => 'not_found');
    return $data;
}
$urlManager = Driver::getInstance()->getUrlManager();
$currentFolderId = $urlManager->resolveFolderIdFromPath($storage, $path);
/** @var Folder $folder */
$folder = Folder::loadById($currentFolderId);
if (!$folder) {
    $data = array('status' => 'not_found');
    return $data;
}
$securityContext = $storage->getCurrentUserSecurityContext();
$items = array();
$countFolders = $countFiles = 0;
foreach ($folder->getChildren($securityContext) as $item) {
    /** @var File|Folder $item */
    $isFolder = $item instanceof Folder;
    if ($isFolder) {
        $icon = CMobileHelper::mobileDiskGetIconByFilename($item->getName());
        $items[] = array('NAME' => mobileDiskPrepareForJson($item->getName()), 'TABLE_URL' => SITE_DIR . 'mobile/index.php?' . '&mobile_action=' . 'disk_folder_list' . '&path=' . mobileDiskPrepareForJson($path . '/' . $item->getName()) . '&entityId=' . $entityId . '&type=' . $type, 'IMAGE' => CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/folder.png'), 'TABLE_SETTINGS' => array('type' => 'files', 'useTagsInSearch' => 'NO'));
        $countFolders++;
    } else {
        $icon = CMobileHelper::mobileDiskGetIconByFilename($item->getName());
        $items[] = array('ID' => $item->getId(), 'VALUE' => \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX . $item->getId(), 'NAME' => mobileDiskPrepareForJson($item->getName()), 'URL' => array('URL' => SITE_DIR . "mobile/ajax.php?mobile_action=disk_download_file&action=downloadFile&fileId={$item->getId()}&filename=" . mobileDiskPrepareForJson($item->getName()), 'EXTERNAL' => 'YES'), 'IMAGE' => CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/' . $icon), 'TAGS' => mobileDiskPrepareForJson(\CFile::FormatSize($item->getSize()) . ' ' . $item->getCreateTime()));
        $countFiles++;
    }
}
unset($item);
$data = array("data" => $items, "TABLE_SETTINGS" => array('footer' => mobileDiskPrepareForJson(Loc::getMessage('MD_DISK_TABLE_FOLDERS_FILES', array('#FOLDERS#' => $countFolders, '#FILES#' => $countFiles)))));
return $data;
Example #5
0
 if (!$moduleId || !IsModuleInstalled($moduleId)) {
     $moduleId = 'main';
 }
 $arFile = $_FILES["file"];
 $arFile["MODULE_ID"] = $moduleId;
 $res = '';
 if ($arParams["ALLOW_UPLOAD"] == "I") {
     $res = '' . CFile::CheckImageFile($arFile, $max_file_size, 0, 0);
 } elseif ($arParams["ALLOW_UPLOAD"] == "F") {
     $res = CFile::CheckFile($arFile, $max_file_size, false, $arParams["ALLOW_UPLOAD_EXT"]);
 } else {
     $res = CFile::CheckFile($arFile, $max_file_size, false, false);
 }
 $arPostResult = array();
 if ($res === '') {
     $arSaveResult = CMobileHelper::SaveFile($arFile, $arFileStorage);
     if ($arSaveResult && isset($arSaveResult["ID"])) {
         $varKey = isset($arParams["POST_ID"]) && intval($arParams["POST_ID"]) > 0 ? "MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId() . "_" . intval($arParams["POST_ID"]) : "MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId();
         if (!isset($_SESSION[$varKey])) {
             $_SESSION[$varKey] = array($arSaveResult["ID"]);
         } else {
             $_SESSION[$varKey][] = $arSaveResult["ID"];
         }
         if (!empty($arFileStorage["DISC_FOLDER"])) {
             $str_res = "disk_id:" . $arSaveResult["ID"];
         } elseif (!empty($arFileStorage["WEBDAV_DATA"]) && !empty($arFileStorage["WEBDAV_IBLOCK_OBJECT"])) {
             $str_res = "element_id:" . $arSaveResult["ID"];
         } else {
             $str_res = "file_id:" . $arSaveResult["ID"];
         }
     }
Example #6
0
                if ($perm >= BLOG_PERMS_MODERATE) {
                    if ($arComment["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
                        $arComment["CAN_HIDE"] = "Y";
                    } else {
                        $arComment["CAN_SHOW"] = "Y";
                    }
                } else {
                    $arComment["CAN_SHOW"] = $arComment["CAN_HIDE"] = "N";
                }
                $urlToPost = CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => "#source_post_id#", "user_id" => $arPost["AUTHOR_ID"]));
                $urlToPost .= strpos($urlToPost, "?") !== false ? "&" : "?";
                $arFields = array("POST_ID" => $arBlogPost["ID"], "COMMENT_ID" => $commentId, "arComment" => $arComment, "arAuthor" => $arAuthor, "arUrl" => array("LINK" => $urlToPost, "SHOW" => $urlToPost . "show_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "HIDE" => $urlToPost . "hide_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "DELETE" => $urlToPost . "delete_comment_id=#comment_id#&comment_post_id=#post_id#&" . bitrix_sessid_get(), "USER" => htmlspecialcharsback($arParams["PATH_TO_USER"])), "RATING_TYPE" => "like", "SHOW_RATING" => $arParams["SHOW_RATING"]);
                $arParams["RATING_TYPE"] = "like";
                CRatingsComponentsMain::GetShowRating($arParams);
                if ($arParams["SHOW_RATING"] == "Y") {
                    $arFields['arRating'] = CRatings::GetRatingVoteResult('BLOG_COMMENT', array($arFields["arComment"]["ID"]));
                }
                CMobileHelper::SendPullComment("blog", $arFields);
            }
        }
    }
}
if (!$strError) {
    $arResult["SUCCESS"] = "Y";
} else {
    $arResult["ERROR"] = $strError;
}
echo \Bitrix\Main\Web\Json::encode($arResult);
define('PUBLIC_AJAX_MODE', true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
die;