Exemple #1
0
function echo_commit($Info)
{
    global $Conf, $Me, $User, $Pset;
    global $TABWIDTH, $WDIFF;
    $Notes = $Info->commit_info();
    $TABWIDTH = $Info->commit_info("tabwidth") ?: 4;
    $WDIFF = isset($Notes->wdiff) ? $Notes->wdiff : false;
    // current commit and commit selector
    $sel = array();
    $curhead = $grouphead = null;
    foreach ($Info->recent_commits() as $k) {
        // visually separate older heads
        if ($curhead === null) {
            $curhead = $k->fromhead;
        }
        if ($curhead != $k->fromhead) {
            if (!$grouphead) {
                $sel["from.{$k->fromhead}"] = (object) array("type" => "optgroup", "label" => "Other snapshots");
            } else {
                $sel["from.{$k->fromhead}"] = null;
            }
            $curhead = $grouphead = $k->fromhead;
        }
        // actual option
        $x = UnicodeHelper::utf8_prefix($k->subject, 72);
        if (strlen($x) != strlen($k->subject)) {
            $x .= "...";
        }
        $sel[$k->hash] = substr($k->hash, 0, 7) . " " . htmlspecialchars($x);
    }
    $result = $Conf->qe("select hash from CommitNotes where (haslinenotes & ?)!=0 and pset=? and hash ?a", $Me == $User && !$Info->can_see_grades ? HASNOTES_COMMENT : HASNOTES_ANY, $Pset->psetid, array_keys($sel));
    while ($row = edb_row($result)) {
        $sel[$row[0]] .= "  ♪";
    }
    if (($h = $Info->grading_hash()) && isset($sel[$h])) {
        $sel[$h] = preg_replace('_(.*?)(?:  )?(♪?)\\z_', '$1  ✱$2', $sel[$h]);
    }
    if ($Info->is_grading_commit()) {
        $key = "grading commit";
    } else {
        $key = "this commit";
    }
    $value = Ht::select("newcommit", $sel, $Info->commit_hash(), array("onchange" => "jQuery(this).closest('form').submit()"));
    if ($Me != $User) {
        $x = $Info->is_grading_commit() ? "" : "font-weight:bold";
        $value .= " " . Ht::submit("grade", "Grade", array("style" => $x));
    }
    // view options
    $fold_viewoptions = !isset($_REQUEST["tab"]) && !isset($_REQUEST["wdiff"]);
    $value .= '<div class="viewoptions61">' . '<a class="q" href="#" onclick="return fold61(this.nextSibling,this.parentNode)">' . '<span class="foldarrow">' . ($fold_viewoptions ? '&#x25B6;' : '&#x25BC;') . '</span>&nbsp;options</a><span style="padding-left:1em' . ($fold_viewoptions ? ';display:none' : '') . '">tab width:';
    foreach (array(2, 4, 8) as $i) {
        $value .= '&nbsp;<a href="' . self_href(array("tab" => $i)) . '"' . ($TABWIDTH == $i ? " class=\"q\"><strong>{$i}</strong>" : '>' . $i) . '</a>';
    }
    $value .= '<span style="padding-left:1em">wdiff:';
    foreach (array("no", "yes") as $i => $t) {
        $value .= '&nbsp;<a href="' . self_href(array("wdiff" => $i)) . '"' . (!$WDIFF == !$i ? " class=\"q\"><strong>{$t}</strong>" : '>' . $t) . '</a>';
    }
    $value .= '</span></span></div>';
    // warnings
    $remarks = array();
    if (!$Info->grading_hash() && $Me != $User && !$Pset->gitless_grades) {
        $remarks[] = array(true, "No commit has been marked for grading.");
    } else {
        if (!$Info->is_grading_commit() && $Info->grading_hash()) {
            $remarks[] = array(true, "This is not " . "<a class=\"uu\" href=\"" . $Info->hoturl("pset", array("commit" => $Info->grading_hash())) . "\">the commit currently marked for grading</a>" . " <span style=\"font-weight:normal\">(<a href=\"" . $Info->hoturl("diff", array("commit1" => $Info->grading_hash())) . "\">see diff</a>)</span>.");
        }
    }
    if (!$Info->is_latest_commit()) {
        $remarks[] = array(true, "This is not " . "<a class=\"uu\" href=\"" . $Info->hoturl("pset", array("commit" => $Info->latest_hash())) . "\">the latest commit</a>" . " <span style=\"font-weight:normal\">(<a href=\"" . $Info->hoturl("diff", array("commit1" => $Info->latest_hash())) . "\">see diff</a>)</span>.");
    }
    if (($lh = $Info->late_hours()) && $lh->hours > 0) {
        $extra = array();
        if (get($lh, "commitat")) {
            $extra[] = "commit at " . $Conf->printableTimestamp($lh->commitat);
        }
        if (get($lh, "deadline")) {
            $extra[] = "deadline " . $Conf->printableTimestamp($lh->deadline);
        }
        $extra = count($extra) ? ' <span style="font-weight:normal">(' . join(", ", $extra) . ')</span>' : "";
        $remarks[] = array(true, "This commit uses " . plural($lh->hours, "late hour") . $extra . ".");
    }
    if (($Info->is_latest_commit() || $Me->isPC) && $Pset->handout_repo_url) {
        $Pset->latest_handout_commit();
        $last_handout = $Pset->latest_handout_commit();
        $last_myhandout = $last_handout ? $Info->derived_handout_hash() : false;
        if ($last_handout && $last_myhandout && $last_handout->hash == $last_myhandout) {
            /* this is ideal: they have the latest handout commit */
        } else {
            if ($last_handout && $last_myhandout) {
                // they don't have the latest updates
                $remarks[] = array(true, "Updates are available for this problem set <span style=\"font-weight:normal\">(<a href=\"" . $Info->hoturl("diff", array("commit" => $last_myhandout, "commit1" => $last_handout->hash)) . "\">see diff</a>)</span>. Run <code>git pull handout master</code> to merge these updates.");
            } else {
                if ($last_handout) {
                    $remarks[] = array(true, "Please create your repository by cloning our repository. Creating your repository from scratch makes it harder for you to get pset updates.");
                } else {
                    if (!$last_handout && $Me->isPC) {
                        $handout_files = $Pset->handout_repo()->ls_files("master");
                        if (!count($handout_files)) {
                            $remarks[] = array(true, "The handout repository, " . htmlspecialchars($Pset->handout_repo_url) . ", contains no files; perhaps handout_repo_url is misconfigured.");
                        } else {
                            $remarks[] = array(true, "The handout repository, " . htmlspecialchars($Pset->handout_repo_url) . ", does not contain problem set code yet.");
                        }
                    }
                }
            }
        }
    }
    // actually print
    echo Ht::form($Info->hoturl_post("pset", array("commit" => null, "setcommit" => 1)), array("class" => "commitcontainer61", "data-pa-pset" => $Info->pset->urlkey, "data-pa-commit" => $Info->latest_hash())), "<div class=\"f-contain\">";
    ContactView::echo_group($key, $value, $remarks);
    echo "</div></form>\n";
}
Exemple #2
0
 function escape()
 {
     if (req("ajax") || req("latestcommit")) {
         if ($this->is_empty()) {
             $this->conf->ajaxExit(array("ok" => 0, "loggedout" => 1));
         } else {
             $this->conf->ajaxExit(array("ok" => 0, "error" => "You don’t have permission to access that page."));
         }
     }
     if ($this->is_empty()) {
         // Preserve post values across session expiration.
         $x = array();
         if (Navigation::path()) {
             $x["__PATH__"] = preg_replace(",^/+,", "", Navigation::path());
         }
         if (req("anchor")) {
             $x["anchor"] = req("anchor");
         }
         $url = self_href($x, array("raw" => true, "site_relative" => true));
         $_SESSION["login_bounce"] = array($this->conf->dsn, $url, Navigation::page(), $_POST);
         if (check_post()) {
             error_go(false, "You’ve been logged out due to inactivity, so your changes have not been saved. After logging in, you may submit them again.");
         } else {
             error_go(false, "You must sign in to access that page.");
         }
     } else {
         error_go(false, "You don’t have permission to access that page.");
     }
 }
