<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -21,11 +21,12 @@ class Low_nospam_check
 	var $settings		= array();
 
 	var $name			= 'Low NoSpam';
-	var $version		= '1.0.3';
+	var $version		= '1.0.4';
 	var $description	= 'Anti-spam utility using online services like Akismet and TypePad AntiSpam';
 	var $settings_exist = 'y';
 	var $docs_url		= '';
 	
+	var $default_groups	= array(2, 3, 4);
 	var $input			= array();
 	var $API;
 
@@ -50,17 +51,29 @@ class Low_nospam_check
 	// --------------------------------	
 	function settings()
 	{
-		return array(
+		global $DB;
+		
+		// Get member groups
+		$groups = array();
+		$query = $DB-&gt;query(&quot;SELECT group_id, group_title FROM exp_member_groups ORDER BY group_title ASC&quot;);
+		foreach($query-&gt;result AS $row)
+		{
+			$groups[$row['group_id']] = $row['group_title'];
+		}
+		
+		$settings = array(
 			'service'					=&gt; array('s', array('akismet' =&gt; &quot;akismet&quot;, 'tpas' =&gt; &quot;tpas&quot;), 'akismet'),
 			'api_key'					=&gt; '',
+			'check_members'				=&gt; array('ms', $groups, $this-&gt;default_groups),
 			'check_comments'			=&gt; array('r', array('y' =&gt; &quot;yes&quot;, 'n' =&gt; &quot;no&quot;), 'y'),
 			'check_gallery_comments'	=&gt; array('r', array('y' =&gt; &quot;yes&quot;, 'n' =&gt; &quot;no&quot;), 'y'),
-			'check_members'				=&gt; array('r', array('y' =&gt; &quot;yes&quot;, 'n' =&gt; &quot;no&quot;), 'n'),
 			'check_forum_posts'			=&gt; array('r', array('y' =&gt; &quot;yes&quot;, 'n' =&gt; &quot;no&quot;), 'n'),
 			'check_wiki_articles'		=&gt; array('r', array('y' =&gt; &quot;yes&quot;, 'n' =&gt; &quot;no&quot;), 'n'),
 			'check_trackbacks'			=&gt; array('r', array('y' =&gt; &quot;yes&quot;, 'n' =&gt; &quot;no&quot;), 'y'),
 			'moderate_if_unreachable'	=&gt; array('r', array('y' =&gt; &quot;yes&quot;, 'n' =&gt; &quot;no&quot;), 'y')
 		);
+		
+		return $settings;
 	}
 	// END settings
 
@@ -74,31 +87,27 @@ class Low_nospam_check
 		global $SESS, $DB;
 		
 		// check settings to see if comment needs to be verified
-		if ($this-&gt;settings['check_comments'] == 'y')
+		if ($this-&gt;settings['check_comments'] == 'y' AND $this-&gt;_check_user())
 		{
-			// Check members too?
-			if (!$SESS-&gt;userdata['member_id'] OR ($SESS-&gt;userdata['member_id'] AND $this-&gt;settings['check_members'] == 'y'))
-			{
-				// Input array
-				$this-&gt;input = array(
-					'comment_author'		=&gt; $data['name'],
-					'comment_author_email'	=&gt; $data['email'],
-					'comment_author_url'	=&gt; $data['url'],
-					'comment_content'		=&gt; $data['comment']				
-				);
+			// Input array
+			$this-&gt;input = array(
+				'comment_author'		=&gt; $data['name'],
+				'comment_author_email'	=&gt; $data['email'],
+				'comment_author_url'	=&gt; $data['url'],
+				'comment_content'		=&gt; $data['comment']				
+			);
 
-				// Check it!
-				if ($this-&gt;is_spam())
-				{
-					// set comment status to 'c' 
-					$data['status'] = 'c';
-					
-					// insert closed comment to DB
-					$DB-&gt;query($DB-&gt;insert_string('exp_comments', $data));
-					
-					// Exit
-					$this-&gt;abort();
-				}
+			// Check it!
+			if ($this-&gt;is_spam())
+			{
+				// set comment status to 'c' 
+				$data['status'] = 'c';
+				
+				// insert closed comment to DB
+				$DB-&gt;query($DB-&gt;insert_string('exp_comments', $data));
+				
+				// Exit
+				$this-&gt;abort();
 			}
 		}
 		
@@ -115,7 +124,7 @@ class Low_nospam_check
 	function check_trackback($data)
 	{
 		// check settings to see if trackback needs to be verified
-		if ($this-&gt;settings['check_trackbacks'] == 'y')
+		if ($this-&gt;settings['check_trackbacks'] == 'y' AND $this-&gt;_check_user())
 		{
 			// input array
 			$this-&gt;input = array(
@@ -151,7 +160,7 @@ class Low_nospam_check
 		global $SESS, $IN;
 
 		// check settings to see if trackback needs to be verified
-		if ($this-&gt;settings['check_forum_posts'] == 'y')
+		if ($this-&gt;settings['check_forum_posts'] == 'y' AND $this-&gt;_check_user())
 		{
 			// input array
 			$this-&gt;input = array(
@@ -185,51 +194,47 @@ class Low_nospam_check
 		global $SESS, $IN, $DB, $LOC;
 		
 		// check settings to see if comment needs to be verified
-		if ($this-&gt;settings['check_gallery_comments'] == 'y')
+		if ($this-&gt;settings['check_gallery_comments'] == 'y' AND $this-&gt;_check_user())
 		{
-			// Check members too?
-			if (!$SESS-&gt;userdata['member_id'] OR ($SESS-&gt;userdata['member_id'] AND $this-&gt;settings['check_members'] == 'y'))
+			// Input array
+			$this-&gt;input = array(
+				'comment_author'		=&gt; $SESS-&gt;userdata['screen_name']	? $SESS-&gt;userdata['screen_name']	: $IN-&gt;GBL('name'),
+				'comment_author_email'	=&gt; $SESS-&gt;userdata['email']			? $SESS-&gt;userdata['email']			: $IN-&gt;GBL('email'),
+				'comment_author_url'	=&gt; $SESS-&gt;userdata['url']			? $SESS-&gt;userdata['url']			: $IN-&gt;GBL('url'),
+				'comment_content'		=&gt; $IN-&gt;GBL('comment')
+			);
+			
+			// Check it!
+			if ($this-&gt;is_spam())
 			{
-				// Input array
-				$this-&gt;input = array(
-					'comment_author'		=&gt; $SESS-&gt;userdata['screen_name']	? $SESS-&gt;userdata['screen_name']	: $IN-&gt;GBL('name'),
-					'comment_author_email'	=&gt; $SESS-&gt;userdata['email']			? $SESS-&gt;userdata['email']			: $IN-&gt;GBL('email'),
-					'comment_author_url'	=&gt; $SESS-&gt;userdata['url']			? $SESS-&gt;userdata['url']			: $IN-&gt;GBL('url'),
-					'comment_content'		=&gt; $IN-&gt;GBL('comment')
+				// gallery entry id
+				$entry_id = $DB-&gt;escape_str($IN-&gt;GBL('entry_id'));
+				
+				// get gallery id
+				$query = $DB-&gt;query(&quot;SELECT gallery_id FROM exp_gallery_entries WHERE entry_id = '{$entry_id}'&quot;);
+				
+				// row to insert
+				$data = array(
+					'entry_id'		=&gt; $entry_id,
+					'gallery_id'	=&gt; $query-&gt;row['gallery_id'],
+					'author_id'		=&gt; $SESS-&gt;userdata['member_id'],
+					'name'			=&gt; $this-&gt;input['comment_author'],
+					'email'			=&gt; $this-&gt;input['comment_author_email'],
+					'url'			=&gt; $this-&gt;input['comment_author_url'],
+					'location'		=&gt; $SESS-&gt;userdata['location'] ? $SESS-&gt;userdata['location'] : $IN-&gt;GBL('location'),
+					'ip_address'	=&gt; $SESS-&gt;userdata['ip_address'],
+					'comment_date'	=&gt; $LOC-&gt;now,
+					'comment'		=&gt; $this-&gt;input['comment_content'],
+					'notify'		=&gt; $IN-&gt;GBL('notify_me') ? 'y' : 'n',
+					// Set status to closed
+					'status'		=&gt; 'c'
 				);
 				
-				// Check it!
-				if ($this-&gt;is_spam())
-				{
-					// gallery entry id
-					$entry_id = $DB-&gt;escape_str($IN-&gt;GBL('entry_id'));
-					
-					// get gallery id
-					$query = $DB-&gt;query(&quot;SELECT gallery_id FROM exp_gallery_entries WHERE entry_id = '{$entry_id}'&quot;);
-					
-					// row to insert
-					$data = array(
-						'entry_id'		=&gt; $entry_id,
-						'gallery_id'	=&gt; $query-&gt;row['gallery_id'],
-						'author_id'		=&gt; $SESS-&gt;userdata['member_id'],
-						'name'			=&gt; $this-&gt;input['comment_author'],
-						'email'			=&gt; $this-&gt;input['comment_author_email'],
-						'url'			=&gt; $this-&gt;input['comment_author_url'],
-						'location'		=&gt; $SESS-&gt;userdata['location'] ? $SESS-&gt;userdata['location'] : $IN-&gt;GBL('location'),
-						'ip_address'	=&gt; $SESS-&gt;userdata['ip_address'],
-						'comment_date'	=&gt; $LOC-&gt;now,
-						'comment'		=&gt; $this-&gt;input['comment_content'],
-						'notify'		=&gt; $IN-&gt;GBL('notify_me') ? 'y' : 'n',
-						// Set status to closed
-						'status'		=&gt; 'c'
-					);
-					
-					// insert closed comment to DB
-					$DB-&gt;query($DB-&gt;insert_string('exp_gallery_comments', $data));
-					
-					// Exit
-					$this-&gt;abort();
-				}
+				// insert closed comment to DB
+				$DB-&gt;query($DB-&gt;insert_string('exp_gallery_comments', $data));
+				
+				// Exit
+				$this-&gt;abort();
 			}
 		}
 		
@@ -247,7 +252,7 @@ class Low_nospam_check
 		global $SESS, $IN, $DB;
 		
 		// check settings to see if comment needs to be verified
-		if ($this-&gt;settings['check_wiki_articles'] == 'y')
+		if ($this-&gt;settings['check_wiki_articles'] == 'y' AND $this-&gt;_check_user())
 		{
 			$this-&gt;input = array(
 				'user_ip'				=&gt; $SESS-&gt;userdata['ip_address'],
@@ -357,6 +362,34 @@ class Low_nospam_check
 
 
 	// --------------------------------
+	//	Check current user
+	// --------------------------------
+	function _check_user()
+	{
+		global $SESS;
+		
+		// Don't check if we don't have to check logged-in members
+		if ($this-&gt;settings['check_members'] === 'n' AND $SESS-&gt;userdata['member_id'] != 0)
+		{
+			$do_check = FALSE;
+		}
+		// Don't check if user is not in selected member groups
+		elseif (is_array($this-&gt;settings['check_members']) AND !in_array($SESS-&gt;userdata['group_id'], $this-&gt;settings['check_members']))
+		{
+			$do_check = FALSE;
+		}
+		// Every other case, perform check
+		else
+		{
+			$do_check = TRUE;
+		}
+		
+		return $do_check;
+	}
+	//END _check_user
+
+
+	// --------------------------------
 	//	Activate Extension
 	// --------------------------------
 	
@@ -406,7 +439,42 @@ class Low_nospam_check
 		{
 			return FALSE;
 		}
-		
+	    
+		// Update to version 1.0.4
+		// - Change check_members setting from y/n to array of member groups
+		if ($current &lt; '1.0.4')
+		{
+			// Get current settings
+			$query = $DB-&gt;query(&quot;SELECT settings FROM exp_extensions WHERE class = '&quot;.__CLASS__.&quot;' LIMIT 1&quot;);
+			$settings = unserialize($query-&gt;row['settings']);
+			
+			// init member groups
+			$groups = array();
+			
+			// Default member groups if members should not be checked
+			if (!isset($settings['check_members']) OR $settings['check_members'] === 'n')
+			{
+				$groups = $this-&gt;default_groups;
+			}
+			// All member groups, except superadmins, if members should be checked
+			else
+			{
+				$query = $DB-&gt;query(&quot;SELECT group_id FROM exp_member_groups WHERE group_id != 1&quot;);
+				foreach($query-&gt;result AS $row)
+				{
+					$groups[] = $row['group_id'];
+				}
+			}
+			
+			// update current settings
+			$settings['check_members'] = $groups;
+			$new_settings = $DB-&gt;escape_str(serialize($settings));
+			
+			// save new settings to DB
+			$DB-&gt;query(&quot;UPDATE exp_extensions SET settings = '{$new_settings}' WHERE class = '&quot;.__CLASS__.&quot;'&quot;);
+		}
+	    
+		// default: update version number
 		$DB-&gt;query(&quot;UPDATE exp_extensions SET version = '{$this-&gt;version}' WHERE class = '&quot;.__CLASS__.&quot;'&quot;);
 	}
 	// END update_extension</diff>
      <filename>system/extensions/ext.low_nospam_check.php</filename>
    </modified>
    <modified>
      <diff>@@ -88,7 +88,7 @@ $L = array(
 &quot;Check comments?&quot;,
 
 &quot;check_members&quot; =&gt;
-&quot;Check comments made by registered members?&quot;,
+&quot;Member groups to check&quot;,
 
 &quot;check_trackbacks&quot; =&gt;
 &quot;Check trackbacks?&quot;,</diff>
      <filename>system/language/english/lang.low_nospam.php</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,7 @@ if ( ! defined('EXT'))
 class Low_nospam_CP {
 
 	var $name		= 'Low_nospam';
-	var $version	= '1.0.3';
+	var $version	= '1.0.4';
 
 	var $site_id;
 	var $gallery;</diff>
      <filename>system/modules/low_nospam/mcp.low_nospam.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9f1da69584ff5b4b07803ab7f301ff2fd79d7bba</id>
    </parent>
  </parents>
  <author>
    <name>Lodewijk Schutte</name>
    <email>lodewijk@gmail.com</email>
  </author>
  <url>http://github.com/lodewijk/low.nospam.ee_addon/commit/8bdf6826e89a44303b2e4afb70c68146eb83319b</url>
  <id>8bdf6826e89a44303b2e4afb70c68146eb83319b</id>
  <committed-date>2009-04-17T07:31:39-07:00</committed-date>
  <authored-date>2009-04-17T07:31:39-07:00</authored-date>
  <message>v1.0.4: changed setting check_members from y/n to array of member groups to check</message>
  <tree>d10dce078fd028b1b351625f302de48566c4dcc2</tree>
  <committer>
    <name>Lodewijk Schutte</name>
    <email>lodewijk@gmail.com</email>
  </committer>
</commit>
