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

/conference/volunteer.php

https://github.com/azeckoski/az-php-sandbox
PHP | 369 lines | 291 code | 45 blank | 33 comment | 81 complexity | 30214deadea4e60c4a66a3230f2a721f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /* add_session.php
  3. * Created on May 20, 2006 by @author az - Aaron Zeckoski
  4. * Aaron Zeckoski (aaronz@vt.edu) - Virginia Tech (http://www.vt.edu/)
  5. * copyright 2006 Virginia Tech
  6. */
  7. ?>
  8. <?php
  9. require_once 'include/tool_vars.php';
  10. $PAGE_NAME = "Volunteer";
  11. $Message = "";
  12. // connect to database
  13. require $ACCOUNTS_PATH.'sql/mysqlconnect.php';
  14. // check authentication
  15. require $ACCOUNTS_PATH.'include/check_authentic.php';
  16. // login if not autheticated
  17. //require $ACCOUNTS_PATH.'include/auth_login_redirect.php';
  18. // adding volunteer
  19. if ($_REQUEST['sessions_pk'] && $User->pk) {
  20. $error = false;
  21. $sessionPk = $_REQUEST['sessions_pk'];
  22. if ($_REQUEST['C'] || $_REQUEST['R']) {
  23. // adding a volunteer for this session
  24. $sql = "select * from conf_sessions where pk = '$sessionPk'";
  25. $result = mysql_query($sql) or die("Fetch query failed ($sql): " . mysql_error());
  26. $conf_session = mysql_fetch_assoc($result);
  27. if (empty($conf_session)) {
  28. echo "FATAL ERROR: Invalid session pk: $sessionPk <br/>";
  29. echo "<a href='$_SERVER[PHP_SELF]'>BACK</a><br/>";
  30. exit;
  31. }
  32. $volunteer_sql = "";
  33. if ($_REQUEST['C'] && !$conf_session['convenor_pk']) {
  34. $volunteer_sql = "convenor_pk = '$User->pk'";
  35. $Message = "convenor (".$User->fullname.") added to session";
  36. } else if ($_REQUEST['R'] && !$conf_session['recorder_pk']) {
  37. $volunteer_sql = "recorder_pk = ".$User->pk;
  38. $Message = "Recorder (".$User->fullname.") added to session";
  39. } else {
  40. // can only add a convenor or recorder if one is not already set
  41. $error = true;
  42. }
  43. if (!$error) {
  44. // update sql
  45. $sql = "UPDATE conf_sessions SET $volunteer_sql WHERE pk = '$sessionPk'";
  46. $result = mysql_query($sql) or die("Sessions query failed ($sql): " . mysql_error());
  47. if (mysql_affected_rows() <= 0) {
  48. $Message = "Error: Could not insert volunteer!";
  49. }
  50. }
  51. } else if ($_REQUEST['NC'] || $_REQUEST['NR']) {
  52. // removing the volunteer from a session
  53. $volunteer_sql = "";
  54. if ($_REQUEST['NC']) {
  55. $volunteer_sql = "convenor_pk = null";
  56. $Message = "convenor removed from session";
  57. } else if ($_REQUEST['NR']) {
  58. $volunteer_sql = "recorder_pk = null";
  59. $Message = "Recorder removed from session";
  60. } else {
  61. // can only add a convenor or recorder if one is not already set
  62. $error = true;
  63. }
  64. if (!$error) {
  65. // update sql
  66. $sql = "UPDATE conf_sessions SET $volunteer_sql WHERE pk = '$sessionPk'";
  67. $result = mysql_query($sql) or die("Sessions query failed ($sql): " . mysql_error());
  68. if (mysql_affected_rows() <= 0) {
  69. $Message = "Error: Could not remove volunteer!";
  70. }
  71. }
  72. }
  73. }
  74. // fetch the proposals
  75. $sql = "select CP.*, CS.timeslots_pk, CS.pk as sessions_pk, CS.convenor_pk, CS.recorder_pk, " .
  76. "CT.start_time, CR.title as room_title from conf_proposals CP " .
  77. "join conf_sessions CS on CS.proposals_pk = CP.pk " .
  78. "join conf_timeslots CT on CT.pk = CS.timeslots_pk and CT.start_time is not null " .
  79. "left join conf_rooms CR on CR.pk = CS.rooms_pk " .
  80. "where CP.confID = '$CONF_ID' and CP.approved='Y' and CP.type != 'demo' " .
  81. "and CP.type != 'BOF' order by start_time, track";
  82. //echo "$sql<br/>";
  83. $result = mysql_query($sql) or die("Fetch query failed ($sql): " . mysql_error());
  84. $conf_proposals = array();
  85. while($row=mysql_fetch_assoc($result)) { $conf_proposals[$row['pk']] = $row; }
  86. //echo "<pre>",print_r($conf_proposals),"</pre>";
  87. // fetch the list of sessions for this user to stop time conflicts
  88. $user_conf_sessions = array();
  89. if ($User->pk) {
  90. $sql = "select distinct(timeslots_pk) as pk from conf_sessions " .
  91. "where (recorder_pk = '$User->pk' or convenor_pk='$User->pk') " .
  92. "and confID='$CONF_ID'";
  93. $result = mysql_query($sql) or die("Fetch query failed ($sql): " . mysql_error());
  94. while($row=mysql_fetch_assoc($result)) { $user_conf_sessions[$row['pk']] = $row; }
  95. //echo "<pre>",print_r($user_conf_sessions),"</pre>";
  96. }
  97. // custom CSS file
  98. $CSS_FILE = $ACCOUNTS_URL."/include/accounts.css";
  99. $CSS_FILE2 = $TOOL_URL."/include/schedule.css";
  100. $DATE_FORMAT = "M d, Y h:i A";
  101. $CSS_FILE = $ACCOUNTS_URL.'/include/accounts.css';
  102. // top header links
  103. if ( ($User->checkPerm("admin_accounts")) || ($User->checkPerm("admin_conference")) || ($User->checkPerm("proposals_dec2006")) || ($User->checkPerm("registration_dec2006")) ) {
  104. // top header links for admins
  105. $EXTRA_LINKS = "<span class='extralinks'>" ;
  106. $EXTRA_LINKS .= "<a class='active' href='$CONFADMIN_URL/admin/schedule.php'>Schedule (table view)</a>";
  107. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/admin/schedule_details.php'>Schedule (list view)</a>";
  108. if ($VOLUNTEER) {
  109. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/volunteer.php'>Volunteer</a>";
  110. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/admin/volunteers.php'>Convener List</a>";
  111. }
  112. $EXTRA_LINKS .="</span>";
  113. } else {
  114. $EXTRA_LINKS = "<span class='extralinks'>";
  115. $EXTRA_LINKS .= "<a class='active' href='$ACCOUNTS_URL/index.php' title='Sakai accounts home'><strong>Home</strong></a>:";
  116. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/registration/index.php'>Register</a>" .
  117. "<a href='$CONFADMIN_URL/proposals/index.php'>Call for Proposals</a>" ;
  118. if ($SCHEDULE_PUBLISHED) {
  119. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/admin/schedule.php'>Schedule (table view)</a>";
  120. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/admin/schedule_details.php'>Schedule (list view)</a>";
  121. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/volunteer.php'>VOLUNTEER</a>";
  122. } else {
  123. $EXTRA_LINKS .= "<a href='$CONFADMIN_URL/admin/draft_schedule.php'>Schedule</a>";
  124. }
  125. $EXTRA_LINKS.="</span>";
  126. }
  127. ?>
  128. <?php //INCLUDE THE HEADER
  129. include $ACCOUNTS_PATH.'include/top_header.php'; ?>
  130. <script type="text/javascript">
  131. <!--
  132. function orderBy(newOrder) {
  133. if (document.adminform.sortorder.value == newOrder) {
  134. document.adminform.sortorder.value = newOrder + " desc";
  135. } else {
  136. document.adminform.sortorder.value = newOrder;
  137. }
  138. document.adminform.submit();
  139. return false;
  140. }
  141. function setSessions(pk) {
  142. document.adminform.sessions_pk.value = pk;
  143. }
  144. // -->
  145. </script>
  146. <?php include $ACCOUNTS_PATH.'include/header.php'; ?>
  147. <form name="adminform" method="post" action="<?=$_SERVER['PHP_SELF']; ?>" style="margin:0px;">
  148. <input type="hidden" name="sessions_pk" value=""/>
  149. <div class="definitions" id="help">
  150. <div class="defheader">How to use the volunteer page</div>
  151. <div style="padding:3px;">
  152. <?php if(!$User->pk) { ?>
  153. <div style="font-size:1.1em;"> &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<strong>You must <a style="color:red" href="<?=$ACCOUNTS_URL?>/login.php?ref=/conference/volunteer.php">login</a>
  154. in order to volunteer for a session</strong><br/><br/></div>
  155. <?php } ?>
  156. <ul style="margin:2px 20px;">
  157. <li>This page contains a full listing of all sessions that need to be convened<!-- or recorded-->. Sessions are listed by dates in the order they will occur.</li>
  158. <li><strong>You must be logged in to volunteer yourself</strong>, if you do not see any buttons on the page then login using the <strong>login</strong> link in the upper right.</li>
  159. <li>Click the <strong>Conv</strong> button to the left of a session volunteer to convene it</li>
  160. <li>Click the <strong>X</strong> button to the left of a session remove yourself as a volunteer for it<br/><br/></li>
  161. <li><strong>Convenor responsibilities</strong></li>
  162. <ul>
  163. <li><strong>Introductions</strong> - Introduce the presenters for each session.</li>
  164. <li><strong>Timekeeping</strong> - Attempt to start the session they are convening on time. It is also the responsibility of the Session Convenor to end the session on time. (It often works well to signal the presenter(s) when they have 5 minutes left and then assertively end the session on time.)</li>
  165. <li><strong>Evaluations</strong> - Distribute session evaluations to attendees at the beginning of the session and encourage attendees to put their completed evaluations in the Evaluation Collection Boxes at the door. The convenor should pick up any completed session evaluations from the box and bring them to the registration table after the session is over.</li>
  166. </ul>
  167. <!--
  168. <li>Click the <strong>Rec</strong> button to the left of a session volunteer to record it</li>
  169. <li><strong>Recorder responsibilities</strong></li>
  170. <ul>
  171. <li><strong>Recording audio</strong> - Bring their own iPods (or check out an iPod from the registration table if available) and record the entire session.</li>
  172. <li><strong>Posting recording</strong> - Immediately following the session, recorders will take their iPod to the registration table and Sakai staff or volunteers will download the session recording and post it to the appropriate session page in confluence.</li>
  173. </ul> -->
  174. </ul>
  175. </div>
  176. </div>
  177. <div class="colorkey">
  178. <div class="colorkeyheader">Color Key</div>
  179. <div style="padding:3px;">
  180. <b style="font-size:1.1em;">Key:</b>
  181. <?php if($User->pk) { ?>
  182. <div class="convenor_user" style='display:inline;'>&nbsp;You are the convenor&nbsp;</div>
  183. &nbsp;
  184. <!-- <div class="recorder_user" style='display:inline;'>&nbsp;You are the recorder&nbsp;</div>
  185. &nbsp;
  186. -->
  187. <?php } ?>
  188. <div class="convenor_exists" style='display:inline;'>&nbsp;Convenor set&nbsp;</div>
  189. &nbsp;
  190. <!--<div class="recorder_exists" style='display:inline;'>&nbsp;Recorder set&nbsp;</div>
  191. &nbsp;
  192. <div class="recorder_convenor_exist" style='display:inline;'>&nbsp;Covenor and Recorder set&nbsp;</div>
  193. &nbsp;
  194. -->
  195. </div>
  196. </div>
  197. <table border="0" cellspacing="0" width="100%">
  198. <?php
  199. $line = 0;
  200. $last = 0;
  201. foreach ($conf_proposals as $proposal_pk=>$conf_proposal) {
  202. $line++;
  203. $linestyle = "oddrow";
  204. if (($line % 2) == 0) { $linestyle = "evenrow"; } else { $linestyle = "oddrow"; }
  205. $disabledN = "";
  206. if (strtotime($CONF_START_DATE) < time()) {
  207. // cannot unvolunteer after the conference start date
  208. $disabledN = "disabled='y'";
  209. }
  210. $disabledR = "";
  211. $disabledC = "";
  212. // cannot volunteer for something that someone else already volunteered for
  213. if ($conf_proposal['recorder_pk'] && $conf_proposal['convenor_pk']) {
  214. $disabledC = "disabled='y'";
  215. $disabledR = "disabled='y'";
  216. $linestyle = "recorder_convenor_exist";
  217. } else if ($conf_proposal['recorder_pk']) {
  218. $disabledR = "disabled='y'";
  219. $linestyle = "recorder_exists";
  220. } else if ($conf_proposal['convenor_pk']) {
  221. $disabledC = "disabled='y'";
  222. $linestyle = "convenor_exists";
  223. }
  224. // make it easy for someone to tell they are a convenor or recorder
  225. if ($User->pk) {
  226. if ($conf_proposal['convenor_pk'] == $User->pk) {
  227. $linestyle = "convenor_user";
  228. } else if ($conf_proposal['recorder_pk'] == $User->pk) {
  229. $linestyle = "recorder_user";
  230. }
  231. if (array_key_exists($conf_proposal['timeslots_pk'],$user_conf_sessions) &&
  232. $conf_proposal['length'] > 45) {
  233. $disabledC = "disabled='y'";
  234. $disabledR = "disabled='y'";
  235. }
  236. }
  237. //$current = $conf_proposal['type'];
  238. $current = date('D, M d',strtotime($conf_proposal['start_time']));
  239. if ($line == 1 || $current != $last) {
  240. // next item, print the header again
  241. ?>
  242. <tr>
  243. <td class='time_header'><?= $current ?></td>
  244. <td class='schedule_header'>Title</td>
  245. <td class='schedule_header'>Track</td>
  246. <td class='schedule_header'>Room</td>
  247. <td class='schedule_header'>Length</td>
  248. <td class='schedule_header'>Scheduled</td>
  249. </tr>
  250. <?php
  251. }
  252. $last = $current;
  253. if ($conf_proposal['track'] =="unavailable") {
  254. //do nothing
  255. } else {
  256. ?>
  257. <tr class="<?= $linestyle ?>">
  258. <td valign="middle" align="center">
  259. <?php if (!$User->pk) { ?>
  260. <label title="Login to enable the volunteer buttons" style="font-size:.95em;">
  261. <?php
  262. if ($conf_proposal['convenor_pk']) { echo "<strong>Conv</strong>"; } else { echo "NC"; }
  263. //echo ", ";
  264. //if ($conf_proposal['recorder_pk']) { echo "<strong>Rec</strong>"; } else { echo "NR"; }
  265. ?>
  266. </label>
  267. <?php } else if ($conf_proposal['convenor_pk'] == $User->pk) { ?>
  268. <label title="Remove yourself as a volunteer to convene this session">
  269. <span style="font-size:.9em;">Convenor</span>
  270. <input class="filter" type="submit" <?= $disabledN ?> name="NC" value="X" onClick="setSessions('<?= $conf_proposal['sessions_pk'] ?>');" />
  271. </label>
  272. <?php } else if ($conf_proposal['recorder_pk'] == $User->pk) { ?>
  273. <label title="Remove yourself as a volunteer to record this session">
  274. <span style="font-size:.9em;">Recorder</span>
  275. <input class="filter" type="submit" <?= $disabledN ?> name="NR" value="X" onClick="setSessions('<?= $conf_proposal['sessions_pk'] ?>');" />
  276. </label>
  277. <?php } else { ?>
  278. <label title="Volunteer to convene this session">
  279. <input class="filter" type="submit" <?= $disabledC ?> name="C" value="Conv" onClick="setSessions('<?= $conf_proposal['sessions_pk'] ?>');" />
  280. </label>
  281. <!--- <label title="Volunteer to record this session">
  282. <input class="filter" type="submit" <?= $disabledR ?> name="R" value="Rec" onClick="setSessions('<?= $conf_proposal['sessions_pk'] ?>');" />
  283. </label>
  284. -->
  285. <?php } ?>
  286. </td>
  287. <td class="small_text">
  288. <label title="<?= mysql_real_escape_string($conf_proposal['abstract']) ?>">
  289. <?= $conf_proposal['title'] ?>
  290. </label>
  291. </td>
  292. <td >
  293. <?php
  294. if ($conf_proposal['track']=="Other"){
  295. echo "Multiple Audiences";
  296. } else {
  297. echo $conf_proposal['track'];
  298. }
  299. ?>
  300. </td>
  301. <td nowrap='y'>
  302. <?= $conf_proposal['room_title'] ?>
  303. </td>
  304. <td class="grid">
  305. <?= $conf_proposal['length'] ?>
  306. </td>
  307. <td class="session_date" nowrap='y'>
  308. <?php
  309. if ($conf_proposal['start_time']) {
  310. echo date('D, M d, g:i a',strtotime($conf_proposal['start_time']));
  311. } else {
  312. echo "--";
  313. }
  314. ?>
  315. </td>
  316. </tr>
  317. <?php
  318. } //end check for unavailable or placeholder slots
  319. } // end foreach
  320. ?>
  321. </table>
  322. </form>
  323. <br/>
  324. <?php include $TOOL_PATH.'include/admin_footer.php'; ?>