Exemple #3
0
function whyNotText($whyNot, $action)
{
    global $Conf;
    if (!is_array($whyNot)) {
        $whyNot = array($whyNot => 1);
    }
    $paperId = isset($whyNot['paperId']) ? $whyNot['paperId'] : -1;
    $reviewId = isset($whyNot['reviewId']) ? $whyNot['reviewId'] : -1;
    $thisPaper = $paperId < 0 ? "this paper" : "paper #{$paperId}";
    $text = '';
    if (isset($whyNot['invalidId'])) {
        $x = $whyNot['invalidId'] . "Id";
        $xid = isset($whyNot[$x]) ? " \"" . $whyNot[$x] . "\"" : "";
        $text .= "Invalid " . $whyNot['invalidId'] . " number" . htmlspecialchars($xid) . ". ";
    }
    if (isset($whyNot['noPaper'])) {
        $text .= "No such paper" . ($paperId < 0 ? "" : " #{$paperId}") . ". ";
    }
    if (isset($whyNot['noReview'])) {
        $text .= "No such review" . ($reviewId < 0 ? "" : " #{$reviewId}") . ". ";
    }
    if (isset($whyNot['dbError'])) {
        $text .= $whyNot['dbError'] . " ";
    }
    if (isset($whyNot['permission'])) {
        $text .= "You don’t have permission to {$action} {$thisPaper}. ";
    }
    if (isset($whyNot['withdrawn'])) {
        $text .= ucfirst($thisPaper) . " has been withdrawn. ";
    }
    if (isset($whyNot['notWithdrawn'])) {
        $text .= ucfirst($thisPaper) . " has not been withdrawn. ";
    }
    if (isset($whyNot['notSubmitted'])) {
        $text .= ucfirst($thisPaper) . " was never officially submitted. ";
    }
    if (isset($whyNot['notAccepted'])) {
        $text .= ucfirst($thisPaper) . " was not accepted for publication. ";
    }
    if (isset($whyNot["decided"])) {
        $text .= "The review process for {$thisPaper} has completed. ";
    }
    if (isset($whyNot['updateSubmitted'])) {
        $text .= ucfirst($thisPaper) . " has already been submitted and can no longer be updated. ";
    }
    if (isset($whyNot['notUploaded'])) {
        $text .= ucfirst($thisPaper) . " can’t be submitted because you haven’t yet uploaded the paper itself. Upload the paper and try again. ";
    }
    if (isset($whyNot['reviewNotSubmitted'])) {
        $text .= "This review is not yet ready for others to see. ";
    }
    if (isset($whyNot['reviewNotComplete'])) {
        $text .= "Your own review for {$thisPaper} is not complete, so you can’t view other people’s reviews. ";
    }
    if (isset($whyNot['responseNotReady'])) {
        $text .= "The authors&rsquo; response for {$thisPaper} is not yet ready for reviewers to view. ";
    }
    if (isset($whyNot['reviewsOutstanding'])) {
        $text .= "You will get access to the reviews once you complete <a href=\"" . hoturl("search", "q=&amp;t=r") . "\">your assigned reviews for other papers</a>.  If you can’t complete your reviews, please let the conference organizers know via the “Refuse review” links. ";
    }
    if (isset($whyNot['reviewNotAssigned'])) {
        $text .= "You are not assigned to review {$thisPaper}. ";
    }
    if (isset($whyNot['deadline'])) {
        $dname = $whyNot['deadline'];
        if ($dname[0] == "s") {
            $start = $Conf->setting("sub_open", -1);
        } else {
            if ($dname[0] == "p" || $dname[0] == "e") {
                $start = $Conf->setting("rev_open", -1);
            } else {
                $start = 1;
            }
        }
        $end = $Conf->setting($dname, -1);
        $now = time();
        if ($start <= 0) {
            $text .= "You can’t {$action} {$thisPaper} yet. ";
        } else {
            if ($start > 0 && $now < $start) {
                $text .= "You can’t {$action} {$thisPaper} until " . $Conf->printableTime($start, "span") . ". ";
            } else {
                if ($end > 0 && $now > $end) {
                    if ($dname == "sub_reg") {
                        $text .= "The paper registration deadline has passed. ";
                    } else {
                        if ($dname == "sub_update") {
                            $text .= "The deadline to update papers has passed. ";
                        } else {
                            if ($dname == "sub_sub") {
                                $text .= "The paper submission deadline has passed. ";
                            } else {
                                if ($dname == "extrev_hard") {
                                    $text .= "The external review deadline has passed. ";
                                } else {
                                    if ($dname == "pcrev_hard") {
                                        $text .= "The PC review deadline has passed. ";
                                    } else {
                                        $text .= "The deadline to {$action} {$thisPaper} has passed. ";
                                    }
                                }
                            }
                        }
                    }
                    $text .= "It was " . $Conf->printableTime($end, "span") . ". ";
                } else {
                    if ($dname == "au_seerev") {
                        if ($Conf->setting("au_seerev") == AU_SEEREV_YES) {
                            $text .= "Authors who are also reviewers can’t see reviews for their papers while they still have <a href='" . hoturl("search", "t=rout&amp;q=") . "'>incomplete reviews</a> of their own. ";
                        } else {
                            $text .= "Authors can’t view paper reviews at the moment. ";
                        }
                    } else {
                        $text .= "You can’t {$action} {$thisPaper} at the moment. ";
                    }
                }
            }
        }
        $text .= "(<a class='nowrap' href='" . hoturl("deadlines") . "'>View deadlines</a>) ";
    }
    if (isset($whyNot['override']) && $whyNot['override']) {
        $text .= "“Override deadlines” can override this restriction. ";
    }
    if (isset($whyNot['blindSubmission'])) {
        $text .= "Submission to this conference is blind. ";
    }
    if (isset($whyNot['author'])) {
        $text .= "You aren’t a contact for {$thisPaper}. ";
    }
    if (isset($whyNot['conflict'])) {
        $text .= "You have a conflict with {$thisPaper}. ";
    }
    if (isset($whyNot['externalReviewer'])) {
        $text .= "External reviewers may not view other reviews for the papers they review. ";
    }
    if (isset($whyNot['differentReviewer'])) {
        $text .= "You didn’t write this review, so you can’t change it. ";
    }
    if (isset($whyNot['reviewToken'])) {
        $text .= "If you know a valid review token, enter it above to edit that review. ";
    }
    // finish it off
    if (isset($whyNot['chairMode'])) {
        $text .= "(<a class='nowrap' href=\"" . self_href(array("forceShow" => 1)) . "\">" . ucfirst($action) . " the paper anyway</a>) ";
    }
    if (isset($whyNot['forceShow'])) {
        $text .= "(<a class='nowrap' href=\"" . self_href(array("forceShow" => 1)) . "\">Override conflict</a>) ";
    }
    if ($text && $action == "view") {
        $text .= "Enter a paper number above, or <a href='" . hoturl("search", "q=") . "'>list the papers you can view</a>. ";
    }
    return rtrim($text);
}
Exemple #4
0
 static function echo_repo_group($info, $include_tarball = false)
 {
     global $Conf, $Me, $Now;
     if ($info->pset->gitless) {
         return;
     }
     list($user, $pset, $partner, $repo) = array($info->user, $info->pset, $info->partner, $info->repo);
     $editable = $info->can_set_repo && !$user->is_anonymous;
     $repo_url = $repo ? $repo->friendly_url() : "";
     $title = "repository";
     if (!RepositorySite::is_primary($repo)) {
         $title = $repo->reposite->friendly_siteclass() . " " . $title;
     }
     if ($repo && $repo->url) {
         $title = $user->link_repo($title, $repo->web_url());
     }
     if ($editable) {
         $value = Ht::entry("repo", $repo_url, array("style" => "width:32em")) . " " . Ht::submit("Save");
     } else {
         if ($user->is_anonymous) {
             $value = $repo_url ? "[anonymous]" : "(none)";
         } else {
             $value = htmlspecialchars($repo_url ? $repo_url : "(none)");
         }
     }
     if ($repo_url) {
         $value .= ' <button class="b repoclip hottooltip" data-pa-repo="' . htmlspecialchars($repo->ssh_url()) . '"';
         if ($user->is_anonymous) {
             $value .= ' data-tooltip="[anonymous]"';
         } else {
             $value .= ' data-tooltip="' . htmlspecialchars($repo->ssh_url()) . '"';
         }
         $value .= ' type="button" onclick="false">Copy URL to clipboard</button>';
         Ht::stash_script('$(".repoclip").each(pa_init_repoclip)', "repoclip");
         if ($include_tarball && $info->commit_hash() && ($tarball_url = $info->tarball_url())) {
             $value .= ' <a class="bsm q" href="' . htmlspecialchars($tarball_url) . '">Download tarball for ' . substr($info->commit_hash(), 0, 7) . '</a>';
         }
     }
     // check repo
     $ms = new MessageSet($user);
     if ($repo) {
         $repo->check_working($ms);
         $repo->check_open($ms);
     }
     if ($partner && $info->partner_same()) {
         $prepo = $partner->repo($pset->id);
         if (!$repo && $prepo || $repo && !$prepo || $repo && $prepo && $repo->repoid != $prepo->repoid) {
             if ($prepo && $repo) {
                 $prepo_url = ", " . htmlspecialchars($prepo->friendly_url_like($repo));
             } else {
                 if ($prepo) {
                     $prepo_url = ", " . htmlspecialchars($prepo->friendly_url());
                 } else {
                     $prepo_url = "";
                 }
             }
             $your_partner = "your partner’s";
             if ($Me->isPC) {
                 $your_partner = '<a href="' . hoturl("pset", array("pset" => $pset->urlkey, "u" => $Me->user_linkpart($partner))) . '">' . $your_partner . '</a>';
             }
             $ms->set_error_html("partner", "This repository differs from {$your_partner}{$prepo_url}.");
         }
     }
     if ($repo) {
         $repo->check_ownership($user, $partner, $ms);
     }
     $prefixes = ["", "WARNING: ", "ERROR: "];
     $notes = array_map(function ($m) use($prefixes) {
         return [$m[2] > 0, $prefixes[$m[2]] . $m[1]];
     }, $ms->messages(true));
     if ($repo && $repo->truncated_psetdir($pset)) {
         $notes[] = array(true, "Please create your repository by cloning our repository. Creating your repository from scratch makes it harder for us to grade and harder for you to get pset updates.");
     }
     if (!$repo) {
         $repoclasses = RepositorySite::site_classes($Conf);
         $x = commajoin(array_map(function ($k) {
             return Ht::link($k::global_friendly_siteclass(), $k::global_friendly_siteurl());
         }, $repoclasses), "or");
         if ($editable) {
             $notes[] = array(false, "Enter your {$x} repository URL here.");
         }
     }
     // edit
     if ($editable) {
         echo Ht::form(self_href(array("post" => post_value(), "set_repo" => 1, "pset" => $pset->urlkey))), '<div class="f-contain">';
     }
     self::echo_group($title, $value, $notes);
     if ($editable) {
         echo "</div></form>\n";
     }
     return $repo;
 }
