function Module_Awards_update_award(&$msgs) { global $db_game, $params; $award = Module_Awards_getAward($awardID); if (!Module_Awards_check_tag($params->awardTag)) { $msgs[] = "Tag has to match '^[0-9a-zA-Z]+\$'"; return false; } $description = lib_bb_code($params->awardDescription); $sql = "UPDATE Awards SET tag = '{$params->awardTag}', " . "title = '{$params->awardTitle}', " . "description = '{$description}' " . "WHERE awardID = '{$params->awardID}' LIMIT 1"; if (!$db_game->query($sql)) { return false; } if (!award_lib_change_tag_from_players($db_game, $award['tag'], $params->awardTag)) { // FIXME should not be a "die" here die("Could not delete tags from players.."); } return true; }
function getContent($modus) { global $db_game, $params; $content = ""; $msgs = array(); switch ($modus) { case 'award_create': // show form if (!isset($params->creator)) { $content = Module_Awards_show_create(); // form submitted } else { // TODO check values if (empty($params->awardTag) || empty($params->awardTitle)) { } // give feedback on success if (!Module_Awards_insert_award($msgs)) { $msgs[] = "Error while inserting the new award!"; } else { $msgs[] = "Award inserted!"; } $content = Module_Awards_show_list($msgs); } break; case 'award_edit': // form submitted if (isset($params->editaward)) { // give feedback on success if (!Module_Awards_update_award($msgs)) { $msgs[] = "Error editing the award!"; } else { $msgs[] = "Award edited!"; } $content = Module_Awards_show_list($msgs); // show form } else { $award = Module_Awards_getAward($params->awardID); // db error .. if ($award === false) { $msgs[] = "Error while retrieving award."; $content = Module_Awards_show_list($msgs); // wrong id } else { if (!sizeof($award)) { $msgs[] = "No such award!"; $content = Module_Awards_show_list($msgs); } else { $content = Module_Awards_show_edit($award); } } } break; case 'award_delete': Module_Awards_delete($params->awardID); $content = Module_Awards_show_list($msgs); break; case 'award_list': $content = Module_Awards_show_list($msgs); break; case 'award_decorate_player': $content = Module_Awards_decorate_player(); break; case 'award_decorate_tribe': $content = Module_Awards_decorate_tribe(); break; } return $content; }