function __construct($contact, $type, $usertype) { global $Conf; if (preg_match(',\\A(?:college|extension|students|all|pc)\\z,', $usertype)) { $this->usertype = $usertype; } else { $this->usertype = "students"; } if (preg_match(',\\A(\\w+):(openrepo|brokenrepo|repo|norepo|workingrepo|partner|nopartner)\\z,', $type, $m) && ($this->pset = Pset::find($m[1]))) { $this->type = $m[2]; } else { if (preg_match(',\\A(?:students|all|pc(?::\\S+)?)\\z,', $type)) { $this->type = $this->usertype = $type; } else { $this->type = $this->usertype; } } }
function reconfig() { global $Conf, $Me, $PsetOverrides, $PsetInfo; if (!($pset = Pset::find(@$_REQUEST["pset"]))) { return $Conf->errorMsg("No such pset"); } $psetkey = $pset->psetkey; $json = load_psets_json(true); object_merge_recursive($json->{$psetkey}, $json->_defaults); $old_pset = new Pset($psetkey, $json->{$psetkey}); $o = (object) array(); $o->disabled = $o->visible = $o->grades_visible = null; $state = @$_POST["state"]; if ($state === "disabled") { $o->disabled = true; } else { if ($old_pset->disabled) { $o->disabled = false; } } if ($state === "visible" || $state === "grades_visible") { $o->visible = true; } else { if (!$old_pset->disabled && $old_pset->visible) { $o->visible = false; } } if ($state === "grades_visible") { $o->grades_visible = true; } else { if ($state === "visible" && $old_pset->grades_visible) { $o->grades_visible = false; } } if (@$_POST["frozen"] === "yes") { $o->frozen = true; } else { $o->frozen = $old_pset->frozen ? false : null; } if (@$_POST["anonymous"] === "yes") { $o->anonymous = true; } else { $o->anonymous = $old_pset->anonymous ? false : null; } save_config_overrides($psetkey, $o, $json); }
static function set_seascode_repo_action($user) { global $Conf, $Me; if (!($Me->has_database_account() && check_post() && ($pset = Pset::find(@$_REQUEST["pset"])))) { return; } if (!$Me->can_set_repo($pset, $user)) { return $Conf->errorMsg("You can’t edit repository information for that problem set now."); } if ($user->set_seascode_repo($pset, $_REQUEST["repo"])) { redirectSelf(); } }