public function assign($j) { $this->name = get($j, "name") ?: "Field name"; $this->name_html = htmlspecialchars($this->name); $this->description = get($j, "description") ?: ""; $this->display_space = get_i($j, "display_space"); if (!$this->has_options && $this->display_space < 3) { $this->display_space = 3; } $vis = get($j, "visibility"); if ($vis === null) { $vis = get($j, "view_score"); if (is_int($vis)) { $vis = self::$view_score_upgrade_map[$vis]; } } $this->view_score = VIEWSCORE_PC; if (is_string($vis) && isset(self::$view_score_map[$vis])) { $this->view_score = self::$view_score_map[$vis]; } if (get($j, "position")) { $this->displayed = true; $this->display_order = $j->position; } else { $this->displayed = $this->display_order = false; } $this->round_mask = get_i($j, "round_mask"); if ($this->has_options) { $options = get($j, "options") ?: array(); $ol = get($j, "option_letter"); if ($ol && ctype_alpha($ol) && strlen($ol) == 1) { $this->option_letter = ord($ol) + count($options); } else { if ($ol && (is_int($ol) || ctype_digit($ol))) { $this->option_letter = (int) $ol; } else { $this->option_letter = false; } } $this->options = array(); if ($this->option_letter) { foreach (array_reverse($options, true) as $i => $n) { $this->options[chr($this->option_letter - $i - 1)] = $n; } } else { foreach ($options as $i => $n) { $this->options[$i + 1] = $n; } } if ($p = get($j, "option_class_prefix")) { $this->option_class_prefix = $p; } if (get($j, "allow_empty")) { $this->allow_empty = true; } } $this->analyzed = false; }
private function _row_thenval($row) { if ($this->search->thenmap) { return get_i($this->search->thenmap, $row->paperId); } else { return 0; } }
function __construct($args) { if (is_object($args)) { $args = get_object_vars($args); } $this->id = (int) $args["id"]; $this->name = $args["name"]; $this->type = $args["type"]; $this->abbr = $args["abbr"]; $this->description = get_s($args, "description"); $p = get($args, "position"); if ((is_int($p) || is_float($p)) && $p > 0) { $this->position = $p; } else { $this->position = 99999; } $this->final = !!get($args, "final"); $vis = get($args, "visibility") ?: get($args, "view_type"); if ($vis !== "rev" && $vis !== "nonblind" && $vis !== "admin") { $vis = "rev"; } $this->visibility = $vis; $disp = get($args, "display"); if (get($args, "near_submission")) { $disp = "submission"; } if (get($args, "highlight")) { $disp = "prominent"; } if ($disp === null) { $disp = "topics"; } $this->display = get(self::$display_map, $disp, self::DISP_DEFAULT); $this->form_priority = get_i($args, "form_priority"); if ($x = get($args, "display_space")) { $this->display_space = (int) $x; } $this->selector = get($args, "selector"); }
private function _save_assign_field($k, $v, Contact_Update $cu) { global $Conf; $fieldtype = get_i(self::$save_fields, $k); if ($fieldtype & 2) { $v = simplify_whitespace($v); } else { if ($fieldtype & 1) { $v = trim($v); } } // check CDB version first (in case $this === $cdbu) $cdbu = $this->contactDbId ? $this : $this->contactdb_user_; if ($fieldtype & 4 && (!$cdbu || $cu->different_email || $cdbu->{$k} !== $v)) { $cu->cdb_uqv[$k] = $v; } // change local version if ($this->{$k} !== $v || !$this->contactId) { $cu->qv[$k] = $this->{$k} = $v; } }
public function document($dtype, $did = 0) { assert($did || $dtype == DTYPE_SUBMISSION || $dtype == DTYPE_FINAL); if ($dtype == DTYPE_SUBMISSION || $dtype == DTYPE_FINAL) { if ($this->finalPaperStorageId <= 0) { $psi = [DTYPE_SUBMISSION, $this->paperStorageId]; } else { $psi = [DTYPE_FINAL, $this->finalPaperStorageId]; } if ($did == 0 || $did == $psi[1]) { return (object) ["paperId" => $this->paperId, "documentType" => $psi[0], "paperStorageId" => $psi[1], "mimetype" => get_s($this, "mimetype"), "size" => get_i($this, "size"), "timestamp" => get_i($this, "timestamp"), "sha1" => get_s($this, "sha1")]; } } // load document object from database if pre-loaded version doesn't work return Dbl::fetch_first_object("select paperId, documentType, paperStorageId, mimetype, size, timestamp, sha1, filename from PaperStorage where paperStorageId=?", $did); }
function conflicts_array($pj, $old_pj) { $x = array(); if ($pj && get($pj, "pc_conflicts") !== null) { $c = $pj->pc_conflicts; } else { $c = $old_pj ? get($old_pj, "pc_conflicts") : null ?: array(); } foreach ((array) $c as $email => $type) { $x[strtolower($email)] = $type; } if ($pj && get($pj, "authors") !== null) { $c = $pj->authors; } else { $c = $old_pj ? $old_pj->authors : array(); } foreach ($c as $au) { if (get($au, "email")) { $lemail = strtolower($au->email); $x[$lemail] = get($au, "contact") ? CONFLICT_CONTACTAUTHOR : CONFLICT_AUTHOR; } } if ($pj && get($pj, "contacts") !== null) { $c = $pj->contacts; } else { $c = $old_pj ? get($old_pj, "contacts") ?: [] : []; } foreach ($c as $v) { $lemail = strtolower($v->email); $x[$lemail] = max((int) get($x, $lemail), CONFLICT_CONTACTAUTHOR); } if ($old_pj && get($old_pj, "pc_conflicts")) { $can_administer = !$this->contact || $this->contact->can_administer($this->prow, $this->forceShow); foreach ($old_pj->pc_conflicts as $email => $type) { if ($type == CONFLICT_CHAIRMARK) { $lemail = strtolower($email); if (get_i($x, $lemail) < CONFLICT_CHAIRMARK && !$can_administer) { $x[$lemail] = CONFLICT_CHAIRMARK; } } } } ksort($x); return $x; }
public function selection_index($pid) { return get_i($this->selection_map(), $pid) - 1; }
function ajaxshow($params) { $this->sv("id", get_i($params[0])); }
public function load_content($doc) { global $Conf; $ok = false; $result = null; if (!opt("dbNoPapers") && get_i($doc, "paperStorageId") > 1) { $result = Dbl::q("select paper, compression from PaperStorage where paperStorageId=" . $doc->paperStorageId); } if (!$result || !($row = edb_row($result)) || $row[0] === null) { $doc->content = ""; } else { if ($row[1] == 1) { $doc->content = gzinflate($row[0]); $ok = true; } else { $doc->content = $row[0]; $ok = true; } } if (!$ok && ($s3 = self::s3_document()) && ($filename = self::s3_filename($doc))) { $filename = self::s3_filename($doc); $content = $s3->load($filename); if ($content !== "" && $content !== null) { $doc->content = $content; $ok = true; } else { if ($s3->status != 200) { error_log("S3 error: GET {$filename}: {$s3->status} {$s3->status_text} " . json_encode($s3->response_headers)); } } } if (!$ok) { $num = get($doc, "paperId") ? " #{$doc->paperId}" : ""; $doc->error = true; if ($this->dtype == DTYPE_SUBMISSION) { $doc->error_text = "Paper{$num} has not been uploaded."; } else { if ($this->dtype == DTYPE_FINAL) { $doc->error_text = "Paper{$num}’s final copy has not been uploaded."; } } } $doc->size = strlen($doc->content); $this->store_filestore($doc, true); // silently does nothing if error || !filestore return $ok; }
public static function barchart_compare($a, $b) { if (get_i($a, 4) != get_i($b, 4)) { return get_i($a, 4) - get_i($b, 4); } if ($a[0] != $b[0]) { return $a[0] < $b[0] ? -1 : 1; } return strcmp($a[3], $b[3]); }