Skip to content

Commit

Permalink
Merge remote-tracking branch 'andreas/master'
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
Bjwebb committed Jun 15, 2014
2 parents 5a9085c + b7220dc commit e84a61d
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 35 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -13,6 +13,8 @@ License: GPLv2
```
v. Date Description
0.3 2014-05-31 Moved to phpList organisation and renamed phplist-plugin-restapi
0.2.7 2013-03-13 Added order and limit to listsGet
0.2.6 2013-03-13 Test script fixed with login and password.
0.2.5 2013-02-24 New name: RESTAPI and some documentation updates. No new functionality.
0.2.4 2012-12-29 API-location "coderoot" dynamically routed, recommended by Bramley
0.2.3 2012-12-29 Corrections to static calls, recommended by Bramley
Expand Down
3 changes: 2 additions & 1 deletion plugins/restapi/includes/lists.php
@@ -1,7 +1,8 @@
<?php

/**
* Common functions to manage lists in phpList
* Class phpList_RESTAPI_Lists
* Getting lists, adding and removing its users and messages
*/
class phpList_RESTAPI_Lists{

Expand Down
4 changes: 4 additions & 0 deletions plugins/restapi/includes/messages.php
@@ -1,5 +1,9 @@
<?php

/**
* Class phpList_RESTAPI_Messages
* Manage phplist Messages
*/
class phpList_RESTAPI_Messages{

static function messageGet( $id=0 ) {
Expand Down
3 changes: 3 additions & 0 deletions plugins/restapi/includes/pdo.php
@@ -1,5 +1,8 @@
<?php

/**
* Class phpList_RESTAPI_PDO
*/
class phpList_RESTAPI_PDO{

static function getConnection() {
Expand Down
4 changes: 4 additions & 0 deletions plugins/restapi/includes/templates.php
@@ -1,5 +1,9 @@
<?php

/**
* Class phpList_RESTAPI_Templates
* Handling templates at phplist
*/
class phpList_RESTAPI_Templates{

static function templatesGet() {
Expand Down
39 changes: 37 additions & 2 deletions plugins/restapi/includes/users.php
Expand Up @@ -4,12 +4,23 @@ class phpList_RESTAPI_Users{

/**
* <p>Get all the users in the system.</p>
* <p><strong>Parameters:</strong><br/>
* [order_by] {string} name of column to sort, default "id".<br/>
* [order] {string} sort order asc or desc, default: asc.<br/>
* [limit] {integer} limit the result, default 100.<br/>
* </p>
* <p><strong>Returns:</strong><br/>
* List of users.
* </p>
*/
static function usersGet() {
phpList_RESTAPI_Common::select( 'Users', "SELECT * FROM " . $GLOBALS['usertable_prefix'] . "user ORDER BY id;" );
static function usersGet( $order_by='id', $order='asc', $limit=100 ) {

//getting optional values
if ( isset( $_REQUEST['order_by'] ) && !empty( $_REQUEST['order_by'] ) ) $order_by = $_REQUEST['order_by'];
if ( isset( $_REQUEST['order'] ) && !empty( $_REQUEST['order'] ) ) $order = $_REQUEST['order'];
if ( isset( $_REQUEST['limit'] ) && !empty( $_REQUEST['limit'] ) ) $limit = $_REQUEST['limit'];

phpList_RESTAPI_Common::select( 'Users', "SELECT * FROM " . $GLOBALS['usertable_prefix'] . "user ORDER BY $order_by $order LIMIT $limit;" );
}

/**
Expand Down Expand Up @@ -77,6 +88,21 @@ static function userAdd(){

}

/**
* <p>Updates one user to the system.</p>
* <p><strong>Parameters:</strong><br/>
* [*id] {integer} the ID of the user.<br/>
* [*email] {string} the email address of the user.<br/>
* [*confirmed] {integer} 1=confirmed, 0=unconfirmed.<br/>
* [*htmlemail] {integer} 1=html emails, 0=no html emails.<br/>
* [*rssfrequency] {integer}<br/>
* [*password] {string} The password to this user.<br/>
* [*disabled] {integer} 1=disabled, 0=enabled<br/>
* </p>
* <p><strong>Returns:</strong><br/>
* The updated user.
* </p>
*/
static function userUpdate(){

$sql = "UPDATE " . $GLOBALS['usertable_prefix'] . "user SET email=:email, confirmed=:confirmed, htmlemail=:htmlemail, rssfrequency=:rssfrequency, password=:password, passwordchanged=now(), disabled=:disabled WHERE id=:id;";
Expand All @@ -100,6 +126,15 @@ static function userUpdate(){

}

/**
* <p>Deletes a user.</p>
* <p><strong>Parameters:</strong><br/>
* [*id] {integer} the ID of the user.<br/>
* </p>
* <p><strong>Returns:</strong><br/>
* The deleted user ID.
* </p>
*/
static function userDelete(){

$sql = "DELETE FROM " . $GLOBALS['usertable_prefix'] . "user WHERE id=:id;";
Expand Down

0 comments on commit e84a61d

Please sign in to comment.