Exemple #5
0
 static function echo_repo_group($info, $include_tarball = false)
 {
     global $Conf, $Me, $Now;
     if ($info->pset->gitless) {
         return;
     }
     list($user, $pset, $partner, $repo) = array($info->user, $info->pset, $info->partner, $info->repo);
     $editable = $info->can_set_repo && !$user->is_anonymous;
     $repo_url = $user->seascode_repo_base($repo ? $repo->url : "");
     $title = "repository";
     if ($repo_url && strpos($repo_url, ":") === false) {
         $title = $user->repo_link($repo_url, $title);
     }
     if ($editable) {
         $value = Ht::entry("repo", $repo_url, array("style" => "width:32em")) . " " . Ht::submit("Save");
     } else {
         if ($user->is_anonymous) {
             $value = $repo_url ? "[anonymous]" : "(none)";
         } else {
             $value = htmlspecialchars($repo_url ? $repo_url : "(none)");
         }
     }
     if ($repo_url) {
         $value .= ' <button class="b repoclip hottooltip" data-pa-repo="' . htmlspecialchars($repo->url) . '"';
         if ($user->is_anonymous) {
             $value .= ' data-tooltip="[anonymous]"';
         } else {
             $value .= ' data-tooltip="' . htmlspecialchars($repo->url) . '"';
         }
         $value .= ' type="button" onclick="false">Copy URL to clipboard</button>';
         $Conf->footerScript('$(".repoclip").each(pa_init_repoclip)', "repoclip");
         if ($include_tarball && $info->commit_hash() && ($tarball_url = $info->tarball_url())) {
             $value .= ' <a class="bsm q" href="' . htmlspecialchars($tarball_url) . '">Download tarball for ' . substr($info->commit_hash(), 0, 7) . '</a>';
         }
     }
     // check repo
     $notes = array();
     if ($repo && !$repo->working) {
         if ($user->check_seascode_repo($pset, $repo, false)) {
             $Now = time();
             $Conf->qe("update Repository set `working`={$Now} where repoid={$repo->repoid}");
         } else {
             $notes[] = array(true, "ERROR: " . Messages::$main->expand_html("repo_unreadable", $user->repo_messagedefs($repo)));
         }
     }
     if (($open = $info->check_repo_open()) > 0) {
         $notes[] = array(true, "ERROR: " . Messages::$main->expand_html("repo_toopublic", $user->repo_messagedefs($repo)));
     } else {
         if ($open < 0 && $Me->isPC) {
             $notes[] = array(true, "WARNING: " . Messages::$main->expand_html("repo_toopublic_timeout", $user->repo_messagedefs($repo)));
         }
     }
     if ($partner && $info->partner_same) {
         $prepo = $partner->repo($pset->id);
         if (!$repo && $prepo || $repo && !$prepo || $repo && $prepo && $repo->repoid != $prepo->repoid) {
             if ($prepo) {
                 $prepo_url = ", " . htmlspecialchars($user->seascode_repo_base($prepo->url));
             } else {
                 $prepo_url = "";
             }
             $your_partner = "your partner’s";
             if ($Me->isPC) {
                 $your_partner = '<a href="' . hoturl("pset", array("pset" => $pset->urlkey, "u" => $Me->user_linkpart($partner))) . '">' . $your_partner . '</a>';
             }
             $notes[] = array(true, "ERROR: This repository differs from {$your_partner}{$prepo_url}.");
         }
     }
     if ($repo && $repo_url[0] == "~" && $user->seascode_username && !preg_match("_\\A~(?:" . preg_quote($user->seascode_username) . ($partner ? "|" . preg_quote($partner->seascode_username) : "") . ")/_i", $repo_url)) {
         if ($partner) {
             $notes[] = array(true, "ERROR: This repository belongs to neither you nor your partner.");
         } else {
             $notes[] = array(true, "ERROR: This repository does not belong to you.");
         }
     }
     if ($repo && isset($repo->truncated_psetdir) && defval($repo->truncated_psetdir, $pset->id)) {
         $notes[] = array(true, "Please create your repository by cloning our repository. Creating your repository from scratch makes it harder for us to grade and harder for you to get pset updates.");
     }
     if (!$repo) {
         $notes[] = array(false, "Enter your " . Contact::seascode_home("code.seas") . " repository URL here.");
     }
     // edit
     if ($editable) {
         echo Ht::form(self_href(array("post" => post_value(), "set_seascode_repo" => 1, "pset" => $pset->urlkey))), '<div class="f-contain">';
     }
     self::echo_group($title, $value, $notes);
     if ($editable) {
         echo "</div></form>\n";
     }
     return $repo;
 }
