1<?php
2// pc_shepherd.php -- HotCRP helper classes for paper list content
3// Copyright (c) 2006-2018 Eddie Kohler; see LICENSE.
4
5class Shepherd_PaperColumn extends PaperColumn {
6    function __construct(Conf $conf, $cj) {
7        parent::__construct($conf, $cj);
8        $this->override = PaperColumn::OVERRIDE_FOLD_IFEMPTY;
9    }
10    function prepare(PaperList $pl, $visible) {
11        return $pl->user->can_view_shepherd(null)
12            && ($pl->conf->has_any_lead_or_shepherd() || $visible);
13    }
14    static private function cid(PaperList $pl, PaperInfo $row) {
15        if ($row->shepherdContactId && $pl->user->can_view_shepherd($row))
16            return $row->shepherdContactId;
17        return 0;
18    }
19    function compare(PaperInfo $a, PaperInfo $b, ListSorter $sorter) {
20        $pl = $sorter->list;
21        return $pl->_compare_pc(self::cid($pl, $a), self::cid($pl, $b));
22    }
23    function header(PaperList $pl, $is_text) {
24        return "Shepherd";
25    }
26    function content_empty(PaperList $pl, PaperInfo $row) {
27        return !self::cid($pl, $row);
28    }
29    function content(PaperList $pl, PaperInfo $row) {
30        return $pl->_content_pc($row->shepherdContactId);
31    }
32    function text(PaperList $pl, PaperInfo $row) {
33        return $pl->_text_pc($row->shepherdContactId);
34    }
35}
36