/**
  * Constructor
  * 
  * @param object HierarchicalRadioMatrix $property
  * @param object Agent $agent
  * @return void
  * @access public
  * @since 11/14/07
  */
 public function __construct(HierarchicalRadioMatrix $property, Agent $agent)
 {
     $this->property = $property;
     $this->agent = $agent;
     $this->agentId = $agent->getId();
     $this->siteImplicitRole = new NoAccess_SegueRole();
     $this->siteImplicitRoleMessage = '';
 }
Пример #2
0
 /**
  * Return <code>true</code> if the Member or Group is in the Group,
  * optionally including subgroups, <code>false</code> otherwise.
  * 
  * @param object Agent $memberOrGroup
  * @param boolean $searchSubgroups
  *	
  * @return boolean
  * 
  * @throws object AgentException An exception with one of the
  *		   following messages defined in org.osid.agent.AgentException may
  *		   be thrown:  {@link
  *		   org.osid.agent.AgentException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.agent.AgentException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.agent.AgentException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  *		   {@link org.osid.agent.AgentException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}
  * 
  * @access public
  */
 function contains(Agent $memberOrGroup, $searchSubgroups)
 {
     // we are going to ignore the Everyone group and the Anonymous agent
     // otherwise they are in the group
     $ids = Services::getService("Id");
     $ignore = array("edu.middlebury.agents.users", "edu.middlebury.agents.everyone", "edu.middlebury.agents.anonymous");
     foreach ($igonre as $id) {
         $rId = $ids->getId($id);
         if ($rId->isEqual($memberOrGroup->getId())) {
             return false;
         }
     }
     return true;
 }
