コード例 #1
0
ファイル: Users.php プロジェクト: ponydevs/MLPVC-RR
    static function getPendingReservationsHTML($UserID, $sameUser, &$YouHave = null)
    {
        global $Database, $currentUser;
        $YouHave = $sameUser ? 'You have' : 'This user has';
        $PrivateSection = $sameUser ? Users::PROFILE_SECTION_PRIVACY_LEVEL['staff'] : '';
        $cols = "id, season, episode, preview, label, posted, reserved_by";
        $PendingReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('reservations', null, $cols);
        $PendingRequestReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('requests', null, "{$cols}, reserved_at, true as requested_by");
        $TotalPending = count($PendingReservations) + count($PendingRequestReservations);
        $hasPending = $TotalPending > 0;
        $HTML = '';
        if (Permission::sufficient('staff') || $sameUser) {
            $pendingCountReadable = $hasPending > 0 ? "<strong>{$TotalPending}</strong>" : 'no';
            $posts = CoreUtils::makePlural('reservation', $TotalPending);
            $gamble = $TotalPending < 4 && $sameUser ? ' <button id="suggestion" class="btn orange typcn typcn-lightbulb">Suggestion</button>' : '';
            $HTML .= <<<HTML
<section class='pending-reservations'>
<h2>{$PrivateSection}Pending reservations{$gamble}</h2>
\t\t\t\t<span>{$YouHave} {$pendingCountReadable} pending {$posts}
HTML;
            if ($hasPending) {
                $HTML .= " which ha" . ($TotalPending !== 1 ? 've' : 's') . "n't been marked as finished yet";
            }
            $HTML .= ".";
            if ($sameUser) {
                $HTML .= " Please keep in mind that the global limit is 4 at any given time. If you reach the limit, you can't reserve any more images until you finish or cancel some of your pending reservations.";
            }
            $HTML .= "</span>";
            if ($hasPending) {
                /** @var $Posts Post[] */
                $Posts = array_merge(Posts::getReservationsSection($PendingReservations, RETURN_ARRANGED)['unfinished'], array_filter(array_values(Posts::getRequestsSection($PendingRequestReservations, RETURN_ARRANGED)['unfinished'])));
                usort($Posts, function (Post $a, Post $b) {
                    $a = strtotime($a->posted);
                    $b = strtotime($b->posted);
                    return -($a < $b ? -1 : ($a === $b ? 0 : 1));
                });
                $LIST = '';
                foreach ($Posts as $Post) {
                    unset($_);
                    $postLink = $Post->toLink($_);
                    $postAnchor = $Post->toAnchor(null, $_);
                    $label = !empty($Post->label) ? "<span class='label'>{$Post->label}</span>" : '';
                    $is_request = isset($Post->rq);
                    $reservation_time_known = !empty($Post->reserved_at);
                    $posted = Time::tag($is_request && $reservation_time_known ? $Post->reserved_at : $Post->posted);
                    $PostedAction = $is_request && !$reservation_time_known ? 'Posted' : 'Reserved';
                    $contestable = $Post->isOverdue() ? Posts::CONTESTABLE : '';
                    $LIST .= <<<HTML
<li>
<div class='image screencap'>
\t<a href='{$postLink}'><img src='{$Post->preview}'></a>
</div>
{$label}
<em>{$PostedAction} under {$postAnchor} {$posted}</em>{$contestable}
<div>
\t<a href='{$postLink}' class='btn blue typcn typcn-arrow-forward'>View</a>
\t<button class='red typcn typcn-user-delete cancel'>Cancel</button>
</div>
</li>
HTML;
                }
                $HTML .= "<ul>{$LIST}</ul>";
            }
            $HTML .= "</section>";
        }
        return $HTML;
    }
コード例 #2
0
ファイル: episode.php プロジェクト: ponydevs/MLPVC-RR
         Response::dbError();
     }
     Logs::action('episodes', array('action' => 'del', 'season' => $Episode->season, 'episode' => $Episode->episode, 'twoparter' => $Episode->twoparter, 'title' => $Episode->title, 'airs' => $Episode->airs));
     $CGDb->where('name', "s{$Episode->season}e{$Episode->episode}")->delete('tags');
     Response::success('Episode deleted successfuly', array('upcoming' => Episodes::getSidebarUpcoming(NOWRAP)));
     break;
 case "requests":
 case "reservations":
     $only = $action === 'requests' ? ONLY_REQUESTS : ONLY_RESERVATIONS;
     $posts = Posts::get($Episode, $only);
     switch ($only) {
         case ONLY_REQUESTS:
             $rendered = Posts::getRequestsSection($posts);
             break;
         case ONLY_RESERVATIONS:
             $rendered = Posts::getReservationsSection($posts);
             break;
     }
     Response::done(array('render' => $rendered));
     break;
 case "vote":
     if (isset($_REQUEST['detail'])) {
         $VoteCountQuery = $Database->rawQuery("SELECT count(*) as value, vote as label\n\t\t\t\tFROM episodes__votes v\n\t\t\t\tWHERE season = ? && episode = ?\n\t\t\t\tGROUP BY v.vote\n\t\t\t\tORDER BY v.vote ASC", array($Episode->season, $Episode->episode));
         $VoteCounts = array('labels' => array(), 'datasets' => array(array('data' => array())));
         foreach ($VoteCountQuery as $row) {
             $VoteCounts['labels'][] = $row['label'];
             $VoteCounts['datasets'][0]['data'][] = $row['value'];
         }
         Response::done(array('data' => $VoteCounts));
     } else {
         if (isset($_REQUEST['html'])) {
コード例 #3
0
ファイル: episode.php プロジェクト: ponydevs/MLPVC-RR
	</section>
<?php 
    echo Episodes::getAppearancesSectionHTML($CurrentEpisode);
    if (Permission::sufficient('staff')) {
        ?>
	<section class="admin">
		<h2>Administration area</h2>
		<p class="align-center">
			<button id="edit-ep" class="typcn typcn-pencil large darkblue">Metadata</button>
			<button id="video" class="typcn typcn-pencil large darkblue">Video links</button>
			<button id="cg-relations" class="typcn typcn-pencil large darkblue">Guide relations</button>
		</p>
	</section>
<?php 
    }
    echo Posts::getReservationsSection(null, false, true);
    echo Posts::getRequestsSection(null, false, true);
    $export = array('SEASON' => $CurrentEpisode->season, 'EPISODE' => $CurrentEpisode->episode);
    if (Permission::sufficient('developer')) {
        $export['USERNAME_REGEX'] = $USERNAME_REGEX;
    }
    if ($signedIn) {
        $export['FULLSIZE_MATCH_REGEX'] = $FULLSIZE_MATCH_REGEX;
    }
    echo CoreUtils::exportVars($export);
} else {
    ?>
	<h1>There's nothing here yet&hellip;</h1>
	<p>&hellip;but there will be!</p>

<?php