示例#1
0
    $data = isset($_REQUEST['ENTITY_DATA']) && is_array($_REQUEST['ENTITY_DATA']) ? $_REQUEST['ENTITY_DATA'] : array();
    if (count($data) == 0) {
        __CrmMobileActivityEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_DATA_NOT_FOUND')));
    }
    $ID = isset($data['ID']) ? intval($data['ID']) : 0;
    if ($ID <= 0) {
        __CrmMobileActivityEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_ID_NOT_FOUND')));
    }
    $dbItem = CCrmActivity::GetList(array(), array('=ID' => $ID), false, false, array('OWNER_TYPE_ID', 'OWNER_ID'));
    $item = $dbItem->Fetch();
    if (!is_array($item)) {
        __CrmMobileActivityEditEndResonse(array('ERROR' => GetMessage('CRM_ACTIVITY_NOT_FOUND', array('#ID#' => $ID))));
    }
    $ownerTypeID = isset($item['OWNER_TYPE_ID']) ? intval($item['OWNER_TYPE_ID']) : 0;
    $ownerID = isset($item['OWNER_ID']) ? intval($item['OWNER_ID']) : 0;
    if (!CCrmActivity::CheckUpdatePermission($ownerTypeID, $ownerID)) {
        __CrmMobileActivityEditEndResonse(array('ERROR' => 'Access denied.'));
    }
    $completed = (isset($data['COMPLETED']) ? intval($data['COMPLETED']) : 0) > 0;
    if (CCrmActivity::Complete($ID, $completed, array('REGISTER_SONET_EVENT' => true))) {
        $dbRes = CCrmActivity::GetList(array(), array('=ID' => $ID, 'CHECK_PERMISSIONS' => 'N'));
        $currentItem = $dbRes->Fetch();
        $formatParams = isset($_REQUEST['FORMAT_PARAMS']) ? $_REQUEST['FORMAT_PARAMS'] : array();
        CCrmMobileHelper::PrepareActivityItem($currentItem, $formatParams, array('ENABLE_COMMUNICATIONS' => true));
        __CrmMobileActivityEditEndResonse(array('SAVED_ENTITY_ID' => $ID, 'SAVED_ENTITY_DATA' => CCrmMobileHelper::PrepareActivityData($currentItem)));
    } else {
        __CrmMobileActivityEditEndResonse(array('ERROR' => CCrmActivity::GetLastErrorMessage()));
    }
} else {
    __CrmMobileActivityEditEndResonse(array('ERROR' => 'Action is not supported in current context.'));
}
示例#2
0
     }
 } elseif ($storageTypeID === CCrmActivityStorageType::WebDav || $storageTypeID === CCrmActivityStorageType::Disk) {
     $fileKey = $storageTypeID === CCrmActivityStorageType::Disk ? 'diskfiles' : 'webdavelements';
     $arFileIDs = isset($data[$fileKey]) && is_array($data[$fileKey]) ? $data[$fileKey] : array();
     if (!empty($arFileIDs) || !$isNew) {
         $arFields['STORAGE_ELEMENT_IDS'] = Bitrix\Crm\Integration\StorageManager::filterFiles($arFileIDs, $storageTypeID, $userID);
     }
 }
 if ($isNew) {
     if (!($ID = CCrmActivity::Add($arFields, false, false, array('REGISTER_SONET_EVENT' => true)))) {
         echo CUtil::PhpToJSObject(array('ERROR' => CCrmActivity::GetLastErrorMessage()));
         die;
     }
 } else {
     if (!CCrmActivity::Update($ID, $arFields, false, false)) {
         echo CUtil::PhpToJSObject(array('ERROR' => CCrmActivity::GetLastErrorMessage()));
         die;
     }
 }
 $urn = CCrmActivity::PrepareUrn($arFields);
 if ($urn !== '') {
     CCrmActivity::Update($ID, array('URN' => $urn), false, false, array('REGISTER_SONET_EVENT' => true));
 }
 CCrmActivity::SaveCommunications($ID, $arComms, $arFields, false, false);
 // Creating Email -->
 //Save user email in settings -->
 if ($from !== CUserOptions::GetOption('crm', 'activity_email_addresser', '')) {
     CUserOptions::SetOption('crm', 'activity_email_addresser', $from);
 }
 /*CCrmMailTemplate::SetLastUsedTemplateID(
 		isset($data['templateID']) ? intval($data['templateID']) : 0,
示例#3
0
 protected function innerDelete($ID, &$errors)
 {
     $currentFields = CCrmActivity::GetByID($ID);
     if (!is_array($currentFields)) {
         $errors[] = 'Activity is not found.';
         return false;
     }
     if (!CCrmActivity::CheckDeletePermission($currentFields['OWNER_TYPE_ID'], $currentFields['OWNER_ID'])) {
         $errors[] = 'Access denied.';
         return false;
     }
     $result = CCrmActivity::Delete($ID, false, true, array());
     if ($result === false) {
         $errors[] = CCrmActivity::GetLastErrorMessage();
     }
     return $result;
 }