mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
Merge branch 'develop' into odain
This commit is contained in:
88
sources/Application/Helper/SearchHelper.php
Normal file
88
sources/Application/Helper/SearchHelper.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\Helper;
|
||||
|
||||
use Combodo\iTop\Application\WebPage\iTopWebPage;
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
use DBSearch;
|
||||
use DisplayBlock;
|
||||
use MetaModel;
|
||||
use utils;
|
||||
|
||||
class SearchHelper
|
||||
{
|
||||
/**
|
||||
* Displays the result of a search request
|
||||
* @param $oP WebPage Web page for the output
|
||||
* @param $oFilter DBSearch The search of objects to display
|
||||
* @param $bSearchForm boolean Whether or not to display the search form at the top the page
|
||||
* @param $sBaseClass string The base class for the search (can be different from the actual class of the results)
|
||||
* @param $sFormat string The format to use for the output: csv or html
|
||||
* @param $bDoSearch bool True to display the search results below the search form
|
||||
* @param $bSearchFormOpen bool True to display the search form fully expanded (only if $bSearchForm of course)
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
*/
|
||||
public static function DisplaySearchSet($oP, $oFilter, $bSearchForm = true, $sBaseClass = '', $sFormat = '', $bDoSearch = true, $bSearchFormOpen = true, $aParams = []): void
|
||||
{
|
||||
//search block
|
||||
$oBlockForm = null;
|
||||
if ($bSearchForm) {
|
||||
$aParams['open'] = $bSearchFormOpen;
|
||||
if (false === isset($aParams['table_id'])) {
|
||||
$aParams['table_id'] = 'result_1';
|
||||
}
|
||||
if (!empty($sBaseClass)) {
|
||||
$aParams['baseClass'] = $sBaseClass;
|
||||
}
|
||||
$oBlockForm = new DisplayBlock($oFilter, 'search', false /* Asynchronous */, $aParams);
|
||||
|
||||
if (!$bDoSearch) {
|
||||
$oBlockForm->Display($oP, 0);
|
||||
}
|
||||
}
|
||||
if ($bDoSearch) {
|
||||
if (strtolower($sFormat) == 'csv') {
|
||||
$oBlock = new DisplayBlock($oFilter, 'csv', false);
|
||||
// Adjust the size of the Textarea containing the CSV to fit almost all the remaining space
|
||||
$oP->add_ready_script(" $('#1>textarea').height($('#1').parent().height() - $('#0').outerHeight() - 30).width( $('#1').parent().width() - 20);"); // adjust the size of the block
|
||||
} else {
|
||||
$oBlock = new DisplayBlock($oFilter, 'list', false);
|
||||
|
||||
// Breadcrumb
|
||||
//$iCount = $oBlock->GetDisplayedCount();
|
||||
$sPageId = "ui-search-".$oFilter->GetClass();
|
||||
$sLabel = MetaModel::GetName($oFilter->GetClass());
|
||||
$oP->SetBreadCrumbEntry($sPageId, $sLabel, '', '', 'fas fa-search', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES);
|
||||
}
|
||||
if ($bSearchForm) {
|
||||
//add search block
|
||||
$sTableId = utils::ReadParam('_table_id_', null, false, 'raw_data');
|
||||
if ($sTableId == '') {
|
||||
$sTableId = 'result_1';
|
||||
}
|
||||
$aExtraParams['table_id'] = $sTableId;
|
||||
$aExtraParams['submit_on_load'] = false;
|
||||
$oUIBlockForm = $oBlockForm->GetDisplay($oP, 'search_1', $aExtraParams);
|
||||
|
||||
// If the class is not high cardinality, we can display the results directly in the same page
|
||||
if (!utils::IsHighCardinality($oFilter->GetClass())) {
|
||||
//add result block
|
||||
$oUIBlock = $oBlock->GetDisplay($oP, $sTableId);
|
||||
$oUIBlock->AddCSSClasses(['display_block', 'sf_results_area']);
|
||||
$oUIBlock->AddDataAttribute('target', 'search_results');
|
||||
$oUIBlockForm->AddSubBlock($oUIBlock);
|
||||
}
|
||||
|
||||
$oP->AddUiBlock($oUIBlockForm);
|
||||
} else {
|
||||
$oBlock->Display($oP, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -738,7 +738,7 @@ abstract class Controller extends AbstractController
|
||||
*
|
||||
* @param string $sCode Code of the tab
|
||||
*/
|
||||
public function AddAjaxTab(string $sCode, string $sURL, bool $bCache = true, string $sLabel = null): void
|
||||
public function AddAjaxTab(string $sCode, string $sURL, bool $bCache = true, ?string $sLabel = null): void
|
||||
{
|
||||
if (is_null($sLabel)) {
|
||||
$sLabel = Dict::S($sCode);
|
||||
|
||||
@@ -340,8 +340,10 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
$aClassAliases = $oSet->GetFilter()->GetSelectedClasses();
|
||||
$aAuthorizedClasses = [];
|
||||
foreach ($aClassAliases as $sAlias => $sClassName) {
|
||||
if ((UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $oSet) != UR_ALLOWED_NO) &&
|
||||
((count($aDisplayAliases) == 0) || (in_array($sAlias, $aDisplayAliases)))) {
|
||||
if (
|
||||
((UserRights::IsActionAllowed($sClassName, UR_ACTION_READ, $oSet) !== UR_ALLOWED_NO) || ($aExtraParams['display_unauthorized_objects'] ?? false) === true)
|
||||
&& ((count($aDisplayAliases) == 0) || (in_array($sAlias, $aDisplayAliases)))
|
||||
) {
|
||||
$aAuthorizedClasses[$sAlias] = $sClassName;
|
||||
}
|
||||
}
|
||||
@@ -520,6 +522,14 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
if ($aData['checked']) {
|
||||
if ($sAttCode == '_key_') {
|
||||
if ($bViewLink) {
|
||||
$sRenderLink = "return row['".$sClassAlias."/hyperlink'];";
|
||||
if (
|
||||
($aExtraParams['display_unauthorized_objects'] ?? false) === true
|
||||
&& UserRights::IsActionAllowed($sClassName, UR_ACTION_READ) !== UR_ALLOWED_YES
|
||||
) {
|
||||
$sRenderLink = "return row['".$sClassAlias."/friendlyname'];";
|
||||
}
|
||||
|
||||
$aColumnDefinition[] = [
|
||||
'description' => $aData['label'],
|
||||
'object_class' => $sClassName,
|
||||
@@ -527,7 +537,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
'attribute_code' => $sAttCode,
|
||||
'attribute_type' => '_key_',
|
||||
'attribute_label' => MetaModel::GetName($sClassName),
|
||||
'render' => "return row['".$sClassAlias."/hyperlink'];",
|
||||
'render' => $sRenderLink,
|
||||
];
|
||||
|
||||
}
|
||||
@@ -952,6 +962,8 @@ JS;
|
||||
/** Handler to call when trying to create a new object in modal */
|
||||
'creation_disallowed',
|
||||
/** Don't provide the standard object creation feature */
|
||||
'display_unauthorized_objects',
|
||||
/** bool Display objects for which the user has no read rights */
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class TurboForm extends UIContentBlock
|
||||
protected ?string $sAction;
|
||||
private FormView $oFormView;
|
||||
|
||||
public function __construct(FormView $oFormView, string $sId = null)
|
||||
public function __construct(FormView $oFormView, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->oFormView = $oFormView;
|
||||
|
||||
@@ -36,7 +36,7 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboForm An HTML form in which you can add UIBlocks
|
||||
*/
|
||||
public static function MakeStandard(FormView $oFormView, string $sAction = null, string $sId = null): TurboForm
|
||||
public static function MakeStandard(FormView $oFormView, ?string $sAction = null, ?string $sId = null): TurboForm
|
||||
{
|
||||
$oTurboForm = new TurboForm($oFormView, $sId);
|
||||
if (!is_null($sAction)) {
|
||||
@@ -57,7 +57,7 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboForm
|
||||
* @throws \Combodo\iTop\Forms\Block\FormBlockException
|
||||
*/
|
||||
public static function MakeForDashletConfiguration(string $sDashletId, array $aData = [], string $sId = null): TurboForm
|
||||
public static function MakeForDashletConfiguration(string $sDashletId, array $aData = [], ?string $sId = null): TurboForm
|
||||
{
|
||||
$oBlockForm = FormBlockService::GetInstance()->GetFormBlockById($sDashletId, 'Dashlet');
|
||||
$oController = new FormsController();
|
||||
|
||||
@@ -16,7 +16,7 @@ class TurboStream extends UIContentBlock
|
||||
private string $sTarget;
|
||||
private string $sAction;
|
||||
|
||||
public function __construct(string $sTarget, string $sAction, string $sId = null)
|
||||
public function __construct(string $sTarget, string $sAction, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->sTarget = $sTarget;
|
||||
|
||||
@@ -31,7 +31,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
|
||||
*/
|
||||
public static function MakeUpdate(string $sTarget, string $sId = null): TurboStream
|
||||
public static function MakeUpdate(string $sTarget, ?string $sId = null): TurboStream
|
||||
{
|
||||
return new TurboStream($sTarget, 'update', $sId);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
|
||||
*/
|
||||
public static function MakeReplace(string $sTarget, string $sId = null): TurboStream
|
||||
public static function MakeReplace(string $sTarget, ?string $sId = null): TurboStream
|
||||
{
|
||||
return new TurboStream($sTarget, 'replace', $sId);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
|
||||
*/
|
||||
public static function MakePrepend(string $sTarget, string $sId = null): TurboStream
|
||||
public static function MakePrepend(string $sTarget, ?string $sId = null): TurboStream
|
||||
{
|
||||
return new TurboStream($sTarget, 'prepend', $sId);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
|
||||
*/
|
||||
public static function MakeAppend(string $sTarget, string $sId = null): TurboStream
|
||||
public static function MakeAppend(string $sTarget, ?string $sId = null): TurboStream
|
||||
{
|
||||
return new TurboStream($sTarget, 'append', $sId);
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ class ActivityPanelFactory
|
||||
if (false === empty($aRelatedTriggersIDs)) {
|
||||
// - Prepare query to retrieve events
|
||||
$oNotifEventsSearch = DBObjectSearch::FromOQL('SELECT EN FROM EventNotification AS EN JOIN Action AS A ON EN.action_id = A.id WHERE EN.trigger_id IN (:triggers_ids) AND EN.object_id = :object_id');
|
||||
$oNotifEventsSearch->AllowAllData();
|
||||
$oNotifEventsSet = new DBObjectSet($oNotifEventsSearch, ['id' => false], ['triggers_ids' => $aRelatedTriggersIDs, 'object_id' => $sObjId]);
|
||||
$oNotifEventsSet->SetLimit(MetaModel::GetConfig()->Get('max_history_length'));
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ class AjaxPage extends WebPage implements iTabbedPage
|
||||
'aJsInlineLive' => $this->a_scripts,
|
||||
'aJsInlineOnDomReady' => $this->GetReadyScripts(),
|
||||
'aJsInlineOnInit' => $this->a_init_scripts,
|
||||
'sBodyDataGuiType' => static::BODY_DATA_GUI_TYPE,
|
||||
'bEscapeContent' => ($this->sContentType == 'text/html') && ($this->sContentDisposition == 'inline'),
|
||||
// TODO 3.0.0: TEMP, used while developping, remove it.
|
||||
'sSanitizedContent' => utils::FilterXSS($this->s_content),
|
||||
|
||||
@@ -51,7 +51,7 @@ class ErrorPage extends NiceWebPage
|
||||
$this->log_warning($sText);
|
||||
}
|
||||
|
||||
public function error($sText, \Throwable $oException = null)
|
||||
public function error($sText, ?\Throwable $oException = null)
|
||||
{
|
||||
$this->add("<div class=\"message message-error\">$sText</div>");
|
||||
if (utils::IsEasterEggAllowed()) {
|
||||
|
||||
@@ -172,6 +172,7 @@ class UnauthenticatedWebPage extends NiceWebPage
|
||||
'aJsInlineLive' => $this->a_scripts,
|
||||
'aJsInlineOnDomReady' => $this->GetReadyScripts(),
|
||||
'aJsInlineOnInit' => $this->a_init_scripts,
|
||||
'sBodyDataGuiType' => static::BODY_DATA_GUI_TYPE,
|
||||
|
||||
// TODO 3.0.0: TEMP, used while developing, remove it.
|
||||
'sCapturedOutput' => utils::FilterXSS($s_captured_output),
|
||||
|
||||
@@ -152,6 +152,8 @@ class WebPage implements Page
|
||||
*/
|
||||
public const DEFAULT_PAGE_TEMPLATE_REL_PATH = 'pages/backoffice/webpage/layout';
|
||||
|
||||
public const BODY_DATA_GUI_TYPE = 'backoffice';
|
||||
|
||||
protected $s_title;
|
||||
protected $s_content;
|
||||
protected $s_deferred_content;
|
||||
@@ -1566,6 +1568,7 @@ JS;
|
||||
'aJsInlineLive' => $this->a_scripts,
|
||||
'aJsInlineOnDomReady' => $this->GetReadyScripts(),
|
||||
'aJsInlineOnInit' => $this->a_init_scripts,
|
||||
'sBodyDataGuiType' => static::BODY_DATA_GUI_TYPE,
|
||||
|
||||
// TODO 3.0.0: TEMP, used while developing, remove it.
|
||||
'sCapturedOutput' => utils::FilterXSS($s_captured_output),
|
||||
|
||||
@@ -929,6 +929,7 @@ HTML;
|
||||
'aJsInlineOnInit' => $this->a_init_scripts,
|
||||
'aJsInlineOnDomReady' => $this->GetReadyScripts(),
|
||||
'aJsInlineLive' => $this->a_scripts,
|
||||
'sBodyDataGuiType' => static::BODY_DATA_GUI_TYPE,
|
||||
// TODO 3.0.0: TEMP, used while developping, remove it.
|
||||
'sSanitizedContent' => utils::FilterXSS($this->s_content),
|
||||
'sDeferredContent' => utils::FilterXSS($this->s_deferred_content),
|
||||
|
||||
@@ -42,6 +42,7 @@ use RunTimeEnvironment;
|
||||
use ScalarExpression;
|
||||
use SetupUtils;
|
||||
use UILinksWidget;
|
||||
use UserRights;
|
||||
use utils;
|
||||
use WizardHelper;
|
||||
|
||||
@@ -71,6 +72,15 @@ class AjaxRenderController
|
||||
$bShowObsoleteData = utils::ShowObsoleteData();
|
||||
}
|
||||
$oSet->SetShowObsoleteData($bShowObsoleteData);
|
||||
|
||||
// N°8606 : Check user permissions on the main class
|
||||
if (
|
||||
UserRights::IsActionAllowed($oSet->GetClass(), UR_ACTION_READ, $oSet) !== UR_ALLOWED_YES
|
||||
&& ($aExtraParams['display_unauthorized_objects'] ?? false) === false
|
||||
) {
|
||||
throw new Exception(Dict::Format('UI:Error:ReadNotAllowedOn_Class', $oSet->GetClass()));
|
||||
}
|
||||
|
||||
$iCount = 0;
|
||||
if (isset($aExtraParams['object_count'])) {
|
||||
$iCount = $aExtraParams['object_count'];
|
||||
@@ -101,6 +111,14 @@ class AjaxRenderController
|
||||
continue;
|
||||
}
|
||||
|
||||
// N°8606 : Check user permissions on the current class
|
||||
if (
|
||||
UserRights::IsActionAllowed($sClass, UR_ACTION_READ, $oSet) !== UR_ALLOWED_YES
|
||||
&& ($aExtraParams['display_unauthorized_objects'] ?? false) === false
|
||||
) {
|
||||
throw new Exception(Dict::Format('UI:Error:ReadNotAllowedOn_Class', $sClass));
|
||||
}
|
||||
|
||||
foreach ($aColumnsLoad[$sAlias] as $sAttCode) {
|
||||
$aObj[$sAlias."/".$sAttCode] = $aObject[$sAlias]->GetAsHTML($sAttCode);
|
||||
$bExcludeRawValue = false;
|
||||
|
||||
@@ -26,6 +26,7 @@ use CoreException;
|
||||
use DBObjectSearch;
|
||||
use DBObjectSet;
|
||||
use Dict;
|
||||
use EventNotificationNewsroom;
|
||||
use MetaModel;
|
||||
use SecurityException;
|
||||
use UserRights;
|
||||
@@ -361,6 +362,7 @@ JS
|
||||
// Search for all notifications for the current user
|
||||
$oSearch = DBObjectSearch::FromOQL('SELECT EventNotificationNewsroom');
|
||||
$oSearch->AddCondition('contact_id', UserRights::GetContactId(), '=');
|
||||
$oSearch->AllowAllData();
|
||||
$oSet = new DBObjectSet($oSearch, ['read' => true, 'date' => false], []);
|
||||
|
||||
// Add main content block
|
||||
@@ -529,6 +531,7 @@ JS
|
||||
|
||||
if (utils::IsNotNullOrEmptyString($iContactId)) {
|
||||
$oSearch = DBObjectSearch::FromOQL('SELECT EventNotificationNewsroom WHERE contact_id = :contact_id AND read = "no"');
|
||||
$oSearch->AllowAllData();
|
||||
$oSet = new DBObjectSet($oSearch, [], ['contact_id' => $iContactId]);
|
||||
|
||||
while ($oMessage = $oSet->Fetch()) {
|
||||
@@ -542,7 +545,7 @@ $sMessage
|
||||
HTML;
|
||||
|
||||
$sIcon = $oMessage->Get('icon') !== null ?
|
||||
$oMessage->Get('icon')->GetDisplayURL('EventNotificationNewsroom', $oMessage->GetKey(), 'icon') :
|
||||
$oMessage->Get('icon')->GetDisplayURL(EventNotificationNewsroom::class, $oMessage->GetKey(), 'icon') :
|
||||
Branding::GetCompactMainLogoAbsoluteUrl();
|
||||
$aMessages[] = [
|
||||
'id' => $oMessage->GetKey(),
|
||||
@@ -579,6 +582,7 @@ HTML;
|
||||
|
||||
if (utils::IsNotNullOrEmptyString($iContactId)) {
|
||||
$oSearch = DBObjectSearch::FromOQL('SELECT EventNotificationNewsroom WHERE contact_id = :contact_id AND read = "no"');
|
||||
$oSearch->AllowAllData();
|
||||
$oSet = new DBObjectSet($oSearch, [], ['contact_id' => $iContactId]);
|
||||
|
||||
while ($oEvent = $oSet->Fetch()) {
|
||||
@@ -608,7 +612,7 @@ HTML;
|
||||
$sEventId = utils::ReadParam('event_id', 0);
|
||||
if ($sEventId > 0) {
|
||||
try {
|
||||
$oEvent = MetaModel::GetObject('EventNotificationNewsroom', $sEventId);
|
||||
$oEvent = MetaModel::GetObject(EventNotificationNewsroom::class, $sEventId, true, true);
|
||||
if ($oEvent !== null && $oEvent->Get('contact_id') === UserRights::GetContactId()) {
|
||||
$oEvent->Set('read', 'yes');
|
||||
$oEvent->SetCurrentDate('read_date');
|
||||
|
||||
@@ -67,12 +67,12 @@ class AttributeBlob extends AttributeDefinition
|
||||
return true;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return new ormDocument('', '', '');
|
||||
}
|
||||
|
||||
public function IsNullAllowed(DBObject $oHostObject = null)
|
||||
public function IsNullAllowed(?DBObject $oHostObject = null)
|
||||
{
|
||||
return $this->GetOptional("is_null_allowed", false);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class AttributeCaseLog extends AttributeLongText
|
||||
}
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return new ormCaseLog();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class AttributeClass extends AttributeString
|
||||
parent::__construct($sCode, $aParams);
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
$sDefault = parent::GetDefaultValue($oHostObject);
|
||||
if (!$this->IsNullAllowed() && $this->IsNull($sDefault)) {
|
||||
|
||||
@@ -61,7 +61,7 @@ class AttributeCustomFields extends AttributeDefinition
|
||||
return false;
|
||||
} // See ReadValue...
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return new ormCustomFieldsValue($oHostObject, $this->GetCode());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class AttributeDBField extends AttributeDBFieldVoid
|
||||
return array_merge(parent::ListExpectedParams(), ["default_value", "is_null_allowed"]);
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return $this->MakeRealValue($this->Get("default_value"), $oHostObject);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
|
||||
return $this->Get("sql");
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return $this->MakeRealValue("", $oHostObject);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class AttributeDashboard extends AttributeDefinition
|
||||
return "";
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
return $iUnixSeconds;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
$sDefaultValue = $this->Get('default_value');
|
||||
if (utils::IsNotNullOrEmptyString($sDefaultValue)) {
|
||||
|
||||
@@ -875,7 +875,7 @@ abstract class AttributeDefinition
|
||||
return null;
|
||||
}
|
||||
|
||||
abstract public function GetDefaultValue(DBObject $oHostObject = null);
|
||||
abstract public function GetDefaultValue(?DBObject $oHostObject = null);
|
||||
|
||||
//
|
||||
// To be overloaded in subclasses
|
||||
|
||||
@@ -326,7 +326,7 @@ class AttributeExternalField extends AttributeDefinition
|
||||
return $oExtAttDef->GetSQLExpr();
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
$oExtAttDef = $this->GetExtAttDef();
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
|
||||
return $this->GetOptional('display_style', 'select');
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class AttributeFinalClass extends AttributeString
|
||||
$this->m_sValue = $sValue;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return $this->m_sValue;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class AttributeFriendlyName extends AttributeDefinition
|
||||
$this->m_sValue = $sValue;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return $this->m_sValue;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class AttributeImage extends AttributeBlob
|
||||
return $oDoc;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return new ormDocument('', '', '');
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ class AttributeLinkedSet extends AttributeDefinition
|
||||
* @throws CoreException
|
||||
* @throws CoreWarning
|
||||
*/
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
if ($oHostObject === null) {
|
||||
return null;
|
||||
|
||||
@@ -52,7 +52,7 @@ class AttributeObjectKey extends AttributeDBFieldVoid
|
||||
return "INT(11)".($bFullSpec ? " DEFAULT 0" : "");
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class AttributeObsolescenceFlag extends AttributeBoolean
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return $this->MakeRealValue(false, $oHostObject);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
|
||||
return true;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class AttributeRedundancySettings extends AttributeDBField
|
||||
return 20;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
$sRet = 'disabled';
|
||||
if ($this->Get('enabled')) {
|
||||
|
||||
@@ -131,7 +131,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
|
||||
return true;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
return true;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return $this->NewStopWatch();
|
||||
}
|
||||
@@ -578,7 +578,10 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
switch ($sThresholdCode) {
|
||||
case 'deadline':
|
||||
if ($value) {
|
||||
if (is_int($value)) {
|
||||
if (is_numeric($value)) {
|
||||
if (!is_int($value)) {
|
||||
$value = intval($value);
|
||||
}
|
||||
$sDate = date(AttributeDateTime::GetInternalFormat(), $value);
|
||||
$sRet = AttributeDeadline::FormatDeadline($sDate);
|
||||
} else {
|
||||
|
||||
@@ -117,7 +117,7 @@ class AttributeSubItem extends AttributeDefinition
|
||||
return false;
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ class AttributeTagSet extends AttributeSet
|
||||
return new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode(), $this->GetMaxItems());
|
||||
}
|
||||
|
||||
public function GetDefaultValue(DBObject $oHostObject = null)
|
||||
public function GetDefaultValue(?DBObject $oHostObject = null)
|
||||
{
|
||||
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode(), $this->GetMaxItems());
|
||||
$oTagSet->SetValues([]);
|
||||
|
||||
@@ -253,7 +253,7 @@ abstract class AbstractFormBlock implements IFormBlock
|
||||
* @throws FormBlockIOException
|
||||
* @throws RegisterException
|
||||
*/
|
||||
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, AbstractConverter $oConverter = null): AbstractFormBlock
|
||||
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, ?AbstractConverter $oConverter = null): AbstractFormBlock
|
||||
{
|
||||
$this->oIORegister->AddOutput($sName, $sType, $bIsArray, $oConverter);
|
||||
return $this;
|
||||
@@ -413,7 +413,7 @@ abstract class AbstractFormBlock implements IFormBlock
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsInputsDataReady(string $sType = null): bool
|
||||
public function IsInputsDataReady(?string $sType = null): bool
|
||||
{
|
||||
return $this->oIORegister->IsInputsDataReady($sType);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ abstract class AbstractTypeFormBlock extends AbstractFormBlock
|
||||
* @return bool
|
||||
* @throws FormBlockException
|
||||
*/
|
||||
public function IsVisible(string $sEventType = null): bool
|
||||
public function IsVisible(?string $sEventType = null): bool
|
||||
{
|
||||
$oInput = $this->GetInput(self::INPUT_VISIBLE);
|
||||
if (!$oInput->IsBound()) {
|
||||
@@ -68,7 +68,7 @@ abstract class AbstractTypeFormBlock extends AbstractFormBlock
|
||||
/**
|
||||
* @return true
|
||||
*/
|
||||
public function AllowAdd(string $sEventType = null): bool
|
||||
public function AllowAdd(?string $sEventType = null): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ class FormBlockService
|
||||
{
|
||||
private static FormBlockService $oInstance;
|
||||
|
||||
protected function __construct(ModelReflection $oModelReflection = null)
|
||||
protected function __construct(?ModelReflection $oModelReflection = null)
|
||||
{
|
||||
ServiceLocator::GetInstance()->RegisterService('ModelReflection', $oModelReflection ?? new ModelReflectionRuntime());
|
||||
}
|
||||
|
||||
final public static function GetInstance(ModelReflection $oModelReflection = null): FormBlockService
|
||||
final public static function GetInstance(?ModelReflection $oModelReflection = null): FormBlockService
|
||||
{
|
||||
if (!isset(static::$oInstance)) {
|
||||
static::$oInstance = new FormBlockService($oModelReflection);
|
||||
|
||||
@@ -161,7 +161,7 @@ class DependencyHandler
|
||||
* @return void
|
||||
* @throws FormBlockException
|
||||
*/
|
||||
private function CheckDependencies(FormInterface|FormBuilderInterface $oForm, string $sOutputBlock = null, string $sEventType = null): void
|
||||
private function CheckDependencies(FormInterface|FormBuilderInterface $oForm, ?string $sOutputBlock = null, ?string $sEventType = null): void
|
||||
{
|
||||
$aImpactedBlocks = $this->aDependentBlocks;
|
||||
if ($sOutputBlock !== null) {
|
||||
|
||||
@@ -171,7 +171,7 @@ class DependencyMap
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function GetBlocksImpactedBy(string $sBlockName, callable $oFilter = null): ?array
|
||||
public function GetBlocksImpactedBy(string $sBlockName, ?callable $oFilter = null): ?array
|
||||
{
|
||||
if (!array_key_exists($sBlockName, $this->aBlocksImpactedBy)) {
|
||||
return null;
|
||||
|
||||
@@ -164,7 +164,7 @@ class AbstractFormIO
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetValue(string $sEventType = null): mixed
|
||||
public function GetValue(?string $sEventType = null): mixed
|
||||
{
|
||||
if ($sEventType === null) {
|
||||
return $this->Value();
|
||||
@@ -190,7 +190,7 @@ class AbstractFormIO
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function HasEventValue(string $sEventType = null): bool
|
||||
public function HasEventValue(?string $sEventType = null): bool
|
||||
{
|
||||
if ($sEventType === null) {
|
||||
return $this->HasValue();
|
||||
|
||||
@@ -28,7 +28,7 @@ class FormInput extends AbstractFormIO
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsEventDataReady(string $sEventType = null): bool
|
||||
public function IsEventDataReady(?string $sEventType = null): bool
|
||||
{
|
||||
return $this->HasEventValue($sEventType);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class FormOutput extends AbstractFormIO
|
||||
*
|
||||
* @throws FormBlockIOException
|
||||
*/
|
||||
public function __construct(string $sName, string $sType, bool $bIsArray = false, AbstractConverter $oConverter = null)
|
||||
public function __construct(string $sName, string $sType, bool $bIsArray = false, ?AbstractConverter $oConverter = null)
|
||||
{
|
||||
parent::__construct($sName, $sType, $bIsArray);
|
||||
$this->oConverter = $oConverter;
|
||||
|
||||
@@ -135,7 +135,7 @@ class IORegister
|
||||
* @throws FormBlockIOException
|
||||
* @throws RegisterException
|
||||
*/
|
||||
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, AbstractConverter $oConverter = null): void
|
||||
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, ?AbstractConverter $oConverter = null): void
|
||||
{
|
||||
$oFormOutput = new FormOutput($sName, $sType, $bIsArray, $oConverter);
|
||||
$oFormOutput->SetOwnerBlock($this->oFormBlock);
|
||||
@@ -349,7 +349,7 @@ class IORegister
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsInputsDataReady(string $sType = null): bool
|
||||
public function IsInputsDataReady(?string $sType = null): bool
|
||||
{
|
||||
foreach ($this->aInputs as $oFormInput) {
|
||||
if ($oFormInput->IsBound()) {
|
||||
|
||||
@@ -32,18 +32,14 @@ class AttributeExist extends Constraint
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|null $sOqlPropertyPath
|
||||
* @param string $sOqlPropertyPath
|
||||
* @param string|null $sFilter
|
||||
* @param array $aOptions
|
||||
* @param array|null $aGroups
|
||||
* @param mixed|null $oPayload
|
||||
*/
|
||||
public function __construct(string $sOqlPropertyPath = null, string $sFilter = null, array $aOptions = [], ?array $aGroups = null, mixed $oPayload = null)
|
||||
public function __construct(string $sOqlPropertyPath, ?string $sFilter = null, array $aOptions = [], ?array $aGroups = null, mixed $oPayload = null)
|
||||
{
|
||||
if ($sOqlPropertyPath === null) {
|
||||
throw new InvalidArgumentException('The argument "sOqlPropertyPath" must be set.');
|
||||
}
|
||||
|
||||
// Merge argument into options array
|
||||
$aOptions = array_merge([
|
||||
'sOqlPropertyPath' => $sOqlPropertyPath,
|
||||
|
||||
@@ -18,7 +18,7 @@ use utils;
|
||||
*/
|
||||
class PropertyTypeDesign extends DesignDocument
|
||||
{
|
||||
public function __construct(string $sDesignSourceId = null, string $sType = 'Default')
|
||||
public function __construct(?string $sDesignSourceId = null, string $sType = 'Default')
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ class NotificationsRepository
|
||||
protected function PrepareSearchForNotificationsByContact(int $iContactId, array $aNotificationIds = []): DBSearch
|
||||
{
|
||||
$oSearch = DBObjectSearch::FromOQL("SELECT EventNotificationNewsroom WHERE contact_id = :contact_id");
|
||||
$oSearch->AllowAllData();
|
||||
$aParams = [
|
||||
"contact_id" => $iContactId,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user