Commit 33dd4a80 authored by MBoretto's avatar MBoretto

reintroduced update()

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