ftp_user_list

Versions
mediamosa-174
ftp_user_list($a_args)

Code

ftp_users/ftp_users.module, line 31

<?php
function ftp_user_list($a_args) {
  $a_parameters = array(
    'app_id' => array(
      'value' => vpx_get_parameter_2($a_args['get'], 'app_id'),
      'type' => 'int',
      'required' => TRUE,
    ),
  );

  // valideer alle parameters op aanwezigheid en type
  $result = vpx_validate($a_parameters);
  if (vpx_check_result_for_error($result)) {
    return new rest_response($result);
  }

  // controleer of de webservice aan staat
  if (!vpx_shared_webservice_is_active('batch_upload', $a_parameters['app_id']['value'])) {
    return new rest_response(vpx_return_error(ERRORCODE_WEBSERVICE_DISABLED));
  }

  $result = new rest_response(
    array(
      "id"          => ERRORCODE_OKAY,
      "status"      => ERRORMESSAGE_OKAY,
      "description" => "FTP users")
  );

  db_set_active("ftp");
  $resultset = db_query("select * from {ftpuser} where eua_id='%d'", (int) $a_parameters['app_id']['value']);
  if (!$resultset) {
    $result = new rest_response(vpx_return_error(ERRORCODE_FTP_ERROR));
  }
  else {
    while ($a_user = db_fetch_array($resultset)) {
      $result->add_item(
        array(
          "userid" => $a_user['userid'],
          "active" => intval($a_user['active']) ? 'true' : 'false',
          "modified" => $a_user['modified'],
        )
      );
    }
  }

  db_set_active();

  return $result;
}
?>