function questionnaire_getQuestionnairePresents($caveID, &$ownCaves) { global $template; // open template $template->setFile('questionnairePresents.tmpl'); $template->setShowRresource(false); //messages $messageText = array(-5 => array('type' => 'error', 'message' => _('Ich bin mit dem Schnecken abzählen durcheinander gekommen, Häuptling! Versucht es noch einmal!')), -4 => array('type' => 'error', 'message' => _('Ihr habt nicht die passenden Schnecken, Häuptling!"')), -3 => array('type' => 'error', 'message' => _('Dieses Geschenk kann ich euch nicht anbieten, Häuptling!')), -2 => array('type' => 'error', 'message' => _('Datenbankfehler. Bitte versuche es später nochmals.')), -1 => array('type' => 'error', 'message' => _('Du hast keine Belognung ausgewählt.')), 1 => array('type' => 'success', 'message' => _('Eure Geschenke sind nun in eurer Höhle!')), 2 => array('type' => 'info', 'message' => _('Danke für die Schnecken!'))); $action = Request::getVar('action', ''); switch ($action) { /**************************************************************************************************** * * Gescenke abholen * ****************************************************************************************************/ case 'present': $presentID = Request::getVar('presentID', 0); $messageID = questionnaire_getPresent($caveID, $ownCaves, $presentID); break; } // geschenke auslesen $presents = questionnaire_getPresents(); // show my credits $credits = questionnaire_getCredits($_SESSION['player']->questionCredits); /**************************************************************************************************** * * Übergeben ans Template * ****************************************************************************************************/ $template->addVars(array('credits' => $credits, 'presents' => $presents, 'status_msg' => isset($messageID) ? $messageText[$messageID] : '')); }
function questionnaire_presents($caveID, &$meineHoehlen) { global $params, $config, $db, $defenseSystemTypeList, $unitTypeList, $resourceTypeList, $no_resource_flag; $no_resource_flag = 1; $template = tmpl_open('./templates/' . $config->template_paths[$params->SESSION->user['template']] . '/questionnaire_presents.ihtml'); if (isset($params->POST->presentID) && intval($params->POST->presentID) > 0) { $msg = questionnaire_getPresent($caveID, $meineHoehlen, $params->POST->presentID); } // show message if ($msg != "") { tmpl_set($template, 'MESSAGE/message', $msg); } // show my credits if ($account = questionnaire_getCredits($params->SESSION->user['questionCredits'])) { tmpl_set($template, 'ACCOUNT', $account); } $query = "SELECT * FROM `Questionnaire_presents` ORDER BY presentID ASC"; if (!($result = $db->query($query))) { return "Datenbankfehler: " . mysql_error(); } $presents = array(); while ($row = $result->nextRow(MYSQL_ASSOC)) { if (!questionnaire_timeIsRight($row)) { continue; } $row += questionnaire_getCredits($row['credits']); $externals = array(); foreach ($defenseSystemTypeList as $external) { if ($row[$external->dbFieldName] > 0) { $externals[] = array('amount' => $row[$external->dbFieldName], 'name' => $external->name); } } if (sizeof($externals)) { $row['EXTERNAL'] = $externals; } $resources = array(); foreach ($resourceTypeList as $resource) { if ($row[$resource->dbFieldName] > 0) { $resources[] = array('amount' => $row[$resource->dbFieldName], 'name' => $resource->name); } } if (sizeof($resources)) { $row['RESOURCE'] = $resources; } $units = array(); foreach ($unitTypeList as $unit) { if ($row[$unit->dbFieldName] > 0) { $units[] = array('amount' => $row[$unit->dbFieldName], 'name' => $unit->name); } } if (sizeof($units)) { $row['UNIT'] = $units; } $presents[] = $row; } if (sizeof($presents)) { tmpl_set($template, 'PRESENTS/PRESENT', $presents); tmpl_set($template, 'PRESENTS/PARAMS', array(array('name' => "modus", 'value' => QUESTIONNAIRE_PRESENTS))); } else { tmpl_set($template, 'NO_PRESENT/dummy', ""); } // show the link to the questions page tmpl_set($template, 'QUESTIONNAIRE', QUESTIONNAIRE); return tmpl_parse($template); }