Forráskód Böngészése

Customer portal : Manage Brick : Added an optional tag <opening_mode> to define how the objects should be open (Value can be edit|view, Default is edit). Note that even if the tag is set to edit, objects that the user isn't allowed to edit will open in view mode.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4175 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 9 éve
szülő
commit
05edea43f8

+ 1 - 1
datamodels/2.x/itop-portal-base/portal/src/controllers/managebrickcontroller.class.inc.php

@@ -344,7 +344,7 @@ class ManageBrickController extends BrickController
 					if ($sItemAttr === $sMainActionAttrCode)
 					{
 						// Checking if we can edit the object
-						if (SecurityHelper::IsActionAllowed($oApp, UR_ACTION_MODIFY, $sCurrentClass, $oCurrentRow->GetKey()))
+						if (SecurityHelper::IsActionAllowed($oApp, UR_ACTION_MODIFY, $sCurrentClass, $oCurrentRow->GetKey()) && ($oBrick->GetOpeningMode() === ManageBrick::ENUM_ACTION_EDIT))
 						{
 							$sActionType = ManageBrick::ENUM_ACTION_EDIT;
 						}

+ 38 - 2
datamodels/2.x/itop-portal-base/portal/src/entities/managebrick.class.inc.php

@@ -38,12 +38,14 @@ class ManageBrick extends PortalBrick
 	const ENUM_ACTION_EDIT = 'edit';
 	const DEFAULT_PAGE_TEMPLATE_PATH = 'itop-portal-base/portal/src/views/bricks/manage/layout.html.twig';
 	const DEFAULT_OQL = '';
+	const DEFAULT_OPENING_MODE = self::ENUM_ACTION_EDIT;
 	const DEFAULT_DATA_LOADING = self::ENUM_DATA_LOADING_LAZY;
 	const DEFAULT_COUNT_PER_PAGE_LIST = 20;
 	const DEFAULT_ZLIST_FIELDS = 'list';
 
 	static $sRouteName = 'p_manage_brick';
 	protected $sOql;
+	protected $sOpeningMode;
 	protected $aGrouping;
 	protected $aFields;
 
@@ -52,6 +54,7 @@ class ManageBrick extends PortalBrick
 		parent::__construct();
 
 		$this->sOql = static::DEFAULT_OQL;
+		$this->sOpeningMode = static::DEFAULT_OPENING_MODE;
 		$this->aGrouping = array();
 		$this->aFields = array();
 
@@ -70,6 +73,16 @@ class ManageBrick extends PortalBrick
 	}
 
 	/**
+	 * Returns the brick's objects opening mode (edit or view)
+	 *
+	 * @return string
+	 */
+	public function GetOpeningMode()
+	{
+		return $this->sOpeningMode;
+	}
+
+	/**
 	 * Returns the brick grouping
 	 *
 	 * @return array
@@ -93,6 +106,7 @@ class ManageBrick extends PortalBrick
 	 * Sets the oql of the brick
 	 *
 	 * @param string $sOql
+	 * @return \Combodo\iTop\Portal\Brick\ManageBrick
 	 */
 	public function SetOql($sOql)
 	{
@@ -101,6 +115,18 @@ class ManageBrick extends PortalBrick
 	}
 
 	/**
+	 * Sets the brick's objects opening mode
+	 *
+	 * @param string $sOpeningMode
+	 * @return \Combodo\iTop\Portal\Brick\ManageBrick
+	 */
+	public function SetOpeningMode($sOpeningMode)
+	{
+		$this->sOpeningMode = $sOpeningMode;
+		return $this;
+	}
+
+	/**
 	 * Sets the grouping of the brick
 	 *
 	 * @param array $aGrouping
@@ -287,7 +313,7 @@ class ManageBrick extends PortalBrick
 					$sClass = $oBrickSubNode->GetText();
 					if ($sClass === '')
 					{
-						throw new DOMFormatException('BrowseBrick : class tag is empty. Must contain Classname', null, null, $oBrickSubNode);
+						throw new DOMFormatException('ManageBrick : class tag is empty. Must contain Classname', null, null, $oBrickSubNode);
 					}
 
 					$this->SetOql('SELECT ' . $sClass);
@@ -297,12 +323,22 @@ class ManageBrick extends PortalBrick
 					$sOql = $oBrickSubNode->GetText();
 					if ($sOql === '')
 					{
-						throw new DOMFormatException('BrowseBrick : oql tag is empty. Must contain OQL statement', null, null, $oBrickSubNode);
+						throw new DOMFormatException('ManageBrick : oql tag is empty. Must contain OQL statement', null, null, $oBrickSubNode);
 					}
 
 					$this->SetOql($sOql);
 					break;
 
+				case 'opening_mode':
+					$sOpeningMode = $oBrickSubNode->GetText(static::DEFAULT_OPENING_MODE);
+					if (!in_array($sOpeningMode, array(static::ENUM_ACTION_VIEW, static::ENUM_ACTION_EDIT)))
+					{
+						throw new DOMFormatException('ManageBrick : opening_mode tag value must be edit|view ("' . $sOpeningMode . '" given)', null, null, $oBrickSubNode);
+					}
+
+					$this->SetOpeningMode($sOpeningMode);
+					break;
+
 				case 'fields':
 					foreach ($oBrickSubNode->GetNodes('./field') as $oFieldNode)
 					{

+ 3 - 1
datamodels/2.x/itop-tickets/datamodel.itop-tickets.xml

@@ -1113,7 +1113,9 @@
 			  <default>fc fc-ongoing-request fc-2x</default>
 		  </decoration_class>
           <oql><![CDATA[SELECT Ticket]]></oql>
-          <!-- Can be either a class tag with the class name or an oql tag with the query -->
+          <!-- Optional tag to define the how the objects should be opened. Values can be edit|view. Note that even if this is set to edit, objects not allowed in edition mode for the user (cf. scopes and security layers) will open in view mode -->
+		  <!-- <opening_mode>edit</opening_mode> -->
+		  <!-- Can be either a class tag with the class name or an oql tag with the query -->
           <!-- <class>Ticket</class> -->
           <fields>
             <field id="title"/>