Skip to content

Commit

Permalink
Merge pull request #406 from amdrade/develop
Browse files Browse the repository at this point in the history
#403 Fatal error on click New Conversation
  • Loading branch information
tobyzerner committed Jan 22, 2015
2 parents 2f4fbbf + 18a0c80 commit e4f0988
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 11 additions & 4 deletions core/controllers/ETConversationController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ETConversationController extends ETController {
public function action_index($conversationId = false, $year = false, $month = false)
{
if (!$this->allowed()) return;

// Get the conversation.
$conversation = ET::conversationModel()->getById((int)$conversationId);

Expand Down Expand Up @@ -112,7 +112,7 @@ public function action_index($conversationId = false, $year = false, $month = fa

// Make a timestamp out of this date.
else $timestamp = mktime(0, 0, 0, min($month, 12), 1, min($year, 2038));

// Find the closest post that's after this timestamp, and find its position within the conversation.
$position = ET::SQL()
->select("COUNT(postId)", "position")
Expand Down Expand Up @@ -243,7 +243,7 @@ public function action_index($conversationId = false, $year = false, $month = fa

// If the user has permission to moderate this conversation...
if ($conversation["canModerate"]) {

// Add the sticky/unsticky control.
$controls->add("sticky", "<a href='".URL("conversation/sticky/".$conversation["conversationId"]."/?token=".ET::$session->token."&return=".urlencode($this->selfURL))."' id='control-sticky'><i class='icon-pushpin'></i> <span>".T($conversation["sticky"] ? "Unsticky" : "Sticky")."</span></a>");

Expand Down Expand Up @@ -352,6 +352,13 @@ public function action_start($member = false)

// Get a list of channels so that we can check to make sure a valid channel is selected.
$channels = ET::channelModel()->get("start");

// The user not permission to star conversation.
if (!$channels){
$this->renderMessage("Error!", T("message.noPermission"));
return;
}

$channelId = $form->validPostBack("content") ? ET::$session->get("channelId") : ET::$session->get("searchChannelId");
ET::$session->store("channelId", isset($channels[$channelId]) ? $channelId : reset(array_keys($channels)));

Expand Down Expand Up @@ -1414,7 +1421,7 @@ protected function getPostForQuoting($postId, $conversationId)
$result = $result->firstRow();

// Convert spaces in the member name to non-breaking spaces.
// (Spaces aren't usually allowed in esoTalk usernames, so this is a bit of a "hack" for
// (Spaces aren't usually allowed in esoTalk usernames, so this is a bit of a "hack" for
// certain esoTalk installations that do allow them.)
$result["username"] = str_replace(" ", "\xc2\xa0", $result["username"]);

Expand Down
5 changes: 4 additions & 1 deletion core/models/ETChannelModel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public function get($permission = "view")
unset($channels[$k]);
}

if (empty($channels))
return false;

// Add user data (eg. unsubscribed) into the channel array.
$this->joinUserData($channels);

Expand Down Expand Up @@ -348,7 +351,7 @@ public function setStatus($channelIds, $memberIds, $data)
}

if (empty($inserts)) return;

ET::SQL()
->insert("member_channel")
->setMultiple($keys, $inserts)
Expand Down

0 comments on commit e4f0988

Please sign in to comment.