userrightsprofile.class.inc.php 38 KB

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