diff options
author | Simon Rettberg | 2017-12-16 18:33:16 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-16 18:33:16 +0100 |
commit | cd55ead3e2810e209b726faca12fa749f6875d0f (patch) | |
tree | 94b2f29b023e8a0c5100e1d06c974c3c04f890fd | |
parent | Merge branch 'permission-manager' of openslx.org:openslx-ng/slx-admin into pe... (diff) | |
download | slx-admin-cd55ead3e2810e209b726faca12fa749f6875d0f.tar.gz slx-admin-cd55ead3e2810e209b726faca12fa749f6875d0f.tar.xz slx-admin-cd55ead3e2810e209b726faca12fa749f6875d0f.zip |
Fix A LOT of type problems, logic flaws, uninitialized variables etc.
Most of them were found by phpstorm, so I put in some time and
went through the list, fixing quite a bunch of them.
58 files changed, 299 insertions, 185 deletions
diff --git a/apis/cron.inc.php b/apis/cron.inc.php index 4a980fed..75d7f132 100644 --- a/apis/cron.inc.php +++ b/apis/cron.inc.php @@ -96,7 +96,7 @@ foreach (Hook::load('cron') as $hook) { handleModule($hook->file); } catch (Exception $e) { // Logging - EventLog::failure('Cronjob for module ' . $hook->moduleId . ' has crashed. Check the php or web server error log.', $e->toString()); + EventLog::failure('Cronjob for module ' . $hook->moduleId . ' has crashed. Check the php or web server error log.', $e->getMessage()); } Property::removeFromList(CRON_KEY_STATUS, $value); } diff --git a/inc/dashboard.inc.php b/inc/dashboard.inc.php index 2cf0b494..3db42efb 100644 --- a/inc/dashboard.inc.php +++ b/inc/dashboard.inc.php @@ -41,8 +41,8 @@ class Dashboard } $currentPage = Page::getModule()->getIdentifier(); $categories = array(); - $catSort = array(); foreach ($modByCategory as $catId => $modList) { + /* @var Module[] $modList */ $modules = array(); foreach ($modList as $modId => $module) { if ($module === false) diff --git a/inc/dictionary.inc.php b/inc/dictionary.inc.php index ca2811ff..ee196f59 100644 --- a/inc/dictionary.inc.php +++ b/inc/dictionary.inc.php @@ -3,7 +3,13 @@ class Dictionary { + /** + * @var string[] Array of languages, numeric index, two letter CC as values + */ private static $languages = false; + /** + * @var array Array of languages, numeric index, values are ['name' => 'Language Name', 'cc' => 'xx'] + */ private static $languagesLong = false; private static $stringCache = array(); @@ -49,16 +55,24 @@ class Dictionary define('LANG', $language); } - public static function getArray($module, $path, $lang = false) + /** + * Get complete key=>value list for given module, file, language + * + * @param string $module Module name + * @param string $file Dictionary name + * @param string|false $lang Language CC, false === current language + * @return array assoc array mapping language tags to the translated strings + */ + public static function getArray($module, $file, $lang = false) { if ($lang === false) $lang = LANG; - $file = Util::safePath("modules/{$module}/lang/{$lang}/{$path}.json"); - if (isset(self::$stringCache[$file])) - return self::$stringCache[$file]; - if (!file_exists($file)) + $path = Util::safePath("modules/{$module}/lang/{$lang}/{$file}.json"); + if (isset(self::$stringCache[$path])) + return self::$stringCache[$path]; + if (!file_exists($path)) return array(); - $content = file_get_contents($file); + $content = file_get_contents($path); if ($content === false) { // File does not exist for language $content = '[]'; } @@ -66,12 +80,22 @@ class Dictionary if (!is_array($json)) { $json = array(); } - return self::$stringCache[$file] = $json; + return self::$stringCache[$path] = $json; } - public static function translateFileModule($moduleId, $path, $tag, $returnTagOnMissing = false) + /** + * Translate a tag from a dictionary of a module. The current + * language will be used. + * + * @param string $moduleId The module in question + * @param string $file Dictionary name + * @param string $tag Tag name + * @param bool $returnTagOnMissing If true, the tag name enclosed in {{}} will be returned if the tag does not exist + * @return string|false The requested tag's translation, or false if not found and $returnTagOnMissing === false + */ + public static function translateFileModule($moduleId, $file, $tag, $returnTagOnMissing = false) { - $strings = self::getArray($moduleId, $path); + $strings = self::getArray($moduleId, $file); if (!isset($strings[$tag])) { if ($returnTagOnMissing) { return '{{' . $tag . '}}'; @@ -80,14 +104,29 @@ class Dictionary } return $strings[$tag]; } - - public static function translateFile($path, $tag, $returnTagOnMissing = false) + + /** + * Translate a tag from a dictionary of the current module, using the current language. + * + * @param string $file Dictionary name + * @param string $tag Tag name + * @param bool $returnTagOnMissing If true, the tag name enclosed in {{}} will be returned if the tag does not exist + * @return string|false The requested tag's translation, or false if not found and $returnTagOnMissing === false + */ + public static function translateFile($file, $tag, $returnTagOnMissing = false) { if (!class_exists('Page') || Page::getModule() === false) return false; // We have no page - return false for now, as we're most likely running in api or install mode - return self::translateFileModule(Page::getModule()->getIdentifier(), $path, $tag, $returnTagOnMissing); + return self::translateFileModule(Page::getModule()->getIdentifier(), $file, $tag, $returnTagOnMissing); } + /** + * Translate a tag from the current module's default dictionary, using the current language. + * + * @param string $tag Tag name + * @param bool $returnTagOnMissing If true, the tag name enclosed in {{}} will be returned if the tag does not exist + * @return string|false The requested tag's translation, or false if not found and $returnTagOnMissing === false + */ public static function translate($tag, $returnTagOnMissing = false) { $string = self::translateFile('module', $tag); @@ -99,6 +138,13 @@ class Dictionary return '{{' . $tag . '}}'; } + /** + * Translate the given message id, reading the given module's messages dictionary. + * + * @param string $module Module the message belongs to + * @param string $id Message id + * @return string|false + */ public static function getMessage($module, $id) { $string = self::translateFileModule($module, 'messages', $id); @@ -107,7 +153,13 @@ class Dictionary } return $string; } - + + /** + * Get translation of the given category. + * + * @param string $category + * @return string Category name, or some generic fallback to the given category id + */ public static function getCategoryName($category) { if ($category === false) { @@ -126,7 +178,7 @@ class Dictionary /** * Get all supported languages as array. * - * @param boolean $withName true = return assoc array containinc cc and name of all languages; + * @param boolean $withName true = return assoc array containing cc and name of all languages; * false = regular array containing only the ccs * @return array List of languages */ @@ -151,7 +203,14 @@ class Dictionary } return self::$languagesLong; } - + + /** + * Get name of language matching given language CC. + * Default to the CC if the language isn't known. + * + * @param string $langCC + * @return string + */ public static function getLanguageName($langCC) { if (file_exists("lang/$langCC/name.txt")) { diff --git a/inc/download.inc.php b/inc/download.inc.php index e5764d37..39f8e2e2 100644 --- a/inc/download.inc.php +++ b/inc/download.inc.php @@ -69,7 +69,7 @@ class Download * POST-Download file, obey given timeout in seconds * Return data on success, false on failure * @param string $url URL to fetch - * @param array $params POST params to set in body, list of key-value-pairs + * @param array|false $params POST params to set in body, list of key-value-pairs * @param int $timeout timeout in seconds * @param int $code HTTP response code, or 999 on error */ diff --git a/inc/module.inc.php b/inc/module.inc.php index ec3d095b..7610c720 100644 --- a/inc/module.inc.php +++ b/inc/module.inc.php @@ -214,7 +214,7 @@ class Module private function getDepsInternal(&$deps) { if (!is_array($this->dependencies)) - return array(); + return; foreach ($this->dependencies as $dep) { if (isset($deps[$dep])) // Handle cyclic dependencies continue; diff --git a/inc/property.inc.php b/inc/property.inc.php index 0b4ea7b3..56adb823 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -243,7 +243,7 @@ class Property public static function setPasswordFieldType($value) { - return self::set('password-type', $value); + self::set('password-type', $value); } public static function getPasswordFieldType() diff --git a/inc/render.inc.php b/inc/render.inc.php index d09b2a8e..0ce39dbe 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -15,6 +15,9 @@ Render::init(); class Render { + /** + * @var Mustache_Engine + */ private static $mustache = false; private static $body = ''; private static $header = ''; @@ -81,7 +84,7 @@ class Render '; // Include any module specific styles foreach ($modules as $module) { - $files = $module->getCss($module != $pageModule); + $files = $module->getCss($module !== $pageModule); foreach ($files as $file) { echo '<link href="', $module->getDir(), '/', $file, '" rel="stylesheet" media="screen">'; } @@ -110,7 +113,7 @@ class Render <script src="script/slx-fixes.js"></script> '; foreach ($modules as $module) { - $files = $module->getScripts($module != $pageModule); + $files = $module->getScripts($module !== $pageModule); foreach ($files as $file) { echo '<script src="', $module->getDir(), '/', $file, '"></script>'; } diff --git a/inc/taskmanager.inc.php b/inc/taskmanager.inc.php index dcf54448..cdc90f55 100644 --- a/inc/taskmanager.inc.php +++ b/inc/taskmanager.inc.php @@ -29,7 +29,7 @@ class Taskmanager * @param array $data data to pass to the task. the structure depends on the task. * @param boolean $async if true, the function will not wait for the reply of the taskmanager, which means * the return value is just true (and you won't know if the task could acutally be started) - * @return array struct representing the task status (as a result of submit); false on communication error + * @return array|false struct representing the task status (as a result of submit); false on communication error */ public static function submit($task, $data = false, $async = false) { @@ -60,7 +60,7 @@ class Taskmanager * Query status of given task. * * @param mixed $task task id or task struct - * @return array status of task as array, or false on communication error + * @return array|false status of task as array, or false on communication error */ public static function status($task) { @@ -72,7 +72,7 @@ class Taskmanager self::init(); $seq = (string) mt_rand(); $message = "$seq, status, $task"; - $sent = socket_send(self::$sock, $message, strlen($message), 0); + socket_send(self::$sock, $message, strlen($message), 0); $reply = self::readReply($seq); if (!is_array($reply)) return false; @@ -96,9 +96,9 @@ class Taskmanager /** * Wait for the given task's completion. * - * @param array $task task to wait for + * @param string|array $task task to wait for * @param int $timeout maximum time in ms to wait for completion of task - * @return array result/status of task, or false if it couldn't be queried + * @return array|false result/status of task, or false if it couldn't be queried */ public static function waitComplete($task, $timeout = 2500) { @@ -112,7 +112,8 @@ class Taskmanager if (!is_string($task)) return false; $done = false; - for ($i = 0; $i < ($timeout / 150); ++$i) { + $deadline = microtime(true) + $timeout / 1000; + do { $status = self::status($task); if (!isset($status['statusCode'])) break; @@ -121,9 +122,10 @@ class Taskmanager break; } usleep(100000); - } - if ($done) + } while (microtime(true) < $deadline); + if ($done) { // For now we do this unconditionally, but maybe we want to keep them longer some time? self::release($task); + } return $status; } @@ -131,7 +133,7 @@ class Taskmanager * Check whether the given task can be considered failed. This * includes that the task id is invalid, etc. * - * @param array $task struct representing task, obtained by ::status + * @param array|false $task struct representing task, obtained by ::status * @return boolean true if task failed, false if finished successfully or still waiting/running */ public static function isFailed($task) @@ -183,7 +185,7 @@ class Taskmanager /** * Release a given task from the task manager, so it won't keep the result anymore in case it's finished running. * - * @param string $task task to release. can either be its id, or a struct representing the task, as returned + * @param string|array $task task to release. can either be its id, or a struct representing the task, as returned * by ::submit() or ::status() */ public static function release($task) diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index db4a2148..2af73872 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -111,7 +111,7 @@ class Trigger * Mount the VM store into the server. * * @param array $vmstore VM Store configuration to use. If false, read from properties - * @return array task status of mount procedure, or false on error + * @return array|false task status of mount procedure, or false on error */ public static function mount($vmstore = false) { @@ -125,12 +125,13 @@ class Trigger } else { $storetype = 'unknown'; } - if ($storetype === 'nfs') + if ($storetype === 'nfs') { $addr = $vmstore['nfsaddr']; - if ($storetype === 'cifs') + } elseif ($storetype === 'cifs') { $addr = $vmstore['cifsaddr']; - if ($storetype === 'internal') + } else { $addr = 'null'; + } return Taskmanager::submit('MountVmStore', array( 'address' => $addr, 'type' => 'images', @@ -175,6 +176,16 @@ class Trigger $taskids['dmsdid'] = $task['id']; $parent = $task['id']; } + $task = Taskmanager::submit('Systemctl', array( + 'operation' => $action, + 'service' => 'dnbd3-server', + 'parentTask' => $parent, + 'failOnParentFail' => false + )); + if (isset($task['id'])) { + $taskids['dnbd3id'] = $task['id']; + $parent = $task['id']; + } return $parent; } diff --git a/inc/up_json_encode.php b/inc/up_json_encode.php index 0f5776c2..ac47ef51 100644 --- a/inc/up_json_encode.php +++ b/inc/up_json_encode.php @@ -90,7 +90,6 @@ function up_json_encode($var, $options = 0, $_indent = "") #-- prepare JSON string list($_space, $_tab, $_nl) = ($options & JSON_PRETTY_PRINT) ? array(" ", " $_indent", "\n") : array("", "", ""); - $json = "$_indent"; if (($options & JSON_NUMERIC_CHECK) and is_string($var) and is_numeric($var)) { $var = (strpos($var, ".") || strpos($var, "e")) ? floatval($var) : intval($var); @@ -143,7 +142,6 @@ function up_json_encode($var, $options = 0, $_indent = "") "<" => $options & JSON_HEX_TAG ? "\\u003C" : "<", ">" => $options & JSON_HEX_TAG ? "\\u003E" : ">", "'" => $options & JSON_HEX_APOS ? "\\u0027" : "'", - "\"" => "\\u0022", "&" => $options & JSON_HEX_AMP ? "\\u0026" : "&", ); $var = strtr($var, $rewrite); diff --git a/inc/user.inc.php b/inc/user.inc.php index 1e6a2d0e..95680e65 100644 --- a/inc/user.inc.php +++ b/inc/user.inc.php @@ -79,7 +79,7 @@ class User public static function updatePassword($password) { if (!self::isLoggedIn()) - return; + return false; $passwd = Crypto::hash6($password); $userid = self::getId(); return Database::exec('UPDATE user SET passwd = :passwd WHERE userid = :userid LIMIT 1', compact('userid', 'passwd')) > 0; diff --git a/inc/util.inc.php b/inc/util.inc.php index ace879f4..69eaf941 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -109,7 +109,7 @@ SADFACE; return $arg; } - public static function formatBacktraceHtml($trace, $escape = true) + public static function formatBacktraceHtml($trace) { $output = ''; foreach ($trace as $idx => $line) { @@ -185,7 +185,7 @@ SADFACE; public static function addRedirectParam($key, $value) { - self::$redirectParams[] = $key .= '=' . urlencode($value); + self::$redirectParams[] = $key . '=' . urlencode($value); } /** @@ -225,14 +225,14 @@ SADFACE; * Convert given number to human readable file size string. * Will append Bytes, KiB, etc. depending on magnitude of number. * - * @param type $bytes numeric value of the filesize to make readable - * @param type $decimals number of decimals to show, -1 for automatic - * @return type human readable string representing the given filesize + * @param float|int $bytes numeric value of the filesize to make readable + * @param int $decimals number of decimals to show, -1 for automatic + * @return string human readable string representing the given filesize */ public static function readableFileSize($bytes, $decimals = -1) { static $sz = array('Byte', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'); - $factor = floor((strlen($bytes) - 1) / 3); + $factor = (int)floor((strlen($bytes) - 1) / 3); if ($factor == 0) { $decimals = 0; } elseif ($decimals === -1) { @@ -351,9 +351,9 @@ SADFACE; /** * Send a file to user for download. * - * @param type $file path of local file - * @param type $name name of file to send to user agent - * @param type $delete delete the file when done? + * @param string $file path of local file + * @param string $name name of file to send to user agent + * @param boolean $delete delete the file when done? * @return boolean false: file could not be opened. * true: error while reading the file * - on success, the function does not return @@ -362,7 +362,7 @@ SADFACE; { while ((@ob_get_level()) > 0) @ob_end_clean(); - $fh = @fopen($file, 'rb'); + $fh = fopen($file, 'rb'); if ($fh === false) { Message::addError('main.error-read', $file); return false; @@ -382,9 +382,10 @@ SADFACE; @ob_flush(); @flush(); } - @fclose($fh); - if ($delete) - @unlink($file); + fclose($fh); + if ($delete) { + unlink($file); + } exit(0); } @@ -401,7 +402,11 @@ SADFACE; public static function randomBytes($length, $secure = true) { if (function_exists('random_bytes')) { - return random_bytes($length); + try { + return random_bytes($length); + } catch (Exception $e) { + // Continue below + } } if ($secure) { if (function_exists('openssl_random_pseudo_bytes')) { @@ -172,7 +172,7 @@ if (defined('CONFIG_DEBUG') && CONFIG_DEBUG) { * Map an error code into an Error word. * * @param int $code Error code to map - * @return array Array of error word. + * @return string Readable error type */ function mapErrorCode($code) { diff --git a/install.php b/install.php index a5d18f0c..88eb82c2 100644 --- a/install.php +++ b/install.php @@ -256,6 +256,9 @@ function hasUpdateScript($module) return is_readable($module->getDir() . '/install.inc.php'); } +/** + * @param Module $module + */ function runUpdateScript($module) { require_once $module->getDir() . '/install.inc.php'; @@ -277,6 +280,7 @@ if (DIRECT_MODE) { $new[] = $entry; } } + /* @var Module[] $new */ $modules = $new; if (empty($modules)) { finalResponse(UPDATE_NOOP, 'No modules with install scripts, nothing to do'); @@ -287,6 +291,7 @@ if (DIRECT_MODE) { for ($i = 0; $i < $count; ++$i) { $assoc[$modules[$i]->getIdentifier()] = $modules[($i + 1) % $count]; } + /* @var Module[] $assoc */ if (!empty($argv[1])) { $last = $argv[1]; diff --git a/modules-available/backup/page.inc.php b/modules-available/backup/page.inc.php index 26182ca3..949cd7f3 100644 --- a/modules-available/backup/page.inc.php +++ b/modules-available/backup/page.inc.php @@ -139,35 +139,5 @@ class Page_Backup extends Page if (isset($task['id'])) $this->templateData['rebootid'] = $task['id']; } - private function stopDaemons($parent) - { - $task = Taskmanager::submit('SyncdaemonLauncher', array( - 'operation' => 'stop', - 'parentTask' => $parent, - 'failOnParentFail' => false - )); - if (isset($task['id'])) { - $this->templateData['syncid'] = $task['id']; - $parent = $task['id']; - } - $task = Taskmanager::submit('DozmodLauncher', array( - 'operation' => 'stop', - 'parentTask' => $parent, - 'failOnParentFail' => false - )); - if (isset($task['id'])) { - $this->templateData['dmsdid'] = $task['id']; - $parent = $task['id']; - } - $task = Taskmanager::submit('LdadpLauncher', array( - 'ids' => array(), - 'parentTask' => $parent, - 'failOnParentFail' => false - )); - if (isset($task['id'])) { - $this->templateData['ldadpid'] = $task['id']; - $parent = $task['id']; - } - return $parent; - } + } diff --git a/modules-available/backup/templates/restore.html b/modules-available/backup/templates/restore.html index 4494a993..5de7d1cc 100644 --- a/modules-available/backup/templates/restore.html +++ b/modules-available/backup/templates/restore.html @@ -2,8 +2,8 @@ <div class="panel-heading">{{lang_backup}}</div> <div class="panel-body"> <div id="zeug"> - <div data-tm-id="{{syncid}}" data-tm-log="messages">{{lang_stopping}} syncdaemon</div> <div data-tm-id="{{dmsdid}}" data-tm-log="messages">{{lang_stopping}} dmsd</div> + <div data-tm-id="{{dnbd3id}}" data-tm-log="messages">{{lang_stopping}} DNBD3</div> <div data-tm-id="{{ldadpid}}" data-tm-log="messages">{{lang_stopping}} ldadp</div> <div data-tm-id="{{mountid}}" data-tm-log="messages">{{lang_stopping}} vmstore</div> <div data-tm-id="{{restoreid}}" data-tm-log="messages" data-tm-callback="restoreCb">{{lang_restoreConfig}}</div> @@ -19,6 +19,7 @@ </div> <script type="text/javascript"> + var slxDotInterval = false; function restoreCb(task) { if (!task || !task.statusCode) diff --git a/modules-available/baseconfig/inc/baseconfigutil.inc.php b/modules-available/baseconfig/inc/baseconfigutil.inc.php index 3039ea12..a48eb93b 100644 --- a/modules-available/baseconfig/inc/baseconfigutil.inc.php +++ b/modules-available/baseconfig/inc/baseconfigutil.inc.php @@ -37,12 +37,18 @@ class BaseConfigUtil return $settings; } + /** + * Get configuration categories for given module, or all modules if false is passed. + * + * @param \Module $module + * @return array + */ public static function getCategories($module = false) { $categories = array(); if ($module === false) { $module = '*'; - } else { + } elseif (is_object($module)) { $module = $module->getIdentifier(); } foreach (glob("modules/{$module}/baseconfig/categories.json", GLOB_NOSORT) as $file) { @@ -61,8 +67,8 @@ class BaseConfigUtil /** * Mark variables that would be shadowed according to the given values. * - * @param $vars list of vars as obtained from BaseConfigUtil::getVariables() - * @param $values key-value-pairs of variable assignments to work with + * @param array $vars list of vars as obtained from BaseConfigUtil::getVariables() + * @param array $values key-value-pairs of variable assignments to work with */ public static function markShadowedVars(&$vars, $values) { foreach ($vars as $key => &$var) { diff --git a/modules-available/baseconfig/inc/validator.inc.php b/modules-available/baseconfig/inc/validator.inc.php index d65b592c..2dfeed7c 100644 --- a/modules-available/baseconfig/inc/validator.inc.php +++ b/modules-available/baseconfig/inc/validator.inc.php @@ -99,7 +99,7 @@ class Validator return $displayValue; } - private static function validateMultiInput(&$list, &$displayValue) + private static function validateMultiInput($list, &$displayValue) { return $displayValue; } diff --git a/modules-available/baseconfig/page.inc.php b/modules-available/baseconfig/page.inc.php index 366a1238..426d3fdd 100644 --- a/modules-available/baseconfig/page.inc.php +++ b/modules-available/baseconfig/page.inc.php @@ -30,11 +30,14 @@ class Page_BaseConfig extends Page $qry_values = ', :enabled'; $qry_update = ', enabled = :enabled'; $params = array(); + $delExtra = ''; } elseif (empty($this->qry_extra['field'])) { // Module specific, but module doesn't have an extra field $qry_insert = ''; $qry_values = ''; $qry_update = ''; + $params = array(); + $delExtra = ''; } else { // Module with extra field $qry_insert = ', ' . $this->qry_extra['field']; @@ -290,7 +293,7 @@ class Page_BaseConfig extends Page /** * Create html snippet for setting, based on given validator - * @param type $validator + * @param string $validator * @return boolean */ private function makeInput($validator, $setting, $current, $shadows) diff --git a/modules-available/baseconfig/templates/_page.html b/modules-available/baseconfig/templates/_page.html index f2dfd17b..89caf9f2 100644 --- a/modules-available/baseconfig/templates/_page.html +++ b/modules-available/baseconfig/templates/_page.html @@ -127,7 +127,7 @@ document.addEventListener("DOMContentLoaded", function () { }); /* data-shadowing bindings */ - $allShadowingFields = $('[data-shadows]'); + var $allShadowingFields = $('[data-shadows]'); $allShadowingFields.on('change', function (event) { updateShadows(event.target); }); $allShadowingFields.each(function (idx, elem) { updateShadows(elem); }); }); diff --git a/modules-available/baseconfig_bwidm/hooks/translation.inc.php b/modules-available/baseconfig_bwidm/hooks/translation.inc.php index 00898075..5ccafbc4 100644 --- a/modules-available/baseconfig_bwidm/hooks/translation.inc.php +++ b/modules-available/baseconfig_bwidm/hooks/translation.inc.php @@ -15,7 +15,9 @@ $HANDLER['subsections'] = array( */ /** - * Configuration categories + * Configuration categories. + * @param \Module $module + * @return array */ $HANDLER['grep_config-variable-categories'] = function($module) { if (!$module->activate()) @@ -28,7 +30,9 @@ $HANDLER['grep_config-variable-categories'] = function($module) { }; /** - * Configuration variables + * Configuration variables. + * @param \Module $module + * @return array */ $HANDLER['grep_config-variables'] = function($module) { if (!$module->activate()) diff --git a/modules-available/baseconfig_bwlp/hooks/translation.inc.php b/modules-available/baseconfig_bwlp/hooks/translation.inc.php index 00898075..5ccafbc4 100644 --- a/modules-available/baseconfig_bwlp/hooks/translation.inc.php +++ b/modules-available/baseconfig_bwlp/hooks/translation.inc.php @@ -15,7 +15,9 @@ $HANDLER['subsections'] = array( */ /** - * Configuration categories + * Configuration categories. + * @param \Module $module + * @return array */ $HANDLER['grep_config-variable-categories'] = function($module) { if (!$module->activate()) @@ -28,7 +30,9 @@ $HANDLER['grep_config-variable-categories'] = function($module) { }; /** - * Configuration variables + * Configuration variables. + * @param \Module $module + * @return array */ $HANDLER['grep_config-variables'] = function($module) { if (!$module->activate()) diff --git a/modules-available/dnbd3/page.inc.php b/modules-available/dnbd3/page.inc.php index 39500f83..1fa38805 100644 --- a/modules-available/dnbd3/page.inc.php +++ b/modules-available/dnbd3/page.inc.php @@ -230,7 +230,7 @@ class Page_Dnbd3 extends Page $stats['bytesReceived_s'] = Util::readableFileSize($stats['bytesReceived']); $stats['uptime_s'] = floor($stats['uptime'] / 86400) . 'd ' . gmdate('H:i:s', $stats['uptime']); Render::addTemplate('page-proxy-stats', $stats); - $images = Dnbd3Rpc::query($server['ip'], 5003,false, false, true); + // TODO $images = Dnbd3Rpc::query($server['ip'], 5003,false, false, true); $confAlts = Dnbd3Rpc::query($server['ip'], 5003,false, false, false, false, true, true); $ips = array(); $sort = array(); diff --git a/modules-available/dozmod/inc/pagedozmodlog.inc.php b/modules-available/dozmod/inc/pagedozmodlog.inc.php index 957abd2f..80441cd1 100644 --- a/modules-available/dozmod/inc/pagedozmodlog.inc.php +++ b/modules-available/dozmod/inc/pagedozmodlog.inc.php @@ -48,7 +48,7 @@ class Page_dozmod_log extends Page . ' WHERE userid = :uuid' . ' LIMIT 1', array('uuid' => $this->uuid)); if ($user === false) { - Message:addError('unknown-userid', $this->uuid); + Message::addError('unknown-userid', $this->uuid); Util::redirect('?do=dozmod§ion=actionlog'); } // Mangle date and render @@ -70,7 +70,7 @@ class Page_dozmod_log extends Page // We have to guess what kind of target it is if (!$this->addImageHeader() && !$this->addLectureHeader()) { - Message:addError('unknown-targetid', $this->uuid); + Message::addError('unknown-targetid', $this->uuid); // Keep going, there might still be log entries for a deleted uuid } diff --git a/modules-available/dozmod/templates/orglist.html b/modules-available/dozmod/templates/orglist.html index 5224c962..33db955a 100644 --- a/modules-available/dozmod/templates/orglist.html +++ b/modules-available/dozmod/templates/orglist.html @@ -33,6 +33,7 @@ function seto(action, el, orgid) { var box = $(el); + var $notification; box = box.parent(); var v = el.checked ? '1' : '0'; var old = el.checked == true; diff --git a/modules-available/dozmod/templates/userlist.html b/modules-available/dozmod/templates/userlist.html index 378a2be1..b8080b44 100644 --- a/modules-available/dozmod/templates/userlist.html +++ b/modules-available/dozmod/templates/userlist.html @@ -56,6 +56,7 @@ function setu(action, el, uid) { var box = $(el); + var $notification; box = box.parent(); var v = el.checked ? '1' : '0'; var old = el.checked == true; diff --git a/modules-available/exams/page.inc.php b/modules-available/exams/page.inc.php index a6bd7e16..75fb6a0b 100644 --- a/modules-available/exams/page.inc.php +++ b/modules-available/exams/page.inc.php @@ -330,9 +330,9 @@ class Page_Exams extends Page die('delete only works with a post request'); } $examid = Request::post('examid'); - $res = Database::exec("DELETE FROM exams WHERE examid = :examid;", compact('examid')); - $res = Database::exec("DELETE FROM exams_x_location WHERE examid = :examid;", compact('examid')); - if ($res === false) { + $res1 = Database::exec("DELETE FROM exams WHERE examid = :examid;", compact('examid')); + $res2 = Database::exec("DELETE FROM exams_x_location WHERE examid = :examid;", compact('examid')); + if ($res1 === false || $res2 === false) { Message::addError('exam-not-deleted-error'); } else { Message::addInfo('exam-deleted-success'); diff --git a/modules-available/exams/templates/page-exams-vis.html b/modules-available/exams/templates/page-exams-vis.html index caf4aea2..5c14c4a6 100644 --- a/modules-available/exams/templates/page-exams-vis.html +++ b/modules-available/exams/templates/page-exams-vis.html @@ -11,6 +11,7 @@ +<!--suppress JSDeprecatedSymbols --> <script type="application/javascript"><!-- diff --git a/modules-available/locationinfo/frontend/frontendscript.js b/modules-available/locationinfo/frontend/frontendscript.js index cc5c6827..bad6a8ed 100644 --- a/modules-available/locationinfo/frontend/frontendscript.js +++ b/modules-available/locationinfo/frontend/frontendscript.js @@ -45,7 +45,7 @@ function toInt(str) { * @param {Array} globalConfig * @returns {string} printable time */ -function GetTimeDiferenceAsString(a, b, globalConfig = null) { +function GetTimeDiferenceAsString(a, b, globalConfig) { if (!a || !b) { return ""; } diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php index adff8b1b..94c967de 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_dummy.inc.php @@ -137,5 +137,3 @@ class CourseBackend_Dummy extends CourseBackend } } - -?> diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 2ed3622d..e3d7db3d 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -11,9 +11,7 @@ class LocationInfo */ public static function getPcState($pc) { - $logintime = (int)$pc['logintime']; $lastseen = (int)$pc['lastseen']; - $lastboot = (int)$pc['lastboot']; $NOW = time(); if ($pc['state'] === 'OFFLINE' && $NOW - $lastseen > 21 * 86400) { diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index c6aa0860..d4a2b35e 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -392,7 +392,7 @@ class Page_LocationInfo extends Page $credentialsOk = $serverInstance->setCredentials($serverid, json_decode($dbresult['credentials'], true)); if ($credentialsOk) { - $connectionOk = $serverInstance->checkConnection(); + $serverInstance->checkConnection(); } LocationInfo::setServerError($serverid, $serverInstance->getError()); diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html index 92cad055..e457f68d 100755 --- a/modules-available/locationinfo/templates/frontend-default.html +++ b/modules-available/locationinfo/templates/frontend-default.html @@ -369,6 +369,7 @@ optional: </div> </body> +<!--suppress RedundantIfStatementJS --> <script type="text/javascript"> var rooms = {}; var lastRoomUpdate = 0; diff --git a/modules-available/locationinfo/templates/page-panels.html b/modules-available/locationinfo/templates/page-panels.html index f374e456..e17b6584 100644 --- a/modules-available/locationinfo/templates/page-panels.html +++ b/modules-available/locationinfo/templates/page-panels.html @@ -11,8 +11,8 @@ {{#hasRunmode}} <th class="slx-smallcol">{{lang_runmodeTHead}}</th> {{/hasRunmode}} - <th class="slx-smallcol"></th> - <th class="slx-smallcol"></th> + <th class="slx-smallcol">{{lang_edit}}</th> + <th class="slx-smallcol">{{lang_delete}}</th> </tr> </thead> <tbody> @@ -43,13 +43,11 @@ <td> <a class="btn btn-default btn-xs" href="?do=locationinfo&show=edit-panel&uuid={{paneluuid}}"> <span class="glyphicon glyphicon-cog"></span> - {{lang_edit}} </a> </td> <td> <button type="submit" name="uuid" value="{{paneluuid}}" class="btn btn-danger btn-xs"> <span class="glyphicon glyphicon-trash"></span> - {{lang_delete}} </button> </td> </tr> @@ -58,16 +56,16 @@ </tbody> </table> -<div> - <a class="btn btn-sm btn-success" href="?do=locationinfo&show=edit-panel&uuid=new-default"> +<div class="buttonbar text-right"> + <a class="btn btn-success" href="?do=locationinfo&show=edit-panel&uuid=new-default"> <span class="glyphicon glyphicon-plus"></span> {{lang_defaultPanel}} </a> - <a class="btn btn-sm btn-success" href="?do=locationinfo&show=edit-panel&uuid=new-summary"> + <a class="btn btn-success" href="?do=locationinfo&show=edit-panel&uuid=new-summary"> <span class="glyphicon glyphicon-plus"></span> {{lang_summaryPanel}} </a> - <a class="btn btn-sm btn-success" href="?do=locationinfo&show=edit-panel&uuid=new-url"> + <a class="btn btn-success" href="?do=locationinfo&show=edit-panel&uuid=new-url"> <span class="glyphicon glyphicon-plus"></span> {{lang_urlPanel}} </a> diff --git a/modules-available/main/hooks/translation.inc.php b/modules-available/main/hooks/translation.inc.php index 03fa5f79..7590dcb6 100644 --- a/modules-available/main/hooks/translation.inc.php +++ b/modules-available/main/hooks/translation.inc.php @@ -18,6 +18,9 @@ $HANDLER['subsections'] = array( * Global tags. * This just returns the union of global tags of all languages, as there is no * way to define a definite set of required global tags. + * + * @param Module $module + * @return array dem tags */ $HANDLER['grep_global-tags'] = function($module) { $want = array(); diff --git a/modules-available/news/page.inc.php b/modules-available/news/page.inc.php index 5ad79b0e..399fc307 100644 --- a/modules-available/news/page.inc.php +++ b/modules-available/news/page.inc.php @@ -2,21 +2,29 @@ class Page_News extends Page { - /** - * Member variables needed to represent a news entry. - * - * @var newsId int ID of the news entry attributed by the database. - * @var string Title of the entry. - * $newsContent string Content as text. (TODO: html-Support?) - * $newsDate string Unix epoch date of the news' creation. - */ - private $newsId = false; - private $newsTitle = false; - private $newsContent = false; - private $newsDate = false; - private $helpContent = ''; - private $editHelp = false; - private $hasSummernote = false; + /* + * Member variables needed to represent a news entry. + */ + + /** + * @var int ID of the news entry attributed by the database. + */ + private $newsId = false; + /** + * @var string Title of the entry. + */ + private $newsTitle = false; + /** + * @var string Content as text. (TODO: html-Support?) + */ + private $newsContent = false; + /** + * @var int Unix epoch date of the news' creation. + */ + private $newsDate = false; + private $helpContent = ''; + private $editHelp = false; + private $hasSummernote = false; /** * Implementation of the abstract doPreprocess function. diff --git a/modules-available/permissionmanager/inc/permissionutil.inc.php b/modules-available/permissionmanager/inc/permissionutil.inc.php index 64fe8f26..6fc33ad1 100644 --- a/modules-available/permissionmanager/inc/permissionutil.inc.php +++ b/modules-available/permissionmanager/inc/permissionutil.inc.php @@ -101,7 +101,6 @@ class PermissionUtil $tree =& $tree[$subPermission]; } } - $tree = $description; return $original; } }
\ No newline at end of file diff --git a/modules-available/rebootcontrol/inc/rebootqueries.inc.php b/modules-available/rebootcontrol/inc/rebootqueries.inc.php index 1bdcb9a2..3dc3183f 100644 --- a/modules-available/rebootcontrol/inc/rebootqueries.inc.php +++ b/modules-available/rebootcontrol/inc/rebootqueries.inc.php @@ -27,7 +27,6 @@ class RebootQueries $leftJoin WHERE $where AND machine.lastseen > :cutoff", $queryArgs); $ret = $res->fetchAll(PDO::FETCH_ASSOC); - $NOW = time(); foreach ($ret as &$row) { if ($row['state'] === 'IDLE' || $row['state'] === 'OCCUPIED') { $row['status'] = 1; diff --git a/modules-available/rebootcontrol/page.inc.php b/modules-available/rebootcontrol/page.inc.php index db7882d9..fc3ded8f 100644 --- a/modules-available/rebootcontrol/page.inc.php +++ b/modules-available/rebootcontrol/page.inc.php @@ -33,7 +33,6 @@ class Page_RebootControl extends Page } $shutdown = $this->action === "startShutdown"; $minutes = Request::post('minutes', 0, 'int'); - $privKey = SSHKey::getPrivateKey(); $list = RebootQueries::getMachinesByUuid($clients); if (count($list) !== count($clients)) { diff --git a/modules-available/roomplanner/clientscript.js b/modules-available/roomplanner/clientscript.js index 5c9776b2..bd29c06c 100644 --- a/modules-available/roomplanner/clientscript.js +++ b/modules-available/roomplanner/clientscript.js @@ -11,6 +11,9 @@ var selectMachinInitialized = false; var placedMachines = []; +var $modal, $selectizeSearch; +var currentCallback = false; + function makeCombinedFieldSingle(item) { item.combined = (item.machineuuid + " " + item.hostname + " " + item.clientip + " " + item.macaddr + " " + item.macaddr.replace(/-/g, ':')).toLocaleLowerCase(); diff --git a/modules-available/roomplanner/inc/pvsgenerator.inc.php b/modules-available/roomplanner/inc/pvsgenerator.inc.php index 292441d4..cda32fce 100644 --- a/modules-available/roomplanner/inc/pvsgenerator.inc.php +++ b/modules-available/roomplanner/inc/pvsgenerator.inc.php @@ -54,7 +54,6 @@ class PvsGenerator /* collect names and build room blocks - filter empty rooms while at it */ $roomNames = array(); $roomBlocks = ''; - $overrides = []; foreach ($rooms as $room) { if (is_null($room['notnull']) || isset($room['skip'])) // Not leaf continue; diff --git a/modules-available/roomplanner/js/lib/jquery-collision.js b/modules-available/roomplanner/js/lib/jquery-collision.js index 98e37882..eae7ef85 100644 --- a/modules-available/roomplanner/js/lib/jquery-collision.js +++ b/modules-available/roomplanner/js/lib/jquery-collision.js @@ -175,11 +175,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. { if( ! inclusive ) inclusive = false; var epsilon = ( inclusive ? -1 : +1 ) * CollisionCoords.EPSILON; - if( ( x > ( this.x1 + epsilon ) && x < ( this.x2 - epsilon ) ) && - ( y > ( this.y1 + epsilon ) && y < ( this.y2 - epsilon ) ) ) - return true; - else - return false; + return (x > (this.x1 + epsilon) && x < (this.x2 - epsilon)) && + (y > (this.y1 + epsilon) && y < (this.y2 - epsilon)); }; CollisionCoords.prototype.overlaps = function( other, inclusive ) @@ -189,16 +186,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. hit = other._overlaps( this, inclusive ); if( hit.length > 0 ) { - hit[0].dir = hit[0].dir == "Inside" ? "Outside" : - hit[0].dir == "Outside" ? "Inside" : - hit[0].dir == "N" ? "S" : - hit[0].dir == "S" ? "N" : - hit[0].dir == "W" ? "E" : - hit[0].dir == "E" ? "W" : - hit[0].dir == "NE" ? "SW" : - hit[0].dir == "SW" ? "NE" : - hit[0].dir == "SE" ? "NW" : - hit[0].dir == "NW" ? "SE" : + hit[0].dir = hit[0].dir === "Inside" ? "Outside" : + hit[0].dir === "Outside" ? "Inside" : + hit[0].dir === "N" ? "S" : + hit[0].dir === "S" ? "N" : + hit[0].dir === "W" ? "E" : + hit[0].dir === "E" ? "W" : + hit[0].dir === "NE" ? "SW" : + hit[0].dir === "SW" ? "NE" : + hit[0].dir === "SE" ? "NW" : + hit[0].dir === "NW" ? "SE" : undefined; } return hit || []; diff --git a/modules-available/statistics/inc/parser.inc.php b/modules-available/statistics/inc/parser.inc.php index acf6ebd4..679055a7 100644 --- a/modules-available/statistics/inc/parser.inc.php +++ b/modules-available/statistics/inc/parser.inc.php @@ -99,8 +99,8 @@ class Parser { $hdds = array(); // Could have more than one disk - linear scan $lines = preg_split("/[\r\n]+/", $data); - $dev = false; $i = 0; + $mbrToMbFactor = $sectorToMbFactor = 0; foreach ($lines as $line) { if (preg_match('/^Disk (\S+):.* (\d+) bytes/i', $line, $out)) { // --- Beginning of MBR disk --- @@ -260,7 +260,6 @@ class Parser { public static function parseSmartctl(&$hdds, $data) { $lines = preg_split("/[\r\n]+/", $data); - $i = 0; foreach ($lines as $line) { if (preg_match('/^NEXTHDD=(.+)$/', $line, $out)) { unset($dev); diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php index c3ecf52b..bd67123e 100644 --- a/modules-available/statistics/page.inc.php +++ b/modules-available/statistics/page.inc.php @@ -622,7 +622,6 @@ class Page_Statistics extends Page . ' badsectors ' . $xtra . ' FROM machine' . " $join WHERE $where $sort", $args); $rows = array(); - $NOW = time(); $singleMachine = 'none'; while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if ($singleMachine === 'none') { @@ -894,7 +893,7 @@ class Page_Statistics extends Page continue; // Don't differentiate between session and idle for non-clients if ($first && $row['dateline'] > $cutoff && $client['lastboot'] > $cutoff) { // Special case: offline before - $spans['graph'] .= '<div style="background:#444;left:0%;width:' . round((min($row['dateline'], $client['lastboot']) - $cutoff) * $scale, 2) . '%"> </div>'; + $spans['graph'] .= '<div style="background:#444;left:0;width:' . round((min($row['dateline'], $client['lastboot']) - $cutoff) * $scale, 2) . '%"> </div>'; } $first = false; if ($row['dateline'] + $row['data'] < $cutoff || $row['data'] > 864000) { @@ -931,10 +930,10 @@ class Page_Statistics extends Page } if ($first && $client['lastboot'] > $cutoff) { // Special case: offline before - $spans['graph'] .= '<div style="background:#444;left:0%;width:' . round(($client['lastboot'] - $cutoff) * $scale, 2) . '%"> </div>'; + $spans['graph'] .= '<div style="background:#444;left:0;width:' . round(($client['lastboot'] - $cutoff) * $scale, 2) . '%"> </div>'; } elseif ($first) { // Not seen in last two weeks - $spans['graph'] .= '<div style="background:#444;left:0%;width:100%"> </div>'; + $spans['graph'] .= '<div style="background:#444;left:0;width:100%"> </div>'; } if (isset($client['state_occupied'])) { $spans['graph'] .= '<div style="background:#e99;left:' . round(($client['logintime'] - $cutoff) * $scale, 2) . '%;width:' . round(($NOW - $client['logintime'] + 900) * $scale, 2) . '%"> </div>'; diff --git a/modules-available/statistics/templates/filterbox.html b/modules-available/statistics/templates/filterbox.html index 31daabc6..32464031 100644 --- a/modules-available/statistics/templates/filterbox.html +++ b/modules-available/statistics/templates/filterbox.html @@ -105,6 +105,7 @@ var slxFilterNames = { slxLocations = {{{locations}}}; var slxFilterDel = '{{delimiter}}'; +var $modal, $queryForm; document.addEventListener("DOMContentLoaded", function () { @@ -217,7 +218,7 @@ function popupFilter(field) { function addFilterFromForm() { var argument1 = $('#argumentInput').val(); var argument2 = $('#argumentSelect').val(); - var argument = argument1 == '' ? argument2 : argument1; + var argument = argument1 ? argument1 : argument2; var col = $('#columnSelect').val(); var op = $('#operatorSelect').val(); @@ -246,8 +247,8 @@ function toggleSort(field) { /* equal sign should always be first, the rest doesn't matter*/ function myOpSort(a,b) { - if (a == '=') { return -1; } - else if (a == b) {return 0} + if (a === '=') { return -1; } + else if (a === b) {return 0} else { return 1;} } diff --git a/modules-available/statistics_reporting/inc/queries.inc.php b/modules-available/statistics_reporting/inc/queries.inc.php index 1a125c9e..bd8eb72e 100644 --- a/modules-available/statistics_reporting/inc/queries.inc.php +++ b/modules-available/statistics_reporting/inc/queries.inc.php @@ -5,7 +5,7 @@ class Queries { // Client Data: Name, Time Online, Median Time Online, Time Offline, last start, last logout, Last Time Booted, Number of Sessions > 60Sec, Number of Sessions < 60Sec, name of location, id of location (anonymized), machine uuid (anonymized) - public static function getClientStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24, $excludeToday = false) { + public static function getClientStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24) { $notassigned = Dictionary::translate('notAssigned', true); Database::exec("SET SESSION group_concat_max_len = 1000000000"); $res = Database::simpleQuery("SELECT t2.name AS clientName, timeSum, medianSessionLength, offlineSum, IFNULL(lastStart, 0) as lastStart, IFNULL(lastLogout, 0) as lastLogout, longSessions, shortSessions, t2.locId, t2.locName, MD5(CONCAT(t2.locId, :salt)) AS locHash, MD5(CONCAT(t2.uuid, :salt)) AS clientHash FROM ( @@ -27,7 +27,7 @@ class Queries } // Location Data: Name, ID (anonymized), Time Online, Median Time Online, Time Offline, Number of Sessions > 60Sec, Number of Sessions < 60Sec - public static function getLocationStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24, $excludeToday = false) { + public static function getLocationStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24) { $notassigned = Dictionary::translate('notAssigned', true); Database::exec("SET SESSION group_concat_max_len = 1000000000"); $res = Database::simpleQuery("SELECT t2.locId, t2.locName, MD5(CONCAT(t2.locId, :salt)) AS locHash, timeSum, medianSessionLength, offlineSum, longSessions, shortSessions FROM ( diff --git a/modules-available/statistics_reporting/inc/remotereport.inc.php b/modules-available/statistics_reporting/inc/remotereport.inc.php index e94e9b93..98af8888 100644 --- a/modules-available/statistics_reporting/inc/remotereport.inc.php +++ b/modules-available/statistics_reporting/inc/remotereport.inc.php @@ -96,7 +96,7 @@ class RemoteReport return $result; } - private function getLocalHardware() + private static function getLocalHardware() { $cpuInfo = file_get_contents('/proc/cpuinfo'); $uptime = file_get_contents('/proc/uptime'); diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php index 5d586b6c..863715d4 100644 --- a/modules-available/statistics_reporting/page.inc.php +++ b/modules-available/statistics_reporting/page.inc.php @@ -8,7 +8,18 @@ class Page_Statistics_Reporting extends Page private $type; // "Constants" + /** + * @var int + */ private $days; + /** + * @var int + */ + private $lower; + /** + * @var int + */ + private $upper; /** * @var array Names of columns that are being used by the various tables @@ -306,6 +317,7 @@ class Page_Statistics_Reporting extends Page case 'vm': return GetData::perVM($flags); } + return false; } } diff --git a/modules-available/sysconfig/addconfig.inc.php b/modules-available/sysconfig/addconfig.inc.php index f66bc508..55944cfa 100644 --- a/modules-available/sysconfig/addconfig.inc.php +++ b/modules-available/sysconfig/addconfig.inc.php @@ -22,7 +22,6 @@ abstract class AddConfig_Base /** * * @param string $step - * @return \AddConfig_Base */ public static function setStep($step) { @@ -186,6 +185,9 @@ class AddConfig_Start extends AddConfig_Base */ class AddConfig_Finish extends AddConfig_Base { + /** + * @var ConfigTgz + */ private $config = false; protected function preprocessInternal() diff --git a/modules-available/sysconfig/addmodule.inc.php b/modules-available/sysconfig/addmodule.inc.php index 30ca1d2c..1f78de81 100644 --- a/modules-available/sysconfig/addmodule.inc.php +++ b/modules-available/sysconfig/addmodule.inc.php @@ -21,8 +21,7 @@ abstract class AddModule_Base /** * - * @param type $step - * @return \AddModule_Base + * @param string $step name of class representing the current step */ public static function setStep($step) { diff --git a/modules-available/sysconfig/addmodule_branding.inc.php b/modules-available/sysconfig/addmodule_branding.inc.php index c2f9e690..6e628926 100644 --- a/modules-available/sysconfig/addmodule_branding.inc.php +++ b/modules-available/sysconfig/addmodule_branding.inc.php @@ -116,8 +116,10 @@ class Branding_ProcessFile extends AddModule_Base // [wikipedia] Try to be nice and detect links that might give a hint where the svg can be found if (preg_match_all('#href="([^"]*upload.wikimedia.org/[^"]*/[^"]*/[^"]*\.svg|[^"]+/[^"]+:[^"]+\.svg[^"]*)"#', $content, $out, PREG_PATTERN_ORDER)) { - if ($title === false && preg_match('#<title>([^<]*)</title>#i', $content, $tout)) + if ($title === false && preg_match('#<title>([^<]*)</title>#i', $content, $tout)) { $title = trim(preg_replace('/\W*Wikipedia.*/', '', $tout[1])); + } + $new = false; foreach ($out[1] as $res) { if (strpos($res, 'action=edit') !== false) continue; @@ -125,7 +127,7 @@ class Branding_ProcessFile extends AddModule_Base if ($new !== $url) break; } - if ($new === $url) + if ($new === $url || $new === false) break; $url = $new; continue; diff --git a/modules-available/sysconfig/inc/configmodule.inc.php b/modules-available/sysconfig/inc/configmodule.inc.php index 54d06afe..cfe79802 100644 --- a/modules-available/sysconfig/inc/configmodule.inc.php +++ b/modules-available/sysconfig/inc/configmodule.inc.php @@ -135,7 +135,7 @@ abstract class ConfigModule * Get module instances from module type. * * @param int $moduleType module type to get - * @return \ConfigModule[] The requested modules from DB, or false on error + * @return \ConfigModule[]|false The requested modules from DB, or false on error */ public static function getAll($moduleType = false) { diff --git a/modules-available/sysconfig/inc/configtgz.inc.php b/modules-available/sysconfig/inc/configtgz.inc.php index dbf1bc99..09ea999c 100644 --- a/modules-available/sysconfig/inc/configtgz.inc.php +++ b/modules-available/sysconfig/inc/configtgz.inc.php @@ -232,6 +232,11 @@ class ConfigTgz self::recompress([], SysConfig::GLOBAL_MINIMAL_CONFIG); } + /** + * @param string $title Title of config + * @param int[] $moduleIds Modules to include in config + * @return false|ConfigTgz The module instance, false on error + */ public static function insert($title, $moduleIds) { if (!is_array($moduleIds)) @@ -287,6 +292,10 @@ class ConfigTgz return $instance; } + /** + * @param int $moduleId ID of config module + * @return ConfigTgz[]|false + */ public static function getAllForModule($moduleId) { $res = Database::simpleQuery("SELECT configid, title, filepath FROM configtgz_x_module " diff --git a/modules-available/sysconfig/inc/ppd.inc.php b/modules-available/sysconfig/inc/ppd.inc.php index aa2e0e5a..5ccdbd53 100644 --- a/modules-available/sysconfig/inc/ppd.inc.php +++ b/modules-available/sysconfig/inc/ppd.inc.php @@ -413,6 +413,8 @@ class Ppd // StringValue $value = $vMatch[1]; $valueTranslation = isset($vMatch[2]) ? $this->unhexTranslation($no, substr($vMatch[2], 1)) : $value; + } else { + $valueTranslation = $value; } // Key-value-pair parsed, now the fun part // Special cases for openening closing certain groups @@ -691,6 +693,7 @@ class Ppd $chars = array_reduce(array_unique($array), function ($carry, $item) { return $carry . '\x' . dechex(ord($item)); }, ''); + return $chars; } private function unhexTranslation($lineNo, $translation) @@ -703,7 +706,7 @@ class Ppd } $string = preg_replace('/[^a-fA-F0-9]/', '', $match[0]); if (strlen($string) % 2 !== 0) { - $this->warn('Odd number of hex digits in hex substring'); + $this->warn($lineNo, 'Odd number of hex digits in hex substring'); $string = substr($string, 0, -1); } return pack('H*', $string); diff --git a/modules-available/sysconfignew/page.inc.php b/modules-available/sysconfignew/page.inc.php index 44b385b6..c8cdb3cd 100644 --- a/modules-available/sysconfignew/page.inc.php +++ b/modules-available/sysconfignew/page.inc.php @@ -73,6 +73,7 @@ class Page_SysConfigNew extends Page ); } + $ret = ''; foreach ($modules as $module) { $class = ($module['chosen']) ? "select-item select-item-selected" : "select-item"; $ret .= "<button type='button' class='" . $class . "' onclick='select(this)' >"; diff --git a/modules-available/translation/page.inc.php b/modules-available/translation/page.inc.php index acc0d6e8..a5cdebed 100644 --- a/modules-available/translation/page.inc.php +++ b/modules-available/translation/page.inc.php @@ -132,8 +132,6 @@ class Page_Translation extends Page protected function doRender() { - $langs = Dictionary::getLanguages(true); - // Overview (list of modules) if ($this->module === false) { $this->showListOfModules(); @@ -466,7 +464,7 @@ class Page_Translation extends Page /** * Get all module tags used/required. * - * @param type $module + * @param string $module * @return array of array(tagname => (bool)required) */ private function loadUsedModuleTags($module = false) @@ -507,7 +505,16 @@ class Page_Translation extends Page } return $want; } - + + /** + * Return list of existing tags needing translation. This calls + * the function defined by the module. which is expected to return + * an array serving as a list, where the KEYS are the tags expected, + * the value of each entry can be false if the tag is optional. + * + * @param string $subsection Name of subsection + * @return array|false List of tags as KEYS of array + */ private function loadUsedCustomTags($subsection) { if (!isset($this->customHandler['grep_'.$subsection])) @@ -534,10 +541,10 @@ class Page_Translation extends Page /** * Get missing and unused counters for given module's templates. * - * @param type $lang lang to use - * @param type $tags - * @param type $module - * @return array list(missingCount, unusedCount) + * @param string $lang lang to use + * @param array $tags Array of tags, where the tag names are the keys + * @param \Module|false $module the module to work with, defaults to the currently edited module + * @return array [missingCount, unusedCount] */ private function getModuleTemplateStatus($lang, $tags = false, $module = false) { @@ -553,8 +560,8 @@ class Page_Translation extends Page * @param string $file the name of the translation file to load for checking * @param boolean $fallback whether to check the global-tags of the main module as fallback * @param array $tags list of tags that are expected to exist. Tags are the array keys! - * @param \Module $module the module to work with, defaults to the currently edited module - * @return array list(missingCount, unusedCount) + * @param \Module|false $module the module to work with, defaults to the currently edited module + * @return array [missingCount, unusedCount] */ private function getModuleTranslationStatus($lang, $file, $fallback, $tags, $module = false) { @@ -663,8 +670,6 @@ class Page_Translation extends Page private function loadTemplateEditArray() { $tags = $this->loadUsedTemplateTags(); - if ($tags === false) - return false; $table = $this->buildTranslationTable('template-tags', array_keys($tags), true); $global = Dictionary::getArray($this->module->getIdentifier(), 'global-tags', $this->destLang); foreach ($table as &$entry) { @@ -833,6 +838,12 @@ class Page_Translation extends Page return $tags; } + /** + * @param string $file Source dictionary + * @param string[]|false $requiredTags Tags that are considered required + * @param bool $findAlreadyTranslated If true, try to find a translation for this string in another language + * @return array numeric array suitable for passing to mustache + */ private function buildTranslationTable($file, $requiredTags = false, $findAlreadyTranslated = false) { $tags = array(); @@ -891,7 +902,7 @@ class Page_Translation extends Page * user selected, then english, then everything else. * * @param string $file translation unit - * @param type $tags list of tags, formatted as used in buildTranslationTable() + * @param array $tags list of tags, formatted as used in buildTranslationTable() */ private function findTranslationSamples($file, &$tags) { diff --git a/script/install.js b/script/install.js index abb76d6f..719fab41 100644 --- a/script/install.js +++ b/script/install.js @@ -10,7 +10,7 @@ function slxRunInstall() { onceOnlyGoddammit = true; $('.install-btn').prop('disabled', true); var first = false; - list = $('.id-col').each(function () { + $('.id-col').each(function () { var id = $(this).text(); slxModules[id] = 'IDLE'; slxTries[id] = 0; diff --git a/tools/convert-modules.php b/tools/convert-modules.php index 9b479886..f8c7a1a5 100644 --- a/tools/convert-modules.php +++ b/tools/convert-modules.php @@ -182,8 +182,8 @@ foreach ($messages as $id => $modules) { asort($modules, SORT_NUMERIC); $modules = array_reverse($modules, true); reset($modules); - list($topModule, $topCount) = each($modules); - reset($modules); + $topModule = key($modules); + $topCount = $modules[$topModule]; $sum = 0; foreach ($modules as $c) { $sum += $c; |