Changeset 4512


Ignore:
Timestamp:
Dec 18, 2009, 10:08:21 PM (14 years ago)
Author:
rvelices
Message:

web method images.setPrivacyLevel (ws_images_setPrivacyLevel) is POST only

Location:
branches/2.0
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/ws_functions.inc.php

    r4510 r4512  
    856856    return new PwgError(401, 'Access denied');
    857857  }
     858  if (!$service->isPost())
     859  {
     860    return new PwgError(405, "This method requires HTTP POST");
     861  }
    858862  $params['image_id'] = array_map( 'intval',$params['image_id'] );
    859863  if ( empty($params['image_id']) )
     
    866870    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid level");
    867871  }
     872
    868873  $query = '
    869874UPDATE '.IMAGES_TABLE.'
     
    886891  // type {thumb, file, high}
    887892  // position
    888  
     893
    889894  if (!is_admin() || is_adviser() )
    890895  {
     
    951956  {
    952957    unlink($output_filepath);
    953    
     958
    954959    if (is_file($output_filepath))
    955960    {
     
    958963    }
    959964  }
    960  
     965
    961966  $upload_dir = PHPWG_ROOT_PATH.'upload/buffer';
    962967  $pattern = '/'.$original_sum.'-'.$type.'/';
    963968  $chunks = array();
    964  
     969
    965970  if ($handle = opendir($upload_dir))
    966971  {
     
    983988
    984989  $i = 0;
    985  
     990
    986991  foreach ($chunks as $chunk)
    987992  {
    988993    $string = file_get_contents($chunk);
    989    
     994
    990995    if (function_exists('memory_get_usage')) {
    991996      ws_logfile('[merge_chunks] memory_get_usage on chunk '.++$i.': '.memory_get_usage());
    992997    }
    993    
     998
    994999    if (!file_put_contents($output_filepath, $string, FILE_APPEND))
    9951000    {
     
    9971002      exit();
    9981003    }
    999    
     1004
    10001005    unlink($chunk);
    10011006  }
     
    10151020
    10161021  $upload_dir = dirname($file_path);
    1017  
     1022
    10181023  if (!is_dir($upload_dir)) {
    10191024    umask(0000);
     
    11021107  //
    11031108  $update = array();
    1104  
     1109
    11051110  if ('high' == $params['type'])
    11061111  {
     
    11211126  {
    11221127    $update['id'] = $params['image_id'];
    1123    
     1128
    11241129    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    11251130    mass_updates(
     
    18401845    exit();
    18411846  }
    1842  
     1847
    18431848  $query = '
    18441849SELECT
     
    18581863    exit();
    18591864  }
    1860  
     1865
    18611866  $to_update_cat_ids = array();
    1862    
     1867
    18631868  // in case of replace mode, we first check the existing associations
    18641869  $query = '
     
    18851890    }
    18861891  }
    1887  
     1892
    18881893  $new_cat_ids = array_diff($cat_ids, $existing_cat_ids);
    18891894  if (count($new_cat_ids) == 0)
     
    18911896    return true;
    18921897  }
    1893    
     1898
    18941899  if ($search_current_ranks)
    18951900  {
     
    19151920        $current_rank_of[$cat_id] = 0;
    19161921      }
    1917      
     1922
    19181923      if ('auto' == $rank_on_category[$cat_id])
    19191924      {
     
    19221927    }
    19231928  }
    1924  
     1929
    19251930  $inserts = array();
    1926  
     1931
    19271932  foreach ($new_cat_ids as $cat_id)
    19281933  {
     
    19361941      );
    19371942  }
    1938  
     1943
    19391944  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    19401945  mass_inserts(
     
    19431948    $inserts
    19441949    );
    1945  
     1950
    19461951  update_category($new_cat_ids);
    19471952}
     
    20022007      );
    20032008  }
    2004  
     2009
    20052010}
    20062011
     
    20122017    return true;
    20132018  }
    2014  
     2019
    20152020  file_put_contents(
    20162021    $conf['ws_log_filepath'],
  • branches/2.0/template-common/scripts.js

    r3009 r4512  
    7171}
    7272
     73
     74function blockToggleDisplay(headerId, contentId)
     75{
     76        var revHeader = document.getElementById(headerId);
     77        var revContent = document.getElementById(contentId);
     78
     79        if (revContent.style.display == 'none')
     80        {
     81                revContent.style.display = 'block';
     82                revHeader.className = 'instructionBlockHeaderExpanded';
     83        }
     84        else
     85        {
     86                revContent.style.display = 'none';
     87                revHeader.className = 'instructionBlockHeaderCollapsed';
     88        }
     89}
    7390
    7491
     
    91108};
    92109
    93 function blockToggleDisplay(headerId, contentId)
    94 {
    95   var revHeader = document.getElementById(headerId);
    96   var revContent = document.getElementById(contentId);
    97 
    98   if (revContent.style.display == 'none')
    99   {
    100     revContent.style.display = 'block';
    101     revHeader.className = 'instructionBlockHeaderExpanded';
    102   }
    103   else
    104   {
    105     revContent.style.display = 'none';
    106     revHeader.className = 'instructionBlockHeaderCollapsed';
    107   }
    108 }
    109 
    110110
    111111PwgWS.prototype = {
     
    130130                this.transport.onreadystatechange = this.onStateChange.pwgBind(this);
    131131
    132                 var url = this.urlRoot;
    133                 url += "ws.php?format=json&method="+method;
     132                var url = this.urlRoot+"ws.php?format=json";
     133
     134                var body = "method="+method;
    134135                if (parameters)
    135136                {
     
    139140                                {
    140141                                        for (var i=0; i<parameters[property].length; i++)
    141                                                 url += "&"+property+"[]="+encodeURIComponent(parameters[property][i]);
     142                                                body += "&"+property+"[]="+encodeURIComponent(parameters[property][i]);
    142143                                }
    143144                                else
    144                                         url += "&"+property+"="+encodeURIComponent(parameters[property]);
    145                         }
    146                 }
    147                 this.transport.open(this.options.method, url, this.options.async);
    148                 this.transport.send(null);
     145                                        body += "&"+property+"="+encodeURIComponent(parameters[property]);
     146                        }
     147                }
     148
     149                if (this.options.method == "POST" )
     150                {
     151                        this.transport.open(this.options.method, url, this.options.async);
     152                        this.transport.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     153                        this.transport.send(body);
     154                }
     155                else
     156                {
     157                        url += "&"+body;
     158                        this.transport.open(this.options.method, url, this.options.async);
     159                        this.transport.send(null);
     160                }
    149161        },
    150162
  • branches/2.0/template/yoga/picture.tpl

    r2903 r4512  
    216216        "pwg.images.setPrivacyLevel", {image_id: id, level:level} ,
    217217        {
     218                method: "POST",
    218219                onFailure: function(num, text) { selectElement.disabled = false; alert(num + " " + text); },
    219220                onSuccess: function(result) { selectElement.disabled = false; }
  • branches/2.0/ws.php

    r4459 r4512  
    137137      'level' => array('maxValue'=>$conf['available_permission_levels']),
    138138      ),
    139     'sets the privacy levels for the images'
     139    'sets the privacy levels for the images (POST method only)'
    140140    );
    141141
     
    279279    array(
    280280      'image_id' => array(),
    281      
     281
    282282      'name' => array('default' => null),
    283283      'author' => array('default' => null),
     
    298298<br/><b>multiple_value_mode</b> can be "append" (no change on existing values, add the new values) or "replace" and applies to multiple values properties like tag_ids/categories'
    299299    );
    300  
     300
    301301  $service->addMethod(
    302302    'pwg.categories.setInfo',
     
    304304    array(
    305305      'category_id' => array(),
    306      
     306
    307307      'name' => array('default' => null),
    308308      'comment' => array('default' => null),
Note: See TracChangeset for help on using the changeset viewer.