public function __get($property) { if (property_exists($this, $property)) { if ($property == "displayname") { if ($this->isDefault) { if ($this->owner == $GLOBALS['obm']['uid'] || $this->name == 'public_contacts') { return $GLOBALS["l_{$this->name}"]; } else { $owner = get_entity_info($this->owner, 'user'); return $GLOBALS["l_{$this->name}"]." ($owner[label])"; } } else { if ($this->owner == $GLOBALS['obm']['uid'] || $this->name == 'public_contacts') { return $this->name; } else { $owner = get_entity_info($this->owner, 'user'); return $this->name." ($owner[label])"; } } } else { return $this->$property; } } return; }
/** * Format entities email. * * @param mixed $mail Brut email(s) (if not set use id and entity to retrieve * all informations including domain name) * @param mixed $domain current domain name (if not set use obm['domain_name']) * @param mixed $first_only return only the first entity email if true, all if * false * @param string $separator if null return an array, if not null return a * string containing all email, separated by '$separator' * @param mixed $id Entity id, needed only if $mail is null * @param string $entity Entity kind, needed only if $mail is null * @access public * @return array | string */ protected function getEntityEmail($mail=null, $domain=null, $first_only=true, $separator=', ', $id=null, $entity='user') { global $obm; if ($mail === null) { if ($id === null) { $id = $obm['uid']; } $e = get_entity_info($id, $entity); $mail = $e['email']; $domain = $e['domain_name']; } if ($domain === null && $obm['domain_global'] === false) { $domain = $obm['domain_name']; } $mail = explode("\r\n",$mail); if ($first_only && count($mail) > 1) { $mail = array(array_shift($mail)); } $emails = array(); foreach ($mail as $key => $email) { if (strpos($email,'@') === false && !empty($email)) { $emails[] = $email.'@'.$domain; } elseif (!empty($email)) { $emails[] = $email; } } if ($separator !== null) { return implode($separator,$emails); } else { return $emails; } }
function writeAttendee($name, $value) { if (key_exists('state', $value)) { $value = array($value); } foreach ($value as $attendee) { $params = array(); $value = ''; if($attendee['state']) { $partstat = $attendee['state']; } else { $partstat = 'NEEDS-ACTION'; } switch($attendee['entity']) { case 'user' : if(!$this->attendees['user'][$attendee['id']]) { $this->attendees['user'][$attendee['id']] = get_user_info($attendee['id']); } $userInfo = $this->attendees['user'][$attendee['id']]; if(!$userInfo['email']) $userInfo['email'] = $this->noreply ; $value = 'MAILTO:'.$this->parseText($userInfo['email']); $params[] = 'CUTYPE=INDIVIDUAL'; $params[] = 'CN='.$this->parseText($userInfo['firstname'].' '.$userInfo['lastname']); $params[] = 'PARTSTAT='.$partstat; $params[] = $this->parseName('x-obm-id').'='.$attendee['id']; break; case 'resource' : if(!$this->attendees['resource'][$attendee['id']]) { $this->attendees['resource'][$attendee['id']] = get_entity_info($attendee['id'],'resource'); } $resourceInfo = $this->attendees['resource'][$attendee['id']]; $value = 'MAILTO:'.$this->parseText($this->noreply ); $params[] = 'CUTYPE=RESOURCE'; $params[] = 'CN='.$this->parseText($resourceInfo['label']); $params[] = 'PARTSTAT='.$partstat; $params[] = $this->parseName('x-obm-id').'='.$attendee['id']; break; case 'group' : if(!$this->attendees['group'][$attendee['id']]) { $this->attendees['group'][$attendee['id']] = get_group_info($attendee ['id']); } $groupInfo = $this->attendees['contact'][$attendee['id']]; if(!$groupInfo['email']) $groupInfo['email'] = $this->noreply ; $value = 'MAILTO:'.$this->parseText($groupInfo['email']); $params[] = 'CUTYPE=GROUP'; $params[] = 'CN='.$this->parseText($groupInfo['name']); $params[] = 'PARTSTAT='.$partstat; $params[] = $this->parseName('x-obm-id').'='.$attendee['id']; break; case 'task' : $mail = 'MAILTO:'.$this->parseText($this->noreply ); $params[] = 'CUTYPE=X-TASK'; $params[] = 'PARTSTAT=ACCEPTED'; $params[] = $this->parseName('x-obm-id').'='.$attendee['id']; break; case 'contact' : if(!$this->attendees['contact'][$attendee['id']]) { $this->attendees['contact'][$attendee['id']] = get_contact_from_ids(array($attendee['id'])); } $contactInfo = $this->attendees['contact'][$attendee['id']]; $params[] = 'CUTYPE=INDIVIDUAL'; if(!$contactInfo['entity'][ $attendee['id'] ]['email_address'])$contactInfo['entity'][ $attendee['id'] ]['email_address'] = $this->noreply ; $value = 'MAILTO:'.$this->parseText($contactInfo['entity'][ $attendee['id'] ]['email_address']); break; default: // Skip $params[]'less entities continue 2; // This 'continue' is catched by switch(). With '2' we reach our foreach(). } $property = $this->parseProperty($this->parseName($name).';'.implode(';',$params).':'.$value); $this->buffer .= $property."\r\n"; } }
protected function contactUpdate($event, $oldEvent, $contacts) { $this->from = $this->getSender(); $recips = array(); foreach($contacts as $contact) { $contact_info = get_entity_info($contact->id, 'contact'); $label = $contact_info['label']; $email = $contact_info['email']; if (trim($email) != "") { array_push($recips, array($email, $label)); } } $this->recipients = $recips; $this->subject = __('Event updated by %sender%: %title%', array('%sender%'=>$event->owner->label, '%title%' => $event->title)); $this->body = array_merge($this->extractEventDetails($event, $this->from), $this->extractEventDetails($oldEvent, $this->from, 'old_')); $this->attachIcs($event, "request", true); }
/** * addResource * * @param string $property * @param string $value * @access public * @return void */ public function addResource($property, $value) { $entity = get_entity_info($value, $property); $res = new OBM_EventAttendee($value, null, $entity["label"]); array_push($this->$property, $res); }