Ver Fonte

Prevent a crash when not authorized to see an object of a derived class.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2502 a333f486-631f-4898-b8df-5754b55c2be0
dflaven há 12 anos atrás
pai
commit
63bec7157b
1 ficheiros alterados com 16 adições e 2 exclusões
  1. 16 2
      pages/UI.php

+ 16 - 2
pages/UI.php

@@ -699,7 +699,7 @@ try
 		case 'details': // Details of an object
 			$sClass = utils::ReadParam('class', '');
 			$id = utils::ReadParam('id', '');
-		if ( empty($sClass) || empty($id))
+			if ( empty($sClass) || empty($id))
 			{
 				throw new ApplicationException(Dict::Format('UI:Error:2ParametersMissing', 'class', 'id'));
 			}
@@ -719,7 +719,21 @@ try
 			}
 			else
 			{
-			DisplayDetails($oP, $sClass, $oObj, $id);
+				try
+				{
+					$oObj->Reload();
+				}
+				catch(Exception $e)
+				{
+					// Probably not allowed to see this instance of a derived class
+					$oObj = null; 
+					$oP->set_title(Dict::S('UI:ErrorPageTitle'));
+					$oP->P(Dict::S('UI:ObjectDoesNotExist'));
+				}
+				if (!is_null($oObj))
+				{
+					DisplayDetails($oP, $sClass, $oObj, $id);
+				}				
 			}
 		break;