1
0
mirror of https://github.com/nextcloud/ocsms.git synced 2026-08-11 16:32:55 +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
+11 -6
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"]
));
}