mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
Enhancement: added the capability to filter (based on user's defined preferences the list of organizations displayed in the drop-down menu)
SVN:trunk[1423]
This commit is contained in:
@@ -443,11 +443,19 @@ EOF
|
||||
{
|
||||
// List of visible Organizations
|
||||
$iCount = 0;
|
||||
$oSet = null;
|
||||
if (MetaModel::IsValidClass('Organization'))
|
||||
{
|
||||
// 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();
|
||||
$iCount = $oSet->Count(); // real number of visible orgs
|
||||
if (!empty($aFavoriteOrgs))
|
||||
{
|
||||
$oSearchFilter->AddCondition('id', $aFavoriteOrgs, 'IN');
|
||||
}
|
||||
$oSet = new CMDBObjectSet($oSearchFilter); // List of favorite orgs
|
||||
}
|
||||
switch($iCount)
|
||||
{
|
||||
@@ -488,9 +496,9 @@ EOF
|
||||
}
|
||||
$sHtml .= '</select>';
|
||||
*/
|
||||
$oAllowedValues = new DBObjectSet(DBObjectSearch::FromOQL('SELECT Organization'));
|
||||
$sFavoriteOrgs = '';
|
||||
$oWidget = new UIExtKeyWidget('Organization', 'org_id');
|
||||
$sHtml .= $oWidget->Display($this, 50, false, '', $oAllowedValues, $iCurrentOrganization, 'org_id', false, 'c[org_id]', '', array('iFieldSize' => 20, 'sDefaultValue' => Dict::S('UI:AllOrganizations')), $bSearchMode = true);
|
||||
$sHtml .= $oWidget->Display($this, 50, false, '', $oSet, $iCurrentOrganization, 'org_id', false, 'c[org_id]', '', array('iFieldSize' => 20, 'sDefaultValue' => Dict::S('UI:AllOrganizations')), $bSearchMode = true);
|
||||
$this->add_ready_script('$("#org_id").bind("extkeychange", function() { $("#SiloSelection form").submit(); } )');
|
||||
$this->add_ready_script("$('#label_org_id').click( function() { $(this).val(''); $('#org_id').val(''); return true; } );\n");
|
||||
// Add other dimensions/context information to this form
|
||||
@@ -672,6 +680,7 @@ EOF
|
||||
}
|
||||
$sLogOffMenu = "<span id=\"logOffBtn\"><ul><li><img src=\"../images/onOffBtn.png\"><ul>";
|
||||
$sLogOffMenu .= "<li><span>$sLogonMessage</span></li>\n";
|
||||
$sLogOffMenu .= "<li><a href=\"".utils::GetAbsoluteUrlAppRoot()."pages/preferences.php\">".Dict::S('UI:Preferences')."</a></li>\n";
|
||||
|
||||
if (utils::CanLogOff())
|
||||
{
|
||||
|
||||
@@ -921,5 +921,9 @@ When associated with a trigger, each action is given an "order" number, specifyi
|
||||
'UI:Pagination:PagesLabel' => 'Pages:',
|
||||
'UI:Pagination:All' => 'All',
|
||||
'UI:HierarchyOf_Class' => 'Hierarchy of %1$s',
|
||||
'UI:Preferences' => 'Preferences...',
|
||||
'UI:FavoriteOrganizations' => 'My Favorite Organizations',
|
||||
'UI:FavoriteOrganizations+' => 'Check in the list below the organizations that you want to see in the drop-down menu for a quick access. '.
|
||||
'Note that this is not a security setting, objects from any organization are still visible and can be accessed by selecting "All Organizations" in the drop-down list.',
|
||||
));
|
||||
?>
|
||||
|
||||
@@ -771,5 +771,9 @@ Lors de l\'association à un déclencheur, on attribue à chaque action un numé
|
||||
'UI:Pagination:PagesLabel' => 'Pages:',
|
||||
'UI:Pagination:All' => 'Tous',
|
||||
'UI:HierarchyOf_Class' => 'Hiérarchie de type %1$s',
|
||||
'UI:Preferences' => 'Preferences...',
|
||||
'UI:FavoriteOrganizations' => 'Mes Organisations Favorites',
|
||||
'UI:FavoriteOrganizations+' => 'Cochez dans la liste ci-dessous les organisations que vous voulez voir listées dans le menu principal. '.
|
||||
'Ceci n\'est pas un réglage de sécurité. Les objets de toutes les organisations sont toujours visibles en choisissant "Toutes les Organisations" dans le menu.',
|
||||
));
|
||||
?>
|
||||
|
||||
BIN
images/preferences.png
Normal file
BIN
images/preferences.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
186
pages/preferences.php
Normal file
186
pages/preferences.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
// Copyright (C) 2010 Combodo SARL
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; version 3 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
/**
|
||||
* User preferences page
|
||||
* Displays / edit some user preferences
|
||||
*
|
||||
* @author Erwan Taloc <erwan.taloc@combodo.com>
|
||||
* @author Romain Quetiez <romain.quetiez@combodo.com>
|
||||
* @author Denis Flaven <denis.flaven@combodo.com>
|
||||
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
|
||||
*/
|
||||
require_once('../approot.inc.php');
|
||||
require_once(APPROOT.'/application/application.inc.php');
|
||||
require_once(APPROOT.'/application/itopwebpage.class.inc.php');
|
||||
require_once(APPROOT.'/application/startup.inc.php');
|
||||
|
||||
/**
|
||||
* Displays the user's changeable preferences
|
||||
* @param $oP WebPage The web page used for the output
|
||||
*/
|
||||
function DisplayPreferences($oP)
|
||||
{
|
||||
$oAppContext = new ApplicationContext();
|
||||
|
||||
// Favorite organizations: the organizations listed in the drop-down menu
|
||||
$sOQL = 'SELECT Organization';
|
||||
$oFilter = DBObjectSearch::FromOQL($sOQL);
|
||||
$oBlock = new DisplayBlock($oFilter, 'list', false);
|
||||
|
||||
$oP->add('<div class="page_header"><h1><img style="vertical-align:middle" src="../images/preferences.png"/> '.Dict::S('UI:Preferences')."</h1></div>\n");
|
||||
$oP->add('<div id="user_prefs" style="max-width:800px; min-width:400px;">');
|
||||
$oP->add('<fieldset><legend>'.Dict::S('UI:FavoriteOrganizations').'</legend>');
|
||||
$oP->p(Dict::S('UI:FavoriteOrganizations+'));
|
||||
$oP->add('<form method="post">');
|
||||
$oBlock->Display($oP, 1, array('menu' => false, 'selection_mode' => true, 'selection_type' => 'multiple', 'cssCount'=> '.selectedCount'));
|
||||
$oP->add($oAppContext->GetForForm());
|
||||
$oP->add('<input type="hidden" name="operation" value="apply"/>');
|
||||
$oP->add('</fieldset>');
|
||||
$sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php';
|
||||
$oP->add('<p><input type="button" onClick="window.location.href=\''.$sURL.'\'" value="'.Dict::S('UI:Button:Cancel').'"/>');
|
||||
$oP->add(' ');
|
||||
$oP->add('<input type="submit" value="'.Dict::S('UI:Button:Apply').'"/></p>');
|
||||
$oP->add('</form>');
|
||||
$oP->add('</div>');
|
||||
|
||||
$aFavoriteOrgs = appUserPreferences::GetPref('favorite_orgs', null);
|
||||
if ($aFavoriteOrgs == null)
|
||||
{
|
||||
// All checked
|
||||
$oP->add_ready_script(
|
||||
<<<EOF
|
||||
CheckAll('#user_prefs .listResults :checkbox:not(:disabled)', true);
|
||||
EOF
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sChecked = implode('","', $aFavoriteOrgs);
|
||||
$oP->add_ready_script(
|
||||
<<<EOF
|
||||
$('#user_prefs form :checkbox[name^=selectObject]').each( function()
|
||||
{
|
||||
var aChecked = ["$sChecked"];
|
||||
if ($.inArray($(this).val(), aChecked) > -1)
|
||||
{
|
||||
$(this).attr('checked', true);
|
||||
$(this).trigger('change');
|
||||
}
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Main program
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
|
||||
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
|
||||
|
||||
$iStep = utils::ReadParam('step', 1);
|
||||
|
||||
$oPage = new iTopWebPage(Dict::S('UI:Preferences'));
|
||||
|
||||
$sOperation = utils::ReadParam('operation', '');
|
||||
|
||||
try
|
||||
{
|
||||
switch($sOperation)
|
||||
{
|
||||
case 'apply':
|
||||
$oFilter = DBObjectSearch::FromOQL('SELECT Organization');
|
||||
$sSelectionMode = utils::ReadParam('selectionMode', '');
|
||||
$aExceptions = utils::ReadParam('storedSelection', array());
|
||||
if (($sSelectionMode == 'negative') && (count($aExceptions) == 0))
|
||||
{
|
||||
// All Orgs selected
|
||||
appUserPreferences::SetPref('favorite_orgs', null);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Some organizations selected... store them
|
||||
$aSelectOrgs = utils::ReadMultipleSelection($oFilter);
|
||||
appUserPreferences::SetPref('favorite_orgs', $aSelectOrgs);
|
||||
}
|
||||
DisplayPreferences($oPage);
|
||||
break;
|
||||
|
||||
case 'display':
|
||||
default:
|
||||
DisplayPreferences($oPage);
|
||||
}
|
||||
$oPage->output();
|
||||
}
|
||||
catch(CoreException $e)
|
||||
{
|
||||
require_once(APPROOT.'/setup/setuppage.class.inc.php');
|
||||
$oP = new SetupWebPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
$oP->error(Dict::Format('UI:Error_Details', $e->getHtmlDesc()));
|
||||
$oP->output();
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue())
|
||||
{
|
||||
if (MetaModel::IsValidClass('EventIssue'))
|
||||
{
|
||||
$oLog = new EventIssue();
|
||||
|
||||
$oLog->Set('message', $e->getMessage());
|
||||
$oLog->Set('userinfo', '');
|
||||
$oLog->Set('issue', $e->GetIssue());
|
||||
$oLog->Set('impact', 'Page could not be displayed');
|
||||
$oLog->Set('callstack', $e->getTrace());
|
||||
$oLog->Set('data', $e->getContextData());
|
||||
$oLog->DBInsertNoReload();
|
||||
}
|
||||
|
||||
IssueLog::Error($e->getMessage());
|
||||
}
|
||||
|
||||
// For debugging only
|
||||
//throw $e;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
require_once(APPROOT.'/setup/setuppage.class.inc.php');
|
||||
$oP = new SetupWebPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
$oP->error(Dict::Format('UI:Error_Details', $e->getMessage()));
|
||||
$oP->output();
|
||||
|
||||
if (MetaModel::IsLogEnabledIssue())
|
||||
{
|
||||
if (MetaModel::IsValidClass('EventIssue'))
|
||||
{
|
||||
$oLog = new EventIssue();
|
||||
|
||||
$oLog->Set('message', $e->getMessage());
|
||||
$oLog->Set('userinfo', '');
|
||||
$oLog->Set('issue', 'PHP Exception');
|
||||
$oLog->Set('impact', 'Page could not be displayed');
|
||||
$oLog->Set('callstack', $e->getTrace());
|
||||
$oLog->Set('data', array());
|
||||
$oLog->DBInsertNoReload();
|
||||
}
|
||||
|
||||
IssueLog::Error($e->getMessage());
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user