merge -r4512 from branch 2.0 to trunk
web method images.setPrivacyLevel (ws_images_setPrivacyLevel) is POST only git-svn-id: http://piwigo.org/svn/trunk@4513 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
975188d088
commit
8c051ea526
5 changed files with 46 additions and 28 deletions
|
|
@ -54,11 +54,11 @@ class Calendar extends CalendarBase
|
||||||
'labels' => null
|
'labels' => null
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'sql'=> pwg_db_get_week($this->date_field)+1,
|
'sql'=> pwg_db_get_week($this->date_field).'+1',
|
||||||
'labels' => $week_no_labels,
|
'labels' => $week_no_labels,
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'sql'=> pwg_db_get_dayofweek($this->date_field)-1,
|
'sql'=> pwg_db_get_dayofweek($this->date_field).'-1',
|
||||||
'labels' => $lang['day']
|
'labels' => $lang['day']
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -855,6 +855,10 @@ function ws_images_setPrivacyLevel($params, &$service)
|
||||||
{
|
{
|
||||||
return new PwgError(401, 'Access denied');
|
return new PwgError(401, 'Access denied');
|
||||||
}
|
}
|
||||||
|
if (!$service->isPost())
|
||||||
|
{
|
||||||
|
return new PwgError(405, "This method requires HTTP POST");
|
||||||
|
}
|
||||||
$params['image_id'] = array_map( 'intval',$params['image_id'] );
|
$params['image_id'] = array_map( 'intval',$params['image_id'] );
|
||||||
if ( empty($params['image_id']) )
|
if ( empty($params['image_id']) )
|
||||||
{
|
{
|
||||||
|
|
@ -865,6 +869,7 @@ function ws_images_setPrivacyLevel($params, &$service)
|
||||||
{
|
{
|
||||||
return new PwgError(WS_ERR_INVALID_PARAM, "Invalid level");
|
return new PwgError(WS_ERR_INVALID_PARAM, "Invalid level");
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = '
|
$query = '
|
||||||
UPDATE '.IMAGES_TABLE.'
|
UPDATE '.IMAGES_TABLE.'
|
||||||
SET level='.(int)$params['level'].'
|
SET level='.(int)$params['level'].'
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,9 @@ PwgWS.prototype = {
|
||||||
}
|
}
|
||||||
this.transport.onreadystatechange = this.onStateChange.pwgBind(this);
|
this.transport.onreadystatechange = this.onStateChange.pwgBind(this);
|
||||||
|
|
||||||
var url = this.urlRoot;
|
var url = this.urlRoot+"ws.php?format=json";
|
||||||
url += "ws.php?format=json&method="+method;
|
|
||||||
|
var body = "method="+method;
|
||||||
if (parameters)
|
if (parameters)
|
||||||
{
|
{
|
||||||
for (var property in parameters)
|
for (var property in parameters)
|
||||||
|
|
@ -120,14 +121,25 @@ PwgWS.prototype = {
|
||||||
if ( typeof parameters[property] == 'object' && parameters[property])
|
if ( typeof parameters[property] == 'object' && parameters[property])
|
||||||
{
|
{
|
||||||
for (var i=0; i<parameters[property].length; i++)
|
for (var i=0; i<parameters[property].length; i++)
|
||||||
url += "&"+property+"[]="+encodeURIComponent(parameters[property][i]);
|
body += "&"+property+"[]="+encodeURIComponent(parameters[property][i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
url += "&"+property+"="+encodeURIComponent(parameters[property]);
|
body += "&"+property+"="+encodeURIComponent(parameters[property]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.transport.open(this.options.method, url, this.options.async);
|
|
||||||
this.transport.send(null);
|
if (this.options.method == "POST" )
|
||||||
|
{
|
||||||
|
this.transport.open(this.options.method, url, this.options.async);
|
||||||
|
this.transport.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
this.transport.send(body);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
url += "&"+body;
|
||||||
|
this.transport.open(this.options.method, url, this.options.async);
|
||||||
|
this.transport.send(null);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onStateChange: function() {
|
onStateChange: function() {
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,7 @@ var y = new PwgWS(rootUrl);
|
||||||
y.callService(
|
y.callService(
|
||||||
"pwg.images.setPrivacyLevel", {image_id: id, level:level} ,
|
"pwg.images.setPrivacyLevel", {image_id: id, level:level} ,
|
||||||
{
|
{
|
||||||
|
method: "POST",
|
||||||
onFailure: function(num, text) { selectElement.disabled = false; alert(num + " " + text); },
|
onFailure: function(num, text) { selectElement.disabled = false; alert(num + " " + text); },
|
||||||
onSuccess: function(result) { selectElement.disabled = false; }
|
onSuccess: function(result) { selectElement.disabled = false; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
ws.php
2
ws.php
|
|
@ -136,7 +136,7 @@ function ws_addDefaultMethods( $arr )
|
||||||
'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY),
|
'image_id' => array('flags'=>WS_PARAM_FORCE_ARRAY),
|
||||||
'level' => array('maxValue'=>$conf['available_permission_levels']),
|
'level' => array('maxValue'=>$conf['available_permission_levels']),
|
||||||
),
|
),
|
||||||
'sets the privacy levels for the images'
|
'sets the privacy levels for the images (POST method only)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$service->addMethod('pwg.session.getStatus', 'ws_session_getStatus', null, '' );
|
$service->addMethod('pwg.session.getStatus', 'ws_session_getStatus', null, '' );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue