getUser(); // $database->set(_debug,1); $config = new GuildMasterConf($database); $config->load(1); $error = array (); if (!$config->guild_id) { $error[] = "Guild ID not set.
Please check configuration."; error_message($error); return; } $force_update = mosGetParam($_REQUEST, 'force_update', ''); $disable_hiding = mosGetParam($_REQUEST, 'disable_hiding', ''); $action = mosGetParam($_REQUEST, 'action', ''); $todo = mosGetParam($_REQUEST, 'todo', ''); $_Itemid = (int)mosGetParam($_REQUEST, 'Itemid', ''); $config->index = 'index.php?option=com_guildmaster&Itemid='.$_Itemid; $config->images_path = 'components/com_guildmaster/'; update_all($error, $config, $database, $force_update); // temporary error handling if (count($error)) { error_message($error); return; } switch ($action) { case "claim" : claim_toon($database, $config, $user, $session); break; case "release" : release_toon($database, $config, $user, $session); break; case "heritage" : display_heritage($database, $config, $user, $session, $disable_hiding); break; case "edit_heri" : edit_heritage($database, $config, $user, $session); break; case "save_heri" : if (strtolower($todo) == "save") { save_heritage($database, $config, $user, $session); } else { mosRedirect($config->index.'&action=heritage', ""); } break; case "compare_heri" : compare_heritage($database, $config, $user, $session); break; default : display_roster($database, $config, $user, $session, $disable_hiding); } return; // ******************************** save heritage quests ***************************** function compare_heritage(& $database, & $config, $user, $session) { $heri_id = (int)mosGetParam($_REQUEST, 'heri_id',0); $quest = new GuildMasterHeritage($database); $quest->load($heri_id); if (!$quest->name) { $error[] = "Quests not found !"; error_message($error); return; } echo ''; echo ''; echo ''; echo ''; // Row Headers echo ''; echo ''; echo ''; echo ''; $steps = $quest->get_all_steps(); $toggle = 1; // Display Rows of data foreach ($steps as $step) { echo ''; if ($toggle == 1) { $toggle = 2; } else { $toggle = 1; } echo ''; $toons = GuildMasterHeritage :: get_toons_for_step($database, $step->step_id); if (!$toons) { $toons = array (); } echo ''; } echo ''; echo ''; echo '
'.$quest->name_short.' - '.$quest->name.'
StepToons
'.$step->name.''.implode(',', $toons).'
'; echo 'Back'; echo '
'; return; } // ******************************** save heritage quests ***************************** function save_heritage(& $database, & $config, $user, $session) { $user_id = $user->id; $toon_id = (int)mosGetParam($_REQUEST, 'toon_id', ''); $toon = new GuildMasterToon($database); $toon->load($toon_id); if (check_toon($toon, $user, 1)) { return; } $quests = GuildMasterHeritage :: get_all($database); // Check to see if the data was returned if (is_null($quests)) { $error[] = "No quests found to display."; error_message($error); return; } foreach ($quests as $quest) { // search new value foreach ($_POST as $key => $var) { // echo $key."=".$var."
"; if (preg_match("/^quest_".$quest->heri_id."$/", $key)) { echo 'Quest '.$quest->heri_id.' set to '.$var; $quest->update_step_for_toon($toon_id, (int) $var); } } } mosRedirect($config->index."&action=heritage", "Heritage quests for ".$toon->Name." updated !"); return; } // ******************************** edit heritage quests ***************************** function edit_heritage(& $database, & $config, $user, $session) { $user_id = $user->id; $toon_id = (int)mosGetParam($_REQUEST, 'toon_id', ''); $qlimit = (int) mosGetParam($_REQUEST, 'qlimit', 16); session_start(); if (isset( $_REQUEST['qoffset'] )) { $qoffset = (int) mosGetParam($_REQUEST, 'qoffset', 0); $_SESSION['qoffset'] = $qoffset; } $qoffset = mosGetParam($_SESSION, 'qoffset', 0); $toon = new GuildMasterToon($database); $toon->load($toon_id); if (check_toon($toon, $user, 1)) { return; } $quests = GuildMasterHeritage :: get_all($database, $qoffset, $qlimit); $nr_quests = GuildMasterHeritage :: get_nr_quests($database); // Check to see if the data was returned if (is_null($quests)) { $error[] = "No quests found to display."; error_message($error); return; } echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $toggle = 1; // Display Rows of data foreach ($quests as $quest) { echo ''; if ($toggle == 1) { $toggle = 2; } else { $toggle = 1; } echo ''; echo ''; $all_steps = $quest->get_all_steps(); $step = $quest->step_for_toon($toon->toon_id); echo ''; echo ''; } echo ''; echo '
Heritage Quests for '.$toon->Name.'
 QuestCurrent Step
