/** * Gets fields which Externalizer or Internalizer should modify. * @return array */ public function getFieldsForMap() { return array('TYPE' => array('IN' => function ($externalValue) { switch ($externalValue) { case 'folder': return ObjectTable::TYPE_FOLDER; case 'file': return ObjectTable::TYPE_FILE; } return null; }, 'OUT' => function ($internalValue) { switch ($internalValue) { case ObjectTable::TYPE_FOLDER: return 'folder'; case ObjectTable::TYPE_FILE: return 'file'; } return null; }), 'CREATE_TIME' => array('IN' => function ($externalValue) { return \CRestUtil::unConvertDateTime($externalValue); }, 'OUT' => function (DateTime $internalValue = null) { return \CRestUtil::convertDateTime($internalValue); }), 'UPDATE_TIME' => array('IN' => function ($externalValue) { return \CRestUtil::unConvertDateTime($externalValue); }, 'OUT' => function (DateTime $internalValue = null) { return \CRestUtil::convertDateTime($internalValue); }), 'DELETE_TIME' => array('IN' => function ($externalValue) { return \CRestUtil::unConvertDateTime($externalValue); }, 'OUT' => function (DateTime $internalValue = null) { return \CRestUtil::convertDateTime($internalValue); })); }
/** * Gets fields which Externalizer or Internalizer should modify. * @return array */ public function getFieldsForMap() { return array('CREATE_TIME' => array('IN' => function ($externalValue) { return \CRestUtil::unConvertDateTime($externalValue); }, 'OUT' => function (DateTime $internalValue = null) { return \CRestUtil::convertDateTime($internalValue); })); }
private function convertDateTimeFields($data) { if ($data instanceof DateTime) { return \CRestUtil::convertDateTime($data); } if (!is_array($data)) { return $data; } foreach ($data as $key => $item) { $data[$key] = $this->convertDateTimeFields($data[$key]); } unset($item); return $data; }
/** * Gets fields which Externalizer or Internalizer should modify. * @return array */ public function getFieldsForMap() { return array('CREATE_TIME' => array('IN' => function ($externalValue) { return \CRestUtil::unConvertDateTime($externalValue); }, 'OUT' => function (DateTime $internalValue = null) { return \CRestUtil::convertDateTime($internalValue); }), 'ENTITY_TYPE' => array('IN' => function ($externalValue) { switch ($externalValue) { case 'blog_comment': return BlogPostCommentConnector::className(); case 'blog_post': return BlogPostConnector::className(); case 'calendar_event': return CalendarEventConnector::className(); case 'forum_message': return ForumMessageConnector::className(); case 'tasks_task': return TaskConnector::className(); case 'sonet_log': return SonetLogConnector::className(); case 'sonet_comment': return SonetCommentConnector::className(); } return null; }, 'OUT' => function ($internalValue) { switch ($internalValue) { case BlogPostCommentConnector::className(): return 'blog_comment'; case BlogPostConnector::className(): return 'blog_post'; case CalendarEventConnector::className(): return 'calendar_event'; case ForumMessageConnector::className(): return 'forum_message'; case TaskConnector::className(): return 'tasks_task'; case SonetLogConnector::className(): return 'sonet_log'; case SonetCommentConnector::className(): return 'sonet_comment'; } return null; })); }
private static function _filterArrayByAllowedKeys($arData, $arAllowedKeys, $arDateFields = array()) { $filteredData = array(); foreach ($arAllowedKeys as $allowedKey) { if (array_key_exists($allowedKey, $arData)) { // Additionally convert datetime fields if (in_array((string) $allowedKey, $arDateFields, true)) { $filteredData[$allowedKey] = CRestUtil::convertDateTime($arData[$allowedKey]); } else { $filteredData[$allowedKey] = $arData[$allowedKey]; } } } return $filteredData; }
/** * @param array $params Input params. * @param int $n Offset. * @param \CRestServer $server Rest server instance. * @return array * @throws AccessException */ public static function getTaskList($params, $n, $server) { global $USER; self::checkAdminPermissions(); $params = array_change_key_case($params, CASE_UPPER); $fields = array('ID' => 'ID', 'WORKFLOW_ID' => 'WORKFLOW_ID', 'DOCUMENT_NAME' => 'DOCUMENT_NAME', 'DESCRIPTION' => 'DESCRIPTION', 'NAME' => 'NAME', 'MODIFIED' => 'MODIFIED', 'WORKFLOW_STARTED' => 'WORKFLOW_STARTED', 'WORKFLOW_STARTED_BY' => 'WORKFLOW_STARTED_BY', 'OVERDUE_DATE' => 'OVERDUE_DATE', 'WORKFLOW_TEMPLATE_ID' => 'WORKFLOW_TEMPLATE_ID', 'WORKFLOW_TEMPLATE_NAME' => 'WORKFLOW_TEMPLATE_NAME', 'WORKFLOW_STATE' => 'WORKFLOW_STATE', 'STATUS' => 'STATUS', 'USER_ID' => 'USER_ID', 'USER_STATUS' => 'USER_STATUS', 'MODULE_ID' => 'MODULE_ID', 'ENTITY' => 'ENTITY', 'DOCUMENT_ID' => 'DOCUMENT_ID'); $select = static::getSelect($params['SELECT'], $fields, array('ID', 'WORKFLOW_ID', 'DOCUMENT_NAME', 'NAME')); $select = array_merge(array('MODULE', 'ENTITY', 'DOCUMENT_ID'), $select); $filter = static::getFilter($params['FILTER'], $fields); $order = static::getOrder($params['ORDER'], $fields); $currentUserId = (int) $USER->getId(); $targetUserId = isset($filter['USER_ID']) ? (int) $filter['USER_ID'] : 0; if ($targetUserId !== $currentUserId && !\CBPHelper::checkUserSubordination($currentUserId, $targetUserId)) { self::checkAdminPermissions(); } $iterator = \CBPTaskService::getList($order, $filter, false, static::getNavData($n), $select); $result = array(); while ($row = $iterator->fetch()) { if (isset($row['MODIFIED'])) { $row['MODIFIED'] = \CRestUtil::convertDateTime($row['MODIFIED']); } if (isset($row['WORKFLOW_STARTED'])) { $row['WORKFLOW_STARTED'] = \CRestUtil::convertDateTime($row['WORKFLOW_STARTED']); } if (isset($row['OVERDUE_DATE'])) { $row['OVERDUE_DATE'] = \CRestUtil::convertDateTime($row['OVERDUE_DATE']); } $row['DOCUMENT_URL'] = \CBPDocument::getDocumentAdminPage(array($row['MODULE_ID'], $row['ENTITY'], $row['DOCUMENT_ID'])); $result[] = $row; } return $result; }