Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support php 8.2.0 #17280

Open
wants to merge 6 commits into
base: developer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Purifier.php
Expand Up @@ -591,7 +591,7 @@ public static function bool($value)
*/
public static function encodeHtml($string)
{
return htmlspecialchars($string, ENT_QUOTES, static::$defaultCharset);
return htmlspecialchars($string ?? '', ENT_QUOTES, static::$defaultCharset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

}

/**
Expand Down
6 changes: 4 additions & 2 deletions layouts/basic/modules/Settings/Menu/types/Module.tpl
Expand Up @@ -18,14 +18,16 @@
</div>
{include file=\App\Layout::getTemplatePath('fields/Newwindow.tpl', $QUALIFIED_MODULE)}
{include file=\App\Layout::getTemplatePath('fields/Hotkey.tpl', $QUALIFIED_MODULE)}
{assign var=FILTERS value=explode(',',$RECORD->get('filters'))}
{if !$RECORD->isEmpty('filters')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

{assign var=FILTERS value=explode(',',$RECORD->get('filters'))}
{/if}
<div class="form-group row">
<label class="col-md-4 col-form-label">{\App\Language::translate('LBL_AVAILABLE_FILTERS', $QUALIFIED_MODULE)}:</label>
<div class="col-md-7">
<div class="input-group">
<select name="filters" multiple class="select2 type form-control">
{foreach from=$MODULE_MODEL->getCustomViewList() item=ITEM}
<option value="{$ITEM.cvid}" {if $RECORD && in_array($ITEM['cvid'],$FILTERS)} selected="" {/if} data-tabid="{$ITEM['tabid']}">{\App\Language::translate($ITEM['viewname'], $ITEM['entitytype'])}</option>
<option value="{$ITEM.cvid}" {if isset($FILTERS) && in_array($ITEM['cvid'],$FILTERS)} selected="" {/if} data-tabid="{$ITEM['tabid']}">{\App\Language::translate($ITEM['viewname'], $ITEM['entitytype'])}</option>
{/foreach}
</select>
<span class="input-group-append">
Expand Down
Expand Up @@ -38,7 +38,7 @@
<span class="actionImages">
{foreach item=RECORD_LINK from=$LISTVIEW_ENTRY->getRecordLinks()}
{assign var="RECORD_LINK_URL" value=$RECORD_LINK->getUrl()}
<a class="{if $LISTVIEW_ENTRY->get('access') eq '0' && $RECORD_LINK->get('linklabel') eq 'LBL_DELETE'} d-none {/if} {$RECORD_LINK->getClassName()}" {if stripos($RECORD_LINK_URL, 'javascript:')===0} onclick="{substr($RECORD_LINK_URL, strlen("javascript"))};if (event.stopPropagation){ldelim}
<a class="{if $LISTVIEW_ENTRY->get('access') eq '0' && $RECORD_LINK->get('linklabel') eq 'LBL_DELETE'} d-none {/if} {$RECORD_LINK->getClassName()}" {if stripos($RECORD_LINK_URL, 'javascript:')===0} onclick="{substr($RECORD_LINK_URL, strlen("javascript:"))};if (event.stopPropagation){ldelim}
event.stopPropagation();{rdelim} else{ldelim}
event.cancelBubble = true;{rdelim}" {else} href='{$RECORD_LINK_URL}' {/if}>
<span class="{$RECORD_LINK->getIcon()}" title="{\App\Language::translate($RECORD_LINK->getLabel(), $QUALIFIED_MODULE)}"></span>
Expand Down
64 changes: 34 additions & 30 deletions modules/Settings/SharingAccess/models/Rule.php
Expand Up @@ -118,6 +118,10 @@ class Settings_SharingAccess_Rule_Model extends \App\Base
],
],
];
/** @var Vtiger_Module_Model Module model. */
private $module;
/** @var array Details of access rules to the module. */
private $ruleDetails;

/**
* Function to get the Id of the Sharing Access Rule.
Expand Down Expand Up @@ -154,36 +158,6 @@ public function getModule()
return $this->module;
}

/**
* Function to get rules.
*
* @return array
*/
protected function getRuleComponents()
{
if (!isset($this->rule_details) && $this->getId()) {
$relationTypeComponents = explode('::', $this->get('relationtype'));
$sourceType = $relationTypeComponents[0];
$targetType = $relationTypeComponents[1];
$tableColumnInfo = self::$dataShareTableColArr[$sourceType][$targetType];
$tableName = $tableColumnInfo['table'];
$sourceColumnName = $tableColumnInfo['source_id'];
$targetColumnName = $tableColumnInfo['target_id'];
$row = (new App\Db\Query())->from($tableName)->where(['shareid' => $this->getId()])
->one();
if ($row) {
$sourceMemberType = self::$ruleMemberToRelationMapping[$sourceType];
$qualifiedSourceId = Settings_SharingAccess_RuleMember_Model::getQualifiedId($sourceMemberType, $row[$sourceColumnName]);
$this->rule_details['source_member'] = Settings_SharingAccess_RuleMember_Model::getInstance($qualifiedSourceId);
$targetMemberType = self::$ruleMemberToRelationMapping[$targetType];
$qualifiedTargetId = Settings_SharingAccess_RuleMember_Model::getQualifiedId($targetMemberType, $row[$targetColumnName]);
$this->rule_details['target_member'] = Settings_SharingAccess_RuleMember_Model::getInstance($qualifiedTargetId);
$this->rule_details['permission'] = $row['permission'];
}
}
return $this->rule_details;
}

public function getSourceMember()
{
if ($this->getId()) {
Expand Down Expand Up @@ -436,4 +410,34 @@ public static function getAllByModule($moduleModel)

return $ruleModels;
}

/**
* Function to get rules.
*
* @return array
*/
protected function getRuleComponents()
{
if (!isset($this->ruleDetails) && $this->getId()) {
$relationTypeComponents = explode('::', $this->get('relationtype'));
$sourceType = $relationTypeComponents[0];
$targetType = $relationTypeComponents[1];
$tableColumnInfo = self::$dataShareTableColArr[$sourceType][$targetType];
$tableName = $tableColumnInfo['table'];
$sourceColumnName = $tableColumnInfo['source_id'];
$targetColumnName = $tableColumnInfo['target_id'];
$row = (new App\Db\Query())->from($tableName)->where(['shareid' => $this->getId()])
->one();
if ($row) {
$sourceMemberType = self::$ruleMemberToRelationMapping[$sourceType];
$qualifiedSourceId = Settings_SharingAccess_RuleMember_Model::getQualifiedId($sourceMemberType, $row[$sourceColumnName]);
$this->ruleDetails['source_member'] = Settings_SharingAccess_RuleMember_Model::getInstance($qualifiedSourceId);
$targetMemberType = self::$ruleMemberToRelationMapping[$targetType];
$qualifiedTargetId = Settings_SharingAccess_RuleMember_Model::getQualifiedId($targetMemberType, $row[$targetColumnName]);
$this->ruleDetails['target_member'] = Settings_SharingAccess_RuleMember_Model::getInstance($qualifiedTargetId);
$this->ruleDetails['permission'] = $row['permission'];
}
}
return $this->ruleDetails;
}
}
64 changes: 32 additions & 32 deletions modules/Settings/TreesManager/models/Record.php
Expand Up @@ -10,6 +10,9 @@
*/
class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model
{
/** @var string[] Fields to edit */
public $editFields = ['name', 'tabid', 'share'];

/**
* Function to get the Id.
*
Expand Down Expand Up @@ -70,7 +73,7 @@ public function getEditViewUrl()
*/
public function getDeleteUrl()
{
return '?module=TreesManager&parent=Settings&action=Delete&record=' . $this->getId();
return 'index.php?module=TreesManager&parent=Settings&action=Delete&record=' . $this->getId();
}

/**
Expand Down Expand Up @@ -108,7 +111,7 @@ public function getRecordLinks(): array
[
'linktype' => 'LISTVIEWRECORD',
'linklabel' => 'LBL_DELETE',
'linkurl' => "javascript:Settings_Vtiger_List_Js.triggerDelete(event,'" . $this->getDeleteUrl() . "');",
'linkurl' => "javascript:Settings_Vtiger_List_Js.triggerDelete(event,'" . $this->getDeleteUrl() . "')",
'linkicon' => 'fas fa-trash-alt',
'linkclass' => 'btn btn-sm btn-danger text-white',
],
Expand Down Expand Up @@ -303,33 +306,6 @@ public function replaceValue($tree, $templateId)
$dataReader->close();
}

/**
* Update category multipicklist.
*
* @param array $tree
* @param string $tableName
* @param string $columnName
*
* @throws \yii\db\Exception
*/
private function updateCategoryMultipicklist(array $tree, string $tableName, string $columnName)
{
$dbCommand = \App\Db::getInstance()->createCommand();
foreach ($tree as $treeRow) {
$query = (new \App\Db\Query())->from($tableName);
$query->orWhere(['like', $columnName, ",T{$treeRow['old'][0]},"]);
$dataReaderTree = $query->createCommand()->query();
while ($rowTree = $dataReaderTree->read()) {
$dbCommand->update(
$tableName,
[$columnName => str_replace(",T{$treeRow['old'][0]},", ",T{$treeRow['new'][0]},", $rowTree[$columnName])],
[$columnName => $rowTree[$columnName]]
)->execute();
}
$dataReaderTree->close();
}
}

/**
* Function to delete the role.
*/
Expand Down Expand Up @@ -440,9 +416,6 @@ public function clearCache(): void
\App\Cache::delete('TreeValuesById', $this->getId());
}

/** @var string[] Fields to edit */
public $editFields = ['name', 'tabid', 'share'];

/**
* Get structure fields.
*
Expand Down Expand Up @@ -645,4 +618,31 @@ public function addValue(string $label, string $parent = ''): string
$this->set('lastId', $last + 1);
return $treeID;
}

/**
* Update category multipicklist.
*
* @param array $tree
* @param string $tableName
* @param string $columnName
*
* @throws \yii\db\Exception
*/
private function updateCategoryMultipicklist(array $tree, string $tableName, string $columnName)
{
$dbCommand = \App\Db::getInstance()->createCommand();
foreach ($tree as $treeRow) {
$query = (new \App\Db\Query())->from($tableName);
$query->orWhere(['like', $columnName, ",T{$treeRow['old'][0]},"]);
$dataReaderTree = $query->createCommand()->query();
while ($rowTree = $dataReaderTree->read()) {
$dbCommand->update(
$tableName,
[$columnName => str_replace(",T{$treeRow['old'][0]},", ",T{$treeRow['new'][0]},", $rowTree[$columnName])],
[$columnName => $rowTree[$columnName]]
)->execute();
}
$dataReaderTree->close();
}
}
}
60 changes: 31 additions & 29 deletions modules/Vtiger/models/TreeInventoryModal.php
Expand Up @@ -19,6 +19,37 @@ class Vtiger_TreeInventoryModal_Model extends Vtiger_TreeCategoryModal_Model
* @var bool Auto register events
*/
public $autoRegisterEvents = false;
/** @var int Last id in tree. */
private $lastTreeId;

