Пример #1
0
 private function viewFractalSheet($fractal_id)
 {
     $user = $this->getUser();
     $out = $this->getOutput();
     if ($fractal_id) {
         $fractal = new FateFractal($fractal_id);
         $table = '';
         if ($fractal->name) {
             if (!$fractal->is_private || $user->isAllowed('fategm') || $fractal->fate_game->is_staff($user->getID()) || $fractal->user_id == $user->getID()) {
                 $table .= $fractal->getFractalSheet();
             } else {
                 $table .= "<div class='error' style='font-weight: bold; color: red'>You do not have permission to view this fractal's stats.</div>";
             }
         } else {
             $table .= "<div class='error' style='font-weight: bold; color: red'>No data found for that fractal_id; please check URL and try again.</div>";
         }
         $out->addHTML($table);
     } else {
         $out->addHTML("<div class='error' style='font-weight: bold; color: red'>Missing fractal_id argument; don't know which fractal to show.</div>");
     }
 }
Пример #2
0
    private function getApproveForm($game, $results)
    {
        $user = $this->getUser();
        $output = $this->getOutput();
        $request = $this->getRequest();
        $form_url = $this->getPageTitle()->getSubPage('Approval')->getLinkURL();
        $game_id = $game->game_id;
        $form = '<h2>Process Approvals for: ' . $game->game_name . '</h2>';
        if ($game->pending_stat_approvals) {
            $form .= <<<EOT
                <script type='text/javascript'>
                    function toggle_check(id, check) {
                        var approve = document.getElementById('approve_' + id);
                        var deny = document.getElementById('deny_' + id);
                        if (check == approve) {
                            deny.checked = false;
                        } else {
                            approve.checked = false;
                        }
                    }
                </script>
                <form action='{$form_url}' method='post'>
                <input type='hidden' name='game_id' value='{$game_id}'/>
                <input type='hidden' name='action' value='edit'/>
EOT;
            // Errors and successes here
            if (count($results) > 0) {
                if (count($results['error']) > 0) {
                    $form .= "<div class='errorbox'><strong>Approval error.</strong><br/>One or more error was found. Please correct them below, and resubmit to save approvals.</div>";
                } else {
                    $form .= "<div class='successbox'><strong>Approvals updated.</strong></div>";
                }
            }
            // TODO: Check for characters that need to be approved
            // Now look for individual stats that need approval
            if ($game->pending_stat_approvals) {
                $form .= "<fieldset><legend>Pending Stats</legend><table width='100%'><tbody>";
                foreach ($game->fractals['Character'] as $f) {
                    if ($f['pending']) {
                        $fractal = new FateFractal($f['fractal_id']);
                        $form .= "<tr><td>" . $fractal->getFractalBlock(1);
                        if (array_key_exists(FateGameGlobals::STAT_ASPECT, $fractal->pending_stats)) {
                            foreach ($fractal->pending_stats[FateGameGlobals::STAT_ASPECT] as $aspect) {
                                $form .= $this->getApproveAspect($aspect, $fractal->stats_by_id[$aspect->{original_stat_id}], $results);
                            }
                        }
                        if (array_key_exists(FateGameGlobals::STAT_STUNT, $fractal->pending_stats)) {
                            foreach ($fractal->pending_stats[FateGameGlobals::STAT_STUNT] as $stunt) {
                                $form .= $this->getApproveStunt($stunt, $fractal->stats_by_id[$stunt->{original_stat_id}], $results);
                            }
                        }
                        $form .= "</td></tr>";
                    }
                }
                $form .= "</tbody></table></fieldset>";
            }
            $form .= "<span class='mw-htmlform-submit-buttons'><input class='mw-htmlform-submit' type='submit' value='Update'/></span></form>";
        } else {
            $form .= "<div class='error' style='font-weight: bold; color: red;'>No pending approvals found for this game.</div>";
        }
        return $form;
    }