diff --git a/app/Purifier.php b/app/Purifier.php index d26e506ddb1..65fcd91cc49 100644 --- a/app/Purifier.php +++ b/app/Purifier.php @@ -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); } /** diff --git a/layouts/basic/modules/Settings/Menu/types/Module.tpl b/layouts/basic/modules/Settings/Menu/types/Module.tpl index c9a92e5a286..31dcd630f6b 100644 --- a/layouts/basic/modules/Settings/Menu/types/Module.tpl +++ b/layouts/basic/modules/Settings/Menu/types/Module.tpl @@ -18,14 +18,16 @@ {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')} + {assign var=FILTERS value=explode(',',$RECORD->get('filters'))} + {/if}
diff --git a/layouts/basic/modules/Settings/TreesManager/ListViewContents.tpl b/layouts/basic/modules/Settings/TreesManager/ListViewContents.tpl index 1e4362ee0c1..226bde93933 100644 --- a/layouts/basic/modules/Settings/TreesManager/ListViewContents.tpl +++ b/layouts/basic/modules/Settings/TreesManager/ListViewContents.tpl @@ -38,7 +38,7 @@ {foreach item=RECORD_LINK from=$LISTVIEW_ENTRY->getRecordLinks()} {assign var="RECORD_LINK_URL" value=$RECORD_LINK->getUrl()} - diff --git a/modules/Settings/SharingAccess/models/Rule.php b/modules/Settings/SharingAccess/models/Rule.php index f892cae13d2..4a7275f462d 100644 --- a/modules/Settings/SharingAccess/models/Rule.php +++ b/modules/Settings/SharingAccess/models/Rule.php @@ -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. @@ -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()) { @@ -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; + } } diff --git a/modules/Settings/TreesManager/models/Record.php b/modules/Settings/TreesManager/models/Record.php index d009d59ff02..f8309953f73 100644 --- a/modules/Settings/TreesManager/models/Record.php +++ b/modules/Settings/TreesManager/models/Record.php @@ -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. * @@ -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(); } /** @@ -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', ], @@ -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. */ @@ -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. * @@ -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(); + } + } } diff --git a/modules/Vtiger/models/TreeInventoryModal.php b/modules/Vtiger/models/TreeInventoryModal.php index b65113d242e..dd6ae4e2fef 100644 --- a/modules/Vtiger/models/TreeInventoryModal.php +++ b/modules/Vtiger/models/TreeInventoryModal.php @@ -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. @@ -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); - } } diff --git a/modules/com_vtiger_workflow/tasks/VTCreateEventTask.php b/modules/com_vtiger_workflow/tasks/VTCreateEventTask.php index a8bcbf1251e..4ea2cbcdad1 100644 --- a/modules/com_vtiger_workflow/tasks/VTCreateEventTask.php +++ b/modules/com_vtiger_workflow/tasks/VTCreateEventTask.php @@ -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. * @@ -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'); } @@ -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'); + } } diff --git a/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php b/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php index 17e21e73507..4697ab71bd7 100644 --- a/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php +++ b/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.php @@ -94,15 +94,16 @@ public function doTask($recordModel) $time = explode(' ', $baseDateStart); if (\count($time) < 2) { $timeWithSec = \App\Fields\Time::sanitizeDbFormat($this->time); - $dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateStart . ' ' . $timeWithSec); + $dbInsertDateTime = DateTimeField::convertToDBTimeZone(App\Fields\Date::formatToDisplay($baseDateStart) . ' ' . $timeWithSec); $time = $dbInsertDateTime->format('H:i:s'); } else { $time = $time[1]; } preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateStart, $match); - $baseDateStart = strtotime($match[0]); - $date_start = strftime('%Y-%m-%d', $baseDateStart + (int) $this->days_start * 24 * 60 * 60 * ('before' == strtolower($this->direction_start) ? -1 : 1)); - $endIncrement = \App\Fields\Double::formatToDb($this->days_end) * 24 * 60 * 60 * ('before' == strtolower($this->direction_end) ? -1 : 1); + $baseDateStart = new DateTime($match[0]); + $daysStart = (int) $this->days_start + ('before' === strtolower($this->direction_start) ? -1 : 1); + $dateStart = $baseDateStart->modify("+ $daysStart days")->format('Y-m-d'); + $endIncrement = \App\Fields\Double::formatToDb($this->days_end) + ('before' == strtolower($this->direction_end) ? -1 : 1); if ('fromDateStart' !== $this->datefield_end) { if ('wfRunTime' == $this->datefield_end) { @@ -123,21 +124,20 @@ public function doTask($recordModel) $timeEnd = \App\User::getUserModel(\App\User::getActiveAdminId())->getDetail('end_hour'); } $timeWithSec = \App\Fields\Time::sanitizeDbFormat($timeEnd); - $dbInsertDateTime = DateTimeField::convertToDBTimeZone($baseDateEnd . ' ' . $timeWithSec); + $dbInsertDateTime = DateTimeField::convertToDBTimeZone(App\Fields\Date::formatToDisplay($baseDateEnd) . ' ' . $timeWithSec); $timeEnd = $dbInsertDateTime->format('H:i:s'); } else { $timeEnd = $timeEnd[1]; } preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateEnd, $match); - $baseDateEnd = strtotime($match[0]); - $due_date = strftime('%Y-%m-%d ', $baseDateEnd + $endIncrement); + $baseDateEnd = new DateTime($match[0]); + $dueDate = $baseDateEnd->modify("+ $endIncrement days")->format('Y-m-d'); } else { - $dueDateTime = date('Y-m-d H:i:s', strtotime($date_start . ' ' . $time) + $endIncrement); + $dueDateTime = date('Y-m-d H:i:s', strtotime($dateStart . ' ' . $time) + $endIncrement); $dueDateTime = explode(' ', $dueDateTime); - $due_date = $dueDateTime[0]; + $dueDate = $dueDateTime[0]; $timeEnd = $dueDateTime[1]; } - $textParser = \App\TextParser::getInstanceByModel($recordModel); $fields = [ 'activitytype' => 'Task', @@ -149,8 +149,8 @@ public function doTask($recordModel) 'time_start' => $time, 'time_end' => $timeEnd, 'sendnotification' => ('' != $this->sendNotification && 'N' != $this->sendNotification), - 'date_start' => $date_start, - 'due_date' => $due_date, + 'date_start' => $dateStart, + 'due_date' => $dueDate, 'visibility' => 'Private', 'meeting_url' => $this->meetingUrl ?? '', ]; diff --git a/modules/com_vtiger_workflow/tasks/VTUpdateCalendarDates.php b/modules/com_vtiger_workflow/tasks/VTUpdateCalendarDates.php index d85bcf05062..a1c6355e230 100644 --- a/modules/com_vtiger_workflow/tasks/VTUpdateCalendarDates.php +++ b/modules/com_vtiger_workflow/tasks/VTUpdateCalendarDates.php @@ -54,7 +54,9 @@ public function doTask($recordModel) } } preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateStart, $match); - $baseDateStart = strtotime($match[0]); + $baseDateStart = new DateTime($match[0]); + $daysStart = $task['days_start'] + ('before' === strtolower($task['direction_start']) ? -1 : 1); + $dateStart = $baseDateStart->modify("+ $daysStart days")->format('Y-m-d'); if ('wfRunTime' === $task['datefield_end']) { $baseDateEnd = date('Y-m-d H:i:s'); @@ -65,13 +67,12 @@ public function doTask($recordModel) } } preg_match('/\d\d\d\d-\d\d-\d\d/', $baseDateEnd, $match); - $baseDateEnd = strtotime($match[0]); + $baseDateEnd = new DateTime($match[0]); + $daysEnd = $task['days_end'] + ('before' === strtolower($task['direction_start']) ? -1 : 1); + $duedate = $baseDateEnd->modify("+ $daysEnd days")->format('Y-m-d'); - $date_start = strftime('%Y-%m-%d', $baseDateStart + $task['days_start'] * 24 * 60 * 60 * ('before' == strtolower($task['direction_start']) ? -1 : 1)); - $due_date = strftime('%Y-%m-%d', $baseDateEnd + $task['days_end'] * 24 * 60 * 60 * ('before' == strtolower($task['direction_start']) ? -1 : 1)); - - $rowRecordModel->set('date_start', $date_start); - $rowRecordModel->set('due_date', $due_date); + $rowRecordModel->set('date_start', $dateStart); + $rowRecordModel->set('due_date', $duedate); $rowRecordModel->save(); } } diff --git a/public_html/layouts/basic/modules/Settings/PickListDependency/resources/Edit.js b/public_html/layouts/basic/modules/Settings/PickListDependency/resources/Edit.js index 6c86902cec9..b07a1296d3c 100644 --- a/public_html/layouts/basic/modules/Settings/PickListDependency/resources/Edit.js +++ b/public_html/layouts/basic/modules/Settings/PickListDependency/resources/Edit.js @@ -36,7 +36,7 @@ window.Settings_PickListDependency_Edit_Js = class { this.fieldsContainer.on('change', 'select[name="source_field"]', () => { this.graphContainer.html(''); - this.validate(form).done(() => { + this.validate(this.form).done(() => { this.getView({ mode: 'getDependencyGraph', ...this.getDefaultParams(), ...this.form.serializeFormData() }).done( (data) => { this.graphContainer.html(data); diff --git a/vtlib/Vtiger/Filter.php b/vtlib/Vtiger/Filter.php index ce85b4d8e61..5f428439944 100644 --- a/vtlib/Vtiger/Filter.php +++ b/vtlib/Vtiger/Filter.php @@ -29,19 +29,8 @@ class Filter public $privileges = 1; public $sort; public $module; - - /** - * Initialize this filter instance. - * - * @param mixed $module Mixed id or name of the module - * @param mixed $valuemap - */ - public function initialize($valuemap, $module = false) - { - $this->id = $valuemap['cvid']; - $this->name = $valuemap['viewname']; - $this->module = Module::getInstance($module ?: $valuemap['tabid']); - } + /** @var int Filter sequence. */ + public $sequence; /** * Create this instance. @@ -100,6 +89,33 @@ public function __delete() \App\CustomView::clearCacheById($this->id, $this->module->name); } + /** + * Get the column value to use in custom view tables. + * + * @param FieldBasic $fieldInstance + * + * @return string + */ + public function __getColumnValue(FieldBasic $fieldInstance) + { + $tod = explode('~', $fieldInstance->typeofdata); + $displayinfo = $fieldInstance->getModuleName() . '_' . str_replace(' ', '_', $fieldInstance->label) . ':' . $tod[0]; + return "$fieldInstance->table:$fieldInstance->column:$fieldInstance->name:$displayinfo"; + } + + /** + * Initialize this filter instance. + * + * @param mixed $module Mixed id or name of the module + * @param mixed $valuemap + */ + public function initialize($valuemap, $module = false) + { + $this->id = $valuemap['cvid']; + $this->name = $valuemap['viewname']; + $this->module = Module::getInstance($module ?: $valuemap['tabid']); + } + /** * Save this instance. * @@ -124,20 +140,6 @@ public function delete() $this->__delete(); } - /** - * Get the column value to use in custom view tables. - * - * @param FieldBasic $fieldInstance - * - * @return string - */ - public function __getColumnValue(FieldBasic $fieldInstance) - { - $tod = explode('~', $fieldInstance->typeofdata); - $displayinfo = $fieldInstance->getModuleName() . '_' . str_replace(' ', '_', $fieldInstance->label) . ':' . $tod[0]; - return "$fieldInstance->table:$fieldInstance->column:$fieldInstance->name:$displayinfo"; - } - /** * Add the field to this filer instance. * diff --git a/vtlib/Vtiger/PackageImport.php b/vtlib/Vtiger/PackageImport.php index 242dcafd553..5710d087e4d 100644 --- a/vtlib/Vtiger/PackageImport.php +++ b/vtlib/Vtiger/PackageImport.php @@ -49,6 +49,29 @@ public function __parseManifestFile(\App\Zip $zip) return false; } + /** + * Cache the field instance for re-use. + * + * @param mixed $moduleInstance + * @param mixed $fieldname + * @param mixed $fieldInstance + */ + public function __AddModuleFieldToCache($moduleInstance, $fieldname, $fieldInstance) + { + $this->_modulefields_cache["$moduleInstance->name"]["$fieldname"] = $fieldInstance; + } + + /** + * Get field instance from cache. + * + * @param mixed $moduleInstance + * @param mixed $fieldname + */ + public function __GetModuleFieldFromCache($moduleInstance, $fieldname) + { + return $this->_modulefields_cache["$moduleInstance->name"]["$fieldname"]; + } + /** * Get type of package (as specified in manifest). * @@ -403,29 +426,6 @@ public function getModuleName() return (string) $this->_modulexml->name; } - /** - * Cache the field instance for re-use. - * - * @param mixed $moduleInstance - * @param mixed $fieldname - * @param mixed $fieldInstance - */ - public function __AddModuleFieldToCache($moduleInstance, $fieldname, $fieldInstance) - { - $this->_modulefields_cache["$moduleInstance->name"]["$fieldname"] = $fieldInstance; - } - - /** - * Get field instance from cache. - * - * @param mixed $moduleInstance - * @param mixed $fieldname - */ - public function __GetModuleFieldFromCache($moduleInstance, $fieldname) - { - return $this->_modulefields_cache["$moduleInstance->name"]["$fieldname"]; - } - /** * Initialize Import. * @@ -456,7 +456,7 @@ public function initImport($zipfile, $overwrite = true) // Settings templates folder 'settings/templates' => "layouts/$defaultLayout/modules/Settings/$module", 'settings/public_resources' => "public_html/layouts/$defaultLayout/modules/Settings/$module/resources", - //module images + // module images 'images' => "layouts/$defaultLayout/images/$module", 'updates' => 'cache/updates', 'layouts' => 'layouts', @@ -734,18 +734,17 @@ public function importBlock($modulenode, $moduleInstance, $blocknode) $blockInstance = new Block(); $blockInstance->label = $blocklabel; if (isset($blocknode->sequence, $blocknode->display_status)) { - $blockInstance->sequence = (string) ($blocknode->sequence); + $blockInstance->sequence = (string) $blocknode->sequence; if ($blockInstance->sequence = '') { $blockInstance->sequence = null; } - $blockInstance->showtitle = (string) ($blocknode->show_title); - $blockInstance->visible = (string) ($blocknode->visible); - $blockInstance->increateview = (string) ($blocknode->create_view); - $blockInstance->ineditview = (string) ($blocknode->edit_view); - $blockInstance->indetailview = (string) ($blocknode->detail_view); - $blockInstance->display_status = (string) ($blocknode->display_status); - $blockInstance->iscustom = (string) ($blocknode->iscustom); - $blockInstance->islist = (string) ($blocknode->islist); + $blockInstance->showtitle = (string) $blocknode->show_title; + $blockInstance->visible = (string) $blocknode->visible; + $blockInstance->increateview = (string) $blocknode->create_view; + $blockInstance->ineditview = (string) $blocknode->edit_view; + $blockInstance->indetailview = (string) $blocknode->detail_view; + $blockInstance->display_status = (string) $blocknode->display_status; + $blockInstance->iscustom = (string) $blocknode->iscustom; } else { $blockInstance->display_status = null; } @@ -813,7 +812,7 @@ public function importField($blocknode, $blockInstance, $moduleInstance, $fieldn } if (isset($fieldnode->columntype) && !empty($fieldnode->columntype)) { - $fieldInstance->columntype = (string) ($fieldnode->columntype); + $fieldInstance->columntype = (string) $fieldnode->columntype; } if (!empty($fieldnode->tree_template)) { @@ -1076,7 +1075,12 @@ public function importCustomLinks($modulenode, $moduleInstance) 'method' => "$customlinknode->handler", ]; } $moduleInstance->addLink( - "$customlinknode->linktype", "$customlinknode->linklabel", "$customlinknode->linkurl", "$customlinknode->linkicon", "$customlinknode->sequence", $handlerInfo + "$customlinknode->linktype", + "$customlinknode->linklabel", + "$customlinknode->linkurl", + "$customlinknode->linkicon", + "$customlinknode->sequence", + $handlerInfo ); } } @@ -1097,7 +1101,7 @@ public function importCronTasks($modulenode) } else { $cronTask->status = Cron::$STATUS_ENABLED; } - if ((empty($cronTask->sequence))) { + if (empty($cronTask->sequence)) { $cronTask->sequence = Cron::nextSequence(); } Cron::register("$cronTask->name", "$cronTask->handler", "$cronTask->frequency", "$modulenode->name", "$cronTask->status", "$cronTask->sequence", "$cronTask->description"); @@ -1253,12 +1257,12 @@ public function importFont($zipfile) $tempFonts[$font['family']][$font['weight']][$font['style']] = $font['file']; } foreach ($files as $key => &$file) { - $file = \str_replace('fonts/', '', $file); + $file = str_replace('fonts/', '', $file); if (empty($file)) { unset($files[$key]); } } - $files = \array_flip($files); + $files = array_flip($files); $missing = []; if (!empty($this->_modulexml->fonts->font)) { foreach ($this->_modulexml->fonts->font as $font) { @@ -1276,11 +1280,11 @@ public function importFont($zipfile) } } if ($missing) { - $this->_errorText = \App\Language::translate('LBL_ERROR_MISSING_FILES', 'Settings:ModuleManager') . ' ' . \implode(',', $missing); + $this->_errorText = \App\Language::translate('LBL_ERROR_MISSING_FILES', 'Settings:ModuleManager') . ' ' . implode(',', $missing); } $css = []; foreach ($fonts as $key => $font) { - if (!\file_exists("$fontsDir/{$font['file']}")) { + if (!file_exists("$fontsDir/{$font['file']}")) { unset($fonts[$key]); } else { $woff = pathinfo($font['file'], PATHINFO_FILENAME) . '.woff'; diff --git a/vtlib/Vtiger/PackageUpdate.php b/vtlib/Vtiger/PackageUpdate.php index 6cc29a4d178..6e1a3abdbd4 100644 --- a/vtlib/Vtiger/PackageUpdate.php +++ b/vtlib/Vtiger/PackageUpdate.php @@ -211,7 +211,7 @@ public function updateBlocks($modulenode, $moduleInstance) } foreach ($modulenode->blocks->block as $blocknode) { - $this->listBlocks[] = (string) ($blocknode->blocklabel); + $this->listBlocks[] = (string) $blocknode->blocklabel; $blockInstance = Block::getInstance((string) $blocknode->blocklabel, $moduleInstance->id); if (!$blockInstance) { $blockInstance = $this->importBlock($modulenode, $moduleInstance, $blocknode); @@ -224,7 +224,7 @@ public function updateBlocks($modulenode, $moduleInstance) // Deleting removed blocks $listBlockBeforeUpdate = Block::getAllForModule($moduleInstance); foreach ($listBlockBeforeUpdate as $blockInstance) { - if (!(\in_array($blockInstance->label, $this->listBlocks))) { + if (!\in_array($blockInstance->label, $this->listBlocks)) { $blockInstance->delete(); } } @@ -232,7 +232,7 @@ public function updateBlocks($modulenode, $moduleInstance) if ($this->listFields) { $listFieldBeforeUpdate = Field::getAllForModule($moduleInstance); foreach ($listFieldBeforeUpdate as $fieldInstance) { - if (!(\in_array($fieldInstance->name, $this->listFields))) { + if (!\in_array($fieldInstance->name, $this->listFields)) { $fieldInstance->delete(); } } @@ -249,17 +249,16 @@ public function updateBlocks($modulenode, $moduleInstance) */ public function updateBlock($modulenode, $moduleInstance, $blocknode, $blockInstance) { - $blockInstance->label = (string) ($blocknode->blocklabel); + $blockInstance->label = (string) $blocknode->blocklabel; if (isset($blocknode->sequence, $blocknode->display_status)) { - $blockInstance->sequence = (string) ($blocknode->sequence); - $blockInstance->showtitle = (string) ($blocknode->show_title); - $blockInstance->visible = (string) ($blocknode->visible); - $blockInstance->increateview = (string) ($blocknode->create_view); - $blockInstance->ineditview = (string) ($blocknode->edit_view); - $blockInstance->indetailview = (string) ($blocknode->detail_view); - $blockInstance->display_status = (string) ($blocknode->display_status); - $blockInstance->iscustom = (string) ($blocknode->iscustom); - $blockInstance->islist = (string) ($blocknode->islist); + $blockInstance->sequence = (string) $blocknode->sequence; + $blockInstance->showtitle = (string) $blocknode->show_title; + $blockInstance->visible = (string) $blocknode->visible; + $blockInstance->increateview = (string) $blocknode->create_view; + $blockInstance->ineditview = (string) $blocknode->edit_view; + $blockInstance->indetailview = (string) $blocknode->detail_view; + $blockInstance->display_status = (string) $blocknode->display_status; + $blockInstance->iscustom = (string) $blocknode->iscustom; } else { $blockInstance->display_status = null; } @@ -282,7 +281,7 @@ public function updateFields($blocknode, $blockInstance, $moduleInstance) } foreach ($blocknode->fields->field as $fieldnode) { - $this->listFields[] = (string) ($fieldnode->fieldname); + $this->listFields[] = (string) $fieldnode->fieldname; $fieldInstance = Field::getInstance((string) $fieldnode->fieldname, $moduleInstance); if (!$fieldInstance) { $fieldInstance = $this->importField($blocknode, $blockInstance, $moduleInstance, $fieldnode); @@ -305,31 +304,31 @@ public function updateFields($blocknode, $blockInstance, $moduleInstance) public function updateField($blocknode, $blockInstance, $moduleInstance, $fieldnode, $fieldInstance) { // strval used because in $fieldnode there is a SimpleXMLElement object - $fieldInstance->name = (string) ($fieldnode->fieldname); - $fieldInstance->label = (string) ($fieldnode->fieldlabel); - $fieldInstance->table = (string) ($fieldnode->tablename); - $fieldInstance->column = (string) ($fieldnode->columnname); - $fieldInstance->uitype = (string) ($fieldnode->uitype); - $fieldInstance->generatedtype = (string) ($fieldnode->generatedtype); - $fieldInstance->readonly = (string) ($fieldnode->readonly); - $fieldInstance->presence = (string) ($fieldnode->presence); - $fieldInstance->defaultvalue = (string) ($fieldnode->defaultvalue); - $fieldInstance->maximumlength = (string) ($fieldnode->maximumlength); - $fieldInstance->sequence = (string) ($fieldnode->sequence); - $fieldInstance->quickcreate = (string) ($fieldnode->quickcreate); - $fieldInstance->quicksequence = (string) ($fieldnode->quickcreatesequence); - $fieldInstance->typeofdata = (string) ($fieldnode->typeofdata); - $fieldInstance->displaytype = (string) ($fieldnode->displaytype); - $fieldInstance->info_type = (string) ($fieldnode->info_type); - $fieldInstance->fieldparams = (string) ($fieldnode->fieldparams); + $fieldInstance->name = (string) $fieldnode->fieldname; + $fieldInstance->label = (string) $fieldnode->fieldlabel; + $fieldInstance->table = (string) $fieldnode->tablename; + $fieldInstance->column = (string) $fieldnode->columnname; + $fieldInstance->uitype = (string) $fieldnode->uitype; + $fieldInstance->generatedtype = (string) $fieldnode->generatedtype; + $fieldInstance->readonly = (string) $fieldnode->readonly; + $fieldInstance->presence = (string) $fieldnode->presence; + $fieldInstance->defaultvalue = (string) $fieldnode->defaultvalue; + $fieldInstance->maximumlength = (string) $fieldnode->maximumlength; + $fieldInstance->sequence = (string) $fieldnode->sequence; + $fieldInstance->quickcreate = (string) $fieldnode->quickcreate; + $fieldInstance->quicksequence = (string) $fieldnode->quickcreatesequence; + $fieldInstance->typeofdata = (string) $fieldnode->typeofdata; + $fieldInstance->displaytype = (string) $fieldnode->displaytype; + $fieldInstance->info_type = (string) $fieldnode->info_type; + $fieldInstance->fieldparams = (string) $fieldnode->fieldparams; if (!empty($fieldnode->fieldparams)) { - $fieldInstance->fieldparams = (string) ($fieldnode->fieldparams); + $fieldInstance->fieldparams = (string) $fieldnode->fieldparams; } // Check if new parameters are defined if (isset($fieldnode->columntype)) { - $fieldInstance->columntype = (string) ($fieldnode->columntype); + $fieldInstance->columntype = (string) $fieldnode->columntype; } else { $fieldInstance->columntype = null; } @@ -350,12 +349,12 @@ public function updateField($blocknode, $blockInstance, $moduleInstance, $fieldn // Set the field as entity identifier if marked. if (!empty($fieldnode->entityidentifier)) { if (isset($fieldnode->entityidentifier->fieldname) && !empty($fieldnode->entityidentifier->fieldname)) { - $moduleInstance->entityfieldname = (string) ($fieldnode->entityidentifier->fieldname); + $moduleInstance->entityfieldname = (string) $fieldnode->entityidentifier->fieldname; } else { $moduleInstance->entityfieldname = $fieldInstance->name; } - $moduleInstance->entityidfield = (string) ($fieldnode->entityidentifier->entityidfield); - $moduleInstance->entityidcolumn = (string) ($fieldnode->entityidentifier->entityidcolumn); + $moduleInstance->entityidfield = (string) $fieldnode->entityidentifier->entityidfield; + $moduleInstance->entityidcolumn = (string) $fieldnode->entityidentifier->entityidcolumn; $moduleInstance->setEntityIdentifier($fieldInstance); } @@ -575,7 +574,7 @@ public function updateCronTasks($modulenode) } else { $cronTask->status = Cron::$STATUS_ENABLED; } - if ((empty($importCronTask->sequence))) { + if (empty($importCronTask->sequence)) { $importCronTask->sequence = Cron::nextSequence(); } Cron::register("$importCronTask->name", "$importCronTask->handler", "$importCronTask->frequency", "$modulenode->name", "$importCronTask->status", "$importCronTask->sequence", "$importCronTask->description");