validateReceivedSMS($sms->Number(), count($args), 2, _('with stand name:') . " LIST RACKO"); listBikes($sms->Number(), $args[1]); break; case "ADD": checkUserPrivileges($sms->Number()); validateReceivedSMS($sms->Number(), count($args), 3, _('with email, phone, fullname:') . " ADD king@earth.com 0901456789 Martin Luther King Jr."); add($sms->Number(), $args[1], $args[2], trim(urldecode($sms->Text()))); break; case "REVERT": checkUserPrivileges($sms->Number()); validateReceivedSMS($sms->Number(), count($args), 2, _('with bike number:') . " REVERT 47"); revert($sms->Number(), $args[1]); break; // case "NEAR": // case "BLIZKO": // near($sms->Number(),$args[1]); // case "NEAR": // case "BLIZKO": // near($sms->Number(),$args[1]); case "LAST": checkUserPrivileges($sms->Number()); validateReceivedSMS($sms->Number(), count($args), 2, _('with bike number:') . " LAST 47"); last($sms->Number(), $args[1]); break; default: unknownCommand($sms->Number(), $args[0]); } } R::commit(); $sms->Respond(); R::close();
function delstandnote($number, $standName, $message) { global $db; $userId = getUser($number); checkUserPrivileges($number); $result = $db->query("SELECT standId FROM stands where standName='{$standName}'"); if ($result->num_rows != 1) { sendSMS($number, _("Stand") . " " . $standName . _("does not exist") . "."); return; } $row = $result->fetch_assoc(); $standId = $row["standId"]; $result = $db->query("SELECT userName FROM users WHERE number={$number}"); $row = $result->fetch_assoc(); $reportedBy = $row["userName"]; $matches = explode(" ", $message, 3); $userNote = $db->conn->real_escape_string(trim($matches[2])); if ($userNote == '') { $userNote = '%'; } $result = $db->query("UPDATE notes SET deleted=NOW() where standId={$standId} and deleted is null and note like '%{$userNote}%'"); $count = $db->conn->affected_rows; if ($count == 0) { if ($userNote == "%") { sendSMS($number, _('No notes found for stand') . " " . $standName . " " . _('to delete') . "."); } else { sendSMS($number, _('No notes matching pattern') . " '" . $userNote . "' " . _('found on stand') . " " . $standName . " " . _('to delete') . "."); } } else { //only admins can delete and those will receive the confirmation in the next step. //sendSMS($number,"Note for bike $bikeNum deleted."); if ($userNote == "%") { notifyAdmins(_('All') . " " . sprintf(ngettext('%d note', '%d notes', $count), $count) . " " . _('on stand') . " " . $standName . " " . _('deleted by') . " " . $reportedBy . "."); } else { notifyAdmins(sprintf(ngettext('%d note', '%d notes', $count), $count) . " " . _('on stand') . " " . $standName . " " . _('matching') . " '" . $userNote . "' " . _('deleted by') . " " . $reportedBy . "."); } } }