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); } } } }
/** * 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; }
$ID = IntVal($ID); if($ID <= 0) continue; if(!$hotKeyCodes->Update($ID, $arFields)) { $e = $APPLICATION->GetException(); $lAdmin->AddUpdateError(($e? $e->GetString():GetMessage("HK_UPDATE_ERROR")), $ID); } } } if(($arID = $lAdmin->GroupAction())) { if($_REQUEST['action_target']=='selected') { $rsData = $hotKeyCodes->GetList(array($by=>$order), $arFilter); while($arRes = $rsData->Fetch()) $arID[] = $arRes['ID']; } foreach($arID as $ID) { $ID = IntVal($ID); if($ID <= 0) continue; switch($_REQUEST['action']) { case "delete": if(!$hotKeyCodes->Delete($ID)) $lAdmin->AddGroupError(GetMessage("HK_DELETION_ERROR"), $ID);