Commit 92608fd3 authored by Armando Lüscher's avatar Armando Lüscher

Add clear() method to reset internal conversation variables when cancelling a conversation.

parent 88555856
...@@ -81,16 +81,27 @@ class Conversation ...@@ -81,16 +81,27 @@ class Conversation
} }
/** /**
* Load the conversation from the database * Clear all conversation variables.
* *
* @return bool * @return bool Always return true, to allow this method in an if statement.
*/ */
protected function load() protected function clear()
{ {
$this->conversation = null; $this->conversation = null;
$this->protected_notes = null; $this->protected_notes = null;
$this->notes = null; $this->notes = null;
return true;
}
/**
* Load the conversation from the database
*
* @return bool
*/
protected function load()
{
//Select an active conversation //Select an active conversation
$conversation = ConversationDB::selectConversation($this->user_id, $this->chat_id, 1); $conversation = ConversationDB::selectConversation($this->user_id, $this->chat_id, 1);
if (isset($conversation[0])) { if (isset($conversation[0])) {
...@@ -102,7 +113,6 @@ class Conversation ...@@ -102,7 +113,6 @@ class Conversation
if ($this->command !== $this->conversation['command']) { if ($this->command !== $this->conversation['command']) {
$this->cancel(); $this->cancel();
$this->conversation = null;
return false; return false;
} }
...@@ -153,7 +163,7 @@ class Conversation ...@@ -153,7 +163,7 @@ class Conversation
*/ */
public function stop() public function stop()
{ {
return $this->updateStatus('stopped'); return ($this->updateStatus('stopped') && $this->clear());
} }
/** /**
...@@ -163,7 +173,7 @@ class Conversation ...@@ -163,7 +173,7 @@ class Conversation
*/ */
public function cancel() public function cancel()
{ {
return $this->updateStatus('cancelled'); return ($this->updateStatus('cancelled') && $this->clear());
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment