mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-22 15:26:26 +00:00
Merge branch 'master' of https://github.com/nerzhul/ocsms into stable
This commit is contained in:
commit
9a9ce17082
24
README.md
24
README.md
@ -1,8 +1,20 @@
|
||||
# Oc Sms
|
||||
|
||||
## Introduction
|
||||
|
||||
Oc Sms provides a webinterface to display your SMS conversations.
|
||||
|
||||
SMS conversations are pushed by your Android devices using ownCloud Sms app, available on Google Play Store
|
||||
|
||||
Android download link: https://play.google.com/store/apps/details?id=fr.unix_experience.owncloud_sms
|
||||
|
||||
## Licence
|
||||
|
||||
OcSMS web application is actually under AGPL licence but this free licence can be modificated to a better free licence.
|
||||
|
||||
## Requirements
|
||||
- An ownCloud instance
|
||||
|
||||
|
||||
## Installation
|
||||
Place this app in **owncloud/apps/**
|
||||
|
||||
|
||||
## Running tests
|
||||
After [Installing PHPUnit](http://phpunit.de/getting-started.html) run:
|
||||
|
||||
phpunit tests/
|
@ -16,6 +16,7 @@ use \OCP\IRequest;
|
||||
use \OCP\AppFramework\Http\TemplateResponse;
|
||||
use \OCP\AppFramework\Controller;
|
||||
use \OCP\AppFramework\Http\JSONResponse;
|
||||
use \OCA\OcSms\AppInfo\OcSmsApp;
|
||||
use \OCA\OcSms\Db\SmsMapper;
|
||||
|
||||
class SmsController extends Controller {
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
// db/author.php
|
||||
namespace OCA\OcSms\Db;
|
||||
|
||||
use \OCP\AppFramework\Db\Entity;
|
||||
|
@ -33,7 +33,7 @@ class SmsMapper extends Mapper {
|
||||
}
|
||||
|
||||
public function getAllIds ($userId) {
|
||||
$query = \OC_DB::prepare('SELECT sms_id, sms_mailbox FROM ' .
|
||||
$query = \OCP\DB::prepare('SELECT sms_id, sms_mailbox FROM ' .
|
||||
'*PREFIX*ocsms_smsdatas WHERE user_id = ?');
|
||||
$result = $query->execute(array($userId));
|
||||
|
||||
@ -52,7 +52,7 @@ class SmsMapper extends Mapper {
|
||||
}
|
||||
|
||||
public function getAllPeersPhoneNumbers ($userId) {
|
||||
$query = \OC_DB::prepare('SELECT sms_address FROM ' .
|
||||
$query = \OCP\DB::prepare('SELECT sms_address FROM ' .
|
||||
'*PREFIX*ocsms_smsdatas WHERE user_id = ? AND sms_mailbox IN (?,?)');
|
||||
$result = $query->execute(array($userId, 0, 1));
|
||||
|
||||
@ -66,7 +66,7 @@ class SmsMapper extends Mapper {
|
||||
}
|
||||
|
||||
public function getAllMessagesForPhoneNumber ($userId, $phoneNumber, $minDate = 0) {
|
||||
$query = \OC_DB::prepare('SELECT sms_date, sms_msg, sms_type FROM ' .
|
||||
$query = \OCP\DB::prepare('SELECT sms_date, sms_msg, sms_type FROM ' .
|
||||
'*PREFIX*ocsms_smsdatas WHERE user_id = ? AND sms_address = ? ' .
|
||||
'AND sms_mailbox IN (?,?) AND sms_date > ?');
|
||||
$result = $query->execute(array($userId, $phoneNumber, 0, 1, $minDate));
|
||||
@ -86,7 +86,7 @@ class SmsMapper extends Mapper {
|
||||
\OCP\DB::beginTransaction();
|
||||
|
||||
if ($purgeAllSmsBeforeInsert === true) {
|
||||
$query = \OC_DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' .
|
||||
$query = \OCP\DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' .
|
||||
'WHERE user_id = ?');
|
||||
$result = $query->execute(array($userId));
|
||||
}
|
||||
@ -101,14 +101,14 @@ class SmsMapper extends Mapper {
|
||||
if ($purgeAllSmsBeforeInsert === false) {
|
||||
// Remove previous record
|
||||
// @ TODO: only update the required fields, getAllIds can be useful
|
||||
$query = \OC_DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' .
|
||||
$query = \OCP\DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' .
|
||||
'WHERE user_id = ? AND sms_id = ?');
|
||||
$result = $query->execute(array(
|
||||
$userId, (int) $sms["_id"]
|
||||
));
|
||||
}
|
||||
|
||||
$query = \OC_DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' .
|
||||
$query = \OCP\DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' .
|
||||
'(user_id, added, lastmodified, sms_flags, sms_date, sms_id,' .
|
||||
'sms_address, sms_msg, sms_mailbox, sms_type) VALUES ' .
|
||||
'(?,?,?,?,?,?,?,?,?,?)');
|
||||
|
28
js/script.js
28
js/script.js
@ -25,6 +25,11 @@ $.urlParam = function(name){
|
||||
};
|
||||
|
||||
var refreshConversation = function() {
|
||||
// if no conversation selected, then don't fetch page
|
||||
if (curPhoneNumber == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'),
|
||||
{
|
||||
'phoneNumber': curPhoneNumber,
|
||||
@ -152,18 +157,25 @@ function changeSelectedConversation(item) {
|
||||
OC.Util.History.pushState('phonenumber=' + phoneNumber);
|
||||
// Reset it for refreshConversation
|
||||
lastMsgDate = 0;
|
||||
fetchConversation(phoneNumber);
|
||||
changeSelectedConversation($(this));
|
||||
|
||||
// phoneNumber must exist
|
||||
if (phoneNumber != null) {
|
||||
fetchConversation(phoneNumber);
|
||||
changeSelectedConversation($(this));
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
var urlPhoneNumber = decodeURIComponent($.urlParam('phonenumber'));
|
||||
if (urlPhoneNumber != null) {
|
||||
fetchConversation(urlPhoneNumber);
|
||||
var pnParam = $.urlParam('phonenumber'));
|
||||
if (pnParam != null) {
|
||||
var urlPhoneNumber = decodeURIComponent(pnParam);
|
||||
if (urlPhoneNumber != null) {
|
||||
fetchConversation(urlPhoneNumber);
|
||||
|
||||
var pObject = $("a[mailbox-navigation='" + urlPhoneNumber + "']");
|
||||
if (pObject != null) {
|
||||
changeSelectedConversation(pObject);
|
||||
var pObject = $("a[mailbox-navigation='" + urlPhoneNumber + "']");
|
||||
if (pObject != null) {
|
||||
changeSelectedConversation(pObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user