userrightsprofile.class.inc.php 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * UserRightsProfile
  18. * User management Module, basing the right on profiles and a matrix (similar to UserRightsMatrix, but profiles and other decorations have been added)
  19. *
  20. * @author Erwan Taloc <erwan.taloc@combodo.com>
  21. * @author Romain Quetiez <romain.quetiez@combodo.com>
  22. * @author Denis Flaven <denis.flaven@combodo.com>
  23. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  24. */
  25. define('ADMIN_PROFILE_ID', 1);
  26. class UserRightsBaseClass extends cmdbAbstractObject
  27. {
  28. // Whenever something changes, reload the privileges
  29. protected function AfterInsert()
  30. {
  31. UserRights::FlushPrivileges();
  32. }
  33. protected function AfterUpdate()
  34. {
  35. UserRights::FlushPrivileges();
  36. }
  37. protected function AfterDelete()
  38. {
  39. UserRights::FlushPrivileges();
  40. }
  41. }
  42. class URP_Profiles extends UserRightsBaseClass
  43. {
  44. public static function Init()
  45. {
  46. $aParams = array
  47. (
  48. "category" => "addon/userrights",
  49. "key_type" => "autoincrement",
  50. "name_attcode" => "name",
  51. "state_attcode" => "",
  52. "reconc_keys" => array(),
  53. "db_table" => "priv_urp_profiles",
  54. "db_key_field" => "id",
  55. "db_finalclass_field" => "",
  56. "display_template" => "",
  57. );
  58. MetaModel::Init_Params($aParams);
  59. //MetaModel::Init_InheritAttributes();
  60. MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
  61. MetaModel::Init_AddAttribute(new AttributeString("description", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
  62. MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("user_list", array("linked_class"=>"URP_UserProfile", "ext_key_to_me"=>"profileid", "ext_key_to_remote"=>"userid", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
  63. // Display lists
  64. MetaModel::Init_SetZListItems('details', array('name', 'description', 'user_list')); // Attributes to be displayed for the complete details
  65. MetaModel::Init_SetZListItems('list', array('description')); // Attributes to be displayed for a list
  66. // Search criteria
  67. MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
  68. MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
  69. }
  70. function GetGrantAsHtml($oUserRights, $sClass, $sAction)
  71. {
  72. $oGrant = $oUserRights->GetProfileActionGrant($this->GetKey(), $sClass, $sAction);
  73. if (is_object($oGrant) && ($oGrant->Get('permission') == 'yes'))
  74. {
  75. return '<span style="background-color: #ddffdd;">'.Dict::S('UI:UserManagement:ActionAllowed:Yes').'</span>';
  76. }
  77. else
  78. {
  79. return '<span style="background-color: #ffdddd;">'.Dict::S('UI:UserManagement:ActionAllowed:No').'</span>';
  80. }
  81. }
  82. function DoShowGrantSumary($oPage)
  83. {
  84. if ($this->GetName() == "Administrator")
  85. {
  86. // Looks dirty, but ok that's THE ONE
  87. $oPage->p(Dict::S('UI:UserManagement:AdminProfile+'));
  88. return;
  89. }
  90. // Note: for sure, we assume that the instance is derived from UserRightsProfile
  91. $oUserRights = UserRights::GetModuleInstance();
  92. $aDisplayData = array();
  93. foreach (MetaModel::GetClasses('bizmodel') as $sClass)
  94. {
  95. // Skip non instantiable classes
  96. if (MetaModel::IsAbstract($sClass)) continue;
  97. $aStimuli = array();
  98. foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus)
  99. {
  100. $oGrant = $oUserRights->GetClassStimulusGrant($this->GetKey(), $sClass, $sStimulusCode);
  101. if (is_object($oGrant) && ($oGrant->Get('permission') == 'yes'))
  102. {
  103. $aStimuli[] = '<span title="'.$sStimulusCode.': '.htmlentities($oStimulus->GetDescription()).'">'.htmlentities($oStimulus->GetLabel()).'</span>';
  104. }
  105. }
  106. $sStimuli = implode(', ', $aStimuli);
  107. $aDisplayData[] = array(
  108. 'class' => MetaModel::GetName($sClass),
  109. 'read' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Read'),
  110. 'bulkread' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Read'),
  111. 'write' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Modify'),
  112. 'bulkwrite' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Modify'),
  113. 'delete' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Delete'),
  114. 'bulkdelete' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Delete'),
  115. 'stimuli' => $sStimuli,
  116. );
  117. }
  118. $aDisplayConfig = array();
  119. $aDisplayConfig['class'] = array('label' => Dict::S('UI:UserManagement:Class'), 'description' => Dict::S('UI:UserManagement:Class+'));
  120. $aDisplayConfig['read'] = array('label' => Dict::S('UI:UserManagement:Action:Read'), 'description' => Dict::S('UI:UserManagement:Action:Read+'));
  121. $aDisplayConfig['bulkread'] = array('label' => Dict::S('UI:UserManagement:Action:BulkRead'), 'description' => Dict::S('UI:UserManagement:Action:BulkRead+'));
  122. $aDisplayConfig['write'] = array('label' => Dict::S('UI:UserManagement:Action:Modify'), 'description' => Dict::S('UI:UserManagement:Action:Modify+'));
  123. $aDisplayConfig['bulkwrite'] = array('label' => Dict::S('UI:UserManagement:Action:BulkModify'), 'description' => Dict::S('UI:UserManagement:Action:BulkModify+'));
  124. $aDisplayConfig['delete'] = array('label' => Dict::S('UI:UserManagement:Action:Delete'), 'description' => Dict::S('UI:UserManagement:Action:Delete+'));
  125. $aDisplayConfig['bulkdelete'] = array('label' => Dict::S('UI:UserManagement:Action:BulkDelete'), 'description' => Dict::S('UI:UserManagement:Action:BulkDelete+'));
  126. $aDisplayConfig['stimuli'] = array('label' => Dict::S('UI:UserManagement:Action:Stimuli'), 'description' => Dict::S('UI:UserManagement:Action:Stimuli+'));
  127. $oPage->table($aDisplayConfig, $aDisplayData);
  128. }
  129. function DisplayBareRelations(WebPage $oPage, $bEditMode = false)
  130. {
  131. parent::DisplayBareRelations($oPage);
  132. if (!$bEditMode)
  133. {
  134. $oPage->SetCurrentTab(Dict::S('UI:UserManagement:GrantMatrix'));
  135. $this->DoShowGrantSumary($oPage);
  136. }
  137. }
  138. }
  139. class URP_UserProfile extends UserRightsBaseClass
  140. {
  141. public static function Init()
  142. {
  143. $aParams = array
  144. (
  145. "category" => "addon/userrights",
  146. "key_type" => "autoincrement",
  147. "name_attcode" => "userid",
  148. "state_attcode" => "",
  149. "reconc_keys" => array(),
  150. "db_table" => "priv_urp_userprofile",
  151. "db_key_field" => "id",
  152. "db_finalclass_field" => "",
  153. "display_template" => "",
  154. );
  155. MetaModel::Init_Params($aParams);
  156. //MetaModel::Init_InheritAttributes();
  157. MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  158. MetaModel::Init_AddAttribute(new AttributeExternalField("userlogin", array("allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
  159. MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  160. MetaModel::Init_AddAttribute(new AttributeExternalField("profile", array("allowed_values"=>null, "extkey_attcode"=> 'profileid', "target_attcode"=>"name")));
  161. MetaModel::Init_AddAttribute(new AttributeString("reason", array("allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  162. // Display lists
  163. MetaModel::Init_SetZListItems('details', array('userid', 'profileid', 'reason')); // Attributes to be displayed for the complete details
  164. MetaModel::Init_SetZListItems('list', array('profileid', 'reason')); // Attributes to be displayed for a list
  165. // Search criteria
  166. MetaModel::Init_SetZListItems('standard_search', array('userid', 'profileid')); // Criteria of the std search form
  167. MetaModel::Init_SetZListItems('advanced_search', array('userid', 'profileid')); // Criteria of the advanced search form
  168. }
  169. public function GetName()
  170. {
  171. return Dict::Format('UI:UserManagement:LinkBetween_User_And_Profile', $this->Get('userlogin'), $this->Get('profile'));
  172. }
  173. }
  174. class URP_UserOrg extends UserRightsBaseClass
  175. {
  176. public static function Init()
  177. {
  178. $aParams = array
  179. (
  180. "category" => "addon/userrights",
  181. "key_type" => "autoincrement",
  182. "name_attcode" => "userid",
  183. "state_attcode" => "",
  184. "reconc_keys" => array(),
  185. "db_table" => "priv_urp_userorg",
  186. "db_key_field" => "id",
  187. "db_finalclass_field" => "",
  188. "display_template" => "",
  189. );
  190. MetaModel::Init_Params($aParams);
  191. //MetaModel::Init_InheritAttributes();
  192. MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  193. MetaModel::Init_AddAttribute(new AttributeExternalField("userlogin", array("allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login")));
  194. MetaModel::Init_AddAttribute(new AttributeExternalKey("allowed_org_id", array("targetclass"=>"Organization", "jointype"=> "", "allowed_values"=>null, "sql"=>"allowed_org_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array())));
  195. MetaModel::Init_AddAttribute(new AttributeExternalField("allowed_org_name", array("allowed_values"=>null, "extkey_attcode"=> 'allowed_org_id', "target_attcode"=>"name")));
  196. MetaModel::Init_AddAttribute(new AttributeString("reason", array("allowed_values"=>null, "sql"=>"reason", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
  197. // Display lists
  198. MetaModel::Init_SetZListItems('details', array('userid', 'allowed_org_id', 'reason')); // Attributes to be displayed for the complete details
  199. MetaModel::Init_SetZListItems('list', array('allowed_org_id', 'reason')); // Attributes to be displayed for a list
  200. // Search criteria
  201. MetaModel::Init_SetZListItems('standard_search', array('userid', 'allowed_org_id')); // Criteria of the std search form
  202. MetaModel::Init_SetZListItems('advanced_search', array('userid', 'allowed_org_id')); // Criteria of the advanced search form
  203. }
  204. public function GetName()
  205. {
  206. return Dict::Format('UI:UserManagement:LinkBetween_User_And_Org', $this->Get('userlogin'), $this->Get('allowed_org_name'));
  207. }
  208. }
  209. class URP_ActionGrant extends UserRightsBaseClass
  210. {
  211. public static function Init()
  212. {
  213. $aParams = array
  214. (
  215. "category" => "addon/userrights",
  216. "key_type" => "autoincrement",
  217. "name_attcode" => "profileid",
  218. "state_attcode" => "",
  219. "reconc_keys" => array(),
  220. "db_table" => "priv_urp_grant_actions",
  221. "db_key_field" => "id",
  222. "db_finalclass_field" => "",
  223. "display_template" => "",
  224. );
  225. MetaModel::Init_Params($aParams);
  226. //MetaModel::Init_InheritAttributes();
  227. // Common to all grant classes (could be factorized by class inheritence, but this has to be benchmarked)
  228. MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  229. MetaModel::Init_AddAttribute(new AttributeExternalField("profile", array("allowed_values"=>null, "extkey_attcode"=> 'profileid', "target_attcode"=>"name")));
  230. MetaModel::Init_AddAttribute(new AttributeClass("class", array("class_category"=>"", "more_values"=>"", "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
  231. MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
  232. MetaModel::Init_AddAttribute(new AttributeString("action", array("allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  233. // Display lists
  234. MetaModel::Init_SetZListItems('details', array('profileid', 'class', 'permission', 'action')); // Attributes to be displayed for the complete details
  235. MetaModel::Init_SetZListItems('list', array('class', 'permission', 'action')); // Attributes to be displayed for a list
  236. // Search criteria
  237. MetaModel::Init_SetZListItems('standard_search', array('profileid', 'class', 'permission', 'action')); // Criteria of the std search form
  238. MetaModel::Init_SetZListItems('advanced_search', array('profileid', 'class', 'permission', 'action')); // Criteria of the advanced search form
  239. }
  240. }
  241. class URP_StimulusGrant extends UserRightsBaseClass
  242. {
  243. public static function Init()
  244. {
  245. $aParams = array
  246. (
  247. "category" => "addon/userrights",
  248. "key_type" => "autoincrement",
  249. "name_attcode" => "profileid",
  250. "state_attcode" => "",
  251. "reconc_keys" => array(),
  252. "db_table" => "priv_urp_grant_stimulus",
  253. "db_key_field" => "id",
  254. "db_finalclass_field" => "",
  255. "display_template" => "",
  256. );
  257. MetaModel::Init_Params($aParams);
  258. //MetaModel::Init_InheritAttributes();
  259. // Common to all grant classes (could be factorized by class inheritence, but this has to be benchmarked)
  260. MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  261. MetaModel::Init_AddAttribute(new AttributeExternalField("profile", array("allowed_values"=>null, "extkey_attcode"=> 'profileid', "target_attcode"=>"name")));
  262. MetaModel::Init_AddAttribute(new AttributeClass("class", array("class_category"=>"", "more_values"=>"", "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
  263. MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array())));
  264. MetaModel::Init_AddAttribute(new AttributeString("stimulus", array("allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array())));
  265. // Display lists
  266. MetaModel::Init_SetZListItems('details', array('profileid', 'class', 'permission', 'stimulus')); // Attributes to be displayed for the complete details
  267. MetaModel::Init_SetZListItems('list', array('class', 'permission', 'stimulus')); // Attributes to be displayed for a list
  268. // Search criteria
  269. MetaModel::Init_SetZListItems('standard_search', array('profileid', 'class', 'permission', 'stimulus')); // Criteria of the std search form
  270. MetaModel::Init_SetZListItems('advanced_search', array('profileid', 'class', 'permission', 'stimulus')); // Criteria of the advanced search form
  271. }
  272. }
  273. class URP_AttributeGrant extends UserRightsBaseClass
  274. {
  275. public static function Init()
  276. {
  277. $aParams = array
  278. (
  279. "category" => "addon/userrights",
  280. "key_type" => "autoincrement",
  281. "name_attcode" => "actiongrantid",
  282. "state_attcode" => "",
  283. "reconc_keys" => array(),
  284. "db_table" => "priv_urp_grant_attributes",
  285. "db_key_field" => "id",
  286. "db_finalclass_field" => "",
  287. "display_template" => "",
  288. );
  289. MetaModel::Init_Params($aParams);
  290. //MetaModel::Init_InheritAttributes();
  291. MetaModel::Init_AddAttribute(new AttributeExternalKey("actiongrantid", array("targetclass"=>"URP_ActionGrant", "jointype"=> "", "allowed_values"=>null, "sql"=>"actiongrantid", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
  292. MetaModel::Init_AddAttribute(new AttributeString("attcode", array("allowed_values"=>null, "sql"=>"attcode", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
  293. // Display lists
  294. MetaModel::Init_SetZListItems('details', array('actiongrantid', 'attcode')); // Attributes to be displayed for the complete details
  295. MetaModel::Init_SetZListItems('list', array('attcode')); // Attributes to be displayed for a list
  296. // Search criteria
  297. MetaModel::Init_SetZListItems('standard_search', array('actiongrantid', 'attcode')); // Criteria of the std search form
  298. MetaModel::Init_SetZListItems('advanced_search', array('actiongrantid', 'attcode')); // Criteria of the advanced search form
  299. }
  300. }
  301. class UserRightsProfile extends UserRightsAddOnAPI
  302. {
  303. static public $m_aActionCodes = array(
  304. UR_ACTION_READ => 'read',
  305. UR_ACTION_MODIFY => 'modify',
  306. UR_ACTION_DELETE => 'delete',
  307. UR_ACTION_BULK_READ => 'bulk read',
  308. UR_ACTION_BULK_MODIFY => 'bulk modify',
  309. UR_ACTION_BULK_DELETE => 'bulk delete',
  310. );
  311. // Installation: create the very first user
  312. public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US')
  313. {
  314. // Create a change to record the history of the User object
  315. $oChange = MetaModel::NewObject("CMDBChange");
  316. $oChange->Set("date", time());
  317. $oChange->Set("userinfo", "Initialization");
  318. $iChangeId = $oChange->DBInsert();
  319. $oOrg = new Organization();
  320. $oOrg->Set('name', 'My Company/Department');
  321. $oOrg->Set('code', 'SOMECODE');
  322. // $oOrg->Set('status', 'implementation');
  323. //$oOrg->Set('parent_id', xxx);
  324. $iOrgId = $oOrg->DBInsertTrackedNoReload($oChange);
  325. $oContact = new Person();
  326. $oContact->Set('name', 'My last name');
  327. $oContact->Set('first_name', 'My first name');
  328. //$oContact->Set('status', 'available');
  329. $oContact->Set('org_id', $iOrgId);
  330. $oContact->Set('email', 'my.email@foo.org');
  331. //$oContact->Set('phone', '');
  332. //$oContact->Set('location_id', $iLocationId);
  333. //$oContact->Set('employee_number', '');
  334. $iContactId = $oContact->DBInsertTrackedNoReload($oChange);
  335. $oUser = new UserLocal();
  336. $oUser->Set('login', $sAdminUser);
  337. $oUser->Set('password', $sAdminPwd);
  338. $oUser->Set('contactid', $iContactId);
  339. $oUser->Set('language', $sLanguage); // Language was chosen during the installation
  340. $iUserId = $oUser->DBInsertTrackedNoReload($oChange);
  341. // Add this user to the very specific 'admin' profile
  342. $oUserProfile = new URP_UserProfile();
  343. $oUserProfile->Set('userid', $iUserId);
  344. $oUserProfile->Set('profileid', ADMIN_PROFILE_ID);
  345. $oUserProfile->Set('reason', 'By definition, the administrator must have the administrator profile');
  346. $oUserProfile->DBInsertTrackedNoReload($oChange);
  347. return true;
  348. }
  349. public function Setup()
  350. {
  351. SetupProfiles::ComputeITILProfiles();
  352. //SetupProfiles::ComputeBasicProfiles();
  353. SetupProfiles::DoCreateProfiles();
  354. return true;
  355. }
  356. public function Init()
  357. {
  358. MetaModel::RegisterPlugin('userrights', 'ACbyProfile', array($this, 'LoadCache'));
  359. }
  360. protected $m_aAdmins; // id of users being linked to the well-known admin profile
  361. protected $m_aProfiles; // id -> object
  362. protected $m_aUserProfiles; // userid,profileid -> object
  363. protected $m_aUserOrgs; // userid,orgid -> object
  364. protected $m_aClassActionGrants; // profile, class, action -> permission
  365. protected $m_aClassStimulusGrants; // profile, class, stimulus -> permission
  366. public function ResetCache()
  367. {
  368. // Loaded by Load cache
  369. $this->m_aProfiles = null;
  370. $this->m_aUserProfiles = null;
  371. $this->m_aUserOrgs = null;
  372. $this->m_aAdmins = null;
  373. // Loaded on demand
  374. $this->m_aClassActionGrants = array();
  375. $this->m_aClassStimulusGrants = array();
  376. }
  377. public function LoadCache()
  378. {
  379. if (!is_null($this->m_aProfiles)) return;
  380. // Could be loaded in a shared memory (?)
  381. $oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL_AllData("SELECT URP_Profiles"));
  382. $this->m_aProfiles = array();
  383. while ($oProfile = $oProfileSet->Fetch())
  384. {
  385. $this->m_aProfiles[$oProfile->GetKey()] = $oProfile;
  386. }
  387. $oUserProfileSet = new DBObjectSet(DBObjectSearch::FromOQL_AllData("SELECT URP_UserProfile"));
  388. $this->m_aUserProfiles = array();
  389. $this->m_aAdmins = array();
  390. while ($oUserProfile = $oUserProfileSet->Fetch())
  391. {
  392. $this->m_aUserProfiles[$oUserProfile->Get('userid')][$oUserProfile->Get('profileid')] = $oUserProfile;
  393. if ($oUserProfile->Get('profileid') == ADMIN_PROFILE_ID)
  394. {
  395. $this->m_aAdmins[] = $oUserProfile->Get('userid');
  396. }
  397. }
  398. $oUserOrgSet = new DBObjectSet(DBObjectSearch::FromOQL_AllData("SELECT URP_UserOrg"));
  399. $this->m_aUserOrgs = array();
  400. while ($oUserOrg = $oUserOrgSet->Fetch())
  401. {
  402. $this->m_aUserOrgs[$oUserOrg->Get('userid')][$oUserOrg->Get('allowed_org_id')] = $oUserOrg;
  403. }
  404. /*
  405. echo "<pre>\n";
  406. print_r($this->m_aProfiles);
  407. print_r($this->m_aUserProfiles);
  408. print_r($this->m_aUserOrgs);
  409. echo "</pre>\n";
  410. exit;
  411. */
  412. return true;
  413. }
  414. public function IsAdministrator($oUser)
  415. {
  416. $this->LoadCache();
  417. if (in_array($oUser->GetKey(), $this->m_aAdmins))
  418. {
  419. return true;
  420. }
  421. else
  422. {
  423. return false;
  424. }
  425. }
  426. public function GetSelectFilter($oUser, $sClass)
  427. {
  428. $this->LoadCache();
  429. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, UR_ACTION_READ);
  430. if ($aObjectPermissions['permission'] == UR_ALLOWED_NO)
  431. {
  432. return false;
  433. }
  434. // Determine how to position the objects of this class
  435. //
  436. if ($sClass == 'Organization')
  437. {
  438. $sAttCode = 'id';
  439. }
  440. elseif(MetaModel::IsValidAttCode($sClass, 'org_id'))
  441. {
  442. $sAttCode = 'org_id';
  443. }
  444. else
  445. {
  446. // The objects of this class are not positioned in this dimension
  447. // All of them are visible
  448. return true;
  449. }
  450. $oExpression = new FieldExpression($sAttCode, $sClass);
  451. // Position the user
  452. //
  453. @$aUserOrgs = $this->m_aUserOrgs[$oUser->GetKey()];
  454. if (!isset($aUserOrgs) || count($aUserOrgs) == 0)
  455. {
  456. // No position means 'Everywhere'
  457. return true;
  458. }
  459. $aIds = array_keys($aUserOrgs);
  460. $oListExpr = ListExpression::FromScalars($aIds);
  461. $oCondition = new BinaryExpression($oExpression, 'IN', $oListExpr);
  462. $oFilter = new DBObjectSearch($sClass);
  463. $oFilter->AddConditionExpression($oCondition);
  464. return $oFilter;
  465. }
  466. // This verb has been made public to allow the development of an accurate feedback for the current configuration
  467. public function GetProfileActionGrant($iProfile, $sClass, $sAction)
  468. {
  469. $this->LoadCache();
  470. if (isset($this->m_aClassActionGrants[$iProfile][$sClass][$sAction]))
  471. {
  472. return $this->m_aClassActionGrants[$iProfile][$sClass][$sAction];
  473. }
  474. // Get the permission for this profile/class/action
  475. $oSearch = DBObjectSearch::FromOQL_AllData("SELECT URP_ActionGrant WHERE class = :class AND action = :action AND profileid = :profile AND permission = 'yes'");
  476. $oSet = new DBObjectSet($oSearch, array(), array('class'=>$sClass, 'action'=>$sAction, 'profile'=>$iProfile));
  477. if ($oSet->Count() >= 1)
  478. {
  479. $oGrantRecord = $oSet->Fetch();
  480. }
  481. else
  482. {
  483. $sParentClass = MetaModel::GetParentPersistentClass($sClass);
  484. if (empty($sParentClass))
  485. {
  486. $oGrantRecord = null;
  487. }
  488. else
  489. {
  490. // Recursively look for the grant record in the class hierarchy
  491. $oGrantRecord = $this->GetProfileActionGrant($iProfile, $sParentClass, $sAction);
  492. }
  493. }
  494. $this->m_aClassActionGrants[$iProfile][$sClass][$sAction] = $oGrantRecord;
  495. return $oGrantRecord;
  496. }
  497. protected function GetUserActionGrant($oUser, $sClass, $iActionCode)
  498. {
  499. $this->LoadCache();
  500. // load and cache permissions for the current user on the given class
  501. //
  502. $iUser = $oUser->GetKey();
  503. $aTest = @$this->m_aObjectActionGrants[$iUser][$sClass][$iActionCode];
  504. if (is_array($aTest)) return $aTest;
  505. $sAction = self::$m_aActionCodes[$iActionCode];
  506. $iInstancePermission = UR_ALLOWED_NO;
  507. $aAttributes = array();
  508. if (isset($this->m_aUserProfiles[$iUser]))
  509. {
  510. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  511. {
  512. $oGrantRecord = $this->GetProfileActionGrant($iProfile, $sClass, $sAction);
  513. if (is_null($oGrantRecord))
  514. {
  515. continue; // loop to the next profile
  516. }
  517. else
  518. {
  519. $iInstancePermission = UR_ALLOWED_YES;
  520. // update the list of attributes with those allowed for this profile
  521. //
  522. $oSearch = DBObjectSearch::FromOQL_AllData("SELECT URP_AttributeGrant WHERE actiongrantid = :actiongrantid");
  523. $oSet = new DBObjectSet($oSearch, array(), array('actiongrantid' => $oGrantRecord->GetKey()));
  524. $aProfileAttributes = $oSet->GetColumnAsArray('attcode', false);
  525. if (count($aProfileAttributes) == 0)
  526. {
  527. $aAllAttributes = array_keys(MetaModel::ListAttributeDefs($sClass));
  528. $aAttributes = array_merge($aAttributes, $aAllAttributes);
  529. }
  530. else
  531. {
  532. $aAttributes = array_merge($aAttributes, $aProfileAttributes);
  533. }
  534. }
  535. }
  536. }
  537. $aRes = array(
  538. 'permission' => $iInstancePermission,
  539. 'attributes' => $aAttributes,
  540. );
  541. $this->m_aObjectActionGrants[$iUser][$sClass][$iActionCode] = $aRes;
  542. return $aRes;
  543. }
  544. public function IsActionAllowed($oUser, $sClass, $iActionCode, $oInstanceSet = null)
  545. {
  546. $this->LoadCache();
  547. if (is_null($oInstanceSet))
  548. {
  549. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, $iActionCode);
  550. return $aObjectPermissions['permission'];
  551. }
  552. $oInstanceSet->Rewind();
  553. while($oObject = $oInstanceSet->Fetch())
  554. {
  555. $aObjectPermissions = $this->GetUserActionGrant($oUser, get_class($oObject), $iActionCode);
  556. $iInstancePermission = $aObjectPermissions['permission'];
  557. if (isset($iGlobalPermission))
  558. {
  559. if ($iInstancePermission != $iGlobalPermission)
  560. {
  561. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  562. break;
  563. }
  564. }
  565. else
  566. {
  567. $iGlobalPermission = $iInstancePermission;
  568. }
  569. }
  570. $oInstanceSet->Rewind();
  571. if (isset($iGlobalPermission))
  572. {
  573. return $iGlobalPermission;
  574. }
  575. else
  576. {
  577. return UR_ALLOWED_NO;
  578. }
  579. }
  580. public function IsActionAllowedOnAttribute($oUser, $sClass, $sAttCode, $iActionCode, $oInstanceSet = null)
  581. {
  582. $this->LoadCache();
  583. if (is_null($oInstanceSet))
  584. {
  585. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, $iActionCode);
  586. $aAttributes = $aObjectPermissions['attributes'];
  587. if (in_array($sAttCode, $aAttributes))
  588. {
  589. return $aObjectPermissions['permission'];
  590. }
  591. else
  592. {
  593. return UR_ALLOWED_NO;
  594. }
  595. }
  596. $oInstanceSet->Rewind();
  597. while($oObject = $oInstanceSet->Fetch())
  598. {
  599. $aObjectPermissions = $this->GetUserActionGrant($oUser, get_class($oObject), $iActionCode);
  600. $aAttributes = $aObjectPermissions['attributes'];
  601. if (in_array($sAttCode, $aAttributes))
  602. {
  603. $iInstancePermission = $aObjectPermissions['permission'];
  604. }
  605. else
  606. {
  607. $iInstancePermission = UR_ALLOWED_NO;
  608. }
  609. if (isset($iGlobalPermission))
  610. {
  611. if ($iInstancePermission != $iGlobalPermission)
  612. {
  613. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  614. }
  615. }
  616. else
  617. {
  618. $iGlobalPermission = $iInstancePermission;
  619. }
  620. }
  621. $oInstanceSet->Rewind();
  622. if (isset($iGlobalPermission))
  623. {
  624. return $iGlobalPermission;
  625. }
  626. else
  627. {
  628. return UR_ALLOWED_NO;
  629. }
  630. }
  631. // This verb has been made public to allow the development of an accurate feedback for the current configuration
  632. public function GetClassStimulusGrant($iProfile, $sClass, $sStimulusCode)
  633. {
  634. $this->LoadCache();
  635. if (isset($this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode]))
  636. {
  637. return $this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode];
  638. }
  639. // Get the permission for this profile/class/stimulus
  640. $oSearch = DBObjectSearch::FromOQL_AllData("SELECT URP_StimulusGrant WHERE class = :class AND stimulus = :stimulus AND profileid = :profile AND permission = 'yes'");
  641. $oSet = new DBObjectSet($oSearch, array(), array('class'=>$sClass, 'stimulus'=>$sStimulusCode, 'profile'=>$iProfile));
  642. if ($oSet->Count() >= 1)
  643. {
  644. $oGrantRecord = $oSet->Fetch();
  645. }
  646. else
  647. {
  648. $oGrantRecord = null;
  649. }
  650. $this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode] = $oGrantRecord;
  651. return $oGrantRecord;
  652. }
  653. public function IsStimulusAllowed($oUser, $sClass, $sStimulusCode, $oInstanceSet = null)
  654. {
  655. $this->LoadCache();
  656. // Note: this code is VERY close to the code of IsActionAllowed()
  657. $iUser = $oUser->GetKey();
  658. if (is_null($oInstanceSet))
  659. {
  660. $iInstancePermission = UR_ALLOWED_NO;
  661. if (isset($this->m_aUserProfiles[$iUser]))
  662. {
  663. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  664. {
  665. $oGrantRecord = $this->GetClassStimulusGrant($iProfile, $sClass, $sStimulusCode);
  666. if (!is_null($oGrantRecord))
  667. {
  668. // no need to fetch the record, we've requested the records having permission = 'yes'
  669. $iInstancePermission = UR_ALLOWED_YES;
  670. }
  671. }
  672. }
  673. return $iInstancePermission;
  674. }
  675. $oInstanceSet->Rewind();
  676. while($oObject = $oInstanceSet->Fetch())
  677. {
  678. $iInstancePermission = UR_ALLOWED_NO;
  679. if (isset($this->m_aUserProfiles[$iUser]))
  680. {
  681. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  682. {
  683. $oGrantRecord = $this->GetClassStimulusGrant($iProfile, get_class($oObject), $sStimulusCode);
  684. if (!is_null($oGrantRecord))
  685. {
  686. // no need to fetch the record, we've requested the records having permission = 'yes'
  687. $iInstancePermission = UR_ALLOWED_YES;
  688. }
  689. }
  690. }
  691. if (isset($iGlobalPermission))
  692. {
  693. if ($iInstancePermission != $iGlobalPermission)
  694. {
  695. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  696. }
  697. }
  698. else
  699. {
  700. $iGlobalPermission = $iInstancePermission;
  701. }
  702. }
  703. $oInstanceSet->Rewind();
  704. if (isset($iGlobalPermission))
  705. {
  706. return $iGlobalPermission;
  707. }
  708. else
  709. {
  710. return UR_ALLOWED_NO;
  711. }
  712. }
  713. public function FlushPrivileges()
  714. {
  715. $this->ResetCache();
  716. }
  717. }
  718. //
  719. // Create simple profiles into our user management model:
  720. // - administrator
  721. // - readers
  722. // - contributors
  723. //
  724. class SetupProfiles
  725. {
  726. protected static $m_aActions = array(
  727. UR_ACTION_READ => 'Read',
  728. UR_ACTION_MODIFY => 'Modify',
  729. UR_ACTION_DELETE => 'Delete',
  730. UR_ACTION_BULK_READ => 'Bulk Read',
  731. UR_ACTION_BULK_MODIFY => 'Bulk Modify',
  732. UR_ACTION_BULK_DELETE => 'Bulk Delete',
  733. );
  734. // Note: It is possible to specify the same class in several modules
  735. //
  736. protected static $m_aModules = array();
  737. protected static $m_aProfiles = array();
  738. protected static function DoCreateActionGrant($iProfile, $iAction, $sClass, $bPermission = true)
  739. {
  740. $oNewObj = MetaModel::NewObject("URP_ActionGrant");
  741. $oNewObj->Set('profileid', $iProfile);
  742. $oNewObj->Set('permission', $bPermission ? 'yes' : 'no');
  743. $oNewObj->Set('class', $sClass);
  744. $oNewObj->Set('action', self::$m_aActions[$iAction]);
  745. $iId = $oNewObj->DBInsertNoReload();
  746. return $iId;
  747. }
  748. protected static function DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass)
  749. {
  750. $oNewObj = MetaModel::NewObject("URP_StimulusGrant");
  751. $oNewObj->Set('profileid', $iProfile);
  752. $oNewObj->Set('permission', 'yes');
  753. $oNewObj->Set('class', $sClass);
  754. $oNewObj->Set('stimulus', $sStimulusCode);
  755. $iId = $oNewObj->DBInsertNoReload();
  756. return $iId;
  757. }
  758. protected static function DoCreateAdminProfile()
  759. {
  760. $oNewObj = MetaModel::NewObject("URP_Profiles");
  761. $oNewObj->Set('name', 'Administrator');
  762. $oNewObj->Set('description', 'Has the rights on everything (bypassing any control)');
  763. $iNewId = $oNewObj->DBInsertNoReload();
  764. if ($iNewId != ADMIN_PROFILE_ID)
  765. {
  766. throw new CoreException('Admin profile could not be created with its standard id', array('requested'=>ADMIN_PROFILE_ID, 'obtained'=>$iNewId));
  767. }
  768. }
  769. protected static function DoCreateOneProfile($sName, $aProfileData)
  770. {
  771. $sDescription = $aProfileData['description'];
  772. if (strlen(trim($aProfileData['write_modules'])) == 0)
  773. {
  774. $aWriteModules = array();
  775. }
  776. else
  777. {
  778. $aWriteModules = explode(',', trim($aProfileData['write_modules']));
  779. }
  780. $aStimuli = $aProfileData['stimuli'];
  781. $oNewObj = MetaModel::NewObject("URP_Profiles");
  782. $oNewObj->Set('name', $sName);
  783. $oNewObj->Set('description', $sDescription);
  784. $iProfile = $oNewObj->DBInsertNoReload();
  785. // Grant read rights for everything
  786. //
  787. foreach (MetaModel::GetClasses('bizmodel') as $sClass)
  788. {
  789. // Skip non instantiable classes
  790. if (MetaModel::IsAbstract($sClass)) continue;
  791. self::DoCreateActionGrant($iProfile, UR_ACTION_READ, $sClass);
  792. self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_READ, $sClass);
  793. }
  794. // Grant write for given modules
  795. // Start by compiling the information, because some modules may overlap
  796. $aWriteableClasses = array();
  797. foreach ($aWriteModules as $sModule)
  798. {
  799. //$oPage->p('Granting write access for the module"'.$sModule.'" - '.count(self::$m_aModules[$sModule]).' classes');
  800. foreach (self::$m_aModules[$sModule] as $sClass)
  801. {
  802. $aWriteableClasses[$sClass] = true;
  803. }
  804. }
  805. foreach ($aWriteableClasses as $sClass => $foo)
  806. {
  807. // Skip non instantiable classes
  808. if (MetaModel::IsAbstract($sClass)) continue;
  809. if (!MetaModel::IsValidClass($sClass))
  810. {
  811. throw new CoreException("Invalid class name '$sClass'");
  812. }
  813. self::DoCreateActionGrant($iProfile, UR_ACTION_MODIFY, $sClass);
  814. self::DoCreateActionGrant($iProfile, UR_ACTION_DELETE, $sClass);
  815. self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_MODIFY, $sClass);
  816. // By default, do not allow bulk deletion operations for standard users
  817. // self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_DELETE, $sClass);
  818. }
  819. // Grant stimuli for given classes
  820. foreach ($aStimuli as $sClass => $sAllowedStimuli)
  821. {
  822. if (!MetaModel::IsValidClass($sClass))
  823. {
  824. // Could be a class defined in a module that wasn't installed
  825. continue;
  826. //throw new CoreException("Invalid class name '$sClass'");
  827. }
  828. if ($sAllowedStimuli == 'any')
  829. {
  830. $aAllowedStimuli = array_keys(MetaModel::EnumStimuli($sClass));
  831. }
  832. elseif ($sAllowedStimuli == 'none')
  833. {
  834. $aAllowedStimuli = array();
  835. }
  836. else
  837. {
  838. $aAllowedStimuli = explode(',', $sAllowedStimuli);
  839. }
  840. foreach ($aAllowedStimuli as $sStimulusCode)
  841. {
  842. self::DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass);
  843. }
  844. }
  845. }
  846. public static function DoCreateProfiles()
  847. {
  848. self::DoCreateAdminProfile();
  849. foreach(self::$m_aProfiles as $sName => $aProfileData)
  850. {
  851. self::DoCreateOneProfile($sName, $aProfileData);
  852. }
  853. }
  854. public static function ComputeBasicProfiles()
  855. {
  856. // In this profiling scheme, one single module represents all the classes
  857. //
  858. self::$m_aModules = array(
  859. 'UserData' => MetaModel::GetClasses('bizmodel'),
  860. );
  861. self::$m_aProfiles = array(
  862. 'Reader' => array(
  863. 'description' => 'Person having a ready-only access to the data',
  864. 'write_modules' => '',
  865. 'stimuli' => array(
  866. ),
  867. ),
  868. 'Writer' => array(
  869. 'description' => 'Contributor to the contents (read + write access)',
  870. 'write_modules' => 'UserData',
  871. 'stimuli' => array(
  872. // any class => 'any'
  873. ),
  874. ),
  875. );
  876. }
  877. public static function ComputeITILProfiles()
  878. {
  879. // In this profiling scheme, modules are based on ITIL recommendations
  880. //
  881. self::$m_aModules = array(
  882. /*
  883. 'WriteModule' => array(
  884. 'someclass',
  885. 'anotherclass',
  886. ),
  887. */
  888. 'General' => MetaModel::GetClasses('structure'),
  889. 'Documentation' => MetaModel::GetClasses('documentation'),
  890. 'Configuration' => MetaModel::GetClasses('configmgmt'),
  891. 'Incident' => MetaModel::GetClasses('incidentmgmt'),
  892. 'Problem' => MetaModel::GetClasses('problemmgmt'),
  893. 'Change' => MetaModel::GetClasses('changemgmt'),
  894. 'Service' => MetaModel::GetClasses('servicemgmt'),
  895. 'Call' => MetaModel::GetClasses('requestmgmt'),
  896. 'KnownError' => MetaModel::GetClasses('knownerrormgmt'),
  897. );
  898. self::$m_aProfiles = array(
  899. 'Configuration Manager' => array(
  900. 'description' => 'Person in charge of the documentation of the managed CIs',
  901. 'write_modules' => 'General,Documentation,Configuration',
  902. 'stimuli' => array(
  903. //'bizServer' => 'none',
  904. //'bizContract' => 'none',
  905. //'bizIncidentTicket' => 'none',
  906. //'bizChangeTicket' => 'any',
  907. ),
  908. ),
  909. 'Service Desk Agent' => array(
  910. 'description' => 'Person in charge of creating incident reports',
  911. 'write_modules' => 'Incident,Call',
  912. 'stimuli' => array(
  913. 'Incident' => 'ev_assign',
  914. 'UserRequest' => 'ev_assign',
  915. ),
  916. ),
  917. 'Support Agent' => array(
  918. 'description' => 'Person analyzing and solving the current incidents or problems',
  919. 'write_modules' => 'Incident,Problem,KnownError',
  920. 'stimuli' => array(
  921. 'Incident' => 'ev_assign,ev_reassign,ev_resolve,ev_close',
  922. 'UserRequest' => 'ev_assign,ev_reassign,ev_resolve,ev_close,ev_freeze',
  923. ),
  924. ),
  925. 'Change Implementor' => array(
  926. 'description' => 'Person executing the changes',
  927. 'write_modules' => 'Change',
  928. 'stimuli' => array(
  929. 'NormalChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  930. 'EmergencyChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  931. 'RoutineChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  932. ),
  933. ),
  934. 'Change Supervisor' => array(
  935. 'description' => 'Person responsible for the overall change execution',
  936. 'write_modules' => 'Change',
  937. 'stimuli' => array(
  938. 'NormalChange' => 'ev_validate,ev_reject,ev_assign,ev_reopen,ev_finish',
  939. 'EmergencyChange' => 'ev_assign,ev_reopen,ev_finish',
  940. 'RoutineChange' => 'ev_assign,ev_reopen,ev_finish',
  941. ),
  942. ),
  943. 'Change Approver' => array(
  944. 'description' => 'Person who could be impacted by some changes',
  945. 'write_modules' => 'Change',
  946. 'stimuli' => array(
  947. 'NormalChange' => 'ev_approve,ev_notapprove',
  948. 'EmergencyChange' => 'ev_approve,ev_notapprove',
  949. 'RoutineChange' => 'none',
  950. ),
  951. ),
  952. 'Service Manager' => array(
  953. 'description' => 'Person responsible for the service delivered to the [internal] customer',
  954. 'write_modules' => 'Service',
  955. 'stimuli' => array(
  956. ),
  957. ),
  958. 'Document author' => array(
  959. 'description' => 'Any person who could contribute to documentation',
  960. 'write_modules' => 'Documentation',
  961. 'stimuli' => array(
  962. ),
  963. ),
  964. );
  965. }
  966. }
  967. UserRights::SelectModule('UserRightsProfile');
  968. ?>