Skip to content

Commit

Permalink
Syncing files from cloud/master to master
Browse files Browse the repository at this point in the history
  • Loading branch information
maneeshchiba-hl committed Apr 17, 2024
1 parent 9ee55ad commit 5b1704d
Show file tree
Hide file tree
Showing 141 changed files with 3,285 additions and 1,802 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Expand Up @@ -59,6 +59,7 @@
"plugins/ImageRequired": true,
"plugins/Images": true,
"plugins/IpsumInserter": true,
"plugins/Jira": true,
"plugins/KeywordBlocker": true,
"plugins/LinkedIn": true,
"plugins/MailChimpPush": true,
Expand Down Expand Up @@ -150,7 +151,7 @@
"plugins/vfoptions": true,
"plugins/vanilla-ai": true,
"plugins/webhooks": true,
"plugins/zapier": true,
"plugins/zapier": true
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand Down
122 changes: 66 additions & 56 deletions applications/conversations/controllers/class.messagescontroller.php
Expand Up @@ -51,13 +51,14 @@ public function initialize()
/**
* Start a new conversation.
*
* @param string $recipient Username of the recipient.
* @param string $subject Subject of the message.
* @param string|null $content initial content.
* @since 2.0.0
* @access public
*
* @param string $recipient Username of the recipient.
* @param string $subject Subject of the message.
*/
public function add($recipient = "", $subject = "")
public function add($recipient = "", $subject = "", $content = null)
{
$this->permission("Conversations.Conversations.Add");

Expand All @@ -66,11 +67,16 @@ public function add($recipient = "", $subject = "")
if (!empty($optionalRedirection)) {
$this->redirect($optionalRedirection);
$this->render("blank", "utility", "dashboard");

return;
}

$this->Form->setModel($this->ConversationModel);

if ($content !== null) {
$this->Form->setValue("Body", $content);
}

// Detect our recipient limit.
$maxRecipients = ConversationModel::getMaxRecipients();

Expand Down Expand Up @@ -113,6 +119,7 @@ public function add($recipient = "", $subject = "")
if (!empty($this->Form->getFormValue("To"))) {
$this->Form->setFormValue("RecipientUserID", $recipientUserIDs);
}

$conversationID = $this->Form->save();
if ($conversationID !== false) {
$target = $this->Form->getFormValue("Target", "messages/" . $conversationID);
Expand Down Expand Up @@ -210,8 +217,10 @@ protected function tryGetRedirectUrl(): ?string
"ssoID" => rawurlencode($userSsoID),
];
$newUrl = formatString($redirectUrl, $urlReplacements);

return $newUrl;
}

return null;
}

Expand All @@ -227,16 +236,17 @@ private function redirect(string $url): void
} else {
$this->setRedirectTo($url, false);
}

return;
}

/**
* Add a message to a conversation.
*
* @param int|string $conversationID Unique ID of the conversation.
* @since 2.0.0
* @access public
*
* @param int|string $conversationID Unique ID of the conversation.
*/
public function addMessage($conversationID = "")
{
Expand Down Expand Up @@ -303,58 +313,6 @@ public function addMessage($conversationID = "")
$this->render();
}

/**
* Show all conversations for the currently authenticated user.
*
* @since 2.0.0
* @access public
*
* @param string $page The page number argument.
*/
public function all($page = "")
{
$this->title(t("Inbox"));
Gdn_Theme::section("ConversationList");

[$offset, $limit] = offsetLimit($page, c("Conversations.Conversations.PerPage", 50));

// Calculate offset
$this->Offset = $offset;

$userID = $this->Request->get("userid", Gdn::session()->UserID);
if ($userID != Gdn::session()->UserID) {
if (!c("Conversations.Moderation.Allow", false)) {
throw permissionException();
}
$this->permission("Conversations.Moderation.Manage");
}

$conversations = $this->ConversationModel->get2($userID, $offset, $limit)->resultArray();

$this->EventArguments["Conversations"] = &$conversations;
$this->fireEvent("beforeMessagesAll");

$this->setData("Conversations", $conversations);

// Build the pager
if (!$this->data("_PagerUrl")) {
$this->setData("_PagerUrl", "messages/all/{Page}");
}
$this->setData("_Page", $page);
$this->setData("_Limit", $limit);
$this->setData("_CurrentRecords", count($conversations));

// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL && $this->_DeliveryMethod == DELIVERY_METHOD_XHTML) {
$this->setJson("LessRow", $this->Pager->toString("less"));
$this->setJson("MoreRow", $this->Pager->toString("more"));
$this->View = "conversations";
}

// Build and display page.
$this->render();
}

/**
* Clear the message history for a specific conversation & user.
*
Expand Down Expand Up @@ -672,4 +630,56 @@ public function inbox($page = "")
$this->View = "All";
$this->all($page);
}

/**
* Show all conversations for the currently authenticated user.
*
* @param string $page The page number argument.
* @since 2.0.0
* @access public
*
*/
public function all($page = "")
{
$this->title(t("Inbox"));
Gdn_Theme::section("ConversationList");

[$offset, $limit] = offsetLimit($page, c("Conversations.Conversations.PerPage", 50));

// Calculate offset
$this->Offset = $offset;

$userID = $this->Request->get("userid", Gdn::session()->UserID);
if ($userID != Gdn::session()->UserID) {
if (!c("Conversations.Moderation.Allow", false)) {
throw permissionException();
}
$this->permission("Conversations.Moderation.Manage");
}

$conversations = $this->ConversationModel->get2($userID, $offset, $limit)->resultArray();

$this->EventArguments["Conversations"] = &$conversations;
$this->fireEvent("beforeMessagesAll");

$this->setData("Conversations", $conversations);

// Build the pager
if (!$this->data("_PagerUrl")) {
$this->setData("_PagerUrl", "messages/all/{Page}");
}
$this->setData("_Page", $page);
$this->setData("_Limit", $limit);
$this->setData("_CurrentRecords", count($conversations));

// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL && $this->_DeliveryMethod == DELIVERY_METHOD_XHTML) {
$this->setJson("LessRow", $this->Pager->toString("less"));
$this->setJson("MoreRow", $this->Pager->toString("more"));
$this->View = "conversations";
}

// Build and display page.
$this->render();
}
}

0 comments on commit 5b1704d

Please sign in to comment.