Source for file grant-permissions.php

Documentation is available at grant-permissions.php

  1. <?php
  2. /**
  3. * Grant elevated permissions to a team member.
  4. *
  5. * This file is part of CompInaBox.
  6. * @copyright Copyright 2001-2005. Eric D. Nielsen, All rights reserverd.
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. * @author Eric D. Nielsen <nielsene@alum.mit.edu>
  9. *
  10. * @package WebPages
  11. * @subpackage Team-Admin
  12. * @todo Lock down more user pre-set fields, but allow team to set needed ones
  13. * if not set
  14. * @internal This file is called from within the admin script up on-level
  15. * in the directory, the admin script handles all the setup tasks needed.
  16. */
  17. // {{{ Variable Importation
  18. if (isset($_POST["submit"]))
  19. {
  20. $currentUsername = $user->getUsername();
  21. $query = "SELECT rolename FROM user_team_roles WHERE username='$currentUsername' AND teamid=$teamID;";
  22. $result=$db->query($query);
  23. $curUserRoles=array();
  24. $numRoles=$result->numrows();
  25. for ($i=0;$i<$numRoles;$i++)
  26. {
  27. list($aRole)=$result->getRowAt($i);
  28. $curUserRoles[]=$aRole;
  29. }
  30. if (in_array("Affiliation Captain/Owner",$curUserRoles))
  31. {
  32. $curUserRoles[]="Affiliation Registration Coordinator";
  33. $curUserRoles[]="Addiliation Treasurer";
  34. }
  35.  
  36. for($i=0;$i<3;$i++)
  37. {
  38. if (isset($_POST["name-$i"]) && $_POST["name-$i"]!="" &&
  39. isset($_POST["role-$i"]) && $_POST["role-$i"]!="")
  40. {
  41. $grantUser=$_POST["name-$i"];
  42. $grantRole=$_POST["role-$i"];
  43. if (!in_array($granttRole,$curUserRoles)) continue;
  44. $query = "SELECT COUNT(*) FROM users NATURAL JOIN people NATURAL JOIN team_membership WHERE username='$grantUser';";
  45. $result=$db->query($query);
  46. $numrows=$result->getRowAt(0);
  47. if ($numrows==0) continue;
  48. $query = "SELECT COUNT(*) FROM users NATURAL JOIN user_team_roles WHERE teamid=$teamID AND username='$grantUser' AND rolename='Affiliation Captain/Owner';";
  49. $result=$db->query($query);
  50. $numrows=$result->getRowAt(0);
  51. if ($numrows==0) $continue; //Prevent redundant entries
  52. $query = "SELECT COUNT(*) FROM users NATURAL JOIN user_team_roles WHERE teamid=$teamID AND username='$grantUser' AND rolename='$grantRole';";
  53. $result=$db->query($query);
  54. $numrows=$result->getRowAt(0);
  55. if ($numrows==0) continue; //Prevent redundant entries
  56. $db->startTransaction();
  57. if ($grantRole=='Affiliation Captain/Owver')
  58. {
  59. $query="DELETE FROM user_team_roles WHERE teamid=$teamID AND username='$grantUser';";
  60. $db->query($query);
  61. }
  62. $query ="INSERT INTO user_team_roles (teamid, rolename, username) VALUES ($teamID,'$grantRole','$grantUser');";
  63. $db->query($query);
  64. $db->commit();
  65. }
  66. }
  67. }
  68. // }}}
  69.  
  70. localRedirect("Location: {$CIB_BASE_URL}team/admin/$teamID/Membership");
  71. exit();
  72. ?>

Documentation generated on Tue, 25 Apr 2006 13:01:40 -0400 by phpDocumentor 1.3.0RC3