Ejemplo n.º 1
0
 protected function magic_get_author()
 {
     $dialogue = $this->dialogue;
     //return $dialogue->get_user_brief_details($this->_authorid);
     return dialogue_get_user_details($dialogue, $this->_authorid);
 }
Ejemplo n.º 2
0
 /**
  * Render a list of conversations in a dialogue for a particular user.
  *
  * @global global $OUTPUT
  * @global global $PAGE
  * @param mod_dialogue_conversations $conversations
  * @return string
  */
 public function conversation_listing(\mod_dialogue\conversations $conversations)
 {
     global $OUTPUT, $PAGE;
     $dialogue = $conversations->dialogue;
     $cm = $conversations->dialogue->cm;
     $list = array();
     $html = '';
     $rowsmatched = $conversations->rows_matched();
     if ($rowsmatched) {
         $list = $conversations->records();
     }
     if (empty($list)) {
         $html .= '<br/><br/>';
         $html .= $OUTPUT->notification(get_string('noconversationsfound', 'dialogue'), 'notifyproblem');
     } else {
         $today = strtotime("today");
         $yearago = strtotime("-1 year");
         $rowsreturned = count($list);
         $html .= html_writer::start_div('listing-meta');
         $html .= html_writer::tag('h6', get_string('displaying', 'dialogue'));
         $a = new stdClass();
         $a->start = $conversations->page ? $conversations->page * $conversations->limit : 1;
         $a->end = $conversations->page * $conversations->limit + $rowsreturned;
         $a->total = $rowsmatched;
         $html .= html_writer::tag('h6', get_string('listpaginationheader', 'dialogue', $a), array('class' => 'pull-right'));
         $html .= html_writer::end_div();
         $html .= html_writer::start_tag('table', array('class' => 'conversation-list table table-hover table-condensed'));
         $html .= html_writer::start_tag('tbody');
         foreach ($list as $record) {
             $datattributes = array('data-redirect' => 'conversation', 'data-action' => 'view', 'data-conversationid' => $record->conversationid);
             $html .= html_writer::start_tag('tr', $datattributes);
             $statelabel = '';
             if ($record->state == \mod_dialogue\dialogue::STATE_CLOSED) {
                 $statelabel = html_writer::tag('span', get_string('closed', 'dialogue'), array('class' => 'state-indicator state-closed'));
             }
             $html .= html_writer::tag('td', $statelabel);
             if (isset($record->unread)) {
                 $badge = '';
                 $unreadcount = $record->unread;
                 if ($unreadcount > 0) {
                     $badgeclass = 'badge label-info';
                     $badge = html_writer::span($unreadcount, $badgeclass, array('title' => get_string('numberunread', 'dialogue', $unreadcount)));
                 }
                 $html .= html_writer::tag('td', $badge);
             }
             if (isset($record->userid)) {
                 $displayuser = dialogue_get_user_details($dialogue, $record->userid);
                 $avatar = $OUTPUT->user_picture($displayuser, array('class' => 'userpicture img-rounded', 'size' => 48));
                 $html .= html_writer::tag('td', $avatar);
                 $html .= html_writer::tag('td', fullname($displayuser));
             }
             if (isset($record->subject) and isset($record->body)) {
                 $subject = empty($record->subject) ? get_string('nosubject', 'dialogue') : $record->subject;
                 $summaryline = dialogue_generate_summary_line($subject, $record->body, $record->bodyformat);
                 $html .= html_writer::start_tag('td');
                 $html .= html_writer::start_div();
                 $html .= $summaryline;
                 $participants = dialogue_get_conversation_participants($dialogue, $record->conversationid);
                 $html .= html_writer::start_div();
                 foreach ($participants as $participantid) {
                     //if ($participantid == $USER->id) {
                     //    continue;
                     //}
                     $participant = dialogue_get_user_details($dialogue, $participantid);
                     $picture = $OUTPUT->user_picture($participant, array('class' => 'userpicture img-rounded', 'size' => 16));
                     $html .= html_writer::tag('span', $picture . ' ' . fullname($participant), array('class' => 'participant'));
                 }
                 $html .= html_writer::start_div();
                 $html .= html_writer::end_div();
                 $html .= html_writer::end_tag('td');
             }
             if (isset($record->timemodified)) {
                 $datestrings = (object) dialogue_get_humanfriendly_dates($record->timemodified);
                 if ($record->timemodified >= $today) {
                     $datetime = $datestrings->timepast;
                 } else {
                     if ($record->timemodified >= $yearago) {
                         $datetime = get_string('dateshortyear', 'dialogue', $datestrings);
                     } else {
                         $datetime = get_string('datefullyear', 'dialogue', $datestrings);
                     }
                 }
                 $html .= html_writer::tag('td', $datetime, array('title' => userdate($record->timemodified)));
             }
             $viewurlparams = array('id' => $cm->id, 'conversationid' => $record->conversationid, 'action' => 'view');
             $viewlink = html_writer::link(new moodle_url('conversation.php', $viewurlparams), get_string('view'));
             $html .= html_writer::tag('td', $viewlink, array('class' => 'nonjs-control'));
             $html .= html_writer::end_tag('tr');
         }
         $html .= html_writer::end_tag('tbody');
         $html .= html_writer::end_tag('table');
         $pagination = new paging_bar($rowsmatched, $conversations->page, $conversations->limit, $PAGE->url);
         $html .= $OUTPUT->render($pagination);
     }
     return $html;
 }
 protected function load_participants()
 {
     global $DB;
     $this->_participants = array();
     // clear participants array if previous loaded
     $dialogue = $this->dialogue;
     $params = array('conversationid' => $this->_conversationid);
     $records = $DB->get_records('dialogue_participants', $params);
     foreach ($records as $record) {
         // key up on userid and fetch brief details from cache as value (cut down user record)
         //$this->_participants[$record->userid] = $dialogue->get_user_brief_details($record->userid);
         $this->_participants[$record->userid] = dialogue_get_user_details($dialogue, $record->userid);
     }
     return $this->_participants;
 }