@@ -12,7 +12,7 @@ class Lists
1212{
1313 /**
1414 * Gets all lists in phpList as an array.
15- *
15+ *
1616 * <p><strong>Parameters:</strong><br/>
1717 * (none)
1818 * <p><strong>Returns:</strong><br/>
@@ -26,7 +26,7 @@ public static function listsGet()
2626
2727 /**
2828 * Gets one (1) list.
29- *
29+ *
3030 * <p><strong>Parameters:</strong><br/>
3131 * [*id] {integer} the ID of the list.
3232 * <p><strong>Returns:</strong><br/>
@@ -38,18 +38,18 @@ public static function listGet($id = 0)
3838 if ($ id == 0 ) {
3939 $ id = $ _REQUEST ['id ' ];
4040 }
41-
41+
4242 $ params = array (
4343 'id ' => array ($ id ,PDO ::PARAM_INT ),
4444 );
45-
46-
45+
46+
4747 Common::select ('List ' , 'SELECT * FROM ' .$ GLOBALS ['tables ' ]['list ' ]." WHERE id = :id; " ,$ params ,true );
4848 }
4949
5050 /**
5151 * Add a new list.
52- *
52+ *
5353 * <p><strong>Parameters:</strong><br/>
5454 * [*name] {string} the name of the list.<br/>
5555 * [description] {string} adds a description to the list.<br/>
@@ -61,10 +61,10 @@ public static function listGet($id = 0)
6161 */
6262 public static function listAdd ()
6363 {
64- $ sql = 'INSERT INTO ' .$ GLOBALS ['tables ' ]['list ' ].'
65- (name, description, listorder, category, active)
64+ $ sql = 'INSERT INTO ' .$ GLOBALS ['tables ' ]['list ' ].'
65+ (name, description, listorder, category, active)
6666 VALUES (:name, :description, :listorder, :category, :active); ' ;
67-
67+
6868 // allow for an empty category, which didn't exist before
6969 if (!isset ($ _REQUEST ['category ' ])) {
7070 $ _REQUEST ['category ' ] = '' ;
@@ -89,7 +89,7 @@ public static function listAdd()
8989
9090 /**
9191 * Update existing List.
92- *
92+ *
9393 * <p><strong>Parameters:</strong><br/>
9494 * [*id] {integer} the ID of the list.<br/>
9595 * [*name] {string} the name of the list.<br/>
@@ -103,7 +103,7 @@ public static function listAdd()
103103 public static function listUpdate ()
104104 {
105105 $ sql = 'UPDATE ' .$ GLOBALS ['tables ' ]['list ' ].'
106- SET name=:name, description=:description, listorder=:listorder, category=:category, active=:active
106+ SET name=:name, description=:description, listorder=:listorder, category=:category, active=:active
107107 WHERE id=:id; ' ;
108108
109109 // allow for an empty category, which didn't exist before
@@ -129,9 +129,9 @@ public static function listUpdate()
129129 die (0 );
130130 }
131131
132- /**
132+ /**
133133 * Delete a List.
134- *
134+ *
135135 * <p><strong>Parameters:</strong><br/>
136136 * [*id] {integer} the ID of the list.
137137 * <p><strong>Returns:</strong><br/>
@@ -159,7 +159,7 @@ public static function listDelete()
159159
160160 /**
161161 * Get Lists a Subscriber is Member of.
162- *
162+ *
163163 * <p><strong>Parameters:</strong><br/>
164164 * [*subscriber_id] {integer} the Subscriber-ID.
165165 * <p><strong>Returns:</strong><br/>
@@ -172,7 +172,7 @@ public static function listsSubscriber($subscriber_id = 0)
172172 if ($ subscriber_id == 0 ) {
173173 $ subscriber_id = sprintf ('%d ' ,$ _REQUEST ['subscriber_id ' ]);
174174 }
175- $ sql = 'SELECT * FROM ' .$ GLOBALS ['tables ' ]['list ' ].' WHERE id IN
175+ $ sql = 'SELECT * FROM ' .$ GLOBALS ['tables ' ]['list ' ].' WHERE id IN
176176 (SELECT listid FROM ' .$ GLOBALS ['tables ' ]['listuser ' ].' WHERE userid=:subscriber_id) ORDER BY listorder; ' ;
177177 if (!is_numeric ($ subscriber_id ) || empty ($ subscriber_id )) {
178178 Response::outputErrorMessage ('invalid call ' );
@@ -194,7 +194,7 @@ public static function listsSubscriber($subscriber_id = 0)
194194
195195 /**
196196 * Add a subscriber to a list.
197- *
197+ *
198198 * <p>The subscriber then subscribes to the list.</p>
199199 * <p><strong>Parameters:</strong><br/>
200200 * [*list_id] {integer} the ID of the list.<br/>
@@ -231,7 +231,7 @@ public static function listSubscriberAdd($list_id = 0, $subscriber_id = 0)
231231
232232 /**
233233 * Remove a subscriber from a list.
234- *
234+ *
235235 * <p><strong>Parameters:</strong><br/>
236236 * [*list_id] {integer} the ID of the list.<br/>
237237 * [*subscriber_id] {integer} the ID of the subscriber.
@@ -264,7 +264,7 @@ public static function listSubscriberDelete($list_id = 0, $subscriber_id = 0)
264264
265265 /**
266266 * Assigns a list to a campaign.
267- *
267+ *
268268 * <p><strong>Parameters:</strong><br/>
269269 * [*list_id] {integer} the ID of the list.<br/>
270270 * [*campaign_id] {integer} the ID of the campaign.
@@ -297,7 +297,7 @@ public static function listCampaignAdd($list_id = 0, $campaign_id = 0)
297297
298298 /**
299299 * Unassigns a list from a campaign.
300- *
300+ *
301301 * <p><strong>Parameters:</strong><br/>
302302 * [*list_id] {integer} the ID of the list.<br/>
303303 * [*campaign_id] {integer} the ID of the campaign.
@@ -330,7 +330,7 @@ public static function listCampaignDelete($list_id = 0, $campaign_id = 0)
330330 }
331331 /**
332332 * Get all subscribers from a list
333- *
333+ *
334334 * <p><strong>Parameters:</strong><br/>
335335 * [*list_id] {integer} the List-ID.
336336 * <p><strong>Returns:</strong><br/>
@@ -343,7 +343,7 @@ public static function listSubscribers($list_id = 0)
343343 if ($ list_id == 0 ) {
344344 $ list_id = sprintf ('%d ' ,$ _REQUEST ['list_id ' ]);
345345 }
346- $ sql = 'SELECT * FROM ' .$ GLOBALS ['tables ' ]['user ' ].' WHERE id IN
346+ $ sql = 'SELECT * FROM ' .$ GLOBALS ['tables ' ]['user ' ].' WHERE id IN
347347 (SELECT userid FROM ' .$ GLOBALS ['tables ' ]['listuser ' ].' WHERE listid=:list_id) ORDER BY id; ' ;
348348 if (!is_numeric ($ list_id ) || empty ($ list_id )) {
349349 Response::outputErrorMessage ('invalid call ' );
@@ -396,5 +396,24 @@ public static function listSubscribersCount($list_id = 0)
396396 }
397397 }
398398
399-
399+ /**
400+ * Get all lists within a category
401+ *
402+ * <p><strong>Parameters:</strong><br/>
403+ * [*category] {string} the category.
404+ * <p><strong>Returns:</strong><br/>
405+ * Array of lists that are in the category.
406+ * </p>
407+ */
408+ public static function listsByCategory ($ category = '' )
409+ {
410+ if ($ category == '' ) {
411+ $ category = sprintf ('%s ' , $ _REQUEST ['category ' ]);
412+ }
413+ $ sql = 'SELECT * FROM ' .$ GLOBALS ['tables ' ]['list ' ].' WHERE category = :category ' ;
414+ $ params = [
415+ 'category ' => [$ category , PDO ::PARAM_STR ]
416+ ];
417+ Common::select ('Lists ' , $ sql , $ params );
418+ }
400419}
0 commit comments