Index: /extensions/rv_autocomplete/admin/custom.php
===================================================================
--- /extensions/rv_autocomplete/admin/custom.php	(revision 27563)
+++ /extensions/rv_autocomplete/admin/custom.php	(revision 27564)
@@ -5,5 +5,5 @@
 ORDER BY name';
 
-$suggestions = array_from_query($query);
+$suggestions = query2array($query);
 
 $roots = rvac_get_url_roots();
@@ -12,4 +12,14 @@
 
 $template->assign('suggestions', $suggestions);
+foreach ($conf['available_permission_levels'] as $level)
+{
+	if (0 == $level)
+		$label = l10n('Everybody');
+	else
+		$label = l10n( sprintf('Level %d', $level) );
+	$options[$level] = $label;
+}
+$template->assign('available_permission_levels', $options);
+
 $template->assign('RVAC_ID', RVAC_ID);
 ?>
Index: /extensions/rv_autocomplete/admin/custom.tpl
===================================================================
--- /extensions/rv_autocomplete/admin/custom.tpl	(revision 27563)
+++ /extensions/rv_autocomplete/admin/custom.tpl	(revision 27564)
@@ -28,4 +28,17 @@
 <td>
 	<input id="ac_counter" type="text" size="3">
+</td>
+</tr>
+
+<tr>
+<td>
+<label for=ac_level>{'Privacy level'|@translate}:</label>
+</td>
+<td>
+	<select id="ac_level"> 
+	{foreach $available_permission_levels as $level=>$label}
+		<option value="{$level}">{$label}</option>
+	{/foreach}
+	</select>
 </td>
 </tr>
@@ -54,8 +67,9 @@
 <thead>
 <tr class="throw">
-<th>{'Name'|@translate}</th>
-<th>{'Weight'|@translate}</th>
-<th>{'URL'|@translate}</th>
-<th>{'Actions'|@translate}</th>
+<th class="dtc_Name">{'Name'|@translate}</th>
+<th class="dtc_Weight">{'Weight'|@translate}</th>
+<th class="dtc_Level">{'Privacy level'|@translate}</th>
+<th class="dtc_Url">{'URL'|@translate}</th>
+<th class="dtc_Actions">{'Actions'|@translate}</th>
 </tr>
 </thead>
@@ -110,37 +124,5 @@
 
 {footer_script}