'.$quest->name_short.' - '.$quest->name.' ('.$quest->level.')'; echo ''; echo '
'; echo ''; echo '   '; echo ''; echo ''; echo ''; echo '
'; echo '
'; show_pager($qoffset, $qlimit, $nr_quests, $config->index.'&action=edit_heri&toon_id='.$toon_id); return; } // ******************************** Release toon ***************************** function release_toon(& $database, & $config, $user, $session) { $user_id = $user->id; $toon_id = (int)mosGetParam($_REQUEST, 'toon_id', ''); $toon = new GuildMasterToon($database); $toon->load($toon_id); if (check_toon($toon, $user, 1)) { return; } $toon->release(); mosRedirect($config->index, $toon->Name." is free again !"); return; } // ******************************** Claim toon ***************************** function claim_toon(& $database, & $config, $user, $session) { $user_id = $user->id; $toon_id = (int)mosGetParam($_REQUEST, 'toon_id', ''); $toon = new GuildMasterToon($database); $toon->load($toon_id); if (check_toon($toon, $user, 0)) { return; } $toon->claim($user_id); mosRedirect($config->index, $toon->Name." is now yours !"); } // ******************************** Display Code ***************************** function display_roster(& $database, & $config, $user, $session, $disable_hiding=null) { $order = mosGetParam($_REQUEST, 'order', 'S'); $orderd = (int)mosGetParam($_REQUEST, 'orderd', 0); $toffset = (int)mosGetParam($_REQUEST, 'toffset', 0); $tlimit = (int)mosGetParam($_REQUEST, 'tlimit', 50); $user_id = $user->id; ($disable_hiding)? $hide_time=0: $hide_time = $config->hide_time; // $roster_columns = array ('N' => array ('name', 'Name', 'left'), 'R' => array ('rank_value', 'Rank', 'left'), 'AC' => array ('Adv_Class', 'Adventure', 'left'), 'AL' => array ('Adv_Level', 'Lvl', 'left'), 'CC' => array ('Art_Class', 'Artisan', 'left'), 'CL' => array ('Art_Level', 'Lvl', 'left'), 'S' => array ('Points', 'Status', 'right'), 'ST' => array ('Points_time', 'Stat/d', 'right'), 'Q' => array ('Quests', 'Quests', 'right'), 'K' => array ('KvD', 'KvD', 'right'), 'LON' => array ('lastonline', 'Last on', 'right')); // Remove Last Online for the public :) // if ($user_id) { // $roster_columns = array ('R' => array ('rank_value', 'Rank', 'left'), 'N' => array ('name', 'Name', 'left'), 'RA' => array ('Race', 'Race', 'left'), 'AL' => array ('Adv_Level', 'Lvl', 'right'), 'AC' => array ('Adv_Class', 'Adventure', 'left'), 'CL' => array ('Art_Level', 'Lvl', 'right'), 'CC' => array ('Art_Class', 'Artisan', 'left'), 'S' => array ('Points', 'Status', 'right'), 'ST' => array ('Points_time', 'Stat/d', 'right'), 'Q' => array ('Quests', 'Quests', 'right'), 'LON' => array ('lastonline', 'Last on', 'right')); // } else { // $roster_columns = array ('R' => array ('rank_value', 'Rank', 'left'), 'N' => array ('name', 'Name', 'left'), 'RA' => array ('Race', 'Race', 'left'), 'AL' => array ('Adv_Level', 'Lvl', 'right'), 'AC' => array ('Adv_Class', 'Adventure', 'left'), 'CL' => array ('Art_Level', 'Lvl', 'right'), 'CC' => array ('Art_Class', 'Artisan', 'left'), 'S' => array ('Points', 'Status', 'right'), 'ST' => array ('Points_time', 'Stat/d', 'right'), 'Q' => array ('Quests', 'Quests', 'right')); // } $roster_columns = array ('R' => array ('rank_value', 'Rank', 'left'), 'N' => array ('name', 'Name', 'left'), 'AL' => array ('Adv_Level', 'Lvl', 'right'), 'AC' => array ('Adv_Class', 'Adventure', 'left'), 'CL' => array ('Art_Level', 'Lvl', 'right'), 'CC' => array ('Art_Class', 'Artisan', 'left'), 'CL2' => array ('Art2_Level', 'Lvl', 'right'), 'CC2' => array ('Art2_Class', 'Artisan', 'left'), 'S' => array ('Points', 'Status', 'right'), 'Q' => array ('Quests', 'Quests', 'right')); $db_order = $roster_columns[$order][0]; if (!$db_order) { $db_order = 'Points'; } // reload guild from DB $guild = new GuildMasterGuild($database); $guild->load($config->guild_id); $toons = GuildMasterToon :: get_all($database, $db_order, $orderd, $toffset, $tlimit, $hide_time); // Check to see if the data was returned if (is_null($toons)) { $error[] = "No data found to display."; error_message($error); return; } // Default colspan for the top row $colspan = count($roster_columns) + 1; echo ''; if ($config->guild_info) { echo ''; echo ''; echo ''; } // Row Headers echo ''; echo ''; foreach ($roster_columns as $key => $col) { echo ''; } echo ''; if ($config->popup) { $target = ' target="_blank"'; } else { $target = ""; } $toggle = 1; // Display Rows of data foreach ($toons as $toon) { echo ''; if ($toggle == 1) { $toggle = 2; } else { $toggle = 1; } // Action cell if logged in echo ''; // Rank if ($config->use_images) { echo ''; } else { echo ''; } // Name $toon_name=$toon->Name; if ($config->show_lastnames) { $toon_name .= ' '.$toon->Last_name; } if ($config->show_prefixtitles) { $toon_name = $toon->PrefixTitle.' '.$toon_name; } echo ''; // Race // if ($config->use_images) { // echo ''; // } else { // echo ''; // } // Adventurer echo ''; if ($config->use_images) { echo ''; } else { echo ''; } // Artisan if (!$toon->Art_Class) { $toon->Art_Class="Unskilled"; } echo ''; if ($config->use_images) { echo ''; } else { echo ''; } // Secondary Tradeskill echo ''; echo ''; // Status Points echo ''; // echo ''; // Quests echo ''; // echo ''; // Last online // if ($user_id) { // echo ''; // } echo ''; } if ($config->show_updated) { echo ''; } echo '
'; echo $guild->guild_name; echo '
'; echo 'Members: '.$guild->members.'   '; echo 'Level: '.$guild->level.'   '; echo 'Status: '.$guild->points.'   '; echo 'Server: '.$guild->server_name; echo '
'; echo ' '; echo '
  '.$col[1].' 
