Example #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;
 }
Example #2
0
<?
// v.091

require_once(dirname(__FILE__)."/../include/prolog_admin_before.php");

ClearVars();

if(!$USER->CanDoOperation('edit_other_settings'))
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));

IncludeModuleLangFile(__FILE__);

$ID = intval($ID);

$hotKeyCodes = new CHotKeysCode;
$str_IS_CUSTOM = true;
$errMess = "";
$bVarsFromForm = false;

if($_SERVER['REQUEST_METHOD']=="POST" && ($_POST['save']<>"" || $_POST['apply']<>"") && check_freetrix_sessid())
{
	$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)
Example #3
0
 function Delete($ID)
 {
     global $DB;
     $codes = new CHotKeysCode();
     $res = CFavorites::GetByID($ID);
     while ($arFav = $res->Fetch()) {
         $codes->Delete($arFav["CODE_ID"]);
     }
     return $DB->Query("DELETE FROM b_favorite WHERE ID='" . intval($ID) . "'", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
 }
Example #4
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);
             }
         }
     }
 }
Example #5
0
<?
// v.091

require_once(dirname(__FILE__)."/../include/prolog_admin_before.php");

IncludeModuleLangFile(__FILE__);

if(!$USER->CanDoOperation('edit_other_settings') && !$USER->CanDoOperation('view_other_settings'))
	$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));

$isAdmin = $USER->CanDoOperation('edit_other_settings');

$sTableID = "tbl_hk_codes";
$oSort = new CAdminSorting($sTableID, "id", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
$hotKeyCodes = new CHotKeysCode;

$FilterArr = Array(
	"find_class_name",
	"find_code",
	"find_name",
	"find_url",
	"find_is_custom",
);

$lAdmin->InitFilter($FilterArr);

$arFilter = Array(
	"CLASS_NAME"	=> $find_class_name,
	"CODE"			=> $find_code,
	"NAME"			=> $find_name,