Beispiel #1
0
 /**
  * This method is only for rest purposes
  */
 public function deleteFile($attachmentId)
 {
     Attachment::delete($this->getId(), $attachmentId, array('USER_ID' => $GLOBALS['USER']->GetId(), 'ENTITY_ID' => UserField::getTargetEntityId(), 'FIELD_NAME' => 'UF_TASK_WEBDAV_FILES'));
     // drop cache
     $this->markCacheAsDirty();
 }
Beispiel #2
0
 public static function postProcessValues($values, $parameters = array())
 {
     if (!is_array($parameters)) {
         $parameters = array();
     }
     if (!isset($parameters['FIELDS'])) {
         $parameters['FIELDS'] = array();
         $res = static::getFieldList();
         while ($item = $res->fetch()) {
             $parameters['FIELDS'][$item['FIELD_NAME']] = $item;
         }
     }
     if (!isset($parameters['SERVER']) || !$parameters['SERVER'] instanceof \CRestServer) {
         throw new \Bitrix\Main\ArgumentException('Argument $parameters[SERVER] should be a valid CRestServer instance');
     }
     foreach ($parameters['FIELDS'] as $fieldName => $fieldData) {
         if (isset($values[$fieldData['FIELD_NAME']])) {
             $value = $values[$fieldData['FIELD_NAME']];
             if (is_array($value) && empty($value) || (string) $value == '') {
                 continue;
             }
             if ($fieldData['MULTIPLE'] == 'N') {
                 $value = array($value);
             }
             // only disk files will be converted
             if ($fieldData['USER_TYPE_ID'] == 'disk_file') {
                 foreach ($value as $i => $attachmentId) {
                     $value[$i] = Attachment::getById($attachmentId, array('SERVER' => $parameters['SERVER']));
                 }
             }
             $values[$fieldData['FIELD_NAME']] = $fieldData['MULTIPLE'] == 'N' ? $value[0] : $value;
         }
     }
     return $values;
 }