Commit 33dd4a80 authored by MBoretto's avatar MBoretto

reintroduced update()

parent f302c734
......@@ -69,7 +69,7 @@ class SendtochannelCommand extends AdminCommand
// getConfig has not been configured asking for channel to administer
if ($type != 'Message' || empty($text)) {
$this->conversation->notes['state'] = -1;
//$this->conversation->update();
$this->conversation->update();
$data['text'] = 'Insert the channel name: (@yourchannel)';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
......@@ -88,7 +88,7 @@ class SendtochannelCommand extends AdminCommand
// getConfig has been configured choose channel
if ($type != 'Message' || !in_array($text, $channels)) {
$this->conversation->notes['state'] = 0;
//$this->conversation->update();
$this->conversation->update();
$keyboard = [];
foreach ($channels as $channel) {
......@@ -118,7 +118,7 @@ class SendtochannelCommand extends AdminCommand
insert:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || ($type == 'Message' && empty($text))) {
$this->conversation->notes['state'] = 1;
//$this->conversation->update();
$this->conversation->update();
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
$data['text'] = 'Insert the content you want to share: text, photo, audio...';
......@@ -133,7 +133,7 @@ class SendtochannelCommand extends AdminCommand
case 2:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || !($text == 'Yes' || $text == 'No')) {
$this->conversation->notes['state'] = 2;
//$this->conversation->update();
$this->conversation->update();
// Execute this just with object that allow caption
if ($this->conversation->notes['message_type'] == 'Video' || $this->conversation->notes['message_type'] == 'Photo') {
......@@ -165,7 +165,7 @@ class SendtochannelCommand extends AdminCommand
case 3:
if (($this->conversation->notes['last_message_id'] == $message->getMessageId() || $type != 'Message' ) && $this->conversation->notes['set_caption']) {
$this->conversation->notes['state'] = 3;
//$this->conversation->update();
$this->conversation->update();
$data['text'] = 'Insert caption:';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
......@@ -178,7 +178,7 @@ class SendtochannelCommand extends AdminCommand
case 4:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || !($text == 'Yes' || $text == 'No')) {
$this->conversation->notes['state'] = 4;
//$this->conversation->update();
$this->conversation->update();
$data['text'] = 'Message will look like this:';
$result = Request::sendMessage($data);
......
......@@ -79,6 +79,7 @@ class SurveyCommand extends UserCommand
case 0:
if (empty($text)) {
$this->conversation->notes['state'] = 0;
$this->conversation->update();
$data['text'] = 'Type your name:';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
......@@ -91,6 +92,7 @@ class SurveyCommand extends UserCommand
case 1:
if (empty($text)) {
$this->conversation->notes['state'] = 1;
$this->conversation->update();
$data['text'] = 'Type your surname:';
$result = Request::sendMessage($data);
......@@ -104,6 +106,7 @@ class SurveyCommand extends UserCommand
case 2:
if (empty($text) || !is_numeric($text)) {
$this->conversation->notes['state'] = 2;
$this->conversation->update();
$data['text'] = 'Type your age:';
if (!empty($text) && !is_numeric($text)) {
......@@ -119,6 +122,7 @@ class SurveyCommand extends UserCommand
case 3:
if (empty($text) || !($text == 'M' || $text == 'F')) {
$this->conversation->notes['state'] = 3;
$this->conversation->update();
$keyboard = [['M','F']];
$reply_keyboard_markup = new ReplyKeyboardMarkup(
......@@ -144,6 +148,7 @@ class SurveyCommand extends UserCommand
case 4:
if (is_null($message->getLocation())) {
$this->conversation->notes['state'] = 4;
$this->conversation->update();
$data['text'] = 'Insert your home location (need location object):';
$data['reply_markup'] = new ReplyKeyBoardHide(['selective' => true]);
......@@ -158,6 +163,7 @@ class SurveyCommand extends UserCommand
case 5:
if (is_null($message->getPhoto())) {
$this->conversation->notes['state'] = 5;
$this->conversation->update();
$data['text'] = 'Insert your picture:';
$result = Request::sendMessage($data);
......
......@@ -89,17 +89,6 @@ class Conversation
}
}
/**
* Conversation destructor updates the conversation
*/
public function __destruct()
{
//Perform the update when the object goes out of the stage and notes have changed after load()
if ($this->command_is_provided && $this->notes !== $this->protected_notes) {
$this->update();
}
}
/**
* Load the conversation from the database
*
......
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