mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
Customer portal : Added support for demo mode
SVN:trunk[4159]
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
namespace Combodo\iTop\Portal\Controller;
|
||||
|
||||
use \Exception;
|
||||
use \MetaModel;
|
||||
use \UserRights;
|
||||
use \Silex\Application;
|
||||
use \Symfony\Component\HttpFoundation\Request;
|
||||
@@ -87,14 +88,18 @@ class UserProfileBrickController extends BrickController
|
||||
$sCurContactClass = get_class($oCurContact);
|
||||
$sCurContactId = $oCurContact->GetKey();
|
||||
|
||||
// Setting form mode regarding the demo mode parameter
|
||||
$sFormMode = (MetaModel::GetConfig()->Get('demo_mode')) ? ObjectController::ENUM_MODE_VIEW : ObjectController::ENUM_MODE_EDIT;
|
||||
|
||||
// Preparing forms
|
||||
$aData['forms']['contact'] = ObjectController::HandleForm($oRequest, $oApp, ObjectController::ENUM_MODE_EDIT, $sCurContactClass, $sCurContactId, $oBrick->GetForm());
|
||||
$aData['forms']['preferences'] = $this->HandlePreferencesForm($oRequest, $oApp);
|
||||
$aData['forms']['contact'] = ObjectController::HandleForm($oRequest, $oApp, $sFormMode, $sCurContactClass, $sCurContactId, $oBrick->GetForm());
|
||||
$aData['forms']['preferences'] = $this->HandlePreferencesForm($oRequest, $oApp, $sFormMode);
|
||||
// - If user can change password, we display the form
|
||||
$aData['forms']['password'] = (UserRights::CanChangePassword()) ? $this->HandlePasswordForm($oRequest, $oApp) : null;
|
||||
|
||||
$aData = $aData + array(
|
||||
'oBrick' => $oBrick
|
||||
'oBrick' => $oBrick,
|
||||
'sFormMode' => $sFormMode
|
||||
);
|
||||
|
||||
$oResponse = $oApp['twig']->render($oBrick->GetPageTemplatePath(), $aData);
|
||||
@@ -103,7 +108,7 @@ class UserProfileBrickController extends BrickController
|
||||
return $oResponse;
|
||||
}
|
||||
|
||||
public function HandlePreferencesForm(Request $oRequest, Application $oApp)
|
||||
public function HandlePreferencesForm(Request $oRequest, Application $oApp, $sFormMode)
|
||||
{
|
||||
$aFormData = array();
|
||||
$oRequestParams = $oRequest->request;
|
||||
@@ -120,6 +125,11 @@ class UserProfileBrickController extends BrickController
|
||||
$oFormManager = new PreferencesFormManager();
|
||||
$oFormManager->SetRenderer($oFormRenderer)
|
||||
->Build();
|
||||
// - Checking if we have to make the form read only
|
||||
if ($sFormMode === ObjectController::ENUM_MODE_VIEW)
|
||||
{
|
||||
$oFormManager->GetForm()->MakeReadOnly();
|
||||
}
|
||||
}
|
||||
// - Submit
|
||||
else if ($sOperation === 'submit')
|
||||
|
||||
@@ -89,7 +89,9 @@
|
||||
</div>
|
||||
<div class="form_buttons">
|
||||
<div class="form_btn_regular">
|
||||
<input class="btn btn-primary form_btn_submit" type="submit" value="{{ 'Portal:Button:Submit'|dict_s }}">
|
||||
{% if sFormMode == constant('\\Combodo\\iTop\\Portal\\Controller\\ObjectController::ENUM_MODE_EDIT') %}
|
||||
<input class="btn btn-primary form_btn_submit" type="submit" value="{{ 'Portal:Button:Submit'|dict_s }}">
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -425,6 +425,21 @@ class Form
|
||||
return $bRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the form to a read only state by setting read only to true on all its fields
|
||||
*
|
||||
* @return \Combodo\iTop\Form\Form
|
||||
*/
|
||||
public function MakeReadOnly()
|
||||
{
|
||||
foreach ($this->GetFields() as $oField)
|
||||
{
|
||||
$oField->SetReadOnly(true);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sFormPath
|
||||
* @return Form|null
|
||||
|
||||
Reference in New Issue
Block a user