aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2022-09-28 14:24:20 +0000
committerMoritz Strohm <strohm@data-quest.de>2022-09-28 14:24:20 +0000
commite75c08bedd60a6674d22ce3e2ec57b5a5f1d85eb (patch)
tree2d9cf000153360bdc9e1841693406f3a3b1d58ae /lib
parent1e6f3d59c1989dc0da68d3200090cb4768ab3094 (diff)
fix for BIESt #1118
Merge request studip/studip!676
Diffstat (limited to 'lib')
-rw-r--r--lib/classes/ActionMenu.php6
-rw-r--r--lib/classes/EventLog.php3
-rw-r--r--lib/classes/PluginAdministration.php4
-rw-r--r--lib/classes/RangeTreeObject.class.php78
-rw-r--r--lib/classes/SemClass.class.php4
-rw-r--r--lib/classes/StudipForm.class.php8
-rw-r--r--lib/classes/StudipRangeTree.class.php2
-rw-r--r--lib/classes/StudipRangeTreeViewAdmin.class.php8
-rw-r--r--lib/classes/StudipSemSearchHelper.class.php2
-rw-r--r--lib/classes/StudipSemTree.class.php6
-rw-r--r--lib/classes/StudipSemTreeViewAdmin.class.php21
-rw-r--r--lib/classes/TreeView.class.php28
-rw-r--r--lib/classes/URLHelper.php2
-rw-r--r--lib/classes/restapi/Router.php4
-rw-r--r--lib/classes/searchtypes/RangeSearch.class.php1
-rw-r--r--lib/extern/admin_extern.inc.php2
-rw-r--r--lib/extern/lib/ExternConfig.class.php2
-rw-r--r--lib/extern/lib/ExternConfigDb.class.php2
-rw-r--r--lib/extern/views/extern_edit_module.inc.php2
-rw-r--r--lib/functions.php2
-rw-r--r--lib/models/LogEvent.php2
-rw-r--r--lib/models/OERHost.php4
-rw-r--r--lib/models/SimpleCollection.class.php6
-rw-r--r--lib/models/SimpleORMap.class.php4
-rw-r--r--lib/models/User.class.php2
-rw-r--r--lib/plugins/engine/PluginManager.class.php6
-rw-r--r--lib/plugins/engine/PluginRepository.class.php4
-rw-r--r--lib/visual.inc.php2
28 files changed, 116 insertions, 101 deletions
diff --git a/lib/classes/ActionMenu.php b/lib/classes/ActionMenu.php
index 92eac8d..511c995 100644
--- a/lib/classes/ActionMenu.php
+++ b/lib/classes/ActionMenu.php
@@ -111,7 +111,8 @@ class ActionMenu
'link' => $url->link,
'icon' => $url->icon,
'label' => $url->label,
- 'attributes' => $url->attributes
+ 'attributes' => $url->attributes,
+ 'index' => $index
];
} else {
$action = [
@@ -120,6 +121,7 @@ class ActionMenu
'icon' => $icon,
'label' => $label,
'attributes' => $attributes,
+ 'index' => $index
];
}
$index = $index ?: md5($action['link'].json_encode($action['attributes']));
@@ -180,6 +182,7 @@ class ActionMenu
'icon' => $icon,
'label' => $label,
'attributes' => $attributes,
+ 'index' => ''
];
}
@@ -198,6 +201,7 @@ class ActionMenu
$this->actions[] = [
'type' => 'multi-person-search',
'object' => $mp,
+ 'index' => ''
];
}
diff --git a/lib/classes/EventLog.php b/lib/classes/EventLog.php
index b6481d2..7336415 100644
--- a/lib/classes/EventLog.php
+++ b/lib/classes/EventLog.php
@@ -89,6 +89,7 @@ class EventLog
$filter = $this->sql_event_filter($action_id, $object_id, $parameters) ?: '1';
$filter .= " ORDER BY mkdate DESC, event_id DESC LIMIT {$offset}, 50";
$log_events = LogEvent::findBySQL($filter, $parameters);
+ $events = [];
foreach ($log_events as $log_event) {
$events[] = [
@@ -113,7 +114,7 @@ class EventLog
foreach ($actions as $action) {
$log_actions[$action->getId()] = $action->toArray();
$log_actions[$action->getId()]['log_count']
- = (int) $log_count[$action->getId()];
+ = (int) ($log_count[$action->getId()] ?? 0);
}
return $log_actions;
diff --git a/lib/classes/PluginAdministration.php b/lib/classes/PluginAdministration.php
index dc3f3bc..dc8418e 100644
--- a/lib/classes/PluginAdministration.php
+++ b/lib/classes/PluginAdministration.php
@@ -327,6 +327,10 @@ class PluginAdministration
$plugindir = Config::get()->PLUGINS_PATH . '/' . $plugin['path'];
$manifest = $plugin_manager->getPluginManifest($plugindir);
+ if (!$manifest) {
+ continue;
+ }
+
if (isset($manifest['updateURL'])) {
$repository = new PluginRepository($manifest['updateURL']);
}
diff --git a/lib/classes/RangeTreeObject.class.php b/lib/classes/RangeTreeObject.class.php
index 95f98b8..c4c5320 100644
--- a/lib/classes/RangeTreeObject.class.php
+++ b/lib/classes/RangeTreeObject.class.php
@@ -7,8 +7,8 @@
// This file is part of Stud.IP
// RangeTreeObject.class.php
// Class to handle items in the "range tree"
-//
-// Copyright (c) 2002 André Noack <noack@data-quest.de>
+//
+// Copyright (c) 2002 André Noack <noack@data-quest.de>
// Suchi & Berg GmbH <info@data-quest.de>
// +---------------------------------------------------------------------------+
// This program is free software; you can redistribute it and/or
@@ -28,18 +28,18 @@
/**
* base class for items in the "range tree"
*
-* This class is used for items
+* This class is used for items
*
* @access public
* @author André Noack <noack@data-quest.de>
-* @package
+* @package
*/
class RangeTreeObject {
-
+
/**
* item_id in range_tree
*
- *
+ *
* @access public
* @var string $tree_item_id
*/
@@ -47,7 +47,7 @@ class RangeTreeObject {
/**
* References the tree object
*
- *
+ *
* @access private
* @var object StudipRangeTree $tree
*/
@@ -55,25 +55,25 @@ class RangeTreeObject {
/**
* associative array with data from database fields
*
- *
+ *
* @access public
* @var array $item_data
*/
var $item_data = null;
-
+
/**
* associative array with mapping for database fields
*
- *
+ *
* @access public
* @var array $item_data_mapping
*/
var $item_data_mapping = null;
-
+
/**
* Factory method
*
- *
+ *
* @access public
* @static
* @param string $item_id
@@ -84,7 +84,7 @@ class RangeTreeObject {
$class_name = "RangeTreeObject" . ucfirst($tree->tree_data[$item_id]['studip_object']);
return new $class_name($item_id);
}
-
+
/**
* Constructor
*
@@ -97,11 +97,11 @@ class RangeTreeObject {
$this->tree_item_id = $item_id;
$this->item_data = $this->tree->tree_data[$item_id];
}
-
+
/**
* Returns all tree items which are kids of this object
*
- *
+ *
* @access public
* @param boolean $as_value_list
* @return mixed returns numeric array if param is false, else comma separated string
@@ -109,11 +109,11 @@ class RangeTreeObject {
function getAllItemKids($as_value_list = false){
return ($as_value_list) ? $this->getValueList($this->tree->getKidsKids($this->tree_item_id)) : $this->tree->getKidsKids($this->tree_item_id);
}
-
+
/**
* Returns all tree items which are kids of this object and are "real" Stud.IP objects
*
- *
+ *
* @access public
* @param boolean $as_value_list
* @return mixed returns numeric array if param is false, else comma separated string
@@ -122,11 +122,11 @@ class RangeTreeObject {
$all_object_kids = array_merge((array)$this->getInstKids(), (array)$this->getFakKids());
return ($as_value_list) ? $this->getValueList($all_object_kids) : $all_object_kids;
}
-
+
/**
* Returns all tree items which are kids of this object and are Stud.IP "Einrichtungen"
*
- *
+ *
* @access public
* @param boolean $as_value_list
* @return mixed returns numeric array if param is false, else comma separated string
@@ -141,11 +141,11 @@ class RangeTreeObject {
}
return ($as_value_list) ? $this->getValueList($inst_kids) : $inst_kids;
}
-
+
/**
* Returns all tree items which are kids of this object and are Stud.IP "Fakultaeten"
*
- *
+ *
* @access public
* @param boolean $as_value_list
* @return mixed returns numeric array if param is false, else comma separated string
@@ -160,19 +160,19 @@ class RangeTreeObject {
}
return ($as_value_list) ? $this->getValueList($fak_kids) : $fak_kids;
}
-
+
/**
* Returns array of Stud.IP range_ids of "real" objects
*
* This function is a wrapper for the according function in StudipRangeTree
* @see StudipRangeTree::getAdminRange()
* @access public
- * @return array of primary keys from table "institute"
+ * @return array of primary keys from table "institute"
*/
function getAdminRange(){
return $this->tree->getAdminRange($this->tree_item_id);
}
-
+
/**
* Only useful in RangeTreeObjectInst ,all other items are always in the correct branch
*
@@ -182,24 +182,24 @@ class RangeTreeObject {
function isInCorrectBranch(){
return true;
}
-
+
/**
* Returns tree path of the current object
*
* This function is a wrapper for the according function in StudipRangeTree
* @see StudipRangeTree::getItemPath()
* @access public
- * @return string
+ * @return string
*/
function getItemPath(){
return $this->tree->getItemPath($this->tree_item_id);
}
-
+
/**
* extends the $item_data array
*
* This function fills the $item_data array with fields from the according database table (is of no use in the base class)
- * @abstract
+ * @abstract
* @access private
*/
function initItemDetail(){
@@ -220,7 +220,7 @@ class RangeTreeObject {
}
return false;
}
-
+
/**
* fetch categories of this object from database
*
@@ -238,21 +238,21 @@ class RangeTreeObject {
}
return false;
}
-
+
/**
* getter method for categories of this object
*
- *
+ *
* @access public
* @return object DbSnapshot
*/
function &getCategories(){
- if (!is_object($this->item_data['categories'])){
+ if (empty($this->item_data['categories']) || !is_object($this->item_data['categories'])){
$this->fetchCategories();
}
return $this->item_data['categories'];
}
-
+
function fetchNumStaff(){
$view = DbView::getView('range_tree');
if (!($view->params[0] = $this->item_data['studip_object_id']))
@@ -264,15 +264,15 @@ class RangeTreeObject {
}
return false;
}
-
+
function getNumStaff(){
if(!isset($this->item_data['num_staff'])){
$this->fetchNumStaff();
}
return $this->item_data['num_staff'];
}
-
-
+
+
/**
* transform numerical array into a comma separated string
*
@@ -281,12 +281,12 @@ class RangeTreeObject {
* @param array $list
* @return string
*/
-
+
function getValueList($list){
$value_list = false;
- if (count($list) == 1)
+ if (count($list) == 1)
$value_list = "'$list[0]'";
- else
+ else
$value_list = "'".join("','",$list)."'";
return $value_list;
}
diff --git a/lib/classes/SemClass.class.php b/lib/classes/SemClass.class.php
index 5ab5a2d..dbbbcd7 100644
--- a/lib/classes/SemClass.class.php
+++ b/lib/classes/SemClass.class.php
@@ -305,7 +305,7 @@ class SemClass implements ArrayAccess
*/
public function isModuleActivated($modulename)
{
- return !$this->data['modules'][$modulename]
+ return empty($this->data['modules'][$modulename])
|| $this->data['modules'][$modulename]['activated'];
}
@@ -316,7 +316,7 @@ class SemClass implements ArrayAccess
*/
public function isModuleAllowed($modulename)
{
- return !$this->data['modules'][$modulename]
+ return empty($this->data['modules'][$modulename])
|| !$this->data['modules'][$modulename]['sticky']
|| $this->data['modules'][$modulename]['activated'];
}
diff --git a/lib/classes/StudipForm.class.php b/lib/classes/StudipForm.class.php
index 88c36fe..024e2e3 100644
--- a/lib/classes/StudipForm.class.php
+++ b/lib/classes/StudipForm.class.php
@@ -182,7 +182,7 @@ class StudipForm {
$attributes['required'] = 'required';
}
- if (!isset($attributes['id'])) {
+ if (empty($attributes['id'])) {
$attributes['id'] = $this->form_name . '_' . $name;
}
@@ -282,7 +282,7 @@ class StudipForm {
function getFormFieldSelect($name, $attributes, $default){
$ret = "\n<select name=\"{$this->form_name}_{$name}";
- if (!empty($this->form_fields[$name]['multiple'])){
+ if (!empty($this->form_fields[$name]['multiple'])) {
$ret .= "[]\" multiple ";
} else {
$ret .= "\" ";
@@ -292,9 +292,9 @@ class StudipForm {
if ($default === false){
$default = $this->form_fields[$name]['default_value'];
}
- if (!empty($this->form_fields[$name]['options']) && is_array($this->form_fields[$name]['options'])){
+ if (!empty($this->form_fields[$name]['options']) && is_array($this->form_fields[$name]['options'])) {
$options = $this->form_fields[$name]['options'];
- } else if ($this->form_fields[$name]['options_callback']){
+ } else if (!empty($this->form_fields[$name]['options_callback'])) {
$options = call_user_func($this->form_fields[$name]['options_callback'],$this,$name);
}
for ($i = 0; $i < count($options); ++$i){
diff --git a/lib/classes/StudipRangeTree.class.php b/lib/classes/StudipRangeTree.class.php
index 291d443..36f7314 100644
--- a/lib/classes/StudipRangeTree.class.php
+++ b/lib/classes/StudipRangeTree.class.php
@@ -61,7 +61,7 @@ class StudipRangeTree extends TreeAbstract
if (isset($args['sem_status']) ){
$this->sem_status = array_map('intval', $args['sem_status']);
}
- $this->visible_only = (int)$args['visible_only'];
+ $this->visible_only = (int)($args['visible_only'] ?? 0);
parent::__construct(); //calling the baseclass constructor
$this->sem_dates = Semester::findAllVisible();
}
diff --git a/lib/classes/StudipRangeTreeViewAdmin.class.php b/lib/classes/StudipRangeTreeViewAdmin.class.php
index 1bde371..6c5f349 100644
--- a/lib/classes/StudipRangeTreeViewAdmin.class.php
+++ b/lib/classes/StudipRangeTreeViewAdmin.class.php
@@ -576,7 +576,7 @@ class StudipRangeTreeViewAdmin extends TreeView{
return $content;
}
$range_object = RangeTreeObject::GetInstance($item_id);
- $name = ($range_object->item_data['type']) ? $range_object->item_data['type'] . ": " : "";
+ $name = !empty($range_object->item_data['type']) ? $range_object->item_data['type'] . ": " : "";
$name .= $range_object->item_data['name'];
$content .= "\n<tr><td class=\"table_header_bold\" align=\"left\" style=\"font-size:10pt\">" . htmlReady($name) ." </td></tr>";
if (is_array($range_object->item_data_mapping)){
@@ -728,7 +728,7 @@ class StudipRangeTreeViewAdmin extends TreeView{
</div>
<?
- $content .= ob_get_clean();
+ $content = ob_get_clean();
return $content;
}
@@ -787,7 +787,7 @@ class StudipRangeTreeViewAdmin extends TreeView{
</footer>
</form>
- <? $content .= ob_get_clean() . '</td></tr>';
+ <? $content = ob_get_clean() . '</td></tr>';
return $content;
}
@@ -795,7 +795,7 @@ class StudipRangeTreeViewAdmin extends TreeView{
function getItemMessage($item_id, $colspan = 1)
{
$content = "";
- if ($this->msg[$item_id]){
+ if (!empty($this->msg[$item_id])) {
$msg = explode("§", $this->msg[$item_id]);
$pics = [
'error' => Icon::create('decline', 'attention'),
diff --git a/lib/classes/StudipSemSearchHelper.class.php b/lib/classes/StudipSemSearchHelper.class.php
index e87da1b..ea7aa9c 100644
--- a/lib/classes/StudipSemSearchHelper.class.php
+++ b/lib/classes/StudipSemSearchHelper.class.php
@@ -103,7 +103,7 @@ class StudipSemSearchHelper {
if (isset($this->params['type']) && $this->params['type'] != 'all'){
$sem_types = [$this->params['type']];
}
- if ($sem_types) {
+ if (!empty($sem_types) && is_array($sem_types)) {
$clause = " AND c.status IN('" . join("','",$sem_types) . "') " . $clause;
}
diff --git a/lib/classes/StudipSemTree.class.php b/lib/classes/StudipSemTree.class.php
index 82fd37c..203bec1 100644
--- a/lib/classes/StudipSemTree.class.php
+++ b/lib/classes/StudipSemTree.class.php
@@ -110,7 +110,7 @@ class StudipSemTree extends TreeAbstract
public function isHiddenItem($item_id)
{
- return (bool) $GLOBALS['SEM_TREE_TYPES'][$this->getValue($item_id, 'type')]['hidden'];
+ return !empty($GLOBALS['SEM_TREE_TYPES'][$this->getValue($item_id, 'type')]['hidden']);
}
public function getSemIds($item_id,$ids_from_kids = false)
@@ -173,11 +173,11 @@ class StudipSemTree extends TreeAbstract
public function getNumEntries($item_id, $num_entries_from_kids = false)
{
- if (!$this->tree_data[$item_id]) {
+ if (empty($this->tree_data[$item_id])) {
return false;
}
- if (!$this->entries_init_done) {
+ if (empty($this->entries_init_done)) {
$this->initEntries();
}
diff --git a/lib/classes/StudipSemTreeViewAdmin.class.php b/lib/classes/StudipSemTreeViewAdmin.class.php
index 8644fef..c615f98 100644
--- a/lib/classes/StudipSemTreeViewAdmin.class.php
+++ b/lib/classes/StudipSemTreeViewAdmin.class.php
@@ -105,6 +105,7 @@ class StudipSemTreeViewAdmin extends TreeView
}
function parseCommand(){
+ $this->mode = '';
if (Request::quoted('mode'))
$this->mode = Request::quoted('mode');
if (Request::option('cmd')){
@@ -483,7 +484,7 @@ class StudipSemTreeViewAdmin extends TreeView
$head = $this->getItemHeadFrontPic($item_id);
$head .= "\n<td class=\"printhead\" nowrap align=\"left\" valign=\"bottom\">";
if ($this->tree->hasKids($item_id)){
- $head .= Icon::create('folder-full', 'clickable', ['title' => $this->open_ranges[$item_id]?_('Alle Unterelemente schliessen'):_('Alle Unterelemente öffnen')])->asImg(16, ['class' => 'text-top']);
+ $head .= Icon::create('folder-full', Icon::ROLE_CLICKABLE, ['title' => !empty($this->open_ranges[$item_id]) ? _('Alle Unterelemente schliessen') : _('Alle Unterelemente öffnen')])->asImg(['class' => 'text-top']);
} else {
$head .= Icon::create('folder-empty', 'clickable', ['title' => _('Dieses Element hat keine Unterelemente')])->asImg();
}
@@ -491,18 +492,18 @@ class StudipSemTreeViewAdmin extends TreeView
}
function getItemContent($item_id){
- if ($item_id == $this->edit_item_id ) return $this->getEditItemContent();
- if(!$GLOBALS['SEM_TREE_TYPES'][$this->tree->getValue($item_id, 'type')]['editable']){
+ if (!empty($this->edit_item_id) && ($item_id == $this->edit_item_id)) return $this->getEditItemContent();
+ if(empty($GLOBALS['SEM_TREE_TYPES'][$this->tree->getValue($item_id, 'type')]['editable'])){
$is_not_editable = true;
$this->msg[$item_id] = "info§" . sprintf(_("Der Typ dieses Elementes verbietet eine Bearbeitung."));
}
- if ($item_id == $this->move_item_id){
+ if (!empty($this->move_item_id) && ($item_id == $this->move_item_id)) {
$this->msg[$item_id] = "info§" . sprintf(_("Dieses Element wurde zum Verschieben / Kopieren markiert. Bitte wählen Sie ein Einfügesymbol %s aus, um das Element zu verschieben / kopieren."), Icon::create('arr_2right', 'sort', ['title' => "Einfügesymbol"])->asImg(16, ["alt" => "Einfügesymbol"]));
}
$content = "\n<table width=\"90%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" style=\"font-size:10pt;\">";
$content .= $this->getItemMessage($item_id);
$content .= "\n<tr><td style=\"font-size:10pt;\">";
- if(!$is_not_editable){
+ if (empty($is_not_editable)) {
if ($this->isItemAdmin($item_id) ){
$content .= LinkButton::create(_('Neues Objekt'),
URLHelper::getURL($this->getSelf('cmd=NewItem&item_id='.$item_id)),
@@ -520,7 +521,7 @@ class StudipSemTreeViewAdmin extends TreeView
URLHelper::getURL($this->getSelf('cmd=AssertDeleteItem&item_id=' . $item_id)),
['title' => _('Dieses Element löschen')]) . '&nbsp;';
- if ($this->move_item_id == $item_id && ($this->mode == "MoveItem" || $this->mode == "CopyItem")){
+ if (!empty($this->move_item_id) && ($this->move_item_id == $item_id) && ($this->mode == "MoveItem" || $this->mode == "CopyItem")){
$content .= LinkButton::create(_('Abbrechen'),
URLHelper::getURL($this->getSelf('cmd=Cancel&item_id=' . $item_id)),
['title' => _('Verschieben / Kopieren abbrechen')]) . '&nbsp;';
@@ -561,7 +562,7 @@ class StudipSemTreeViewAdmin extends TreeView
$content .= formatReady($this->tree->tree_data[$item_id]['info']) . "</td></tr>";
}
$content .= "<tr><td style=\"font-size:10pt;\"colspan=\"3\">&nbsp;</td></tr>";
- if ($this->tree->getNumEntries($item_id) - $this->tree->tree_data[$item_id]['lonely_sem']){
+ if (!empty($this->tree->tree_data[$item_id]['lonely_sem']) && ($this->tree->getNumEntries($item_id) - $this->tree->tree_data[$item_id]['lonely_sem'])) {
$content .= "<tr><td class=\"table_row_even\" style=\"font-size:10pt;\" align=\"left\" colspan=\"3\"><b>" . _("Einträge auf dieser Ebene:");
$content .= "</b>\n</td></tr>";
$entries = $this->tree->getSemData($item_id);
@@ -569,7 +570,7 @@ class StudipSemTreeViewAdmin extends TreeView
} else {
$content .= "\n<tr><td class=\"table_row_even\" style=\"font-size:10pt;\" colspan=\"3\">" . _("Keine Einträge auf dieser Ebene vorhanden!") . "</td></tr>";
}
- if ($this->tree->tree_data[$item_id]['lonely_sem']){
+ if (!empty($this->tree->tree_data[$item_id]['lonely_sem'])) {
$content .= "<tr><td class=\"table_row_even\" align=\"left\" style=\"font-size:10pt;\" colspan=\"3\"><b>" . _("Nicht zugeordnete Veranstaltungen auf dieser Ebene:");
$content .= "</b>\n</td></tr>";
$entries = $this->tree->getLonelySemData($item_id);
@@ -775,7 +776,7 @@ class StudipSemTreeViewAdmin extends TreeView
if ($item_id != "root"){
$head .= " (" . $this->tree->getNumEntries($item_id,true) . ") " ;
}
- if ($item_id != $this->start_item_id && $this->isParentAdmin($item_id) && $item_id != $this->edit_item_id){
+ if ($item_id != $this->start_item_id && $this->isParentAdmin($item_id) && !empty($this->edit_item_id) && ($item_id != $this->edit_item_id)){
$head .= "</td><td nowrap align=\"right\" valign=\"bottom\" class=\"printhead\">";
if (!$this->tree->isFirstKid($item_id)){
$head .= "<a href=\"". URLHelper::getLink($this->getSelf("cmd=OrderItem&direction=up&item_id=$item_id")) .
@@ -794,7 +795,7 @@ class StudipSemTreeViewAdmin extends TreeView
function getItemMessage($item_id,$colspan = 1){
$content = "";
- if ($this->msg[$item_id]){
+ if (!empty($this->msg[$item_id])) {
$msg = explode("§",$this->msg[$item_id]);
$pics = [
'error' => Icon::create('decline', 'attention'),
diff --git a/lib/classes/TreeView.class.php b/lib/classes/TreeView.class.php
index b2d8f5b..243a9b9 100644
--- a/lib/classes/TreeView.class.php
+++ b/lib/classes/TreeView.class.php
@@ -168,7 +168,7 @@ class TreeView {
$toggle_item = Request::option('close_item') ?: Request::option('open_item');
if ($toggle_item){
- if ($this->open_items[$toggle_item]) {
+ if (!empty($this->open_items[$toggle_item])) {
unset($this->open_items[$toggle_item]);
} else {
$this->openItem($toggle_item);
@@ -216,7 +216,7 @@ class TreeView {
for ($j = 0; $j < $num_items; ++$j){
$this->printLevelOutput($items[$j]);
$this->printItemOutput($items[$j]);
- if ($this->tree->hasKids($items[$j]) && $this->open_ranges[$items[$j]]) {
+ if ($this->tree->hasKids($items[$j]) && !empty($this->open_ranges[$items[$j]])) {
$this->showTree($this->tree->tree_childs[$items[$j]]);
}
}
@@ -276,7 +276,7 @@ class TreeView {
echo "\n</td><td class=\"printhead\" align=\"left\" width=\"99%\" nowrap valign=\"bottom\">";
echo $this->getItemHead($item_id);
echo "</td></tr></table>";
- if ($this->open_items[$item_id]) {
+ if (!empty($this->open_items[$item_id])) {
$this->printItemDetails($item_id);
}
return;
@@ -318,7 +318,7 @@ class TreeView {
else
$level_output = "<td class=\"blank\" background=\"" . Assets::image_path('forumstrich.gif') . "\">"
. Assets::img('forumleer.gif', ['size' => '10@20'])
- . "</td>" . $level_output; //vertical line
+ . "</td>" . ($level_output ?? ''); //vertical line
}
}
//$level_output = "<td class=\"blank\" background=\"".$GLOBALS['ASSETS_URL']."images/forumleer.gif\" ><img src=\"".$GLOBALS['ASSETS_URL']."images/forumleer.gif\" width=\"20\" height=\"20\" border=\"0\" ></td>" . $level_output;
@@ -342,9 +342,11 @@ class TreeView {
$head .= "\n<td class=\"printhead\" nowrap align=\"left\" valign=\"bottom\">";
if ($this->tree->hasKids($item_id)){
$head .= "<a href=\"";
- $head .= ($this->open_ranges[$item_id]) ? URLHelper::getLink($this->getSelf("close_range={$item_id}")) : URLHelper::getLink($this->getSelf("open_range={$item_id}"));
+ $head .= !empty($this->open_ranges[$item_id])
+ ? URLHelper::getLink($this->getSelf("close_range={$item_id}"))
+ : URLHelper::getLink($this->getSelf("open_range={$item_id}"));
$head .= "\">";
- $head .= Icon::create('folder-full', 'clickable', ['title' => $this->open_ranges[$item_id]?_('Alle Unterelemente schließen'):_('Alle Unterelemente öffnen')])->asImg(16, ['class' => 'text-top']);
+ $head .= Icon::create('folder-full', 'clickable', ['title' => !empty($this->open_ranges[$item_id]) ? _('Alle Unterelemente schließen') : _('Alle Unterelemente öffnen')])->asImg(16, ['class' => 'text-top']);
$head .= "</a>";
} else {
$head .= Icon::create('folder-empty', 'clickable', ['title' => _('Dieses Element hat keine Unterelemente')])->asImg();
@@ -362,9 +364,10 @@ class TreeView {
$head = "<td class=\"printhead\" nowrap align=\"left\" valign=\"bottom\">";
}
$head .= "<a href=\"";
- $head .= ($this->open_items[$item_id])? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . ">"
- : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">";
- $head .= Assets::img($this->open_items[$item_id] ? $this->pic_open : $this->pic_close);
+ $head .= !empty($this->open_items[$item_id])
+ ? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . ">"
+ : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">";
+ $head .= Assets::img(!empty($this->open_items[$item_id]) ? $this->pic_open : $this->pic_close);
#$head .= (!$this->open_items[$item_id]) ? "<img src=\"".$GLOBALS['ASSETS_URL']."images/forumleer.gif\" width=\"5\" border=\"0\">" : "";
$head .= "</a>";
$head .= '</td>';
@@ -381,10 +384,11 @@ class TreeView {
function getItemHead($item_id){
$head = "";
$head .= "&nbsp;<a class=\"tree\" href=\"";
- $head .= ($this->open_items[$item_id])? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . "><b>"
- : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">";
+ $head .= !empty($this->open_items[$item_id])
+ ? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . "><b>"
+ : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">";
$head .= htmlReady(my_substr($this->tree->tree_data[$item_id]['name'],0,$this->max_cols));
- $head .= ($this->open_items[$item_id]) ? "</b></a>" : "</a>";
+ $head .= (!empty($this->open_items[$item_id])) ? "</b></a>" : "</a>";
return $head;
}
diff --git a/lib/classes/URLHelper.php b/lib/classes/URLHelper.php
index ae83022..732ce99 100644
--- a/lib/classes/URLHelper.php
+++ b/lib/classes/URLHelper.php
@@ -69,7 +69,7 @@ class URLHelper
if ($url[0] === '/') {
preg_match('%^[a-z]+://[\w:.-]+%', $base_url, $host);
- $base_url = isset($host) ? $host[0] : '';
+ $base_url = $host[0] ?? '';
}
return $base_url.$url;
diff --git a/lib/classes/restapi/Router.php b/lib/classes/restapi/Router.php
index a66463e..d6a331c 100644
--- a/lib/classes/restapi/Router.php
+++ b/lib/classes/restapi/Router.php
@@ -322,8 +322,8 @@ class Router
}
if ($describe) {
$result[$uri][$method] = [
- 'description' => $this->descriptions[$uri][$method] ?: null,
- 'source' => $route['source'] ?: 'unknown',
+ 'description' => $this->descriptions[$uri][$method] ?? null,
+ 'source' => $route['source'] ?? 'unknown',
];
} else {
$result[$uri][] = $method;
diff --git a/lib/classes/searchtypes/RangeSearch.class.php b/lib/classes/searchtypes/RangeSearch.class.php
index ee7f969..b9c83ae 100644
--- a/lib/classes/searchtypes/RangeSearch.class.php
+++ b/lib/classes/searchtypes/RangeSearch.class.php
@@ -10,6 +10,7 @@ class RangeSearch extends SQLSearch
public function __construct()
{
+ $this->avatarLike = $this->search = '';
$this->sql = $this->getSQL();
}
diff --git a/lib/extern/admin_extern.inc.php b/lib/extern/admin_extern.inc.php
index 0b6affe..fd436c4 100644
--- a/lib/extern/admin_extern.inc.php
+++ b/lib/extern/admin_extern.inc.php
@@ -315,7 +315,7 @@ else {
}
-if (!$have_config) {
+if (empty($have_config)) {
echo "<blockquote>\n";
echo _("Es wurden noch keine Konfigurationen angelegt.");
echo "</blockquote>";
diff --git a/lib/extern/lib/ExternConfig.class.php b/lib/extern/lib/ExternConfig.class.php
index 226dbe7..4c34625 100644
--- a/lib/extern/lib/ExternConfig.class.php
+++ b/lib/extern/lib/ExternConfig.class.php
@@ -121,7 +121,7 @@ class ExternConfig
{
foreach ($config as $element_name => $element) {
if (is_array($element)) foreach ($element as $attribute => $value) {
- if ((string)$value[0] == '|') {
+ if (!empty($value[0]) && (string)$value[0] == '|') {
$new_config[$element_name][$attribute] = explode('|', mb_substr($value, 1));
} else {
$new_config[$element_name][$attribute] = $value;
diff --git a/lib/extern/lib/ExternConfigDb.class.php b/lib/extern/lib/ExternConfigDb.class.php
index 1f23a86..c1ab29b 100644
--- a/lib/extern/lib/ExternConfigDb.class.php
+++ b/lib/extern/lib/ExternConfigDb.class.php
@@ -77,7 +77,7 @@ class ExternConfigDb extends ExternConfig
if (!parent::insertConfiguration()) {
return false;
}
- $serialized_config = json_encode($this->config);
+ $serialized_config = json_encode($this->config ?? null);
$time = time();
$query = "INSERT INTO extern_config VALUES (?, ?, ?, ?, 0, ?, ?, ?)";
$statement = DBManager::get()->prepare($query);
diff --git a/lib/extern/views/extern_edit_module.inc.php b/lib/extern/views/extern_edit_module.inc.php
index 8c4bac4..21c5c88 100644
--- a/lib/extern/views/extern_edit_module.inc.php
+++ b/lib/extern/views/extern_edit_module.inc.php
@@ -145,7 +145,7 @@ if (Request::option('com') == 'store') {
}
-if (!$edit_open[$edit]) {
+if (empty($edit_open[$edit])) {
echo LinkButton::create("<< " . _("Zurück"), URLHelper::getURL('?list=TRUE'));;
}
diff --git a/lib/functions.php b/lib/functions.php
index 9986104..a86a9c4 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -1420,7 +1420,7 @@ function get_route($route = '')
if (mb_strpos($route, 'plugins.php/') !== false) {
$trails = explode('plugins.php/', $route);
$pieces = explode('/', $trails[1]);
- $route = 'plugins.php/' . $pieces[0] . ($pieces[1] ? '/' . $pieces[1] : '') . ($pieces[2] ? '/' . $pieces[2] : '');
+ $route = 'plugins.php/' . $pieces[0] . (!empty($pieces[1]) ? '/' . $pieces[1] : '') . (!empty($pieces[2]) ? '/' . $pieces[2] : '');
} elseif (mb_strpos($route, 'dispatch.php/') !== false) {
$trails = explode('dispatch.php/', $route);
$dispatcher = new StudipDispatcher();
diff --git a/lib/models/LogEvent.php b/lib/models/LogEvent.php
index 38fdd72..2e83590 100644
--- a/lib/models/LogEvent.php
+++ b/lib/models/LogEvent.php
@@ -279,7 +279,7 @@ class LogEvent extends SimpleORMap implements PrivacyObject
protected function formatSemester($field) {
$all_semester = Semester::findAllVisible(false);
foreach ($all_semester as $val) {
- if ($val['beginn'] == $this->$field) {
+ if (!empty($val['beginn']) && ($val['beginn'] == $this->$field)) {
return '<em>' . $val['name'] . '</em>';
}
}
diff --git a/lib/models/OERHost.php b/lib/models/OERHost.php
index 7cb2ba5..1c7c01e 100644
--- a/lib/models/OERHost.php
+++ b/lib/models/OERHost.php
@@ -15,7 +15,7 @@ class OERHost extends OERIdentity
{
$host = self::findOneBySQL("`private_key` IS NOT NULL AND `sorm_class` = 'OERHost' LIMIT 1");
if ($host) {
- $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/";
+ $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?? $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/";
if ($host->isFieldDirty("url")) {
$host->store();
}
@@ -23,7 +23,7 @@ class OERHost extends OERIdentity
} else {
$host = new self();
$host['name'] = Config::get()->UNI_NAME_CLEAN;
- $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/";
+ $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?? $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/";
$host['last_updated'] = time();
$host->store();
return $host;
diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php
index 588de1b..26439b2 100644
--- a/lib/models/SimpleCollection.class.php
+++ b/lib/models/SimpleCollection.class.php
@@ -684,9 +684,9 @@ class SimpleCollection extends StudipArrayObject
$func = function ($d1, $d2) use ($sorter, $sort_func, $sort_locale) {
do {
- $field = current($sorter);
- $dir = $field[1] ?? '';
- $field = $field[0] ?? '';
+ $current_sorter = current($sorter);
+ $field = $current_sorter[0];
+ $dir = $current_sorter[1] ?? '';
if (!$sort_locale) {
$value1 = $d1[$field];
$value2 = $d2[$field];
diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php
index 5fed34a..bc670d8 100644
--- a/lib/models/SimpleORMap.class.php
+++ b/lib/models/SimpleORMap.class.php
@@ -1094,14 +1094,14 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
}
if ($type === 'has_and_belongs_to_many') {
$thru_table = $options['thru_table'];
- if (!$options['thru_key']) {
+ if (empty($options['thru_key'])) {
$options['thru_key'] = $this->pk()[0];
}
if (empty($options['thru_assoc_key']) || empty($options['assoc_foreign_key'])) {
$class = $options['class_name'];
$record = new $class();
$meta = $record->getTableMetadata();
- if (!$options['thru_assoc_key'] ) {
+ if (empty($options['thru_assoc_key'])) {
$options['thru_assoc_key'] = $meta['pk'][0];
}
if (empty($options['assoc_foreign_key'])) {
diff --git a/lib/models/User.class.php b/lib/models/User.class.php
index 7ce868b..7eb1321 100644
--- a/lib/models/User.class.php
+++ b/lib/models/User.class.php
@@ -365,7 +365,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject
}
//locked user
- if ((int)$attributes['locked'] == 1) {
+ if (!empty($attributes['locked'])) {
$where[] = "au.`locked` = 1";
}
diff --git a/lib/plugins/engine/PluginManager.class.php b/lib/plugins/engine/PluginManager.class.php
index 7193f31..7ced174 100644
--- a/lib/plugins/engine/PluginManager.class.php
+++ b/lib/plugins/engine/PluginManager.class.php
@@ -657,9 +657,9 @@ class PluginManager
}
foreach ($manifest as $line) {
- list($key, $value) = explode('=', $line);
- $key = trim($key);
- $value = trim($value);
+ $key_and_value = explode('=', $line);
+ $key = trim($key_and_value[0]);
+ $value = trim($key_and_value[1] ?? '');
// skip empty lines and comments
if ($key === '' || $key[0] === '#') {
diff --git a/lib/plugins/engine/PluginRepository.class.php b/lib/plugins/engine/PluginRepository.class.php
index ef09a6c..14415f4 100644
--- a/lib/plugins/engine/PluginRepository.class.php
+++ b/lib/plugins/engine/PluginRepository.class.php
@@ -116,7 +116,7 @@ class PluginRepository
*/
protected function registerPlugin($name, $meta_data)
{
- $old_data = $this->plugins[$name];
+ $old_data = $this->plugins[$name] ?? null;
if (!isset($old_data) ||
version_compare($meta_data['version'], $old_data['version']) > 0) {
@@ -132,7 +132,7 @@ class PluginRepository
*/
public function getPlugin($name)
{
- return $this->plugins[$name];
+ return $this->plugins[$name] ?? null;
}
/**
diff --git a/lib/visual.inc.php b/lib/visual.inc.php
index 303987d..9cf78c3 100644
--- a/lib/visual.inc.php
+++ b/lib/visual.inc.php
@@ -679,7 +679,7 @@ function TransformInternalLinks($str){
}
$str = $GLOBALS['ABSOLUTE_URI_STUDIP'] . $str;
}
- if (is_array($GLOBALS['STUDIP_DOMAINS']) && count($GLOBALS['STUDIP_DOMAINS']) > 1) {
+ if (!empty($GLOBALS['STUDIP_DOMAINS']) && count($GLOBALS['STUDIP_DOMAINS']) > 1) {
if (!isset($GLOBALS['TransformInternalLinks_domainData'])){
$domain_data['domains'] = '';
foreach ($GLOBALS['STUDIP_DOMAINS'] as $studip_domain) $domain_data['domains'] .= '|' . preg_quote($studip_domain);