protected function initSession($CID, $controlId)
 {
     $ts = time();
     if (!isset($_SESSION[self::SESSION_LIST][$controlId])) {
         $_SESSION[self::SESSION_LIST][$controlId] = array();
     } else {
         foreach ($_SESSION[self::SESSION_LIST][$controlId] as $key => $arSession) {
             if ($arSession["SESSID"] != bitrix_sessid() || $ts - $arSession["TS"] > self::SESSION_TTL) {
                 $c = $_SESSION[self::SESSION_LIST][$controlId][$key]["CID"];
                 unset($_SESSION[self::SESSION_LIST][$controlId][$key]);
                 unset($_SESSION[self::SESSION_VAR_PREFIX . $c]);
             }
         }
     }
     $_SESSION[self::SESSION_LIST][$controlId][] = array("CID" => $CID, "TS" => $ts, "SESSID" => bitrix_sessid());
     $_SESSION[self::SESSION_VAR_PREFIX . $CID] = array();
 }
Exemple #2
0
 public static function GetDirectoryName($hours_to_keep_files = 0, $subdir = "")
 {
     if ($hours_to_keep_files <= 0) {
         return self::GetFileName('');
     }
     if ($subdir === "") {
         $dir_name = self::GetAbsoluteRoot() . '/BXTEMP-' . date('Y-m-d/H/', time() + 3600 * $hours_to_keep_files);
         $i = 0;
         while (true) {
             $i++;
             $dir_add = md5(mt_rand());
             $temp_path = $dir_name . $dir_add . "/";
             if (!file_exists($temp_path)) {
                 break;
             }
         }
     } else {
         $subdir = implode("/", is_array($subdir) ? $subdir : array($subdir, bitrix_sessid())) . "/";
         while (strpos($subdir, "//") !== false) {
             $subdir = str_replace("//", "/", $subdir);
         }
         $bFound = false;
         for ($i = $hours_to_keep_files - 1; $i > 0; $i--) {
             $dir_name = self::GetAbsoluteRoot() . '/BXTEMP-' . date('Y-m-d/H/', time() + 3600 * $i);
             $temp_path = $dir_name . $subdir;
             if (file_exists($temp_path) && is_dir($temp_path)) {
                 $bFound = true;
                 break;
             }
         }
         if (!$bFound) {
             $dir_name = self::GetAbsoluteRoot() . '/BXTEMP-' . date('Y-m-d/H/', time() + 3600 * $hours_to_keep_files);
             $temp_path = $dir_name . $subdir;
         }
     }
     //Delayed unlink
     if (empty(self::$arFiles)) {
         register_shutdown_function(array('CTempFile', 'Cleanup'));
     }
     //Function ends only here
     return $temp_path;
 }
Exemple #3
0
 protected static function checkAccessPermissions($parameters = array())
 {
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $errors = array();
     if ($GLOBALS['APPLICATION']->GetGroupRight("sale") < "W") {
         $errors[] = Loc::getMessage("SALE_SLI_SALE_MODULE_WRITE_ACCESS_DENIED");
     }
     if (!LocationHelper::checkLocationEnabled()) {
         $errors[] = 'Locations were disabled or data has not been converted';
     }
     if ($parameters['CHECK_CSRF']) {
         $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList();
         if (!strlen($post['csrf']) || bitrix_sessid() != $post['csrf']) {
             $errors[] = 'CSRF token is not valid';
         }
     }
     return $errors;
 }
Exemple #4
0
 protected static function checkAccessPermissions($parameters = array())
 {
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $errors = array();
     $CCrmPerms = new CCrmPerms($GLOBALS['USER']->GetID());
     if ($CCrmPerms->HavePerm('CONFIG', BX_CRM_PERM_NONE, 'WRITE')) {
         $errors[] = Loc::getMessage("SALE_CCLI2_CRM_MODULE_WRITE_ACCESS_DENIED");
     }
     if (!LocationHelper::checkLocationEnabled()) {
         $errors[] = 'Locations were disabled or data has not been converted';
     }
     if ($parameters['CHECK_CSRF']) {
         $post = \Bitrix\Main\Context::getCurrent()->getRequest()->getPostList();
         if (!strlen($post['csrf']) || bitrix_sessid() != $post['csrf']) {
             $errors[] = 'CSRF token is not valid';
         }
     }
     return $errors;
 }
