[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+******************************************************************************* 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 *********************************************************************************/ 11 require_once ("include/events/include.inc"); 12 /** 13 * @author MAK 14 */ 15 16 function vtws_deleteUser($id, $newOwnerId,$user){ 17 global $log,$adb; 18 $webserviceObject = VtigerWebserviceObject::fromId($adb,$id); 19 $handlerPath = $webserviceObject->getHandlerPath(); 20 $handlerClass = $webserviceObject->getHandlerClass(); 21 22 require_once $handlerPath; 23 24 $handler = new $handlerClass($webserviceObject,$user,$adb,$log); 25 $meta = $handler->getMeta(); 26 $entityName = $meta->getObjectEntityName($id); 27 28 $types = vtws_listtypes(null, $user); 29 if(!in_array($entityName,$types['types'])){ 30 throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, 31 "Permission to perform the operation is denied, EntityName = ".$entityName); 32 } 33 34 if($entityName !== $webserviceObject->getEntityName()){ 35 throw new WebServiceException(WebServiceErrorCode::$INVALIDID, 36 "Id specified is incorrect"); 37 } 38 39 if(!$meta->hasPermission(EntityMeta::$DELETE,$id)){ 40 throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, 41 "Permission to read given object is denied"); 42 } 43 44 $idComponents = vtws_getIdComponents($id); 45 if(!$meta->exists($idComponents[1])){ 46 throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND, 47 "Record you are trying to access is not found, idComponent = ".$idComponents); 48 } 49 50 if($meta->hasWriteAccess()!==true){ 51 throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, 52 "Permission to write is denied"); 53 } 54 55 $newIdComponents = vtws_getIdComponents($newOwnerId); 56 if(empty($newIdComponents[1])) { 57 //force the default user to be the default admin user. 58 $newIdComponents[1] = 1; 59 } 60 61 $userObj = new Users(); 62 $userObj->transformOwnerShipAndDelete($idComponents[1], $newIdComponents[1]); 63 64 VTWS_PreserveGlobal::flush(); 65 return array("status"=>"successful"); 66 } 67 68 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |