18 require_once SQ_PACKAGES_PATH.
'/web_services/api/soap_api/soap_api.inc';
43 parent::__construct($assetid);
59 'GetPermission' =>
'1',
61 'SetPermission' =>
'1',
84 $request_info = (Array) $request;
85 $assetid = array_get_index($request_info,
'AssetID',
'');
86 $access_level = $this->array_get_index_restricted_value($request_info,
'PermissionLevel',
'');
88 if (!empty($assetid) && !empty($access_level)) {
89 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
90 $access_func_call = strtolower($access_level).
"Access";
91 $access = $asset->$access_func_call();
93 'HasAccessResult' => (
bool) $access,
96 throw new SoapFault(
'Server',
'Asset ID or Access Level is not valid. Please provide a valid AssetID and Access Level');
121 $request_info = (Array) $request;
122 $assetid = array_get_index($request_info,
'AssetID',
'');
123 $userid = array_get_index($request_info,
'UserID',
'');
124 $permission = $this->array_get_index_restricted_value($request_info,
'PermissionLevel',
'');
125 $cascade = self::getBooleanIndex($request_info,
'Cascade', TRUE);
126 $grant = $this->array_get_index_restricted_value($request_info,
'Grant',
'');
127 $grant_level = Array (
133 $grant_val = $grant_level[$grant];
134 $perm_level = self::getPermValue($permission);
135 $auto_cascade = array_get_index($request_info,
'Cascade',
'1');
137 if (!empty($assetid) && !empty($userid) && !empty($permission)) {
138 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
139 $running_vars = Array (
140 'permission_changes' => Array (
142 'assetids' => Array ( $assetid),
143 'granted' => $grant_val,
144 'permission' => $perm_level,
146 'cascades' => $auto_cascade,
147 'previous_access' => NULL,
148 'dependants_only' => !($cascade && $auto_cascade),
152 $errors = $hh->freestyleHipo(
'hipo_job_edit_permissions', $running_vars);
153 if (empty($errors)) {
155 'SetPermissionResult' => TRUE,
158 throw new SoapFault(
'Server',
'Unable to set Permission on Asset');
161 throw new SoapFault(
'Server',
'Asset ID or Permission Level or User ID is not valid');
186 $request_info = (Array) $request;
187 $assetid = array_get_index($request_info,
'AssetID',
'');
188 $perm_level = $this->array_get_index_restricted_value($request_info,
'PermissionLevel',
'');
189 $granted = self::getNullIndex($request_info,
'Granted', NULL);
190 $and_greater = self::getBooleanIndex($request_info,
'AndGreater', FALSE);
191 $expand_groups = self::getBooleanIndex($request_info,
'ExpandGroups', FALSE);
192 $all_info = self::getBooleanIndex($request_info,
'AllInfo', FALSE);
193 $collapse_roles = self::getBooleanIndex($request_info,
'CollapseRoles', FALSE);
195 $perm_level = self::getPermValue($perm_level);
196 if (!empty($assetid) && !empty($perm_level)) {
197 $permission_list = $GLOBALS[
'SQ_SYSTEM']->am->getPermission($assetid, $perm_level, $granted, $and_greater, $expand_groups, $all_info, $collapse_roles);
198 $final_result = Array();
200 foreach ($permission_list as $key => $value) {
202 $final_result[$i][
'UserID'] = $key;
203 $final_result[$i][
'Grant'] = $value;
205 $final_result[$i][
'UserID'] = $value;
210 'GetPermissionResult' => $final_result,
213 throw new SoapFault(
'Server',
'Asset ID or Access Level is not valid. Please provide a valid AssetID and Access Level');
240 $request_info = (Array) $request;
241 $assetid = self::getNullIndex($request_info,
'AssetID', NULL);
242 $roleid = self::getNullIndex($request_info,
'RoleID', NULL);
243 $userid = self::getNullIndex($request_info,
'UserID', NULL);
244 $include_assetid = self::getBooleanIndex($request_info,
'IncludeAssetID', FALSE);
245 $include_globals = self::getBooleanIndex($request_info,
'IncludeGlobals', FALSE);
246 $include_dependants = self::getBooleanIndex($request_info,
'IncludeDependants', TRUE);
247 $expand_groups = self::getBooleanIndex($request_info,
'ExpandGroups', FALSE);
249 $role_list = $GLOBALS[
'SQ_SYSTEM']->am->getRole($assetid, $roleid, $userid, $include_assetid, $include_globals, $expand_groups, $include_dependants);
250 $role_list_result = Array();
253 foreach ($role_list as $role_id => $user_info) {
254 if ($include_assetid) {
255 foreach ($user_info as $userid => $assetid_info) {
256 $role_list_result[$i][
'RoleID'] = $role_id;
257 $role_list_result[$i][
'UserID'] = $userid;
258 $role_list_result[$i][
'AssetID'] = $assetid_info[0];
262 if (count($user_info > 1)) {
263 foreach ($user_info as $index => $userid) {
264 $role_list_result[$i][
'RoleID'] = $role_id;
265 $role_list_result[$i][
'UserID'] = $userid;
269 $role_list_result[$i][
'RoleID'] = $role_id;
270 $role_list_result[$i][
'UserID'] = $user_info[0];
277 'GetRoleResult' => $role_list_result,
303 $request_info = (Array) $request;
304 $assetid = self::getNullIndex($request_info,
'AssetID', NULL);
305 $roleid = self::getNullIndex($request_info,
'RoleID', NULL);
306 $userid = self::getNullIndex($request_info,
'UserID', NULL);
307 $action = self::getNullIndex($request_info,
'Action', NULL);
308 $global_role = self::getBooleanIndex($request_info,
'GlobalRole', FALSE);
309 $cascade = self::getBooleanIndex($request_info,
'Cascade', TRUE);
311 if (!empty($assetid) && !empty($roleid)) {
312 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
313 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
314 $action = strtolower($action);
318 if ($userid === NULL) {
319 throw new SoapFault(
'Server',
'Please Provide User ID');
323 $user = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($userid);
324 if (!($user instanceof
User)) {
325 throw new SoapFault(
'Server',
'The provided User ID does not belong to a User');
330 if ($roleid === NULL) {
331 throw new SoapFault(
'Server',
'Please Provide Role ID');
334 $role = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($roleid);
335 if (!($role instanceof
Role)) {
336 throw new SoapFault(
'Server',
'The provided Role ID does not belong to a Role');
340 if ($action ==
'delete') {
342 $user_role = $GLOBALS[
'SQ_SYSTEM']->am->getRole($assetid, $roleid, $userid);
343 if (empty($user_role)) {
344 throw new SoapFault(
'Server',
'No such Role ID #'.$roleid.
' for User ID #'.$userid);
355 $running_vars = Array(
358 'type_code' => $asset->type(),
361 'role_changes' => $role_vars,
364 $errors = $hh->freestyleHipo(
'hipo_job_edit_roles', $running_vars);
365 if (empty($errors)) {
367 'SetRoleResult' => TRUE,
370 throw new SoapFault(
'Server',
'Unable to set Permission on Asset');
373 throw new SoapFault(
'Server',
'Asset ID or Access Level is not valid. Please provide a valid AssetID and Access Level');
379 private static function getPermValue($permission)
381 $perm_level = Array (
387 if (empty($permission) || !isset($perm_level[$permission]))
return NULL;
389 return $perm_level[$permission];
402 $role_details = self::getArgType(
'RoleDetail', 0,
'unbounded');
403 $permission_type = self::getArgType(
'PermissionLevel', 1, 1);
404 $grant_type = self::getArgType(
'Grant', 1, 1);
405 $role_action = self::getArgType(
'RoleActionType', 1, 1);
406 $permission_detail = self::getArgType(
'PermissionDetail', 0,
'unbounded');
408 $complex_types = Array (
409 'HasAccess' => Array (
410 'HasAccess' => Array (
411 'AssetID' => self::$string_non_optional,
412 'PermissionLevel' => $permission_type,
414 'HasAccessResponse' => Array (
415 'HasAccessResult' => self::$boolean_optional,
418 'SetPermission' => Array (
419 'SetPermission' => Array (
420 'AssetID' => self::$string_non_optional,
421 'UserID' => self::$string_non_optional,
422 'PermissionLevel' => $permission_type,
423 'Grant' => $grant_type,
424 'Cascade' => self::$boolean_optional,
426 'SetPermissionResponse' => Array (
427 'SetPermissionResult' => self::$string_optional,
430 'GetPermission' => Array (
431 'GetPermission' => Array (
432 'AssetID' => self::$string_non_optional,
433 'PermissionLevel' => $permission_type,
434 'Granted' => self::$boolean_optional,
435 'AndGreater' => self::$boolean_optional,
436 'ExpandGroups' => self::$boolean_optional,
437 'AllInfo' => self::$boolean_optional,
438 'CollapseRoles' => self::$boolean_optional,
440 'GetPermissionResponse' => Array (
441 'GetPermissionResult' => $permission_detail,
446 'AssetID' => self::$string_optional,
447 'RoleID' => self::$string_optional,
448 'UserID' => self::$string_optional,
449 'IncludeAssetID' => self::$string_optional,
450 'IncludeGlobals' => self::$string_optional,
451 'ExpandGroups' => self::$string_optional,
452 'IncludeDependants' => self::$string_optional,
454 'GetRoleResponse' => Array (
455 'GetRoleResult' => $role_details,
460 'AssetID' => self::$string_non_optional,
461 'RoleID' => self::$string_non_optional,
462 'UserID' => self::$string_optional,
463 'Action' => $role_action,
464 'GlobalRole' => self::$boolean_optional,
466 'SetRoleResponse' => Array (
467 'SetRoleResult' => self::$boolean_optional,
472 $complex_types_available = parent::getComplexElements($complex_types);
474 return $complex_types_available;
489 $complex_types = Array (
491 'RoleDetail' => Array (
492 'RoleID' => self::$string_optional,
493 'UserID' => self::$string_optional,
494 'AssetID' => self::$string_optional,
497 'GetPermission' => Array (
498 'PermissionDetail' => Array (
499 'UserID' => self::$string_optional,
500 'Grant' => self::$string_optional,
505 $complex_types_available = parent::getComplexElements($complex_types);
507 return $complex_types_available;
521 $access_level = Array (
522 'restriction_base' =>
'string',
523 'enumeration' => Array (
524 'Read',
'Write',
'Admin'
527 $simple_restricted_types = Array (
528 'HasAccess' => Array (
529 'PermissionLevel' => $access_level,
531 'SetPermission' => Array (
532 'PermissionLevel' => $access_level,
534 'restriction_base' =>
'string',
535 'enumeration' => Array (
536 'Apply',
'Deny',
'Revoke',
541 'RoleActionType' => Array (
542 'restriction_base' =>
'string',
543 'enumeration' => Array (
550 $simple_restricted_types_available = parent::processSimpleRestrictedTypes($simple_restricted_types);
552 return $simple_restricted_types_available;