PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/addons/questlist/realm/index.php

http://wowroster.googlecode.com/
PHP | 206 lines | 144 code | 36 blank | 26 comment | 4 complexity | 7288b39f647e865e50ab45000252ed17 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * WoWRoster.net WoWRoster
  4. *
  5. * Lists quests for each character
  6. *
  7. *
  8. * @copyright 2002-2011 WoWRoster.net
  9. * @license http://www.gnu.org/licenses/gpl.html Licensed under the GNU General Public License v3.
  10. * @version SVN: $Id: index.php 2302 2011-03-19 16:50:59Z c.treyce@gmail.com $
  11. * @link http://www.wowroster.net
  12. * @package QuestList
  13. */
  14. if( !defined('IN_ROSTER') )
  15. {
  16. exit('Detected invalid access to this file!');
  17. }
  18. $roster->output['title'] = $roster->locale->act['questlist'];
  19. $roster->tpl->assign_vars(array(
  20. 'S_INFO_ADDON' => active_addon('info'),
  21. 'S_SHOW' => false,
  22. 'L_QUEST_LIST' => $roster->locale->act['questlist'],
  23. 'L_QUEST_LIST_HELP' => $roster->locale->act['questlist_help'],
  24. 'L_SEARCH_ZONE' => $roster->locale->act['search_by_zone'],
  25. 'L_SEARCH_QUEST' => $roster->locale->act['search_by_quest'],
  26. 'L_NAME' => $roster->locale->act['name'],
  27. 'L_QUEST_DATA' => $roster->locale->act['quest_data'],
  28. 'L_COMPLETE' => $roster->locale->act['complete'],
  29. 'L_FAILED' => $roster->locale->act['failed'],
  30. 'L_DAILY' => $roster->locale->act['daily'],
  31. )
  32. );
  33. $zoneid = ( isset($_GET['zoneid']) ? $_GET['zoneid'] : '' );
  34. $questid = ( isset($_GET['questid']) ? $_GET['questid'] : '' );
  35. // The next two lines call the function selectQuery and use it to populate and return the code that lists the dropboxes for quests and for zones
  36. selectQuery('`' . $roster->db->table('quests') . "` AS quests LEFT JOIN `" . $roster->db->table('quest_data') . "` AS quest_data ON `quests`.`quest_id` = `quest_data`.`quest_id` LEFT JOIN `" . $roster->db->table('players') . "` AS players ON `players`.`member_id` = `quests`.`member_id` WHERE `players`.`server` = '" . $roster->db->escape($roster->data['server']) . "' AND `quests`.`member_id` = `players`.`member_id`", 'DISTINCT `quest_data`.`zone`', 'zone', $zoneid, '&amp;zoneid');
  37. selectQuery('`' . $roster->db->table('quests') . "` AS quests LEFT JOIN `" . $roster->db->table('quest_data') . "` AS quest_data ON `quests`.`quest_id` = `quest_data`.`quest_id` LEFT JOIN `" . $roster->db->table('players') . "` AS players ON `players`.`member_id` = `quests`.`member_id` WHERE `players`.`server` = '" . $roster->db->escape($roster->data['server']) . "' AND `quests`.`member_id` = `players`.`member_id`", 'DISTINCT `quest_data`.`quest_name`', 'quest_name', $questid, '&amp;questid');
  38. if( !empty($zoneid) )
  39. {
  40. $sql = "SELECT DISTINCT `zone` FROM `" . $roster->db->table('quest_data') . "` WHERE `zone` = '$zoneid' ORDER BY `zone`;";
  41. $zone = $roster->db->query_first($sql) or die_quietly($roster->db->error(),'Database Error',__FILE__,__LINE__,$sql);
  42. // Set our questlink caption name
  43. setTooltip('questlink',$roster->locale->act['quest_links']);
  44. $roster->tpl->assign_vars(array(
  45. 'S_SHOW' => true,
  46. 'ZONE_NAME' => $zone
  47. )
  48. );
  49. $qquery = "SELECT *"
  50. . " FROM `" . $roster->db->table('quest_data') . "`"
  51. . " WHERE `zone` = '" . $zoneid . "'"
  52. . " ORDER BY `quest_name`;";
  53. $qresult = $roster->db->query($qquery) or die_quietly($roster->db->error(),'Database Error',__FILE__,__LINE__,$qquery);
  54. while( $qrow = $roster->db->fetch($qresult) )
  55. {
  56. $query = "SELECT `q`.*, `p`.`name`, `p`.`server`, `p`.`member_id`, `p`.`level`"
  57. . " FROM `" . $roster->db->table('quests') . "` AS q, `" . $roster->db->table('players') . "` AS p"
  58. . " WHERE `p`.`server` = '" . $roster->db->escape($roster->data['server']) . "' AND `q`.`quest_id` = '" . $qrow['quest_id'] . "' AND `q`.`member_id` = `p`.`member_id`"
  59. . " ORDER BY `p`.`level` DESC, `p`.`name` ASC;";
  60. $result = $roster->db->query($query) or die_quietly($roster->db->error(),'Database Error',__FILE__,__LINE__,$query);
  61. // Quest links
  62. $num_of_tips = (count($tooltips)+1);
  63. $linktip = array();
  64. foreach( $roster->locale->act['questlinks'] as $link )
  65. {
  66. $linktip[] = '<a href="' . sprintf($link['url'],$qrow['quest_id']) . '" target="_blank">' . $link['name'] . '</a>';
  67. }
  68. setTooltip($num_of_tips, implode('<br />', $linktip));
  69. // Set template variables
  70. $roster->tpl->assign_block_vars('quests',array(
  71. 'ID' => $qrow['quest_id'],
  72. 'NAME' => $qrow['quest_name'],
  73. 'LEVEL' => $qrow['quest_level'],
  74. 'TAG' => $qrow['quest_tag'],
  75. 'GROUP' => $qrow['group'],
  76. 'DAILY' => $qrow['daily'],
  77. 'TOOLTIP' => ' onclick="return overlib(overlib_' . $num_of_tips . ',CAPTION,overlib_questlink,STICKY,NOCLOSE,WRAP,OFFSETX,5,OFFSETY,5);"',
  78. )
  79. );
  80. while( $row = $roster->db->fetch($result) )
  81. {
  82. // Set template variables
  83. $roster->tpl->assign_block_vars('quests.members',array(
  84. 'ROW_CLASS' => $roster->switch_row_class(),
  85. 'LINK' => makelink('char-info-quests&amp;a=c:' . $row['member_id']),
  86. 'NAME' => $row['name'],
  87. 'LEVEL' => $row['level'],
  88. 'COMPLETE' => $row['is_complete'],
  89. )
  90. );
  91. }
  92. $roster->db->free_result($result);
  93. }
  94. }
  95. if( !empty($questid) )
  96. {
  97. $sql = "SELECT * FROM `" . $roster->db->table('quest_data') . "` WHERE `quest_name` = '" . $questid . "';";
  98. $result = $roster->db->query($sql) or die_quietly($roster->db->error(),'Database Error',__FILE__,__LINE__,$sql);
  99. // Set our questlink caption name
  100. setTooltip('questlink',$roster->locale->act['quest_links']);
  101. $qnrow = $roster->db->fetch($result,SQL_ASSOC);
  102. $roster->tpl->assign_vars(array(
  103. 'S_SHOW' => true,
  104. 'ZONE_NAME' => $qnrow['zone']
  105. )
  106. );
  107. // Quest links
  108. $num_of_tips = (count($tooltips)+1);
  109. $linktip = array();
  110. foreach( $roster->locale->act['questlinks'] as $link )
  111. {
  112. $linktip[] = '<a href="' . sprintf($link['url'],$qnrow['quest_id']) . '" target="_blank">' . $link['name'] . '</a>';
  113. }
  114. setTooltip($num_of_tips, implode('<br />', $linktip));
  115. $linktip = ' onclick="return overlib(overlib_'.$num_of_tips.',CAPTION,overlib_questlink,STICKY,NOCLOSE,WRAP,OFFSETX,5,OFFSETY,5);"';
  116. $roster->tpl->assign_block_vars('quests',array(
  117. 'ID' => $qnrow['quest_id'],
  118. 'NAME' => $qnrow['quest_name'],
  119. 'LEVEL' => $qnrow['quest_level'],
  120. 'TAG' => $qnrow['quest_tag'],
  121. 'GROUP' => $qnrow['group'],
  122. 'DAILY' => $qnrow['daily'],
  123. 'TOOLTIP' => ' onclick="return overlib(overlib_' . $num_of_tips . ',CAPTION,overlib_questlink,STICKY,NOCLOSE,WRAP,OFFSETX,5,OFFSETY,5);"',
  124. )
  125. );
  126. $query = "SELECT `q`.*, `p`.`name`, `p`.`server`, `p`.`member_id`, `p`.`level`"
  127. . " FROM `" . $roster->db->table('quests') . "` AS q, `" . $roster->db->table('players') . "` AS p"
  128. . " WHERE `p`.`server` = '" . $roster->db->escape($roster->data['server']) . "' AND `q`.`quest_id` = '" . $qnrow['quest_id'] . "' AND `q`.`member_id` = `p`.`member_id`"
  129. . " ORDER BY `p`.`level` DESC, `p`.`name` ASC;";
  130. $result = $roster->db->query($query) or die_quietly($roster->db->error(),'Database Error',__FILE__,__LINE__,$query);
  131. while( $row = $roster->db->fetch($result) )
  132. {
  133. // Set template variables
  134. $roster->tpl->assign_block_vars('quests.members',array(
  135. 'ROW_CLASS' => $roster->switch_row_class(),
  136. 'LINK' => makelink('char-info-quests&amp;a=c:' . $row['member_id']),
  137. 'NAME' => $row['name'],
  138. 'LEVEL' => $row['level'],
  139. 'COMPLETE' => $row['is_complete'],
  140. )
  141. );
  142. }
  143. $roster->db->free_result($result);
  144. }
  145. $roster->tpl->set_handle('body', $addon['basename'] . '/questlist.html');
  146. $roster->tpl->display('body');
  147. function selectQuery( $table , $fieldtoget , $field , $current , $urltorun )
  148. {
  149. global $roster;
  150. /**
  151. * table, field, current option if matching to existing data (EG: $row['state'])
  152. * and you want the drop down to be preselected on their current data, the id field from that table (EG: stateid)
  153. */
  154. $sql = "SELECT $fieldtoget FROM $table ORDER BY `quest_data`.$field ASC;";
  155. // execute SQL query and get result
  156. $sql_result = $roster->db->query($sql) or die_quietly($roster->db->error(),'Database Error',__FILE__,__LINE__,$sql);
  157. // put data into drop-down list box
  158. while( $row = $roster->db->fetch($sql_result) )
  159. {
  160. $id = rawurlencode($row["$field"]); // must leave double quote
  161. $optiontocompare = $row["$field"]; // must leave double quote
  162. $optiontodisplay = $row["$field"]; // must leave double quote
  163. $roster->tpl->assign_block_vars($field . '_list',array(
  164. 'NAME' => $optiontodisplay,
  165. 'VALUE' => makelink("$urltorun=$id", true),
  166. 'SELECTED' => ( stripslashes($current) == $optiontocompare ? true : false )
  167. )
  168. );
  169. }
  170. }