/** * For the given task display the form, and run the task if data entered from the corresponding form * * @param string $actionName The code-name for the desired task */ public function process($actionName) { global $Misc; // TODO: Use late static binding for this instead of INBOARD detection extract($this->actionsList[$actionName]); print '<li class="formlisttitle"> <a name="' . $actionName . '"></a>' . l_t($name) . '</li>'; try { if (isset($_REQUEST['actionName']) and $_REQUEST['actionName'] == $actionName) { print '<li class="formlistfield">'; $paramValues = array(); foreach ($params as $paramName => $paramFullName) { if (isset($_REQUEST[$paramName])) { $paramValues[$paramName] = $_REQUEST[$paramName]; } } if (isset($paramValues['gameID'])) { require_once l_r('objects/game.php'); $Variant = libVariant::loadFromGameID((int) $paramValues['gameID']); $Game = $Variant->Game((int) $paramValues['gameID']); print '<p>' . l_t('Game link') . ': <a href="board.php?gameID=' . $Game->id . '">' . $Game->name . '</a></p>'; } if (isset($paramValues['userID'])) { $User = new User((int) $paramValues['userID']); print '<p>' . l_t('User link') . ': ' . $User->profile_link() . '</p>'; } if (isset($paramValues['postID'])) { print '<p>' . l_t('Post link') . ': ' . libHTML::threadLink($paramValues['postID']) . '</p>'; } // If it needs confirming but ( hasn't been confirmed or is being resubmitted ): if (!self::isActionDangerous($actionName) && (!isset($_REQUEST['actionConfirm']) || !libHTML::checkTicket())) { print '<strong>' . $this->{$actionName . 'Confirm'}($paramValues) . '</strong>'; print '<form action="' . self::$target . '#' . $actionName . '" method="post"> <input type="hidden" name="actionName" value="' . $actionName . '" /> <input type="hidden" name="actionConfirm" value="on" /> <input type="hidden" name="formTicket" value="' . libHTML::formTicket() . '" />'; foreach ($paramValues as $name => $value) { print '<input type="hidden" name="' . $name . '" value="' . $value . '" />'; } print '</li><li class="formlistfield" style="margin-bottom:20px"> <input type="submit" class="form-submit" value="Confirm" /> </form>'; } else { $details = $this->{$actionName}($paramValues); self::save($name, $paramValues, $details); $description = '<p class="notice">' . $details . '</p> <p>' . l_t($description) . '</p>'; $Misc->LastModAction = time(); } print '</li>'; } } catch (Exception $e) { $description = '<p><strong>' . l_t('Error') . ':</strong> ' . $e->getMessage() . '</p> <p>' . l_t($description) . '</p>'; } self::form($actionName, $params, $description); }
public function toString() { $Moderator = new User($this->moderatorUserID); $startTime = libTime::text($this->startTime); $endTime = $this->length == 0 ? l_t("Indefinite") : libTime::text($this->startTime + $this->length * 60 * 60 * 24); $silenceData = array('Status' => '<b>' . ($this->enabled ? $this->isExpired() ? l_t('Ended') : l_t('Active') : l_t('Disabled')) . '</b>', 'Mod' => $Moderator->profile_link(), 'Started' => $startTime, 'Ends' => $endTime, 'Reason' => $this->reason); if ($this->userID) { $SilencedUser = new User($this->userID); $silenceData['User'] = $SilencedUser->profile_link(); } if ($this->postID) { $silenceData['Thread'] = libHTML::threadLink($this->postID); } $strArr = array('<ul class="formlist"><li>'); foreach ($silenceData as $k => $v) { $strArr[] = l_t($k) . ": <i>" . $v . "</i>"; } $strArr[] = '</li></ul>'; return implode("</li><li>", $strArr); }