'; if ($user_id) { // toon is free $toon->user_id = $toon->get_user_id(); if (is_null($toon->user_id)) { //claim toon echo 'C'; } elseif ($toon->user_id == $user_id || $user->usertype == "Super Administrator") { //release toon echo 'R'; } } echo ''.$toon->Rank.' '.$toon->Rank.'  '.$toon_name.' '.$toon->Race.''.$toon->Race.' '.$toon->Adv_Level.' '.$toon->Adv_Class.' '.$toon->Adv_Class.'  '.$toon->Art_Level.' '.$toon->Art_Class.' '.$toon->Art_Class.'  '.$toon->Art2_Level.'  '.substr($toon->Art2_Class,0,4).'  '.$toon->Points.'  '.sprintf("%.0f", $toon->Points_time).'  '.$toon->Quests.'  '.sprintf("%.0f", $toon->KvD).'  '.date("j.M", strtotime($toon->lastonline)).' 
'; echo 'Last Updated: '.$guild->Last_Updated; echo '
'; return; } // ******************************** Display Code ***************************** function display_heritage(& $database, & $config, $user, $session, $disable_hiding=null) { $user_id = $user->id; $qlimit = (int)mosGetParam($_REQUEST, 'qlimit', 16); $toffset = (int)mosGetParam($_REQUEST, 'toffset', 0); $tlimit = (int)mosGetParam($_REQUEST, 'tlimit', 50); session_start(); if (isset( $_REQUEST['qoffset'] )) { $qoffset = (int) mosGetParam($_REQUEST, 'qoffset', 0); $_SESSION['qoffset'] = $qoffset; } $qoffset = (int)$_SESSION['qoffset']; ($disable_hiding)? $hide_time=0: $hide_time = $config->hide_time; $quests = GuildMasterHeritage :: get_all($database, $qoffset, $qlimit); $nr_quests = GuildMasterHeritage :: get_nr_quests($database); // Check to see if the data was returned if (is_null($quests)) { $error[] = "No quests found to display."; error_message($error); return; } echo ''; // Row Headers echo ''; echo ''; echo ''; foreach ($quests as $quest) { echo ''; } echo ''; echo ''; echo ''; echo ''; foreach ($quests as $quest) { echo ''; } echo ''; echo ''; echo ''; echo ''; foreach ($quests as $quest) { echo ''; } echo ''; $toggle = 1; // Display Rows of data $toons = GuildMasterToon :: get_all($database, 'Points', 0, $toffset, $tlimit, $hide_time); // Check to see if the data was returned if (!is_null($toons)) { foreach ($toons as $toon) { echo ''; if ($toggle == 1) { $toggle = 2; } else { $toggle = 1; } echo ''; // If logged in, get toon<->user mapping if ($user_id) { $toon->user_id = $toon->get_user_id(); } if (is_null($toon->user_id) || $toon->user_id != $user_id) { echo ''; } else { // edit button echo ''; } foreach ($quests as $quest) { $step = $quest->step_for_toon($toon->toon_id); if (!$step) { echo ''; } else { if ($step[1] == "COMPLETED!") { $image = "finished.png"; } else { $image = "progress.png"; } echo ''; } } echo ''; } } echo '
 Reward
 Quest
