Skip to content

Commit

Permalink
code cleaning with phpstorm code inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoffy committed Feb 20, 2023
1 parent 00f83a9 commit 9785bab
Show file tree
Hide file tree
Showing 103 changed files with 499 additions and 547 deletions.
26 changes: 11 additions & 15 deletions admin/account.php
Expand Up @@ -50,7 +50,7 @@

$GLOBALS['xoopsTpl']->assign('account_check', true);

if (0 == $accId) {
if (0 === $accId) {
redirect_header('account.php', 3, _MA_WGEVENTS_INVALID_PARAM);
} else {
$accountObj = $helper->getHandler('Account')->get($accId);
Expand Down Expand Up @@ -78,35 +78,33 @@
$account_username = $accountObj->getVar('username');

$command = $account_server_in . ':' . $account_port_in;
if ('' != $service) {
if ('' !== $service) {
$command .= '/' . $service;
}
if ('' != $account_securetype_in) {
if ('' !== $account_securetype_in) {
$command .= '/' . $account_securetype_in;
}
$logDetails .= '<br>command:' . $command;

$checks = [];

$mbox = @imap_open('{' . $command . '}', $account_username, $account_password);
$checks['openmailbox']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OPEN_MAILBOX;
if (false === $mbox) {
$checks['openmailbox']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OPEN_MAILBOX;
$checks['openmailbox']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED;
$checks['openmailbox']['result_img'] = $imgFailed;
$checks['openmailbox']['info'] = \imap_last_error();
} else {
$checks['openmailbox']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OPEN_MAILBOX;
$checks['openmailbox']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OK;
$checks['openmailbox']['result_img'] = $imgOK;

$folders = \imap_list($mbox, '{' . $command . '}', '*');
$checks['listfolder']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_LIST_FOLDERS;
if (false === $folders) {
$checks['listfolder']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_LIST_FOLDERS;
$checks['listfolder']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED;
$checks['listfolder']['result_img'] = $imgFailed;
$checks['listfolder']['info'] = \imap_last_error();
} else {
$checks['listfolder']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_LIST_FOLDERS;
$checks['listfolder']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OK;
$checks['listfolder']['result_img'] = $imgOK;
$checks['listfolder']['info'] = \implode('<br>', $folders);
Expand Down Expand Up @@ -181,15 +179,13 @@
$logHandler->createLog($logDetails);

//execute sending
$export = \var_export($xoopsMailer, TRUE);
$export = \preg_replace("/\n/", '<br>', $export);
if ($xoopsMailer->send()) {
$export = var_export($xoopsMailer, TRUE);
$export = \preg_replace("/\n/", '<br>', $export);
$logHandler->createLog('Result Test send mail to ' . $usermail .': success' . '<br>' . $export);
$result = \_AM_WGEVENTS_ACCOUNT_CHECK_OK . '<br>' . $xoopsMailer->getErrors();;
$result = \_AM_WGEVENTS_ACCOUNT_CHECK_OK . '<br>' . $xoopsMailer->getErrors();
$resultImg = $imgOK;
} else {
$export = var_export($xoopsMailer, TRUE);
$export = \preg_replace("/\n/", '<br>', $export);
$logHandler->createLog('Result Test send mail to ' . $usermail .': failed - ' . $xoopsMailer->getErrors() . '<br>' . $export);
$result = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED . '<br>' . $xoopsMailer->getErrors();
$resultImg = $imgFailed;
Expand Down Expand Up @@ -222,8 +218,8 @@
default:
$crAccount = new \CriteriaCompo();
$crAccount->add(new \Criteria('primary', 1));
$primaryCount = $accountHandler->getCount($crAccount);
if (0 == $primaryCount) {
$accountsCount = $accountHandler->getCount($crAccount);
if (0 === $accountsCount) {
$GLOBALS['xoopsTpl']->assign('info', \_AM_WGEVENTS_THEREARENT_ACCOUNTS_DESC);
}
// Define Stylesheet
Expand Down Expand Up @@ -335,7 +331,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('account.php'));
$accountObj = $accountHandler->get($accId);
$accType = $accountObj->getVar('type');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('account.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand Down
2 changes: 1 addition & 1 deletion admin/answer.php
Expand Up @@ -157,7 +157,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php'));
$answerObj = $answerHandler->get($ansId);
$ansEvid = $answerObj->getVar('evid');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('answer.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand Down
2 changes: 1 addition & 1 deletion admin/answerhist.php
Expand Up @@ -97,7 +97,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php'));
$answerObj = $answerHandler->get($ansId);
$ansEvid = $answerObj->getVar('evid');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('answer.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand Down
4 changes: 2 additions & 2 deletions admin/category.php
Expand Up @@ -50,7 +50,7 @@
$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
$categoryCount = $categoryHandler->getCountCategories();
$categoryAll = $categoryHandler->getAllCategories();
$GLOBALS['xoopsTpl']->assign('categorieCount', $categoryCount);
$GLOBALS['xoopsTpl']->assign('categoryCount', $categoryCount);
$GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL);
$GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL);
$GLOBALS['xoopsTpl']->assign('wgevents_icons_url_16', \WGEVENTS_ICONS_URL_16);
Expand Down Expand Up @@ -265,7 +265,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('category.php'));
$categoryObj = $categoryHandler->get($catId);
$catName = $categoryObj->getVar('name');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('category.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand Down
10 changes: 5 additions & 5 deletions admin/clone.php
Expand Up @@ -66,7 +66,7 @@
];

$patKeys = \array_keys($patterns);
$patValuess = \array_values($patterns);
$patValues = \array_values($patterns);
cloneFileFolder(\WGEVENTS_PATH);
$logocreated = createLogo(\mb_strtolower($clone));

Expand Down Expand Up @@ -97,10 +97,10 @@
function cloneFileFolder($path)
{
global $patKeys;
global $patValuess;
global $patValues;

//remove \XOOPS_ROOT_PATH and add after replace, otherwise there can be a bug if \XOOPS_ROOT_PATH contains same pattern
$newPath = \XOOPS_ROOT_PATH . \str_replace($patKeys[0], $patValuess[0], \substr($path, \strlen(\XOOPS_ROOT_PATH)));
$newPath = \XOOPS_ROOT_PATH . \str_replace($patKeys[0], $patValues[0], \substr($path, \strlen(\XOOPS_ROOT_PATH)));

if (\is_dir($path)) {
// create new dir
Expand All @@ -113,7 +113,7 @@ function cloneFileFolder($path)
if ($handle) {
while (false !== ($file = \readdir($handle))) {
if (0 !== \mb_strpos($file, '.')) {
cloneFileFolder("{$path}/{$file}");
cloneFileFolder("$path/$file");
}
}
\closedir($handle);
Expand All @@ -126,7 +126,7 @@ function cloneFileFolder($path)
} else {
// file, read it
$content = \file_get_contents($path);
$content = \str_replace($patKeys, $patValuess, $content);
$content = \str_replace($patKeys, $patValues, $content);
\file_put_contents($newPath, $content);
}
}
Expand Down
10 changes: 5 additions & 5 deletions admin/event.php
Expand Up @@ -133,11 +133,11 @@
$uploaderErrors .= '<br>' . $uploader->getErrors();
}
} else {
if ('' != $filename) {
if ('' !== $filename) {
$uploaderErrors .= '<br>' . $uploader->getErrors();
}
$filename = Request::getString('logo');
if ('' != $filename) {
if ('' !== $filename) {
$eventObj->setVar('logo', $filename);
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@
$eventObj->setVar('register_sendermail', Request::getString('register_sendermail'));
$eventObj->setVar('register_sendername', Request::getString('register_sendername'));
$eventObj->setVar('register_signature', Request::getString('register_signature'));
} else if ($evId > 0) {
} elseif ($evId > 0) {
//reset previous values
$eventObj->setVar('register_to', 0);
$eventObj->setVar('register_max', 0);
Expand All @@ -226,7 +226,7 @@
if (in_array('00000', $arrGroups)) {
$eventObj->setVar('groups', '00000');
} else {
$eventObj->setVar('groups', implode("|", $arrGroups));
$eventObj->setVar('groups', implode('|', $arrGroups));
}
$eventObj->setVar('identifier', Request::getString('identifier'));
$eventDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated'));
Expand Down Expand Up @@ -265,7 +265,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('event.php'));
$eventObj = $eventHandler->get($evId);
$evName = $eventObj->getVar('name');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('event.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand Down
2 changes: 1 addition & 1 deletion admin/fee.php
Expand Up @@ -135,7 +135,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('fee.php'));
$feeObj = $feeHandler->get($Id);
$Evid = $feeObj->getVar('evid');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('fee.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand Down
2 changes: 0 additions & 2 deletions admin/feedback.php
Expand Up @@ -34,8 +34,6 @@
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
\xoops_loadLanguage('feedback', $moduleDirName);

//xoops_cp_header();

switch ($op) {
case 'list':
default:
Expand Down
15 changes: 8 additions & 7 deletions admin/field.php
Expand Up @@ -50,7 +50,7 @@
$adminObject->addItemButton(\_AM_WGEVENTS_FIELD_CREATE_DEFAULT, 'field.php?op=default_set');
$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
$fieldCount = $fieldHandler->getCountFields();
if (0 == $fieldCount) {
if (0 === $fieldCount) {
// load default set
\redirect_header('field.php?op=default_set', 0);
}
Expand Down Expand Up @@ -111,7 +111,7 @@
$fieldObj->setVar('desc', Request::getText('desc'));
$atValuesText = '';
$fdValues = Request::getString('values');
if ('' != $fdValues) {
if ('' !== $fdValues) {
if (Constants::FIELD_COMBOBOX == $fdType || Constants::FIELD_SELECTBOX == $fdType || Constants::FIELD_RADIO == $fdType) {
$atValuesText = \serialize(\preg_split('/\r\n|\r|\n/', $fdValues));
} else {
Expand Down Expand Up @@ -160,7 +160,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('field.php'));
$fieldObj = $fieldHandler->get($atId);
$atName = $fieldObj->getVar('caption');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('field.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand All @@ -181,7 +181,7 @@
case 'default_set':
$templateMain = 'wgevents_admin_field.tpl';
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('field.php'));
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('field.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand All @@ -199,7 +199,7 @@
$fieldObj->setVar('desc', $item['desc']);
$fdValues = (string)$item['values'];
$atValuesText = '';
if ('' != $fdValues) {
if ('' !== $fdValues) {
$tmpArr[] = $fdValues;
$atValuesText = \serialize($tmpArr);
}
Expand Down Expand Up @@ -250,10 +250,11 @@
}
require __DIR__ . '/footer.php';

/**
* @return array
*/
function BuildDefaultSet () {
$defaultSet = [];
$i = 0;

$defaultSet[] = [
'type' => Constants::FIELD_LABEL,
'caption' => \_MA_WGEVENTS_FIELD_LABEL,
Expand Down
2 changes: 1 addition & 1 deletion admin/footer.php
Expand Up @@ -21,7 +21,7 @@

if (isset($templateMain)) {
$GLOBALS['xoopsTpl']->assign('maintainedby', $helper->getConfig('maintainedby'));
$GLOBALS['xoopsTpl']->display("db:{$templateMain}");
$GLOBALS['xoopsTpl']->display("db:$templateMain");
}

$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
Expand Down
2 changes: 1 addition & 1 deletion admin/header.php
Expand Up @@ -79,7 +79,7 @@
$GLOBALS['xoopsTpl']->assign('tablesorter_of', \_AM_WGEVENTS_TABLESORTER_OF);
$GLOBALS['xoopsTpl']->assign('tablesorter_total', \_AM_WGEVENTS_TABLESORTER_TOTALROWS);
$GLOBALS['xoopsTpl']->assign('tablesorter_pagesize', $helper->getConfig('adminpager'));
if ('d.m.Y' == _SHORTDATESTRING) {
if ('d.m.Y' === \_SHORTDATESTRING) {
$dateformat = 'ddmmyyyy';
} else {
$dateformat = 'mmddyyyy';
Expand Down
20 changes: 10 additions & 10 deletions admin/import.php
Expand Up @@ -58,8 +58,8 @@
$modsArray[] = $module->getInfo('dirname');
unset($module);
}
$modulesList[] = ['name' => \_AM_WGEVENTS_IMPORT_APCAL, 'op' => 'apcal', 'installed' => in_array('apcal', $modsArray)];
$modulesList[] = ['name' => \_AM_WGEVENTS_IMPORT_EXTCAL, 'op' => 'extcal', 'installed' => in_array('extcal', $modsArray)];
$modulesList[] = ['name' => \_AM_WGEVENTS_IMPORT_APCAL, 'op' => 'apcal', 'installed' => \in_array('apcal', $modsArray)];
$modulesList[] = ['name' => \_AM_WGEVENTS_IMPORT_EXTCAL, 'op' => 'extcal', 'installed' => \in_array('extcal', $modsArray)];
//TODO:
//$modulesList[] = ['name' => \_AM_WGEVENTS_IMPORT_EGUIDE, 'op' => 'eguide', 'installed' => in_array('eguide', $modsArray)]];
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('import.php'));
Expand Down Expand Up @@ -327,28 +327,28 @@
$resultLoc = $GLOBALS['xoopsDB']->queryF('SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('extcal_location') . ' WHERE id=' . $row['event_location']);
while ($rowLoc = $GLOBALS['xoopsDB']->fetchArray($resultLoc)) {
$location .= $rowLoc['nom'] . PHP_EOL;
if ('' != $rowLoc['adresse']) {
if ('' !== (string)$rowLoc['adresse']) {
$location .= $rowLoc['adresse'] . PHP_EOL;
}
if ('' != $rowLoc['adresse2']) {
if ('' !== (string)$rowLoc['adresse2']) {
$location .= $rowLoc['adresse2'] . PHP_EOL;
}
if ('' != $rowLoc['cp']) {
if ('' !== (string)$rowLoc['cp']) {
$location .= $rowLoc['cp'] . PHP_EOL;
}
if ('' != $rowLoc['ville']) {
if ('' !== (string)$rowLoc['ville']) {
$location .= $rowLoc['ville'] . PHP_EOL;
}
if ('' != $rowLoc['tel_fixe']) {
if ('' !== (string)$rowLoc['tel_fixe']) {
$location .= $rowLoc['tel_fixe'] . PHP_EOL;
}
if ('' != $rowLoc['tel_portable']) {
if ('' !== (string)$rowLoc['tel_portable']) {
$location .= $rowLoc['tel_portable'] . PHP_EOL;
}
if ('' != $rowLoc['mail']) {
if ('' !== (string)$rowLoc['mail']) {
$location .= $rowLoc['mail'] . PHP_EOL;
}
if ('' != $rowLoc['site']) {
if ('' !== (string)$rowLoc['site']) {
$location .= $rowLoc['site'] . PHP_EOL;
}
}
Expand Down
4 changes: 2 additions & 2 deletions admin/log.php
Expand Up @@ -104,7 +104,7 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('log.php'));
$logObj = $logHandler->get($logId);
$logText = $logObj->getVar('text');
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('log.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand All @@ -125,7 +125,7 @@
case 'deleteall':
$templateMain = 'wgevents_admin_log.tpl';
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('log.php'));
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
\redirect_header('log.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
Expand Down

0 comments on commit 9785bab

Please sign in to comment.