-var iniDatas = [
-{foreach from=$suggestions item=s name=sloop}
-{ldelim}id:{$s.id},name:"{$s.name|@escape:javascript}",counter:{$s.counter},url:"{$s.url|@escape:javascript}",U_LINK:"{$s.U_LINK|@escape:javascript}"{rdelim}{if !$smarty.foreach.sloop.last},{/if}
-{/foreach}
-];
-var SHelper = {ldelim}
-{literal}
-
-buildRowData: function(item) {
-	var rowData = [];
-	rowData.push(item.name);
-	rowData.push(item.counter);
-	rowData.push( "<a href=\""+item.U_LINK+"\" onclick=\"return SHelper.zoom(this.href)\">"
-		+ (item.url ? item.url : "show" )
-		+ "</a>"
-	);
-	rowData.push("<a href=\"\" onclick=\"return SHelper.del(this)\">Delete</a>"
-		+ " <a href=\"\" onclick=\"return SHelper.edit(this)\">Edit</a>"
-	);
-	return rowData;
-},
-
-buildRow: function(item) {
-	var rd = SHelper.buildRowData(item)
-	 , row = "<tr>";
-	 
-	for (var i =0; i<rd.length; i++)
-		row += "<td>"+rd[i]+"</td>";
-
-	row += "</tr>";
-
-	return $(row).data("ac", item)
-},
+var SHelper = {
 
 rowFromNode: function(node) {
@@ -160,14 +142,13 @@
 	if (!confirm("Are you sure?")) return false;
 	var row = SHelper.rowFromNode(node)
-		, item=row.data("ac");
+		, item=dataTable.fnGetData(row[0]);
 		
 	row.fadeTo(500, 0.4);
 	(new PwgWS("")).callService(
-		"rvac.delCustom", {id: item.id} ,
+		"rvac.delCustom", { id: item.id},
 		{
 			method: "POST",
 			onFailure: function(num, text) { row.stop(); row.fadeTo(0,1); alert(num + " " + text); },
 			onSuccess: function(result) { 
-				// row.remove();
 				dataTable.fnDeleteRow( row[0] );
 			}
@@ -180,8 +161,9 @@
 add: function() {
 	$("#ac_name,#ac_counter,#ac_url").val( "" );
+	$("#ac_level").val("0");
 	$("#acFormContainer")
-		.dialog("option", "buttons", [{text: "Create", click: function() {
+		.dialog("option", "buttons", [{ text: "Create", click: function() {
 				(new PwgWS("")).callService(
-					"rvac.addCustom", { name:$("#ac_name").val(), counter:$("#ac_counter").val(), url:$("#ac_url").val() },
+					"rvac.addCustom", { name:$("#ac_name").val(), counter:$("#ac_counter").val(), level:$("#ac_level").val(), url:$("#ac_url").val() },
 					{
 						method: "POST",
@@ -190,9 +172,5 @@
 						},
 						onSuccess: function(result) {
-							//$("#csTable").append( SHelper.buildRow(result) );
-							var rd = SHelper.buildRowData(result);
-							var node = dataTable.fnGetNodes( dataTable.fnAddData(rd)[0] );
-							$(node).data("ac", result);
-
+							dataTable.fnAddData(result);
 							$("#ac_name,#ac_counter,#ac_url").val( "" );
 						}
@@ -206,14 +184,15 @@
 edit: function(node) {
 	var row = SHelper.rowFromNode(node)
-		, item=row.data("ac");
+		, item=dataTable.fnGetData(row[0]);
 
 	$("#ac_name").val( item.name );
 	$("#ac_counter").val( item.counter );
+	$("#ac_level").val( item.level );
 	$("#ac_url").val( item.url );
 
 	$("#acFormContainer")
-		.dialog("option", "buttons", [{text: "Modify", click: function() {
+		.dialog("option", "buttons", [{ text: "Modify", click: function() {
 				(new PwgWS("")).callService(
-					"rvac.modCustom", {id: item.id, name:$("#ac_name").val(), counter:$("#ac_counter").val(), url:$("#ac_url").val() },
+					"rvac.modCustom", { id: item.id, name:$("#ac_name").val(), counter:$("#ac_counter").val(), level:$("#ac_level").val(), url:$("#ac_url").val() },
 					{
 						method: "POST",
@@ -222,10 +201,5 @@
 						},
 						onSuccess: function(result) {
-							/*row.after( SHelper.buildRow(result) )
-								.remove();*/
-
-							dataTable.fnUpdate(SHelper.buildRowData(result), row[0]);
-							row.data("ac", result);
-
+							dataTable.fnUpdate(result, row[0]);
 							$("#acFormContainer").dialog("close");
 						}
@@ -242,13 +216,53 @@
 $().ready( function() {
 	var table = $("#csTable");
-	$.each(iniDatas, function(i, item) {
-		table.append( SHelper.buildRow(item) );
-	});
 	dataTable = table.dataTable( {
 		sDom : '<"dtBar"filp>rt<"dtBar"ilp>',
 		iDisplayLength: 100,
-		aoColumnDefs: [
-			{ bSearchable: false, aTargets: [1,3] },
-			{ bSortable: false, aTargets: [3] }
+		aaData: [{foreach from=$suggestions item=s name=sloop}
+{ldelim}id:{$s.id},name:"{$s.name|@escape:javascript}",counter:{$s.counter},level:{$s.level},url:"{$s.url|@escape:javascript}",U_LINK:"{$s.U_LINK|@escape:javascript}"{rdelim}{if !$smarty.foreach.sloop.last},{/if}
+{/foreach}
+],
+		aoColumnDefs: [ {
+				aTargets: ["dtc_Name"],
+				mData: function(item) {
+					return item.name;
+				}
+			},{
+				aTargets: ["dtc_Weight"],
+				bSearchable: false,
+				mData: function(item) {
+					return item.counter;
+				}
+			},{
+				aTargets: ["dtc_Level"],
+				mData: function(item, type) {
+					if ("sort"===type)
+						return item.level;
+					switch (item.level) {
+					{foreach $available_permission_levels as $level=>$label}
+						case {$level}:
+						case "{$level}":
+							return "{$label|escape:'javascript'}";
+					{/foreach}
+					}
+					return item.level;
+				}
+			},{
+				aTargets: ["dtc_Url"],
+				bSearchable: false,
+				mData: function(item) {
+					return "<a href=\""+item.U_LINK+"\" onclick=\"return SHelper.zoom(this.href)\">"
+						+ (item.url ? item.url : "show" )
+						+ "</a>"
+				}
+			},{
+				aTargets: ["dtc_Actions"],
+				bSearchable: false,
+				bSortable: false,
+				mData: function(item) {
+					return "<a href=\"\" onclick=\"return SHelper.del(this)\">Delete</a>"
+						+ " <a href=\"\" onclick=\"return SHelper.edit(this)\">Edit</a>"
+				}
+			}
 		],
 		asStripeClasses: ["row1", "row2"],
@@ -273,4 +287,3 @@
 	);
 });
-{/literal}
 {/footer_script}
Index: /extensions/rv_autocomplete/admin/exclude.php
===================================================================
--- /extensions/rv_autocomplete/admin/exclude.php	(revision 27563)
+++ /extensions/rv_autocomplete/admin/exclude.php	(revision 27564)
@@ -29,5 +29,5 @@
   GROUP BY id
   ORDER BY global_rank';
-$albums = array_from_query($query);
+$albums = query2array($query);
 usort($albums, 'global_rank_compare');
 
@@ -40,5 +40,5 @@
   GROUP BY id
   ORDER BY url_name';
-$tags = array_from_query($query);
+$tags = query2array($query);
 $tags_select = array();
 foreach($tags as $tag)
Index: /extensions/rv_autocomplete/admin/functions.inc.php
===================================================================
--- /extensions/rv_autocomplete/admin/functions.inc.php	(revision 27563)
+++ /extensions/rv_autocomplete/admin/functions.inc.php	(revision 27564)
@@ -48,13 +48,15 @@
 function rvac_ws_add_methods($srv_arr)
 {
+	global $conf;
   $srv = $srv_arr[0];
   include_once( dirname(__FILE__).'/../functions.inc.php' );
   $srv->addMethod('rvac.addCustom', 'rv_ac_ws_add_custom_suggestion',
     array(
-      'name' => array(),
-      'counter' => array('default'=>0),
-      'url' => array('default'=>''),
+			'name' => array(),
+			'counter' => array('default'=>0),
+			'url' => array('default'=>''),
+			'level' => array('default'=>min($conf['available_permission_levels']), 'maxValue'=>max($conf['available_permission_levels']),'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
     ),
-    '');
+    '','', array('admin_only'=>true, 'post_only'=>true));
 
   $srv->addMethod('rvac.modCustom', 'rv_ac_ws_mod_custom_suggestion',
@@ -64,18 +66,15 @@
       'counter' => array('flags' => WS_PARAM_OPTIONAL),
       'url' => array('flags' => WS_PARAM_OPTIONAL),
+			'level' => array('flags' => WS_PARAM_OPTIONAL, 'maxValue'=>max($conf['available_permission_levels']),'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
     ),
-    '');
+    '','', array('admin_only'=>true, 'post_only'=>true));
 
   $srv->addMethod('rvac.delCustom', 'rv_ac_ws_del_custom_suggestion',
     array('id'),
-    '');
+    '','', array('admin_only'=>true, 'post_only'=>true));
 }
 
 function rv_ac_ws_add_custom_suggestion($params, $service)
 {
-  global $conf;
-  if (!is_admin() || !$service->isPost())
-    return new PwgError(403, 'post admin');
-
   $name = trim($params['name']);
   if (empty($name))
@@ -88,4 +87,6 @@
   if ( !empty($params['url']) )
     $insert['url'] = $params['url'];
+  if ( isset($params['level']) )
+    $insert['level'] = $params['level'];
 
   mass_inserts(RVAC_SUGGESTIONS, array_keys($insert), array($insert));
@@ -100,7 +101,4 @@
 function rv_ac_ws_mod_custom_suggestion($params, $service)
 {
-  global $conf;
-  if (!is_admin() || !$service->isPost())
-    return new PwgError(403, 'post admin');
   $id = intval($params['id']);
   $update = array();
@@ -112,4 +110,6 @@
   if (isset($params['url']))
     $update['url'] = $params['url'];
+  if ( isset($params['level']) )
+    $update['level'] = $params['level'];
 
   single_update(RVAC_SUGGESTIONS,
@@ -129,8 +129,4 @@
 function rv_ac_ws_del_custom_suggestion($params, $service)
 {
-  global $conf;
-  if (!is_admin() || !$service->isPost())
-    return new PwgError(403, 'post admin');
-
   $id = intval($params['id']);
   $q = 'DELETE FROM '.RVAC_SUGGESTIONS.' WHERE id='.$id;
Index: /extensions/rv_autocomplete/functions.inc.php
===================================================================
--- /extensions/rv_autocomplete/functions.inc.php	(revision 27563)
+++ /extensions/rv_autocomplete/functions.inc.php	(revision 27564)
@@ -76,5 +76,5 @@
   if ( !empty($rvac_conf['excluded_tags']) )
     $query .= ' WHERE id NOT IN ('.implode(',',$rvac_conf['excluded_tags']).')';
-  $tag_names = simple_hash_from_query($query, 'id','name');
+  $tag_names = query2array($query, 'id','name');
 
   $url_len = strlen( $roots['t'] );
@@ -105,5 +105,5 @@
   }
 
-  $query = 'SELECT name,counter,url FROM '.RVAC_SUGGESTIONS;
+  $query = 'SELECT name,counter,url FROM '.RVAC_SUGGESTIONS.' WHERE level<='.$user['level'];
   $result = pwg_query($query);
   while ($row = pwg_db_fetch_assoc($result))
Index: /extensions/rv_autocomplete/main.inc.php
===================================================================
--- /extensions/rv_autocomplete/main.inc.php	(revision 27563)
+++ /extensions/rv_autocomplete/main.inc.php	(revision 27564)
@@ -1,5 +1,5 @@
 <?php /*
 Plugin Name: RV autocomplete
-Version: 2.6.a
+Version: 2.6.b
 Description: Autocompletes the quick search with albums, tags or custom suggestions
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=694