Level
'.$quest->name_short.'
'.$quest->level.'
PlayerCompare[?]
'.$toon->Name.' Edit 
'; show_pager($qoffset, $qlimit, $nr_quests, $config->index.'&action=heritage'); return; } function show_pager($qoffset, $qlimit, $nr_quests, $next_url) { echo ''; echo ''; echo ''; echo '
'; if ($qoffset) { $new_qoffset = $qoffset - $qlimit; if ($new_qoffset < 0) { $new_qoffset = 0; } echo 'Previous'; } echo ''; if ($nr_quests > $qoffset + $qlimit) { $new_qoffset = $qoffset + $qlimit; echo 'Next'; } echo '
'; } // Function: error_message($message) // What it does: Displays an error message // Variables: // $message - Error Message to display function error_message($message) { echo '
Guild Master Error

'; echo implode('
', $message).'

'; echo 'If problem persists, check for latest updates on www.startux.de'; echo '

'; return; } function check_toon(& $toon, & $user, $must_own = 1) { $user_id = $user->id; if (is_null($user_id)) { $error[] = "Please log in to manage a toon!"; error_message($error); return true; } if (!$toon->Name) { $error[] = "Toon ( ".$toon->toon_id." ) not found !"; error_message($error); return true; } if ($must_own) { if (($toon->get_user_id() != $user_id) && ($user->usertype != "Super Administrator")) { $error[] = $toon->Name." is not owned by you!"; error_message($error); return true; } } else { if (!is_null($toon->get_user_id())) { $error[] = $toon->Name." is owned by ".$user->name." !
Toon must be released first."; error_message($error); return; } } return null; } ?>