diff --git a/addons/userrights/userrightsmatrix.class.inc.php b/addons/userrights/userrightsmatrix.class.inc.php index 80a4b97ee..8341f6cdf 100644 --- a/addons/userrights/userrightsmatrix.class.inc.php +++ b/addons/userrights/userrightsmatrix.class.inc.php @@ -178,6 +178,11 @@ class UserRightsMatrix extends UserRightsAddOnAPI return true; } + public function IsAdministrator($iUserId) + { + return ($iUserId == 1); + } + public function Setup() { // Users must be added manually diff --git a/addons/userrights/userrightsnull.class.inc.php b/addons/userrights/userrightsnull.class.inc.php index 0d9656fef..79a8600a7 100644 --- a/addons/userrights/userrightsnull.class.inc.php +++ b/addons/userrights/userrightsnull.class.inc.php @@ -22,6 +22,11 @@ class UserRightsNull extends UserRightsAddOnAPI return true; } + public function IsAdministrator($iUserId) + { + return true; + } + public function Setup() { return true; diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index 10528bc90..ca8fbaa2f 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -14,12 +14,14 @@ */ -// It is supposed that this profile does exist in the DB -// Possible improvement: add it when executing the setup procedure -// define('ADMIN_PROFILE_ID', 1); -class URP_Users extends DBObject +class UserRightsBaseClass extends cmdbAbstractObject +{ +} + + +class URP_Users extends UserRightsBaseClass { public static function Init() { @@ -36,23 +38,38 @@ class URP_Users extends DBObject "db_table" => "priv_urp_users", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); - MetaModel::Init_AddAttribute(new AttributeInteger("userid", array("label"=>"User id", "description"=>"User identifier (depends on the business model)", "allowed_values"=>null, "sql"=>"userid", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("login", array("label"=>"login", "description"=>"user identification string", "allowed_values"=>null, "sql"=>"login", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("password", array("label"=>"password", "description"=>"user authentication string", "allowed_values"=>null, "sql"=>"pwd", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("email", array("label"=>"email", "description"=>"email address", "allowed_values"=>null, "sql"=>"email", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("firstname", array("label"=>"firstname", "description"=>"first name", "allowed_values"=>null, "sql"=>"firstname", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("lastname", array("label"=>"lastname", "description"=>"last name", "allowed_values"=>null, "sql"=>"lastname", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + + MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"bizPerson", "label"=>"Contact (person)", "description"=>"Personal details from the business data", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>true, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeExternalField("last_name", array("label"=>"Last name", "description"=>"Name of the corresponding contact", "allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"name"))); + MetaModel::Init_AddAttribute(new AttributeExternalField("first_name", array("label"=>"First name", "description"=>"First name of the corresponding contact", "allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"first_name"))); + MetaModel::Init_AddAttribute(new AttributeExternalField("email", array("label"=>"Email", "description"=>"Email of the corresponding contact", "allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"email"))); + + MetaModel::Init_AddAttribute(new AttributeString("login", array("label"=>"Login", "description"=>"user identification string", "allowed_values"=>null, "sql"=>"login", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributePassword("password", array("label"=>"Password", "description"=>"user authentication string", "allowed_values"=>null, "sql"=>"pwd", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + + MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("profiles", array("label"=>"Profiles", "description"=>"roles, granting rights for that person", "linked_class"=>"URP_UserProfile", "ext_key_to_me"=>"userid", "ext_key_to_remote"=>"profileid", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array()))); //MetaModel::Init_InheritFilters(); MetaModel::Init_AddFilterFromAttribute("userid"); MetaModel::Init_AddFilterFromAttribute("login"); + MetaModel::Init_AddFilterFromAttribute("password"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('userid', 'first_name', 'email', 'login')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('first_name', 'last_name', 'login')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('login', 'userid')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('login', 'userid')); // Criteria of the advanced search form } + } -class URP_Profiles extends DBObject + +class URP_Profiles extends UserRightsBaseClass { public static function Init() { @@ -69,19 +86,93 @@ class URP_Profiles extends DBObject "db_table" => "priv_urp_profiles", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); - MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"name", "description"=>"label", "allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"description", "description"=>"one line description", "allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"label", "allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"one line description", "allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + + MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("users", array("label"=>"Users", "description"=>"persons having this role", "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()))); //MetaModel::Init_InheritFilters(); MetaModel::Init_AddFilterFromAttribute("name"); MetaModel::Init_AddFilterFromAttribute("description"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('name', 'description')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('name', 'description')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form + } + + function GetGrantAsHtml($oUserRights, $sClass, $sAction) + { + $oGrant = $oUserRights->GetClassActionGrant($this->GetKey(), $sClass, $sAction); + if (is_object($oGrant) && ($oGrant->Get('permission') == 'yes')) + { + return 'yes'; + } + else + { + return 'no'; + } + } + + function DoShowGrantSumary($oPage) + { + + // Note: for sure, we assume that the instance is derived from UserRightsProfile + $oUserRights = UserRights::GetModuleInstance(); + + $aDisplayData = array(); + foreach (MetaModel::GetClasses('bizmodel') as $sClass) + { + $aStimuli = array(); + foreach (array_keys(MetaModel::EnumStimuli($sClass)) as $sStimulusCode) + { + $oGrant = $oUserRights->GetClassStimulusGrant($this->GetKey(), $sClass, $sStimulusCode); + if (is_object($oGrant) && ($oGrant->Get('permission') == 'yes')) + { + $aStimuli[] = $sStimulusCode; + } + } + $sStimuli = implode(', ', $aStimuli); + + $aDisplayData[] = array( + 'class' => MetaModel::GetName($sClass), + 'read' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Read'), + 'bulkread' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Read'), + 'write' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Modify'), + 'bulkwrite' => $this->GetGrantAsHtml($oUserRights, $sClass, 'Bulk Modify'), + 'stimuli' => $sStimuli, + ); + } + + $aDisplayConfig = array(); + $aDisplayConfig['class'] = array('label' => 'Class', 'description' => ''); + $aDisplayConfig['read'] = array('label' => 'Read', 'description' => ''); + $aDisplayConfig['bulkread'] = array('label' => 'Bulk read', 'description' => 'List objects or export massively'); + $aDisplayConfig['write'] = array('label' => 'Write', 'description' => 'Create and edit (modify)'); + $aDisplayConfig['bulkwrite'] = array('label' => 'Bulk write', 'description' => 'Massively create/edit (CSV import)'); + $aDisplayConfig['stimuli'] = array('label' => 'Stimuli', 'description' => 'Allowed (compound) actions'); + $oPage->table($aDisplayConfig, $aDisplayData); + } + + function DisplayBareRelations(web_page $oPage) + { + parent::DisplayBareRelations($oPage); + + $oPage->SetCurrentTabContainer('Related Objects'); + + $oPage->SetCurrentTab('Grants matrix'); + $this->DoShowGrantSumary($oPage); } } -class URP_Dimensions extends DBObject + +class URP_Dimensions extends UserRightsBaseClass { public static function Init() { @@ -98,17 +189,25 @@ class URP_Dimensions extends DBObject "db_table" => "priv_urp_dimensions", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "../business/templates/default.html", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); - MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"name", "description"=>"label", "allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"description", "description"=>"one line description", "allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("type", array("label"=>"type", "description"=>"class name or data type (projection unit)", "allowed_values"=>new ValueSetEnumClasses('bizmodel', 'String,Integer'), "sql"=>"type", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("name", array("label"=>"Name", "description"=>"label", "allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("description", array("label"=>"Description", "description"=>"one line description", "allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("type", array("label"=>"Type", "description"=>"class name or data type (projection unit)", "allowed_values"=>new ValueSetEnumClasses('bizmodel', 'String,Integer'), "sql"=>"type", "default_value"=>'String', "is_null_allowed"=>false, "depends_on"=>array()))); //MetaModel::Init_InheritFilters(); MetaModel::Init_AddFilterFromAttribute("name"); MetaModel::Init_AddFilterFromAttribute("description"); MetaModel::Init_AddFilterFromAttribute("type"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('name', 'description', 'type')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('name', 'description')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form } public function CheckProjectionSpec($oProjectionSpec, $sProjectedClass) @@ -193,39 +292,51 @@ class URP_Dimensions extends DBObject } } -class URP_UserProfile extends DBObject + +class URP_UserProfile extends UserRightsBaseClass { public static function Init() { $aParams = array ( "category" => "addon/userrights", - "name" => "user_profile", + "name" => "User to profile", "description" => "user profiles", "key_type" => "autoincrement", "key_label" => "", - "name_attcode" => "", + "name_attcode" => "userid", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_urp_userprofile", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "../business/templates/default.html", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"URP_Users", "jointype"=> "", "label"=>"User", "description"=>"user account", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalField("userlogin", array("label"=>"Login", "description"=>"User's login", "allowed_values"=>null, "extkey_attcode"=> 'userid', "target_attcode"=>"login"))); - MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "label"=>"profile", "description"=>"usage profile", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "label"=>"Profile", "description"=>"usage profile", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalField("profile", array("label"=>"Profile", "description"=>"Profile name", "allowed_values"=>null, "extkey_attcode"=> 'profileid', "target_attcode"=>"name"))); + MetaModel::Init_AddAttribute(new AttributeString("reason", array("label"=>"Reason", "description"=>"explain why this person may have this role", "allowed_values"=>null, "sql"=>"description", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + //MetaModel::Init_InheritFilters(); MetaModel::Init_AddFilterFromAttribute("userid"); MetaModel::Init_AddFilterFromAttribute("profileid"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('userid', 'profileid', 'reason')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('userid', 'profileid', 'reason')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('userid', 'profileid')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('userid', 'profileid')); // Criteria of the advanced search form } } -class URP_ProfileProjection extends DBObject + +class URP_ProfileProjection extends UserRightsBaseClass { public static function Init() { @@ -236,19 +347,20 @@ class URP_ProfileProjection extends DBObject "description" => "profile projections", "key_type" => "autoincrement", "key_label" => "", - "name_attcode" => "", + "name_attcode" => "profileid", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_urp_profileprojection", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "../business/templates/default.html", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); MetaModel::Init_AddAttribute(new AttributeExternalKey("dimensionid", array("targetclass"=>"URP_Dimensions", "jointype"=> "", "label"=>"Dimension", "description"=>"application dimension", "allowed_values"=>null, "sql"=>"dimensionid", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalField("dimension", array("label"=>"Dimension", "description"=>"application dimension", "allowed_values"=>null, "extkey_attcode"=> 'dimensionid', "target_attcode"=>"name"))); - MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "label"=>"profile", "description"=>"usage profile", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "label"=>"Profile", "description"=>"usage profile", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalField("profile", array("label"=>"Profile", "description"=>"Profile name", "allowed_values"=>null, "extkey_attcode"=> 'profileid', "target_attcode"=>"name"))); MetaModel::Init_AddAttribute(new AttributeString("value", array("label"=>"Value expression", "description"=>"OQL expression (using \$user) | constant | | +attribute code", "allowed_values"=>null, "sql"=>"value", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); @@ -257,6 +369,13 @@ class URP_ProfileProjection extends DBObject //MetaModel::Init_InheritFilters(); MetaModel::Init_AddFilterFromAttribute("dimensionid"); MetaModel::Init_AddFilterFromAttribute("profileid"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('dimensionid', 'profileid', 'value', 'attribute')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('dimensionid', 'profileid', 'value', 'attribute')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('dimensionid', 'profileid')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('dimensionid', 'profileid')); // Criteria of the advanced search form } public function ProjectUser(URP_Users $oUser) @@ -296,7 +415,8 @@ class URP_ProfileProjection extends DBObject } } -class URP_ClassProjection extends DBObject + +class URP_ClassProjection extends UserRightsBaseClass { public static function Init() { @@ -307,12 +427,13 @@ class URP_ClassProjection extends DBObject "description" => "class projections", "key_type" => "autoincrement", "key_label" => "", - "name_attcode" => "", + "name_attcode" => "dimensionid", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_urp_classprojection", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "../business/templates/default.html", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); @@ -328,6 +449,13 @@ class URP_ClassProjection extends DBObject MetaModel::Init_AddFilterFromAttribute("dimensionid"); // #@# verifier MetaModel::Init_AddFilterFromAttribute("class"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('dimensionid', 'class', 'value', 'attribute')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('dimensionid', 'class', 'value', 'attribute')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('dimensionid', 'class')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('dimensionid', 'class')); // Criteria of the advanced search form } public function ProjectObject($oObject) @@ -371,7 +499,8 @@ class URP_ClassProjection extends DBObject } } -class URP_ActionGrant extends DBObject + +class URP_ActionGrant extends UserRightsBaseClass { public static function Init() { @@ -382,12 +511,13 @@ class URP_ActionGrant extends DBObject "description" => "permissions on classes", "key_type" => "autoincrement", "key_label" => "", - "name_attcode" => "", + "name_attcode" => "profileid", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_urp_grant_actions", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "../business/templates/default.html", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); @@ -395,10 +525,10 @@ class URP_ActionGrant extends DBObject // Common to all grant classes (could be factorized by class inheritence, but this has to be benchmarked) MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "label"=>"Profile", "description"=>"usage profile", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalField("profile", array("label"=>"Profile", "description"=>"usage profile", "allowed_values"=>null, "extkey_attcode"=> 'profileid', "target_attcode"=>"name"))); - MetaModel::Init_AddAttribute(new AttributeString("class", array("label"=>"class", "description"=>"class name", "allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("label"=>"permission", "description"=>"allowed or not allowed?", "allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("class", array("label"=>"Class", "description"=>"class name", "allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("label"=>"Permission", "description"=>"allowed or not allowed?", "allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("action", array("label"=>"action", "description"=>"operations to perform on the given class", "allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("action", array("label"=>"Action", "description"=>"operations to perform on the given class", "allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); //MetaModel::Init_InheritFilters(); // Common to all grant classes (could be factorized by class inheritence, but this has to be benchmarked) @@ -408,10 +538,18 @@ class URP_ActionGrant extends DBObject MetaModel::Init_AddFilterFromAttribute("permission"); MetaModel::Init_AddFilterFromAttribute("action"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('profileid', 'class', 'permission', 'action')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('profileid', 'class', 'permission', 'action')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('profileid', 'class', 'permission', 'action')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('profileid', 'class', 'permission', 'action')); // Criteria of the advanced search form } } -class URP_StimulusGrant extends DBObject + +class URP_StimulusGrant extends UserRightsBaseClass { public static function Init() { @@ -422,12 +560,13 @@ class URP_StimulusGrant extends DBObject "description" => "permissions on stimilus in the life cycle of the object", "key_type" => "autoincrement", "key_label" => "", - "name_attcode" => "", + "name_attcode" => "profileid", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_urp_grant_stimulus", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "../business/templates/default.html", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); @@ -435,10 +574,10 @@ class URP_StimulusGrant extends DBObject // Common to all grant classes (could be factorized by class inheritence, but this has to be benchmarked) MetaModel::Init_AddAttribute(new AttributeExternalKey("profileid", array("targetclass"=>"URP_Profiles", "jointype"=> "", "label"=>"Profile", "description"=>"usage profile", "allowed_values"=>null, "sql"=>"profileid", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalField("profile", array("label"=>"Profile", "description"=>"usage profile", "allowed_values"=>null, "extkey_attcode"=> 'profileid', "target_attcode"=>"name"))); - MetaModel::Init_AddAttribute(new AttributeString("class", array("label"=>"class", "description"=>"class name", "allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("label"=>"permission", "description"=>"allowed or not allowed?", "allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("class", array("label"=>"Class", "description"=>"class name", "allowed_values"=>null, "sql"=>"class", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeEnum("permission", array("label"=>"Permission", "description"=>"allowed or not allowed?", "allowed_values"=>new ValueSetEnum('yes,no'), "sql"=>"permission", "default_value"=>"yes", "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("stimulus", array("label"=>"stimulus", "description"=>"stimulus code", "allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("stimulus", array("label"=>"Stimulus", "description"=>"stimulus code", "allowed_values"=>null, "sql"=>"action", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); //MetaModel::Init_InheritFilters(); // Common to all grant classes (could be factorized by class inheritence, but this has to be benchmarked) @@ -448,10 +587,18 @@ class URP_StimulusGrant extends DBObject MetaModel::Init_AddFilterFromAttribute("permission"); MetaModel::Init_AddFilterFromAttribute("stimulus"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('profileid', 'class', 'permission', 'stimulus')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('profileid', 'class', 'permission', 'stimulus')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('profileid', 'class', 'permission', 'stimulus')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('profileid', 'class', 'permission', 'stimulus')); // Criteria of the advanced search form } } -class URP_AttributeGrant extends DBObject + +class URP_AttributeGrant extends UserRightsBaseClass { public static function Init() { @@ -462,22 +609,30 @@ class URP_AttributeGrant extends DBObject "description" => "permissions at the attributes level", "key_type" => "autoincrement", "key_label" => "", - "name_attcode" => "", + "name_attcode" => "actiongrantid", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_urp_grant_attributes", "db_key_field" => "id", "db_finalclass_field" => "", + "display_template" => "../business/templates/default.html", ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); MetaModel::Init_AddAttribute(new AttributeExternalKey("actiongrantid", array("targetclass"=>"URP_ActionGrant", "jointype"=> "", "label"=>"Action grant", "description"=>"action grant", "allowed_values"=>null, "sql"=>"actiongrantid", "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeString("attcode", array("label"=>"attribute", "description"=>"attribute code", "allowed_values"=>null, "sql"=>"attcode", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("attcode", array("label"=>"Attribute", "description"=>"attribute code", "allowed_values"=>null, "sql"=>"attcode", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); //MetaModel::Init_InheritFilters(); MetaModel::Init_AddFilterFromAttribute("actiongrantid"); MetaModel::Init_AddFilterFromAttribute("attcode"); + + // Display lists + MetaModel::Init_SetZListItems('details', array('actiongrantid', 'attcode')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('actiongrantid', 'attcode')); // Attributes to be displayed for a list + // Search criteria + MetaModel::Init_SetZListItems('standard_search', array('actiongrantid', 'attcode')); // Criteria of the std search form + MetaModel::Init_SetZListItems('advanced_search', array('actiongrantid', 'attcode')); // Criteria of the advanced search form } } @@ -498,182 +653,68 @@ class UserRightsProfile extends UserRightsAddOnAPI // Installation: create the very first user public function CreateAdministrator($sAdminUser, $sAdminPwd) { + $oOrg = new bizOrganization(); + $oOrg->Set('name', 'My Company/Department'); + $oOrg->Set('code', 'SOMECODE'); + $oOrg->Set('status', 'implementation'); + //$oOrg->Set('parent_id', xxx); + $iOrgId = $oOrg->DBInsertNoReload(); + + // Location : optional + //$oLocation = new bizLocation(); + //$oLocation->Set('name', 'MyOffice'); + //$oLocation->Set('status', 'implementation'); + //$oLocation->Set('org_id', $iOrgId); + //$oLocation->Set('severity', 'high'); + //$oLocation->Set('address', 'my building in my city'); + //$oLocation->Set('country', 'my country'); + //$oLocation->Set('parent_location_id', xxx); + //$iLocationId = $oLocation->DBInsertNoReload(); + + $oContact = new bizPerson(); + $oContact->Set('name', 'My last name'); + $oContact->Set('first_name', 'My first name'); + $oContact->Set('status', 'production'); + $oContact->Set('org_id', $iOrgId); + $oContact->Set('email', 'my.email@foo.org'); + $oContact->Set('phone', ''); + //$oContact->Set('location_id', $iLocationId); + $oContact->Set('employee_number', ''); + $iContactId = $oContact->DBInsertNoReload(); + $oUser = new URP_Users(); $oUser->Set('login', $sAdminUser); $oUser->Set('password', $sAdminPwd); - $oUser->Set('email', 'n/a'); - $oUser->Set('firstname', 'administrator'); - $oUser->Set('lastname', 'itop'); - $oUser->Set('userid', 1); // let's mark it as #1 (for what purpose?) + $oUser->Set('userid', $iContactId); $iUserId = $oUser->DBInsertNoReload(); // Add this user to the very specific 'admin' profile $oUserProfile = new URP_UserProfile(); $oUserProfile->Set('userid', $iUserId); $oUserProfile->Set('profileid', ADMIN_PROFILE_ID); + $oUserProfile->Set('reason', 'By definition, the administrator must have the administrator profile'); $oUserProfile->DBInsertNoReload(); return true; } - public function Setup() + public function IsAdministrator($iUserId) { - // Dimensions/Profiles/Classes/Attributes/Stimuli could be added anytime - // This procedure will then update the matrix with expected default values - // - - $oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Profiles")); - while ($oProfile = $oProfileSet->Fetch()) + if (in_array($iUserId, $this->m_aAdmins)) { - $this->SetupProfile($oProfile); - } - - $oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions")); - while ($oDimension = $oDimensionSet->Fetch()) - { - $this->SetupDimension($oDimension); - } - return true; - } - - protected function SetupDimension($oDimension, $bNewDimension = false) - { - $iDimensionId = $oDimension->GetKey(); - - // Create projections, for any class where it applies - // - foreach(array('bizmodel', 'application', 'gui', 'core/cmdb') as $sCategory) - { - foreach (MetaModel::GetClasses($sCategory) as $sClass) - { - if ($bNewDimension) - { - $bAddCell = true; - } - else - { - $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ClassProjection WHERE class = :class AND dimensionid = :dimension"), array(), array('class'=>$sClass, 'dimension'=>$iDimensionId)); - $bAddCell = ($oSet->Count() < 1); - } - if ($bAddCell) - { - // Create a new entry - $oCProj = MetaModel::NewObject("URP_ClassProjection"); - $oCProj->Set("dimensionid", $iDimensionId); - $oCProj->Set("class", $sClass); - $oCProj->Set("value", "true"); - $iId = $oCProj->DBInsertNoReload(); - } - } - } - // Create projections, for any existing profile - // - $oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Profiles")); - while ($oProfile = $oProfileSet->Fetch()) - { - $iProfileId = $oProfile->GetKey(); - if ($bNewDimension) - { - $bAddCell = true; - } - else - { - $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ProfileProjection WHERE dimensionid = :dimension AND profileid = :profile"), array(), array('dimension'=>$iDimensionId, 'profile'=>$iProfileId)); - $bAddCell = ($oSet->Count() < 1); - } - if ($bAddCell) - { - // Create a new entry - $oDProj = MetaModel::NewObject("URP_ProfileProjection"); - $oDProj->Set("dimensionid", $iDimensionId); - $oDProj->Set("profileid", $iProfileId); - $oDProj->Set("value", "true"); - $iId = $oDProj->DBInsertNoReload(); - } - } - } - - protected function SetupProfile($oProfile, $bNewProfile = false) - { - $iProfileId = $oProfile->GetKey(); - - // Create grant records, for any class where it matters (the rest could be done later on) - // - foreach(array('bizmodel') as $sCategory) - { - foreach (MetaModel::GetClasses($sCategory) as $sClass) - { - foreach (self::$m_aActionCodes as $iActionCode => $sAction) - { - if ($bNewProfile) - { - $bAddCell = true; - } - else - { - $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ActionGrant WHERE class = :class AND action = :action AND profileid = :profile"), array(), array('class'=>$sClass, 'action'=>$sAction, 'profile'=>$iProfileId)); - $bAddCell = ($oSet->Count() < 1); - } - if ($bAddCell) - { - // Create a new entry - $oMyActionGrant = MetaModel::NewObject("URP_ActionGrant"); - $oMyActionGrant->Set("profileid", $iProfileId); - $oMyActionGrant->Set("class", $sClass); - $oMyActionGrant->Set("action", $sAction); - $oMyActionGrant->Set("permission", "yes"); - $iId = $oMyActionGrant->DBInsertNoReload(); - } - } - foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus) - { - if ($bNewProfile) - { - $bAddCell = true; - } - else - { - $oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_StimulusGrant WHERE class = :class AND stimulus = :stimulus AND profileid = :profile"), array(), array('class'=>$sClass, 'stimulus'=>$sStimulusCode, 'profile'=>$iProfileId)); - $bAddCell = ($oSet->Count() < 1); - } - if ($bAddCell) - { - // Create a new entry - $oMyStGrant = MetaModel::NewObject("URP_StimulusGrant"); - $oMyStGrant->Set("profileid", $iProfileId); - $oMyStGrant->Set("class", $sClass); - $oMyStGrant->Set("stimulus", $sStimulusCode); - $oMyStGrant->Set("permission", "yes"); - $iId = $oMyStGrant->DBInsertNoReload(); - } - } - } - } - // Create the "My Bookmarks" menu item (parent_id = 0, rank = 6) - if ($bNewProfile) - { - $bAddMenu = true; + return true; } else { - //$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT menuNode WHERE type = 'user' AND parent_id = 0 AND user_id = $iUserId")); - //$bAddMenu = ($oSet->Count() < 1); - } - $bAddMenu = false; - if ($bAddMenu) - { - $oMenu = MetaModel::NewObject('menuNode'); - $oMenu->Set('type', 'user'); - $oMenu->Set('parent_id', 0); // It's a toplevel entry - $oMenu->Set('rank', 6); // Located just above the Admin Tools section (=7) - $oMenu->Set('name', 'My Bookmarks'); - $oMenu->Set('label', 'My Favorite Items'); - $oMenu->Set('hyperlink', 'UI.php'); - $oMenu->Set('template', '

My bookmarks

This section contains my most favorite search results

'); - $oMenu->Set('user_id', $iUserId); - $oMenu->DBInsert(); + return false; } } + public function Setup() + { + SetupITILProfiles::DoCreateProfiles(); + return true; + } + public function Init() { MetaModel::RegisterPlugin('userrights', 'ACbyProfile', array($this, 'CacheData')); @@ -689,6 +730,7 @@ class UserRightsProfile extends UserRightsAddOnAPI protected $m_aAdmins = array(); // id of users being linked to the profile #ADMIN_PROFILE_ID protected $m_aClassActionGrants = array(); // profile, class, action -> permission + protected $m_aClassStimulusGrants = array(); // profile, class, stimulus -> permission protected $m_aObjectActionGrants = array(); // userid, class, id, action -> permission, list of attributes public function CacheData() @@ -787,19 +829,33 @@ exit; return $oNullFilter; } - protected function GetClassActionGrant($iProfile, $sClass, $sAction) + // This verb has been made public to allow the development of an accurate feedback for the current configuration + public function GetClassActionGrant($iProfile, $sClass, $sAction) { - $aTest = @$this->m_aClassActionGrants[$iProfile][$sClass][$sAction]; - if (isset($aTest)) return $aTest; + if (isset($this->m_aClassActionGrants[$iProfile][$sClass][$sAction])) + { + return $this->m_aClassActionGrants[$iProfile][$sClass][$sAction]; + } // Get the permission for this profile/class/action $oSearch = DBObjectSearch::FromOQL("SELECT URP_ActionGrant WHERE class = :class AND action = :action AND profileid = :profile AND permission = 'yes'"); $oSet = new DBObjectSet($oSearch, array(), array('class'=>$sClass, 'action'=>$sAction, 'profile'=>$iProfile)); - if ($oSet->Count() < 1) + if ($oSet->Count() >= 1) { - return null; + $oGrantRecord = $oSet->Fetch(); + } + else + { + $sParentClass = MetaModel::GetParentPersistentClass($sClass); + if (empty($sParentClass)) + { + $oGrantRecord = null; + } + else + { + $oGrantRecord = $this->GetClassActionGrant($iProfile, $sParentClass, $sAction); + } } - $oGrantRecord = $oSet->Fetch(); $this->m_aClassActionGrants[$iProfile][$sClass][$sAction] = $oGrantRecord; return $oGrantRecord; @@ -854,8 +910,7 @@ exit; public function IsActionAllowed($iUserId, $sClass, $iActionCode, dbObjectSet $oInstances) { - // super admin rights - if (in_array($iUserId, $this->m_aAdmins)) return true; + if ($this->IsAdministrator($iUserId)) return true; $oUser = $this->m_aUsers[$iUserId]; @@ -892,8 +947,7 @@ exit; public function IsActionAllowedOnAttribute($iUserId, $sClass, $sAttCode, $iActionCode, dbObjectSet $oInstances) { - // super admin rights - if (in_array($iUserId, $this->m_aAdmins)) return true; + if ($this->IsAdministrator($iUserId)) return true; $oUser = $this->m_aUsers[$iUserId]; @@ -936,10 +990,33 @@ exit; } } + // This verb has been made public to allow the development of an accurate feedback for the current configuration + public function GetClassStimulusGrant($iProfile, $sClass, $sStimulusCode) + { + if (isset($this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode])) + { + return $this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode]; + } + + // Get the permission for this profile/class/stimulus + $oSearch = DBObjectSearch::FromOQL("SELECT URP_StimulusGrant WHERE class = :class AND stimulus = :stimulus AND profileid = :profile AND permission = 'yes'"); + $oSet = new DBObjectSet($oSearch, array(), array('class'=>$sClass, 'stimulus'=>$sStimulusCode, 'profile'=>$iProfile)); + if ($oSet->Count() >= 1) + { + $oGrantRecord = $oSet->Fetch(); + } + else + { + $oGrantRecord = null; + } + + $this->m_aClassStimulusGrants[$iProfile][$sClass][$sStimulusCode] = $oGrantRecord; + return $oGrantRecord; + } + public function IsStimulusAllowed($iUserId, $sClass, $sStimulusCode, dbObjectSet $oInstances) { - // super admin rights - if (in_array($iUserId, $this->m_aAdmins)) return true; + if ($this->IsAdministrator($iUserId)) return true; $oUser = $this->m_aUsers[$iUserId]; @@ -1069,6 +1146,274 @@ exit; } } +// +// Here is the code that will create some profiles into our user management model, given an ITIL representation of the user profiles +// +class SetupITILProfiles +{ + /* + Later, maybe ? + + protected static $m_aDimensions = array( + 'organization' => array( + 'description' => '', + 'type' => 'bizOrganization', + ), + 'site' => array( + 'description' => '', + 'type' => '', + ), + ); + */ + protected static $m_aActions = array( + UR_ACTION_READ => 'Read', + UR_ACTION_MODIFY => 'Modify', + UR_ACTION_DELETE => 'Delete', + UR_ACTION_BULK_READ => 'Bulk Read', + UR_ACTION_BULK_MODIFY => 'Bulk Modify', + UR_ACTION_BULK_DELETE => 'Bulk Delete', + ); + + // It is possible to specify the same class in several modules + // + protected static $m_aModules = array( + 'General' => array( + 'bizOrganization', + ), + 'Documentation' => array( + 'bizDocVersion', + 'lnkDocumentRealObject', + 'lnkDocumentContract', + 'lnkDocumentError', + ), + 'Configuration' => array( + 'logRealObject', + 'lnkContactRealObject', + 'lnkInterfaces', + 'ClientServerLinks', + 'lnkInfraGrouping', + ), + 'Incident' => array( + 'bizIncidentTicket', + 'lnkRelatedTicket', + 'lnkInfraTicket', + 'lnkContactTicket', + ), + 'Problem' => array( + 'bizKnownError', + 'lnkInfraError', + 'lnkDocumentError', + ), + 'Change' => array( + 'bizChangeTicket', + 'lnkInfraChangeTicket', + 'lnkContactChange', + ), + 'Service' => array( + 'bizContract', + 'lnkInfraContract', + 'lnkContactContract', + 'lnkDocumentContract', + ), + ); + + protected static $m_aProfiles = array( + 'Configuration Manager' => array( + 'description' => 'Person in charge of the documentation of the managed CIs', + 'write_modules' => 'Documentation,Configuration', + 'stimuli' => array( + 'bizServer' => 'any', + //'bizServer' => 'ev_store,ev_ship,ev_plug,ev_configuration_finished,ev_val_failed,ev_mtp,ev_start_change,ev_end_change,ev_decomission,ev_obsolete,ev_recycle', + 'bizContract' => 'none', + 'bizIncidentTicket' => 'none', + 'bizChangeTicket' => 'none', + ), + ), + /* 'Requestor pb granularite actions (create/delete)' => array( + 'description' => 'Person notifying an incident', + 'write_modules' => 'Incident', + 'stimuli' => array( + 'bizServer' => 'none', + 'bizContract' => 'none', + 'bizIncidentTicket' => 'none', + 'bizChangeTicket' => 'none', + ), + ), + */ + 'Service Desk Agent' => array( + 'description' => 'Person in charge of creating incident reports', + 'write_modules' => 'Documentation,Incident', + 'stimuli' => array( + 'bizServer' => 'none', + 'bizContract' => 'none', + 'bizIncidentTicket' => 'ev_assign', + 'bizChangeTicket' => 'none', + ), + ), + 'Support Agent' => array( + 'description' => 'Person analyzing and solving the current incidents or problems', + 'write_modules' => 'Documentation,Incident,Problem', + 'stimuli' => array( + 'bizIncidentTicket' => 'any', + //'bizIncidentTicket' => 'ev_assign,ev_reassign,ev_start_working,ev_close', + ), + ), + 'Change Implementor' => array( + 'description' => 'Person executing the changes', + 'write_modules' => 'Documentation,Configuration,Change', + 'stimuli' => array( + 'bizServer' => 'none', + 'bizContract' => 'none', + 'bizIncidentTicket' => 'none', + 'bizChangeTicket' => 'ev_plan,ev_replan,ev_implement,ev_monitor', + ), + ), + 'Change Supervisor' => array( + 'description' => 'Person responsible for the overall change execution', + 'write_modules' => 'Documentation,Change', + 'stimuli' => array( + 'bizServer' => 'none', + 'bizContract' => 'none', + 'bizIncidentTicket' => 'none', + 'bizChangeTicket' => 'ev_validate,ev_reject,ev_reopen,ev_finish', + ), + ), + 'Change Approver' => array( + 'description' => 'Person who could be impacted by some changes', + 'write_modules' => 'Documentation,Change', + 'stimuli' => array( + 'bizServer' => 'none', + 'bizContract' => 'none', + 'bizIncidentTicket' => 'none', + 'bizChangeTicket' => 'ev_approve,ev_notapprove', + ), + ), + 'Service Manager' => array( + 'description' => 'Person responsible for the service delivered to the [internal] customer', + 'write_modules' => 'Documentation,Service', + 'stimuli' => array( + 'bizServer' => 'none', + 'bizContract' => 'any', + //'bizContract' => 'ev_freeze_version,ev_sign,ev_begin,ev_notice,ev_terminate,ev_elapsed', + 'bizIncidentTicket' => 'none', + 'bizChangeTicket' => 'none', + ), + ), + ); + + + protected static function DoCreateProfileProjection($iProfile, $iDimension) + { + $oNewObj = MetaModel::NewObject("URP_ProfileProjection"); + $oNewObj->Set('profileid', $iProfile); + $oNewObj->Set('dimensionid', $iDimension); + $oNewObj->Set('value', ''); + $oNewObj->Set('attribute', ''); + $iId = $oNewObj->DBInsertNoReload(); + return $iId; + } + + + protected static function DoCreateActionGrant($iProfile, $iAction, $sClass) + { + $oNewObj = MetaModel::NewObject("URP_ActionGrant"); + $oNewObj->Set('profileid', $iProfile); + $oNewObj->Set('permission', true); + $oNewObj->Set('class', $sClass); + $oNewObj->Set('action', self::$m_aActions[$iAction]); + $iId = $oNewObj->DBInsertNoReload(); + return $iId; + } + + protected static function DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass) + { + $oNewObj = MetaModel::NewObject("URP_StimulusGrant"); + $oNewObj->Set('profileid', $iProfile); + $oNewObj->Set('permission', true); + $oNewObj->Set('class', $sClass); + $oNewObj->Set('stimulus', $sStimulusCode); + $iId = $oNewObj->DBInsertNoReload(); + return $iId; + } + + protected static function DoCreateOneProfile($sName, $aProfileData) + { + $sDescription = $aProfileData['description']; + $aWriteModules = explode(',', $aProfileData['write_modules']); + $aStimuli = $aProfileData['stimuli']; + + $oNewObj = MetaModel::NewObject("URP_Profiles"); + $oNewObj->Set('name', $sName); + $oNewObj->Set('description', $sDescription); + $iProfile = $oNewObj->DBInsertNoReload(); + + // Project in every dimension + // + $oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions")); + while ($oDimension = $oDimensionSet->Fetch()) + { + $iDimension = $oDimension->GetKey(); + self::DoCreateProfileProjection($iProfile, $iDimension); + } + + // Grant read rights for everything + // + foreach (MetaModel::GetClasses('bizmodel') as $sClass) + { + self::DoCreateActionGrant($iProfile, UR_ACTION_READ, $sClass); + self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_READ, $sClass); + } + + // Grant write for given modules + // Start by compiling the information, because some modules may overlap + $aWriteableClasses = array(); + foreach ($aWriteModules as $sModule) + { +// $oPage->p('Granting write access for the module"'.$sModule.'" - '.count(self::$m_aModules[$sModule]).' classes'); + foreach (self::$m_aModules[$sModule] as $sClass) + { + $aWriteableClasses[] = $sClass; + } + } + foreach ($aWriteableClasses as $sClass) + { + self::DoCreateActionGrant($iProfile, UR_ACTION_MODIFY, $sClass); + self::DoCreateActionGrant($iProfile, UR_ACTION_DELETE, $sClass); + self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_MODIFY, $sClass); + self::DoCreateActionGrant($iProfile, UR_ACTION_BULK_DELETE, $sClass); + } + + // Grant stimuli for given classes + foreach ($aStimuli as $sClass => $sAllowedStimuli) + { + if ($sAllowedStimuli == 'any') + { + $aAllowedStimuli = array_keys(MetaModel::EnumStimuli($sClass)); + } + elseif ($sAllowedStimuli == 'none') + { + $aAllowedStimuli = array(); + } + else + { + $aAllowedStimuli = explode(',', $sAllowedStimuli); + } + foreach ($aAllowedStimuli as $sStimulusCode) + { + self::DoCreateStimulusGrant($iProfile, $sStimulusCode, $sClass); + } + } + } + + public static function DoCreateProfiles() + { + foreach(self::$m_aProfiles as $sName => $aProfileData) + { + self::DoCreateOneProfile($sName, $aProfileData); + } + } +} + UserRights::SelectModule('UserRightsProfile'); ?> diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 59dd5a48b..e26d0647e 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -100,11 +100,71 @@ abstract class cmdbAbstractObject extends CMDBObject return $sDisplayValue; } + function DisplayBareHeader(web_page $oPage) + { + // Standard Header with name, actions menu and history block + // + $oPage->add("
\n"); + + // action menu + $oSingletonFilter = new DBObjectSearch(get_class($this)); + $oSingletonFilter->AddCondition('pkey', array($this->GetKey())); + $oBlock = new MenuBlock($oSingletonFilter, 'popup', false); + $oBlock->Display($oPage, -1); + + $oPage->add("

".MetaModel::GetName(get_class($this)).": ".$this->GetDisplayName()."

\n"); + + // history block (with toggle) + $oHistoryFilter = new DBObjectSearch('CMDBChangeOpSetAttribute'); + $oHistoryFilter->AddCondition('objkey', $this->GetKey()); + $oBlock = new HistoryBlock($oHistoryFilter, 'toggle', false); + $oBlock->Display($oPage, -1); + + $oPage->add("
\n"); + } + function DisplayBareDetails(web_page $oPage) { $oPage->add($this->GetBareDetails($oPage)); } + function DisplayBareRelations(web_page $oPage) + { + // Related objects + $oPage->AddTabContainer('Related Objects'); + $oPage->SetCurrentTabContainer('Related Objects'); + foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef) + { + if ((get_class($oAttDef) == 'AttributeLinkedSetIndirect') || (get_class($oAttDef) == 'AttributeLinkedSet')) + { + $oPage->SetCurrentTab($oAttDef->GetLabel()); + $oPage->p($oAttDef->GetDescription()); + + if (get_class($oAttDef) == 'AttributeLinkedSet') + { + $sTargetClass = $oAttDef->GetLinkedClass(); + $oFilter = new DBObjectSearch($sTargetClass); + $oFilter->AddCondition($oAttDef->GetExtKeyToMe(), $this->GetKey()); // @@@ condition has same name as field ?? + + $oBlock = new DisplayBlock($oFilter, 'list', false); + $oBlock->Display($oPage, 0); + } + else // get_class($oAttDef) == 'AttributeLinkedSetIndirect' + { + $sLinkClass = $oAttDef->GetLinkedClass(); + // Transform the DBObjectSet into a CMBDObjectSet !!! + $aLinkedObjects = $this->Get($sAttCode)->ToArray(false); + if (count($aLinkedObjects) > 0) + { + $oSet = CMDBObjectSet::FromArray($sLinkClass, $aLinkedObjects); + $this->DisplaySet($oPage, $oSet, $oAttDef->GetExtKeyToMe(), true, false, $this->GetKey(), $oAttDef->GetExtKeyToRemote()); + } + } + } + } + $oPage->SetCurrentTab(''); + } + function GetDisplayName() { return $this->GetAsHTML(MetaModel::GetNameAttributeCode(get_class($this))); @@ -152,56 +212,11 @@ abstract class cmdbAbstractObject extends CMDBObject } else { - // Standard Header with name, actions menu and history block - $oPage->add("
\n"); - $oSingletonFilter = new DBObjectSearch(get_class($this)); - $oSingletonFilter->AddCondition('pkey', array($this->GetKey())); - $oBlock = new MenuBlock($oSingletonFilter, 'popup', false); - $oBlock->Display($oPage, -1); - $oPage->add("

".Metamodel::GetName(MetaModel::GetName(get_class($this))).": ".$this->GetDisplayName()."

\n"); - $oHistoryFilter = new DBObjectSearch('CMDBChangeOpSetAttribute'); - $oHistoryFilter->AddCondition('objkey', $this->GetKey()); - $oBlock = new HistoryBlock($oHistoryFilter, 'toggle', false); - $oBlock->Display($oPage, -1); - $oPage->add("
\n"); - // Object's details // template not found display the object using the *old style* - self::DisplayBareDetails($oPage); - - // Related objects - $oPage->AddTabContainer('Related Objects'); - $oPage->SetCurrentTabContainer('Related Objects'); - foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef) - { - if ((get_class($oAttDef) == 'AttributeLinkedSetIndirect') || (get_class($oAttDef) == 'AttributeLinkedSet')) - { - $oPage->SetCurrentTab($oAttDef->GetLabel()); - $oPage->p($oAttDef->GetDescription()); - - if (get_class($oAttDef) == 'AttributeLinkedSet') - { - $sTargetClass = $oAttDef->GetLinkedClass(); - $oFilter = new DBObjectSearch($sTargetClass); - $oFilter->AddCondition($oAttDef->GetExtKeyToMe(), $this->GetKey()); // @@@ condition has same name as field ?? - - $oBlock = new DisplayBlock($oFilter, 'list', false); - $oBlock->Display($oPage, 0); - } - else // get_class($oAttDef) == 'AttributeLinkedSetIndirect' - { - $sLinkClass = $oAttDef->GetLinkedClass(); - // Transform the DBObjectSet into a CMBDObjectSet !!! - $aLinkedObjects = $this->Get($sAttCode)->ToArray(false); - if (count($aLinkedObjects) > 0) - { - $oSet = CMDBObjectSet::FromArray($sLinkClass, $aLinkedObjects); - $this->DisplaySet($oPage, $oSet, $oAttDef->GetExtKeyToMe()); - } - } - } - } - $oPage->SetCurrentTab(''); + $this->DisplayBareHeader($oPage); + $this->DisplayBareDetails($oPage); + $this->DisplayBareRelations($oPage); } } @@ -218,10 +233,10 @@ abstract class cmdbAbstractObject extends CMDBObject } // Comment by Rom: this helper may be used to display objects of class DBObject - // -> I am using this to display the changes history - public static function DisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false, $iObjectId = 0) + // -> I am using this to display the changes history + public static function DisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false, $iObjectId = 0, $sTargetAttribute = '') { - $oPage->add(self::GetDisplaySet($oPage, $oSet, array( 'link_attr' => $sLinkageAttribute, 'object_id' => $iObjectId, 'menu' => $bDisplayMenu, 'selection_mode' => $bSelectMode))); + $oPage->add(self::GetDisplaySet($oPage, $oSet, array( 'link_attr' => $sLinkageAttribute, 'object_id' => $iObjectId, 'target_attr' => $sTargetAttribute, 'menu' => $bDisplayMenu, 'selection_mode' => $bSelectMode))); } //public static function GetDisplaySet(web_page $oPage, CMDBObjectSet $oSet, $sLinkageAttribute = '', $bDisplayMenu = true, $bSelectMode = false) @@ -238,7 +253,7 @@ abstract class cmdbAbstractObject extends CMDBObject { if($iLinkedObjectId == 0) { - // if 'links' mode is requested the d of the object to link to must be specified + // if 'links' mode is requested the id of the object to link to must be specified throw new ApplicationException("Parameter object_id is mandatory when link_attr is specified. Check the definition of the display template."); } if($sTargetAttr == '') @@ -438,9 +453,9 @@ abstract class cmdbAbstractObject extends CMDBObject $sClassName = $oSet->GetFilter()->GetClass(); $sHtml .= "\n"; +
  • OQL Query
  • +
  • Simple Search
  • + \n"; // Simple search form $sHtml .= "
    \n"; $sHtml .= "

    Search for ".MetaModel::GetName($sClassName)." Objects

    \n"; @@ -487,32 +502,33 @@ abstract class cmdbAbstractObject extends CMDBObject } } } - $aAllowedValues = MetaModel::GetAllowedValues_flt($sClassName, $sFilterCode, array(), ''); - if ($aAllowedValues != null) - { - //Enum field or external key, display a combo - $sValue = "\n"; - $sHtml .= "$sValue\n"; - } - else - { - // Any value is possible, display an input box - $sHtml .= "\n"; - } + // #@# todo - add context information, otherwise any value will be authorized for external keys + $aAllowedValues = MetaModel::GetAllowedValues_flt($sClassName, $sFilterCode, array()); + if ($aAllowedValues != null) + { + //Enum field or external key, display a combo + $sValue = "\n"; + $sHtml .= "$sValue\n"; + } + else + { + // Any value is possible, display an input box + $sHtml .= "\n"; + } $index++; } if (($index % $numCols) != 0) @@ -577,6 +593,10 @@ abstract class cmdbAbstractObject extends CMDBObject $sHTMLValue = ""; break; + case 'Password': + $sHTMLValue = ""; + break; + case 'Text': $sHTMLValue = ""; break; @@ -588,39 +608,41 @@ abstract class cmdbAbstractObject extends CMDBObject case 'String': default: - $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array(), ''); - if ($aAllowedValues !== null) - { - //Enum field or external key, display a combo - if (count($aAllowedValues) == 0) + // #@# todo - add context information (depending on dimensions) + $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array()); + if ($aAllowedValues !== null) { - $sHTMLValue = ""; - } - else if (count($aAllowedValues) > 50) - { - // too many choices, use an autocomplete - // The input for the auto complete - $sHTMLValue = ""; - // another hidden input to store & pass the object's Id - $sHTMLValue .= "\n"; - $oPage->add_ready_script("\$('#label_$iInputId').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#$iInputId', extraParams:{operation:'autocomplete', sclass:'$sClass',attCode:'".$sAttCode."'}});"); + //Enum field or external key, display a combo + if (count($aAllowedValues) == 0) + { + $sHTMLValue = ""; + } + else if (count($aAllowedValues) > 50) + { + // too many choices, use an autocomplete + // The input for the auto complete + $sHTMLValue = ""; + // another hidden input to store & pass the object's Id + $sHTMLValue .= "\n"; + $oPage->add_ready_script("\$('#label_$iInputId').autocomplete('./ajax.render.php', { minChars:3, onItemSelect:selectItem, onFindValue:findValue, formatItem:formatItem, autoFill:true, keyHolder:'#$iInputId', extraParams:{operation:'autocomplete', sclass:'$sClass',attCode:'".$sAttCode."'}});"); + } + else + { + // Few choices, use a normal 'select' + $sHTMLValue = "\n"; + } } else { - // Few choices, use a normal 'select' - $sHTMLValue = "\n"; + $sHTMLValue = ""; } - } - else - { - $sHTMLValue = ""; - } + break; } } return $sHTMLValue; diff --git a/application/iotask.class.inc.php b/application/iotask.class.inc.php index 32eb33400..f1f62f8c7 100644 --- a/application/iotask.class.inc.php +++ b/application/iotask.class.inc.php @@ -31,7 +31,7 @@ class InputOutputTask extends cmdbAbstractObject MetaModel::Init_AddAttribute(new AttributeEnum("source_type", array("label"=>"Source Type", "description"=>"Type of data source", "allowed_values"=>new ValueSetEnum('File, Database, Web Service'), "sql"=>"source_type", "default_value"=>"File", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeEnum("source_subtype", array("label"=>"Source Subtype", "description"=>"Subtype of Data Source", "allowed_values"=>new ValueSetEnum('Oracle, MySQL, Postgress, MSSQL, SOAP, HTTP-Get, HTTP-Post, XML/RPC, CSV, XML, Excel'), "sql"=>"source_subtype", "default_value"=>"CSV", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeString("source_path", array("label"=>"Source Path", "description"=>"Path to the icon o the menu", "allowed_values"=>null, "sql"=>"source_path", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeEnum("objects_class", array("label"=>"Objects Class", "description"=>"Class of the objects processed by this task", "allowed_values"=>new ValueSetEnum('bizOrganization, bizContact, bizTeam, bizPerson, bizLocation, bizServer, bizPC, bizNetworkDevice, bizInterface, bizService, bizContract, bizInfraGroup, bizIncidentTicket, bizSoftware, bizApplication, bizPatch, bizWorkgroup, lnkContactRealObject, lnkInterfaces, bizInfraGrouping' ), "sql"=>"objects_class", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeEnum("objects_class", array("label"=>"Objects Class", "description"=>"Class of the objects processed by this task", "allowed_values"=>new ValueSetEnumClasses(), "sql"=>"objects_class", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeEnum("test_mode", array("label"=>"Test Mode", "description"=>"If set to 'Yes' the modifications are not applied", "allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"test_mode", "default_value"=>'No', "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeEnum("verbose_mode", array("label"=>"Verbose Mode", "description"=>"If set to 'Yes' extra debug information is added to the log", "allowed_values"=>new ValueSetEnum('Yes,No'), "sql"=>"verbose_mode", "default_value" => 'No', "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeEnum("options", array("label"=>"Options", "description"=>"Reconciliation options", "allowed_values"=>new ValueSetEnum('Full, Update Only, Creation Only'), "sql"=>"options", "default_value"=> 'Full', "is_null_allowed"=>true, "depends_on"=>array()))); diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index b315d17f4..37590b6a3 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -158,29 +158,44 @@ EOF $this->AddToMenu("\n"); $this->AddToMenu("
    \n"); $this->AddToMenu("
      \n"); - $oAppContext = new ApplicationContext(); - // Display the menu - // 1) Application defined menus - $oSearchFilter = $oContext->NewFilter("menuNode"); - $oSearchFilter->AddCondition('parent_id', 0, '='); - $oSearchFilter->AddCondition('type', 'application', '='); - // There may be more criteria added later to have a specific menu based on the user's profile - $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); - while ($oRootMenuNode = $oSet->Fetch()) - { - $oRootMenuNode->DisplayMenu($this, 'application', $oAppContext->GetAsHash()); - } - // 2) User defined menus (Bookmarks) - $oSearchFilter = $oContext->NewFilter("menuNode"); - $oSearchFilter->AddCondition('parent_id', 0, '='); - $oSearchFilter->AddCondition('type', 'user', '='); - $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); - // There may be more criteria added later to have a specific menu based on the user's profile - $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); - while ($oRootMenuNode = $oSet->Fetch()) - { - $oRootMenuNode->DisplayMenu($this, 'user', $oAppContext->GetAsHash()); - } + + // Display the menu + $oAppContext = new ApplicationContext(); + // 1) Application defined menus + $oSearchFilter = $oContext->NewFilter("menuNode"); + $oSearchFilter->AddCondition('parent_id', 0, '='); + $oSearchFilter->AddCondition('type', 'application', '='); + // There may be more criteria added later to have a specific menu based on the user's profile + $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); + while ($oRootMenuNode = $oSet->Fetch()) + { + $oRootMenuNode->DisplayMenu($this, 'application', $oAppContext->GetAsHash()); + } + // 2) User defined menus (Bookmarks) + $oSearchFilter = $oContext->NewFilter("menuNode"); + $oSearchFilter->AddCondition('parent_id', 0, '='); + $oSearchFilter->AddCondition('type', 'user', '='); + $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); + // There may be more criteria added later to have a specific menu based on the user's profile + $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); + while ($oRootMenuNode = $oSet->Fetch()) + { + $oRootMenuNode->DisplayMenu($this, 'user', $oAppContext->GetAsHash()); + } + // 3) Administrator menu + if (userRights::IsAdministrator()) + { + $oSearchFilter = $oContext->NewFilter("menuNode"); + $oSearchFilter->AddCondition('parent_id', 0, '='); + $oSearchFilter->AddCondition('type', 'administrator', '='); + // There may be more criteria added later to have a specific menu based on the user's profile + $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); + while ($oRootMenuNode = $oSet->Fetch()) + { + $oRootMenuNode->DisplayMenu($this, 'administrator', $oAppContext->GetAsHash()); + } + } + $this->AddToMenu("
    \n"); } diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php index 72ddfeb23..23cf78ead 100644 --- a/application/menunode.class.inc.php +++ b/application/menunode.class.inc.php @@ -42,7 +42,7 @@ class menuNode extends DBObject MetaModel::Init_AddAttribute(new AttributeString("hyperlink", array("label"=>"Hyperlink", "description"=>"Hyperlink to the page", "allowed_values"=>null, "sql"=>"hyperlink", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeString("icon_path", array("label"=>"Menu Icon", "description"=>"Path to the icon o the menu", "allowed_values"=>null, "sql"=>"icon_path", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeText("template", array("label"=>"Template", "description"=>"HTML template for the view", "allowed_values"=>null, "sql"=>"template", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of menu", "allowed_values"=>new ValueSetEnum('application,user'), "sql"=>"type", "default_value"=>"application", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeEnum("type", array("label"=>"Type", "description"=>"Type of menu", "allowed_values"=>new ValueSetEnum('application,user,administrator'), "sql"=>"type", "default_value"=>"application", "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeInteger("rank", array("label"=>"Display rank", "description"=>"Sort order for displaying the menu", "allowed_values"=>null, "sql"=>"rank", "default_value" => 999, "is_null_allowed"=>false, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("label"=>"Parent Menu Item", "description"=>"Parent Menu Item", "allowed_values"=>null, "sql"=>"parent_id", "targetclass"=>"menuNode", "is_null_allowed"=>true, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name", array("label"=>"Parent Menu Item", "description"=>"Parent Menu Item", "allowed_values"=>null, "extkey_attcode"=>"parent_id", "target_attcode"=>"name"))); @@ -91,17 +91,25 @@ class menuNode extends DBObject public function GetChildNodesSet($sType = null) { - $oSearchFilter = new DBObjectSearch("menuNode"); - $oSearchFilter->AddCondition('parent_id', $this->GetKey(), '='); - if ($sType != null) + $aParams = array(); + + if ($sType == 'user') { - $oSearchFilter->AddCondition('type', $sType, '='); - if ($sType == 'user') - { - $oSearchFilter->AddCondition('user_id', UserRights::GetUserId(), '='); - } + $sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent AND type = :type AND m.user_id = :user'; + $aParams = array('parent' => $this->GetKey(), 'type' => $sType, 'user' => UserRights::GetUserId()); } - $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true)); + elseif ($sType != null) + { + $sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent AND type = :type'; + $aParams = array('parent' => $this->GetKey(), 'type' => $sType); + } + else + { + $sSelectChilds = 'SELECT menuNode AS m WHERE m.parent_id = :parent'; + $aParams = array('parent' => $this->GetKey()); + } + $oSearchFilter = DBObjectSearch::FromOQL($sSelectChilds); + $oSet = new CMDBObjectSet($oSearchFilter, array('rank' => true), $aParams); return $oSet; } diff --git a/application/ui.linkswidget.class.inc.php b/application/ui.linkswidget.class.inc.php index de602bdd0..5c4bd7d6c 100644 --- a/application/ui.linkswidget.class.inc.php +++ b/application/ui.linkswidget.class.inc.php @@ -21,6 +21,7 @@ class UILinksWidget { $sHTMLValue = ''; $sTargetClass = self::GetTargetClass($this->m_sClass, $this->m_sAttCode); + // #@# todo - add context information, otherwise any value will be authorized for external keys $aAllowedValues = MetaModel::GetAllowedValues_att($this->m_sClass, $this->m_sAttCode, array(), ''); $oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sAttCode); $sExtKeyToRemote = $oAttDef->GetExtKeyToRemote(); @@ -120,6 +121,7 @@ class UILinksWidget */ static public function Autocomplete(web_page $oPage, UserContext $oContext, $sClass, $sAttCode, $sName, $iMaxCount) { + // #@# todo - add context information, otherwise any value will be authorized for external keys $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, array() /* $aArgs */, $sName); if ($aAllowedValues != null) { @@ -154,12 +156,13 @@ class UILinksWidget * This static function is called by the Ajax Page display a set of objects being linked * to the object being created * @param $oPage web_page The ajax page used for the put^put (sent back to the browser - * @param $sClass string The name of the class 'linking class' which is the class of the objects to display - * @param $sAttCode string The name of the attribute is the main object being created + * @param $sClass string The name of the 'linking class' which is the class of the objects to display * @param $sSet JSON serialized set of objects + * @param $sExtKeyToMe Name of the attribute in sClass that is pointing to a given object + * @param $iObjectId The id of the object $sExtKeyToMe is pointing to * @return void */ - static public function RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe) + static public function RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe, $sExtKeyToRemote, $iObjectId) { $aSet = json_decode($sJSONSet, true); // true means hash array instead of object $oSet = CMDBObjectSet::FromScratch($sClass); @@ -182,7 +185,7 @@ class UILinksWidget } $oSet->AddObject($oObj); } - cmdbAbstractObject::DisplaySet($oPage, $oSet, $sExtKeyToMe); + cmdbAbstractObject::DisplaySet($oPage, $oSet, $sExtKeyToMe, true /*menu*/, false /*select*/, $iObjectId, $sExtKeyToRemote); } diff --git a/business/incident.business.php b/business/incident.business.php index 5a130959a..fa275b150 100644 --- a/business/incident.business.php +++ b/business/incident.business.php @@ -55,7 +55,9 @@ class bizIncidentTicket extends cmdbAbstractObject MetaModel::Init_AddAttribute(new AttributeDate("next_update", array("label"=>"Next update", "description"=>"next time the Ticket is expected to be modified", "allowed_values"=>null, "sql"=>"next_update", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributeDate("end_date", array("label"=>"Closed Date", "description"=>"Date when the Ticket was closed", "allowed_values"=>null, "sql"=>"closed_date", "default_value"=>"", "is_null_allowed"=>true, "depends_on"=>array()))); - MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>null, "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array()))); + //MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>null, "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p WHERE p.org_id = :this->customer_id'), "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array('customer_id')))); + //MetaModel::Init_AddAttribute(new AttributeExternalKey("caller_id", array("targetclass"=>"bizPerson", "jointype"=> "", "label"=>"Caller", "description"=>"person that trigger incident", "allowed_values"=>new ValueSetObjects('SELECT bizPerson AS p WHERE p.org_id = 1'), "sql"=>"caller_id", "is_null_allowed"=>false, "depends_on"=>array('customer_id')))); MetaModel::Init_AddAttribute(new AttributeExternalField("caller_mail", array("label"=>"Caller", "description"=>"Person that trigger this incident", "allowed_values"=>null, "extkey_attcode"=> 'caller_id', "target_attcode"=>"email"))); MetaModel::Init_AddAttribute(new AttributeString("impact", array("label"=>"Impact", "description"=>"Impact of the Incident", "allowed_values"=>null, "sql"=>"impact", "default_value"=>"", "is_null_allowed"=>false, "depends_on"=>array()))); diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index d1af378a4..865da0625 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -178,6 +178,13 @@ abstract class AttributeDefinition { return str_replace($sSeparator, $sSepEscape, $sValue); } + + public function GetAllowedValues($aArgs = array(), $sBeginsWith = '') + { + $oValSetDef = $this->GetValuesDef(); + if (!$oValSetDef) return null; + return $oValSetDef->GetValues($aArgs, $sBeginsWith); + } } /** @@ -490,7 +497,10 @@ class AttributeString extends AttributeDBField } public function RealValueToSQLValue($value) { - assert(is_string($value)); + if (!is_string($value)) + { + throw new CoreWarning('Expected the attribute value to be a string', array('found_type' => gettype($value), 'value' => $value, 'class' => $this->GetCode(), 'attribute' => $this->GetHostClass())); + } return $value; } public function SQLValueToRealValue($value) @@ -499,6 +509,29 @@ class AttributeString extends AttributeDBField } } + +/** + * Map a varchar column (size < ?) to an attribute that must never be shown to the user + * + * @package iTopORM + * @author Romain Quetiez + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.itop.com + * @since 1.0 + * @version $itopversion$ + */ +class AttributePassword extends AttributeString +{ + static protected function ListExpectedParams() + { + return parent::ListExpectedParams(); + //return array_merge(parent::ListExpectedParams(), array()); + } + + public function GetEditClass() {return "Password";} + public function GetDBFieldType() {return "VARCHAR(64)";} +} + /** * Map a text column (size > ?) to an attribute * @@ -778,7 +811,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid } // overloaded here so that an ext key always have the answer to - // "what are you possible values?" + // "what are your possible values?" public function GetValuesDef() { $oValSetDef = $this->Get("allowed_values"); @@ -788,7 +821,21 @@ class AttributeExternalKey extends AttributeDBFieldVoid $oValSetDef = new ValueSetObjects($this->GetTargetClass()); } return $oValSetDef; - } + } + + public function GetAllowedValues($aArgs = array(), $sBeginsWith = '') + { + try + { + return parent::GetAllowedValues($aArgs, $sBeginsWith); + } + catch (MissingQueryArgument $e) + { + // Some required arguments could not be found, enlarge to any existing value + $oValSetDef = new ValueSetObjects($this->GetTargetClass()); + return $oValSetDef->GetValues($aArgs, $sBeginsWith); + } + } } /** diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index e30d3a5fa..03020556f 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -16,7 +16,6 @@ /** * Sibusql - value set start * @package iTopORM - * @info zis is private */ define('VS_START', '{'); /** @@ -465,7 +464,7 @@ class DBObjectSearch public function RenderCondition() { - return $this->m_oSearchCondition->Render($this->m_aParams); + return $this->m_oSearchCondition->Render($this->m_aParams, true); } public function serialize() @@ -507,7 +506,15 @@ class DBObjectSearch $sRelCode = $aRelatedTo['relcode']; $iMaxDepth = $aRelatedTo['maxdepth']; - $sValue .= "T:".$oFilter->serialize().":$sRelCode:$iMaxDepth"; + $sValue .= "T:".$oFilter->serialize().":$sRelCode:$iMaxDepth\n"; + } + if (count($this->m_aParams) > 0) + { + foreach($this->m_aParams as $sName => $sArgValue) + { + // G stands for arGument + $sValue .= "G:$sName:$sArgValue\n"; + } } return base64_encode($sValue); } @@ -554,6 +561,11 @@ class DBObjectSearch $sRelCode = $aCondition[2]; $iMaxDepth = $aCondition[3]; $oFilter->AddCondition_RelatedTo($oSubFilter, $sRelCode, $iMaxDepth); + break; + case "G": + $oFilter->m_aParams[$aCondition[1]] = $aCondition[2]; + break; + default: throw new CoreException("invalid filter definition (cannot unserialize the data, clear text = '$sClearText')"); } @@ -600,6 +612,22 @@ class DBObjectSearch public function ToOQL(&$aParams = null) { $bRetrofitParams = (!is_null($aParams)); + if (is_null($aParams)) + { + if (count($this->m_aParams) > 0) + { + $aParams = $this->m_aParams; + } + $bRetrofitParams = false; + } + else + { + if (count($this->m_aParams) > 0) + { + $aParams = array_merge($aParams, $this->m_aParams); + } + $bRetrofitParams = true; + } $sRes = "SELECT ".$this->GetClass().' AS '.$this->GetClassAlias(); $sRes .= $this->ToOQL_Joins(); diff --git a/core/expression.class.inc.php b/core/expression.class.inc.php index 834ac47b7..82b3e61b3 100644 --- a/core/expression.class.inc.php +++ b/core/expression.class.inc.php @@ -11,6 +11,11 @@ * @since 1.0 * @version 1.1.1.1 $ */ + +class MissingQueryArgument extends CoreException +{ +} + abstract class Expression { // recursive translation of identifiers @@ -301,7 +306,7 @@ class VariableExpression extends UnaryExpression // recursive rendering public function Render(&$aArgs = null, $bRetrofitParams = false) { - if (is_null($aArgs) || $bRetrofitParams) + if (is_null($aArgs)) { return ':'.$this->m_sName; } @@ -309,9 +314,14 @@ class VariableExpression extends UnaryExpression { return CMDBSource::Quote($aArgs[$this->m_sName]); } + elseif ($bRetrofitParams) + { + //$aArgs[$this->m_sName] = null; + return ':'.$this->m_sName; + } else { - throw new CoreException('Missing query argument', array('expecting'=>$this->m_sName, 'available'=>$aArgs)); + throw new MissingQueryArgument('Missing query argument', array('expecting'=>$this->m_sName, 'available'=>$aArgs)); } } } diff --git a/core/filterdef.class.inc.php b/core/filterdef.class.inc.php index 371eadbd5..8a2d7d096 100644 --- a/core/filterdef.class.inc.php +++ b/core/filterdef.class.inc.php @@ -209,7 +209,13 @@ class FilterFromAttribute extends FilterDefinition { $oAttDef = $this->Get("refattribute"); return $oAttDef->GetValuesDef(); - } + } + + public function GetAllowedValues($aArgs = array(), $sBeginsWith = '') + { + $oAttDef = $this->Get("refattribute"); + return $oAttDef->GetAllowedValues($aArgs, $sBeginsWith); + } public function GetOperators() { @@ -235,62 +241,4 @@ class FilterFromAttribute extends FilterDefinition } } -/** - * Match against a given column (experimental -to be cleaned up later) - * - * @package iTopORM - * @author Romain Quetiez - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.itop.com - * @since 1.0 - * @version $itopversion$ - */ -class FilterDBValues extends FilterDefinition -{ - static protected function ListExpectedParams() - { - return array_merge(parent::ListExpectedParams(), array("dbfield")); - } - - public function GetType() {return "Values from DB";} - public function GetTypeDesc() {return "Match against the existing values in a field";} - - public function GetLabel() - { - return "enum de valeurs DB"; - } - - public function GetValuesDef() - { - return null; - } - - public function GetOperators() - { - return array( - "IN"=>"in", - ); - } - public function GetLooseOperator() - { - return "IN"; - } - - public function GetFilterSQLExpr($sOpCode, $value) - { - $sFieldName = $this->Get("dbfield"); - if (is_array($value) && !empty($value)) - { - $sValueList = "'".implode("', '", $value)."'"; - return "$sFieldName IN ($sValueList)"; - } - return "1=1"; - } - - public function TemporaryGetSQLCol() - { - return $this->Get("dbfield"); - } -} - ?> diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 5fe13c140..6d24d113e 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -665,19 +665,13 @@ abstract class MetaModel public static function GetAllowedValues_att($sClass, $sAttCode, $aArgs = array(), $sBeginsWith = '') { $oAttDef = self::GetAttributeDef($sClass, $sAttCode); - if (!$oAttDef) return null; - $oValSetDef = $oAttDef->GetValuesDef(); - if (!$oValSetDef) return null; - return $oValSetDef->GetValues($aArgs, $sBeginsWith); + return $oAttDef->GetAllowedValues($aArgs, $sBeginsWith); } public static function GetAllowedValues_flt($sClass, $sFltCode, $aArgs = array(), $sBeginsWith = '') { $oFltDef = self::GetClassFilterDef($sClass, $sFltCode); - if (!$oFltDef) return null; - $oValSetDef = $oFltDef->GetValuesDef(); - if (!$oValSetDef) return null; - return $oValSetDef->GetValues($aArgs, $sBeginsWith); + return $oFltDef->GetAllowedValues($aArgs, $sBeginsWith); } // @@ -820,6 +814,18 @@ abstract class MetaModel self::$m_aFilterDefs[$sClass][$sClassAttCode] = $oClassFlt; self::$m_aFilterOrigins[$sClass][$sClassAttCode] = self::GetRootClass($sClass); } + + // Define defaults values for the standard ZLists + // + foreach (self::$m_aListInfos as $sListCode => $aListConfig) + { + if (!isset(self::$m_aListData[$sClass][$sListCode])) + { + $aAllAttributes = array_keys(self::$m_aAttribDefs[$sClass]); + self::$m_aListData[$sClass][$sListCode] = $aAllAttributes; + //echo "

    $sClass: $sListCode (".count($aAllAttributes)." attributes)

    \n"; + } + } } } diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index 25b546920..0e8cfb21f 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -45,6 +45,8 @@ define('UR_ACTION_APPLICATION_DEFINED', 10000); // Application specific actions abstract class UserRightsAddOnAPI { abstract public function Setup(); // initial installation + abstract public function CreateAdministrator($sAdminUser, $sAdminPwd); // could be used during initial installation + abstract public function Init(); // loads data (possible optimizations) abstract public function CheckCredentials($sLogin, $sPassword); // returns the id of the user or false abstract public function GetUserId($sLogin); // returns the id of the user or false @@ -52,6 +54,7 @@ abstract class UserRightsAddOnAPI abstract public function IsActionAllowed($iUserId, $sClass, $iActionCode, dbObjectSet $oInstances); abstract public function IsStimulusAllowed($iUserId, $sClass, $sStimulusCode, dbObjectSet $oInstances); abstract public function IsActionAllowedOnAttribute($iUserId, $sClass, $sAttCode, $iActionCode, dbObjectSet $oInstances); + abstract public function IsAdministrator($iUserId); } @@ -94,6 +97,11 @@ class UserRights self::$m_iRealUserId = 0; } + public static function GetModuleInstance() + { + return self::$m_oAddOn; + } + // Installation: create the very first user public static function CreateAdministrator($sAdminUser, $sAdminPwd) { @@ -236,6 +244,20 @@ class UserRights return self::$m_oAddOn->IsActionAllowedOnAttribute($iUserId, $sClass, $sAttCode, $iActionCode, $oInstances); } } + + public static function IsAdministrator($iUserId = null) + { + if (!self::CheckLogin()) return false; + + if (is_null($iUserId)) + { + return self::$m_oAddOn->IsAdministrator(self::$m_iUserId); + } + else + { + return self::$m_oAddOn->IsAdministrator($iUserId); + } + } } diff --git a/core/valuesetdef.class.inc.php b/core/valuesetdef.class.inc.php index 2adae3aff..393a06baa 100644 --- a/core/valuesetdef.class.inc.php +++ b/core/valuesetdef.class.inc.php @@ -19,8 +19,6 @@ abstract class ValueSetDefinition { protected $m_bIsLoaded = false; protected $m_aValues = array(); - protected $m_aArgsObj = array(); - protected $m_aArgsApp = array(); // Displayable description that could be computed out of the std usage context @@ -64,15 +62,6 @@ abstract class ValueSetDefinition return $aRet; } - public function ListArgsFromContextApp() - { - return $this->m_aArgsObj; - } - public function ListArgsFromContextObj() - { - return $this->m_aArgsApp; - } - abstract protected function LoadValues($aArgs); } @@ -109,7 +98,7 @@ class ValueSetObjects extends ValueSetDefinition if (empty($this->m_sValueAttCode)) { - $this->m_sValueAttCode = MetaModel::GetNameAttributeCode($oFilter->GetClass()); + $this->m_sValueAttCode = MetaModel::GetNameAttributeCode($oFilter->GetClass()); } $oObjects = new DBObjectSet($oFilter, $this->m_aOrderBy, $aArgs); @@ -127,78 +116,6 @@ class ValueSetObjects extends ValueSetDefinition } -/** - * Set of existing values for an attribute, given a search filter and a relation id - * - * @package iTopORM - * @author Romain Quetiez - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.itop.com - * @since 1.0 - * @version $itopversion$ - */ -class ValueSetRelatedObjects extends ValueSetObjects -{ - public function __construct($sFilterExp, $sRelCode, $sClass, $sValueAttCode = '', $aOrderBy = array()) - { - $sFullFilterExp = "$sClass: RELATED ($sRelCode, 1) TO ($sFilterExp)"; - parent::__construct($sFullFilterExp, $sValueAttCode, $aOrderBy); - } -} - - -/** - * Set oof existing values for an attribute, given a set of objects (AttributeLinkedSet) - * - * @package iTopORM - * @author Romain Quetiez - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.itop.com - * @since 1.0 - * @version $itopversion$ - */ -class ValueSetRelatedObjectsFromLinkedSet extends ValueSetDefinition -{ - protected $m_sLinkedSetAttCode; - protected $m_sRelCode; - protected $m_sValueAttCode; - protected $m_aOrderBy; - - public function __construct($sLinkedSetAttCode, $sRelCode, $sValueAttCode = '', $aOrderBy = array()) - { - $this->m_sLinkedSetAttCode = $sLinkedSetAttCode; - $this->m_sRelCode = $sRelCode; - $this->m_sValueAttCode = $sValueAttCode; - $this->m_aOrderBy = $aOrderBy; - } - - protected function LoadValues($aArgs) - { - $this->m_aValues = array(); - - if (empty($this->m_sValueAttCode)) - { - $this->m_sValueAttCode = MetaModel::GetNameAttributeCode($oFilter->GetClass()); - } - - $oCurrentObject = @$aArgs['*this*']; - if (!is_object($oCurrentObject)) return false; - - $oObjects = $oCurrentObject->Get($this->m_sLinkedSetAttCode); - while ($oObject = $oObjects->Fetch()) - { - $this->m_aValues[$oObject->GetKey()] = $oObject->Get($this->m_sValueAttCode); - } - return true; - } - - public function GetValuesDescription() - { - return 'Objects related ('.$this->m_sRelCode.') to objects linked through '.$this->m_sLinkedSetAttCode; - } -} - - /** * Fixed set values (could be hardcoded in the business model) * diff --git a/js/linkswidget.js b/js/linkswidget.js index 61f63247d..69d890351 100644 --- a/js/linkswidget.js +++ b/js/linkswidget.js @@ -29,7 +29,7 @@ function LinksWidget(id, sLinkedClass, sExtKeyToMe, sExtKeyToRemote, aAttributes { sLinks = JSON.stringify(this.aLinks); $('#'+this.id).val(sLinks); - $('#'+this.id+'_values').load('ajax.render.php?operation=ui.linkswidget.linkedset&sclass='+this.sLinkedClass+'&sextkeytome='+this.sExtKeyToMe, + $('#'+this.id+'_values').load('ajax.render.php?operation=ui.linkswidget.linkedset&sclass='+this.sLinkedClass+'&sextkeytome='+this.sExtKeyToMe+'&sextkeytoremote='+this.sExtKeyToRemote+'&myid='+this.id, {'sset' : sLinks}); } } diff --git a/pages/UniversalSearch.php b/pages/UniversalSearch.php index bb4e15647..a12ab5292 100644 --- a/pages/UniversalSearch.php +++ b/pages/UniversalSearch.php @@ -96,7 +96,7 @@ EOF; $bChildItem = utils::ReadPostedParam('child_item', false); $oMenuNode->Set('label', $sDescription); $oMenuNode->Set('name', $sLabel); - $oMenuNode->Set('icon_path', '/images/std_view.gif'); + $oMenuNode->Set('icon_path', '../images/std_view.gif'); $oMenuNode->Set('template', $sMenuNodeContent); $oMenuNode->Set('hyperlink', 'UI.php'); $oMenuNode->Set('type', 'user'); diff --git a/pages/ajax.render.php b/pages/ajax.render.php index a90059eeb..4461cef6b 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -84,6 +84,8 @@ switch($operation) } foreach($oWizardHelper->GetFieldsForAllowedValues() as $sAttCode) { + // MetaModel::GetAllowedValues_att() => array(id => value) + // Improvement: what if the list is too long? $oWizardHelper->SetAllowedValuesHtml($sAttCode, "Possible values ($sAttCode)"); } $oPage->add($oWizardHelper->ToJSON()); @@ -192,7 +194,9 @@ switch($operation) $sClass = utils::ReadParam('sclass', 'bizContact'); $sJSONSet = stripslashes(utils::ReadParam('sset', '')); $sExtKeyToMe = utils::ReadParam('sextkeytome', ''); - UILinksWidget::RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe); + $sExtKeyToRemote = utils::ReadParam('sextkeytoremote', ''); + $iObjectId = utils::ReadParam('id', -1); + UILinksWidget::RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe, $sExtKeyToRemote, $iObjectId); break; case 'autocomplete': @@ -208,6 +212,7 @@ switch($operation) if ($oThis = MetaModel::GetObject($sClass, $key)) { $aArgs['*this*'] = $oThis; + $aArgs['this'] = $oThis; } } $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs, $sName); diff --git a/pages/index.php b/pages/index.php index 33c4d77c0..f8d93ec62 100644 --- a/pages/index.php +++ b/pages/index.php @@ -87,7 +87,7 @@ function DisplayDetails(web_page $oPage, $sClassName, $sKey) global $oContext; //$oObj = MetaModel::GetObject($sClassName, $sKey); $oObj = $oContext->GetObject($sClassName, $sKey); - $oPage->p("Details of ".get_class($oObj)." - $sKey"); + $oPage->p("Details of ".MetaModel::GetName($sClassName)." - $sKey"); $oObj->DisplayDetails($oPage); @@ -140,7 +140,7 @@ function DisplayChangesLog(web_page $oPage, $sClassName, $sKey) global $oContext; //$oObj = MetaModel::GetObject($sClassName, $sKey); $oObj = $oContext->GetObject($sClassName, $sKey); - $oPage->p("Changes log for ".get_class($oObj)." - $sKey"); + $oPage->p("Changes log for ".MetaModel::GetName($sClassName)." - $sKey"); $oObj->DisplayChangesLog($oPage); @@ -219,7 +219,7 @@ function DisplayEditForm(web_page $oPage, $sClassName, $sKey) $oPage->p("You are not allowed to edit this object."); return; } - $oPage->p("Edition of ".get_class($oObj)." - $sKey\n"); + $oPage->p("Edition of ".MetaModel::GetName($sClassName)." - $sKey\n"); $aDetails = array(); $oPage->add("
    \n"); @@ -332,7 +332,7 @@ function UpdateObject(web_page $oPage, $sClassName, $sKey, $aAttributes) $iChangeId = $oMyChange->DBInsert(); $oObj->DBUpdateTracked($oMyChange); - $oPage->p(get_class($oObj)." updated\n"); + $oPage->p(MetaModel::GetName($sClassName)." updated\n"); } else { @@ -342,13 +342,14 @@ function UpdateObject(web_page $oPage, $sClassName, $sKey, $aAttributes) // By Rom // $oObj->DisplayDetails($oPage); // replaced by... - DisplayDetails($oPage, get_class($oObj), $oObj->GetKey()); + DisplayDetails($oPage, $sClassName, $sKey); $oPage->p("Return to main page"); } function DeleteObject(web_page $oPage, $sClassName, $sKey) { global $oContext; + $sClassLabel = MetaModel::GetName($sClassName); //$oObj = MetaModel::GetObject($sClassName, $sKey); $oObj = $oContext->GetObject($sClassName, $sKey); if ($oObj == null) @@ -356,7 +357,7 @@ function DeleteObject(web_page $oPage, $sClassName, $sKey) $oPage->p("You are not allowed to delete this object."); return; } - $oPage->p("Deletion of $sClassName - $sKey"); + $oPage->p("Deletion of $sClassLabel - $sKey"); if ($oObj->CheckToDelete()) { @@ -368,13 +369,13 @@ function DeleteObject(web_page $oPage, $sClassName, $sKey) $iChangeId = $oMyChange->DBInsert(); $oObj->DBDeleteTracked($oMyChange); - $oPage->p("$sClassName deleted\n"); + $oPage->p("$sClassLabel deleted\n"); } else { $oPage->p("Error: object can not be deleted!\n"); // By Rom - DisplayDetails($oPage, get_class($oObj), $oObj->GetKey()); + DisplayDetails($oPage, $sClassName, $sKey); } $oPage->p("Return to main page"); } @@ -382,7 +383,8 @@ function DeleteObject(web_page $oPage, $sClassName, $sKey) function CreateObject(web_page $oPage, $sClassName, $aAttributes) { $oObj = MetaModel::NewObject($sClassName); - $oPage->p("Creation of ".get_class($oObj)." object."); + $sClassLabel = MetaModel::GetName(get_class($oObj)); + $oPage->p("Creation of $sClassLabel object."); foreach(MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode=>$oAttDef) { @@ -401,7 +403,7 @@ function CreateObject(web_page $oPage, $sClassName, $aAttributes) $iChangeId = $oMyChange->DBInsert(); $oObj->DBInsertTracked($oMyChange); - $oPage->p(get_class($oObj)." created\n"); + $oPage->p($sClassLabel." created\n"); // By Rom // $oObj->DisplayDetails($oPage); @@ -419,6 +421,7 @@ function CreateObject(web_page $oPage, $sClassName, $aAttributes) function AddLinks($oPage, $sClassName, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKeyToPartner, $sFilter) { global $oContext; + $sClassLabel = MetaModel::GetName($sClassName); //$oObj = MetaModel::GetObject($sClassName, $sKey); $oObj = $oContext->GetObject($sClassName, $sKey); if ($oObj == null) @@ -426,7 +429,7 @@ function AddLinks($oPage, $sClassName, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKe $oPage->p("You are not allowed to modify (create links on) this object."); return; } - $oPage->p("Creating links for $sClassName - $sKey"); + $oPage->p("Creating links for $sClassLabel - $sKey"); $oFilter = CMDBSearchFilter::unserialize($sFilter); $oPage->p("Linking to ".$oFilter->__DescribeHTML()); @@ -447,7 +450,7 @@ function AddLinks($oPage, $sClassName, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKe $iChangeId = $oMyChange->DBInsert(); $oNewLink->DBInsertTracked($oMyChange); - $oPage->p(get_class($oNewLink)." created\n"); + $oPage->p(MetaModel::GetName($sLinkClass)." created\n"); } else { @@ -595,19 +598,21 @@ switch($operation) $oPage->add("\n"); foreach( $aTopLevelClasses as $sClassName) { + $sClassLabel = MetaModel::GetName($sClassName); $oPage->add("
    "); if (count(MetaModel::GetSubclasses($sClassName)) > 0) { $sActiveSubclass = ReadParam('subclassname', ''); foreach(MetaModel::GetSubclasses($sClassName) as $sSubclassName) { + $sSubclassLabel = MetaModel::GetName($sSubclassName); //$oSearchFilter = new CMDBSearchFilter($sSubclassName); $oSearchFilter = $oContext->NewFilter($sSubclassName); $oSearchFilter ->AddCondition('org_id', $sCurrentOrganization, '='); $oPage->add("
    \n"); $oPage->add("
    \n"); - $oPage->p("$sSubclassName - ".MetaModel::GetClassDescription($sSubclassName)); + $oPage->p("$sSubclassLabel - ".MetaModel::GetClassDescription($sSubclassName)); $oPage->add("\n"); $oPage->add("\n"); $oPage->add("\n"); @@ -634,7 +639,7 @@ switch($operation) $iMatchesCount = $oSet->Count(); if ($iMatchesCount == 0) { - $oPage->p("No $sSubclassName matches these criteria."); + $oPage->p("No $sSubclassLabel matches these criteria."); $oPage->small_p("(".$oSearchFilter->__DescribeHTML().")"); } else @@ -642,7 +647,7 @@ switch($operation) $oPage->p("$iMatchesCount item(s) found."); cmdbAbstractObject::DisplaySet($oPage, $oSet); } - $oPage->p("Create a new $sSubclassName\n"); + $oPage->p("Create a new $sSubclassLabel\n"); $oPage->add("
    \n"); } } @@ -655,7 +660,7 @@ switch($operation) $oPage->add("
    \n"); $oPage->add("
    \n"); - $oPage->p("$sClassName - ".MetaModel::GetClassDescription($sClassName)); + $oPage->p("$sClassLabel - ".MetaModel::GetClassDescription($sClassName)); $oPage->add("\n"); $oPage->add("\n"); $oPage->add("\n"); @@ -681,7 +686,7 @@ switch($operation) $iMatchesCount = $oSet->Count(); if ($iMatchesCount == 0) { - $oPage->p("No $sClassName matches these criteria."); + $oPage->p("No $sClassLabel matches these criteria."); $oPage->small_p("(".$oSearchFilter->__DescribeHTML().")"); } else @@ -690,7 +695,7 @@ switch($operation) cmdbAbstractObject::DisplaySet($oPage, $oSet); $oPage->small_p("(".$oSearchFilter->__DescribeHTML().")"); } - $oPage->p("Create a new $sClassName\n"); + $oPage->p("Create a new $sClassLabel\n"); $oPage->add("
    \n"); $oPage->add("
    \n"); } diff --git a/pages/schema.php b/pages/schema.php index f3a4ba52e..e985d1908 100644 --- a/pages/schema.php +++ b/pages/schema.php @@ -333,8 +333,8 @@ function DisplayClassDetails($oPage, $sClass) { $sValue = $oAttDef->GetDescription(); } - $sType = $oAttDef->GetType().' ('.$oAttDef->GetTypeDesc().')'; - $sOrigin = MetaModel::GetAttributeOrigin($sClass, $sAttCode); + $sType = $oAttDef->GetType().' ('.$oAttDef->GetTypeDesc().')'; + $sOrigin = MetaModel::GetAttributeOrigin($sClass, $sAttCode); $sAllowedValues = ""; $oAllowedValuesDef = $oAttDef->GetValuesDef(); $sMoreInfo = ""; diff --git a/pages/usermanagement_userstatus.php b/pages/usermanagement_userstatus.php index 8b243ff2a..4468a0cca 100644 --- a/pages/usermanagement_userstatus.php +++ b/pages/usermanagement_userstatus.php @@ -263,6 +263,23 @@ if ($iUser == -1) } else { + $oPage->p('

    How is it computing the user rights?

    '); + + $oPage->p('

    1st, find the profiles that apply

    '); + $oPage->p('

    Project the current object in every existing dimension

    '); + $oPage->p('

    Project the observed profile in every existing dimension (might depend on the user)

    '); + $oPage->p('

    If an overlap is found in any dimension, then the profile applies

    '); + + $oPage->p('

    2nd, interpret the profiles

    '); + $oPage->p('

    Note: granting rights for specific attributes is not fully implemented. It is still not taking into account the inheritance of rights AND the UI will not take that information into account!

    '); + $oPage->p('

    Actions: looks into URP_ActionGrant for a permission (yes or no) and goes up into the class hierarchy until an answer is found, defaults to no

    '); + $oPage->p('

    Stimuli: looks into URP_StimulusGrant for a permission (yes or no), defaults to no

    '); + + + $oPage->p('

    3rd, keep the most permissive one

    '); + $oPage->p('

    If one profile says YES, then the answer is YES

    '); + + $oUser = MetaModel::GetObject('URP_Users', $iUser); $oPage->p('

    Projections for user '.$oUser->GetName().'

    '); diff --git a/setup/data/30.profiles.xml b/setup/data/30.profiles.xml new file mode 100644 index 000000000..85c32a027 --- /dev/null +++ b/setup/data/30.profiles.xml @@ -0,0 +1,7 @@ + + + +Delivery Manager France +Persons in charge of the operations for French customers + + diff --git a/setup/data/31.profileprojection.xml b/setup/data/31.profileprojection.xml new file mode 100644 index 000000000..4a16290fe --- /dev/null +++ b/setup/data/31.profileprojection.xml @@ -0,0 +1,15 @@ + + + +1 +100 +1;2 + + + +2 +100 +<any> + + + diff --git a/setup/data/32.actiongrant.xml b/setup/data/32.actiongrant.xml new file mode 100644 index 000000000..6d1d83633 --- /dev/null +++ b/setup/data/32.actiongrant.xml @@ -0,0 +1,1659 @@ + + + +100 +bizOrganization +yes +read + + +100 +bizOrganization +yes +modify + + +100 +bizOrganization +yes +delete + + +100 +bizOrganization +yes +bulk read + + +100 +bizOrganization +yes +bulk modify + + +100 +bizOrganization +yes +bulk delete + + +100 +logRealObject +yes +read + + +100 +logRealObject +yes +modify + + +100 +logRealObject +yes +delete + + +100 +logRealObject +yes +bulk read + + +100 +logRealObject +yes +bulk modify + + +100 +logRealObject +yes +bulk delete + + +100 +bizContact +yes +read + + +100 +bizContact +yes +modify + + +100 +bizContact +yes +delete + + +100 +bizContact +yes +bulk read + + +100 +bizContact +yes +bulk modify + + +100 +bizContact +yes +bulk delete + + +100 +bizPerson +yes +read + + +100 +bizPerson +yes +modify + + +100 +bizPerson +yes +delete + + +100 +bizPerson +yes +bulk read + + +100 +bizPerson +yes +bulk modify + + +100 +bizPerson +yes +bulk delete + + +100 +bizTeam +yes +read + + +100 +bizTeam +yes +modify + + +100 +bizTeam +yes +delete + + +100 +bizTeam +yes +bulk read + + +100 +bizTeam +yes +bulk modify + + +100 +bizTeam +yes +bulk delete + + +100 +bizDocument +yes +read + + +100 +bizDocument +yes +modify + + +100 +bizDocument +yes +delete + + +100 +bizDocument +yes +bulk read + + +100 +bizDocument +yes +bulk modify + + +100 +bizDocument +yes +bulk delete + + +100 +bizDocVersion +yes +read + + +100 +bizDocVersion +yes +modify + + +100 +bizDocVersion +yes +delete + + +100 +bizDocVersion +yes +bulk read + + +100 +bizDocVersion +yes +bulk modify + + +100 +bizDocVersion +yes +bulk delete + + +100 +lnkDocumentRealObject +yes +read + + +100 +lnkDocumentRealObject +yes +modify + + +100 +lnkDocumentRealObject +yes +delete + + +100 +lnkDocumentRealObject +yes +bulk read + + +100 +lnkDocumentRealObject +yes +bulk modify + + +100 +lnkDocumentRealObject +yes +bulk delete + + +100 +lnkContactRealObject +yes +read + + +100 +lnkContactRealObject +yes +modify + + +100 +lnkContactRealObject +yes +delete + + +100 +lnkContactRealObject +yes +bulk read + + +100 +lnkContactRealObject +yes +bulk modify + + +100 +lnkContactRealObject +yes +bulk delete + + +100 +logInfra +yes +read + + +100 +logInfra +yes +modify + + +100 +logInfra +yes +delete + + +100 +logInfra +yes +bulk read + + +100 +logInfra +yes +bulk modify + + +100 +logInfra +yes +bulk delete + + +100 +bizLocation +yes +read + + +100 +bizLocation +yes +modify + + +100 +bizLocation +yes +delete + + +100 +bizLocation +yes +bulk read + + +100 +bizLocation +yes +bulk modify + + +100 +bizLocation +yes +bulk delete + + +100 +bizCircuit +yes +read + + +100 +bizCircuit +yes +modify + + +100 +bizCircuit +yes +delete + + +100 +bizCircuit +yes +bulk read + + +100 +bizCircuit +yes +bulk modify + + +100 +bizCircuit +yes +bulk delete + + +100 +bizInterface +yes +read + + +100 +bizInterface +yes +modify + + +100 +bizInterface +yes +delete + + +100 +bizInterface +yes +bulk read + + +100 +bizInterface +yes +bulk modify + + +100 +bizInterface +yes +bulk delete + + +100 +lnkInterfaces +yes +read + + +100 +lnkInterfaces +yes +modify + + +100 +lnkInterfaces +yes +delete + + +100 +lnkInterfaces +yes +bulk read + + +100 +lnkInterfaces +yes +bulk modify + + +100 +lnkInterfaces +yes +bulk delete + + +100 +bizDevice +yes +read + + +100 +bizDevice +yes +modify + + +100 +bizDevice +yes +delete + + +100 +bizDevice +yes +bulk read + + +100 +bizDevice +yes +bulk modify + + +100 +bizDevice +yes +bulk delete + + +100 +bizPC +yes +read + + +100 +bizPC +yes +modify + + +100 +bizPC +yes +delete + + +100 +bizPC +yes +bulk read + + +100 +bizPC +yes +bulk modify + + +100 +bizPC +yes +bulk delete + + +100 +bizServer +yes +read + + +100 +bizServer +yes +modify + + +100 +bizServer +yes +delete + + +100 +bizServer +yes +bulk read + + +100 +bizServer +yes +bulk modify + + +100 +bizServer +yes +bulk delete + + +100 +bizNetworkDevice +yes +read + + +100 +bizNetworkDevice +yes +modify + + +100 +bizNetworkDevice +yes +delete + + +100 +bizNetworkDevice +yes +bulk read + + +100 +bizNetworkDevice +yes +bulk modify + + +100 +bizNetworkDevice +yes +bulk delete + + +100 +bizInfraGroup +yes +read + + +100 +bizInfraGroup +yes +modify + + +100 +bizInfraGroup +yes +delete + + +100 +bizInfraGroup +yes +bulk read + + +100 +bizInfraGroup +yes +bulk modify + + +100 +bizInfraGroup +yes +bulk delete + + +100 +bizApplication +yes +read + + +100 +bizApplication +yes +modify + + +100 +bizApplication +yes +delete + + +100 +bizApplication +yes +bulk read + + +100 +bizApplication +yes +bulk modify + + +100 +bizApplication +yes +bulk delete + + +100 +lnkInfraGrouping +yes +read + + +100 +lnkInfraGrouping +yes +modify + + +100 +lnkInfraGrouping +yes +delete + + +100 +lnkInfraGrouping +yes +bulk read + + +100 +lnkInfraGrouping +yes +bulk modify + + +100 +lnkInfraGrouping +yes +bulk delete + + +100 +lnkClientServer +yes +read + + +100 +lnkClientServer +yes +modify + + +100 +lnkClientServer +yes +delete + + +100 +lnkClientServer +yes +bulk read + + +100 +lnkClientServer +yes +bulk modify + + +100 +lnkClientServer +yes +bulk delete + + +100 +bizPatch +yes +read + + +100 +bizPatch +yes +modify + + +100 +bizPatch +yes +delete + + +100 +bizPatch +yes +bulk read + + +100 +bizPatch +yes +bulk modify + + +100 +bizPatch +yes +bulk delete + + +100 +bizIncidentTicket +yes +read + + +100 +bizIncidentTicket +no +modify + + +100 +bizIncidentTicket +no +delete + + +100 +bizIncidentTicket +yes +bulk read + + +100 +bizIncidentTicket +no +bulk modify + + +100 +bizIncidentTicket +no +bulk delete + + +100 +lnkRelatedTicket +yes +read + + +100 +lnkRelatedTicket +yes +modify + + +100 +lnkRelatedTicket +yes +delete + + +100 +lnkRelatedTicket +yes +bulk read + + +100 +lnkRelatedTicket +yes +bulk modify + + +100 +lnkRelatedTicket +yes +bulk delete + + +100 +lnkInfraTicket +yes +read + + +100 +lnkInfraTicket +yes +modify + + +100 +lnkInfraTicket +yes +delete + + +100 +lnkInfraTicket +yes +bulk read + + +100 +lnkInfraTicket +yes +bulk modify + + +100 +lnkInfraTicket +yes +bulk delete + + +100 +lnkContactTicket +yes +read + + +100 +lnkContactTicket +yes +modify + + +100 +lnkContactTicket +yes +delete + + +100 +lnkContactTicket +yes +bulk read + + +100 +lnkContactTicket +yes +bulk modify + + +100 +lnkContactTicket +yes +bulk delete + + +100 +bizWorkgroup +yes +read + + +100 +bizWorkgroup +yes +modify + + +100 +bizWorkgroup +yes +delete + + +100 +bizWorkgroup +yes +bulk read + + +100 +bizWorkgroup +yes +bulk modify + + +100 +bizWorkgroup +yes +bulk delete + + +100 +bizContract +yes +read + + +100 +bizContract +yes +modify + + +100 +bizContract +yes +delete + + +100 +bizContract +yes +bulk read + + +100 +bizContract +yes +bulk modify + + +100 +bizContract +yes +bulk delete + + +100 +lnkInfraContract +yes +read + + +100 +lnkInfraContract +yes +modify + + +100 +lnkInfraContract +yes +delete + + +100 +lnkInfraContract +yes +bulk read + + +100 +lnkInfraContract +yes +bulk modify + + +100 +lnkInfraContract +yes +bulk delete + + +100 +lnkContactContract +yes +read + + +100 +lnkContactContract +yes +modify + + +100 +lnkContactContract +yes +delete + + +100 +lnkContactContract +yes +bulk read + + +100 +lnkContactContract +yes +bulk modify + + +100 +lnkContactContract +yes +bulk delete + + +100 +lnkDocumentContract +yes +read + + +100 +lnkDocumentContract +yes +modify + + +100 +lnkDocumentContract +yes +delete + + +100 +lnkDocumentContract +yes +bulk read + + +100 +lnkDocumentContract +yes +bulk modify + + +100 +lnkDocumentContract +yes +bulk delete + + +100 +bizChangeTicket +yes +read + + +100 +bizChangeTicket +no +modify + + +100 +bizChangeTicket +no +delete + + +100 +bizChangeTicket +yes +bulk read + + +100 +bizChangeTicket +no +bulk modify + + +100 +bizChangeTicket +no +bulk delete + + +100 +lnkInfraChangeTicket +yes +read + + +100 +lnkInfraChangeTicket +yes +modify + + +100 +lnkInfraChangeTicket +yes +delete + + +100 +lnkInfraChangeTicket +yes +bulk read + + +100 +lnkInfraChangeTicket +yes +bulk modify + + +100 +lnkInfraChangeTicket +yes +bulk delete + + +100 +lnkContactChange +yes +read + + +100 +lnkContactChange +yes +modify + + +100 +lnkContactChange +yes +delete + + +100 +lnkContactChange +yes +bulk read + + +100 +lnkContactChange +yes +bulk modify + + +100 +lnkContactChange +yes +bulk delete + + +100 +bizKnownError +yes +read + + +100 +bizKnownError +yes +modify + + +100 +bizKnownError +yes +delete + + +100 +bizKnownError +yes +bulk read + + +100 +bizKnownError +yes +bulk modify + + +100 +bizKnownError +yes +bulk delete + + +100 +lnkInfraError +yes +read + + +100 +lnkInfraError +yes +modify + + +100 +lnkInfraError +yes +delete + + +100 +lnkInfraError +yes +bulk read + + +100 +lnkInfraError +yes +bulk modify + + +100 +lnkInfraError +yes +bulk delete + + +100 +lnkDocumentError +yes +read + + +100 +lnkDocumentError +yes +modify + + +100 +lnkDocumentError +yes +delete + + +100 +lnkDocumentError +yes +bulk read + + +100 +lnkDocumentError +yes +bulk modify + + +100 +lnkDocumentError +yes +bulk delete + + +100 +AuditCategory +yes +read + + +100 +AuditCategory +yes +modify + + +100 +AuditCategory +yes +delete + + +100 +AuditCategory +yes +bulk read + + +100 +AuditCategory +yes +bulk modify + + +100 +AuditCategory +yes +bulk delete + + +100 +AuditRule +yes +read + + +100 +AuditRule +yes +modify + + +100 +AuditRule +yes +delete + + +100 +AuditRule +yes +bulk read + + +100 +AuditRule +yes +bulk modify + + +100 +AuditRule +yes +bulk delete + + +100 +menuNode +yes +read + + +100 +menuNode +yes +modify + + +100 +menuNode +yes +delete + + +100 +menuNode +yes +bulk read + + +100 +menuNode +yes +bulk modify + + +100 +menuNode +yes +bulk delete + + +100 +CMDBChange +yes +read + + +100 +CMDBChange +yes +modify + + +100 +CMDBChange +yes +delete + + +100 +CMDBChange +yes +bulk read + + +100 +CMDBChange +yes +bulk modify + + +100 +CMDBChange +yes +bulk delete + + +100 +CMDBChangeOp +yes +read + + +100 +CMDBChangeOp +yes +modify + + +100 +CMDBChangeOp +yes +delete + + +100 +CMDBChangeOp +yes +bulk read + + +100 +CMDBChangeOp +yes +bulk modify + + +100 +CMDBChangeOp +yes +bulk delete + + +100 +CMDBChangeOpCreate +yes +read + + +100 +CMDBChangeOpCreate +yes +modify + + +100 +CMDBChangeOpCreate +yes +delete + + +100 +CMDBChangeOpCreate +yes +bulk read + + +100 +CMDBChangeOpCreate +yes +bulk modify + + +100 +CMDBChangeOpCreate +yes +bulk delete + + +100 +CMDBChangeOpDelete +yes +read + + +100 +CMDBChangeOpDelete +yes +modify + + +100 +CMDBChangeOpDelete +yes +delete + + +100 +CMDBChangeOpDelete +yes +bulk read + + +100 +CMDBChangeOpDelete +yes +bulk modify + + +100 +CMDBChangeOpDelete +yes +bulk delete + + +100 +CMDBChangeOpSetAttribute +yes +read + + +100 +CMDBChangeOpSetAttribute +yes +modify + + +100 +CMDBChangeOpSetAttribute +yes +delete + + +100 +CMDBChangeOpSetAttribute +yes +bulk read + + +100 +CMDBChangeOpSetAttribute +yes +bulk modify + + +100 +CMDBChangeOpSetAttribute +yes +bulk delete + + diff --git a/setup/data/33.attributegrant.xml b/setup/data/33.attributegrant.xml new file mode 100644 index 000000000..cf1461167 --- /dev/null +++ b/setup/data/33.attributegrant.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/setup/data/34.stimulusgrant.xml b/setup/data/34.stimulusgrant.xml new file mode 100644 index 000000000..47e7e7ecd --- /dev/null +++ b/setup/data/34.stimulusgrant.xml @@ -0,0 +1,189 @@ + + + +100 +bizServer +no +ev_store + + +100 +bizServer +no +ev_ship + + +100 +bizServer +no +ev_plug + + +100 +bizServer +no +ev_configuration_finished + + +100 +bizServer +no +ev_val_failed + + +100 +bizServer +no +ev_mtp + + +100 +bizServer +no +ev_start_change + + +100 +bizServer +no +ev_end_change + + +100 +bizServer +no +ev_decommission + + +100 +bizServer +no +ev_obsolete + + +100 +bizServer +no +ev_recycle + + +100 +bizIncidentTicket +no +ev_assign + + +100 +bizIncidentTicket +no +ev_reassign + + +100 +bizIncidentTicket +no +ev_start_working + + +100 +bizIncidentTicket +no +ev_close + + +100 +bizContract +no +ev_freeze_version + + +100 +bizContract +no +ev_sign + + +100 +bizContract +no +ev_begin + + +100 +bizContract +no +ev_notice + + +100 +bizContract +no +ev_terminate + + +100 +bizContract +no +ev_elapsed + + +100 +bizChangeTicket +yes +ev_validate + + +100 +bizChangeTicket +yes +ev_reject + + +100 +bizChangeTicket +no +ev_reopen + + +100 +bizChangeTicket +no +ev_plan + + +100 +bizChangeTicket +yes +ev_approve + + +100 +bizChangeTicket +no +ev_replan + + +100 +bizChangeTicket +yes +ev_notapprove + + +100 +bizChangeTicket +no +ev_implement + + +100 +bizChangeTicket +no +ev_monitor + + +100 +bizChangeTicket +yes +ev_finish + + diff --git a/setup/data/export.cmd b/setup/data/export.cmd index d7200a315..5e54a4dec 100644 --- a/setup/data/export.cmd +++ b/setup/data/export.cmd @@ -1,6 +1,8 @@ SET WEBROOT=http://localhost:81 -SET USER=Erwan -SET PWD=Taloc +SET EXPORT=%WEBROOT%/webservices/export.php + +SET USER=admin +SET PWD=admin REM The order (numbering) of the files is important since REM it dictates the order to import them back diff --git a/setup/data/structure/1.menus.xml b/setup/data/structure/1.menus.xml index 756cfd4ba..cfea4a792 100644 --- a/setup/data/structure/1.menus.xml +++ b/setup/data/structure/1.menus.xml @@ -1,25 +1,25 @@ - -0 -Admin Tools - + +Tools + UI.php + -7 application +7 +0 +0 - -5 + All Applications UI.php + -999 application +999 +14 +0 - -5 + All Circuits UI.php + -999 application +999 +14 +0 - -64 + All Contracts ./UI.php + -2 application +2 +31 +0 - -5 + All Interfaces UI.php + -999 application +999 +14 +0 - -5 + All Network devices UI.php + -999 application +999 +14 +0 - -5 + All Patches UI.php + -999 application +999 +14 +0 - -5 + All PCs UI.php + -999 application +999 +14 +0 - -5 + All Servers UI.php + -999 application +999 +14 +0 - -1 + Audit ./audit.php + -4 application +4 +15 +0 - -0 + Change Management ./UI.php + -4 application +4 +0 +0 - -66 + Closed Changes UI.php + -2 application +2 +11 +0 - -61 + Closed Incident ./UI.php + -2 application +2 +22 +0 - -1 + Configuration Items UI.php + -2 application +2 +15 +0 - -0 + Configuration Management UI.php + -2 application +2 +0 +0 - -1 + Contacts UI.php -