Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
type.php
1<?php
9
12
13Loc::loadMessages(__FILE__);
14
19class Type extends ClassConstant
20{
21 const EMAIL = 1;
22 const PHONE = 2;
23 const IM = 3;
24 const CRM_COMPANY_ID = 4;
25 const CRM_CONTACT_ID = 5;
26 const CRM_LEAD_ID = 10;
31
39 public static function detect($recipientCode, $isNormalized = false)
40 {
41 $list = self::getNamedList();
42 unset($list[self::PHONE]);
43 $list = array_keys($list);
44 $list[] = self::PHONE;
45
46 foreach ($list as $id)
47 {
48 if ($isNormalized)
49 {
50 $normalizedCode = $recipientCode;
51 }
52 else
53 {
54 $normalizedCode = Normalizer::normalize($recipientCode, $id);
55 }
56
57 if (!Validator::validate($normalizedCode, $id))
58 {
59 continue;
60 }
61
62 return $id;
63 }
64
65 return null;
66 }
67
74 public static function getName($id)
75 {
76 $code = self::getCode($id);
77 $name = Loc::getMessage('SENDER_TYPE_CAPTION_' . $code) ?: $code;
78 return $name;
79 }
80}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static detect($recipientCode, $isNormalized=false)
Definition type.php:39