[ 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 include_once ('vtlib/Vtiger/Utils.php'); 11 12 /** 13 * Provides API to work with vtiger CRM Profile 14 * @package vtlib 15 */ 16 class Vtiger_Profile { 17 18 /** 19 * Helper function to log messages 20 * @param String Message to log 21 * @param Boolean true appends linebreak, false to avoid it 22 * @access private 23 */ 24 static function log($message, $delimit=true) { 25 Vtiger_Utils::Log($message, $delimit); 26 } 27 28 /** 29 * Initialize profile setup for Field 30 * @param Vtiger_Field Instance of the field 31 * @access private 32 */ 33 static function initForField($fieldInstance) { 34 global $adb; 35 36 // Allow field access to all 37 $adb->pquery("INSERT INTO vtiger_def_org_field (tabid, fieldid, visible, readonly) VALUES(?,?,?,?)", 38 Array($fieldInstance->getModuleId(), $fieldInstance->id, '0', '0')); 39 40 $profileids = self::getAllIds(); 41 foreach($profileids as $profileid) { 42 $adb->pquery("INSERT INTO vtiger_profile2field (profileid, tabid, fieldid, visible, readonly) VALUES(?,?,?,?,?)", 43 Array($profileid, $fieldInstance->getModuleId(), $fieldInstance->id, '0', '0')); 44 } 45 } 46 47 /** 48 * Delete profile information related with field. 49 * @param Vtiger_Field Instance of the field 50 * @access private 51 */ 52 static function deleteForField($fieldInstance) { 53 global $adb; 54 55 $adb->pquery("DELETE FROM vtiger_def_org_field WHERE fieldid=?", Array($fieldInstance->id)); 56 $adb->pquery("DELETE FROM vtiger_profile2field WHERE fieldid=?", Array($fieldInstance->id)); 57 } 58 59 /** 60 * Get all the existing profile ids 61 * @access private 62 */ 63 static function getAllIds() { 64 global $adb; 65 $profileids = Array(); 66 $result = $adb->pquery('SELECT profileid FROM vtiger_profile', array()); 67 for($index = 0; $index < $adb->num_rows($result); ++$index) { 68 $profileids[] = $adb->query_result($result, $index, 'profileid'); 69 } 70 return $profileids; 71 } 72 73 /** 74 * Initialize profile setup for the module 75 * @param Vtiger_Module Instance of module 76 * @access private 77 */ 78 static function initForModule($moduleInstance) { 79 global $adb; 80 81 $actionids = Array(); 82 $result = $adb->pquery("SELECT actionid from vtiger_actionmapping WHERE actionname IN 83 (?,?,?,?,?)", array('Save','EditView','Delete','index','DetailView')); 84 /* 85 * NOTE: Other actionname (actionid >= 5) is considered as utility (tools) for a profile. 86 * Gather all the actionid for associating to profile. 87 */ 88 for($index = 0; $index < $adb->num_rows($result); ++$index) { 89 $actionids[] = $adb->query_result($result, $index, 'actionid'); 90 } 91 92 $profileids = self::getAllIds(); 93 94 foreach($profileids as $profileid) { 95 $adb->pquery("INSERT INTO vtiger_profile2tab (profileid, tabid, permissions) VALUES (?,?,?)", 96 Array($profileid, $moduleInstance->id, 0)); 97 98 if($moduleInstance->isentitytype) { 99 foreach($actionids as $actionid) { 100 $adb->pquery( 101 "INSERT INTO vtiger_profile2standardpermissions (profileid, tabid, Operation, permissions) VALUES(?,?,?,?)", 102 Array($profileid, $moduleInstance->id, $actionid, 0)); 103 } 104 } 105 } 106 self::log("Initializing module permissions ... DONE"); 107 } 108 109 /** 110 * Delete profile setup of the module 111 * @param Vtiger_Module Instance of module 112 * @access private 113 */ 114 static function deleteForModule($moduleInstance) { 115 global $adb; 116 $adb->pquery("DELETE FROM vtiger_profile2tab WHERE tabid=?", Array($moduleInstance->id)); 117 $adb->pquery("DELETE FROM vtiger_profile2standardpermissions WHERE tabid=?", Array($moduleInstance->id)); 118 } 119 } 120 ?>
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 |