tmpl.inc-header.php


/ Published in: PHP
Save to your folder(s)

Behold the most technologically advanced ExpressionEngine QDB ever


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. global $DB, $SESS;
  4.  
  5. $show_access_debug = false;
  6.  
  7. // Check to see if a) group has privileges to access QDB, and b) user has privileges to access QDB
  8. $query = "SELECT exp_qdb_group_privileges.group_can_access_qdb FROM exp_qdb_group_privileges WHERE " .
  9. "exp_qdb_group_privileges.group_id = '" . $SESS->userdata['group_id'] . "'";
  10. $result = $DB->query($query);
  11. $group_can_access_qdb = 1;
  12. if ($result->num_rows > 0)
  13. $group_can_access_qdb = intval($result->row['group_can_access_qdb']);
  14.  
  15. $query = "SELECT exp_qdb_member_privileges.member_can_access_qdb FROM exp_qdb_member_privileges WHERE " .
  16. "exp_qdb_member_privileges.member_id = '" . $SESS->userdata['member_id'] . "'";
  17. $result = $DB->query($query);
  18. $member_can_access_qdb = 1;
  19. if ($result->num_rows > 0)
  20. $member_can_access_qdb = intval($result->row['member_can_access_qdb']);
  21.  
  22. $can_access_qdb = 1;
  23. if ($group_can_access_qdb >0 && $member_can_access_qdb <= 0)
  24. $can_access_qdb = 0;
  25. else if ($group_can_access_qdb <= 0 && $member_can_access_qdb > 0)
  26. $can_access_qdb = 1;
  27. else if ($group_can_access_qdb <= 0 && $member_can_access_qdb <= 0)
  28. $can_access_qdb = 0;
  29.  
  30. if (!$can_access_qdb)
  31. $FNS->redirect('');
  32.  
  33. // Check to see if member has privileges to submit quotes
  34. if ($can_access_qdb) {
  35. $query = "SELECT exp_qdb_group_privileges.group_can_add_quotes from exp_qdb_group_privileges WHERE " .
  36. "exp_qdb_group_privileges.group_id = '" . $SESS->userdata['group_id'] . "'";
  37. $result = $DB->query($query);
  38. $group_can_add_quotes = 1;
  39. if ($result->num_rows > 0)
  40. $group_can_add_quotes = intval($result->row['group_can_add_quotes']);
  41.  
  42. $query = "SELECT exp_qdb_member_privileges.member_can_add_quotes from exp_qdb_member_privileges WHERE " .
  43. "exp_qdb_member_privileges.member_id = '" . $SESS->userdata['member_id'] . "'";
  44. $result = $DB->query($query);
  45. $member_can_add_quotes = 1;
  46. if ($result->num_rows > 0)
  47. $member_can_add_quotes = intval($result->row['member_can_add_quotes']);
  48.  
  49. $can_add_quotes = 1;
  50. if ($group_can_add_quotes > 0 && $member_can_access_qdb <= 0)
  51. $can_add_quotes = 0;
  52. else if ($group_can_add_quotes <= 0 && $member_can_add_quotes > 0)
  53. $can_add_quotes = 1;
  54. else if ($group_can_add_quotes <= 0 && $member_can_add_quotes <= 0)
  55. $can_add_quotes = 0;
  56. }
  57.  
  58. ?>
  59.  
  60. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  61. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  62. <html>
  63. <head>
  64. <title>Disciples of Bork - Quote Database</title>
  65. <link rel="stylesheet" type="text/css" media="all" href="{stylesheet=qdb/css_screen}" />
  66. </head>
  67. <body>
  68. <div id="wrapper">
  69.  
  70. <div id="header"><h1>
  71. Quote Database <span class="version">Some things people have said</span>
  72. <span id="nav">&nbsp;<?php if ($can_access_qdb && $can_add_quotes): ?><a href="{path=qdb/submit}">Submit a Quote</a><?php endif; ?></span>
  73. </h1></div>
  74.  
  75. <!-- Access debug information -->
  76. <?php if ($show_access_debug): ?>
  77. <div style="display: block; width: 49%; float: left;">
  78. <h2>QDB Access</h2>
  79. <ul>
  80. <li><b>$group_can_access_qdb</b> = <?=$group_can_access_qdb;?></li>
  81. <li><b>$member_can_access_qdb</b> = <?=$member_can_access_qdb;?></li>
  82. <li><b>$can_access_qdb</b> = <?=$can_access_qdb;?></li>
  83. </ul>
  84. </div>
  85.  
  86. <div style="display: block; width: 49%; float: right;">
  87. <h2>Submit Quote Access</h2>
  88. <ul>
  89. <li><b>$group_can_add_quotes</b> = <?=$group_can_add_quotes;?></li>
  90. <li><b>$member_can_add_quotes</b> = <?=$member_can_add_quotes;?></li>
  91. <li><b>$can_add_quotes</b> = <?=$can_add_quotes;?></li>
  92. </ul>
  93. </div>
  94. <?php endif; ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.