Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #31 from HESPUL/master
Browse files Browse the repository at this point in the history
Fix issue #30 + new API function listSubscribers
  • Loading branch information
michield committed May 3, 2016
2 parents ccf1f5a + ba46911 commit bb3d7a6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
36 changes: 36 additions & 0 deletions plugins/restapi/includes/lists.php
Expand Up @@ -328,4 +328,40 @@ public static function listCampaignDelete($list_id = 0, $campaign_id = 0)
}
die(0);
}
/**
* Get all subscribers from a list
*
* <p><strong>Parameters:</strong><br/>
* [*list_id] {integer} the List-ID.
* <p><strong>Returns:</strong><br/>
* Array of subscribers assigned to the list.
* </p>
*/
public static function listSubscribers($list_id = 0)
{
$response = new Response();
if ($list_id == 0) {
$list_id = sprintf('%d',$_REQUEST['list_id']);
}
$sql = 'SELECT * FROM '.$GLOBALS['tables']['user'].' WHERE id IN
(SELECT userid FROM '.$GLOBALS['tables']['listuser'].' WHERE listid=:list_id) ORDER BY id;';
if (!is_numeric($list_id) || empty($list_id)) {
Response::outputErrorMessage('invalid call');
}
try {
$db = PDO::getConnection();
$stmt = $db->prepare($sql);
$stmt->bindParam('list_id', $list_id, PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
$response->setData('Subscribers', $result);
$response->output();
} catch (\Exception $e) {
Response::outputError($e);
}
die(0);
}


}
4 changes: 2 additions & 2 deletions plugins/restapi/includes/subscribers.php
Expand Up @@ -29,10 +29,10 @@ public static function subscribersGet($order_by = 'id', $order = 'asc', $limit =
$order = $_REQUEST['order'];
}
if (isset($_REQUEST['limit']) && !empty($_REQUEST['limit'])) {
$limit = $_REQUEST['limit'];
$limit = intval($_REQUEST['limit']);
}
if (isset($_REQUEST['offset']) && !empty($_REQUEST['offset'])) {
$offset = $_REQUEST['offset'];
$offset = intval($_REQUEST['offset']);
}
if ($limit > 100) {
$limit = 100;
Expand Down

0 comments on commit bb3d7a6

Please sign in to comment.