diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-10-28 19:17:36 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-10-28 19:17:36 +0000 |
commit | 7ddd9521b3f3a397da3b0a6b56238d31414eb4be (patch) | |
tree | 6eb6a9a51db5fa0f5d3cc2ec6de29b9e258b12a1 /services | |
parent | bd3484417d170e62bc94e9db81d4ad37e8ddee6a (diff) | |
download | elgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.gz elgg-7ddd9521b3f3a397da3b0a6b56238d31414eb4be.tar.bz2 |
Standardized code in all of core, not including language files, tests, or core mods.
git-svn-id: http://code.elgg.org/elgg/trunk@7124 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'services')
-rw-r--r-- | services/api/rest_api.php | 10 | ||||
-rw-r--r-- | services/export/handler.php | 34 |
2 files changed, 24 insertions, 20 deletions
diff --git a/services/api/rest_api.php b/services/api/rest_api.php index 9665c16d3..d5f2d9734 100644 --- a/services/api/rest_api.php +++ b/services/api/rest_api.php @@ -15,10 +15,10 @@ global $CONFIG; // Register the error handler error_reporting(E_ALL); -set_error_handler('__php_api_error_handler'); +set_error_handler('_php_api_error_handler'); // Register a default exception handler -set_exception_handler('__php_api_exception_handler'); +set_exception_handler('_php_api_exception_handler'); // Check to see if the api is available if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true)) { @@ -26,7 +26,7 @@ if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true)) { } // plugins should return true to control what API and user authentication handlers are registered -if (trigger_plugin_hook('rest', 'init', null, false) == false) { +if (trigger_plugin_hook('rest', 'init', null, false) == false) { // for testing from a web browser, you can use the session PAM // do not use for production sites!! //register_pam_handler('pam_auth_session'); @@ -34,9 +34,9 @@ if (trigger_plugin_hook('rest', 'init', null, false) == false) { // user token can also be used for user authentication register_pam_handler('pam_auth_usertoken'); - // simple API key check + // simple API key check register_pam_handler('api_auth_key', "sufficient", "api"); - // hmac + // hmac register_pam_handler('api_auth_hmac', "sufficient", "api"); } diff --git a/services/export/handler.php b/services/export/handler.php index d51db7982..33f4c2ac5 100644 --- a/services/export/handler.php +++ b/services/export/handler.php @@ -13,7 +13,8 @@ require_once("../../engine/start.php"); // Get input values, these will be mapped via modrewrite $guid = get_input("guid"); // guid of the entity -// For attributes eg http://example.com/odd/73/attr/owner_uuid/ or http://example.com/odd/73/metadata/86/ +// For attributes eg http://example.com/odd/73/attr/owner_uuid/ +// or http://example.com/odd/73/metadata/86/ $type = get_input("type"); // attr, metadata, annotation, rekationship $id_or_name = get_input("idname"); // Either a number or the key name (if attribute) @@ -21,23 +22,24 @@ $body = ""; $title = ""; // Only export the GUID -if (($guid!="") && ($type=="") && ($id_or_name=="")) { +if (($guid != "") && ($type == "") && ($id_or_name == "")) { $entity = get_entity($guid); if (!$entity) { - throw new InvalidParameterException(sprintf(elgg_echo('InvalidParameterException:GUIDNotFound'), $guid)); + $query = sprintf(elgg_echo('InvalidParameterException:GUIDNotFound'), $guid); + throw new InvalidParameterException($query); } $title = "GUID:$guid"; $body = elgg_view("export/entity", array("entity" => $entity, "uuid" => guid_to_uuid($guid))); -} -// Export an individual attribute -else if (($guid!="") && ($type!="") && ($id_or_name!="")) { + // Export an individual attribute +} else if (($guid != "") && ($type != "") && ($id_or_name != "")) { // Get a uuid $entity = get_entity($guid); if (!$entity) { - throw new InvalidParameterException(sprintf(elgg_echo('InvalidParameterException:GUIDNotFound'), $guid)); + $msg = sprintf(elgg_echo('InvalidParameterException:GUIDNotFound'), $guid); + throw new InvalidParameterException($msg); } $uuid = guid_to_uuid($entity->getGUID()) . "$type/$id_or_name/"; @@ -46,7 +48,8 @@ else if (($guid!="") && ($type!="") && ($id_or_name!="")) { case 'attr' : // @todo: Do this better? - This is a bit of a hack... $v = $entity->get($id_or_name); if (!$v) { - throw new InvalidParameterException(sprintf(elgg_echo('InvalidParameterException:IdNotExistForGUID'), $id_or_name, $guid)); + $msg = sprintf(elgg_echo('InvalidParameterException:IdNotExistForGUID'), $id_or_name, $guid); + throw new InvalidParameterException($msg); } $m = new ElggMetadata(); @@ -70,11 +73,13 @@ else if (($guid!="") && ($type!="") && ($id_or_name!="")) { $r = get_relationship($id_or_name); break; case 'volatile' : - $m = trigger_plugin_hook('volatile', 'metadata', array('guid' => $guid, 'varname' => $id_or_name)); + $m = trigger_plugin_hook('volatile', 'metadata', + array('guid' => $guid, 'varname' => $id_or_name)); break; default : - throw new InvalidParameterException(sprintf(elgg_echo('InvalidParameterException:CanNotExportType'), $type)); + $msg = sprintf(elgg_echo('InvalidParameterException:CanNotExportType'), $type); + throw new InvalidParameterException($msg); } // Render metadata or relationship @@ -84,7 +89,7 @@ else if (($guid!="") && ($type!="") && ($id_or_name!="")) { // Exporting metadata? if ($m) { - if ($m->entity_guid!=$entity->guid) { + if ($m->entity_guid != $entity->guid) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:DoesNotBelong')); } @@ -94,17 +99,16 @@ else if (($guid!="") && ($type!="") && ($id_or_name!="")) { // Exporting relationship if ($r) { - if (($r->guid_one!=$entity->guid) && ($r->guid_two!=$entity->guid)) { + if (($r->guid_one != $entity->guid) && ($r->guid_two != $entity->guid)) { throw new InvalidParameterException(elgg_echo('InvalidParameterException:DoesNotBelongOrRefer')); } $title = "$type:$id_or_name"; $body = elgg_view("export/relationship", array("relationship" => $r, "uuid" => $uuid)); } -} -// Something went wrong -else { + // Something went wrong +} else { throw new InvalidParameterException(elgg_echo('InvalidParameterException:MissingParameter')); } |