mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-08 00:16:24 +00:00
Add new function to fetch all SMS friends
This commit is contained in:
parent
3f712180fb
commit
169302516b
@ -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.7</version>
|
<version>0.1.8</version>
|
||||||
<requiremin>7</requiremin>
|
<requiremin>7</requiremin>
|
||||||
</info>
|
</info>
|
||||||
|
@ -35,7 +35,9 @@ class SmsController extends Controller {
|
|||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*/
|
*/
|
||||||
public function index () {
|
public function index () {
|
||||||
$params = array('user' => $this->userId);
|
$params = array('user' => $this->userId,
|
||||||
|
"PNLConversations" => $this->smsMapper->getAllPeersPhoneNumbers($this->userId)
|
||||||
|
);
|
||||||
return new TemplateResponse($this->appName, 'main', $params);
|
return new TemplateResponse($this->appName, 'main', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,21 @@ class SmsMapper extends Mapper {
|
|||||||
return $smsList;
|
return $smsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAllPeersPhoneNumbers ($userId) {
|
||||||
|
$query = \OC_DB::prepare('SELECT sms_address FROM ' .
|
||||||
|
'*PREFIX*ocsms_smsdatas WHERE user_id = ? AND sms_mailbox IN (?,?)');
|
||||||
|
$result = $query->execute(array($userId, 0, 1));
|
||||||
|
|
||||||
|
$phoneList = array();
|
||||||
|
while($row = $result->fetchRow()) {
|
||||||
|
if (!in_array($row["sms_id"], $phoneList)) {
|
||||||
|
array_push($phoneList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort($phoneList);
|
||||||
|
return $phoneList;
|
||||||
|
}
|
||||||
|
|
||||||
public function writeToDB ($userId, $smsList, $purgeAllSmsBeforeInsert = false) {
|
public function writeToDB ($userId, $smsList, $purgeAllSmsBeforeInsert = false) {
|
||||||
\OCP\DB::beginTransaction();
|
\OCP\DB::beginTransaction();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user