Пример #3
0
    $property_id = Property::getCurrent()->getId();
    foreach ($agents as $agent_id) {
        try {
            $agent = new Agent($agent_id);
        } catch (Exception $ex) {
        }
        if ($agent != null) {
            ?>

		<div class="box general">

			<div class="agent card">

				<div class="photo">
					<?php 
            echo get_the_post_thumbnail($agent->getId(), array(70, 70));
            ?>
				</div>
				
				<span class="call-to-action"><?php 
            echo __('Contact the agent', THEME_NAME);
            ?>
</span>
				<h5 class="name"><?php 
            echo $agent->getName();
            ?>
</h5>

				<div class="contact-info">
					<?php 
            if ($agent->hasPhone()) {
 /**
  * Add a slot to a users array for an agent.
  * 
  * @param Agent $agent
  * @param Slot $slot
  * @return int
  */
 protected function addSlotForAgent(Agent $agent, Slot $slot)
 {
     $agentIdString = $agent->getId()->getIdString();
     if (!isset($this->users[$agentIdString])) {
         $email = $this->getAgentEmail($agent);
         // Don't include people without email addresses
         if (empty($email)) {
             return 0;
         }
         $this->users[$agentIdString] = array('name' => $agent->getDisplayName(), 'email' => $email, 'slots' => array());
     }
     $this->users[$agentIdString]['slots'][] = $slot;
     return 1;
 }
Пример #5
0
 /**
  * Compare an Agent to an Agent XML description and determine if the two match.
  *
  * The current implementation of this method is kind of goofy. It should be
  * re-worked to either use a more reliable comparison method or be made configurable
  * for different comparrison methods.
  * 
  * @param object Agent $agent
  * @param object DOMElement $element
  * @return boolean
  * @access protected
  * @since 1/28/08
  */
 protected function agentMatches(Agent $agent, DOMElement $element)
 {
     // check some system-ids first as these will not have meaningful properties
     // to compare and their IDs are hard coded into the system.
     $sourceId = $element->getAttribute('id');
     $systemIds = array("edu.middlebury.agents.everyone", "edu.middlebury.institute", "1", "edu.middlebury.agents.anonymous");
     if (in_array($sourceId, $systemIds)) {
         if ($sourceId == $agent->getId()->getIdString()) {
             return true;
         } else {
             return false;
         }
     }
     // Compare agent properties to make sure that the agent and the DOMElement
     // are representing the same user.
     $xmlPropertiesToCheck = array('email', 'username');
     $agentPropertiesToCheck = array('email', 'username');
     // How man properties must match
     $threshold = 1;
     $matches = 0;
     $xmlValues = array();
     foreach ($xmlPropertiesToCheck as $property) {
         // 			printpre(htmlentities($this->doc->saveXMLWithWhitespace($element)));
         $valueElements = $this->xpath->evaluate('./property[key = \'' . $property . '\']/string', $element);
         if ($valueElements->length) {
             $xmlValues[] = $this->getStringValue($valueElements->item(0));
         }
         // 			throw new Exception('test error');
     }
     $agentPropertiesIterator = $agent->getProperties();
     while ($agentPropertiesIterator->hasNext()) {
         $properties = $agentPropertiesIterator->next();
         // 			printpre($properties->getKeys());
         foreach ($agentPropertiesToCheck as $key) {
             try {
                 $value = $properties->getProperty($key);
                 // 					printpre($value);
                 if (!is_null($value) && in_array($value, $xmlValues)) {
                     $matches++;
                 }
             } catch (UnknownKeyException $e) {
             }
         }
     }
     if ($matches >= $threshold) {
         return true;
     } else {
         return false;
     }
 }
Пример #6
0
 /**
  * Constructor
  * 
  * @param object Agent $agent
  * @return void
  * @access public
  * @since 11/27/07
  */
 public function __construct(Agent $agent)
 {
     $this->id = $agent->getId();
     $this->name = $agent->getDisplayName();
     try {
         $propertiesIterator = $agent->getProperties();
         while ($propertiesIterator->hasNext()) {
             $properties = $propertiesIterator->next();
             try {
                 if ($properties->getProperty('email')) {
                     $this->email = $properties->getProperty('email');
                     break;
                 }
             } catch (Exception $e) {
             }
         }
     } catch (Exception $e) {
     }
 }
Пример #7
0
 /**
  * Return <code>true</code> if the Member or Group is in the Group,
  * optionally including subgroups, <code>false</code> otherwise.
  * 
  * @param object Agent $memberOrGroup
  * @param boolean $searchSubgroups
  *	
  * @return boolean
  * 
  * @throws object AgentException An exception with one of the
  *		   following messages defined in org.osid.agent.AgentException may
  *		   be thrown:  {@link
  *		   org.osid.agent.AgentException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.agent.AgentException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.agent.AgentException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  *		   {@link org.osid.agent.AgentException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}
  * 
  * @access public
  */
 function contains(Agent $memberOrGroup, $searchSubgroups)
 {
     ArgumentValidator::validate($searchSubgroups, BooleanValidatorRule::getRule(), true);
     // ** end of parameter validation
     $id = $memberOrGroup->getId();
     $children = $this->getMembers($searchSubgroups);
     while ($children->hasNext()) {
         if ($id->isEqual($children->next()->getId())) {
             return true;
         }
     }
     $children = $this->getGroups($searchSubgroups);
     while ($children->hasNext()) {
         if ($id->isEqual($children->next()->getId())) {
             return true;
         }
     }
     return FALSE;
 }
Пример #8
0
 /**
  * Declares an association between this object and a Agent object.
  *
  * @param      Agent $v
  * @return     void
  * @throws     PropelException
  */
 public function setAgent($v)
 {
     if ($v === null) {
         $this->setAgentId(NULL);
     } else {
         $this->setAgentId($v->getId());
     }
     $this->aAgent = $v;
 }
Пример #9
0
 /**
  * Return <code>true</code> if the Member or Group is in the Group,
  * optionally including subgroups, <code>false</code> otherwise.
  * 
  * @param object Agent $memberOrGroup
  * @param boolean $searchSubgroups
  *	
  * @return boolean
  * 
  * @throws object AgentException An exception with one of the
  *		   following messages defined in org.osid.agent.AgentException may
  *		   be thrown:  {@link
  *		   org.osid.agent.AgentException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.agent.AgentException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.agent.AgentException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.agent.AgentException#UNIMPLEMENTED UNIMPLEMENTED},
  *		   {@link org.osid.agent.AgentException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}
  * 
  * @access public
  */
 function contains(Agent $memberOrGroup, $searchSubgroups)
 {
     $id = $memberOrGroup->getId();
     $myMembers = $this->getMembers(false);
     while ($myMembers->hasNext()) {
         if ($id->isEqual($myMembers->next()->getId())) {
             return true;
         }
     }
     $myGroups = $this->getGroups(false);
     while ($myGroups->hasNext()) {
         if ($id->isEqual($myGroups->next()->getId())) {
             return true;
         }
     }
     if ($searchSubgroups) {
         $myGroups = $this->getGroups(true);
         while ($myGroups->hasNext()) {
             if ($myGroups->next()->contains($memberOrGroup, true)) {
                 return true;
             }
         }
     }
     return false;
 }
Пример #10
0
 /**
  * Print out an agent or group
  * 
  * @param object Agent $agent
  * @param optional boolean $includeChildren Default is false
  * @return void
  * @access protected
  * @since 10/21/08
  */
 protected function printAgent(Agent $agent, $includeChildren = false)
 {
     if ($agent->isAgent()) {
         print "\n\t<agent";
     } else {
         print "\n\t<group";
     }
     print " id=\"" . $agent->getId()->getIdString() . "\">";
     print "\n\t\t<displayName><![CDATA[" . $agent->getDisplayName() . "]]></displayName>";
     $type = $agent->getType();
     print "\n\t\t<type>";
     print "\n\t\t\t<domain><![CDATA[" . $type->getDomain() . "]]></domain>";
     print "\n\t\t\t<authority><![CDATA[" . $type->getAuthority() . "]]></authority>";
     print "\n\t\t\t<keyword><![CDATA[" . $type->getKeyword() . "]]></keyword>";
     print "\n\t\t\t<description><![CDATA[" . $type->getDescription() . "]]></description>";
     print "\n\t\t</type>";
     try {
         print "\n\t\t<email>" . $this->getAgentEmail($agent) . "</email>";
     } catch (OperationFailedException $e) {
     }
     if ($agent->isAgent()) {
         print "\n\t</agent>";
     } else {
         print "\n\t\t<description><![CDATA[" . $agent->getDescription() . "]]></description>";
         $authZ = Services::getService("AuthZ");
         $idMgr = Services::getService("Id");
         if ($includeChildren) {
             $canView = $authZ->isUserAuthorized($idMgr->getId("edu.middlebury.authorization.view"), $agent->getId());
             if ($agent->getId()->isEqual(new HarmoniId('edu.middlebury.agents.everyone'))) {
                 $canView = false;
             }
             // 					$canView = true;
             print "\n\t\t<groups>";
             if ($canView) {
                 $names = array();
                 $strings = array();
                 $children = $agent->getGroups(false);
                 while ($children->hasNext()) {
                     $child = $children->next();
                     ob_start();
                     $this->printAgent($child);
                     $names[] = $child->getDisplayName();
                     $strings[] = ob_get_clean();
                 }
                 array_multisort($names, array_keys($strings), $strings);
                 print implode('', $strings);
             } else {
                 print "\n\t\t\t\t<notice>" . _("Unauthorized to view group membership.") . "</notice>";
             }
             print "\n\t\t</groups>";
             print "\n\t\t<members>";
             if ($canView) {
                 $names = array();
                 $strings = array();
                 $children = $agent->getMembers(false);
                 while ($children->hasNext()) {
                     $child = $children->next();
                     ob_start();
                     $this->printAgent($child);
                     $names[] = $child->getDisplayName();
                     $strings[] = ob_get_clean();
                 }
                 array_multisort($names, array_keys($strings), $strings);
                 print implode('', $strings);
             } else {
                 print "\n\t\t\t\t<notice>" . _("Unauthorized to view group membership.") . "</notice>";
             }
             print "\n\t\t</members>";
         }
         print "\n\t</group>";
     }
 }
 /**
  * Answer the URL to denie an agent
  * 
  * @param Agent $agent
  * @return string
  * @access protected
  * @since 2/19/09
  */
 protected function getDenialUrl(Agent $agent)
 {
     return $this->getPluginActionUrl('deny', array('agent_id' => $agent->getId()->getIdString()));
 }
Пример #12
0
 /**
  * Add a slot to a users array for an agent.
  * 
  * @param Agent $agent
  * @param Slot $slot
  * @return int
  */
 protected function addSlotForAgent(Agent $agent, Slot $slot)
 {
     $agentIdString = $agent->getId()->getIdString();
     $email = $this->getAgentEmail($agent);
     // Don't include people without email addresses
     if (empty($email)) {
         return 0;
     }
     $this->slots[$slot->getShortname()]['users'][$email] = array('name' => $agent->getDisplayName(), 'email' => $email);
     ksort($this->slots[$slot->getShortname()]['users']);
     return 1;
 }