userrightsprofile.class.inc.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  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. $iUser = $oUser->GetKey();
  490. $aTest = @$this->m_aObjectActionGrants[$iUser][$sClass][$iActionCode];
  491. if (is_array($aTest)) return $aTest;
  492. $sAction = self::$m_aActionCodes[$iActionCode];
  493. $iInstancePermission = UR_ALLOWED_NO;
  494. $aAttributes = array();
  495. if (isset($this->m_aUserProfiles[$iUser]))
  496. {
  497. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  498. {
  499. $oGrantRecord = $this->GetProfileActionGrant($iProfile, $sClass, $sAction);
  500. if (is_null($oGrantRecord))
  501. {
  502. continue; // loop to the next profile
  503. }
  504. else
  505. {
  506. $iInstancePermission = UR_ALLOWED_YES;
  507. // update the list of attributes with those allowed for this profile
  508. //
  509. $oSearch = DBObjectSearch::FromOQL_AllData("SELECT URP_AttributeGrant WHERE actiongrantid = :actiongrantid");
  510. $oSet = new DBObjectSet($oSearch, array(), array('actiongrantid' => $oGrantRecord->GetKey()));
  511. $aProfileAttributes = $oSet->GetColumnAsArray('attcode', false);
  512. if (count($aProfileAttributes) == 0)
  513. {
  514. $aAllAttributes = array_keys(MetaModel::ListAttributeDefs($sClass));
  515. $aAttributes = array_merge($aAttributes, $aAllAttributes);
  516. }
  517. else
  518. {
  519. $aAttributes = array_merge($aAttributes, $aProfileAttributes);
  520. }
  521. }
  522. }
  523. }
  524. $aRes = array(
  525. 'permission' => $iInstancePermission,
  526. 'attributes' => $aAttributes,
  527. );
  528. $this->m_aObjectActionGrants[$iUser][$sClass][$iActionCode] = $aRes;
  529. return $aRes;
  530. }
  531. public function IsActionAllowed($oUser, $sClass, $iActionCode, $oInstanceSet = null)
  532. {
  533. if (is_null($oInstanceSet))
  534. {
  535. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, $iActionCode);
  536. return $aObjectPermissions['permission'];
  537. }
  538. $oInstanceSet->Rewind();
  539. while($oObject = $oInstanceSet->Fetch())
  540. {
  541. $aObjectPermissions = $this->GetUserActionGrant($oUser, get_class($oObject), $iActionCode);
  542. $iInstancePermission = $aObjectPermissions['permission'];
  543. if (isset($iGlobalPermission))
  544. {
  545. if ($iInstancePermission != $iGlobalPermission)
  546. {
  547. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  548. break;
  549. }
  550. }
  551. else
  552. {
  553. $iGlobalPermission = $iInstancePermission;
  554. }
  555. }
  556. $oInstanceSet->Rewind();
  557. if (isset($iGlobalPermission))
  558. {
  559. return $iGlobalPermission;
  560. }
  561. else
  562. {
  563. return UR_ALLOWED_NO;
  564. }
  565. }
  566. public function IsActionAllowedOnAttribute($oUser, $sClass, $sAttCode, $iActionCode, $oInstanceSet = null)
  567. {
  568. if (is_null($oInstanceSet))
  569. {
  570. $aObjectPermissions = $this->GetUserActionGrant($oUser, $sClass, $iActionCode);
  571. $aAttributes = $aObjectPermissions['attributes'];
  572. if (in_array($sAttCode, $aAttributes))
  573. {
  574. return $aObjectPermissions['permission'];
  575. }
  576. else
  577. {
  578. return UR_ALLOWED_NO;
  579. }
  580. }
  581. $oInstanceSet->Rewind();
  582. while($oObject = $oInstanceSet->Fetch())
  583. {
  584. $aObjectPermissions = $this->GetUserActionGrant($oUser, get_class($oObject), $iActionCode);
  585. $aAttributes = $aObjectPermissions['attributes'];
  586. if (in_array($sAttCode, $aAttributes))
  587. {
  588. $iInstancePermission = $aObjectPermissions['permission'];
  589. }
  590. else
  591. {
  592. $iInstancePermission = UR_ALLOWED_NO;
  593. }
  594. if (isset($iGlobalPermission))
  595. {
  596. if ($iInstancePermission != $iGlobalPermission)
  597. {
  598. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  599. }
  600. }
  601. else
  602. {
  603. $iGlobalPermission = $iInstancePermission;
  604. }
  605. }
  606. $oInstanceSet->Rewind();
  607. if (isset($iGlobalPermission))
  608. {
  609. return $iGlobalPermission;
  610. }
  611. else
  612. {
  613. return UR_ALLOWED_NO;
  614. }
  615. }
  616. // This verb has been made public to allow the development of an accurate feedback for the current configuration
  617. public function GetClassStimulusGrant($iProfile, $sClass, $sStimulusCode)
  618. {
  619. if (isset($this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode]))
  620. {
  621. return $this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode];
  622. }
  623. // Get the permission for this profile/class/stimulus
  624. $oSearch = DBObjectSearch::FromOQL_AllData("SELECT URP_StimulusGrant WHERE class = :class AND stimulus = :stimulus AND profileid = :profile AND permission = 'yes'");
  625. $oSet = new DBObjectSet($oSearch, array(), array('class'=>$sClass, 'stimulus'=>$sStimulusCode, 'profile'=>$iProfile));
  626. if ($oSet->Count() >= 1)
  627. {
  628. $oGrantRecord = $oSet->Fetch();
  629. }
  630. else
  631. {
  632. $oGrantRecord = null;
  633. }
  634. $this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode] = $oGrantRecord;
  635. return $oGrantRecord;
  636. }
  637. public function IsStimulusAllowed($oUser, $sClass, $sStimulusCode, $oInstanceSet = null)
  638. {
  639. // Note: this code is VERY close to the code of IsActionAllowed()
  640. $iUser = $oUser->GetKey();
  641. if (is_null($oInstanceSet))
  642. {
  643. $iInstancePermission = UR_ALLOWED_NO;
  644. if (isset($this->m_aUserProfiles[$iUser]))
  645. {
  646. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  647. {
  648. $oGrantRecord = $this->GetClassStimulusGrant($iProfile, $sClass, $sStimulusCode);
  649. if (!is_null($oGrantRecord))
  650. {
  651. // no need to fetch the record, we've requested the records having permission = 'yes'
  652. $iInstancePermission = UR_ALLOWED_YES;
  653. }
  654. }
  655. }
  656. return $iInstancePermission;
  657. }
  658. $oInstanceSet->Rewind();
  659. while($oObject = $oInstanceSet->Fetch())
  660. {
  661. $iInstancePermission = UR_ALLOWED_NO;
  662. if (isset($this->m_aUserProfiles[$iUser]))
  663. {
  664. foreach($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
  665. {
  666. $oGrantRecord = $this->GetClassStimulusGrant($iProfile, get_class($oObject), $sStimulusCode);
  667. if (!is_null($oGrantRecord))
  668. {
  669. // no need to fetch the record, we've requested the records having permission = 'yes'
  670. $iInstancePermission = UR_ALLOWED_YES;
  671. }
  672. }
  673. }
  674. if (isset($iGlobalPermission))
  675. {
  676. if ($iInstancePermission != $iGlobalPermission)
  677. {
  678. $iGlobalPermission = UR_ALLOWED_DEPENDS;
  679. }
  680. }
  681. else
  682. {
  683. $iGlobalPermission = $iInstancePermission;
  684. }
  685. }
  686. $oInstanceSet->Rewind();
  687. if (isset($iGlobalPermission))
  688. {
  689. return $iGlobalPermission;
  690. }
  691. else
  692. {
  693. return UR_ALLOWED_NO;
  694. }
  695. }
  696. public function FlushPrivileges()
  697. {
  698. $this->CacheData();
  699. }
  700. }
  701. //
  702. // Create simple profiles into our user management model:
  703. // - administrator
  704. // - readers
  705. // - contributors
  706. //
  707. class SetupProfiles
  708. {
  709. protected static $m_aActions = array(
  710. UR_ACTION_READ => 'Read',
  711. UR_ACTION_MODIFY => 'Modify',
  712. UR_ACTION_DELETE => 'Delete',
  713. UR_ACTION_BULK_READ => 'Bulk Read',
  714. UR_ACTION_BULK_MODIFY => 'Bulk Modify',
  715. UR_ACTION_BULK_DELETE => 'Bulk Delete',
  716. );
  717. // Note: It is possible to specify the same class in several modules
  718. //
  719. protected static $m_aModules = array();
  720. protected static $m_aProfiles = array();
  721. protected static function DoCreateActionGrant($iProfile, $iAction, $sClass, $bPermission = true)
  722. {
  723. $oNewObj = MetaModel::NewObject("URP_ActionGrant");
  724. $oNewObj->Set('profileid', $iProfile);
  725. $oNewObj->Set('permission', $bPermission ? 'yes' : 'no');
  726. $oNewObj->Set('class', $sClass);
  727. $oNewObj->Set('action', self::$m_aActions[$iAction]);
  728. $iId = $oNewObj->DBInsertNoReload();
  729. return $iId;
  730. }
  731. protected static function DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass)
  732. {
  733. $oNewObj = MetaModel::NewObject("URP_StimulusGrant");
  734. $oNewObj->Set('profileid', $iProfile);
  735. $oNewObj->Set('permission', 'yes');
  736. $oNewObj->Set('class', $sClass);
  737. $oNewObj->Set('stimulus', $sStimulusCode);
  738. $iId = $oNewObj->DBInsertNoReload();
  739. return $iId;
  740. }
  741. protected static function DoCreateAdminProfile()
  742. {
  743. $oNewObj = MetaModel::NewObject("URP_Profiles");
  744. $oNewObj->Set('name', 'Administrator');
  745. $oNewObj->Set('description', 'Has the rights on everything (bypassing any control)');
  746. $iNewId = $oNewObj->DBInsertNoReload();
  747. if ($iNewId != ADMIN_PROFILE_ID)
  748. {
  749. throw new CoreException('Admin profile could not be created with its standard id', array('requested'=>ADMIN_PROFILE_ID, 'obtained'=>$iNewId));
  750. }
  751. }
  752. protected static function DoCreateOneProfile($sName, $aProfileData)
  753. {
  754. $sDescription = $aProfileData['description'];
  755. if (strlen(trim($aProfileData['write_modules'])) == 0)
  756. {
  757. $aWriteModules = array();
  758. }
  759. else
  760. {
  761. $aWriteModules = explode(',', trim($aProfileData['write_modules']));
  762. }
  763. $aStimuli = $aProfileData['stimuli'];
  764. $oNewObj = MetaModel::NewObject("URP_Profiles");
  765. $oNewObj->Set('name', $sName);
  766. $oNewObj->Set('description', $sDescription);
  767. $iProfile = $oNewObj->DBInsertNoReload();
  768. // Grant read rights for everything
  769. //
  770. foreach (MetaModel::GetClasses('bizmodel') as $sClass)
  771. {
  772. // Skip non instantiable classes
  773. if (MetaModel::IsAbstract($sClass)) continue;
  774. self::DoCreateActionGrant($iProfile, UR_ACTION_READ, $sClass);
  775. self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_READ, $sClass);
  776. }
  777. // Grant write for given modules
  778. // Start by compiling the information, because some modules may overlap
  779. $aWriteableClasses = array();
  780. foreach ($aWriteModules as $sModule)
  781. {
  782. //$oPage->p('Granting write access for the module"'.$sModule.'" - '.count(self::$m_aModules[$sModule]).' classes');
  783. foreach (self::$m_aModules[$sModule] as $sClass)
  784. {
  785. $aWriteableClasses[$sClass] = true;
  786. }
  787. }
  788. foreach ($aWriteableClasses as $sClass => $foo)
  789. {
  790. // Skip non instantiable classes
  791. if (MetaModel::IsAbstract($sClass)) continue;
  792. if (!MetaModel::IsValidClass($sClass))
  793. {
  794. throw new CoreException("Invalid class name '$sClass'");
  795. }
  796. self::DoCreateActionGrant($iProfile, UR_ACTION_MODIFY, $sClass);
  797. self::DoCreateActionGrant($iProfile, UR_ACTION_DELETE, $sClass);
  798. self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_MODIFY, $sClass);
  799. // By default, do not allow bulk deletion operations for standard users
  800. // self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_DELETE, $sClass);
  801. }
  802. // Grant stimuli for given classes
  803. foreach ($aStimuli as $sClass => $sAllowedStimuli)
  804. {
  805. if (!MetaModel::IsValidClass($sClass))
  806. {
  807. // Could be a class defined in a module that wasn't installed
  808. continue;
  809. //throw new CoreException("Invalid class name '$sClass'");
  810. }
  811. if ($sAllowedStimuli == 'any')
  812. {
  813. $aAllowedStimuli = array_keys(MetaModel::EnumStimuli($sClass));
  814. }
  815. elseif ($sAllowedStimuli == 'none')
  816. {
  817. $aAllowedStimuli = array();
  818. }
  819. else
  820. {
  821. $aAllowedStimuli = explode(',', $sAllowedStimuli);
  822. }
  823. foreach ($aAllowedStimuli as $sStimulusCode)
  824. {
  825. self::DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass);
  826. }
  827. }
  828. }
  829. public static function DoCreateProfiles()
  830. {
  831. self::DoCreateAdminProfile();
  832. foreach(self::$m_aProfiles as $sName => $aProfileData)
  833. {
  834. self::DoCreateOneProfile($sName, $aProfileData);
  835. }
  836. }
  837. public static function ComputeBasicProfiles()
  838. {
  839. // In this profiling scheme, one single module represents all the classes
  840. //
  841. self::$m_aModules = array(
  842. 'UserData' => MetaModel::GetClasses('bizmodel'),
  843. );
  844. self::$m_aProfiles = array(
  845. 'Reader' => array(
  846. 'description' => 'Person having a ready-only access to the data',
  847. 'write_modules' => '',
  848. 'stimuli' => array(
  849. ),
  850. ),
  851. 'Writer' => array(
  852. 'description' => 'Contributor to the contents (read + write access)',
  853. 'write_modules' => 'UserData',
  854. 'stimuli' => array(
  855. // any class => 'any'
  856. ),
  857. ),
  858. );
  859. }
  860. public static function ComputeITILProfiles()
  861. {
  862. // In this profiling scheme, modules are based on ITIL recommendations
  863. //
  864. self::$m_aModules = array(
  865. /*
  866. 'WriteModule' => array(
  867. 'someclass',
  868. 'anotherclass',
  869. ),
  870. */
  871. 'General' => MetaModel::GetClasses('structure'),
  872. 'Documentation' => MetaModel::GetClasses('documentation'),
  873. 'Configuration' => MetaModel::GetClasses('configmgmt'),
  874. 'Incident' => MetaModel::GetClasses('incidentmgmt'),
  875. 'Problem' => MetaModel::GetClasses('problemmgmt'),
  876. 'Change' => MetaModel::GetClasses('changemgmt'),
  877. 'Service' => MetaModel::GetClasses('servicemgmt'),
  878. 'Call' => MetaModel::GetClasses('requestmgmt'),
  879. 'KnownError' => MetaModel::GetClasses('knownerrormgmt'),
  880. );
  881. self::$m_aProfiles = array(
  882. 'Configuration Manager' => array(
  883. 'description' => 'Person in charge of the documentation of the managed CIs',
  884. 'write_modules' => 'General,Documentation,Configuration',
  885. 'stimuli' => array(
  886. //'bizServer' => 'none',
  887. //'bizContract' => 'none',
  888. //'bizIncidentTicket' => 'none',
  889. //'bizChangeTicket' => 'any',
  890. ),
  891. ),
  892. 'Service Desk Agent' => array(
  893. 'description' => 'Person in charge of creating incident reports',
  894. 'write_modules' => 'Incident,Call',
  895. 'stimuli' => array(
  896. 'Incident' => 'ev_assign',
  897. 'UserRequest' => 'ev_assign',
  898. ),
  899. ),
  900. 'Support Agent' => array(
  901. 'description' => 'Person analyzing and solving the current incidents or problems',
  902. 'write_modules' => 'Incident,Problem,KnownError',
  903. 'stimuli' => array(
  904. 'Incident' => 'ev_assign,ev_reassign,ev_resolve,ev_close',
  905. 'UserRequest' => 'ev_assign,ev_reassign,ev_resolve,ev_close,ev_freeze',
  906. ),
  907. ),
  908. 'Change Implementor' => array(
  909. 'description' => 'Person executing the changes',
  910. 'write_modules' => 'Change',
  911. 'stimuli' => array(
  912. 'NormalChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  913. 'EmergencyChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  914. 'RoutineChange' => 'ev_plan,ev_replan,ev_implement,ev_monitor',
  915. ),
  916. ),
  917. 'Change Supervisor' => array(
  918. 'description' => 'Person responsible for the overall change execution',
  919. 'write_modules' => 'Change',
  920. 'stimuli' => array(
  921. 'NormalChange' => 'ev_validate,ev_reject,ev_assign,ev_reopen,ev_finish',
  922. 'EmergencyChange' => 'ev_assign,ev_reopen,ev_finish',
  923. 'RoutineChange' => 'ev_assign,ev_reopen,ev_finish',
  924. ),
  925. ),
  926. 'Change Approver' => array(
  927. 'description' => 'Person who could be impacted by some changes',
  928. 'write_modules' => 'Change',
  929. 'stimuli' => array(
  930. 'NormalChange' => 'ev_approve,ev_notapprove',
  931. 'EmergencyChange' => 'ev_approve,ev_notapprove',
  932. 'RoutineChange' => 'none',
  933. ),
  934. ),
  935. 'Service Manager' => array(
  936. 'description' => 'Person responsible for the service delivered to the [internal] customer',
  937. 'write_modules' => 'Service',
  938. 'stimuli' => array(
  939. ),
  940. ),
  941. 'Document author' => array(
  942. 'description' => 'Any person who could contribute to documentation',
  943. 'write_modules' => 'Documentation',
  944. 'stimuli' => array(
  945. ),
  946. ),
  947. );
  948. }
  949. }
  950. UserRights::SelectModule('UserRightsProfile');
  951. ?>