getUserName() public static method

Returns the real name, if available, of a user.
public static getUserName ( $uid )
Ejemplo n.º 1
0
 public function html($active = true)
 {
     if (!$this->_event) {
         echo '<h3>' . _("Event not found") . '</h3>';
         exit;
     }
     if (is_string($this->_event)) {
         echo '<h3>' . $this->_event . '</h3>';
         exit;
     }
     global $conf, $prefs;
     $this->_event->loadHistory();
     $creatorId = $this->_event->creator;
     $description = $this->_event->description;
     $location = $this->_event->location;
     $eventurl = $this->_event->url;
     $private = $this->_event->isPrivate();
     $owner = Kronolith::getUserName($creatorId);
     $status = Kronolith::statusToString($this->_event->status);
     $attendees = $this->_event->attendees;
     $resources = $this->_event->getResources();
     if ($datetime = Horde_Util::getFormData('datetime')) {
         $datetime = new Horde_Date($datetime);
         $month = $datetime->month;
         $year = $datetime->year;
     } else {
         $month = (int) Horde_Util::getFormData('month', date('n'));
         $year = (int) Horde_Util::getFormData('year', date('Y'));
     }
     $dateFormat = $prefs->getValue('date_format');
     $timeFormat = $prefs->getValue('twentyFour') ? 'G:i' : 'g:ia';
     // Tags
     $tags = implode(', ', $this->_event->tags);
     echo '<div id="Event"' . ($active ? '' : ' style="display:none"') . '>';
     require KRONOLITH_TEMPLATES . '/view/view.inc';
     echo '</div>';
     if ($active && $GLOBALS['browser']->hasFeature('dom')) {
         /* We check for read permissions, because we can always save a
          * copy if we can read the event. */
         if ($this->_event->hasPermission(Horde_Perms::READ) && Kronolith::getDefaultCalendar(Horde_Perms::EDIT)) {
             $edit = new Kronolith_View_EditEvent($this->_event);
             $edit->html(false);
         }
         if ($this->_event->hasPermission(Horde_Perms::DELETE)) {
             $delete = new Kronolith_View_DeleteEvent($this->_event);
             $delete->html(false);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @return string  A tooltip for quick descriptions of this event.
  */
 public function getTooltip()
 {
     $tooltip = $this->getTimeRange() . "\n" . sprintf(_("Owner: %s"), $this->creator == $GLOBALS['registry']->getAuth() ? _("Me") : Kronolith::getUserName($this->creator));
     if (!$this->isPrivate()) {
         if ($this->location) {
             $tooltip .= "\n" . _("Location") . ': ' . $this->location;
         }
         if ($this->description) {
             $tooltip .= "\n\n" . Horde_String::wrap($this->description);
         }
     }
     return $tooltip;
 }
Ejemplo n.º 3
0
 /**
  * Prepares this event to be saved to the backend.
  */
 public function toKolab()
 {
     $event = array();
     $event['uid'] = $this->uid;
     $event['summary'] = $this->title;
     $event['body'] = $this->description;
     $event['location'] = $this->location;
     $event['sensitivity'] = $this->private ? 'private' : 'public';
     // Only set organizer if this is a new event
     if ($this->_id == null) {
         $organizer = array('display-name' => Kronolith::getUserName($this->creator), 'smtp-address' => Kronolith::getUserEmail($this->creator));
         $event['organizer'] = $organizer;
     }
     if ($this->alarm != 0) {
         $event['alarm'] = $this->alarm;
     }
     if ($this->methods !== null) {
         $event['horde-alarm-methods'] = serialize($this->methods);
     }
     $event['start-date'] = $this->start->toDateTime();
     $event['end-date'] = $this->end->toDateTime();
     $event['_is_all_day'] = $this->isAllDay();
     switch ($this->status) {
         case Kronolith::STATUS_FREE:
         case Kronolith::STATUS_CANCELLED:
             $event['show-time-as'] = 'free';
             break;
         case Kronolith::STATUS_TENTATIVE:
             $event['show-time-as'] = 'tentative';
             break;
             // No mapping for outofoffice
         // No mapping for outofoffice
         case Kronolith::STATUS_CONFIRMED:
         default:
             $event['show-time-as'] = 'busy';
     }
     // Recurrence
     if ($this->recurs()) {
         $event['recurrence'] = $this->recurrence->toKolab();
     }
     // Attendees
     $event['attendee'] = array();
     foreach ($this->attendees as $attendee) {
         $new_attendee = array();
         $new_attendee['display-name'] = $attendee->name;
         // Attendee without an email address
         if (strpos($attendee->email, '@') === false) {
             $new_attendee['smtp-address'] = '';
         } else {
             $new_attendee['smtp-address'] = $attendee->email;
         }
         switch ($attendee->role) {
             case Kronolith::PART_OPTIONAL:
                 $new_attendee['role'] = 'optional';
                 break;
             case Kronolith::PART_NONE:
                 $new_attendee['role'] = 'resource';
                 break;
             case Kronolith::PART_REQUIRED:
             default:
                 $new_attendee['role'] = 'required';
                 break;
         }
         $new_attendee['request-response'] = 'false';
         switch ($attendee->response) {
             case Kronolith::RESPONSE_ACCEPTED:
                 $new_attendee['status'] = 'accepted';
                 break;
             case Kronolith::RESPONSE_DECLINED:
                 $new_attendee['status'] = 'declined';
                 break;
             case Kronolith::RESPONSE_TENTATIVE:
                 $new_attendee['status'] = 'tentative';
                 break;
             case Kronolith::RESPONSE_NONE:
             default:
                 $new_attendee['status'] = 'none';
                 break;
         }
         $event['attendee'][] = $new_attendee;
     }
     // Tags
     if (!is_array($this->tags)) {
         $this->tags = Kronolith::getTagger()->split($this->tags);
     }
     if ($this->tags) {
         $event['categories'] = $this->tags;
     }
     return $event;
 }