- Get rid of the class UserContext, since now everything is implemented directly in MetaModel

- Make the Accordion menu collapsible

SVN:trunk[683]
This commit is contained in:
Denis Flaven
2010-08-23 12:27:21 +00:00
parent a33dfa9f10
commit 7aacef8d7d
28 changed files with 65 additions and 266 deletions

View File

@@ -268,12 +268,6 @@ class UserRightsMatrix extends UserRightsAddOnAPI
return true;
}
public function GetFilter($sUserName, $sClass)
{
$oNullFilter = new DBObjectSearch($sClass);
return $oNullFilter;
}
public function GetSelectFilter($oUser, $sClass)
{
$oNullFilter = new DBObjectSearch($sClass);

View File

@@ -47,12 +47,6 @@ class UserRightsNull extends UserRightsAddOnAPI
return true;
}
public function GetFilter($sUserName, $sClass)
{
$oNullFilter = new DBObjectSearch($sClass);
return $oNullFilter;
}
public function GetSelectFilter($oUser, $sClass)
{
$oNullFilter = new DBObjectSearch($sClass);

View File

@@ -729,12 +729,6 @@ exit;
return true;
}
public function GetFilter($sUserName, $sClass)
{
$oNullFilter = new DBObjectSearch($sClass);
return $oNullFilter;
}
public function GetSelectFilter($oUser, $sClass)
{
$aConditions = array();

View File

@@ -24,7 +24,6 @@
*/
require_once('../application/applicationcontext.class.inc.php');
require_once('../application/usercontext.class.inc.php');
require_once('../application/cmdbabstract.class.inc.php');
require_once('../application/displayblock.class.inc.php');
require_once('../application/audit.category.class.inc.php');

View File

@@ -743,10 +743,9 @@ class HistoryBlock extends DisplayBlock
if (is_object($oLatestChangeOp))
{
$oContext = new UserContext();
// There is one change in the list... only when the object has been created !
$sDate = $oLatestChangeOp->GetAsHTML('date');
$oChange = $oContext->GetObject('CMDBChange', $oLatestChangeOp->Get('change'));
$oChange = MetaModel::GetObject('CMDBChange', $oLatestChangeOp->Get('change'));
$sUserInfo = $oChange->GetAsHTML('userinfo');
$sHtml .= $oPage->GetStartCollapsibleSection(Dict::Format('UI:History:LastModified_On_By', $sDate, $sUserInfo));
$sHtml .= $this->GetHistoryTable($oPage, $oSet);

View File

@@ -24,7 +24,6 @@
*/
require_once("../application/nicewebpage.class.inc.php");
require_once("../application/usercontext.class.inc.php");
require_once("../application/applicationcontext.class.inc.php");
require_once("../application/user.preferences.class.inc.php");
/**
@@ -113,7 +112,7 @@ class iTopWebPage extends NiceWebPage
}
// Accordion Menu
$("#accordion").accordion({ header: "h3", navigation: true, autoHeight: false, collapsible: false, icons: false });
$("#accordion").accordion({ header: "h3", navigation: true, autoHeight: false, collapsible: false, icons: false }); // collapsible will be enabled once the item will be selected
});
//add new widget called TruncatedList to properly display truncated lists when they are sorted
$.tablesorter.addWidget({
@@ -293,10 +292,9 @@ EOF
{
// List of visible Organizations
$iCount = 0;
$oContext = new UserContext();
if (MetaModel::IsValidClass('Organization'))
{
$oSearchFilter = $oContext->NewFilter('Organization');
$oSearchFilter = new DBObjectSearch('Organization');
$oSet = new CMDBObjectSet($oSearchFilter);
$iCount = $oSet->Count();
}
@@ -346,7 +344,6 @@ EOF
public function DisplayMenu()
{
$oContext = new UserContext();
// Display the menu
$oAppContext = new ApplicationContext();
$iActiveNodeId = ApplicationMenu::GetActiveNodeId();

View File

@@ -110,6 +110,7 @@ class ApplicationMenu
if ($bActive)
{
$oPage->add_ready_script("$('#accordion').accordion('activate', $iAccordion);");
$oPage->add_ready_script("$('#accordion').accordion('option', {collapsible: true});"); // Make it auto-collapsible once it has been opened properly
}
}
$oPage->AddToMenu('</div>');

View File

@@ -212,12 +212,11 @@ class UILinksWidget
$sHtmlValue .= "<div id=\"linkedset_{$this->m_sAttCode}{$this->m_sNameSuffix}\">\n";
$oValue->Rewind();
$aForm = array();
$oContext = new UserContext();
while($oCurrentLink = $oValue->Fetch())
{
$aRow = array();
$key = $oCurrentLink->GetKey();
$oLinkedObj = $oContext->GetObject($this->m_sRemoteClass, $oCurrentLink->Get($this->m_sExtKeyToRemote));
$oLinkedObj = MetaModel::GetObject($this->m_sRemoteClass, $oCurrentLink->Get($this->m_sExtKeyToRemote));
$aForm[$key] = $this->GetFormRow($oPage, $oLinkedObj, $oCurrentLink, $aArgs);
}
@@ -238,14 +237,13 @@ EOF
/**
* This static function is called by the Ajax Page when there is a need to fill an autocomplete combo
* @param $oPage WebPage The ajax page used for the output (sent back to the browser)
* @param $oContext UserContext The context of the user (for limiting the search)
* @param $sClass string The name of the class of the current object being edited
* @param $sAttCode string The name of the attribute being edited
* @param $sName string The partial name that was typed by the user
* @param $iMaxCount integer The maximum number of items to return
* @return void
*/
static public function Autocomplete(WebPage $oPage, UserContext $oContext, $sClass, $sAttCode, $sName, $iMaxCount)
static public function Autocomplete(WebPage $oPage, $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);
@@ -265,7 +263,7 @@ EOF
$oAttDef = $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
$sLinkedClass = $oAttDef->GetLinkedClass();
$sSearchClass = self::GetTargetClass($sClass, $sAttCode);
$oFilter = $oContext->NewFilter($sSearchClass);
$oFilter = new DBObjectSearch($sSearchClass);
$sSearchAttCode = MetaModel::GetNameAttributeCode($sSearchClass);
$oFilter->AddCondition($sSearchAttCode, $sName, 'Begins with');
$oSet = new CMDBObjectSet($oFilter, array($sSearchAttCode => true));
@@ -346,9 +344,8 @@ EOF
{
$sHtml = "<div id=\"dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}\">";
$sHtml .= "<div class=\"wizContainer\" style=\"vertical-align:top;\">\n";
$oContext = new UserContext();
$iWidgetIndex = self::$iWidgetIndex;
$oFilter = $oContext->NewFilter($this->m_sRemoteClass);
$oFilter = new DBObjectSearch($this->m_sRemoteClass);
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'search', false);
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}", array('open' => true));
@@ -370,21 +367,20 @@ EOF
/**
* Search for objects to be linked to the current object (i.e "remote" objects)
* @param WebPage $oP The page used for the output (usually an AjaxWebPage)
* @param UserContext $oContext User context to limit the search...
* @param string $sRemoteClass Name of the "remote" class to perform the search on, must be a derived class of m_sRemoteClass
* @param Array $aAlreadyLinkedIds List of IDs of objects of "remote" class already linked, to be filtered out of the search
*/
public function SearchObjectsToAdd(WebPage $oP, UserContext $oContext, $sRemoteClass = '', $aAlreadyLinkedIds = array())
public function SearchObjectsToAdd(WebPage $oP, $sRemoteClass = '', $aAlreadyLinkedIds = array())
{
if ($sRemoteClass != '')
{
// assert(MetaModel::IsParentClass($this->m_sRemoteClass, $sRemoteClass));
$oFilter = $oContext->NewFilter($sRemoteClass);
$oFilter = new DBObjectSearch($sRemoteClass);
}
else
{
// No remote class specified use the one defined in the linkedset
$oFilter = $oContext->NewFilter($this->m_sRemoteClass);
$oFilter = new DBObjectSearch($this->m_sRemoteClass);
}
if (count($aAlreadyLinkedIds) > 0)
{
@@ -407,7 +403,7 @@ EOF
if (count($aLinkIds) >0)
{
// Search for the links to find to which "remote" object they are linked
$oLinkFilter = $oContext->NewFilter($this->m_sLinkedClass);
$oLinkFilter = new DBObjectSearch($this->m_sLinkedClass);
$oLinkFilter->AddCondition('id', $aLinkIds, 'IN');
$oLinkSet = new CMDBObjectSet($oLinkFilter);
while($oLink = $oLinkSet->Fetch())
@@ -422,12 +418,12 @@ EOF
$oBlock->Display($oP, 'ResultsToAdd', array('menu' => false, 'selection_mode' => true, 'display_limit' => false)); // Don't display the 'Actions' menu on the results
}
public function DoAddObjects(WebPage $oP, UserContext $oContext, $aLinkedObjectIds = array())
public function DoAddObjects(WebPage $oP, $aLinkedObjectIds = array())
{
$aTable = array();
foreach($aLinkedObjectIds as $iObjectId)
{
$oLinkedObj = $oContext->GetObject($this->m_sRemoteClass, $iObjectId);
$oLinkedObj = MetaModel::GetObject($this->m_sRemoteClass, $iObjectId);
if (is_object($oLinkedObj))
{
$aRow = $this->GetFormRow($oP, $oLinkedObj, -$iObjectId ); // Not yet created link get negative Ids

View File

@@ -79,11 +79,11 @@ class UILinksWizard
}
}
public function Display(WebPage $oP, UserContext $oContext, $aExtraParams = array())
public function Display(WebPage $oP, $aExtraParams = array())
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
$sTargetClass = $oAttDef->GetTargetClass();
$oTargetObj = $oContext->GetObject($sTargetClass, $this->m_iObjectId);
$oTargetObj = MetaModel::GetObject($sTargetClass, $this->m_iObjectId);
$oP->set_title("iTop - ".MetaModel::GetName($this->m_sLinkedClass)." objects linked with ".MetaModel::GetName(get_class($oTargetObj)).": ".$oTargetObj->GetName());
$oP->add("<div class=\"wizContainer\">\n");
@@ -259,7 +259,7 @@ EOF
);
$oP->Add("</script>\n");
$oP->add_ready_script("InitForm();");
$oFilter = $oContext->NewFilter($this->m_sClass);
$oFilter = new DBObjectSearch($this->m_sClass);
$oFilter->AddCondition($this->m_sLinkageAttr, $this->m_iObjectId, '=');
$oSet = new DBObjectSet($oFilter);
$aForm = array();
@@ -267,7 +267,7 @@ EOF
{
$aRow = array();
$key = $oCurrentLink->GetKey();
$oLinkedObj = $oContext->GetObject($this->m_sLinkedClass, $oCurrentLink->Get($this->m_sLinkingAttCode));
$oLinkedObj = MetaModel::GetObject($this->m_sLinkedClass, $oCurrentLink->Get($this->m_sLinkingAttCode));
$aForm[$key] = $this->GetFormRow($oP, $oLinkedObj, $oCurrentLink);
}
@@ -363,17 +363,17 @@ EOF
$oP->add("</tr>\n");
}
public function DisplayAddForm(WebPage $oP, UserContext $oContext)
public function DisplayAddForm(WebPage $oP)
{
$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
$sTargetClass = $oAttDef->GetTargetClass();
$oTargetObj = $oContext->GetObject($sTargetClass, $this->m_iObjectId);
$oTargetObj = MetaModel::GetObject($sTargetClass, $this->m_iObjectId);
$oP->add("<div class=\"wizContainer\">\n");
//$oP->add("<div class=\"page_header\">\n");
//$oP->add("<h1>".Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class_Instance', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName(get_class($oTargetObj)), "<span class=\"hilite\">".$oTargetObj->GetHyperlink()."</span>")."</h1>\n");
//$oP->add("</div>\n");
$oFilter = $oContext->NewFilter($this->m_sLinkedClass);
$oFilter = new DBObjectSearch($this->m_sLinkedClass);
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'search', false);
$oBlock->Display($oP, 'SearchFormToAdd', array('open' => true));
@@ -388,17 +388,17 @@ EOF
$oP->add_ready_script("$('div#SearchFormToAdd form').bind('submit.uilinksWizard', SubmitHook);");
}
public function SearchObjectsToAdd(WebPage $oP, UserContext $oContext)
public function SearchObjectsToAdd(WebPage $oP)
{
//$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
$oFilter = $oContext->NewFilter($this->m_sLinkedClass);
$oFilter = new DBObjectSearch($this->m_sLinkedClass);
$oSet = new CMDBObjectSet($oFilter);
$oBlock = new DisplayBlock($oFilter, 'list', false);
$oBlock->Display($oP, 'ResultsToAdd', array('menu' => false, 'selection_mode' => true, 'display_limit' => false)); // Don't display the 'Actions' menu on the results
}
public function DoAddObjects(WebPage $oP, UserContext $oContext, $aLinkedObjectIds = array())
public function DoAddObjects(WebPage $oP, $aLinkedObjectIds = array())
{
//$oAttDef = MetaModel::GetAttributeDef($this->m_sClass, $this->m_sLinkageAttr);
//$sTargetClass = $oAttDef->GetTargetClass();
@@ -406,7 +406,7 @@ EOF
$aTable = array();
foreach($aLinkedObjectIds as $iObjectId)
{
$oLinkedObj = $oContext->GetObject($this->m_sLinkedClass, $iObjectId);
$oLinkedObj = MetaModel::GetObject($this->m_sLinkedClass, $iObjectId);
if (is_object($oLinkedObj))
{
$aRow = $this->GetFormRow($oP, $oLinkedObj, -$iObjectId ); // Not yet created link get negative Ids

View File

@@ -1,129 +0,0 @@
<?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
/**
* Class UserContext... should be obsoleted later (see notes below)
*
* @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('../core/cmdbobject.class.inc.php');
/**
* Helper class to capture a user's restrictions (access rights, profiles...) as a set of limiting conditions
*
* **** NOW OBSOLETE *** SHOULD BE REPLACED EVERYWHERE BY UserRights *****
*
*
*
*
* Usage:
* 1) Build the user's context (from her rights, a lookup in the database, a cookie, whatever)
* $oContext = new UserContext();
* $oContext->AddCondition('SomeClass', 'someFilter', 'SomeValue', '=');
* ...
*
* 2) Use the restrictions contained in the context when retrieving objects either when:
* getting directly an instance of an object
* $oObj = $oContext->GetObject('myClass', 'someKey'); // Instead of $oObj = MetaModel::GetObject('Klass', 'someKey');
* or when building a new search filter
* $oFilter = $oContext->NewFilter('myClass'); // Instead of $oFilter = new CMDBSearchFilter('Klass');
*/
class UserContext
{
/**
* Hash array to store the restricting conditions by myClass
*/
protected $m_aConditions;
/**
* Constructor
*/
public function __construct()
{
$this->m_aConditions = array();
}
/**
* Create a new search filter for the given class of objects that already contains the context's restrictions
*/
public function NewFilter($sClass)
{
return UserRights::GetFilter($sClass);
/*
$oFilter = new CMDBSearchFilter($sClass);
foreach($this->m_aConditions as $sConditionClass => $aConditionList)
{
// Add to the filter all the conditions of the parent classes of this class
if ($this->IsSubclass($sConditionClass,$sClass))
{
foreach($aConditionList as $sFilterCode => $aCondition)
{
$oFilter->AddCondition($sFilterCode, $aCondition['value'], $aCondition['operator']);
}
}
}
return $oFilter;
*/
}
/**
* Retrieve an instance of an object (if allowed by the context)
*/
public function GetObject($sClass, $sKey)
{
$oObject = null;
$oFilter = $this->NewFilter($sClass);
$oFilter->AddCondition('id', $sKey, '=');
$oSet = new CMDBObjectSet($oFilter);
if ($oSet->Count() > 0)
{
$oObject = $oSet->Fetch();
}
return $oObject;
}
/**
* Add a restriction to the context for a given class of objects (and all its persistent subclasses)
*/
public function AddCondition($sClass, $sFilterCode, $value, $sOperator)
{
if(!isset($this->m_aConditions[$sClass]))
{
$this->m_aConditions[$sClass] = array();
}
$this->m_aConditions[$sClass][$sFilterCode] = array('value'=>$value, 'operator'=>$sOperator);
}
/**
* Check if a given class is a subclass of (or same as) another one
*/
protected function IsSubclass($sParentClass, $sSubclass)
{
$bResult = false;
if ($sParentClass == $sSubclass)
{
$bResult = true;
}
else
{
$aParentList = MetaModel::EnumParentClasses($sSubclass);
$bResult = in_array($sParentClass, $aParentList);
}
return $bResult;
}
}
?>

View File

@@ -55,8 +55,6 @@ abstract class UserRightsAddOnAPI
abstract public function Init(); // loads data (possible optimizations)
// Cf UserContext...
abstract public function GetFilter($sLogin, $sClass); // returns a filter object
// Used to build select queries showing only objects visible for the given user
abstract public function GetSelectFilter($sLogin, $sClass); // returns a filter object
@@ -494,23 +492,6 @@ class UserRights
return true;
}
public static function GetFilter($sClass)
{
// #@# to cleanup !
return new DBObjectSearch($sClass);
if (!self::CheckLogin()) return false;
if (self::IsAdministrator()) return new DBObjectSearch($sClass);
// this module is forbidden for non admins
if (MetaModel::HasCategory($sClass, 'addon/userrights')) return false;
// the rest is allowed (#@# to be improved)
if (!MetaModel::HasCategory($sClass, 'bizmodel')) return new DBObjectSearch($sClass);
return self::$m_oAddOn->GetFilter(self::$m_oUser->GetKey(), $sClass);
}
public static function GetSelectFilter($sClass)
{
// Need to load some records before the login is performed (user preferences)

View File

@@ -445,7 +445,6 @@ try
require_once('../application/wizardhelper.class.inc.php');
require_once('../application/startup.inc.php');
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$currentOrganization = utils::ReadParam('org_id', '');
$operation = utils::ReadParam('operation', '');
@@ -469,7 +468,7 @@ try
{
throw new ApplicationException(Dict::Format('UI:Error:2ParametersMissing', 'class', 'id'));
}
$oObj = $oContext->GetObject($sClass, $id);
$oObj = MetaModel::GetObject($sClass, $id);
if ($oObj != null)
{
$oP->set_title(Dict::Format('UI:DetailsPageTitle', $oObj->GetName(), $sClassLabel));
@@ -540,7 +539,7 @@ try
throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'class'));
}
$oP->set_title(Dict::S('UI:SearchResultsPageTitle'));
$oFilter = $oContext->NewFilter($sClass);
$oFilter = new DBObjectSearch($sClass);
$oSet = new DBObjectSet($oFilter);
if ($bSearchForm)
{
@@ -762,7 +761,6 @@ try
$oP->add_linked_script("../js/linkswidget.js");
$oP->add_linked_script("../js/jquery.blockUI.js");
$oContext = new UserContext();
$aArgs = array_merge($oAppContext->GetAsHash(), utils::ReadParam('default', array()));
// If the specified class has subclasses, ask the user an instance of which class to create
@@ -860,7 +858,7 @@ try
{
throw new ApplicationException(Dict::Format('UI:Error:2ParametersMissing', 'class', 'id'));
}
$oObj = $oContext->GetObject($sClass, $id);
$oObj = MetaModel::GetObject($sClass, $id);
if (!utils::IsTransactionValid($sTransactionId))
{
$oP->p("<strong>".Dict::S('UI:Error:ObjectAlreadyUpdated')."</strong>\n");
@@ -950,7 +948,7 @@ try
}
foreach($aSelectObject as $iId)
{
$aObjects[] = $oContext->GetObject($sClass, $iId);
$aObjects[] = MetaModel::GetObject($sClass, $iId);
}
if (MetaModel::IsReadOnlyClass($sClass) || !UserRights::IsActionAllowed($sClass, UR_ACTION_BULK_DELETE, DBObjectSet::FromArray($sClass, $aObjects)))
{
@@ -965,7 +963,7 @@ try
$sClass = utils::ReadParam('class', '');
$sClassLabel = MetaModel::GetName($sClass);
$id = utils::ReadParam('id', '');
$oObj = $oContext->GetObject($sClass, $id);
$oObj = MetaModel::GetObject($sClass, $id);
if (MetaModel::IsReadOnlyClass($sClass) || !UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY, DBObjectSet::FromObject($oObj)))
{
@@ -985,7 +983,7 @@ try
}
else
{
$oObj = $oContext->GetObject($sClass, $iCloneId);
$oObj = MetaModel::GetObject($sClass, $iCloneId);
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
if (UserRights::IsImpersonated())
@@ -1091,7 +1089,7 @@ try
{
throw new ApplicationException(Dict::Format('UI:Error:3ParametersMissing', 'class', 'id', 'stimulus'));
}
$oObj = $oContext->GetObject($sClass, $id);
$oObj = MetaModel::GetObject($sClass, $id);
if ($oObj != null)
{
$aTransitions = $oObj->EnumTransitions();
@@ -1183,7 +1181,7 @@ EOF
{
throw new ApplicationException(Dict::Format('UI:Error:3ParametersMissing', 'class', 'id', 'stimulus'));
}
$oObj = $oContext->GetObject($sClass, $id);
$oObj = MetaModel::GetObject($sClass, $id);
if ($oObj != null)
{
$aTransitions = $oObj->EnumTransitions();
@@ -1258,7 +1256,7 @@ EOF
}
require_once('../application/uilinkswizard.class.inc.php');
$oWizard = new UILinksWizard($sClass, $sLinkAttr, $id, $sTargetClass);
$oWizard->Display($oP, $oContext, array('StartWithAdd' => $bAddObjects));
$oWizard->Display($oP, array('StartWithAdd' => $bAddObjects));
break;
case 'do_modify_links':
@@ -1291,7 +1289,7 @@ EOF
{
if ($iLinkId > 0) // Negative IDs are objects that were not even created
{
$oLink = $oContext->GetObject($sClass, $iLinkId);
$oLink = MetaModel::GetObject($sClass, $iLinkId);
$oLink->DBDeleteTracked($oMyChange);
}
}
@@ -1314,7 +1312,7 @@ EOF
if ($iLinkId > 0)
{
// This is an existing link to be modified
$oLink = $oContext->GetObject($sClass, $iLinkId);
$oLink = MetaModel::GetObject($sClass, $iLinkId);
// Update all the attributes of the link
foreach($aEditableFields as $sAttCode)
@@ -1352,9 +1350,9 @@ EOF
// Display again the details of the linked object
$oAttDef = MetaModel::GetAttributeDef($sClass, $sLinkageAtt);
$sTargetClass = $oAttDef->GetTargetClass();
$oObj = $oContext->GetObject($sTargetClass, $iObjectId);
$oObj = MetaModel::GetObject($sTargetClass, $iObjectId);
$oSearch = $oContext->NewFilter(get_class($oObj));
$oSearch = new DBObjectSearch(get_class($oObj));
$oBlock = new DisplayBlock($oSearch, 'search', false);
$oBlock->Display($oP, 0);
$oObj->DisplayDetails($oP);

View File

@@ -32,7 +32,6 @@ require_once('../application/startup.inc.php');
require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', '');

View File

@@ -173,8 +173,6 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oContext = new UserContext();
$sOperation = utils::ReadParam('operation', '');
switch($sOperation)

View File

@@ -38,7 +38,6 @@ LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oPage = new ajax_page("");
$oPage->no_cache();
$oContext = new UserContext();
$operation = utils::ReadParam('operation', '');
$sFilter = stripslashes(utils::ReadParam('filter', ''));
$sEncoding = utils::ReadParam('encoding', 'serialize');
@@ -54,7 +53,7 @@ switch($operation)
$sLinkageAttr = utils::ReadParam('linkageAttr', '', 'get');
$iObjectId = utils::ReadParam('objectId', '', 'get');
$oLinksWizard = new UILinksWizard($sClass, $sLinkageAttr, $iObjectId, $sLinkedClass);
$oLinksWizard->DisplayAddForm($oPage, $oContext);
$oLinksWizard->DisplayAddForm($oPage);
break;
// ui.linkswidget
@@ -65,7 +64,7 @@ switch($operation)
$sSuffix = utils::ReadParam('sSuffix', '');
$aAlreadyLinked = utils::ReadParam('aAlreadyLinked', array());
$oWidget = new UILinksWidget($sClass, $sAttCode, $iInputId, $sSuffix);
$oWidget->SearchObjectsToAdd($oPage, $oContext, $sRemoteClass, $aAlreadyLinked);
$oWidget->SearchObjectsToAdd($oPage, $sRemoteClass, $aAlreadyLinked);
break;
// ui.linkswidget
@@ -75,7 +74,7 @@ switch($operation)
$sSuffix = utils::ReadParam('sSuffix', '');
$aLinkedObjectIds = utils::ReadParam('selectObject', array(), 'get');
$oWidget = new UILinksWidget($sClass, $sAttCode, $iInputId, $sSuffix);
$oWidget->DoAddObjects($oPage, $oContext, $aLinkedObjectIds);
$oWidget->DoAddObjects($oPage, $aLinkedObjectIds);
break;
case 'wizard_helper_preview':
@@ -145,7 +144,7 @@ switch($operation)
case 'details':
$key = utils::ReadParam('id', 0);
$oFilter = $oContext->NewFilter($sClass);
$oFilter = new DBObjectSearch($sClass);
$oFilter->AddCondition('id', $key, '=');
$oDisplayBlock = new DisplayBlock($oFilter, 'details', false);
$oDisplayBlock->RenderContent($oPage);
@@ -153,7 +152,7 @@ switch($operation)
case 'preview':
$key = utils::ReadParam('id', 0);
$oFilter = $oContext->NewFilter($sClass);
$oFilter = new DBObjectSearch($sClass);
$oFilter->AddCondition('id', $key, '=');
$oDisplayBlock = new DisplayBlock($oFilter, 'preview', false);
$oDisplayBlock->RenderContent($oPage);
@@ -205,7 +204,7 @@ switch($operation)
case 'modal_details':
$key = utils::ReadParam('id', 0);
$oFilter = $oContext->NewFilter($sClass);
$oFilter = new DBObjectSearch($sClass);
$oFilter->AddCondition('id', $key, '=');
$oPage->Add("<p style=\"width:100%; margin-top:-5px;padding:3px; background-color:#33f; color:#fff;\">Object Details</p>\n");
$oDisplayBlock = new DisplayBlock($oFilter, 'details', false);
@@ -220,7 +219,7 @@ switch($operation)
$sOrg = utils::ReadParam('org_id', '');
$sName = utils::ReadParam('q', '');
$iMaxCount = utils::ReadParam('max', 30);
UILinksWidget::Autocomplete($oPage, $oContext, $sClass, $sAttCode, $sName, $iMaxCount);
UILinksWidget::Autocomplete($oPage, $sClass, $sAttCode, $sName, $iMaxCount);
*/
break;
@@ -268,7 +267,7 @@ switch($operation)
$sName = utils::ReadParam('q', '');
$iMaxCount = utils::ReadParam('max', 30);
$iCount = 0;
$oFilter = $oContext->NewFilter($sClass);
$oFilter = new DBObjectSearch($sClass);
$oFilter->AddCondition($sAttCode, $sName, 'Begins with');
//$oFilter->AddCondition('org_id', $sOrg, '=');
$oSet = new CMDBObjectSet($oFilter, array($sAttCode => true));
@@ -300,7 +299,7 @@ switch($operation)
$sField = utils::ReadParam('field', '');
if (!empty($sClass) && !empty($id) && !empty($sField))
{
DownloadDocument($oPage, $oContext, $sClass, $id, $sField, 'inline');
DownloadDocument($oPage, $sClass, $id, $sField, 'inline');
}
break;
@@ -309,7 +308,7 @@ switch($operation)
$sField = utils::ReadParam('field', '');
if (!empty($sClass) && !empty($id) && !empty($sField))
{
DownloadDocument($oPage, $oContext, $sClass, $id, $sField, 'attachement');
DownloadDocument($oPage, $sClass, $id, $sField, 'attachement');
}
break;
@@ -317,7 +316,7 @@ switch($operation)
$sClass = utils::ReadParam('className', '');
$sRootClass = utils::ReadParam('baseClass', '');
$currentId = utils::ReadParam('currentId', '');
$oFilter = $oContext->NewFilter($sClass);
$oFilter = new DBObjectSearch($sClass);
$oSet = new CMDBObjectSet($oFilter);
$sHtml = cmdbAbstractObject::GetSearchForm($oPage, $oSet, array('currentId' => $currentId, 'baseClass' => $sRootClass));
$oPage->add($sHtml);
@@ -343,18 +342,17 @@ $oPage->output();
* Downloads a document to the browser, either as 'inline' or 'attachment'
*
* @param WebPage $oPage The web page for the output
* @param UserContext $oContext The current User/security context to retreive the objects
* @param string $sClass Class name of the object
* @param mixed $id Identifier of the object
* @param string $sAttCode Name of the attribute containing the document to download
* @param string $sContentDisposition Either 'inline' or 'attachment'
* @return none
*/
function DownloadDocument(WebPage $oPage, UserContext $oContext, $sClass, $id, $sAttCode, $sContentDisposition = 'attachement')
function DownloadDocument(WebPage $oPage, $sClass, $id, $sAttCode, $sContentDisposition = 'attachement')
{
try
{
$oObj = $oContext->GetObject($sClass, $id);
$oObj = MetaModel::GetObject($sClass, $id);
if (is_object($oObj))
{
$oDocument = $oObj->Get($sAttCode);

View File

@@ -38,9 +38,7 @@ $oP = new iTopWebPage(Dict::S('UI:Audit:Title'), $currentOrganization);
function GetRuleResultSet($iRuleId, $oDefinitionFilter)
{
$oContext = new UserContext();
$oRule = $oContext->GetObject('AuditRule', $iRuleId);
$oRule = MetaModel::GetObject('AuditRule', $iRuleId);
$sOql = $oRule->Get('query');
$oRuleFilter = DBObjectSearch::FromOQL($sOql);
if ($oRule->Get('valid_flag') == 'false')
@@ -87,8 +85,7 @@ switch($operation)
$iCategory = utils::ReadParam('category', '');
$iRuleIndex = utils::ReadParam('rule', 0);
$oContext = new UserContext();
$oAuditCategory = $oContext->GetObject('AuditCategory', $iCategory);
$oAuditCategory = MetaModel::GetObject('AuditCategory', $iCategory);
$oDefinitionFilter = DBObjectSearch::FromOQL($oAuditCategory->Get('definition_set'));
if (!empty($currentOrganization))
{
@@ -96,7 +93,7 @@ switch($operation)
}
$oDefinitionSet = new CMDBObjectSet($oDefinitionFilter);
$oErrorObjectSet = GetRuleResultSet($iRuleIndex, $oDefinitionFilter);
$oAuditRule = $oContext->GetObject('AuditRule', $iRuleIndex);
$oAuditRule = MetaModel::GetObject('AuditRule', $iRuleIndex);
$oP->add('<div class="page_header"><h1>Audit Errors: <span class="hilite">'.$oAuditRule->Get('description').'</span></h1><img style="margin-top: -20px; margin-right: 10px; float: right;" src="../images/stop.png"/></div>');
$oP->p('<a href="./audit.php?'.$oAppContext->GetForLink().'">[Back to audit results]</a>');
$sBlockId = 'audit_errors';

View File

@@ -33,7 +33,6 @@ require_once('../application/startup.inc.php');
require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$currentOrganization = utils::ReadParam('org_id', 1);
$iStep = utils::ReadParam('step', 1);
@@ -208,11 +207,10 @@ function GuessParameters($sCSVData)
/**
* Process the CSV data, for real or as a simulation
* @param WebPage $oPage The page used to display the wizard
* @param UserContext $oContext The current user context
* @param bool $bSimulate Whether or not to simulate the data load
* @return array The CSV lines in error that were rejected from the load (with the header line - if any) or null
*/
function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true)
function ProcessCSVData(WebPage $oPage, $bSimulate = true)
{
$aResult = array();
$sCSVData = utils::ReadParam('csvdata', '');
@@ -362,7 +360,7 @@ function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true
case 'RowStatus_NoChange':
$iUnchanged++;
$sFinalClass = $aRes[$iLine]['finalclass'];
$oObj = $oContext->GetObject($sFinalClass, $aRes[$iLine]['id']->GetValue());
$oObj = MetaModel::GetObject($sFinalClass, $aRes[$iLine]['id']->GetValue());
$sUrl = $oObj->GetHyperlink();
$sStatus = '<img src="../images/unchanged.png" title="Unchanged">';
$sCSSRowClass = 'row_unchanged';
@@ -371,7 +369,7 @@ function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true
case 'RowStatus_Modify':
$iModified++;
$sFinalClass = $aRes[$iLine]['finalclass'];
$oObj = $oContext->GetObject($sFinalClass, $aRes[$iLine]['id']->GetValue());
$oObj = MetaModel::GetObject($sFinalClass, $aRes[$iLine]['id']->GetValue());
$sUrl = $oObj->GetHyperlink();
$sStatus = '<img src="../images/modified.png" title="Modified">';
$sCSSRowClass = 'row_modified';
@@ -389,7 +387,7 @@ function ProcessCSVData(WebPage $oPage, UserContext $oContext, $bSimulate = true
else
{
$sFinalClass = $aRes[$iLine]['finalclass'];
$oObj = $oContext->GetObject($sFinalClass, $aRes[$iLine]['id']->GetValue());
$oObj = MetaModel::GetObject($sFinalClass, $aRes[$iLine]['id']->GetValue());
$sUrl = $oObj->GetHyperlink();
$sMessage = 'Object created';
}
@@ -541,13 +539,12 @@ EOF
/**
* Perform the actual load of the CSV data and display the results
* @param WebPage $oPage The web page to display the wizard
* @param UserContext $oContext Current user's context
* @return void
*/
function LoadData(WebPage $oPage, UserContext $oContext)
function LoadData(WebPage $oPage)
{
$oPage->add('<h2>'.Dict::S('UI:Title:CSVImportStep5').'</h2>');
$aResult = ProcessCSVData($oPage, $oContext, false /* simulate = false */);
$aResult = ProcessCSVData($oPage, false /* simulate = false */);
if (is_array($aResult))
{
$oPage->StartCollapsibleSection(Dict::S('UI:CSVImport:LinesNotImported'), false);
@@ -562,13 +559,12 @@ function LoadData(WebPage $oPage, UserContext $oContext)
/**
* Simulate the load of the CSV data and display the results
* @param WebPage $oPage The web page to display the wizard
* @param UserContext $oContext Current user's context
* @return void
*/
function Preview(WebPage $oPage, UserContext $oContext)
function Preview(WebPage $oPage)
{
$oPage->add('<h2>'.Dict::S('UI:Title:CSVImportStep4').'</h2>');
ProcessCSVData($oPage, $oContext, true /* simulate */);
ProcessCSVData($oPage, true /* simulate */);
}
/**
@@ -1049,11 +1045,11 @@ EOF
switch($iStep)
{
case 5:
LoadData($oPage, $oContext);
LoadData($oPage);
break;
case 4:
Preview($oPage, $oContext);
Preview($oPage);
break;
case 3:

View File

@@ -19,7 +19,6 @@ require_once('../application/itopwebpage.class.inc.php');
require_once('../application/wizardhelper.class.inc.php');
require_once('../application/startup.inc.php');
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$currentOrganization = utils::ReadParam('org_id', '');
$operation = utils::ReadParam('operation', '');

View File

@@ -26,7 +26,6 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$sOperation = utils::ReadParam('operation', 'menu');
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', '');

View File

@@ -91,7 +91,6 @@ function ShowExamples($oP, $sExpression)
}
$sOperation = utils::ReadParam('operation', 'menu');
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', '');

View File

@@ -491,7 +491,6 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
// Display the menu on the left
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', 1);

View File

@@ -356,8 +356,6 @@ class TestUserRightsMatrixItop extends TestUserRights
echo "<p>User: ".UserRights::GetUser()."</p>\n";
echo "<p>On behalf of...".UserRights::GetRealUser()."</p>\n";
UserRights::GetFilter('bizOrganization'); // returns a filter object
$oSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT bizOrganization"));
echo "<p>IsActionAllowed...".(UserRights::IsActionAllowed('bizOrganization', UR_ACTION_MODIFY, $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO')."</p>\n";
echo "<p>IsStimulusAllowed...".(UserRights::IsStimulusAllowed('bizOrganization', 'myStimulus', $oSet) == UR_ALLOWED_YES ? 'ok' : 'NO')."</p>\n";

View File

@@ -107,7 +107,6 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
// Display the menu on the left
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', 1);

View File

@@ -118,7 +118,6 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
// Display the menu on the left
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', 1);

View File

@@ -270,7 +270,6 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
// Display the menu on the left
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', 1);

View File

@@ -60,7 +60,6 @@ function AddNodeDetails(&$oNode, $oObj)
*/
function GetRelatedObjects(DBObject $oObj, $sRelationName, &$oLinks, &$oXmlDoc, &$oXmlNode)
{
$oContext = new UserContext();
$aResults = array();
$oObj->GetRelatedObjects($sRelationName, 1 /* iMaxDepth */, $aResults);
static $iDepth = 0;
@@ -115,7 +114,6 @@ LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oPage = new ajax_page("");
$oPage->no_cache();
$oContext = new UserContext();
$sClass = utils::ReadParam('class', 'Contact');
$id = utils::ReadParam('id', 1);
$sRelation = utils::ReadParam('relation', 'impacts');
@@ -129,7 +127,7 @@ if (!in_array($sRelation, $aValidRelations))
if ($id != 0)
{
$oObj = $oContext->GetObject($sClass, $id);
$oObj = MetaModel::GetObject($sClass, $id);
// Build the root XML part
$oXmlDoc = new DOMDocument( '1.0', 'UTF-8' );
$oXmlRoot = $oXmlDoc->CreateElement('root');

View File

@@ -34,7 +34,6 @@ require_once('../application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$sOperation = utils::ReadParam('operation', 'menu');
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
$iActiveNodeId = utils::ReadParam('menu', -1);
$currentOrganization = utils::ReadParam('org_id', '');

View File

@@ -53,7 +53,6 @@ class WebServiceException extends Exception
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oContext = new UserContext();
$oAppContext = new ApplicationContext();
//$iActiveNodeId = utils::ReadParam('menu', -1);
//$currentOrganization = utils::ReadParam('org_id', '');