Source for file EveryoneGroup.class.php

Documentation is available at EveryoneGroup.class.php

  1. <?php
  2.  
  3. require_once(dirname(__FILE__)."/HarmoniGroup.class.php");
  4.  
  5. /**
  6. * The Everyone Group contains all other Agents and Groups in the system,
  7. * including the Anonymous Agent. Agents and Groups cannot be added or removed
  8. * from this group as they are always in it.
  9. *
  10. * <p>
  11. * OSID Version: 2.0
  12. * </p>
  13. *
  14. * @package harmoni.osid_v2.agent
  15. *
  16. * @copyright Copyright &copy; 2005, Middlebury College
  17. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  18. *
  19. * @version $Id: EveryoneGroup.class.php,v 1.7 2007/08/22 14:45:44 adamfranco Exp $
  20. */
  21. class EveryoneGroup
  22. extends HarmoniGroup
  23. {
  24. /**
  25. * Update the Description of this Group.
  26. *
  27. * @param string $description
  28. *
  29. * @throws object AgentException An exception with one of the
  30. * following messages defined in org.osid.agent.AgentException may
  31. * be thrown: {@link }
  32. * org.osid.agent.AgentException#OPERATION_FAILED
  33. * OPERATION_FAILED}, {@link }
  34. * org.osid.agent.AgentException#PERMISSION_DENIED
  35. * PERMISSION_DENIED}, {@link }
  36. * org.osid.agent.AgentException#CONFIGURATION_ERROR
  37. * CONFIGURATION_ERROR}, {@link }
  38. * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  39. * {@link org.osid.agent.AgentException#NULL_ARGUMENT}
  40. * NULL_ARGUMENT}
  41. *
  42. * @access public
  43. */
  44. function updateDescription ( $description ) {
  45. throwError(new Error(AgentException::PERMISSION_DENIED(),"EveryoneGroup",true));
  46. }
  47.  
  48. /**
  49. * Add an Agent or a Group to this Group. The Agent or Group will not be
  50. * added if it already exists in the group.
  51. *
  52. * @param object Agent $memberOrGroup
  53. *
  54. * @throws object AgentException An exception with one of the
  55. * following messages defined in org.osid.agent.AgentException may
  56. * be thrown: {@link }
  57. * org.osid.agent.AgentException#OPERATION_FAILED
  58. * OPERATION_FAILED}, {@link }
  59. * org.osid.agent.AgentException#PERMISSION_DENIED
  60. * PERMISSION_DENIED}, {@link }
  61. * org.osid.agent.AgentException#CONFIGURATION_ERROR
  62. * CONFIGURATION_ERROR}, {@link }
  63. * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  64. * {@link org.osid.agent.AgentException#ALREADY_ADDED}
  65. * ALREADY_ADDED}, {@link }
  66. * org.osid.agent.AgentException#NULL_ARGUMENT NULL_ARGUMENT}
  67. *
  68. * @access public
  69. */
  70. function add ( $memberOrGroup ) {
  71. throwError(new Error(AgentException::PERMISSION_DENIED(),"EveryoneGroup",true));
  72. }
  73.  
  74. /**
  75. * An implementation-specific public method that does exactly the same as add(),
  76. * but does not insert into the database.
  77. * @access public
  78. * @param object memberOrGroup
  79. * @throws object AgentException An exception with one of the
  80. * following messages defined in org.osid.agent.AgentException may
  81. * be thrown: {@link }
  82. * org.osid.agent.AgentException#OPERATION_FAILED
  83. * OPERATION_FAILED}, {@link }
  84. * org.osid.agent.AgentException#PERMISSION_DENIED
  85. * PERMISSION_DENIED}, {@link }
  86. * org.osid.agent.AgentException#CONFIGURATION_ERROR
  87. * CONFIGURATION_ERROR}, {@link }
  88. * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  89. * {@link org.osid.agent.AgentException#ALREADY_ADDED}
  90. * ALREADY_ADDED}, {@link }
  91. * org.osid.agent.AgentException#NULL_ARGUMENT NULL_ARGUMENT}
  92. *
  93. */
  94. function attach( $memberOrGroup) {
  95. throwError(new Error(AgentException::PERMISSION_DENIED(),"EveryoneGroup",true));
  96. }
  97. /**
  98. * Remove an Agent member or a Group from this Group. If the Agent or Group
  99. * is not in this group no action is taken and no exception is thrown.
  100. *
  101. * @param object Agent $memberOrGroup
  102. *
  103. * @throws object AgentException An exception with one of the
  104. * following messages defined in org.osid.agent.AgentException may
  105. * be thrown: {@link }
  106. * org.osid.agent.AgentException#OPERATION_FAILED
  107. * OPERATION_FAILED}, {@link }
  108. * org.osid.agent.AgentException#PERMISSION_DENIED
  109. * PERMISSION_DENIED}, {@link }
  110. * org.osid.agent.AgentException#CONFIGURATION_ERROR
  111. * CONFIGURATION_ERROR}, {@link }
  112. * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  113. * {@link org.osid.agent.AgentException#UNKNOWN_ID UNKNOWN_ID},
  114. * {@link org.osid.agent.AgentException#NULL_ARGUMENT}
  115. * NULL_ARGUMENT}
  116. *
  117. * @access public
  118. */
  119. function remove ( $memberOrGroup ) {
  120. throwError(new Error(AgentException::PERMISSION_DENIED(),"EveryoneGroup",true));
  121. }
  122.  
  123. /**
  124. * Get all the Members of this group and optionally all the Members from
  125. * all subgroups. Duplicates are not returned.
  126. *
  127. * @param boolean $includeSubgroups
  128. *
  129. * @return object AgentIterator
  130. *
  131. * @throws object AgentException An exception with one of the
  132. * following messages defined in org.osid.agent.AgentException may
  133. * be thrown: {@link }
  134. * org.osid.agent.AgentException#OPERATION_FAILED
  135. * OPERATION_FAILED}, {@link }
  136. * org.osid.agent.AgentException#PERMISSION_DENIED
  137. * PERMISSION_DENIED}, {@link }
  138. * org.osid.agent.AgentException#CONFIGURATION_ERROR
  139. * CONFIGURATION_ERROR}, {@link }
  140. * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED}
  141. *
  142. * @access public
  143. */
  144. function getMembers ( $includeSubgroups ) {
  145. $agentManager = Services::getService("Agent");
  146. $agents=$agentManager->getAgents();
  147. return $agents;
  148. }
  149.  
  150. /**
  151. * Get all the Groups in this group and optionally all the subgroups in
  152. * this group. Note since Groups subclass Agents, we are returning an
  153. * AgentIterator and there is no GroupIterator.
  154. *
  155. * @param boolean $includeSubgroups
  156. *
  157. * @return object AgentIterator
  158. *
  159. * @throws object AgentException An exception with one of the
  160. * following messages defined in org.osid.agent.AgentException may
  161. * be thrown: {@link }
  162. * org.osid.agent.AgentException#OPERATION_FAILED
  163. * OPERATION_FAILED}, {@link }
  164. * org.osid.agent.AgentException#PERMISSION_DENIED
  165. * PERMISSION_DENIED}, {@link }
  166. * org.osid.agent.AgentException#CONFIGURATION_ERROR
  167. * CONFIGURATION_ERROR}, {@link }
  168. * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED}
  169. *
  170. * @access public
  171. */
  172. function getGroups ( $includeSubgroups ) {
  173. $agentManager = Services::getService("Agent");
  174. $myId = $this->getId();
  175. //Filter out ourself
  176. if ($includeSubgroups)
  177. $groupIterator = $agentManager->getGroups();
  178. else
  179. $groupIterator = $agentManager->getGroupsBySearch($null = null,
  180. new Type("Agent & Group Search",
  181. "edu.middlebury.harmoni",
  182. "RootGroups"));
  183. $groups = array();
  184. while ($groupIterator->hasNext()) {
  185. $group = $groupIterator->next();
  186. if (!$myId->isEqual($group->getId()))
  187. $groups[] = $group;
  188. }
  189. $obj = new HarmoniAgentIterator($groups);
  190. return $obj;
  191. }
  192.  
  193. /**
  194. * Return <code>true</code> if the Member or Group is in the Group,
  195. * optionally including subgroups, <code>false</code> otherwise.
  196. *
  197. * @param object Agent $memberOrGroup
  198. * @param boolean $searchSubgroups
  199. *
  200. * @return boolean
  201. *
  202. * @throws object AgentException An exception with one of the
  203. * following messages defined in org.osid.agent.AgentException may
  204. * be thrown: {@link }
  205. * org.osid.agent.AgentException#OPERATION_FAILED
  206. * OPERATION_FAILED}, {@link }
  207. * org.osid.agent.AgentException#PERMISSION_DENIED
  208. * PERMISSION_DENIED}, {@link }
  209. * org.osid.agent.AgentException#CONFIGURATION_ERROR
  210. * CONFIGURATION_ERROR}, {@link }
  211. * org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  212. * {@link org.osid.agent.AgentException#NULL_ARGUMENT}
  213. * NULL_ARGUMENT}
  214. *
  215. * @access public
  216. */
  217. function contains ( $memberOrGroup, $searchSubgroups ) {
  218. return true;
  219. }
  220. }
  221.  
  222. ?>

Documentation generated on Wed, 19 Sep 2007 10:23:04 -0400 by phpDocumentor 1.3.0RC3