Exemplo n.º 1
0
 public static function convertValue($method, $valueType, $value)
 {
     $result = null;
     $convert = 'no';
     if ($valueType === 'datetime' || $valueType === 'date') {
         $postfix = '';
         switch ($valueType) {
             case 'datetime':
                 $postfix = '_dt';
                 break;
             case 'date':
                 $postfix = '_d';
                 break;
         }
         switch ($method) {
             case 'add':
             case 'update':
                 $convert = 'in' . $postfix;
                 break;
             case 'list':
             case 'get':
                 $convert = 'out' . $postfix;
                 break;
         }
     }
     switch ($convert) {
         case 'no':
             $result = $value;
             break;
         case 'in_dt':
             $result = CRestUtil::unConvertDateTime($value);
             break;
         case 'in_d':
             $result = CRestUtil::unConvertDate($value);
             break;
         case 'out_dt':
             $result = CRestUtil::ConvertDateTime($value);
             break;
         case 'out_d':
             $result = CRestUtil::ConvertDate($value);
             break;
     }
     return $result;
 }
Exemplo n.º 2
0
 public static function sipConnectorStatus()
 {
     if (!CVoxImplantMain::CheckAccess()) {
         throw new \Bitrix\Rest\AccessException();
     }
     $ViHttp = new CVoxImplantHttp();
     $info = $ViHttp->GetSipInfo();
     if (!$info || $ViHttp->GetError()->error) {
         throw new Bitrix\Rest\RestException($ViHttp->GetError()->msg, $ViHttp->GetError()->code, CRestServer::STATUS_WRONG_REQUEST);
     }
     $result = array('FREE_MINUTES' => intval($info->FREE), 'PAID' => $info->ACTIVE);
     if ($info->ACTIVE) {
         $result['PAID_DATE_END'] = CRestUtil::ConvertDate($info->DATE_END);
     }
     return $result;
 }
Exemplo n.º 3
0
 protected function tryExternalizeProductPropertyField(&$fields, &$fieldsInfo, $fieldName)
 {
     if (!is_array($fields) || !isset($fields[$fieldName])) {
         return;
     }
     $info = isset($fieldsInfo[$fieldName]) ? $fieldsInfo[$fieldName] : null;
     $value = isset($fields[$fieldName]) ? $fields[$fieldName] : null;
     if (!$info) {
         unset($fields[$fieldName]);
         return;
     }
     $attrs = isset($info['ATTRIBUTES']) ? $info['ATTRIBUTES'] : array();
     $isMultiple = in_array(CCrmFieldInfoAttr::Multiple, $attrs, true);
     $isDynamic = in_array(CCrmFieldInfoAttr::Dynamic, $attrs, true);
     $fieldType = isset($info['TYPE']) ? $info['TYPE'] : '';
     $propertyType = isset($info['PROPERTY_TYPE']) ? $info['PROPERTY_TYPE'] : '';
     $userType = isset($info['USER_TYPE']) ? $info['USER_TYPE'] : '';
     if ($fieldType === 'product_property' && $propertyType === 'S' && $userType === 'Date') {
         if (self::isIndexedArray($value)) {
             $fields[$fieldName] = array();
             CTimeZone::Disable();
             foreach ($value as $valueElement) {
                 if (isset($valueElement['VALUE_ID']) && isset($valueElement['VALUE'])) {
                     $fields[$fieldName][] = array('valueId' => $valueElement['VALUE_ID'], 'value' => CRestUtil::ConvertDate($valueElement['VALUE']));
                 }
             }
             CTimeZone::Enable();
         } else {
             if (isset($value['VALUE_ID']) && isset($value['VALUE'])) {
                 CTimeZone::Disable();
                 $fields[$fieldName] = array('valueId' => $value['VALUE_ID'], 'value' => CRestUtil::ConvertDate($value['VALUE']));
                 CTimeZone::Enable();
             } else {
                 $fields[$fieldName] = null;
             }
         }
     } elseif ($fieldType === 'product_property' && $propertyType === 'S' && $userType === 'DateTime') {
         if (self::isIndexedArray($value)) {
             $fields[$fieldName] = array();
             foreach ($value as $valueElement) {
                 if (isset($valueElement['VALUE_ID']) && isset($valueElement['VALUE'])) {
                     $fields[$fieldName][] = array('valueId' => $valueElement['VALUE_ID'], 'value' => CRestUtil::ConvertDateTime($valueElement['VALUE']));
                 }
             }
         } else {
             if (isset($value['VALUE_ID']) && isset($value['VALUE'])) {
                 $fields[$fieldName] = array('valueId' => $value['VALUE_ID'], 'value' => CRestUtil::ConvertDateTime($value['VALUE']));
             } else {
                 $fields[$fieldName] = null;
             }
         }
     } elseif ($fieldType === 'product_property' && $propertyType === 'F' && empty($userType)) {
         $this->tryExternalizeProductFileField($fields, $fieldName, $isMultiple, $isDynamic);
     } else {
         if (self::isIndexedArray($value)) {
             $fields[$fieldName] = array();
             foreach ($value as $valueElement) {
                 if (isset($valueElement['VALUE_ID']) && isset($valueElement['VALUE'])) {
                     $fields[$fieldName][] = array('valueId' => $valueElement['VALUE_ID'], 'value' => $valueElement['VALUE']);
                 }
             }
         } else {
             if (isset($value['VALUE_ID']) && isset($value['VALUE'])) {
                 $fields[$fieldName] = array('valueId' => $value['VALUE_ID'], 'value' => $value['VALUE']);
             } else {
                 $fields[$fieldName] = null;
             }
         }
     }
 }