public static function CheckDeletePermission($ID, $userPermissions = null) { return CCrmAuthorizationHelper::CheckDeletePermission(self::$TYPE_NAME, $ID, $userPermissions); }
public function isMergable($entityID, $roleID) { if (!$this->enablePermissionCheck) { return true; } if (!is_int($entityID)) { $entityID = (int) $entityID; } if ($entityID <= 0) { throw new Main\ArgumentException('Must be greater than zero', 'entityID'); } if (!is_int($roleID)) { $roleID = (int) $roleID; } if (!self::isRoleDefined($roleID)) { throw new Main\ArgumentException('Merge role is not defined', 'roleID'); } $entityTypeID = $this->entityTypeID; $entityTypeName = \CCrmOwnerType::ResolveName($entityTypeID); $permissions = $this->getUserPermissions(); if ($roleID === self::ROLE_SEED) { return \CCrmAuthorizationHelper::CheckReadPermission($entityTypeName, $entityID, $permissions) && \CCrmAuthorizationHelper::CheckDeletePermission($entityTypeName, $entityID, $permissions); } else { return \CCrmAuthorizationHelper::CheckReadPermission($entityTypeName, $entityID, $permissions) && \CCrmAuthorizationHelper::CheckUpdatePermission($entityTypeName, $entityID, $permissions); } }
public function isDeletable($userID = 0, $userPermissions = null) { if (!is_int($userID)) { throw new Main\ArgumentTypeException('userID', 'integer'); } if ($userPermissions === null) { $userPermissions = \CCrmPerms::GetUserPermissions($userID); } return \CCrmAuthorizationHelper::CheckDeletePermission(\CCrmOwnerType::ResolveName($this->entityTypeID), $this->entityID, $userPermissions); }
} $dup = $criterion->createDuplicate($entityTypeID, $rootEntityID, $currentUserID, $enablePermissionCheck, $enableRanking, 50); if ($dup) { $entities = $dup->getEntitiesByType($entityTypeID); foreach ($entities as $entity) { $entityID = $entity->getEntityID(); $info = array('ID' => $entityID); $entityCriterion = $entity->getCriterion(); if ($entityCriterion !== null) { $info['INDEX_MATCHES'] = $entityCriterion->getMatches(); } if (!$enablePermissionCheck) { $info['CAN_UPDATE'] = $info['CAN_DELETE'] = true; } else { $info['CAN_UPDATE'] = \CCrmAuthorizationHelper::CheckUpdatePermission($entityTypeName, $entityID, $currentUserPermissions); $info['CAN_DELETE'] = \CCrmAuthorizationHelper::CheckDeletePermission($entityTypeName, $entityID, $currentUserPermissions); } $entityInfos[$entityID] =& $info; unset($info); } if (empty($entityInfos)) { $result = array('INDEX_TYPE_NAME' => Integrity\DuplicateIndexType::resolveName($typeID), 'ENTITY_TYPE_NAME' => $entityTypeName, 'ENTITY_INFOS' => array(), 'TEXT_TOTALS' => GetMessage("CRM_DEDUPE_LIST_JUNK")); __CrmDedupeListEndResonse($result); } $entityInfoOptions = array('ENABLE_EDIT_URL' => false, 'ENABLE_RESPONSIBLE' => true, 'ENABLE_RESPONSIBLE_PHOTO' => false); if ($entityTypeID === CCrmOwnerType::Lead) { $entityInfoOptions[$layoutID === CCrmOwnerType::Company ? 'TREAT_AS_COMPANY' : 'TREAT_AS_CONTACT'] = true; } \CCrmOwnerType::PrepareEntityInfoBatch($entityTypeID, $entityInfos, $enablePermissionCheck, $entityInfoOptions); \CCrmFieldMulti::PrepareEntityInfoBatch('PHONE', $entityTypeName, $entityInfos, array('ENABLE_NORMALIZATION' => true)); \CCrmFieldMulti::PrepareEntityInfoBatch('EMAIL', $entityTypeName, $entityInfos);
protected function innerDelete($ID, &$errors) { $entity = CCrmProductRow::GetByID($ID); if (!is_array($entity)) { $errors[] = "Product Row not found"; return false; } if (!CCrmAuthorizationHelper::CheckDeletePermission(CCrmProductRow::ResolveOwnerTypeName($entity['OWNER_TYPE']), $entity['OWNER_ID'])) { $errors[] = 'Access denied.'; return false; } $result = CCrmProductRow::Delete($ID, true, true); if ($result !== true) { $errors[] = CCrmProductRow::GetLastError(); } return $result; }
} $APPLICATION->ResetException(); } __CrmMobileInvoiceEditEndResonse(array('ERROR' => $errorText !== '' ? $errorText : GetMessage('CRM_INVOICE_SAVING_GENERAL_ERROR'))); } } elseif ($action === 'DELETE_ENTITY') { __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__)); $typeName = isset($_REQUEST['ENTITY_TYPE_NAME']) ? $_REQUEST['ENTITY_TYPE_NAME'] : ''; if ($typeName !== CCrmOwnerType::InvoiceName) { __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_TYPE_NOT_SUPPORTED', array('#ENTITY_TYPE#' => $typeName)))); } $ID = isset($_REQUEST['ENTITY_ID']) ? intval($_REQUEST['ENTITY_ID']) : 0; if ($ID <= 0) { __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_ENTITY_ID_NOT_FOUND'))); } if (!CCrmAuthorizationHelper::CheckDeletePermission(CCrmOwnerType::InvoiceName, $ID, $curUserPrems)) { __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_ACCESS_DENIED'))); } $entity = new CCrmInvoice(false); //$DB->StartTransaction(); $successed = $entity->Delete($ID); if ($successed) { //$DB->Commit(); __CrmMobileInvoiceEditEndResonse(array('DELETED_ENTITY_ID' => $ID)); } else { //$DB->Rollback(); __CrmMobileInvoiceEditEndResonse(array('ERROR' => GetMessage('CRM_INVOICE_COULD_NOT_DELETE'))); } } elseif ($action === 'GET_ENTITY') { __IncludeLang(dirname(__FILE__) . '/lang/' . LANGUAGE_ID . '/' . basename(__FILE__)); $typeName = isset($_REQUEST['ENTITY_TYPE_NAME']) ? $_REQUEST['ENTITY_TYPE_NAME'] : '';