Changeset 27038


Ignore:
Timestamp:
01/29/14 16:17:51 (6 years ago)
Author:
plg
Message:

2.6 compatibility: bug fixed on album creation and all "admin_only" methods.
This option was added in Piwigo 2.6 and disturbs the hack in Community that
gives "admin" status to users with upload permission when calling specific
API methods.

Discussion in progress to implement this hack in a cleaner way.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/main.inc.php

    r26592 r27038  
    207207 
    208208 
    209 add_event_handler('ws_invoke_allowed', 'community_switch_user_to_admin', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); 
    210 function community_switch_user_to_admin($res, $methodName, $params) 
     209add_event_handler('ws_add_methods', 'community_switch_user_to_admin', EVENT_HANDLER_PRIORITY_NEUTRAL+5); 
     210function community_switch_user_to_admin($arr) 
    211211{ 
    212212  global $user, $community; 
    213213 
     214  $service = &$arr[0]; 
     215 
    214216  if (is_admin()) 
    215217  { 
    216     return $res; 
    217   } 
    218    
    219   $community = array('method' => $methodName); 
     218    return; 
     219  } 
     220   
     221  $community = array('method' => $_REQUEST['method']); 
    220222 
    221223  if ('pwg.images.addSimple' == $community['method']) 
    222224  { 
    223     $community['category'] = $params['category']; 
     225    $community['category'] = $_REQUEST['category']; 
    224226  } 
    225227  elseif ('pwg.images.add' == $community['method']) 
    226228  { 
    227     $community['category'] = $params['categories']; 
    228     $community['md5sum'] = $params['original_sum']; 
     229    $community['category'] = $_REQUEST['categories']; 
     230    $community['md5sum'] = $_REQUEST['original_sum']; 
    229231  } 
    230232 
     
    239241  if (count($user_permissions['upload_categories']) == 0 and !$user_permissions ['create_whole_gallery']) 
    240242  { 
    241     return $res; 
     243    return; 
    242244  } 
    243245 
     
    254256  $methods[] = 'pwg.images.setInfo'; 
    255257 
    256   if (in_array($methodName, $methods)) 
     258  if (in_array($community['method'], $methods)) 
    257259  { 
    258260    $user['status'] = 'admin'; 
    259261  } 
    260262 
    261   if ('pwg.categories.add' == $methodName) 
    262   { 
    263     if (in_array($params['parent'], $user_permissions['create_categories']) 
     263  if ('pwg.categories.add' == $community['method']) 
     264  { 
     265    if (in_array($_REQUEST['parent'], $user_permissions['create_categories']) 
    264266        or $user_permissions['create_whole_gallery']) 
    265267    { 
     
    268270  } 
    269271 
    270   return $res; 
     272  return; 
    271273} 
    272274 
Note: See TracChangeset for help on using the changeset viewer.