Browse Source

Added the ability to specify programmatically the scope for "favorite organizations". Note the the end-user can still restrict this list even further using the "Preferences" page.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1553 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 13 năm trước cách đây
mục cha
commit
b79d887b27

+ 5 - 2
application/itopwebpage.class.inc.php

@@ -460,11 +460,14 @@ EOF
 		$oSet = null;
 		if (MetaModel::IsValidClass('Organization'))
 		{
-			// Display the list of favorite organizations... but keeping in mind what is the real number of organizations
+			// Display the list of *favorite* organizations... but keeping in mind what is the real number of organizations
 			$aFavoriteOrgs = appUserPreferences::GetPref('favorite_orgs', null);
 			$oSearchFilter = new DBObjectSearch('Organization');
 			$oSet = new CMDBObjectSet($oSearchFilter);
-			$iCount = $oSet->Count(); // real number of visible orgs
+			$iCount = $oSet->Count(); // total number of existing Orgs
+			
+			// Now get the list of Orgs to be displayed in the menu
+			$oSearchFilter = DBObjectSearch::FromOQL(ApplicationMenu::GetFavoriteSiloQuery());
 			if (!empty($aFavoriteOrgs))
 			{
 				$oSearchFilter->AddCondition('id', $aFavoriteOrgs, 'IN');

+ 21 - 0
application/menunode.class.inc.php

@@ -61,6 +61,27 @@ class ApplicationMenu
 {
 	static $aRootMenus = array();
 	static $aMenusIndex = array();
+	static $sFavoriteSiloQuery = 'SELECT Organization';
+	
+	/**
+	 * Set the query used to limit the list of displayed organizations in the drop-down menu
+	 * @param $sOQL string The OQL query returning a list of Organization objects
+	 * @return none
+	 */
+	static public function SetFavoriteSiloQuery($sOQL)
+	{
+		self::$sFavoriteSiloQuery = $sOQL;
+	}
+	
+	/**
+	 * Get the query used to limit the list of displayed organizations in the drop-down menu
+	 * @return string The OQL query returning a list of Organization objects
+	 */
+	static public function GetFavoriteSiloQuery()
+	{
+		return self::$sFavoriteSiloQuery;
+	}
+	
 	
 	/**
 	 * Main function to add a menu entry into the application, can be called during the definition

+ 4 - 0
modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php

@@ -1607,6 +1607,10 @@ class lnkProcessToSolution extends cmdbAbstractObject
 // implement this dirty workaround that makes it...
 require_once(APPROOT.'modules/itop-welcome-itil/model.itop-welcome-itil.php');
 
+// Starting with iTop 1.2 you can restrict the list of organizations displayed in the drop-down list
+// by specifying a query as shown below. Note that this is NOT a security settings, since the
+// choice 'All Organizations' will always be available in the menu
+ApplicationMenu::SetFavoriteSiloQuery('SELECT Organization');
 
 $oAdminMenu = new MenuGroup('DataAdministration', 70 /* fRank */, 'Organization', UR_ACTION_MODIFY, UR_ALLOWED_YES|UR_ALLOWED_DEPENDS);
 $iAdminGroup = $oAdminMenu->GetIndex();

+ 1 - 1
pages/preferences.php

@@ -37,7 +37,7 @@ function DisplayPreferences($oP)
 	$oAppContext = new ApplicationContext();
 
 	// Favorite organizations: the organizations listed in the drop-down menu
-	$sOQL = 'SELECT Organization';
+	$sOQL = ApplicationMenu::GetFavoriteSiloQuery();
 	$oFilter = DBObjectSearch::FromOQL($sOQL);
 	$oBlock = new DisplayBlock($oFilter, 'list', false);