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.

SVN:trunk[1553]
This commit is contained in:
Denis Flaven
2011-09-01 14:06:51 +00:00
parent b3121eebae
commit b33989ec62
4 changed files with 31 additions and 3 deletions

View File

@@ -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');

View File

@@ -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

View File

@@ -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();

View File

@@ -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);