Exemple #6
0
 function header($title, $id = "", $actionBar = null, $showTitle = true)
 {
     global $ConfSitePATH, $Me, $Now;
     if ($this->headerPrinted) {
         return;
     }
     // <head>
     if ($title === "Home") {
         $title = "";
     }
     $this->header_head($title);
     // <body>
     echo "<body", $id ? " id=\"{$id}\"" : "", " onload=\"hotcrp_load()\">\n";
     // initial load (JS's timezone offsets are negative of PHP's)
     Ht::stash_script("hotcrp_load.time(" . -date("Z", $Now) / 60 . "," . ($this->opt("time24hour") ? 1 : 0) . ")");
     echo "<div id='prebody'>\n";
     echo "<div id='header'>\n<div id='header_left_conf'><h1>";
     if ($title && $showTitle && ($title == "Home" || $title == "Sign in")) {
         echo "<a name='' class='qq' href='", hoturl("index"), "' title='Home'>", htmlspecialchars($this->short_name), "</a>";
     } else {
         echo "<a name='' class='uu' href='", hoturl("index"), "' title='Home'>", htmlspecialchars($this->short_name), "</a></h1></div><div id='header_left_page'><h1>", $title;
     }
     echo "</h1></div><div id='header_right'>";
     if ($Me && !$Me->is_empty()) {
         // profile link
         $profile_parts = [];
         if ($Me->has_email() && !$Me->disabled) {
             $profile_parts[] = '<strong>' . htmlspecialchars($Me->email) . '</strong>';
             /*echo '<a class="q" href="', hoturl("profile"), '"><strong>',
               htmlspecialchars($Me->email),
               '</strong></a> &nbsp; <a href="', hoturl("profile"), '">Profile</a>',
               $xsep;*/
         }
         // "act as" link
         if (($actas = get($_SESSION, "last_actas")) && get($_SESSION, "trueuser") && ($Me->privChair || Contact::$trueuser_privChair === $Me)) {
             // Link becomes true user if not currently chair.
             if (!$Me->privChair || strcasecmp($Me->email, $actas) == 0) {
                 $actas = $_SESSION["trueuser"]->email;
             }
             if (strcasecmp($Me->email, $actas) != 0) {
                 $profile_parts[] = "<a href=\"" . self_href(["actas" => $actas]) . "\">" . ($Me->privChair ? htmlspecialchars($actas) : "Admin") . "&nbsp;" . Ht::img("viewas.png", "Act as " . htmlspecialchars($actas)) . "</a>";
             }
         }
         // help, sign out
         $x = $id == "search" ? "t={$id}" : ($id == "settings" ? "t=chair" : "");
         if (!$Me->has_email() && !isset($this->opt["httpAuthLogin"])) {
             $profile_parts[] = '<a href="' . hoturl("index", "signin=1") . '">Sign&nbsp;in</a>';
         }
         if (!$Me->is_empty() || isset($this->opt["httpAuthLogin"])) {
             $profile_parts[] = '<a href="' . hoturl_post("index", "signout=1") . '">Sign&nbsp;out</a>';
         }
         if (!empty($profile_parts)) {
             echo join(' <span class="barsep">·</span> ', $profile_parts);
         }
     }
     echo '<div id="maindeadline" style="display:none"></div></div>', "\n";
     echo "  <hr class=\"c\" />\n";
     echo $actionBar;
     echo "</div>\n<div id=\"initialmsgs\">\n";
     if ($x = $this->opt("maintenance")) {
         echo "<div class=\"merror\"><strong>The site is down for maintenance.</strong> ", is_string($x) ? $x : "Please check back later.", "</div>";
     }
     $this->save_messages = false;
     if (($msgs = $this->session("msgs")) && count($msgs)) {
         $this->save_session("msgs", null);
         foreach ($msgs as $m) {
             $this->msg($m[0], $m[1]);
         }
         echo "<div id=\"initialmsgspacer\"></div>";
     }
     echo "</div>\n";
     $this->headerPrinted = true;
     echo "</div>\n<div class='body'>\n";
 }
