Exemple #1
0
 /**
  * Imports hot keys from file and binds them to user
  * @param string $fileName - absolute path to file with serialized data
  * @param int $userID - user's id wich recieves our hot-keys from file
  * @return int count added hot keys
  * */
 public function Import($fileName, $userID)
 {
     $fileContent = file_get_contents($fileName);
     if (!$fileContent) {
         return false;
     }
     $arInput = null;
     if (CheckSerializedData($fileContent)) {
         $arInput = unserialize($fileContent);
     }
     if (!is_array($arInput) || empty($arInput)) {
         return false;
     }
     $added = 0;
     foreach ($arInput as $arHotKey) {
         $codeID = false;
         if (!isset($arHotKey['IS_CUSTOM']) || !isset($arHotKey['KEYS_STRING']) || !isset($arHotKey['NAME']) || !$this->CheckKeysString($arHotKey['KEYS_STRING'])) {
             continue;
         }
         //if custom code
         if ($arHotKey['IS_CUSTOM']) {
             if (!isset($arHotKey['CODE'])) {
                 continue;
             }
             $resCodes = self::$codes->GetList(array(), array('CLASS_NAME' => isset($arHotKey['CLASS_NAME']) ? $arHotKey['CLASS_NAME'] : '', 'NAME' => $arHotKey['NAME'], 'CODE' => $arHotKey['CODE']));
             $arCode = $resCodes->Fetch();
             //if same code alredy exist
             if (isset($arCode['ID'])) {
                 $codeID = $arCode['ID'];
             } else {
                 $codeID = self::$codes->Add(array('CLASS_NAME' => isset($arHotKey['CLASS_NAME']) ? $arHotKey['CLASS_NAME'] : "", 'CODE' => $arHotKey['CODE'], 'NAME' => $arHotKey['NAME'], 'COMMENTS' => isset($arHotKey['COMMENTS']) ? $arHotKey['COMMENTS'] : "", 'TITLE_OBJ' => isset($arHotKey['TITLE_OBJ']) ? $arHotKey['TITLE_OBJ'] : "", 'URL' => isset($arHotKey['URL']) ? $arHotKey['URL'] : "", 'IS_CUSTOM' => $arHotKey['IS_CUSTOM']));
             }
         } else {
             $resCodes = self::$codes->GetList(array(), array('CLASS_NAME' => isset($arHotKey['CLASS_NAME']) ? $arHotKey['CLASS_NAME'] : '', 'NAME' => $arHotKey['NAME']));
             $arCode = $resCodes->Fetch();
             if (isset($arCode['ID'])) {
                 $codeID = $arCode['ID'];
             }
         }
         if (!$codeID) {
             continue;
         }
         $resHK = $this->GetList(array(), array("CODE_ID" => $codeID, "USER_ID" => intval($userID)));
         $arHK = $resHK->Fetch();
         //if this code alredy binding to some keys for this user
         if ($arHK) {
             $hkID = $arHK['ID'];
             $this->Update($hkID, array("KEYS_STRING" => $arHotKey["KEYS_STRING"], "CODE_ID" => $codeID, "USER_ID" => intval($userID)));
         } else {
             $hkID = $this->Add(array("KEYS_STRING" => $arHotKey["KEYS_STRING"], "CODE_ID" => $codeID, "USER_ID" => intval($userID)));
         }
         if ($hkID) {
             $added++;
         }
     }
     return $added;
 }
Exemple #2
0
 function SetHotKeys()
 {
     $arHK = array("B" => "Alt+66", "I" => "Alt+73", "U" => "Alt+85", "QUOTE" => "Alt+81", "CODE" => "Alt+67", "TRANSLIT" => "Alt+84");
     $hkc = new CHotKeysCode();
     foreach ($arHK as $s => $hk) {
         $className = "TICKET_EDIT_{$s}";
         $arHKC = array(CLASS_NAME => $className, CODE => "var d=document.getElementById('{$s}'); if (d) d.click();", NAME => " ({$id})", TITLE_OBJ => "TICKET_EDIT_" . $s . "_T", IS_CUSTOM => "1");
         $objK = $hkc->GetList(array(), array("CLASS_NAME" => $className));
         if ($arK = $objK->Fetch()) {
             $hkc->Update($arK["ID"], $arHKC);
         } else {
             $id = $hkc->Add($arHKC);
             if ($id > 0) {
                 $result = CHotKeys::GetInstance()->AddDefaultKeyToAll($id, $hk);
             }
         }
     }
 }
Exemple #3
0
{
	$arFields = array(
			"CLASS_NAME"=>$_REQUEST["CLASS_NAME"],
			"CODE"=>$_REQUEST["CODE"],
			"NAME"=>$_REQUEST["NAME"],
			"COMMENTS" => $_REQUEST["COMMENTS"],
			"TITLE_OBJ"=>$_REQUEST["TITLE_OBJ"],
			"URL"=>$_REQUEST["URL"],
	);

	if($ID>0)
		$res = $hotKeyCodes->Update($ID, $arFields);

	else
	{
		$ID = $hotKeyCodes->Add($arFields);
		$res = ($ID>0);
	}

	if($res)
	{
		if(isset($_POST['apply']))
			LocalRedirect("hot_keys_edit.php?ID=".$ID."&lang=".LANG."&applied=ok");
		else
			LocalRedirect(($_REQUEST["addhk"]<>""? $_REQUEST["addhk"]:"hot_keys_list.php?lang=".LANG));
	}
	else
	{
		if($e = $APPLICATION->GetException())
			$errMess = new CAdminMessage(GetMessage("HK_EDIT_ERROR"),$e);
		else
Exemple #4
0
 function Add($arFields, $checkDuplicate = false)
 {
     global $DB;
     if (!CFavorites::CheckFields($arFields)) {
         return false;
     }
     if ($checkDuplicate) {
         $duplicate = CFavorites::IsExistDuplicate($arFields);
         if ($duplicate) {
             return $duplicate;
         }
     }
     $codes = new CHotKeysCode();
     $codeID = $codes->Add(array("CODE" => "location.href='" . $arFields["URL"] . "';", "NAME" => $arFields["NAME"], "COMMENTS" => "FAVORITES"));
     $codes->Update($codeID, array("CLASS_NAME" => "FAV-" . $codeID, "TITLE_OBJ" => "FAV-" . $codeID));
     $arFields["CODE_ID"] = intval($codeID);
     $ID = $DB->Add("b_favorite", $arFields);
     return $ID;
 }