/** {@inheritdoc} */
public static function getInstance(Vtiger_Module_Model $moduleModel)
{
$moduleName = $moduleModel->get('name');
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'TreeInventoryModal', $moduleName);
$instance = new $modelClassName();
$instance->set('module', $moduleModel)->set('moduleName', $moduleName);
return $instance;
}

/**
* Retrieves all records and categories.
*
* @return array
*/
public function getTreeData()
{
$treeData = [];
$treeList = $this->getTreeList();
$records = $this->getRecords();
foreach ($records as $tree) {
while (isset($treeList[$tree['parent']]) && !\in_array($treeList[$tree['parent']], $treeData)) {
$tree = $treeList[$tree['parent']];
$treeData[] = $tree;
}
}
return array_merge($treeData, $records);
}

/**
* Creates a tree for records.
Expand Down Expand Up @@ -84,33 +115,4 @@ private function getTreeList()
$this->lastTreeId = $lastId;
return $trees;
}

/** {@inheritdoc} */
public static function getInstance(Vtiger_Module_Model $moduleModel)
{
$moduleName = $moduleModel->get('name');
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'TreeInventoryModal', $moduleName);
$instance = new $modelClassName();
$instance->set('module', $moduleModel)->set('moduleName', $moduleName);
return $instance;
}

