userrightsprofile.class.inc.php 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  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');
  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. // Those arrays could be completed on demand (inheriting parent permissions)
  365. protected $m_aClassActionGrants = null; // profile, class, action -> actiongrantid (or false if NO, or null/missing if undefined)
  366. protected $m_aClassStimulusGrants = array(); // profile, class, stimulus -> permission
  367. // Built on demand, could be optimized if necessary (doing a query for each attribute that needs to be read)
  368. protected $m_aObjectActionGrants = array();
  369. public function ResetCache()
  370. {
  371. // Loaded by Load cache
  372. $this->m_aProfiles = null;
  373. $this->m_aUserProfiles = null;
  374. $this->m_aUserOrgs = null;
  375. $this->m_aAdmins = null;
  376. // Loaded on demand (time consuming as compared to the others)
  377. $this->m_aClassActionGrants = null;
  378. $this->m_aClassStimulusGrants = null;
  379. $this->m_aObjectActionGrants = array();
  380. }
  381. // Separate load: this cache is much more time consuming while loading
  382. // Thus it is loaded iif required
  383. // Could be improved by specifying the profile id
  384. public function LoadActionGrantCache()
  385. {
  386. if (!is_null($this->m_aClassActionGrants)) return;
  387. $oKPI = new ExecutionKPI();
  388. $oFilter = DBObjectSearch::FromOQL_AllData("SELECT URP_ActionGrant AS p WHERE p.permission = 'yes'");
  389. $aGrants = $oFilter->ToDataArray();
  390. foreach($aGrants as $aGrant)
  391. {
  392. $this->m_aClassActionGrants[$aGrant['profileid']][$aGrant['class']][strtolower($aGrant['action'])] = $aGrant['id'];
  393. }
  394. $oKPI->ComputeAndReport('Load of action grants');
  395. }
  396. public function LoadCache()
  397. {
  398. if (!is_null($this->m_aProfiles)) return;
  399. // Could be loaded in a shared memory (?)
  400. $oKPI = new ExecutionKPI();
  401. $oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL_AllData("SELECT URP_Profiles"));
  402. $this->m_aProfiles = array();
  403. while ($oProfile = $oProfileSet->Fetch())
  404. {
  405. $this->m_aProfiles[$oProfile->GetKey()] = $oProfile;
  406. }
  407. $oUserProfileSet = new DBObjectSet(DBObjectSearch::FromOQL_AllData("SELECT URP_UserProfile"));
  408. $this->m_aUserProfiles = array();
  409. $this->m_aAdmins = array();
  410. while ($oUserProfile = $oUserProfileSet->Fetch())
  411. {
  412. $this->m_aUserProfiles[$oUserProfile->Get('userid')][$oUserProfile->Get('profileid')] = $oUserProfile;
  413. if ($oUserProfile->Get('profileid') == ADMIN_PROFILE_ID)
  414. {
  415. $this->m_aAdmins[] = $oUserProfile->Get('userid');
  416. }
  417. }
  418. $oUserOrgSet = new DBObjectSet(DBObjectSearch::FromOQL_AllData("SELECT URP_UserOrg"));
  419. $this->m_aUserOrgs = array();
  420. while ($oUserOrg = $oUserOrgSet->Fetch())
  421. {
  422. $this->m_aUserOrgs[$oUserOrg->Get('userid')][$oUserOrg->Get('allowed_org_id')] = $oUserOrg;
  423. }
  424. $this->m_aClassStimulusGrants = array();
  425. $oStimGrantSet = new DBObjectSet(DBObjectSearch::FromOQL_AllData("SELECT URP_StimulusGrant"));
  426. $this->m_aStimGrants = array();
  427. while ($oStimGrant = $oStimGrantSet->Fetch())
  428. {
  429. $this->m_aClassStimulusGrants[$oStimGrant->Get('profileid')][$oStimGrant->Get('class')][$oStimGrant->Get('stimulus')] = $oStimGrant;
  430. }
  431. $oKPI->ComputeAndReport('Load of user management cache (excepted Action Grants)');
  432. /*
  433. echo "<pre>\n";
  434. print_r($this->m_aProfiles);
  435. print_r($this->m_aUserProfiles);
  436. print_r($this->m_aUserOrgs);
  437. print_r($this->m_aClassActionGrants);
  438. print_r($this->m_aClassStimulusGrants);
  439. echo "</pre>\n";
  440. exit;
  441. */
  442. return true;
  443. }
  444. public function IsAdministrator($oUser)
  445. {
  446. $this->LoadCache();
  447. if (in_array($oUser->GetKey(), $this->m_aAdmins))
  448. {
  449. return true;
  450. }
  451. else
  452. {
  453. return false;
  454. }
  455. }
  456. public function GetSelectFilter($oUser, $sClass)
  457. {
  458. $this->LoadCache();
  459. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, UR_ACTION_READ);
  460. if ($aObjectPermissions['permission'] == UR_ALLOWED_NO)
  461. {
  462. return false;
  463. }
  464. // Determine how to position the objects of this class
  465. //
  466. if ($sClass == 'Organization')
  467. {
  468. $sAttCode = 'id';
  469. }
  470. elseif(MetaModel::IsValidAttCode($sClass, 'org_id'))
  471. {
  472. $sAttCode = 'org_id';
  473. }
  474. else
  475. {
  476. // The objects of this class are not positioned in this dimension
  477. // All of them are visible
  478. return true;
  479. }
  480. $oExpression = new FieldExpression($sAttCode, $sClass);
  481. // Position the user
  482. //
  483. @$aUserOrgs = $this->m_aUserOrgs[$oUser->GetKey()];
  484. if (!isset($aUserOrgs) || count($aUserOrgs) == 0)
  485. {
  486. // No position means 'Everywhere'
  487. return true;
  488. }
  489. $aIds = array_keys($aUserOrgs);
  490. $oListExpr = ListExpression::FromScalars($aIds);
  491. $oCondition = new BinaryExpression($oExpression, 'IN', $oListExpr);
  492. $oFilter = new DBObjectSearch($sClass);
  493. $oFilter->AddConditionExpression($oCondition);
  494. return $oFilter;
  495. }
  496. // This verb has been made public to allow the development of an accurate feedback for the current configuration
  497. public function GetProfileActionGrant($iProfile, $sClass, $sAction)
  498. {
  499. $this->LoadActionGrantCache();
  500. // Note: action is forced lowercase to be more flexible (historical bug)
  501. $sAction = strtolower($sAction);
  502. if (isset($this->m_aClassActionGrants[$iProfile][$sClass][$sAction]))
  503. {
  504. return $this->m_aClassActionGrants[$iProfile][$sClass][$sAction];
  505. }
  506. // Recursively look for the grant record in the class hierarchy
  507. $sParentClass = MetaModel::GetParentPersistentClass($sClass);
  508. if (empty($sParentClass))
  509. {
  510. $iGrant = null;
  511. }
  512. else
  513. {
  514. // Recursively look for the grant record in the class hierarchy
  515. $iGrant = $this->GetProfileActionGrant($iProfile, $sParentClass, $sAction);
  516. }
  517. $this->m_aClassActionGrants[$iProfile][$sClass][$sAction] = $iGrant;
  518. return $iGrant;
  519. }
  520. protected function GetUserActionGrant($oUser, $sClass, $iActionCode)
  521. {
  522. $this->LoadCache();
  523. // load and cache permissions for the current user on the given class
  524. //
  525. $iUser = $oUser->GetKey();
  526. $aTest = @$this->m_aObjectActionGrants[$iUser][$sClass][$iActionCode];
  527. if (is_array($aTest)) return $aTest;
  528. $sAction = self::$m_aActionCodes[$iActionCode];
  529. $iInstancePermission = UR_ALLOWED_NO;
  530. $aAttributes = array();
  531. if (isset($this->m_aUserProfiles[$iUser]))
  532. {
  533. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  534. {
  535. $iGrant = $this->GetProfileActionGrant($iProfile, $sClass, $sAction);
  536. if (is_null($iGrant) || !$iGrant)
  537. {
  538. continue; // loop to the next profile
  539. }
  540. else
  541. {
  542. $iInstancePermission = UR_ALLOWED_YES;
  543. // update the list of attributes with those allowed for this profile
  544. //
  545. $oSearch = DBObjectSearch::FromOQL_AllData("SELECT URP_AttributeGrant WHERE actiongrantid = :actiongrantid");
  546. $oSet = new DBObjectSet($oSearch, array(), array('actiongrantid' => $iGrant));
  547. $aProfileAttributes = $oSet->GetColumnAsArray('attcode', false);
  548. if (count($aProfileAttributes) == 0)
  549. {
  550. $aAllAttributes = array_keys(MetaModel::ListAttributeDefs($sClass));
  551. $aAttributes = array_merge($aAttributes, $aAllAttributes);
  552. }
  553. else
  554. {
  555. $aAttributes = array_merge($aAttributes, $aProfileAttributes);
  556. }
  557. }
  558. }
  559. }
  560. $aRes = array(
  561. 'permission' => $iInstancePermission,
  562. 'attributes' => $aAttributes,
  563. );
  564. $this->m_aObjectActionGrants[$iUser][$sClass][$iActionCode] = $aRes;
  565. return $aRes;
  566. }
  567. public function IsActionAllowed($oUser, $sClass, $iActionCode, $oInstanceSet = null)
  568. {
  569. $this->LoadCache();
  570. if (is_null($oInstanceSet))
  571. {
  572. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, $iActionCode);
  573. return $aObjectPermissions['permission'];
  574. }
  575. $oInstanceSet->Rewind();
  576. while($oObject = $oInstanceSet->Fetch())
  577. {
  578. $aObjectPermissions = $this->GetUserActionGrant($oUser, get_class($oObject), $iActionCode);
  579. $iInstancePermission = $aObjectPermissions['permission'];
  580. if (isset($iGlobalPermission))
  581. {
  582. if ($iInstancePermission != $iGlobalPermission)
  583. {
  584. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  585. break;
  586. }
  587. }
  588. else
  589. {
  590. $iGlobalPermission = $iInstancePermission;
  591. }
  592. }
  593. $oInstanceSet->Rewind();
  594. if (isset($iGlobalPermission))
  595. {
  596. return $iGlobalPermission;
  597. }
  598. else
  599. {
  600. return UR_ALLOWED_NO;
  601. }
  602. }
  603. public function IsActionAllowedOnAttribute($oUser, $sClass, $sAttCode, $iActionCode, $oInstanceSet = null)
  604. {
  605. $this->LoadCache();
  606. if (is_null($oInstanceSet))
  607. {
  608. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, $iActionCode);
  609. $aAttributes = $aObjectPermissions['attributes'];
  610. if (in_array($sAttCode, $aAttributes))
  611. {
  612. return $aObjectPermissions['permission'];
  613. }
  614. else
  615. {
  616. return UR_ALLOWED_NO;
  617. }
  618. }
  619. $oInstanceSet->Rewind();
  620. while($oObject = $oInstanceSet->Fetch())
  621. {
  622. $aObjectPermissions = $this->GetUserActionGrant($oUser, get_class($oObject), $iActionCode);
  623. $aAttributes = $aObjectPermissions['attributes'];
  624. if (in_array($sAttCode, $aAttributes))
  625. {
  626. $iInstancePermission = $aObjectPermissions['permission'];
  627. }
  628. else
  629. {
  630. $iInstancePermission = UR_ALLOWED_NO;
  631. }
  632. if (isset($iGlobalPermission))
  633. {
  634. if ($iInstancePermission != $iGlobalPermission)
  635. {
  636. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  637. }
  638. }
  639. else
  640. {
  641. $iGlobalPermission = $iInstancePermission;
  642. }
  643. }
  644. $oInstanceSet->Rewind();
  645. if (isset($iGlobalPermission))
  646. {
  647. return $iGlobalPermission;
  648. }
  649. else
  650. {
  651. return UR_ALLOWED_NO;
  652. }
  653. }
  654. // This verb has been made public to allow the development of an accurate feedback for the current configuration
  655. public function GetClassStimulusGrant($iProfile, $sClass, $sStimulusCode)
  656. {
  657. $this->LoadCache();
  658. if (isset($this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode]))
  659. {
  660. return $this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode];
  661. }
  662. else
  663. {
  664. return null;
  665. }
  666. }
  667. public function IsStimulusAllowed($oUser, $sClass, $sStimulusCode, $oInstanceSet = null)
  668. {
  669. $this->LoadCache();
  670. // Note: this code is VERY close to the code of IsActionAllowed()
  671. $iUser = $oUser->GetKey();
  672. if (is_null($oInstanceSet))
  673. {
  674. $iInstancePermission = UR_ALLOWED_NO;
  675. if (isset($this->m_aUserProfiles[$iUser]))
  676. {
  677. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  678. {
  679. $oGrantRecord = $this->GetClassStimulusGrant($iProfile, $sClass, $sStimulusCode);
  680. if (!is_null($oGrantRecord))
  681. {
  682. // no need to fetch the record, we've requested the records having permission = 'yes'
  683. $iInstancePermission = UR_ALLOWED_YES;
  684. }
  685. }
  686. }
  687. return $iInstancePermission;
  688. }
  689. $oInstanceSet->Rewind();
  690. while($oObject = $oInstanceSet->Fetch())
  691. {
  692. $iInstancePermission = UR_ALLOWED_NO;
  693. if (isset($this->m_aUserProfiles[$iUser]))
  694. {
  695. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  696. {
  697. $oGrantRecord = $this->GetClassStimulusGrant($iProfile, get_class($oObject), $sStimulusCode);
  698. if (!is_null($oGrantRecord))
  699. {
  700. // no need to fetch the record, we've requested the records having permission = 'yes'
  701. $iInstancePermission = UR_ALLOWED_YES;
  702. }
  703. }
  704. }
  705. if (isset($iGlobalPermission))
  706. {
  707. if ($iInstancePermission != $iGlobalPermission)
  708. {
  709. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  710. }
  711. }
  712. else
  713. {
  714. $iGlobalPermission = $iInstancePermission;
  715. }
  716. }
  717. $oInstanceSet->Rewind();
  718. if (isset($iGlobalPermission))
  719. {
  720. return $iGlobalPermission;
  721. }
  722. else
  723. {
  724. return UR_ALLOWED_NO;
  725. }
  726. }
  727. public function FlushPrivileges()
  728. {
  729. $this->ResetCache();
  730. }
  731. }
  732. //
  733. // Create simple profiles into our user management model:
  734. // - administrator
  735. // - readers
  736. // - contributors
  737. //
  738. class SetupProfiles
  739. {
  740. protected static $m_aActions = array(
  741. UR_ACTION_READ => 'Read',
  742. UR_ACTION_MODIFY => 'Modify',
  743. UR_ACTION_DELETE => 'Delete',
  744. UR_ACTION_BULK_READ => 'Bulk Read',
  745. UR_ACTION_BULK_MODIFY => 'Bulk Modify',
  746. UR_ACTION_BULK_DELETE => 'Bulk Delete',
  747. );
  748. // Note: It is possible to specify the same class in several modules
  749. //
  750. protected static $m_aModules = array();
  751. protected static $m_aProfiles = array();
  752. protected static function DoCreateActionGrant($iProfile, $iAction, $sClass, $bPermission = true)
  753. {
  754. $oNewObj = MetaModel::NewObject("URP_ActionGrant");
  755. $oNewObj->Set('profileid', $iProfile);
  756. $oNewObj->Set('permission', $bPermission ? 'yes' : 'no');
  757. $oNewObj->Set('class', $sClass);
  758. $oNewObj->Set('action', self::$m_aActions[$iAction]);
  759. $iId = $oNewObj->DBInsertNoReload();
  760. return $iId;
  761. }
  762. protected static function DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass)
  763. {
  764. $oNewObj = MetaModel::NewObject("URP_StimulusGrant");
  765. $oNewObj->Set('profileid', $iProfile);
  766. $oNewObj->Set('permission', 'yes');
  767. $oNewObj->Set('class', $sClass);
  768. $oNewObj->Set('stimulus', $sStimulusCode);
  769. $iId = $oNewObj->DBInsertNoReload();
  770. return $iId;
  771. }
  772. protected static function DoCreateAdminProfile()
  773. {
  774. $oNewObj = MetaModel::NewObject("URP_Profiles");
  775. $oNewObj->Set('name', 'Administrator');
  776. $oNewObj->Set('description', 'Has the rights on everything (bypassing any control)');
  777. $iNewId = $oNewObj->DBInsertNoReload();
  778. if ($iNewId != ADMIN_PROFILE_ID)
  779. {
  780. throw new CoreException('Admin profile could not be created with its standard id', array('requested'=>ADMIN_PROFILE_ID, 'obtained'=>$iNewId));
  781. }
  782. }
  783. protected static function DoCreateOneProfile($sName, $aProfileData)
  784. {
  785. $sDescription = $aProfileData['description'];
  786. if (strlen(trim($aProfileData['write_modules'])) == 0)
  787. {
  788. $aWriteModules = array();
  789. }
  790. else
  791. {
  792. $aWriteModules = explode(',', trim($aProfileData['write_modules']));
  793. }
  794. $aStimuli = $aProfileData['stimuli'];
  795. $oNewObj = MetaModel::NewObject("URP_Profiles");
  796. $oNewObj->Set('name', $sName);
  797. $oNewObj->Set('description', $sDescription);
  798. $iProfile = $oNewObj->DBInsertNoReload();
  799. // Grant read rights for everything
  800. //
  801. foreach (MetaModel::GetClasses('bizmodel') as $sClass)
  802. {
  803. self::DoCreateActionGrant($iProfile, UR_ACTION_READ, $sClass);
  804. self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_READ, $sClass);
  805. }
  806. // Grant write for given modules
  807. // Start by compiling the information, because some modules may overlap
  808. $aWriteableClasses = array();
  809. foreach ($aWriteModules as $sModule)
  810. {
  811. //$oPage->p('Granting write access for the module"'.$sModule.'" - '.count(self::$m_aModules[$sModule]).' classes');
  812. foreach (self::$m_aModules[$sModule] as $sClass)
  813. {
  814. $aWriteableClasses[$sClass] = true;
  815. }
  816. }
  817. foreach ($aWriteableClasses as $sClass => $foo)
  818. {
  819. // Skip non instantiable classes
  820. if (MetaModel::IsAbstract($sClass)) continue;
  821. if (!MetaModel::IsValidClass($sClass))
  822. {
  823. throw new CoreException("Invalid class name '$sClass'");
  824. }
  825. self::DoCreateActionGrant($iProfile, UR_ACTION_MODIFY, $sClass);
  826. self::DoCreateActionGrant($iProfile, UR_ACTION_DELETE, $sClass);
  827. self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_MODIFY, $sClass);
  828. // By default, do not allow bulk deletion operations for standard users
  829. // self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_DELETE, $sClass);
  830. }
  831. // Grant stimuli for given classes
  832. foreach ($aStimuli as $sClass => $sAllowedStimuli)
  833. {
  834. if (!MetaModel::IsValidClass($sClass))
  835. {
  836. // Could be a class defined in a module that wasn't installed
  837. continue;
  838. //throw new CoreException("Invalid class name '$sClass'");
  839. }
  840. if ($sAllowedStimuli == 'any')
  841. {
  842. $aAllowedStimuli = array_keys(MetaModel::EnumStimuli($sClass));
  843. }
  844. elseif ($sAllowedStimuli == 'none')
  845. {
  846. $aAllowedStimuli = array();
  847. }
  848. else
  849. {
  850. $aAllowedStimuli = explode(',', $sAllowedStimuli);
  851. }
  852. foreach ($aAllowedStimuli as $sStimulusCode)
  853. {
  854. self::DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass);
  855. }
  856. }
  857. }
  858. public static function DoCreateProfiles()
  859. {
  860. self::DoCreateAdminProfile();
  861. foreach(self::$m_aProfiles as $sName => $aProfileData)
  862. {
  863. self::DoCreateOneProfile($sName, $aProfileData);
  864. }
  865. }
  866. public static function ComputeBasicProfiles()
  867. {
  868. // In this profiling scheme, one single module represents all the classes
  869. //
  870. self::$m_aModules = array(
  871. 'UserData' => MetaModel::GetClasses('bizmodel'),
  872. );
  873. self::$m_aProfiles = array(
  874. 'Reader' => array(
  875. 'description' => 'Person having a ready-only access to the data',
  876. 'write_modules' => '',
  877. 'stimuli' => array(
  878. ),
  879. ),
  880. 'Writer' => array(
  881. 'description' => 'Contributor to the contents (read + write access)',
  882. 'write_modules' => 'UserData',
  883. 'stimuli' => array(
  884. // any class => 'any'
  885. ),
  886. ),
  887. );
  888. }
  889. public static function ComputeITILProfiles()
  890. {
  891. // In this profiling scheme, modules are based on ITIL recommendations
  892. //
  893. self::$m_aModules = array(
  894. /*
  895. 'WriteModule' => array(
  896. 'someclass',
  897. 'anotherclass',
  898. ),
  899. */
  900. 'General' => MetaModel::GetClasses('structure'),
  901. 'Documentation' => MetaModel::GetClasses('documentation'),
  902. 'Configuration' => MetaModel::GetClasses('configmgmt'),
  903. 'Incident' => MetaModel::GetClasses('incidentmgmt'),
  904. 'Problem' => MetaModel::GetClasses('problemmgmt'),
  905. 'Change' => MetaModel::GetClasses('changemgmt'),
  906. 'Service' => MetaModel::GetClasses('servicemgmt'),
  907. 'Call' => MetaModel::GetClasses('requestmgmt'),
  908. 'KnownError' => MetaModel::GetClasses('knownerrormgmt'),
  909. );
  910. self::$m_aProfiles = array(
  911. 'Configuration Manager' => array(
  912. 'description' => 'Person in charge of the documentation of the managed CIs',
  913. 'write_modules' => 'General,Documentation,Configuration',
  914. 'stimuli' => array(
  915. //'bizServer' => 'none',
  916. //'bizContract' => 'none',
  917. //'bizIncidentTicket' => 'none',
  918. //'bizChangeTicket' => 'any',
  919. ),
  920. ),
  921. 'Service Desk Agent' => array(
  922. 'description' => 'Person in charge of creating incident reports',
  923. 'write_modules' => 'Incident,Call',
  924. 'stimuli' => array(
  925. 'Incident' => 'ev_assign',
  926. 'UserRequest' => 'ev_assign',
  927. ),
  928. ),
  929. 'Support Agent' => array(
  930. 'description' => 'Person analyzing and solving the current incidents or problems',
  931. 'write_modules' => 'Incident,Problem,KnownError',
  932. 'stimuli' => array(
  933. 'Incident' => 'ev_assign,ev_reassign,ev_resolve,ev_close',
  934. 'UserRequest' => 'ev_assign,ev_reassign,ev_resolve,ev_close,ev_freeze',
  935. ),
  936. ),
  937. 'Change Implementor' => array(
  938. 'description' => 'Person executing the changes',
  939. 'write_modules' => 'Change',
  940. 'stimuli' => array(
  941. 'NormalChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  942. 'EmergencyChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  943. 'RoutineChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  944. ),
  945. ),
  946. 'Change Supervisor' => array(
  947. 'description' => 'Person responsible for the overall change execution',
  948. 'write_modules' => 'Change',
  949. 'stimuli' => array(
  950. 'NormalChange' => 'ev_validate,ev_reject,ev_assign,ev_reopen,ev_finish',
  951. 'EmergencyChange' => 'ev_assign,ev_reopen,ev_finish',
  952. 'RoutineChange' => 'ev_assign,ev_reopen,ev_finish',
  953. ),
  954. ),
  955. 'Change Approver' => array(
  956. 'description' => 'Person who could be impacted by some changes',
  957. 'write_modules' => 'Change',
  958. 'stimuli' => array(
  959. 'NormalChange' => 'ev_approve,ev_notapprove',
  960. 'EmergencyChange' => 'ev_approve,ev_notapprove',
  961. 'RoutineChange' => 'none',
  962. ),
  963. ),
  964. 'Service Manager' => array(
  965. 'description' => 'Person responsible for the service delivered to the [internal] customer',
  966. 'write_modules' => 'Service',
  967. 'stimuli' => array(
  968. ),
  969. ),
  970. 'Document author' => array(
  971. 'description' => 'Any person who could contribute to documentation',
  972. 'write_modules' => 'Documentation',
  973. 'stimuli' => array(
  974. ),
  975. ),
  976. );
  977. }
  978. }
  979. UserRights::SelectModule('UserRightsProfile');
  980. ?>