Exemple #7
0
 function header($title, $id = "", $actionBar = null, $showTitle = true)
 {
     global $ConfSiteBase, $ConfSiteSuffix, $ConfSitePATH, $Me, $Now, $Opt;
     if ($this->headerPrinted) {
         return;
     }
     // <head>
     $this->header_head($title);
     // <body>
     echo "<body", $id ? " id='{$id}'" : "", " onload='hotcrp_load()'>\n";
     // on load of script.js
     $this->scriptStuff .= "<script>";
     // initial load (JS's timezone offsets are negative of PHP's)
     $this->scriptStuff .= "hotcrp_load.time(" . -date("Z", $Now) / 60 . "," . (@$Opt["time24hour"] ? 1 : 0) . ")";
     $this->scriptStuff .= "</script>";
     echo "<div id='prebody'>\n";
     echo "<div id='header'>\n<div id='header_left_conf'><h1>";
     if ($title && $showTitle && ($title == "Home" || $title == "Sign in")) {
         echo "<a name='' class='qq' href='", hoturl("index"), "' title='Home'>", htmlspecialchars($Opt["shortName"]), "</a>";
     } else {
         echo "<a name='' class='uu' href='", hoturl("index"), "' title='Home'>", htmlspecialchars($Opt["shortName"]), "</a></h1></div><div id='header_left_page'><h1>", $title;
     }
     echo "</h1></div><div id='header_right'>";
     if ($Me && !$Me->is_empty()) {
         // profile link
         $xsep = ' <span class="barsep">&nbsp;|&nbsp;</span> ';
         if ($Me->has_email() && false) {
             echo '<a class="q" href="', hoturl("profile"), '"><strong>', htmlspecialchars($Me->email), '</strong></a> &nbsp; <a href="', hoturl("profile"), '">Profile</a>', $xsep;
         } else {
             if ($Me->has_email()) {
                 echo '<strong>', htmlspecialchars($Me->email), '</strong>', $xsep;
             }
         }
         // "act as" link
         if (($actas = @$_SESSION["last_actas"]) && @$_SESSION["trueuser"]) {
             // Become true user if not currently chair.
             if (!$Me->privChair || strcasecmp($Me->email, $actas) == 0) {
                 $actas = $_SESSION["trueuser"]->email;
             }
             if (strcasecmp($Me->email, $actas) != 0) {
                 echo "<a href=\"", self_href(array("actas" => $actas)), "\">", $Me->privChair ? htmlspecialchars($actas) : "Admin", "&nbsp;", Ht::img("viewas.png", "Act as " . htmlspecialchars($actas)), "</a>", $xsep;
             }
         }
         // help, sign out
         $x = $id == "search" ? "t={$id}" : ($id == "settings" ? "t=chair" : "");
         if (!$Me->has_email() && !isset($Opt["httpAuthLogin"])) {
             echo '<a href="', hoturl("index", "signin=1"), '">Sign&nbsp;in</a>';
         }
         if (!$Me->is_empty() || isset($Opt["httpAuthLogin"])) {
             echo '<a href="', hoturl_post("index", "signout=1"), '">Sign&nbsp;out</a>';
         }
     }
     echo '<div id="maindeadline" style="display:none"></div></div>', "\n";
     echo "  <hr class=\"c\" />\n";
     echo $actionBar;
     echo "</div>\n<div id=\"initialmsgs\">\n";
     if (@$Opt["maintenance"]) {
         echo "<div class=\"merror\"><strong>The site is down for maintenance.</strong> ", is_string($Opt["maintenance"]) ? $Opt["maintenance"] : "Please check back later.", "</div>";
     }
     if (($msgs = $this->session("msgs")) && count($msgs)) {
         foreach ($msgs as $m) {
             echo $m;
         }
         $this->save_session("msgs", null);
         echo "<div id=\"initialmsgspacer\"></div>";
     }
     $this->save_messages = false;
     echo "</div>\n";
     $this->headerPrinted = true;
     echo "</div>\n<div class='body'>\n";
 }