Ignore:
Timestamp:
Mar 5, 2014, 10:44:34 PM (11 years ago)
Author:
rvelices
Message:

autocomplete - privacy level for custom suggestions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_autocomplete/admin/functions.inc.php

    r22201 r27564  
    4848function rvac_ws_add_methods($srv_arr)
    4949{
     50        global $conf;
    5051  $srv = $srv_arr[0];
    5152  include_once( dirname(__FILE__).'/../functions.inc.php' );
    5253  $srv->addMethod('rvac.addCustom', 'rv_ac_ws_add_custom_suggestion',
    5354    array(
    54       'name' => array(),
    55       'counter' => array('default'=>0),
    56       'url' => array('default'=>''),
     55                        'name' => array(),
     56                        'counter' => array('default'=>0),
     57                        'url' => array('default'=>''),
     58                        'level' => array('default'=>min($conf['available_permission_levels']), 'maxValue'=>max($conf['available_permission_levels']),'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
    5759    ),
    58     '');
     60    '','', array('admin_only'=>true, 'post_only'=>true));
    5961
    6062  $srv->addMethod('rvac.modCustom', 'rv_ac_ws_mod_custom_suggestion',
     
    6466      'counter' => array('flags' => WS_PARAM_OPTIONAL),
    6567      'url' => array('flags' => WS_PARAM_OPTIONAL),
     68                        'level' => array('flags' => WS_PARAM_OPTIONAL, 'maxValue'=>max($conf['available_permission_levels']),'type'=>WS_TYPE_INT|WS_TYPE_POSITIVE),
    6669    ),
    67     '');
     70    '','', array('admin_only'=>true, 'post_only'=>true));
    6871
    6972  $srv->addMethod('rvac.delCustom', 'rv_ac_ws_del_custom_suggestion',
    7073    array('id'),
    71     '');
     74    '','', array('admin_only'=>true, 'post_only'=>true));
    7275}
    7376
    7477function rv_ac_ws_add_custom_suggestion($params, $service)
    7578{
    76   global $conf;
    77   if (!is_admin() || !$service->isPost())
    78     return new PwgError(403, 'post admin');
    79 
    8079  $name = trim($params['name']);
    8180  if (empty($name))
     
    8887  if ( !empty($params['url']) )
    8988    $insert['url'] = $params['url'];
     89  if ( isset($params['level']) )
     90    $insert['level'] = $params['level'];
    9091
    9192  mass_inserts(RVAC_SUGGESTIONS, array_keys($insert), array($insert));
     
    100101function rv_ac_ws_mod_custom_suggestion($params, $service)
    101102{
    102   global $conf;
    103   if (!is_admin() || !$service->isPost())
    104     return new PwgError(403, 'post admin');
    105103  $id = intval($params['id']);
    106104  $update = array();
     
    112110  if (isset($params['url']))
    113111    $update['url'] = $params['url'];
     112  if ( isset($params['level']) )
     113    $update['level'] = $params['level'];
    114114
    115115  single_update(RVAC_SUGGESTIONS,
     
    129129function rv_ac_ws_del_custom_suggestion($params, $service)
    130130{
    131   global $conf;
    132   if (!is_admin() || !$service->isPost())
    133     return new PwgError(403, 'post admin');
    134 
    135131  $id = intval($params['id']);
    136132  $q = 'DELETE FROM '.RVAC_SUGGESTIONS.' WHERE id='.$id;
Note: See TracChangeset for help on using the changeset viewer.