本文整理汇总了PHP中Problem类的典型用法代码示例。如果您正苦于以下问题:PHP Problem类的具体用法?PHP Problem怎么用?PHP Problem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Problem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
public function submit($problem_id)
{
try {
$problem = new Problem($problem_id);
$language = fRequest::get('language', 'integer');
if (!array_key_exists($language, static::$languages)) {
throw new fValidationException('Invalid language.');
}
fSession::set('last_language', $language);
$code = trim(fRequest::get('code', 'string'));
if (strlen($code) == 0) {
throw new fValidationException('Code cannot be empty.');
}
if ($problem->isSecretNow()) {
if (!User::can('view-any-problem')) {
throw new fAuthorizationException('Problem is secret now. You are not allowed to submit this problem.');
}
}
$record = new Record();
$record->setOwner(fAuthorization::getUserToken());
$record->setProblemId($problem->getId());
$record->setSubmitCode($code);
$record->setCodeLanguage($language);
$record->setSubmitDatetime(Util::currentTime());
$record->setJudgeStatus(JudgeStatus::PENDING);
$record->setJudgeMessage('Judging... PROB=' . $problem->getId() . ' LANG=' . static::$languages[$language]);
$record->setVerdict(Verdict::UNKNOWN);
$record->store();
Util::redirect('/status');
} catch (fException $e) {
fMessaging::create('error', $e->getMessage());
fMessaging::create('code', '/submit', fRequest::get('code', 'string'));
Util::redirect("/submit?problem={$problem_id}");
}
}
示例2: fetchTimestamp
public function fetchTimestamp()
{
try {
$p = new Problem(fRequest::get('pid', 'integer'));
echo $p->getLastModified();
} catch (fException $e) {
echo -1;
}
}
示例3: canCreateItem
/**
* Is the current user have right to create the current task ?
*
* @return boolean
**/
function canCreateItem()
{
if (!parent::canReadITILItem()) {
return false;
}
$problem = new Problem();
if ($problem->getFromDB($this->fields['problems_id'])) {
return Session::haveRight("edit_all_problem", "1") || Session::haveRight("show_my_problem", "1") && ($problem->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $problem->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']));
}
return false;
}
示例4: checkAuthor
private function checkAuthor($username)
{
foreach ($this->getProblems() as $problem_id) {
try {
$problem = new Problem($problem_id);
if ($problem->getAuthor() == $username) {
return TRUE;
}
} catch (Exception $e) {
continue;
}
}
return FALSE;
}
示例5: save
public function save()
{
if (UserSession::getInstance()->getAccessLevel() < 3) {
die("<h1>Forbidden resource for you.</h1>");
}
$model = new Problem();
$model->setFields($this->params);
$modelId = $model->get("prb_id");
if (!isset($modelId)) {
$status = $this->saveNew($model);
return $status;
} else {
$status = $this->update($model);
return $status;
}
}
示例6: beforeUpdate
static function beforeUpdate(Problem $problem)
{
if (!is_array($problem->input) || !count($problem->input)) {
// Already cancel by another plugin
return false;
}
// Toolbox::logDebug("PluginBehaviorsProblem::beforeUpdate(), Problem=", $problem);
$config = PluginBehaviorsConfig::getInstance();
// Check is the connected user is a tech
if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('problem', UPDATE)) {
return false;
// No check
}
$soltyp = isset($problem->input['solutiontypes_id']) ? $problem->input['solutiontypes_id'] : $problem->fields['solutiontypes_id'];
// Wand to solve/close the problem
if (isset($problem->input['solutiontypes_id']) && $problem->input['solutiontypes_id'] || isset($problem->input['solution']) && $problem->input['solution'] || isset($problem->input['status']) && in_array($problem->input['status'], array_merge(Problem::getSolvedStatusArray(), Problem::getClosedStatusArray()))) {
if ($config->getField('is_problemsolutiontype_mandatory')) {
if (!$soltyp) {
unset($problem->input['status']);
unset($problem->input['solution']);
unset($problem->input['solutiontypes_id']);
Session::addMessageAfterRedirect(__('You cannot close a problem without solution type', 'behaviors'), true, ERROR);
}
}
}
}
示例7: index
public function index()
{
$data = array();
$data['rain_problems'] = Problem::recentByBasin('RAIN', 'OR');
$data['water_problems'] = Problem::recentByBasin('WATER', 'OR');
$data['stats'] = Problem::todayStat();
return View::make('home/index', $data);
}
示例8: index
/**
* View all problems
* @param string $status status of problem ("all", "marked", "unmarked")
* @param string $data_type WATER / RAIN
* @return mixed
*/
public function index($status, $data_type)
{
$params = $this->getParams($status, $data_type);
$data = $this->dataForForm($status, $data_type);
$data['selectDate'] = true;
$data['title'] = 'Error Log';
Log::info($params);
$data['problems'] = Problem::allForTable($params);
return View::make('errorlog/index', $data);
}
示例9: index
public function index($status, $data_type)
{
$params = $this->getParams($status, $data_type);
$data = $this->dataForForm($status, $data_type);
// $params['start_date'] = date('Y-m-d', getTime());
// $params['start_time'] = '07:01';
$params['end_date_after'] = date('Y-m-d', getTime());
$params['end_time_after'] = '07:01';
$data['selectDate'] = false;
$data['title'] = 'Daily Operations';
$data['problems'] = Problem::allForTable($params);
return View::make('dailyop/index', $data);
}
示例10: generateDailyReport
public function generateDailyReport()
{
/*
{
"key": "HAIIEMAILKEY",
"num": 6,
"date": "2014-10-14 20:43",
"rain": [
{
"name": "Out of Ranges",
"stations": [
"TPTN",
"PUAA",
"PPCH"
]
},
{
"name": "Missing Pattern",
"stations": [
"ABCD"
]
}
],
"water": [
{
"name": "Out of Ranges",
"stations": [
"WATER"
]
}
]
}
*/
$data = Problem::yesterdayReport();
$num = count($data["water"]["OR"]["stations"]) + count($data["water"]["MG"]["stations"]) + count($data["water"]["FV"]["stations"]) + count($data["rain"]["OR"]["stations"]) + count($data["rain"]["MG"]["stations"]) + count($data["rain"]["FV"]["stations"]);
$input = array("key" => "HAIIEMAILKEY", "num" => $num, "date" => self::getStartDate('Y-m-d 07:00'), "rain" => $data["rain"], "water" => $data["water"]);
return APIEmailController::sendEmail($input, 'daily');
}
示例11: index
public function index()
{
$this->cache_control('private', 5);
if ($pid = fRequest::get('id', 'integer')) {
Util::redirect('/problem/' . $pid);
}
$view_any = User::can('view-any-problem');
$this->page = fRequest::get('page', 'integer', 1);
$this->title = trim(fRequest::get('title', 'string'));
$this->author = trim(fRequest::get('author', 'string'));
$this->problems = Problem::find($view_any, $this->page, $this->title, $this->author);
$this->page_url = SITE_BASE . '/problems?';
if (!empty($this->title)) {
$this->page_url .= 'title=' . fHTML::encode($this->title) . '&';
}
if (!empty($this->author)) {
$this->page_url .= 'author=' . fHTML::encode($this->author) . '&';
}
$this->page_url .= 'page=';
$this->page_records = $this->problems;
$this->nav_class = 'problems';
$this->render('problem/index');
}
示例12: Problem
<?php
global $user;
if (isset($mo_request[1]) && is_numeric($mo_request[1])) {
$problem = new Problem($mo_request[1]);
$problem->load();
if (!$problem->getPID()) {
require_once $mo_theme_floder . '404.php';
}
if (isset($_POST['lang']) && isset($_POST['code']) && $user->getUID()) {
// 提交solution
if (!b_check_code()) {
echo '提交错误!请检查格式以及是否已经登录!';
} else {
$new_sid = mo_add_new_solution($mo_request[1], $_POST['lang'], $_POST['code']);
echo '提交成功!<a href="/?r=solution/' . $new_sid . '">点此</a>查看详情!';
}
}
echo '<h2>' . $problem->getInfo('title') . '</h2>';
echo '<em>标签:' . $problem->getInfo('tag') . '<br>';
echo '时间限制:' . $problem->getInfo('time_limit') . 'MS 内存限制:' . $problem->getInfo('memory_limit') . 'MB</em>';
echo '<h3>问题描述</h3>';
echo $problem->getInfo('description');
echo '<br>提交人数:' . $problem->getInfo('try') . ' AC人数:' . $problem->getInfo('solved') . '<br>';
echo '<h3>提交代码</h3>';
echo '<form name="form1" method="post" action="">
语言:
<p>
<label>
<input name="lang" type="radio" required id="lang-1" value="1" checked>
C/C++</label>
</p>
示例13: showForm
function showForm($ID, $options = array())
{
global $CFG_GLPI, $DB;
if (!static::canView()) {
return false;
}
// In percent
$colsize1 = '13';
$colsize2 = '37';
$default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
// Set default options
if (!$ID) {
$values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
foreach ($values as $key => $val) {
if (!isset($options[$key])) {
$options[$key] = $val;
}
}
if (isset($options['tickets_id'])) {
$ticket = new Ticket();
if ($ticket->getFromDB($options['tickets_id'])) {
$options['content'] = $ticket->getField('content');
$options['name'] = $ticket->getField('name');
$options['impact'] = $ticket->getField('impact');
$options['urgency'] = $ticket->getField('urgency');
$options['priority'] = $ticket->getField('priority');
$options['itilcategories_id'] = $ticket->getField('itilcategories_id');
$options['due_date'] = $ticket->getField('due_date');
}
}
if (isset($options['problems_id'])) {
$problem = new Problem();
if ($problem->getFromDB($options['problems_id'])) {
$options['content'] = $problem->getField('content');
$options['name'] = $problem->getField('name');
$options['impact'] = $problem->getField('impact');
$options['urgency'] = $problem->getField('urgency');
$options['priority'] = $problem->getField('priority');
$options['itilcategories_id'] = $problem->getField('itilcategories_id');
$options['due_date'] = $problem->getField('due_date');
}
}
}
if ($ID > 0) {
$this->check($ID, READ);
} else {
// Create item
$this->check(-1, CREATE, $options);
}
$showuserlink = 0;
if (User::canView()) {
$showuserlink = 1;
}
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>";
echo "<td class='left' width='{$colsize2}%'>";
if (isset($options['tickets_id'])) {
echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
}
if (isset($options['problems_id'])) {
echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
}
$date = $this->fields["date"];
if (!$ID) {
$date = date("Y-m-d H:i:s");
}
Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>";
echo "<td width='{$colsize2}%' class='left'>";
if ($this->fields["due_date"] == 'NULL') {
$this->fields["due_date"] = '';
}
Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1));
echo "</td></tr>";
if ($ID) {
echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>";
User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
echo "</td>";
echo "<th>" . __('Last update') . "</th>";
echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
if ($this->fields['users_id_lastupdater'] > 0) {
printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
}
echo "</td></tr>";
}
if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
echo "<tr class='tab_bg_1'>";
echo "<th>" . __('Date of solving') . "</th>";
echo "<td>";
Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
echo "<th>" . __('Closing date') . "</th>";
echo "<td>";
Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false));
echo "</td>";
} else {
echo "<td colspan='2'> </td>";
//.........这里部分代码省略.........
示例14: Problem
$prob = new Problem($cleaned["id"]);
$prob->remove();
break;
case "addToLog":
$prob = new Problem($cleaned["id"]);
$prob->addToLog($cleaned["msg"]);
break;
case "getLog":
$prob = new Problem($cleaned["id"]);
$log = $prob->getLog();
header("Content-type: application/json");
echo json_encode($log);
break;
case "getLocation":
header("Content-type: application/json");
$prob = new Problem($cleaned["id"]);
echo json_encode($prob->getLocation());
break;
}
pg_close($conn);
function prob_output($problems, $format, $outProj)
{
if ($format == "xml") {
header("Content-type: text/xml");
$xml = "";
$xml .= "<freemap><projection>{$outProj}</projection>";
foreach ($problems as $prob) {
$xml .= $prob->output("xml", $outProj);
}
$xml .= "</freemap>";
echo $xml;
示例15: giveItem
//.........这里部分代码省略.........
return $out;
}
break;
case "glpi_documenttypes.icon":
if (!empty($data[$num][0]['name'])) {
return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$num][0]['name'] . "'>";
}
return " ";
case "glpi_documents.filename":
$doc = new Document();
if ($doc->getFromDB($data['id'])) {
return $doc->getDownloadLink();
}
return NOT_AVAILABLE;
case "glpi_tickets_tickets.tickets_id_1":
$out = "";
$displayed = array();
for ($k = 0; $k < $data[$num]['count']; $k++) {
$linkid = $data[$num][$k]['tickets_id_2'] == $data['id'] ? $data[$num][$k]['name'] : $data[$num][$k]['tickets_id_2'];
if ($linkid > 0 && !isset($displayed[$linkid])) {
$text = "<a ";
$text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">";
$text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>";
if (count($displayed)) {
$out .= self::LBBR;
}
$displayed[$linkid] = $linkid;
$out .= $text;
}
}
return $out;
case "glpi_problems.id":
if ($searchopt[$ID]["datatype"] == 'count') {
if ($data[$num][0]['name'] > 0 && Session::haveRight("problem", Problem::READALL)) {
if ($itemtype == 'ITILCategory') {
$options['criteria'][0]['field'] = 7;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $data['id'];
$options['criteria'][0]['link'] = 'AND';
} else {
$options['criteria'][0]['field'] = 12;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = 'all';
$options['criteria'][0]['link'] = 'AND';
$options['metacriteria'][0]['itemtype'] = $itemtype;
$options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name');
$options['metacriteria'][0]['searchtype'] = 'equals';
$options['metacriteria'][0]['value'] = $data['id'];
$options['metacriteria'][0]['link'] = 'AND';
}
$options['reset'] = 'reset';
$out = "<a id='problem{$itemtype}" . $data['id'] . "' ";
$out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.php?" . Toolbox::append_params($options, '&') . "\">";
$out .= $data[$num][0]['name'] . "</a>";
return $out;
}
}
break;
case "glpi_tickets.id":
if ($searchopt[$ID]["datatype"] == 'count') {
if ($data[$num][0]['name'] > 0 && Session::haveRight("ticket", Ticket::READALL)) {
if ($itemtype == 'User') {
// Requester
if ($ID == 60) {
$options['criteria'][0]['field'] = 4;
$options['criteria'][0]['searchtype'] = 'equals';