Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sms.php
1<?php
9
11
14
15Loc::loadMessages(__FILE__);
16
21class Sms
22{
31 public static function onPresetTemplateList($templateType = null, $templateId = null, $messageCode = null)
32 {
33 if($templateType && $templateType !== 'BASE')
34 {
35 return array();
36 }
37 if($messageCode && !in_array($messageCode, self::getProvidedMessageCodes()))
38 {
39 return array();
40 }
41
42 return self::getTemplates($templateId, $messageCode = null);
43 }
44
45 private static function getProvidedMessageCodes()
46 {
47 return array(
48 Message\iBase::CODE_CALL,
49 Message\iBase::CODE_SMS,
50 Message\iBase::CODE_IM,
51 );
52 }
53
54 private static function getTemplates($templateId = null, $messageCode = null)
55 {
56 $messageCodes = $messageCode ? array($messageCode) : self::getProvidedMessageCodes();
57
58 $result = array();
59 foreach ($messageCodes as $messageCode)
60 {
61 $textMessageCode = $messageCode;
62 if ($messageCode === Message\iBase::CODE_CALL)
63 {
64 $textMessageCode = Message\iBase::CODE_SMS;
65 }
66
67 foreach (Texts::getListByType($textMessageCode) as $item)
68 {
69 $code = mb_strtolower($messageCode."_".$item['CODE']);
70 if($templateId && $code !== $templateId)
71 {
72 continue;
73 }
74
75 $result[] = array(
76 'ID' => $code,
77 'TYPE' => Type::getCode(Type::BASE),
78 'MESSAGE_CODE' => array($messageCode),
79 'VERSION' => 2,
80 'HOT' => $item['HOT'],
81 'ICON' => $item['ICON'],
82
83 'NAME' => $item['NAME'],
84 'DESC' => $item['DESC'],
85 'FIELDS' => array(
86 'MESSAGE_TEXT' => array(
87 'CODE' => 'MESSAGE_TEXT',
88 'VALUE' => $item['TEXT'],
89 )
90 ),
91 );
92 }
93 }
94
95 return $result;
96 }
97}
static loadMessages($file)
Definition loc.php:64
static onPresetTemplateList($templateType=null, $templateId=null, $messageCode=null)
Definition sms.php:31