1
0
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:
Loïc Blot (@U-Exp) 2014-09-12 17:12:49 +02:00
parent c089cc3ded
commit 52fe3c44c4
4 changed files with 16 additions and 22 deletions

View File

@ -52,16 +52,6 @@
<type>text</type>
<notnull>true</notnull>
</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>
<name>sms_date</name>
<type>integer</type>
@ -69,9 +59,11 @@
<length>10</length>
</field>
<field>
<name>sms_draft</name>
<type>boolean</type>
<name>sms_flags</name>
<type>text</type>
<notnull>true</notnull>
<default>000</default>
<length>3</length>
</field>
</declaration>
</table>

View File

@ -5,6 +5,6 @@
<description>Owncloud SMS app</description>
<licence>AGPL</licence>
<author>Loic Blot</author>
<version>0.1.0</version>
<version>0.1.2</version>
<requiremin>7</requiremin>
</info>

View File

@ -85,9 +85,6 @@ class SmsController extends Controller {
$this->errorMsg = "Error: Invalid SMS Draft state";
return false;
}
else {
$sms["draft"] == $sms["draft"] === true;
}
if (!is_numeric($sms["date"]) && $sms["date"] != 0 && $sms["date"] != 1) {
$this->errorMsg = "Error: Invalid SMS date";

View File

@ -23,14 +23,19 @@ class SmsMapper extends Mapper {
// @TODO
public function saveAll($userId, $smsList) {
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 ' .
'(user_id, added, lastmodified, sms_read, sms_seen, sms_date,' .
'sms_draft, sms_id, sms_address, sms_msg) VALUES ' .
'(?,?,?,?,?,?,?,?,?,?)');
'(user_id, added, lastmodified, sms_flags, sms_date, sms_id,' .
'sms_address, sms_msg) VALUES ' .
'(?,?,?,?,?,?,?,?)');
$result = $query->execute(array(
$userId, "NOW()", "NOW()",
$sms["read"] === "true", $sms["seen"] === "true",
(int) $sms["date"], $sms["draft"], (int) $sms["id"],
$userId, "NOW()", "NOW()", $smsFlags,
(int) $sms["date"], (int) $sms["id"],
$sms["address"], $sms["body"]
));
}