Exemple #5
0
 /**
  * @param string $name
  */
 public function executeAction($name, $params = array())
 {
     global $USER;
     $actionDesc = $this->getAction($name);
     if ($actionDesc) {
         $isSessidValid = true;
         if ($actionDesc["needBitrixSessid"] == true || array_key_exists("sessid", $_REQUEST) && strlen($_REQUEST["sessid"]) > 0) {
             $isSessidValid = check_bitrix_sessid();
         }
         if (!isset($actionDesc["fireInitMobileEvent"]) || $actionDesc["fireInitMobileEvent"] != true) {
             if (!defined("MOBILE_INIT_EVENT_SKIP")) {
                 define("MOBILE_INIT_EVENT_SKIP", true);
             }
         }
         if ($actionDesc["no_check_auth"] !== true && (!$USER->IsAuthorized() || !$isSessidValid)) {
             header("HTTP/1.0 401 Not Authorized");
             header("Content-Type: application/x-javascript");
             header("BX-Authorize: " . bitrix_sessid());
             echo json_encode(array("status" => "failed", "bitrix_sessid" => bitrix_sessid()));
         } elseif ($actionDesc["file"]) {
             if ($actionDesc["json"] === true) {
                 header("Content-Type: application/x-javascript");
                 $data = (include $actionDesc["file"]);
                 if ($data) {
                     echo json_encode($data);
                 }
             } else {
                 include $actionDesc["file"];
             }
         }
     } else {
         if (!defined("MOBILE_INIT_EVENT_SKIP")) {
             define("MOBILE_INIT_EVENT_SKIP", true);
         }
         header("Content-Type: application/x-javascript");
         echo json_encode(array("error" => "unknown action for data request"));
     }
 }
	/**
	 * Displays start master button in public section
	 */
	function ShowCreateButton ()
	{
		// if user is admin
		if ($GLOBALS["USER"]->IsAdmin())
		{
			$GLOBALS["APPLICATION"]->AddHeadString('<style type="text/css">
#wizard_install_dialog { background-color: #F8F9FC; border: 1px solid #ABB7D8; }
#wizard_install_dialog div.title {background-color:#23468A; background-image:url(/bitrix/themes/.default/images/calendar/title_bg.gif); background-repeat:repeat-x; background-position:left top;}
#wizard_install_dialog div.title td.title-text {font-size:11px; font-family: Verdana,Arial,helvetica,sans-serif; font-weight:bold; color:#EEF1F7; padding:3px; cursor:move; vertical-align:top;}
</style>');

			$GLOBALS["APPLICATION"]->AddPanelButton(array(
				"HREF" => "javascript:WizardWindow.Open('beono:component','".bitrix_sessid()."')",   
            	"ID" => "beono.mastercomponent",
				"SRC" => "/bitrix/wizards/beono/component/panel-icon.png", 
				"MAIN_SORT" => 400,
				"SORT" => 100,
				"ALT" => GetMessage("BEONO_MODULE_MASTERCOMP_BUTTON_DESCRIPTION"),
				"TEXT" => GetMessage("BEONO_MODULE_MASTERCOMP_BUTTON_NAME"),
				"MENU" => array(),
			));
		}
	}
Exemple #7
0
    public static function ShowDialogScript($arConfig = array())
    {
        global $USER;
        CUtil::InitJSCore(array('ajax'));
        $strWarn = '';
        $arConfig['bReadOnly'] = false;
        $arConfig['lang'] = LANGUAGE_ID;
        $event = '';
        if (isset($arConfig['event'])) {
            $event = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['event']);
        }
        if (strlen($event) <= 0) {
            $strWarn .= GetMessage('ML_BAD_EVENT') . '. ';
        }
        $resultDest = "";
        $bDest = is_array($arConfig['arResultDest']);
        if ($bDest) {
            if (isset($arConfig['arResultDest']["FUNCTION_NAME"])) {
                $arConfig['arResultDest']["FUNCTION_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FUNCTION_NAME"]);
                $bDest = strlen($arConfig['arResultDest']["FUNCTION_NAME"]) > 0;
                $resultDest = "FUNCTION";
            } elseif (isset($arConfig['arResultDest']["FORM_NAME"], $arConfig['arResultDest']["FORM_ELEMENT_NAME"])) {
                $arConfig['arResultDest']["FORM_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FORM_NAME"]);
                $arConfig['arResultDest']["FORM_ELEMENT_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FORM_ELEMENT_NAME"]);
                $bDest = strlen($arConfig['arResultDest']["FORM_NAME"]) > 0 && strlen($arConfig['arResultDest']["FORM_ELEMENT_NAME"]) > 0;
                $resultDest = "FORM";
            } elseif (isset($arConfig['arResultDest']["ELEMENT_ID"])) {
                $arConfig['arResultDest']["ELEMENT_ID"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["ELEMENT_ID"]);
                $bDest = strlen($arConfig['arResultDest']["ELEMENT_ID"]) > 0;
                $resultDest = "ID";
            } else {
                $bDest = false;
            }
        }
        if (!$bDest) {
            $strWarn .= GetMessage('ML_BAD_RETURN') . '. ';
        }
        if (strlen($strWarn) <= 0) {
            ?>
			<script>
			if (!window.BX && top.BX)
				window.BX = top.BX;

			<?php 
            CMedialib::AppendLangMessages();
            ?>
			window.<?php 
            echo $arConfig['event'];
            ?>
 = function(bLoadJS)
			{
				if (window.oBXMedialib && window.oBXMedialib.bOpened)
					return false;

				<?php 
            if (!CMedialib::CanDoOperation('medialib_view_collection', 0)) {
                ?>
					return alert(ML_MESS.AccessDenied);
				<?php 
            } else {
                ?>

				if (!window.BXMediaLib)
				{
					if (bLoadJS !== false)
					{
						// Append CSS
						BX.loadCSS("/bitrix/js/fileman/medialib/medialib.css");

						var arJS = [];
						if (!window.jsAjaxUtil)
							arJS.push("/bitrix/js/main/ajax.js?v=<?php 
                echo filemtime($_SERVER["DOCUMENT_ROOT"] . '/bitrix/js/main/ajax.js');
                ?>
");
						if (!window.jsUtils)
							arJS.push("/bitrix/js/main/utils.js?v=<?php 
                echo filemtime($_SERVER["DOCUMENT_ROOT"] . '/bitrix/js/main/utils.js');
                ?>
");
						if (!window.CHttpRequest)
							arJS.push("/bitrix/js/main/admin_tools.js?v=<?php 
                echo filemtime($_SERVER["DOCUMENT_ROOT"] . '/bitrix/js/main/admin_tools.js');
                ?>
");

						arJS.push("/bitrix/js/fileman/medialib/common.js?v=<?php 
                echo filemtime($_SERVER["DOCUMENT_ROOT"] . '/bitrix/js/fileman/medialib/common.js');
                ?>
");
						arJS.push("/bitrix/js/fileman/medialib/core.js?v=<?php 
                echo filemtime($_SERVER["DOCUMENT_ROOT"] . '/bitrix/js/fileman/medialib/core.js');
                ?>
");
						BX.loadScript(arJS);
					}
					return setTimeout(function(){<?php 
                echo $arConfig['event'];
                ?>
(false)}, 50);
				}

				<?php 
                CMedialib::ShowJS();
                ?>
				<?php 
                $arSet = explode(',', CUserOptions::GetOption("fileman", "medialib_user_set", '600,450,0'));
                $width = $arSet[0] ? intVal($arSet[0]) : 600;
                $height = $arSet[1] ? intVal($arSet[1]) : 450;
                $coll_id = $arSet[2] ? intVal($arSet[2]) : 0;
                ?>
				window._mlUserSettings = window._mlUserSettings || {width: <?php 
                echo $width;
                ?>
, height: <?php 
                echo $height;
                ?>
, coll_id: <?php 
                echo $coll_id;
                ?>
}

				var oConfig =
				{
					sessid: "<?php 
                echo bitrix_sessid();
                ?>
",
					thumbWidth : <?php 
                echo COption::GetOptionInt('fileman', "ml_thumb_width", 140);
                ?>
,
					thumbHeight : <?php 
                echo COption::GetOptionInt('fileman', "ml_thumb_height", 105);
                ?>
,
					userSettings : window._mlUserSettings,
					resType: "<?php 
                echo $resultDest;
                ?>
",
					Types : <?php 
                echo CUtil::PhpToJSObject(CMedialib::GetTypes($arConfig['types']));
                ?>
,
					arResultDest : <?php 
                echo CUtil::PhpToJSObject($arConfig['arResultDest']);
                ?>
,
					rootAccess: {
						new_col: '<?php 
                echo CMedialib::CanDoOperation('medialib_new_collection', 0);
                ?>
',
						edit: '<?php 
                echo CMedialib::CanDoOperation('medialib_edit_collection', 0);
                ?>
',
						del: '<?php 
                echo CMedialib::CanDoOperation('medialib_del_collection', 0);
                ?>
',
						new_item: '<?php 
                echo CMedialib::CanDoOperation('medialib_new_item', 0);
                ?>
',
						edit_item: '<?php 
                echo CMedialib::CanDoOperation('medialib_edit_item', 0);
                ?>
',
						del_item: '<?php 
                echo CMedialib::CanDoOperation('medialib_del_item', 0);
                ?>
',
						access: '<?php 
                echo CMedialib::CanDoOperation('medialib_access', 0);
                ?>
'
					},
					bCanUpload: <?php 
                echo $USER->CanDoOperation('fileman_upload_files') ? 'true' : 'false';
                ?>
,
					bCanViewStructure: <?php 
                echo $USER->CanDoOperation('fileman_view_file_structure') ? 'true' : 'false';
                ?>
,
					strExt : "<?php 
                echo CUtil::JSEscape(CMedialib::GetMediaExtentions());
                ?>
",
					lang : "<?php 
                echo $arConfig['lang'];
                ?>
",
					description_id : '<?php 
                echo CUtil::JSEscape($arConfig['description_id']);
                ?>
'
				};

				window.oBXMedialib = new BXMediaLib(oConfig);
				oBXMedialib.Open();
				<?php 
            }
            ?>
			};
			</script>
			<?php 
        } else {
            echo '<font color="#FF0000">' . htmlspecialcharsbx($strWarn) . '</font>';
        }
    }
/***************************************************************************
								HTML form
****************************************************************************/
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$aMenu = array(array("TEXT" => GetMessage("AD_BACK_TO_TYPE_LIST"), "LINK" => "adv_type_list.php?lang=" . LANGUAGE_ID, "ICON" => "btn_list"));
if (strlen($SID) > 0) {
    $aMenu[] = array("SEPARATOR" => "Y");
    $aMenu[] = array("TEXT" => GetMessage("AD_STATISTICS"), "LINK" => "adv_banner_graph.php?find_type_sid=" . $SID . "&find_what_show[]=ctr&find_banner_summa=Y&set_filter=Y&lang=" . LANGUAGE_ID, "TITLE" => GetMessage("AD_STATISTICS_TITILE"), "ICON" => "btn_adv_graph");
    if ($isAdmin || $isDemo) {
        if ($action != "view") {
            $aMenu[] = array("TEXT" => GetMessage("AD_TYPE_VIEW_SETTINGS"), "TITLE" => GetMessage("AD_TYPE_VIEW_SETTINGS_TITLE"), "LINK" => "adv_type_edit.php?SID=" . $SID . "&lang=" . LANGUAGE_ID . "&action=view", "ICON" => "btn_adv_view");
        } else {
            $aMenu[] = array("TEXT" => GetMessage("AD_TYPE_EDIT"), "TITLE" => GetMessage("AD_TYPE_EDIT_TITLE"), "LINK" => "adv_type_edit.php?SID=" . $SID . "&lang=" . LANGUAGE_ID, "ICON" => "btn_adv_edit");
        }
        $aMenu[] = array("TEXT" => GetMessage("AD_ADD_NEW_TYPE"), "LINK" => "adv_type_edit.php?lang=" . LANGUAGE_ID, "TITLE" => GetMessage("AD_ADD_NEW_TYPE_TITLE"), "ICON" => "btn_new");
        $aMenu[] = array("TEXT" => GetMessage("AD_DELETE_TYPE"), "LINK" => "javascript:if(confirm('" . GetMessage("AD_DELETE_TYPE_CONFIRM") . "'))window.location='adv_type_list.php?ID=" . $SID . "&lang=" . LANGUAGE_ID . "&action=delete&sessid=" . bitrix_sessid() . "';", "ICON" => "btn_delete");
    }
}
$context = new CAdminContextMenu($aMenu);
$context->Show();
echo CAdminMessage::ShowMessage($strError);
?>
<form name="form1" method="POST" action="<?php 
echo $APPLICATION->GetCurPage();
?>
">
<?php 
echo bitrix_sessid_post();
?>
<input type="hidden" name="lang" value="<?php 
echo LANGUAGE_ID;
Exemple #9
0
    function ShowScript($arConfig)
    {
        global $USER;
        $bCloudsBrowse = is_object($USER) && $USER->CanDoOperation("clouds_browse") && $arConfig["operation"] === "O";
        CUtil::InitJSCore(array('ajax', 'window'));
        if (CModule::IncludeModule("fileman")) {
            $arConfig['path'] = isset($arConfig['arPath']['PATH']) ? $arConfig['arPath']['PATH'] : '';
            $arConfig['site'] = isset($arConfig['arPath']['SITE']) ? $arConfig['arPath']['SITE'] : '';
            $arConfig['lang'] = isset($arConfig['lang']) ? $arConfig['lang'] : LANGUAGE_ID;
            $arConfig['zIndex'] = isset($arConfig['zIndex']) ? $arConfig['zIndex'] : 2500;
            $io = CBXVirtualIo::GetInstance();
            $path = $io->CombinePath("/", $arConfig['path']);
            $path = CFileMan::SecurePathVar($path);
            $rootPath = CSite::GetSiteDocRoot($arConfig['site']);
            while (!$io->DirectoryExists($rootPath . $path)) {
                $rpos = strrpos($path, '/');
                if ($rpos === false || $rpos < 1) {
                    $path = '/';
                    break;
                }
                $path = rtrim(substr($path, 0, $rpos), "/\\");
            }
            if (!$path || $path == '') {
                $path = '/';
            }
            $arConfig['path'] = $path;
            $functionError = "";
            if (!isset($arConfig['event'])) {
                $functionError .= GetMessage("BX_FD_NO_EVENT") . ". ";
            } else {
                $arConfig['event'] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['event']);
                if (strlen($arConfig['event']) <= 0) {
                    $functionError .= GetMessage("BX_FD_NO_EVENT") . ". ";
                }
            }
            $resultDest = "";
            if (!isset($arConfig['arResultDest']) || !is_array($arConfig['arResultDest'])) {
                $functionError .= GetMessage("BX_FD_NO_RETURN_PRM") . ". ";
            } else {
                if (isset($arConfig['arResultDest']["FUNCTION_NAME"]) && strlen($arConfig['arResultDest']["FUNCTION_NAME"]) > 0) {
                    $arConfig['arResultDest']["FUNCTION_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FUNCTION_NAME"]);
                    if (strlen($arConfig['arResultDest']["FUNCTION_NAME"]) <= 0) {
                        $functionError .= GetMessage("BX_FD_NO_RETURN_FNC") . ". ";
                    } else {
                        $resultDest = "FUNCTION";
                    }
                } elseif (isset($arConfig['arResultDest']["FORM_NAME"]) && strlen($arConfig['arResultDest']["FORM_NAME"]) > 0 && isset($arConfig['arResultDest']["FORM_ELEMENT_NAME"]) && strlen($arConfig['arResultDest']["FORM_ELEMENT_NAME"]) > 0) {
                    $arConfig['arResultDest']["FORM_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FORM_NAME"]);
                    $arConfig['arResultDest']["FORM_ELEMENT_NAME"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["FORM_ELEMENT_NAME"]);
                    if (strlen($arConfig['arResultDest']["FORM_NAME"]) <= 0 || strlen($arConfig['arResultDest']["FORM_ELEMENT_NAME"]) <= 0) {
                        $functionError .= GetMessage("BX_FD_NO_RETURN_FRM") . ". ";
                    } else {
                        $resultDest = "FORM";
                    }
                } elseif (isset($arConfig['arResultDest']["ELEMENT_ID"]) && strlen($arConfig['arResultDest']["ELEMENT_ID"]) > 0) {
                    $arConfig['arResultDest']["ELEMENT_ID"] = preg_replace("/[^a-zA-Z0-9_]/i", "", $arConfig['arResultDest']["ELEMENT_ID"]);
                    if (strlen($arConfig['arResultDest']["ELEMENT_ID"]) <= 0) {
                        $functionError .= GetMessage("BX_FD_NO_RETURN_ID") . ". ";
                    } else {
                        $resultDest = "ID";
                    }
                } else {
                    $functionError .= GetMessage("BX_FD_BAD_RETURN") . ". ";
                }
            }
        } else {
            $functionError = GetMessage("BX_FD_NO_FILEMAN");
        }
        if (strlen($functionError) <= 0) {
            ?>
			<script>
			var mess_SESS_EXPIRED = '<?php 
            echo GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_SESS_EXPIRED');
            ?>
';
			var mess_ACCESS_DENIED = '<?php 
            echo GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_NO_PERMS');
            ?>
';
			window.<?php 
            echo CUtil::JSEscape($arConfig['event']);
            ?>
 = function(bLoadJS, Params)
			{
				if (!Params)
					Params = {};

				<?php 
            if (!$GLOBALS['USER']->CanDoOperation('fileman_view_file_structure')) {
                ?>
					return alert(mess_ACCESS_DENIED);
				<?php 
            } else {
                ?>
				<?php 
                $fd_config = stripslashes(CUserOptions::GetOption("fileman", "file_dialog_config", "N"));
                if ($fd_config == "N" || $arConfig['saveConfig'] === false) {
                    ?>
					var UserConfig =
					{
						site : '<?php 
                    echo CUtil::JSEscape($arConfig['site']);
                    ?>
',
						path : '<?php 
                    echo CUtil::JSEscape($arConfig['path']);
                    ?>
',
						view : "list",
						sort : "type",
						sort_order : "asc"
					};
				<?php 
                } else {
                    $res = explode(";", $fd_config);
                    if ($res[0]) {
                        $arConfig['site'] = $res[0];
                    }
                    if ($res[1]) {
                        $arConfig['path'] = rtrim($res[1], " /\\");
                    }
                    if (!$io->DirectoryExists($rootPath . $arConfig['path'])) {
                        $arConfig['path'] = '/';
                    }
                    ?>
					var UserConfig =
					{
						site : '<?php 
                    echo CUtil::JSEscape($arConfig['site']);
                    ?>
',
						path : '<?php 
                    echo CUtil::JSEscape($arConfig['path']);
                    ?>
',
						view : '<?php 
                    echo CUtil::JSEscape($res[2]);
                    ?>
',
						sort : '<?php 
                    echo CUtil::JSEscape($res[3]);
                    ?>
',
						sort_order : '<?php 
                    echo CUtil::JSEscape($res[4]);
                    ?>
'
					};
					<?php 
                }
                ?>

				if (!window.BXFileDialog)
				{
					if (bLoadJS !== false)
						BX.loadScript("/bitrix/js/main/file_dialog.js?v=<?php 
                echo @filemtime($_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/main/file_dialog.js');
                ?>
");
					return setTimeout(function(){window['<?php 
                echo CUtil::JSEscape($arConfig['event']);
                ?>
'](false, Params)}, 50);
				}

				var oConfig =
				{
					submitFuncName : '<?php 
                echo CUtil::JSEscape($arConfig['event']);
                ?>
Result',
					select : '<?php 
                echo CUtil::JSEscape($arConfig['select']);
                ?>
',
					operation: '<?php 
                echo CUtil::JSEscape($arConfig['operation']);
                ?>
',
					showUploadTab : <?php 
                echo $arConfig['showUploadTab'] ? 'true' : 'false';
                ?>
,
					showAddToMenuTab : <?php 
                echo $arConfig['showAddToMenuTab'] ? 'true' : 'false';
                ?>
,
					site : '<?php 
                echo CUtil::JSEscape($arConfig['site']);
                ?>
',
					path : '<?php 
                echo CUtil::JSEscape($arConfig['path']);
                ?>
',
					lang : '<?php 
                echo CUtil::JSEscape($arConfig['lang']);
                ?>
',
					fileFilter : '<?php 
                echo CUtil::JSEscape($arConfig['fileFilter']);
                ?>
',
					allowAllFiles : <?php 
                echo $arConfig['allowAllFiles'] !== false ? 'true' : 'false';
                ?>
,
					saveConfig : <?php 
                echo $arConfig['saveConfig'] !== false ? 'true' : 'false';
                ?>
,
					sessid: "<?php 
                echo bitrix_sessid();
                ?>
",
					checkChildren: true,
					genThumb: <?php 
                echo COption::GetOptionString("fileman", "file_dialog_gen_thumb", "Y") == 'Y' ? 'true' : 'false';
                ?>
,
					zIndex: <?php 
                echo CUtil::JSEscape($arConfig['zIndex']);
                ?>
				};

				if(window.oBXFileDialog && window.oBXFileDialog.UserConfig)
				{
					UserConfig = oBXFileDialog.UserConfig;
					oConfig.path = UserConfig.path;
					oConfig.site = UserConfig.site;
				}

				if (Params.path)
					oConfig.path = Params.path;
				if (Params.site)
					oConfig.site = Params.site;

				oBXFileDialog = new BXFileDialog();
				oBXFileDialog.Open(oConfig, UserConfig);
				<?php 
            }
            ?>
			};
			window.<?php 
            echo CUtil::JSEscape($arConfig['event']);
            ?>
Result = function(filename, path, site, title, menu)
			{
<?php 
            $arBuckets = array();
            if ($bCloudsBrowse && CModule::IncludeModule('clouds')) {
                foreach (CCloudStorageBucket::GetAllBuckets() as $arBucket) {
                    if ($arBucket["ACTIVE"] == "Y") {
                        $obBucket = new CCloudStorageBucket($arBucket["ID"]);
                        if ($obBucket->Init()) {
                            $arBuckets[$arBucket["BUCKET"]] = rtrim($obBucket->GetFileSRC("/"), "/");
                        }
                    }
                }
            }
            ?>
				path = jsUtils.trim(path);
				path = path.replace(/\\/ig,"/");
				path = path.replace(/\/\//ig,"/");
				if (path.substr(path.length-1) == "/")
					path = path.substr(0, path.length-1);
				var full = (path + '/' + filename).replace(/\/\//ig, '/');
				if (path == '')
					path = '/';

				var arBuckets = <?php 
            echo CUtil::PhpToJSObject($arBuckets);
            ?>
;
				if(arBuckets[site])
				{
					full = arBuckets[site] + filename;
					path = arBuckets[site] + path;
				}

				if ('<?php 
            echo CUtil::JSEscape($arConfig['select']);
            ?>
' == 'D')
					name = full;

				<?php 
            if ($resultDest == "FUNCTION") {
                ?>
					<?php 
                echo CUtil::JSEscape($arConfig['arResultDest']["FUNCTION_NAME"]);
                ?>
(filename, path, site, title || '', menu || '');
				<?php 
            } elseif ($resultDest == "FORM") {
                ?>
					document.<?php 
                echo CUtil::JSEscape($arConfig['arResultDest']["FORM_NAME"]);
                ?>
.<?php 
                echo CUtil::JSEscape($arConfig['arResultDest']["FORM_ELEMENT_NAME"]);
                ?>
.value = full;
					BX.fireEvent(document.<?php 
                echo CUtil::JSEscape($arConfig['arResultDest']["FORM_NAME"]);
                ?>
.<?php 
                echo CUtil::JSEscape($arConfig['arResultDest']["FORM_ELEMENT_NAME"]);
                ?>
, 'change');
				<?php 
            } elseif ($resultDest == "ID") {
                ?>
					BX('<?php 
                echo CUtil::JSEscape($arConfig['arResultDest']["ELEMENT_ID"]);
                ?>
').value = full;
					BX.fireEvent(BX('<?php 
                echo CUtil::JSEscape($arConfig['arResultDest']["ELEMENT_ID"]);
                ?>
'), 'change');
				<?php 
            }
            ?>
			};
			<?php 
            self::AttachJSScripts();
            ?>
			</script>
			<?php 
        } else {
            echo "<font color=\"#FF0000\">" . htmlspecialcharsbx($functionError) . "</font>";
        }
    }
    echo $strResult;
    ?>
;
	if (top.<?php 
    echo $strReceiver;
    ?>
)
	{
		top.<?php 
    echo $strReceiver;
    ?>
.SetPropInfo('<?php 
    echo $PARAMS['ID'];
    ?>
',arResult,'<?php 
    echo bitrix_sessid();
    ?>
');
	}
	top.BX.closeWait(); top.BX.WindowManager.Get().AllowClose(); top.BX.WindowManager.Get().Close();
	</script><?php 
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin_js.php";
    die;
}
$aTabs = array();
$tabControl = null;
if (!$bFullForm) {
    $arProperty = array();
    $PROPERTY = $_POST['PROP'];
    $PARAMS = $_POST['PARAMS'];
    if (isset($PARAMS['TITLE']) && '' != $PARAMS['TITLE']) {
    }
    $res["SHOW_PANEL"] = in_array("Y", $res["PANELS"]) ? "Y" : "N";
    if ($arParams["PERMISSION_ORIGINAL"] >= "Q") {
        $bIP = preg_match("/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\$/", $res["~AUTHOR_IP"]) ? true : false;
        $res["AUTHOR_IP"] = $bIP ? GetWhoisLink($res["~AUTHOR_IP"], "") : $res["AUTHOR_IP"];
        $bIP = preg_match("/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\$/", $res["~AUTHOR_REAL_IP"]) ? true : false;
        $res["AUTHOR_REAL_IP"] = $bIP ? GetWhoisLink($res["~AUTHOR_REAL_IP"], "") : $res["AUTHOR_REAL_IP"];
        $res["IP_IS_DIFFER"] = $res["AUTHOR_IP"] != $res["AUTHOR_REAL_IP"] ? "Y" : "N";
    }
    /************** Panels/*********************************************/
    /************** Urls ***********************************************/
    $res["URL"] = array("~USER" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["AUTHOR_ID"])), "~AUTHOR" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["AUTHOR_ID"])), "~EDITOR" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["EDITOR_ID"])), "~MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("UID" => $arParams["USER_ID"], "TID" => $arParams["TID"], "GID" => $arParams["SOCNET_GROUP_ID"], "MID" => $res["ID"])), "~MESSAGE_EDIT" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_TOPIC_EDIT"], array("UID" => $arParams["USER_ID"], "TID" => $arParams["TID"], "GID" => $arParams["SOCNET_GROUP_ID"], "MID" => $res["ID"])), "USER" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["AUTHOR_ID"])), "AUTHOR" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["AUTHOR_ID"])), "EDITOR" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["EDITOR_ID"])), "MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $arParams["USER_ID"], "TID" => $arParams["TID"], "GID" => $arParams["SOCNET_GROUP_ID"], "MID" => $res["ID"])), "MESSAGE_EDIT" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_TOPIC_EDIT"], array("UID" => $arParams["USER_ID"], "TID" => $arParams["TID"], "GID" => $arParams["SOCNET_GROUP_ID"], "MID" => $res["ID"])));
    $res["URL"]["MESSAGE_EDIT"] = ForumAddPageParams($res["URL"]["~MESSAGE_EDIT"], array("MID" => $res["ID"], "ACTION" => "EDIT", "MESSAGE_TYPE" => "EDIT"));
    $res["URL"]["MESSAGE_DELETE"] = ForumAddPageParams($res["URL"]["~MESSAGE"], array("MID" => $res["ID"], "ACTION" => "del", "MESSAGE_TYPE" => "EDIT"));
    $res["URL"]["MESSAGE_SHOW"] = ForumAddPageParams($res["URL"]["~MESSAGE"], array("MID" => $res["ID"], "ACTION" => $res["APPROVED"] == "Y" ? "hide" : "show", "MESSAGE_TYPE" => "EDIT"));
    $res["URL"]["MESSAGE_SUPPORT"] = ForumAddPageParams($res["URL"]["~MESSAGE"], array("MID" => $res["ID"], "ACTION" => "support", "MESSAGE_TYPE" => "EDIT", "sessid" => bitrix_sessid()));
    $res["URL"]["AUTHOR_VOTE"] = ForumAddPageParams($res["URL"]["MESSAGE"], array("UID" => $res["AUTHOR_ID"], "MID" => $res["ID"], "VOTES" => intVal($arResult["USER"]["RANK"]["VOTES"]), "VOTES_TYPE" => $res["VOTING"] == "VOTE" ? "V" : "U", "ACTION" => "VOTE4USER"));
    $res["URL"]["MESSAGE_SPAM"] = ForumAddPageParams($res["URL"]["~MESSAGE"], array("MID" => $res["ID"], "ACTION" => "spam", "MESSAGE_TYPE" => "EDIT"));
    /************** Urls/***********************************************/
    if ($number == 2 && $bNeedFirstMessage) {
        $arResult["MESSAGE_FIRST"] = $res;
    } else {
        $arResult["MESSAGE_LIST"][$res["ID"]] = $res;
    }
}
/************** /Message list **************************************/
/************** Attach files ***************************************/
if (!empty($arResult["MESSAGE_LIST"])) {
    $res = array_keys($arResult["MESSAGE_LIST"]);
    $arFilter[">MESSAGE_ID"] = intVal($res[0]) - 1;
    $arFilter["<MESSAGE_ID"] = intVal($res[count($res) - 1]) + 1;
Exemple #12
0
//Пробегаем по параметрам чщательно складывая их в хранилище
foreach ($arParams as $k => $v) {
    if (strncmp("~", $k, 1) && !in_array($k, $arSessionParams["PAGE_PARAMS"])) {
        $arSessionParams[$k] = $v;
    }
}
//04*
//Эти "параметры" нам понадобятся для правильного подключения компонента в AJAX вызове
$arSessionParams["COMPONENT_NAME"] = $component->GetName();
$arSessionParams["TEMPLATE_NAME"] = $component->GetTemplateName();
if ($parent = $component->GetParent()) {
    $arSessionParams["PARENT_NAME"] = $parent->GetName();
    $arSessionParams["PARENT_TEMPLATE_NAME"] = $parent->GetTemplateName();
    $arSessionParams["PARENT_TEMPLATE_PAGE"] = $parent->GetTemplatePage();
}
//05*
//а вот и ключ!
$idSessionParams = md5(serialize($arSessionParams));
//06*
//Модифицируем arResult компонента.
//Эти данные затем будут извлекаться из кеша
//И записываться в сессию
$component->arResult["AJAX"] = array("SESSION_KEY" => $idSessionParams, "SESSION_PARAMS" => $arSessionParams);
//07*
//Эта переменная для использования в шаблоне
$arResult["~AJAX_PARAMS"] = array("SESSION_PARAMS" => $idSessionParams, "PAGE_PARAMS" => array("ELEMENT_ID" => $arParams["ELEMENT_ID"]), "sessid" => bitrix_sessid(), "AJAX_CALL" => "Y");
//08*
//Она будет прозрачно передана в аяксовый пост
$arResult["AJAX_PARAMS"] = CUtil::PhpToJSObject($arResult["~AJAX_PARAMS"]);
//09*
//Продолжение экскурсии в файле template.php
Exemple #13
0
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
$APPLICATION->AddHeadScript(SITE_TEMPLATE_PATH."/components/bitrix/rating.vote/mobile_like/script_attached.js");

?><script>
BX.message({
	RVSessID: '<?php 
echo CUtil::JSEscape(bitrix_sessid());
?>
',
	RVPathToUserProfile: '<?php 
echo CUtil::JSEscape(htmlspecialcharsbx(str_replace("#", "(_)", $arResult['PATH_TO_USER_PROFILE'])));
?>
',
	RVListBack: '<?php 
echo CUtil::JSEscape(GetMessage("RV_T_LIST_BACK"));
?>
',
	RVRunEvent: '<?php 
echo intval($arParams["VOTE_RAND"]) > 0 ? "Y" : "N";
?>
'
});
</script><?
?><div class="post-item-informers post-item-inform-likes<?php 
echo $arResult['USER_HAS_VOTED'] == "N" ? "" : "-active";
?>
" id="bx-ilike-button-<?php 
echo CUtil::JSEscape(htmlspecialcharsbx($arResult['VOTE_ID']));
?>
"><?
	?><div class="post-item-inform-left"></div><?
 $arHistory['DISCUSSION_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_DISCUSSION'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N' ? array($arParams['OPER_VAR'] => 'discussion') : array());
 $arHistory['SHOW_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_POST'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), array('oldid' => $arHistory['ID']));
 $arHp = array('oldid' => $arHistory['ID'], 'sessid' => bitrix_sessid());
 if ($arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N') {
     $arHp[$arParams['OPER_VAR']] = 'history';
 }
 $arHistory['CANCEL_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_HISTORY'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arHp);
 if ($arHistoryFirst['ID'] != $arHistory['ID']) {
     $arHp = array('diffid' => $arHistoryFirst['ID'], 'oldid' => $arHistory['ID']);
     if ($arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N') {
         $arHp[$arParams['OPER_VAR']] = 'history_diff';
     }
     $arHistory['CUR_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_HISTORY_DIFF'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arHp);
 }
 if (CWikiUtils::IsDeleteable()) {
     $arHp = array('oldid' => $arHistory['ID'], 'sessid' => bitrix_sessid(), 'delete' => 1);
     if ($arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N') {
         $arHp[$arParams['OPER_VAR']] = 'history';
     }
     $arHistory['DELETE_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_HISTORY'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arHp);
 }
 $arHistory['MODIFIED'] = FormatDateFromDB($arHistory['MODIFIED']);
 $arResult['HISTORY'][] = $arHistory;
 $iPrev = count($arResult['HISTORY']) - 2;
 if (isset($arResult['HISTORY'][$iPrev])) {
     $arHp = array('diffid' => $arResult['HISTORY'][$iPrev]['ID'], 'oldid' => $arHistory['ID']);
     if ($arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N') {
         $arHp[$arParams['OPER_VAR']] = 'history_diff';
     }
     $arResult['HISTORY'][$iPrev]['PREV_LINK'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_HISTORY_DIFF'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arHp);
 }
Exemple #15
0
     }
 } else {
     $message = !empty($_REQUEST["MID_ARRAY"]) ? $_REQUEST["MID_ARRAY"] : $_REQUEST["MID"];
     if ((empty($message) || $message == "s") && !empty($_REQUEST["message_id"])) {
         $message = $_REQUEST["message_id"];
     }
 }
 switch ($action) {
     case "EDIT_TOPIC":
         $MID = 0;
         $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $arParams["TID"]), false, 1);
         if ($db_res && ($res = $db_res->Fetch())) {
             $MID = intVal($res["ID"]);
         }
         if ($MID > 0) {
             $url = ForumAddPageParams(CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_TOPIC_NEW"], array("FID" => $arParams["FID"])), array("TID" => $arParams["TID"], "MID" => $MID, "MESSAGE_TYPE" => "EDIT", "sessid" => bitrix_sessid()), false, false);
             LocalRedirect($url);
         }
         break;
     case "REPLY":
         $arFields = array("FID" => $arParams["FID"], "TID" => $arParams["TID"], "POST_MESSAGE" => $_POST["POST_MESSAGE"], "AUTHOR_NAME" => $_POST["AUTHOR_NAME"], "AUTHOR_EMAIL" => $_POST["AUTHOR_EMAIL"], "USE_SMILES" => $_POST["USE_SMILES"], "captcha_word" => $_POST["captcha_word"], "captcha_code" => $_POST["captcha_code"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"]);
         if (!empty($_FILES["ATTACH_IMG"])) {
             $arFields["ATTACH_IMG"] = $_FILES["ATTACH_IMG"];
         } else {
             $arFiles = array();
             if (!empty($_REQUEST["FILES"])) {
                 foreach ($_REQUEST["FILES"] as $key) {
                     $arFiles[$key] = array("FILE_ID" => $key);
                     if (!in_array($key, $_REQUEST["FILES_TO_UPLOAD"])) {
                         $arFiles[$key]["del"] = "Y";
                     }
Exemple #16
0
 private static function replaceSessid(&$content)
 {
     $methodInvocations = bitrix_sessid_post("sessid", true);
     if ($methodInvocations > 0) {
         $content = str_replace("value=\"" . bitrix_sessid() . "\"", "value=\"\"", $content);
     }
 }
Exemple #17
0
if ($arParams['TYPE'] == 'edit' && $bRead && !empty($arParams['ELEMENT_ID'])) {
    $arResult['BUTTONS'][] = array('TEXT' => GetMessage('INVOICE_SHOW'), 'TITLE' => GetMessage('INVOICE_SHOW_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_SHOW'], array('invoice_id' => $arParams['ELEMENT_ID'])), 'ICON' => 'btn-view');
}
if (($arParams['TYPE'] == 'edit' || $arParams['TYPE'] == 'show') && $bAdd && !empty($arParams['ELEMENT_ID']) && !isset($_REQUEST['copy'])) {
    $arResult['BUTTONS'][] = array('TEXT' => GetMessage('INVOICE_COPY'), 'TITLE' => GetMessage('INVOICE_COPY_TITLE'), 'LINK' => CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_EDIT'], array('invoice_id' => $arParams['ELEMENT_ID'])), array('copy' => 1)), 'ICON' => 'btn-copy');
}
$qty = count($arResult['BUTTONS']);
if (!empty($arResult['BUTTONS']) && $arParams['TYPE'] == 'edit' && empty($arParams['ELEMENT_ID'])) {
    $arResult['BUTTONS'][] = array('SEPARATOR' => true);
} elseif ($arParams['TYPE'] == 'show' && $qty > 1) {
    $arResult['BUTTONS'][] = array('NEWBAR' => true);
} elseif ($qty >= 3) {
    $arResult['BUTTONS'][] = array('NEWBAR' => true);
}
if (($arParams['TYPE'] == 'edit' || $arParams['TYPE'] == 'show') && $bDelete && !empty($arParams['ELEMENT_ID'])) {
    $arResult['BUTTONS'][] = array('TEXT' => GetMessage('INVOICE_DELETE'), 'TITLE' => GetMessage('INVOICE_DELETE_TITLE'), 'LINK' => "javascript:invoice_delete('" . GetMessage('INVOICE_DELETE_DLG_TITLE') . "', '" . GetMessage('INVOICE_DELETE_DLG_MESSAGE') . "', '" . GetMessage('INVOICE_DELETE_DLG_BTNTITLE') . "', '" . CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_EDIT'], array('invoice_id' => $arParams['ELEMENT_ID'])), array('delete' => '', 'sessid' => bitrix_sessid())) . "')", 'ICON' => 'btn-delete');
}
//	if ($bAdd)
//	{
//		$arResult['BUTTONS'][] = array(
//			'TEXT' => GetMessage('INVOICE_ADD'),
//			'TITLE' => GetMessage('INVOICE_ADD_TITLE'),
//			'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_INVOICE_EDIT'],
//				array(
//					'invoice_id' => 0
//				)
//			),
//			'ICON' => 'btn-new'
//		);
//	}
$this->IncludeComponentTemplate();
Exemple #18
0
        while ($arMultiField = $dbMultiFields->Fetch()) {
            $arFields['FM'][$arMultiField['TYPE_ID']][$arMultiField['ID']] = array('VALUE' => $arMultiField['VALUE'], 'VALUE_TYPE' => $arMultiField['VALUE_TYPE']);
        }
    }
    CCrmMobileHelper::PrepareLeadItem($arFields, $arParams, array('STATUS_LIST' => $arResult['STATUS_LIST'], 'SOURCE_LIST' => $arResult['SOURCE_LIST']));
}
$currencyID = $arFields['~CURRENCY_ID'];
$arResult['ENTITY'] = $arFields;
unset($arFields);
$arResult['PRODUCT_ROWS'] = $entityID > 0 ? CCrmProductRow::LoadRows('L', $entityID) : array();
foreach ($arResult['PRODUCT_ROWS'] as &$productRow) {
    $price = isset($productRow['PRICE']) ? doubleval($productRow['PRICE']) : 0.0;
    $qty = isset($productRow['QUANTITY']) ? doubleval($productRow['QUANTITY']) : 0;
    $sum = $productRow['SUM'] = $price * $qty;
    $productRow['FORMATTED_PRICE'] = CCrmCurrency::MoneyToString($price, $currencyID);
    $productRow['FORMATTED_SUM'] = CCrmCurrency::MoneyToString($sum, $currencyID);
    $productRow['CURRENCY_ID'] = $currencyID;
}
unset($productRow);
$sid = bitrix_sessid();
$serviceURLTemplate = $arParams["SERVICE_URL_TEMPLATE"] ? $arParams["SERVICE_URL_TEMPLATE"] : '#SITE_DIR#bitrix/components/bitrix/mobile.crm.lead.edit/ajax.php?site_id=#SITE#&sessid=#SID#';
$arResult['SERVICE_URL'] = CComponentEngine::makePathFromTemplate($serviceURLTemplate, array('SID' => $sid));
$productRowServiceURLTemplate = $arParams["PRODUCT_ROW_URL_TEMPLATE"] ? $arParams["PRODUCT_ROW_URL_TEMPLATE"] : '#SITE_DIR#bitrix/components/bitrix/mobile.crm.product_row.edit/ajax.php?site_id=#SITE#&sessid=#SID#';
$arResult['PRODUCT_ROW_SERVICE_URL'] = CComponentEngine::makePathFromTemplate($productRowServiceURLTemplate, array('SID' => $sid));
$arResult['STATUS_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['STATUS_SELECTOR_URL_TEMPLATE'], array('type_id' => 'STATUS', 'context_id' => $contextID));
$arResult['SOURCE_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['STATUS_SELECTOR_URL_TEMPLATE'], array('type_id' => 'SOURCE', 'context_id' => $contextID));
$arResult['CURRENCY_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['CURRENCY_SELECTOR_URL_TEMPLATE'], array('context_id' => ''));
$arResult['LEAD_STATUS_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['LEAD_STATUS_SELECTOR_URL_TEMPLATE'], array('context_id' => ''));
$arResult['PRODUCT_ROW_EDIT_URL'] = CComponentEngine::makePathFromTemplate($arParams['PRODUCT_ROW_EDIT_URL_TEMPLATE'], array('context_id' => ''));
$arResult['PRODUCT_SELECTOR_URL_TEMPLATE'] = CComponentEngine::makePathFromTemplate($arParams['PRODUCT_SELECTOR_URL_TEMPLATE'], array());
$this->IncludeComponentTemplate();
Exemple #19
0
 public static function SetTmpPath($PackageGuid, $pathToTmp)
 {
     CheckDirPath($pathToTmp);
     self::$sTmpPath = $pathToTmp . md5(serialize(array("PackageGuid " => $PackageGuid, "sessid" => bitrix_sessid())));
     return self::$sTmpPath;
 }
Exemple #20
0
.FieldEdit()"></div>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</div>

</div>
<?php 
}
?>

<?php 
$variables = array("mess" => array("collapseTabs" => GetMessage("interface_form_close_all"), "expandTabs" => GetMessage("interface_form_show_all"), "settingsTitle" => GetMessage("intarface_form_settings"), "settingsSave" => GetMessage("interface_form_save"), "tabSettingsTitle" => GetMessage("intarface_form_tab"), "tabSettingsSave" => "OK", "tabSettingsName" => GetMessage("intarface_form_tab_name"), "tabSettingsCaption" => GetMessage("intarface_form_tab_title"), "fieldSettingsTitle" => GetMessage("intarface_form_field"), "fieldSettingsName" => GetMessage("intarface_form_field_name"), "sectSettingsTitle" => GetMessage("intarface_form_sect"), "sectSettingsName" => GetMessage("intarface_form_sect_name")), "ajax" => array("AJAX_ID" => $arParams["AJAX_ID"], "AJAX_OPTION_SHADOW" => $arParams["AJAX_OPTION_SHADOW"] == "Y"), "settingWndSize" => CUtil::GetPopupSize("InterfaceFormSettingWnd"), "tabSettingWndSize" => CUtil::GetPopupSize("InterfaceFormTabSettingWnd", array('width' => 400, 'height' => 200)), "fieldSettingWndSize" => CUtil::GetPopupSize("InterfaceFormFieldSettingWnd", array('width' => 400, 'height' => 150)), "component_path" => $component->GetRelativePath(), "template_path" => $this->GetFolder(), "sessid" => bitrix_sessid(), "current_url" => $APPLICATION->GetCurPageParam("", array("bxajaxid", "AJAX_CALL")), "GRID_ID" => $arParams["THEME_GRID_ID"]);
?>
<script type="text/javascript">
var formSettingsDialog<?php 
echo $arParams["FORM_ID"];
?>
;
bxForm_<?php 
echo $arParams["FORM_ID"];
?>
 = new BxCrmInterfaceForm('<?php 
echo $arParams["FORM_ID"];
?>
', <?php 
echo CUtil::PhpToJsObject(array_keys($arResult["TABS"]));
?>
Exemple #21
0
                                                                        } else {
                                                                            if ($_POST['COMMAND'] == 'cancelTransfer') {
                                                                                $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']);
                                                                                CVoxImplantTransfer::Cancel($_POST['PARAMS']['CALL_ID']);
                                                                            } else {
                                                                                if ($_POST['COMMAND'] == 'timeoutTransfer') {
                                                                                    $_POST['PARAMS'] = CUtil::JsObjectToPhp($_POST['PARAMS']);
                                                                                    CVoxImplantTransfer::Timeout($_POST['PARAMS']['CALL_ID']);
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        echo CUtil::PhpToJsObject(array('BITRIX_SESSID' => bitrix_sessid(), 'ERROR' => 'SESSION_ERROR'));
    }
}
Exemple #22
0
    function ShowStepNoError()
    {
        global $APPLICATION;
        $wizard =& $this->GetWizard();
        $path = $wizard->package->path;
        $to_node_id = $wizard->GetVar('to_node_id');
        if ($wizard->GetVar('module')) {
            $module = $wizard->GetVar('module');
            $from_node_id = intval(COption::GetOptionString($module, "dbnode_id"));
            if ($from_node_id <= 0) {
                $from_node_id = 1;
            }
        } else {
            $from_node_id = $wizard->GetVar('from_node_id');
            $arNodeModules = CClusterDBNode::GetModules($wizard->GetVar('from_node_id'));
            $module = key($arNodeModules);
        }
        CJSCore::Init(array("ajax"));
        $APPLICATION->AddHeadScript($path . '/js/import.js');
        $this->content = '';
        $this->content .= '<div style="padding: 20px;">';
        $this->content .= '<div id="output"><br /></div>';
        $this->content .= '</div>';
        if ($wizard->GetPrevStepID() == 'step1' || $wizard->GetPrevStepID() == 'step2') {
            $this->content .= '
				<script type="text/javascript">
					var nextButtonID = "' . $wizard->GetNextButtonID() . '";
					var formID = "' . $wizard->GetFormName() . '";
					var LANG = \'' . LANG . '\';
					var from_node_id = "' . CUtil::JSEscape($from_node_id) . '";
					var to_node_id = "' . CUtil::JSEscape($to_node_id) . '";
					var module = "' . CUtil::JSEscape($module) . '";
					var status = "' . CUtil::JSEscape($wizard->GetVar('status')) . '";
					var path = "' . CUtil::JSEscape($path) . '";
					var sessid = "' . bitrix_sessid() . '";
					BX.ready(DisableButton);
					BX.ready(MoveTables);
				</script>
			';
        }
    }
Exemple #23
0
// current page index
$arResult['PAGE_NAVCOUNT'] = intval($dbRes->NavPageCount);
// page count
$arResult['PAGER_PARAM'] = "PAGEN_{$arResult['PAGE_NAVNUM']}";
$arResult['PAGE_NEXT_NUMBER'] = $arResult['PAGE_NUMBER'] + 1;
while ($item = $dbRes->GetNext()) {
    CCrmMobileHelper::PrepareContactItem($item, $arParams);
    $arResult['ITEMS'][] =& $item;
    unset($item);
}
//NEXT_PAGE_URL, SEARCH_PAGE_URL, SERVICE_URL -->
if ($arResult['PAGE_NEXT_NUMBER'] > $arResult['PAGE_NAVCOUNT']) {
    $arResult['NEXT_PAGE_URL'] = '';
} elseif ($companyID > 0) {
    $arResult['NEXT_PAGE_URL'] = $APPLICATION->GetCurPageParam('AJAX_CALL=Y&PAGING=Y&FORMAT=json&company_id=' . $companyID . '&' . $arResult['PAGER_PARAM'] . '=' . $arResult['PAGE_NEXT_NUMBER'], array('AJAX_CALL', 'PAGING', 'FORMAT', 'SEARCH', 'company_id', $arResult['PAGER_PARAM']));
} else {
    $arResult['NEXT_PAGE_URL'] = $APPLICATION->GetCurPageParam('AJAX_CALL=Y&PAGING=Y&FORMAT=json&SEARCH=' . ($enableSearch ? 'Y' : 'N') . '&' . $arResult['PAGER_PARAM'] . '=' . $arResult['PAGE_NEXT_NUMBER'], array('AJAX_CALL', 'PAGING', 'FORMAT', 'SEARCH', $arResult['PAGER_PARAM']));
}
$arResult['SEARCH_PAGE_URL'] = $APPLICATION->GetCurPageParam('AJAX_CALL=Y&SEARCH=Y&FORMAT=json&apply_filter=Y&save=Y', array('AJAX_CALL', 'SEARCH', 'FORMAT', 'save', 'apply_filter', 'clear_filter'));
$serviceURLTemplate = $arParams["SERVICE_URL_TEMPLATE"] ? $arParams["SERVICE_URL_TEMPLATE"] : '#SITE_DIR#bitrix/components/bitrix/mobile.crm.contact.edit/ajax.php?site_id=#SITE#&sessid=#SID#';
$arResult['SERVICE_URL'] = CComponentEngine::makePathFromTemplate($serviceURLTemplate, array('SID' => bitrix_sessid()));
//<-- NEXT_PAGE_URL, SEARCH_PAGE_URL, SERVICE_URL
$arResult['PERMISSIONS'] = array('CREATE' => CCrmContact::CheckCreatePermission());
$arResult['CREATE_URL'] = $arParams['CONTACT_EDIT_URL_TEMPLATE'] !== '' ? CComponentEngine::makePathFromTemplate($arParams['CONTACT_EDIT_URL_TEMPLATE'], array('contact_id' => 0, 'company_id' => $companyID)) : '';
$arResult['RELOAD_URL'] = $APPLICATION->GetCurPageParam('AJAX_CALL=Y&FORMAT=json', array('AJAX_CALL', 'SEARCH', 'FORMAT', 'save', 'apply_filter', 'clear_filter'));
$format = isset($_REQUEST['FORMAT']) ? strtolower($_REQUEST['FORMAT']) : '';
// Only JSON format is supported
if ($format !== '' && $format !== 'json') {
    $format = '';
}
$this->IncludeComponentTemplate($format);
Exemple #24
0
	public static function Init($arExt = array(), $bReturn = false)
	{
		if (!self::$bInited)
		{
			self::_RegisterStandardExt();
			self::$bInited = true;
		}

		$str = '';

		if (!is_array($arExt) && strlen($arExt) > 0)
			$arExt = array($arExt);

		$bReturn = ($bReturn === true); // prevent syntax mistake

		if (defined('BX_PUBLIC_MODE') && BX_PUBLIC_MODE == 1 && !$bReturn)
		{
			$bOldReturn = false;
			$bReturn = true;
		}

		$bNeedCore = false;
		if (count($arExt) > 0)
		{
			foreach ($arExt as $ext)
			{
				if (self::$arRegisteredExt[$ext] && !self::$arRegisteredExt[$ext]['skip_core'])
				{
					$bNeedCore = true;
					break;
				}
			}
		}
		else
		{
			$bNeedCore = true;
		}

		$ret = '';
		if ($bNeedCore && !self::$arCurrentlyLoadedExt['core'])
		{
			$autoTimeZone = "N";
			if(is_object($GLOBALS["USER"]))
				$autoTimeZone = trim($GLOBALS["USER"]->GetParam("AUTO_TIME_ZONE"));

			$arLang = array(
				'LANGUAGE_ID' => LANGUAGE_ID,
				'FORMAT_DATE' => FORMAT_DATE,
				'FORMAT_DATETIME' => FORMAT_DATETIME,
				'COOKIE_PREFIX' => COption::GetOptionString("main", "cookie_name", "BITRIX_SM"),
				'USER_ID' => $GLOBALS['USER']->GetID(),
				'SERVER_TIME' => time(),
				'SERVER_TZ_OFFSET' => date("Z"),
				'USER_TZ_OFFSET' => CTimeZone::GetOffset(),
				'USER_TZ_AUTO' => $autoTimeZone == 'N'? 'N': 'Y',
				'bitrix_sessid' => bitrix_sessid(),
			);
			if(!defined("ADMIN_SECTION") || ADMIN_SECTION !== true)
				$arLang["SITE_ID"] = SITE_ID;

			$ret .= self::_loadCSS('/bitrix/js/main/core/css/core.css', $bReturn);
			$ret .= self::_loadJS('/bitrix/js/main/core/core.js', $bReturn);
			$ret .= self::_loadLang(BX_ROOT.'/modules/main/lang/'.LANGUAGE_ID.'/js_core.php', $bReturn, $arLang);

			self::$arCurrentlyLoadedExt['core'] = true;
		}

		for ($i = 0, $len = count($arExt); $i < $len; $i++)
		{
			$ret .= self::_loadExt($arExt[$i], $bReturn);
		}

		if (defined('BX_PUBLIC_MODE') && BX_PUBLIC_MODE == 1 && !$bOldReturn)
			echo $ret;

		return $bReturn ? $ret : true;
	}
Exemple #25
0
 function PrologActions()
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $USER;
     if (defined("BX_CHECK_SHORT_URI") && BX_CHECK_SHORT_URI) {
         if ($arUri = CBXShortUri::GetUri($_SERVER["REQUEST_URI"])) {
             CBXShortUri::SetLastUsed($arUri["ID"]);
             if (CModule::IncludeModule("statistic")) {
                 CStatEvent::AddCurrent("short_uri_redirect", "", "", "", "", $arUri["URI"], "N", SITE_ID);
             }
             LocalRedirect($arUri["URI"], true, CBXShortUri::GetHttpStatusCodeText($arUri["STATUS"]));
             die;
         }
     }
     //session expander
     if (COption::GetOptionString("main", "session_expand", "Y") != "N" && (!defined("BX_SKIP_SESSION_EXPAND") || BX_SKIP_SESSION_EXPAND == false)) {
         $arPolicy = $USER->GetSecurityPolicy();
         $phpSessTimeout = ini_get("session.gc_maxlifetime");
         if ($arPolicy["SESSION_TIMEOUT"] > 0) {
             $sessTimeout = min($arPolicy["SESSION_TIMEOUT"] * 60, $phpSessTimeout);
         } else {
             $sessTimeout = $phpSessTimeout;
         }
         $cookie_prefix = COption::GetOptionString('main', 'cookie_name', 'BITRIX_SM');
         $salt = $_COOKIE[$cookie_prefix . '_UIDH'] . "|" . $_SERVER["REMOTE_ADDR"] . "|" . @filemtime($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/version.php") . "|" . LICENSE_KEY . "|" . CMain::GetServerUniqID();
         $key = md5(bitrix_sessid() . $salt);
         $bShowMess = $USER->IsAuthorized() && COption::GetOptionString("main", "session_show_message", "Y") != "N";
         $ext = array('ajax');
         if ($bShowMess) {
             $ext[] = "fx";
         }
         CUtil::InitJSCore($ext);
         $jsMsg = '<script type="text/javascript">' . "\n" . ($bShowMess ? 'bxSession.mess.messSessExpired = \'' . CUtil::JSEscape(GetMessage("MAIN_SESS_MESS", array("#TIMEOUT#" => round($sessTimeout / 60)))) . '\';' . "\n" : '') . 'bxSession.Expand(' . $sessTimeout . ', \'' . bitrix_sessid() . '\', ' . ($bShowMess ? 'true' : 'false') . ', \'' . $key . '\');' . "\n" . '</script>';
         if ($APPLICATION->IsJSOptimized()) {
             $APPLICATION->AddHeadScript('/bitrix/js/main/session.js');
             $APPLICATION->AddAdditionalJS($jsMsg);
         } else {
             $APPLICATION->AddHeadString('<script type="text/javascript" src="' . CUtil::GetAdditionalFileURL('/bitrix/js/main/session.js') . '"></script>' . "\n" . $jsMsg, true);
         }
         $_SESSION["BX_SESSION_COUNTER"] = intval($_SESSION["BX_SESSION_COUNTER"]) + 1;
         if (!defined("BX_SKIP_SESSION_TERMINATE_TIME")) {
             $_SESSION["BX_SESSION_TERMINATE_TIME"] = time() + $sessTimeout;
         }
     }
     //user auto time zone via js cookies
     if (CTimeZone::Enabled()) {
         CTimeZone::SetAutoCookie();
     }
     // check user options set via cookie
     if ($USER->IsAuthorized()) {
         $cookieName = COption::GetOptionString("main", "cookie_name", "BITRIX_SM") . "_LAST_SETTINGS";
         if (!empty($_COOKIE[$cookieName])) {
             CUserOptions::SetCookieOptions($cookieName);
         }
     }
     if (COption::GetOptionString("main", "buffer_content", "Y") == "Y" && (!defined("BX_BUFFER_USED") || BX_BUFFER_USED !== true)) {
         ob_start(array(&$APPLICATION, "EndBufferContent"));
         $APPLICATION->buffered = true;
         define("BX_BUFFER_USED", true);
         register_shutdown_function(create_function('', 'while(@ob_end_flush());'));
     }
     foreach (GetModuleEvents("main", "OnProlog", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent);
     }
 }
Exemple #26
0
 function __construct($params = array())
 {
     $this->status = new Status("ready");
     global $APPLICATION;
     $this->script = $APPLICATION->GetCurPageParam();
     $this->setParams($params);
     $this->path = \CTempFile::GetDirectoryName(12, array("bxu", md5(serialize(array($this->controlId, bitrix_sessid(), \CMain::GetServerUniqID())))));
     $this->processTime["max"] = intval(ini_get("max_execution_time")) * 0.75;
     $this->processTime["start"] = time();
     $this->log = new Log();
     $this->packLog = new Log();
     $this->http = new HttpClient();
     set_time_limit(0);
     return $this;
 }
Exemple #27
0
$CCrmBizProc = new CCrmBizProc('CONTACT');
$userID = CCrmSecurityHelper::GetCurrentUserID();
$isAdmin = CCrmPerms::IsAdmin();
$arResult['CURRENT_USER_ID'] = CCrmSecurityHelper::GetCurrentUserID();
$arParams['PATH_TO_CONTACT_LIST'] = CrmCheckPath('PATH_TO_CONTACT_LIST', $arParams['PATH_TO_CONTACT_LIST'], $APPLICATION->GetCurPage());
$arParams['PATH_TO_CONTACT_SHOW'] = CrmCheckPath('PATH_TO_CONTACT_SHOW', $arParams['PATH_TO_CONTACT_SHOW'], $APPLICATION->GetCurPage() . '?contact_id=#contact_id#&show');
$arParams['PATH_TO_CONTACT_EDIT'] = CrmCheckPath('PATH_TO_CONTACT_EDIT', $arParams['PATH_TO_CONTACT_EDIT'], $APPLICATION->GetCurPage() . '?contact_id=#contact_id#&edit');
$arParams['PATH_TO_COMPANY_SHOW'] = CrmCheckPath('PATH_TO_COMPANY_SHOW', $arParams['PATH_TO_COMPANY_SHOW'], $APPLICATION->GetCurPage() . '?company_id=#company_id#&show');
$arParams['PATH_TO_DEAL_EDIT'] = CrmCheckPath('PATH_TO_DEAL_EDIT', $arParams['PATH_TO_DEAL_EDIT'], $APPLICATION->GetCurPage() . '?deal_id=#deal_id#&edit');
$arParams['PATH_TO_QUOTE_EDIT'] = CrmCheckPath('PATH_TO_QUOTE_EDIT', $arParams['PATH_TO_QUOTE_EDIT'], $APPLICATION->GetCurPage() . '?quote_id=#quote_id#&edit');
$arParams['PATH_TO_INVOICE_EDIT'] = CrmCheckPath('PATH_TO_INVOICE_EDIT', $arParams['PATH_TO_INVOICE_EDIT'], $APPLICATION->GetCurPage() . '?invoice_id=#invoice_id#&edit');
$arParams['PATH_TO_USER_PROFILE'] = CrmCheckPath('PATH_TO_USER_PROFILE', $arParams['PATH_TO_USER_PROFILE'], '/company/personal/user/#user_id#/');
$arParams['PATH_TO_USER_BP'] = CrmCheckPath('PATH_TO_USER_BP', $arParams['PATH_TO_USER_BP'], '/company/personal/bizproc/');
$arParams['NAME_TEMPLATE'] = empty($arParams['NAME_TEMPLATE']) ? CSite::GetNameFormat(false) : str_replace(array("#NOBR#", "#/NOBR#"), array("", ""), $arParams["NAME_TEMPLATE"]);
$arResult['IS_AJAX_CALL'] = isset($_REQUEST['bxajaxid']) || isset($_REQUEST['AJAX_CALL']);
$arResult['SESSION_ID'] = bitrix_sessid();
CUtil::InitJSCore(array('ajax', 'tooltip'));
$arResult['GADGET'] = 'N';
if (isset($arParams['GADGET_ID']) && strlen($arParams['GADGET_ID']) > 0) {
    $arResult['GADGET'] = 'Y';
    $arResult['GADGET_ID'] = $arParams['GADGET_ID'];
}
$arFilter = $arSort = array();
$bInternal = false;
$arResult['FORM_ID'] = isset($arParams['FORM_ID']) ? $arParams['FORM_ID'] : '';
$arResult['TAB_ID'] = isset($arParams['TAB_ID']) ? $arParams['TAB_ID'] : '';
if (!empty($arParams['INTERNAL_FILTER']) || $arResult['GADGET'] == 'Y') {
    $bInternal = true;
}
$arResult['INTERNAL'] = $bInternal;
if (!empty($arParams['INTERNAL_FILTER']) && is_array($arParams['INTERNAL_FILTER'])) {
Exemple #28
0
    public function GetJSFunctionsForFields($parameterDocumentType, $objectName, $arDocumentFields = array(), $arDocumentFieldTypes = array())
    {
        if (!is_array($arDocumentFields) || count($arDocumentFields) <= 0) {
            $arDocumentFields = self::GetDocumentFields($parameterDocumentType);
        }
        if (!is_array($arDocumentFieldTypes) || count($arDocumentFieldTypes) <= 0) {
            $arDocumentFieldTypes = self::GetDocumentFieldTypes($parameterDocumentType);
        }
        list($moduleId, $entity, $documentType) = CBPHelper::ParseDocumentId($parameterDocumentType);
        if (strlen($moduleId) > 0) {
            CModule::IncludeModule($moduleId);
        }
        $documentFieldsString = "";
        foreach ($arDocumentFields as $fieldKey => $arFieldValue) {
            if (strlen($documentFieldsString) > 0) {
                $documentFieldsString .= ",";
            }
            $documentFieldsString .= "'" . Cutil::JSEscape($fieldKey) . "':{";
            $documentFieldsString .= "'Name':'" . CUtil::JSEscape($arFieldValue["Name"]) . "',";
            $documentFieldsString .= "'Type':'" . CUtil::JSEscape($arFieldValue["Type"]) . "',";
            $documentFieldsString .= "'Multiple':'" . CUtil::JSEscape($arFieldValue["Multiple"] ? "Y" : "N") . "',";
            $documentFieldsString .= "'Complex':'" . CUtil::JSEscape($arFieldValue["Complex"] ? "Y" : "N") . "',";
            $documentFieldsString .= "'Options':";
            if (array_key_exists("Options", $arFieldValue)) {
                if (is_array($arFieldValue["Options"])) {
                    $documentFieldsString .= "{";
                    $flTmp = false;
                    foreach ($arFieldValue["Options"] as $k => $v) {
                        if ($flTmp) {
                            $documentFieldsString .= ",";
                        }
                        $documentFieldsString .= "'" . CUtil::JSEscape($k) . "':'" . CUtil::JSEscape($v) . "'";
                        $flTmp = true;
                    }
                    $documentFieldsString .= "}";
                } else {
                    $documentFieldsString .= "'" . CUtil::JSEscape($arFieldValue["Options"]) . "'";
                }
            } else {
                $documentFieldsString .= "''";
            }
            $documentFieldsString .= "}";
        }
        $fieldTypesString = "";
        $ind = -1;
        foreach ($arDocumentFieldTypes as $typeKey => $arTypeValue) {
            $ind++;
            if (strlen($fieldTypesString) > 0) {
                $fieldTypesString .= ",";
            }
            $fieldTypesString .= "'" . CUtil::JSEscape($typeKey) . "':{";
            $fieldTypesString .= "'Name':'" . CUtil::JSEscape($arTypeValue["Name"]) . "',";
            $fieldTypesString .= "'BaseType':'" . CUtil::JSEscape($arTypeValue["BaseType"]) . "',";
            $fieldTypesString .= "'Complex':'" . CUtil::JSEscape($arTypeValue["Complex"] ? "Y" : "N") . "',";
            $fieldTypesString .= "'Index':" . $ind . "";
            $fieldTypesString .= "}";
        }
        $documentTypeString = CUtil::PhpToJSObject($parameterDocumentType);
        $bitrixSessId = bitrix_sessid();
        $result = <<<EOS
<script type="text/javascript">
var {$objectName} = {};

{$objectName}.arDocumentFields = { {$documentFieldsString} };
{$objectName}.arFieldTypes = { {$fieldTypesString} };

{$objectName}.AddField = function(fldCode, fldName, fldType, fldMultiple, fldOptions)
{
\tthis.arDocumentFields[fldCode] = {};
\tthis.arDocumentFields[fldCode]["Name"] = fldName;
\tthis.arDocumentFields[fldCode]["Type"] = fldType;
\tthis.arDocumentFields[fldCode]["Multiple"] = fldMultiple;
\tthis.arDocumentFields[fldCode]["Options"] = fldOptions;
}

{$objectName}._PrepareResponse = function(v)
{
\tv = v.replace(/^\\s+|\\s+\$/g, '');
\twhile (v.length > 0 && v.charCodeAt(0) == 65279)
\t\tv = v.substring(1);

\tif (v.length <= 0)
\t\treturn undefined;

\teval("v = " + v);

\treturn v;
}

{$objectName}.GetFieldInputControl4Type = function(type, value, name, subtypeFunctionName, func)
{
\tthis.GetFieldInputControlInternal(
\t\ttype,
\t\tvalue,
\t\tname,
\t\tfunction(v)
\t\t{
\t\t\tvar p = v.indexOf('<!--__defaultOptionsValue:');
\t\t\tif (p >= 0)
\t\t\t{
\t\t\t\tp = p + '<!--__defaultOptionsValue:'.length;
\t\t\t\tvar p1 = v.indexOf('-->', p);
\t\t\t\ttype['Options'] = v.substring(p, p1);
\t\t\t}

\t\t\tvar newPromt = "";

\t\t\tp = v.indexOf('<!--__modifyOptionsPromt:');
\t\t\tif (p >= 0)
\t\t\t{
\t\t\t\tp = p + '<!--__modifyOptionsPromt:'.length;
\t\t\t\tp1 = v.indexOf('-->', p);
\t\t\t\tnewPromt = v.substring(p, p1);
\t\t\t}

\t\t\tfunc(v, newPromt);
\t\t},
\t\tfalse,
\t\tsubtypeFunctionName,
\t\t'Type'
\t);
}

{$objectName}.GetFieldInputControl4Subtype = function(type, value, name, func)
{
\t{$objectName}.GetFieldInputControlInternal(type, value, name, func, false, '', '');
}

{$objectName}.GetFieldInputControl = function(type, value, name, func, als)
{
\t{$objectName}.GetFieldInputControlInternal(type, value, name, func, als, '', '');
}

{$objectName}.GetFieldInputControlInternal = function(type, value, name, func, als, subtypeFunctionName, mode)
{
\tif (typeof name == "undefined" || name.length <= 0)
\t\tname = "BPVDDefaultValue";

\tif (typeof type != "object")
\t\ttype = {'Type' : type, 'Multiple' : 0, 'Required' : 0, 'Options' : null};

\tif (typeof name != "object")
\t\tname = {'Field' : name, 'Form' : null};

\tBX.ajax.post(
\t\t'/bitrix/tools/bizproc_get_field.php',
\t\t{
\t\t\t'DocumentType' : {$documentTypeString},
\t\t\t'Field' : name,
\t\t\t'Value' : value,
\t\t\t'Type' : type,
\t\t\t'Als' : als ? 1 : 0,
\t\t\t'rnd' : Math.random(),
\t\t\t'Mode' : mode,
\t\t\t'Func' : subtypeFunctionName,
\t\t\t'sessid' : '{$bitrixSessId}'
\t\t},
\t\tfunc
\t);
}

{$objectName}.GetFieldValueByTagName = function(tag, name, form)
{
\tvar fieldValues = {};

\tvar ar;
\tif (form && (form.length > 0))
\t{
\t\tvar obj = document.getElementById(form);
\t\tif (!obj)
\t\t{
\t\t\tfor (var i in document.forms)
\t\t\t{
\t\t\t\tif (document.forms[i].name == form)
\t\t\t\t{
\t\t\t\t\tobj = document.forms[i];
\t\t\t\t\tbreak;
\t\t\t\t}
\t\t\t}
\t\t}

\t\tif (!obj)
\t\t\treturn;

\t\tar = obj.getElementsByTagName(tag);
\t}
\telse
\t{
\t\tar = document.getElementsByTagName(tag);
\t}

\tfor (var i in ar)
\t{
\t\tif (ar[i] && ar[i].name && (ar[i].name.length >= name.length) && (ar[i].name.substr(0, name.length) == name))
\t\t{
\t\t\tif (ar[i].type.substr(0, "select".length) == "select")
\t\t\t{
\t\t\t\tif (ar[i].multiple)
\t\t\t\t{
\t\t\t\t\tvar newName = ar[i].name.replace(/\\[\\]/g, "");
\t\t\t\t\tfor (var j = 0; j < ar[i].options.length; j++)
\t\t\t\t\t{
\t\t\t\t\t\tif (ar[i].options[j].selected)
\t\t\t\t\t\t{
\t\t\t\t\t\t\tif ((typeof(fieldValues[newName]) != 'object') || !(fieldValues[newName] instanceof Array))
\t\t\t\t\t\t\t{
\t\t\t\t\t\t\t\tif (fieldValues[newName])
\t\t\t\t\t\t\t\t\tfieldValues[newName] = [fieldValues[newName]];
\t\t\t\t\t\t\t\telse
\t\t\t\t\t\t\t\t\tfieldValues[newName] = [];
\t\t\t\t\t\t\t}
\t\t\t\t\t\t\tfieldValues[newName][fieldValues[newName].length] = ar[i].options[j].value;
\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t}
\t\t\t\telse
\t\t\t\t{
\t\t\t\t\tif (ar[i].selectedIndex >= 0)
\t\t\t\t\t\tfieldValues[ar[i].name] = ar[i].options[ar[i].selectedIndex].value;
\t\t\t\t}
\t\t\t}
\t\t\telse
\t\t\t{
\t\t\t\tif (ar[i].name.indexOf("[]", 0) >= 0)
\t\t\t\t{
\t\t\t\t\tvar newName = ar[i].name.replace(/\\[\\]/g, "");

\t\t\t\t\tif ((typeof(fieldValues[newName]) != 'object') || !(fieldValues[newName] instanceof Array))
\t\t\t\t\t{
\t\t\t\t\t\tif (fieldValues[newName])
\t\t\t\t\t\t\tfieldValues[newName] = [fieldValues[newName]];
\t\t\t\t\t\telse
\t\t\t\t\t\t\tfieldValues[newName] = [];
\t\t\t\t\t}

\t\t\t\t\tfieldValues[newName][fieldValues[newName].length] = ar[i].value;
\t\t\t\t}
\t\t\t\telse
\t\t\t\t{
\t\t\t\t\tfieldValues[ar[i].name] = ar[i].value;
\t\t\t\t}
\t\t\t}
\t\t}
\t}

\treturn fieldValues;
}

{$objectName}.GetFieldInputValue = function(type, name, func)
{
\tif (typeof name == "undefined" || name.length <= 0)
\t\tname = "BPVDDefaultValue";

\tif (typeof type != "object")
\t\ttype = {'Type' : type, 'Multiple' : 0, 'Required' : 0, 'Options' : null};

\tif (typeof name != "object")
\t\tname = {'Field' : name, 'Form' : null};

\tvar s = {
\t\t'DocumentType' : {$documentTypeString},
\t\t'Field' : name,
\t\t'Type' : type,
\t\t'rnd' : Math.random(),
\t\t'sessid' : '{$bitrixSessId}'
\t};

\tif (type != null && type['Type'] != "F")
\t{
\t\tvar ar = this.GetFieldValueByTagName('input', name['Field'], name['Form']);
\t\tfor (var v in ar)
\t\t\ts[v] = ar[v];
\t\tar = this.GetFieldValueByTagName('select', name['Field'], name['Form']);
\t\tfor (var v in ar)
\t\t\ts[v] = ar[v];
\t\tar = this.GetFieldValueByTagName('textarea', name['Field'], name['Form']);
\t\tfor (var v in ar)
\t\t\ts[v] = ar[v];
\t\tar = this.GetFieldValueByTagName('hidden', name['Field'], name['Form']);
\t\tfor (var v in ar)
\t\t\ts[v] = ar[v];
\t}

\tBX.ajax.post('/bitrix/tools/bizproc_set_field.php', s, function(v){v = {$objectName}._PrepareResponse(v); func(v);});
}

{$objectName}.HtmlSpecialChars = function(string, quote)
{
\tstring = string.toString();
\tstring = string.replace(/&/g, '&amp;');
\tstring = string.replace(/</g, '&lt;');
\tstring = string.replace(/>/g, '&gt;');
\tstring = string.replace(/"/g, '&quot;');

\tif (quote)
\t\tstring = string.replace(/'/g, '&#039;');

\treturn string;
}

{$objectName}.GetGUITypeEdit = function(type)
{
\treturn "";
}

{$objectName}.SetGUITypeEdit = function(type)
{
\treturn "";
}

function __dump_bx(arr, limitLevel, txt)
{
\tif (limitLevel == undefined)
\t\tlimitLevel = 3;
\tif (txt == undefined)
\t\ttxt = "";
\telse
\t\ttxt += ":\\n";
\talert(txt+__dumpInternal_bx(arr, 0, limitLevel));
}
function __dumpInternal_bx(arr, level, limitLevel) {
\tvar dumped_text = "";
\tif(!level) level = 0;
\tif (level > limitLevel)
\t\treturn "";
\tvar level_padding = "";
\tfor(var j=0;j<level+1;j++) level_padding += "    ";
\tif(typeof(arr) == 'object') {
\t\tfor(var item in arr) {
\t\t\tvar value = arr[item];
\t\t\tif(typeof(value) == 'object') {
\t\t\t\tdumped_text += level_padding + "'" + item + "' ...\\n";
\t\t\t\tdumped_text += __dumpInternal_bx(value, level+1, limitLevel);
\t\t\t} else {
\t\t\t\tdumped_text += level_padding + "'" + item + "' => '" + value + "'\\n";
\t\t\t}
\t\t}
\t} else {
\t\tdumped_text = "===>"+arr+"<===("+typeof(arr)+")";
\t}

\treturn dumped_text;
}

</script>
EOS;
        if (class_exists($entity) && method_exists($entity, "GetJSFunctionsForFields")) {
            $result .= call_user_func_array(array($entity, "GetJSFunctionsForFields"), array($documentType, $objectName, $arDocumentFields, $arDocumentFieldTypes));
        } else {
            if (!is_array($arDocumentFields) || count($arDocumentFields) <= 0) {
                $arDocumentFields = $this->GetDocumentFields($parameterDocumentType);
            }
            if (!is_array($arDocumentFieldTypes) || count($arDocumentFieldTypes) <= 0) {
                $arDocumentFieldTypes = $this->GetDocumentFieldTypes($parameterDocumentType);
            }
            $result .= CBPHelper::GetJSFunctionsForFields($objectName, $arDocumentFields, $arDocumentFieldTypes);
        }
        return $result;
    }
        ShowError(Loc::getMessage('BX_SALE_DISCOUNT_COUPON_ERR_DISCOUNT_ID_ABSENT'));
        require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin.php';
        die;
    }
}
$returnUrl = '';
if (!$subWindow && !empty($_REQUEST['return_url'])) {
    $currentUrl = $APPLICATION->GetCurPage();
    if (strtolower(substr($_REQUEST['return_url'], strlen($currentUrl))) != strtolower($currentUrl)) {
        $returnUrl = $_REQUEST['return_url'];
    }
}
$tabList = array(array('ICON' => 'sale', 'DIV' => 'couponEdit01', 'TAB' => Loc::getMessage('BX_SALE_DISCOUNT_COUPON_EDIT_TAB_NAME_COMMON'), 'TITLE' => $multiCoupons ? Loc::getMessage('BX_SALE_DISCOUNT_COUPON_EDIT_TAB_TITLE_MULTI_COMMON') : Loc::getMessage('BX_SALE_DISCOUNT_COUPON_EDIT_TAB_TITLE_COMMON')));
$couponFormID = '';
if ($subWindow) {
    $arPostParams = array('bxpublic' => 'Y', 'DISCOUNT_ID' => $discountID, 'sessid' => bitrix_sessid());
    $listUrl = array('LINK' => $APPLICATION->GetCurPageParam(), 'POST_PARAMS' => $arPostParams);
    $couponFormID = 'saleSubCouponControl';
    $control = new CAdminSubForm($couponFormID, $tabList, false, true, $listUrl, false);
} else {
    $couponFormID = $multiCoupons ? 'saleMultiCouponControl' : 'saleCouponControl';
    $control = new CAdminForm($couponFormID, $tabList);
    $control->SetShowSettings(false);
}
unset($tabList);
$couponFormID .= '_form';
$errors = array();
$fields = array();
$couponID = 0;
$copy = false;
if (isset($_REQUEST['ID'])) {
Exemple #30
0
    $parentId = false;
    if (CSaleLocation::isLocationProEnabled()) {
        if ($locID) {
            $res = Location\LocationTable::getByID($locID)->fetch();
            if (!!$res['ID']) {
                $parentId = $res['PARENT_ID'];
            }
        } elseif (isset($_REQUEST['PARENT_ID'])) {
            $parentId = intval($_REQUEST['PARENT_ID']);
        }
    }
    // GO TO PARENT LIST IN EDIT
    $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_LOC_LIST'), 'TITLE' => GetMessage('CRM_LOC_LIST_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_LIST'], array()), 'ICON' => 'btn-list');
    // ADD IN EDIT
    if ($locAdd) {
        $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_LOC_ADD'), 'TITLE' => GetMessage('CRM_LOC_ADD_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_ADD'], array()) . ($parentId !== false ? '?PARENT_ID=' . $parentId : ''), 'ICON' => 'btn-new');
    }
} elseif ($arParams['TYPE'] == 'show') {
}
// GO TO LIST ROOT FROM IMPORT
if ($arParams['TYPE'] == 'import') {
    $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_LOC_LIST'), 'TITLE' => GetMessage('CRM_LOC_LIST_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_LIST'], array()), 'ICON' => 'btn-list');
}
if ($locEdit && $arParams['TYPE'] == 'show' && $exists) {
    $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_LOC_EDIT'), 'TITLE' => GetMessage('CRM_LOC_EDIT_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_EDIT'], array('loc_id' => $locID)), 'ICON' => 'btn-edit');
}
// DELETE
if ($locDelete && ($arParams['TYPE'] == 'edit' || $arParams['TYPE'] == 'show') && $exists) {
    $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_LOC_DELETE'), 'TITLE' => GetMessage('CRM_LOC_DELETE_TITLE'), 'LINK' => "javascript:loc_delete('" . GetMessage('CRM_LOC_DELETE_DLG_TITLE') . "', '" . GetMessage('CRM_LOC_DELETE_DLG_MESSAGE') . "', '" . GetMessage('CRM_LOC_DELETE_DLG_BTNTITLE') . "', '" . CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LOCATIONS_EDIT'], array('loc_id' => $locID)), array('delete' => '', 'sessid' => bitrix_sessid())) . "')", 'ICON' => 'btn-delete');
}
$this->IncludeComponentTemplate();