/**
* Retrieves all records and categories.
*
* @return array
*/
public function getTreeData()
{
$treeData = [];
$treeList = $this->getTreeList();
$records = $this->getRecords();
foreach ($records as $tree) {
while (isset($treeList[$tree['parent']]) && !\in_array($treeList[$tree['parent']], $treeData)) {
$tree = $treeList[$tree['parent']];
$treeData[] = $tree;
}
}
return array_merge($treeData, $records);
}
}
43 changes: 26 additions & 17 deletions modules/com_vtiger_workflow/tasks/VTCreateEventTask.php
Expand Up @@ -106,21 +106,6 @@ public function doTask($recordModel)
}
}

private function calculateDate($recordModel, $days, $direction, $datefield)
{
$baseDate = $recordModel->get($datefield);
if ('' == $baseDate) {
$baseDate = date('Y-m-d');
}
if ('' == $days) {
$days = 0;
}
preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDate, $match);
$baseDate = strtotime($match[0]);
return strftime('%Y-%m-%d', $baseDate + $days * 24 * 60 * 60 *
('before' == strtolower($direction) ? -1 : 1));
}

/**
* To convert time_start & time_end values to db format.
*
Expand All @@ -132,8 +117,7 @@ public static function convertToDBFormat($timeStr)
{
$date = new DateTime();
$time = \App\Fields\Time::sanitizeDbFormat($timeStr);
$dbInsertDateTime = DateTimeField::convertToDBTimeZone($date->format('Y-m-d') . ' ' . $time);

$dbInsertDateTime = DateTimeField::convertToDBTimeZone(App\Fields\Date::formatToDisplay($date->format('Y-m-d')) . ' ' . $time);
return $dbInsertDateTime->format('H:i:s');
}

Expand All @@ -153,4 +137,29 @@ public function getTimeFieldList()
{
return ['startTime', 'endTime'];
}

/**
* Calculate date.
*
* @param Vtiger_Record_Model $recordModel
* @param int $days
* @param string $direction
* @param string $datefield
*
* @return string
*/
private function calculateDate(Vtiger_Record_Model $recordModel, int $days, string $direction, string $datefield): string
{
$baseDate = $recordModel->get($datefield);
if ('' == $baseDate) {
$baseDate = date('Y-m-d');
}
if ('' == $days) {
$days = 0;
}
preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDate, $match);
$days = $days + ('before' === strtolower($direction) ? -1 : 1);
$baseDate = new DateTime($match[0]);
return $baseDate->modify("+ $days days")->format('Y-m-d');
}
}