/** * Read the next message. * Override the parent method: we don't want to increment the byte offset * * @return string Message (raw) * @throws \Kafka\Exception when the message cannot be read from the stream buffer */ protected function getMessage() { $msg = parent::getMessage(); // do not increment the offset for internal iterators $this->validByteCount = 0; return $msg; }
function validate_ownership(Repository $repo, Contact $user, Contact $partner = null, MessageSet $ms = null) { $xpartner = $partner && $partner->seascode_username; if (!str_starts_with($this->base, "~") || !$user->seascode_username) { return -1; } if (preg_match('_\\A~(?:' . preg_quote($user->seascode_username) . ($partner ? "|" . preg_quote($partner->seascode_username) : "") . ')/_i', $this->base)) { return 1; } if ($ms) { $ms->set_error_html("ownership", $partner ? "This repository belongs to neither you nor your partner." : "This repository does not belong to you."); } return 0; }
while ($user = $userLookup->fetch_assoc()) { $commentResponse->username = $user['username']; } //if the response has been viewed add it to the unread MessageSet if ($reply['response_viewed'] == 0) { $unreadComments->addMessage($commentResponse); } else { $readComments->addMessage($commentResponse); } } //replies that have already been read } //create a set for unread messages $unreadMessages = new MessageSet(); //create a set for red messages $readMessages = new MessageSet(); $inbox = $connection->query("SELECT * FROM messages M1 WHERE id=(SELECT MAX(id) FROM messages WHERE from_user=M1.from_user) AND to_user={$user_id} ORDER BY id DESC"); while ($row = $inbox->fetch_assoc()) { $newMessage = new InboxMessage(); $newMessage->comment = $row['message']; $newMessage->date = $row['date']; $newMessage->is_comment = 0; $newMessage->user_id = $row['from_user']; $newMessage->id = $row['id']; //get the username from ID $userLookup = $connection->query("SELECT username FROM users WHERE id={$newMessage->user_id}"); while ($user = $userLookup->fetch_assoc()) { $newMessage->username = $user['username']; } //if the message has been viewed add it to the 'unread' set if ($row['viewed'] == 0) {
function validate_working(MessageSet $ms = null) { $status = RepositorySite::run_ls_remote($this->ssh_url(), $output); $answer = join("\n", $output); if ($status == 0 && $ms) { $ms->set_error_html("working", $this->expand_message("repo_unreadable", $ms->user)); } if ($status > 0 && !preg_match(',^[0-9a-f]{40}\\s+refs/heads/master,m', $answer)) { if ($ms) { $ms->set_error_html("working", $this->expand_message("repo_nomaster", $ms->user)); } $status = 0; } return $status; }
<?php session_start(); //get all the comments include "includes/connection.php"; //set the current page as the 'recent_article' variable //so if someone logs in from this page they get sent back to this page $previous_page = $_SESSION['recent_page']; $actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $_SESSION['recent_page'] = $actual_link; //first step, get a list of replies to the user's comments $user_id = $_SESSION['user_id']; //create a message set for undread comment responses $unreadComments = new MessageSet(); //create a message set for read comments $readComments = new MessageSet(); //get all comments made by user $comments = $connection->query("SELECT * FROM comments WHERE user_id={$user_id}"); while ($row = $comments->fetch_assoc()) { //get all the replies to the user's comments $commentID = $row['id']; $replies = $connection->query("SELECT * FROM comments WHERE response_id={$commentID} AND user_id!={$user_id}"); while ($reply = $replies->fetch_assoc()) { //create an inbox object $commentResponse = new InboxMessage(); $commentResponse->id = $reply['id']; $commentResponse->comment = $reply['comment']; $commentResponse->user_id = $reply['user_id']; $commentResponse->date = $reply['date']; $commentResponse->article_path = $reply['article_path']; $commentResponse->is_comment = 1;