Пример #1
0
 public function show($user_id = null)
 {
     if ($user_id == null) {
         $user_id = $this->session->userdata('user_id');
     }
     $profileData = $this->User->get_user_by_id($user_id);
     $messages = $this->Message->get_all_by_user_id($user_id);
     $messageThread = new MessageList();
     foreach ($messages as $message) {
         $messageThread->message_ids[] = $message['id'];
         $message[$message['id']] = new UserMessage($message);
         $messageThread->addMessage($message[$message['id']]);
     }
     if ($messageThread->message_ids != null) {
         $comments = $this->Comment->get_all_by_message_ids($messageThread->message_ids);
         // var_dump($messageThread->message_ids);
         // var_dump($comments);
         foreach ($comments as $comment) {
             $c[$comment['id']] = new UserComment($comment);
             $message[$comment['message_id']]->addComment($c[$comment['id']]);
         }
     }
     $viewData['messageThread'] = $messageThread;
     $viewData['profileData'] = $profileData;
     $viewData['sessionToken'] = array('user_id' => $this->session->userdata('user_id'), 'level' => $this->session->userdata('level'));
     $viewData['errors'] = $this->session->flashdata('errors');
     // error_log('this is the vewData =>' . implode($viewData) . ' and profileData =>' . implode(', ', $profileData));
     $this->load->view('users/show', $viewData);
 }
Пример #2
0
/**
 * Get list of Messages in user's mailbox.
 *
 * @param  Google_Service_Gmail $service Authorized Gmail API instance.
 * @param  string $userId User's email address. The special value 'me'
 * can be used to indicate the authenticated user.
 * @return array Array of Messages.
 */
function message_list($service, $maxResults)
{
    $user = '******';
    $pageToken = NULL;
    $messages = array();
    $opt_param = array();
    $opt_param['includeSpamTrash'] = false;
    // $opt_param['maxResults'] = $maxResults;
    $opt_param['labelIds'] = 'INBOX';
    $messagesResponse = $service->users_messages->listUsersMessages($user, $opt_param);
    if ($messagesResponse->getMessages()) {
        $messageList = new MessageList();
        foreach ($messagesResponse->getMessages() as $message) {
            $messageList->addMessage(new MessageListItem($message->getThreadId(), $message->getId()));
        }
        return $messageList;
    }
}