Skip to content

Commit

Permalink
Merge pull request #30 from ggoffy/master
Browse files Browse the repository at this point in the history
code cleaning with PS Insect Code
  • Loading branch information
ggoffy authored Mar 23, 2022
2 parents 5242685 + 951840a commit df1f386
Show file tree
Hide file tree
Showing 36 changed files with 174 additions and 228 deletions.
36 changes: 16 additions & 20 deletions admin/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,19 @@
$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) {
//reset previous values
$eventObj->setVar('register_to', 0);
$eventObj->setVar('register_max', 0);
$eventObj->setVar('register_listwait', 0);
$eventObj->setVar('register_autoaccept', 0);
$eventObj->setVar('register_notify', '');
$eventObj->setVar('register_sendermail', '');
$eventObj->setVar('register_sendername', '');
$eventObj->setVar('register_signature', '');
$registrationHandler->cleanupRegistrations($evId);
$questionHandler->cleanupQuestions($evId);
$answerHandler->cleanupAnswers($evId);
}
} else if ($evId > 0) {
//reset previous values
$eventObj->setVar('register_to', 0);
$eventObj->setVar('register_max', 0);
$eventObj->setVar('register_listwait', 0);
$eventObj->setVar('register_autoaccept', 0);
$eventObj->setVar('register_notify', '');
$eventObj->setVar('register_sendermail', '');
$eventObj->setVar('register_sendername', '');
$eventObj->setVar('register_signature', '');
$registrationHandler->cleanupRegistrations($evId);
$questionHandler->cleanupQuestions($evId);
$answerHandler->cleanupAnswers($evId);
}
}
$eventObj->setVar('status', Request::getInt('status'));
Expand All @@ -228,12 +226,10 @@
$newEvId = $eventObj->getNewInsertedId();
if ('' !== $uploaderErrors) {
\redirect_header('event.php?op=edit&id=' . $evId, 5, $uploaderErrors);
} else if ($continueAddtionals) {
\redirect_header('question.php?op=edit&evid=' . $newEvId, 2, \_MA_WGEVENTS_FORM_OK);
} else {
if ($continueAddtionals) {
\redirect_header('question.php?op=edit&evid=' . $newEvId, 2, \_MA_WGEVENTS_FORM_OK);
} else {
\redirect_header('event.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK);
}
\redirect_header('event.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK);
}
}
// Get Form
Expand Down
8 changes: 3 additions & 5 deletions admin/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,10 @@
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('field.php'));
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
if (!$GLOBALS['xoopsSecurity']->check()) {
//\redirect_header('field.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
\redirect_header('field.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
}
if ($fieldHandler->getCount() > 0) {
if (!$fieldHandler->deleteAll()) {
$GLOBALS['xoopsTpl']->assign('error', $fieldHandler->getHtmlErrors());
}
if (($fieldHandler->getCount() > 0) && !$fieldHandler->deleteAll()) {
$GLOBALS['xoopsTpl']->assign('error', $fieldHandler->getHtmlErrors());
}
$items = BuildDefaultSet();
$uid = $GLOBALS['xoopsUser']->uid();
Expand Down
24 changes: 11 additions & 13 deletions admin/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,17 @@
'icon' => 'assets/icons/32/logs.png',
];

if (is_object($helper->getModule()) && null !== $helper->getConfig()) {
if ((bool)$helper->getConfig('use_history')) {
$adminmenu[] = [
'title' => \_MI_WGEVENTS_ADMENU11,
'link' => 'admin/registrationshist.php',
'icon' => 'assets/icons/32/registrationshist.png',
];
$adminmenu[] = [
'title' => \_MI_WGEVENTS_ADMENU12,
'link' => 'admin/answershist.php',
'icon' => 'assets/icons/32/answershist.png',
];
}
if (is_object($helper->getModule()) && null !== $helper->getConfig() && (bool)$helper->getConfig('use_history')) {
$adminmenu[] = [
'title' => \_MI_WGEVENTS_ADMENU11,
'link' => 'admin/registrationshist.php',
'icon' => 'assets/icons/32/registrationshist.png',
];
$adminmenu[] = [
'title' => \_MI_WGEVENTS_ADMENU12,
'link' => 'admin/answershist.php',
'icon' => 'assets/icons/32/answershist.png',
];
}
$adminmenu[] = [
'title' => \_MI_WGEVENTS_ADMENU14,
Expand Down
4 changes: 2 additions & 2 deletions blocks/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ function b_wgevents_calendar_show($options)

$GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL . '/');

$block = ['dummy']; //create dummy return in order to show block
return $block;
//create dummy return in order to show block
return ['dummy'];

}

Expand Down
6 changes: 3 additions & 3 deletions calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@

//request
$op = Request::getCmd('op', 'list');
$filterFrom = Request::getInt('filterFrom', 0);
$filterTo = Request::getInt('filterTo', 0);
$filterCat = Request::getInt('filterCat', 0);
$filterFrom = Request::getInt('filterFrom');
$filterTo = Request::getInt('filterTo');
$filterCat = Request::getInt('filterCat');
$filterSort = 'datefrom-ASC';
if (0 == $filterFrom) {
$filterFrom = $dayStart;
Expand Down
4 changes: 2 additions & 2 deletions class/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
class Account extends \XoopsObject
{
public $helper = null;
public $helper;
public $db;

//Constructor
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getForm($action = false)
$action = $_SERVER['REQUEST_URI'];
}

$title = $this->isNew() ? sprintf(_AM_WGEVENTS_ACCOUNT_ADD) : sprintf(_AM_WGEVENTS_ACCOUNT_EDIT);
$title = $this->isNew() ? _AM_WGEVENTS_ACCOUNT_ADD : _AM_WGEVENTS_ACCOUNT_EDIT;

require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
$form = new \XoopsThemeForm($title, 'accounts_form', $action, 'post', true);
Expand Down
6 changes: 3 additions & 3 deletions class/AccountHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function create($isNew = true)
/**
* retrieve a field
*
* @param int $i field id
* @param int $id field id
* @param null fields
* @return \XoopsObject|null reference to the {@link Get} object
*/
public function get($i = null, $fields = null)
public function get($id = null, $fields = null)
{
return parent::get($i, $fields);
return parent::get($id, $fields);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion class/Answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getForm($action = false)
}
$isAdmin = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()) : false;
// Title
$title = $this->isNew() ? \sprintf(\_MA_WGEVENTS_ANSWER_ADD) : \sprintf(\_MA_WGEVENTS_ANSWER_EDIT);
$title = $this->isNew() ? \_MA_WGEVENTS_ANSWER_ADD : \_MA_WGEVENTS_ANSWER_EDIT;
// Get Theme Form
\xoops_load('XoopsFormLoader');
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
Expand Down
6 changes: 3 additions & 3 deletions class/AnswerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function create($isNew = true)
/**
* retrieve a field
*
* @param int $i field id
* @param int $id field id
* @param null fields
* @return \XoopsObject|null reference to the {@link Get} object
*/
public function get($i = null, $fields = null)
public function get($id = null, $fields = null)
{
return parent::get($i, $fields);
return parent::get($id, $fields);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions class/AnswerhistHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function create($isNew = true)
/**
* retrieve a field
*
* @param int $i field id
* @param int $id field id
* @param null fields
* @return \XoopsObject|null reference to the {@link Get} object
*/
public function get($i = null, $fields = null)
public function get($id = null, $fields = null)
{
return parent::get($i, $fields);
return parent::get($id, $fields);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions class/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public function getForm($action = false)
if (!$action) {
$action = $_SERVER['REQUEST_URI'];
}
$isAdmin = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()) : false;
$isAdmin = \is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid());
// Title
$title = $this->isNew() ? \sprintf(\_AM_WGEVENTS_CATEGORY_ADD) : \sprintf(\_AM_WGEVENTS_CATEGORY_EDIT);
$title = $this->isNew() ? \_AM_WGEVENTS_CATEGORY_ADD : \_AM_WGEVENTS_CATEGORY_EDIT;
// Get Theme Form
\xoops_load('XoopsFormLoader');
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
Expand Down
6 changes: 3 additions & 3 deletions class/CategoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function create($isNew = true)
/**
* retrieve a field
*
* @param int $i field id
* @param int $id field id
* @param null fields
* @return \XoopsObject|null reference to the {@link Get} object
*/
public function get($i = null, $fields = null)
public function get($id = null, $fields = null)
{
return parent::get($i, $fields);
return parent::get($id, $fields);
}

/**
Expand Down
56 changes: 27 additions & 29 deletions class/Common/MigrateHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,31 @@ public function createSchemaFromSqlfile(): bool
$tables[$tableName]['options'] = '';
$tables[$tableName]['columns'] = [];
$tables[$tableName]['keys'] = [];
} else {
if (false == $skip) {
if (')' === \mb_strtoupper(\substr($line, 0, 1))) {
// end of table definition
// get options
$this->getOptions($line, $options);
$tables[$tableName]['options'] = $options;
} elseif ('ENGINE' === \mb_strtoupper(\substr($line, 0, 6))) {
$this->getOptions($line, $options);
$tables[$tableName]['options'] = $options;
} elseif ('DEFAULT CHARSET ' === \mb_strtoupper(\substr($line, 0, 16))) {
$this->getOptions($line, $options);
$tables[$tableName]['options'] = $options;
} else {
// get keys and fields
switch (\mb_strtoupper(\substr($line, 0, 3))) {
case 'KEY':
case 'PRI':
case 'UNI':
$tables[$tableName]['keys'][] = $this->getKey($line);
break;
case 'else':
default:
$columns = $this->getColumns($line);
$tables[$tableName]['columns'][] = $columns;
break;
}
} else if (false == $skip) {
if (')' === \mb_strtoupper(\substr($line, 0, 1))) {
// end of table definition
// get options
$this->getOptions($line, $options);
$tables[$tableName]['options'] = $options;
} elseif ('ENGINE' === \mb_strtoupper(\substr($line, 0, 6))) {
$this->getOptions($line, $options);
$tables[$tableName]['options'] = $options;
} elseif ('DEFAULT CHARSET ' === \mb_strtoupper(\substr($line, 0, 16))) {
$this->getOptions($line, $options);
$tables[$tableName]['options'] = $options;
} else {
// get keys and fields
switch (\mb_strtoupper(\substr($line, 0, 3))) {
case 'KEY':
case 'PRI':
case 'UNI':
$tables[$tableName]['keys'][] = $this->getKey($line);
break;
case 'else':
default:
$columns = $this->getColumns($line);
$tables[$tableName]['columns'][] = $columns;
break;
}
}
}
Expand Down Expand Up @@ -163,7 +161,7 @@ public function createSchemaFromSqlfile(): bool
}

// create new file and write schema array into this file
$myfile = \fopen($this->fileYaml, "w");
$myfile = \fopen($this->fileYaml, 'wb');
if (false == $myfile || null === $myfile) {
\xoops_error('Error: Unable to open sql file!');
return false;
Expand Down Expand Up @@ -260,7 +258,7 @@ private function getKey (string $line)

if (\strpos($line, 'RIMARY') > 0) {
$key['PRIMARY'] = [];
$fields = \substr($line, 13, \strlen($line) - 13);
$fields = \substr($line, 13);
$key['PRIMARY']['columns'] = \str_replace(['`', '),', ')'], '', $fields);
$key['PRIMARY']['unique'] = 'true';
} else {
Expand Down
22 changes: 10 additions & 12 deletions class/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function getForm($action = false)
$imgInfo = '<img class="wge-img-info" src="' . \WGEVENTS_ICONS_URL_24 . '/info.png" alt="img-info" title="%s">';

// Title
$title = $this->isNew() ? \sprintf(\_MA_WGEVENTS_EVENT_ADD) : \sprintf(\_MA_WGEVENTS_EVENT_EDIT);
$title = $this->isNew() ? \_MA_WGEVENTS_EVENT_ADD : \_MA_WGEVENTS_EVENT_EDIT;
// Get Theme Form
\xoops_load('XoopsFormLoader');
$form = new \XoopsThemeForm($title, 'formEvent', $action, 'post', true);
Expand Down Expand Up @@ -337,17 +337,15 @@ public function getForm($action = false)
$form->addElement(new \XoopsFormHidden('status', $evStatus));
$form->addElement(new \XoopsFormHidden('datecreated_int', $evDatecreated));
$form->addElement(new \XoopsFormHidden('submitter', $evSubmitter));
if (!$this->isNew()) {
if ($permEventsApprove) {
$evStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $evStatus);
$evStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE);
$evStatusSelect->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE);
$evStatusSelect->addOption(Constants::STATUS_SUBMITTED, \_MA_WGEVENTS_STATUS_SUBMITTED);
$evStatusSelect->addOption(Constants::STATUS_APPROVED, \_MA_WGEVENTS_STATUS_APPROVED);
$form->addElement($evStatusSelect, true);
$form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_DATECREATED, \formatTimestamp($evDatecreated, 's')));
$form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_SUBMITTER, \XoopsUser::getUnameFromId($evSubmitter)));
}
if (!$this->isNew() && $permEventsApprove) {
$evStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $evStatus);
$evStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE);
$evStatusSelect->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE);
$evStatusSelect->addOption(Constants::STATUS_SUBMITTED, \_MA_WGEVENTS_STATUS_SUBMITTED);
$evStatusSelect->addOption(Constants::STATUS_APPROVED, \_MA_WGEVENTS_STATUS_APPROVED);
$form->addElement($evStatusSelect, true);
$form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_DATECREATED, \formatTimestamp($evDatecreated, 's')));
$form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_SUBMITTER, \XoopsUser::getUnameFromId($evSubmitter)));
}
}
if (!$this->isNew()) {
Expand Down
22 changes: 9 additions & 13 deletions class/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public function create($isNew = true)
/**
* retrieve a field
*
* @param int $i field id
* @param int $id field id
* @param null fields
* @return \XoopsObject|null reference to the {@link Get} object
*/
public function get($i = null, $fields = null)
public function get($id = null, $fields = null)
{
return parent::get($i, $fields);
return parent::get($id, $fields);
}

/**
Expand Down Expand Up @@ -155,15 +155,11 @@ public function getFormEventSelect($action = false)
/**
* @public function to get events for given params
*
* @param int $uid : select by/exclude given uid
* @param int $start
* @param int $limit
* @param int $from : filter date created from (timestamp)
* @param int $to : filter date created to (timestamp)
* @param bool $mygroups : show events of all groups of current user
* @param bool $excludeuid : exclude given uid from result
* @param int $groupid : filter by given group id
* @param int $catid : filter by given cat id
* @param int $start
* @param int $limit
* @param int $from : filter date created from (timestamp)
* @param int $to : filter date created to (timestamp)
* @param int $catid : filter by given cat id
* @param string $sortBy
* @param string $orderBy
* @return array
Expand Down Expand Up @@ -253,7 +249,7 @@ public function getEventsCompare($versionOld, $versionNew)
/**
* get email recipients for noticiations
* @param $registerNotify
* @return string
* @return array|false|string[]
*/
public function getRecipientsNotify($registerNotify)
{
Expand Down
2 changes: 1 addition & 1 deletion class/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getForm($action = false)
}
$isAdmin = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()) : false;
// Title
$title = $this->isNew() ? \sprintf(\_AM_WGEVENTS_FIELD_ADD) : \sprintf(\_AM_WGEVENTS_FIELD_EDIT);
$title = $this->isNew() ? \_AM_WGEVENTS_FIELD_ADD : \_AM_WGEVENTS_FIELD_EDIT;
// Get Theme Form
\xoops_load('XoopsFormLoader');
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
Expand Down
Loading

0 comments on commit df1f386

Please sign in to comment.