mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 16:06:15 +00:00
Because there is a bug on boolean recognition in PHP, we are using string octal representation for flags
This commit is contained in:
parent
c089cc3ded
commit
52fe3c44c4
@ -52,16 +52,6 @@
|
|||||||
<type>text</type>
|
<type>text</type>
|
||||||
<notnull>true</notnull>
|
<notnull>true</notnull>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
|
||||||
<name>sms_read</name>
|
|
||||||
<type>boolean</type>
|
|
||||||
<notnull>true</notnull>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>sms_seen</name>
|
|
||||||
<type>boolean</type>
|
|
||||||
<notnull>true</notnull>
|
|
||||||
</field>
|
|
||||||
<field>
|
<field>
|
||||||
<name>sms_date</name>
|
<name>sms_date</name>
|
||||||
<type>integer</type>
|
<type>integer</type>
|
||||||
@ -69,9 +59,11 @@
|
|||||||
<length>10</length>
|
<length>10</length>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>sms_draft</name>
|
<name>sms_flags</name>
|
||||||
<type>boolean</type>
|
<type>text</type>
|
||||||
<notnull>true</notnull>
|
<notnull>true</notnull>
|
||||||
|
<default>000</default>
|
||||||
|
<length>3</length>
|
||||||
</field>
|
</field>
|
||||||
</declaration>
|
</declaration>
|
||||||
</table>
|
</table>
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
<description>Owncloud SMS app</description>
|
<description>Owncloud SMS app</description>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Loic Blot</author>
|
<author>Loic Blot</author>
|
||||||
<version>0.1.0</version>
|
<version>0.1.2</version>
|
||||||
<requiremin>7</requiremin>
|
<requiremin>7</requiremin>
|
||||||
</info>
|
</info>
|
||||||
|
@ -85,9 +85,6 @@ class SmsController extends Controller {
|
|||||||
$this->errorMsg = "Error: Invalid SMS Draft state";
|
$this->errorMsg = "Error: Invalid SMS Draft state";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$sms["draft"] == $sms["draft"] === true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_numeric($sms["date"]) && $sms["date"] != 0 && $sms["date"] != 1) {
|
if (!is_numeric($sms["date"]) && $sms["date"] != 0 && $sms["date"] != 1) {
|
||||||
$this->errorMsg = "Error: Invalid SMS date";
|
$this->errorMsg = "Error: Invalid SMS date";
|
||||||
|
@ -23,14 +23,19 @@ class SmsMapper extends Mapper {
|
|||||||
// @TODO
|
// @TODO
|
||||||
public function saveAll($userId, $smsList) {
|
public function saveAll($userId, $smsList) {
|
||||||
foreach ($smsList as $sms) {
|
foreach ($smsList as $sms) {
|
||||||
|
$smsFlags = sprintf("%s%s%s",
|
||||||
|
$sms["read"] === "true" ? "1" : "0",
|
||||||
|
$sms["seen"] === "true" ? "1" : "0",
|
||||||
|
$sms["draft"] === "true" ? "1" : "0"
|
||||||
|
);
|
||||||
|
|
||||||
$query = \OC_DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' .
|
$query = \OC_DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' .
|
||||||
'(user_id, added, lastmodified, sms_read, sms_seen, sms_date,' .
|
'(user_id, added, lastmodified, sms_flags, sms_date, sms_id,' .
|
||||||
'sms_draft, sms_id, sms_address, sms_msg) VALUES ' .
|
'sms_address, sms_msg) VALUES ' .
|
||||||
'(?,?,?,?,?,?,?,?,?,?)');
|
'(?,?,?,?,?,?,?,?)');
|
||||||
$result = $query->execute(array(
|
$result = $query->execute(array(
|
||||||
$userId, "NOW()", "NOW()",
|
$userId, "NOW()", "NOW()", $smsFlags,
|
||||||
$sms["read"] === "true", $sms["seen"] === "true",
|
(int) $sms["date"], (int) $sms["id"],
|
||||||
(int) $sms["date"], $sms["draft"], (int) $sms["id"],
|
|
||||||
$sms["address"], $sms["body"]
|
$sms["address"], $sms["body"]
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user