Example #1
0
/**
 * Exposes the TheWire functions
 *
 * @return void
 */
function ws_pack_thewire_expose_functions()
{
    expose_function("thewire.post", "my_post_to_wire", array("text" => array("type" => "string", "required" => true), "parent" => array("type" => "int", "required" => false)), 'Post to the wire. 140 characters or less', 'POST', true, true);
    expose_function("thewire.get_wires", "ws_pack_get_wires", array("friends_only" => array("type" => "int", "required" => true)), '', 'GET', true, true);
    expose_function("thewire.get_thread", "ws_pack_get_thread", array("thread_id" => array("type" => "string", "required" => false)), '', 'GET', true, true);
    expose_function("thewire.delete_wire", "ws_pack_delete_wire", array("guid" => array("type" => "int", "required" => true)), '', 'POST', true, true);
}
Example #2
0
/**
 * Exposes the authentication functions
 * 
 * @return void
 */
function ws_pack_auth_expose_functions()
{
    expose_function("auth.get_api_keys", "ws_pack_auth_get_api_keys", array("application_id" => array("type" => "string", "required" => true), "title" => array("type" => "string", "required" => true), "description" => array("type" => "string", "required" => false, "default" => ""), "icon_url" => array("type" => "string", "required" => false, "default" => ""), "application_info" => array("type" => "array", "required" => false, "default" => array())), elgg_echo("ws_pack:api:auth:get_api_keys"), "GET", false, false);
    // reregister login function to allow login by email
    unexpose_function("auth.gettoken");
    expose_function("auth.gettoken", "ws_pack_auth_gettoken", array("username" => array("type" => "string"), "password" => array("type" => "string")), elgg_echo("auth.gettoken"), "POST", false, false);
}
Example #3
0
function elgg_file_viewer_init()
{
    // Registering a new viewtype for output buffer
    elgg_register_viewtype('ob');
    elgg_register_viewtype_fallback('ob');
    // Exposing a function for remote access to non-public files
    expose_function('efv.download', 'elgg_file_viewer_download', array('guid' => array('type' => 'int', 'required' => true)), 'Access a non-public file from a remote location', 'GET', false, true);
    // Projekktor for Video/Audio support
    elgg_register_js('projekktor', '/mod/elgg_file_viewer/vendors/projekktor-1.2.38r332/projekktor-1.2.38r332.min.js');
    elgg_register_simplecache_view('js/elgg_file_viewer/projekktor');
    elgg_register_js('elgg.projekktor', elgg_get_simplecache_url('js', 'elgg_file_viewer/projekktor'), 'footer');
    elgg_register_css('projekktor', '/mod/elgg_file_viewer/vendors/projekktor-1.2.38r332/theme/maccaco/projekktor.style.css');
    // Syntax highlighter / text support
    elgg_register_js('syntaxhighlighter', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/scripts/shCore.js', 'footer');
    elgg_register_js('syntaxhighlighter.css', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/scripts/shBrushCss.js', 'footer');
    elgg_register_js('syntaxhighlighter.xml', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/scripts/shBrushXml.js', 'footer');
    elgg_register_js('syntaxhighlighter.plain', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/scripts/shBrushPlain.js', 'footer');
    elgg_register_js('syntaxhighlighter.js', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/scripts/shBrushJScript.js', 'footer');
    elgg_register_js('syntaxhighlighter.php', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/scripts/shBrushPhp.js', 'footer');
    elgg_register_simplecache_view('js/elgg_file_viewer/syntaxhighlighter');
    elgg_register_js('elgg.syntaxhighlighter', elgg_get_simplecache_url('js', 'elgg_file_viewer/syntaxhighlighter'), 'footer');
    elgg_register_css('syntaxhighlighter.core', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/styles/shCore.css');
    elgg_register_css('syntaxhighlighter.theme', '/mod/elgg_file_viewer/vendors/syntaxhighlighter_3.0.83/styles/shThemeDefault.css');
    // FFmpeg class
    elgg_register_class('FFmpeg', elgg_get_plugins_path() . 'elgg_file_viewer/vendors/ffmpeg/src/ffmpeg.class.php');
    elgg_register_page_handler('projekktor', 'elgg_file_viewer_projekktor_video');
}
Example #4
0
/**
 * Exposes the groups functions
 *
 * @return void
 */
function ws_pack_groups_expose_functions()
{
    // get (all) groups
    /*
    expose_function(
    	"groups.get",
    	"ws_pack_groups_get",
    	array(
    		"filter" => array(
    			"type" => "string",
    			"required" => true
    		),
    		"offset" => array(
    			"type" => "int",
    			"required" => false,
    			"default" => 0
    		),
    		"limit" => array(
    			"type" => "int",
    			"required" => false,
    			"default" => 10
    		)
    	),
    	elgg_echo("ws_pack:api:groups:get"),
    	"GET",
    	true,
    	false
    );
    */
    // get groups user_guid is a member of
    expose_function("groups.member_of", "ws_pack_groups_member_of", array("user_guid" => array("type" => "int", "required" => false, "default" => 0), "offset" => array("type" => "int", "required" => false, "default" => 0), "limit" => array("type" => "int", "required" => false, "default" => 10)), elgg_echo("ws_pack:api:groups:member_of"), "GET", true, true);
}
Example #5
0
/**
 * Exposes the discussions functions
 *
 * @return void
 */
function ws_pack_discussions_expose_functions()
{
    expose_function("discussions.post", "post_discussion", array("title" => array("type" => "string", "required" => false), "content" => array("type" => "string", "required" => true), "group_guid" => array("type" => "int", "required" => true), "tags" => array("type" => "string", "required" => false), "access" => array("type" => "int", "required" => false)), 'Post to discussion', 'POST', true, true);
    expose_function("discussions.post_reply", "post_reply", array("content" => array("type" => "string", "required" => true), "parent_guid" => array("type" => "int", "required" => true)), 'Post reply', 'POST', true, true);
    expose_function("discussions.get_discussions", "ws_pack_get_discussions", array("group_guid" => array("type" => "int", "required" => true)), '', 'GET', true, true);
    expose_function("discussions.get_discussion", "ws_pack_get_discussion", array("guid" => array("type" => "int", "required" => true)), '', 'GET', true, true);
    expose_function("discussions.delete_discussion", "ws_pack_delete_discussion", array("guid" => array("type" => "int", "required" => true)), '', 'POST', true, true);
}
Example #6
0
/**
 * Exposes the messages functions
 *
 * @return void
 */
function ws_pack_messages_expose_functions()
{
    expose_function("messages.send_message", "ws_pack_send_message", array("subject" => array("type" => "string", "required" => true), "message" => array("type" => "string", "required" => true), "recipient" => array("type" => "int", "required" => true)), '', 'POST', true, true);
    expose_function("messages.get_messages", "ws_pack_get_messages", array(), '', 'GET', true, true);
    expose_function("messages.get_conversation", "ws_pack_get_conversation", array("user_guid" => array("type" => "int", "required" => false), "fromto_guid" => array("type" => "int", "required" => false), "relationship" => array("type" => "string", "required" => true)), '', 'GET', true, true);
    expose_function("messages.get_last_conversations", "ws_pack_get_last_conversations", array("user_guid" => array("type" => "int", "required" => false)), '', 'GET', true, true);
    expose_function("messages.delete_message", "ws_pack_delete_message", array("guid" => array("type" => "int", "required" => true)), '', 'POST', true, true);
}
Example #7
0
function zhaohu_expose_restapi()
{
    expose_function("test.echo", "my_echo", array("string" => array('type' => 'string')), 'A testing method which echos back a string', 'GET', false, false);
    expose_function("event.get", "ws_get_event", array("guid" => array('type' => 'int', required => true)), 'API that gets one event', 'GET', false, false);
    expose_function("photo.get", "ws_get_photo", array("guid" => array('type' => 'int', required => true)), 'API that gets one photo', 'GET', false, false);
    expose_function("event.search", "ws_search_events", array("state" => array('type' => 'string', 'default' => 'WA'), "keyword" => array('type' => 'string', 'default' => 'All'), "past" => array('type' => 'string', 'default' => 'n'), "featured" => array('type' => 'string', 'default' => 'n'), "offset" => array('type' => 'int', 'default' => '0')), 'API that searches events', 'GET', false, false);
    expose_function("album.list", "ws_list_albums", array("offset" => array('type' => 'int', 'default' => '0')), 'API that lists albums', 'GET', false, false);
    expose_function("photo.list", "ws_list_photos", array("album_guid" => array('type' => 'int', required => true), "offset" => array('type' => 'int', 'default' => '0'), "batch_size" => array('type' => 'int', 'default' => ZHAOHU_MANAGER_SEARCH_LIST_LIMIT)), 'API that lists albums', 'GET', false, false);
}
Example #8
0
function pleio_api_expose_functions()
{
    foreach (pleio_api_methods() as $method => $info) {
        $info["params"] = isset($info["params"]) ? $info["params"] : array();
        $info["description"] = isset($info["description"]) ? $info["description"] : "Pleio API method " . $method;
        $info["method"] = isset($info["method"]) ? $info["method"] : "GET";
        $info["login_required"] = isset($info["login_required"]) ? $info["login_required"] : true;
        $public_method = isset($info["public_method"]) ? $info["public_method"] : "pleio." . $method;
        $private_function = isset($info["private_function"]) ? $info["private_function"] : "pleio_api_" . $method;
        expose_function($public_method, $private_function, $info["params"], $info["description"], $info["method"], true, $info["login_required"]);
    }
}
Example #9
0
function engape_init()
{
    elgg_register_page_handler('face_upload', 'engap_faceupload_page_handler');
    expose_function("reg.user", "eg_reg_user", array("email" => array('type' => 'string'), "password" => array('type' => 'string')), 'Register a new Users', 'GET', false, false);
    expose_function("list.river", "eg_list_river", array("refid" => array('type' => 'string'), "type" => array('type' => 'string'), "extra" => array('type' => 'string'), "optr" => array('type' => 'string'), "limit" => array('type' => 'string')), 'Provide List of activity', 'GET', false, true);
    expose_function("list.entity", "eg_list_entity", array("type" => array('type' => 'string'), "subtype" => array('type' => 'string'), "refguid" => array('type' => 'string'), "limit" => array('type' => 'string'), "extra" => array('type' => 'string'), "optr" => array('type' => 'string')), 'provide list of entity', 'GET', false, true);
    expose_function("get.entity", "eg_get_entity", array("guid" => array('type' => 'string')), 'Get the properties of an Entity', 'GET', false, false);
    expose_function("refresh.icons", "eg_refresh_entity_icons", array("refreshlist" => array('type' => 'string')), 'returns icontimes for given  set of icons', 'GET', false, true);
    expose_function("sync.entities", "eg_sync_entities", array("guids" => array('type' => 'string'), "iconguids" => array('type' => 'string')), 'returns icontimes for given  set of icons', 'GET', false, true);
    expose_function("wire.post", "eg_wire_post", array("wire_post" => array('type' => 'string')), 'Wire Post', 'POST', false, true);
    expose_function("engap.gettoken", "engap_gettoken", array('username' => array('type' => 'string'), 'password' => array('type' => 'string')), elgg_echo('engap.gettoken'), 'POST', false, false);
    expose_function("engap.refreshtoken", "engap_refreshtoken", array(), elgg_echo('engap.refreshtoken'), 'GET', false, true);
    expose_function("chat.post", "eg_chat_post", array("cp_guid" => array('type' => 'string'), "chat_post" => array('type' => 'string')), 'Chat Post', 'POST', false, true);
    expose_function("chat.get", "eg_chat_get", array("cp_guid" => array('type' => 'string'), "refid" => array('type' => 'string'), "optr" => array('type' => 'string')), 'Chat Get', 'GET', false, true);
    expose_function("submit.form", "eg_submit_form", array("formname" => array('type' => 'string'), "formdata" => array('type' => 'string')), 'html form', 'POST', false, true);
    elgg_register_page_handler('engap', 'engap_page_handler');
    elgg_register_plugin_hook_handler('rest', 'init', 'engape_rest_init');
}
Example #10
0
/**
 * Elgg oauth client and server
 * 
 * @author Justin Richer
 * @copyright The MITRE Corporation
 * @link http://mitre.org/
 */
function oauth_init()
{
    // Get config
    global $CONFIG;
    // include the OAuth library
    if (!class_exists('OAuthConsumer')) {
        include $CONFIG->pluginspath . 'oauth/lib/OAuth.php';
    }
    // set up the data store
    include $CONFIG->pluginspath . 'oauth/lib/ElggOAuthDataStore.php';
    // set up our actions and hooks
    // mechanisms to register and unregister consumers
    elgg_register_action('oauth/register', $CONFIG->pluginspath . 'oauth/actions/register.php');
    elgg_register_action('oauth/unregister', $CONFIG->pluginspath . 'oauth/actions/unregister.php');
    elgg_register_action('oauth/editconsumer', $CONFIG->pluginspath . 'oauth/actions/editconsumer.php');
    // mechanisms to let the user authorize and revoke their tokens
    elgg_register_action('oauth/authorize', $CONFIG->pluginspath . 'oauth/actions/authorize.php');
    elgg_register_action('oauth/revoke', $CONFIG->pluginspath . 'oauth/actions/revoke.php');
    // mechanisms to allow consumers of remote sites to request tokens
    elgg_register_action('oauth/gettoken', $CONFIG->pluginspath . 'oauth/actions/gettoken.php');
    // page handler
    elgg_register_page_handler('oauth', 'oauth_page_handler');
    // plugins hooks (for permissions on OAuth token and consumer objects)
    elgg_register_plugin_hook_handler('permissions_check', 'object', 'oauth_permissions_check');
    // cron to clean up old nonces and tokens
    elgg_register_plugin_hook_handler('cron', 'hourly', 'oauth_cron_cleanup');
    // add our menu pieces
    elgg_register_menu_item('site', array('name' => elgg_echo('oauth:menu'), 'text' => elgg_echo('oauth:menu'), 'href' => $CONFIG->wwwroot . 'oauth/authorize'));
    // hook for the PAM permissions system
    register_pam_handler('oauth_pam_handler', 'sufficient', 'user');
    register_pam_handler('oauth_pam_handler', 'sufficient', 'api');
    // API Test function
    expose_function('oauth.echo', 'oauth_echo', array('string' => array('type' => 'string')), 'A testing method for OAuth authentication', 'GET', true, true);
    // run our set up and upgrade functions
    run_function_once('oauth_run_once');
    run_function_once('oauth_upgrade_201004');
}
Example #11
0
 * @return bool
 */
function wire_delete($username, $wireid)
{
    $user = get_user_by_username($username);
    if (!$user) {
        throw new InvalidParameterException('registration:usernamenotvalid');
    }
    $thewire = get_entity($wireid);
    $return['success'] = false;
    if ($thewire->getSubtype() == "thewire" && $thewire->canEdit($user->guid)) {
        $children = elgg_get_entities_from_relationship(array('relationship' => 'parent', 'relationship_guid' => $wireid, 'inverse_relationship' => true));
        if ($children) {
            foreach ($children as $child) {
                $child->reply = false;
            }
        }
        $rowsaffected = $thewire->delete();
        if ($rowsaffected > 0) {
            $return['success'] = true;
            $return['message'] = elgg_echo("thewire:deleted");
        } else {
            $return['message'] = elgg_echo("thewire:notdeleted");
        }
    } else {
        $return['message'] = elgg_echo("thewire:notdeleted");
    }
    return $return;
}
expose_function('wire.delete_posts', "wire_delete", array('username' => array('type' => 'string'), 'wireid' => array('type' => 'int')), "Delete a wire post", 'POST', true, false);
Example #12
0
}
expose_function('user.friend.get_friends', "user_get_friends", array('username' => array('type' => 'string', 'required' => true), 'limit' => array('type' => 'int', 'required' => false), 'offset' => array('type' => 'int', 'required' => false)), "Register user", 'GET', false, false);
/**
 * Web service to obtains the people who have made a given user a friend
 *
 * @param string $username Username
 * @param string $limit    Number of users to return
 * @param string $offset   Indexing offset, if any
 *
 * @return array
 */
function user_get_friends_of($username, $limit = 10, $offset = 0)
{
    $user = get_user_by_username($username);
    if (!$user) {
        throw new InvalidParameterException(elgg_echo('registration:usernamenotvalid'));
    }
    $friends = get_user_friends_of($user->guid, '', $limit, $offset);
    $success = false;
    foreach ($friends as $friend) {
        $return[$friend->guid]['username'] = $friend->username;
        $return[$friend->guid]['name'] = $friend->name;
        $success = true;
    }
    if (!$success) {
        $return['error']['message'] = elgg_echo('friends:none');
    }
    return $return;
}
expose_function('user.friend.get_friends_of', "user_get_friends_of", array('username' => array('type' => 'string', 'required' => true), 'limit' => array('type' => 'int', 'required' => false), 'offset' => array('type' => 'int', 'required' => false)), "Register user", 'GET', false, false);
Example #13
0
/**
 * Exposes the users functions
 *
 * @return void
 */
function ws_pack_users_expose_functions()
{
    expose_function("users.get_logged_in_user", "ws_pack_users_get_logged_in_user", array(), elgg_echo("ws_pack:api:users:get_logged_in_user"), "GET", true, true);
    expose_function("users.register_for_push_notifications", "ws_pack_users_register_for_push_notifications", array("service_name" => array("type" => "string", "required" => true), "settings" => array("type" => "array", "required" => true)), elgg_echo("ws_pack:api:users:register_for_push_notifications"), "POST", true, true);
    expose_function("users.unregister_from_push_notifications", "ws_pack_users_unregister_from_push_notifications", array("service_name" => array("type" => "string", "required" => true)), elgg_echo("ws_pack:api:users:unregister_from_push_notifications"), "POST", true, true);
}
Example #14
0
/**
 * Exposes the river functions
 *
 * @return void
 */
function ws_pack_river_expose_functions()
{
    expose_function("river.get", "ws_pack_river_get", array("filter" => array("type" => "string", "required" => true), "guids" => array("type" => "array", "required" => false, "default" => array()), "offset" => array("type" => "int", "required" => false, "default" => 0), "limit" => array("type" => "int", "required" => false, "default" => 25), "posted_time_lower" => array("type" => "int", "required" => false, "default" => 0)), elgg_echo("ws_pack:api:river:get"), "GET", true, true);
}
Example #15
0
function ws_pack_search_expose_functions()
{
    expose_function("search.query", "ws_pack_search", array("query" => array("type" => "string", "required" => true), "offset" => array("type" => "integer", "required" => false), "limit" => array("type" => "integer", "required" => false)), elgg_echo("ws_pack:api:system:api:register_push_notification_service"), "GET", true, false);
}
Example #16
0
/**
 * Initialise the API subsystem.
 *
 * @return void
 * @access private
 */
function api_init()
{
    // Register a page handler, so we can have nice URLs
    register_service_handler('rest', 'rest_handler');
    elgg_register_plugin_hook_handler('unit_test', 'system', 'api_unit_test');
    // expose the list of api methods
    expose_function("system.api.list", "list_all_apis", NULL, elgg_echo("system.api.list"), "GET", false, false);
    // The authentication token api
    expose_function("auth.gettoken", "auth_gettoken", array('username' => array('type' => 'string'), 'password' => array('type' => 'string')), elgg_echo('auth.gettoken'), 'POST', false, false);
}
Example #17
0
/**
 * Exposes the community functions
 *
 * @return void
 */
function ws_pack_community_expose_functions()
{
    expose_function("community.get_plugins", "ws_pack_get_plugins", array(), '', 'GET', true, true);
    expose_function("community.get_color_scheme", "ws_pack_get_color_scheme", array(), '', 'GET', true, true);
}
Example #18
0
        $params = array('types' => 'object', 'subtypes' => 'file', 'container_guid' => $group_guid, 'limit' => $limit, 'full_view' => FALSE);
    }
    $latest_file = elgg_get_entities($params);
    if ($context == "friends") {
        $latest_file = get_user_friends_objects($user->guid, 'file', $limit, $offset);
    }
    if ($latest_file) {
        foreach ($latest_file as $single) {
            $file['guid'] = $single->guid;
            $file['title'] = $single->title;
            $owner = get_entity($single->owner_guid);
            $file['owner']['guid'] = $owner->guid;
            $file['owner']['name'] = $owner->name;
            $file['owner']['avatar_url'] = get_entity_icon_url($owner, 'small');
            $file['container_guid'] = $single->container_guid;
            $file['access_id'] = $single->access_id;
            $file['time_created'] = (int) $single->time_created;
            $file['time_updated'] = (int) $single->time_updated;
            $file['last_action'] = (int) $single->last_action;
            $file['MIMEType'] = $single->mimetype;
            $file['file_icon'] = get_entity_icon_url($single, 'small');
            $return[] = $file;
        }
    } else {
        $msg = elgg_echo('file:none');
        throw new InvalidParameterException($msg);
    }
    return $return;
}
expose_function('file.get_files', "file_get_files", array('context' => array('type' => 'string', 'required' => false, 'default' => 'all'), 'limit' => array('type' => 'int', 'required' => false, 'default' => 10), 'offset' => array('type' => 'int', 'required' => false, 'default' => 0), 'group_guid' => array('type' => 'int', 'required' => false, 'default' => 0), 'username' => array('type' => 'string', 'required' => false)), "Get file uploaded by all users", 'GET', false, false);
Example #19
0
    return $return;
}
expose_function('blog.get_comments', "blog_get_comments", array('guid' => array('type' => 'string'), 'limit' => array('type' => 'int', 'required' => false, 'default' => 10), 'offset' => array('type' => 'int', 'required' => false, 'default' => 0)), "Get comments for a blog post", 'GET', false, false);
/**
 * Web service to comment on a post
 *
 * @param int $guid blog guid
 * @param string $text
 * @param int $access_id
 *
 * @return array
 */
function blog_post_comment($guid, $text)
{
    $entity = get_entity($guid);
    $user = elgg_get_logged_in_user_entity();
    $annotation = create_annotation($entity->guid, 'generic_comment', $text, "", $user->guid, $entity->access_id);
    if ($annotation) {
        // notify if poster wasn't owner
        if ($entity->owner_guid != $user->guid) {
            notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $text, $entity->getURL(), $user->name, $user->getURL())));
        }
        $return['success']['message'] = elgg_echo('generic_comment:posted');
    } else {
        $msg = elgg_echo('generic_comment:failure');
        throw new InvalidParameterException($msg);
    }
    return $return;
}
expose_function('blog.post_comment', "blog_post_comment", array('guid' => array('type' => 'int'), 'text' => array('type' => 'string')), "Post a comment on a blog post", 'POST', true, true);
Example #20
0
/**
 * Exposes the languages functions
 *
 * @return void
 */
function ws_pack_languages_expose_functions()
{
    expose_function("languages.get_lang_file", "ws_pack_get_lang_file", array(), '', 'GET', true, true);
}
Example #21
0
/**
 * Exposes the system functions
 *
 * @return void
 */
function ws_pack_system_expose_functions()
{
    expose_function("system.api.register_push_notification_service", "ws_pack_system_api_register_push_notification_service", array("service_name" => array("type" => "string", "required" => true), "settings" => array("type" => "array", "required" => true)), elgg_echo("ws_pack:api:system:api:register_push_notification_service"), "POST", true, false);
    expose_function("system.api.unregister_push_notification_service", "ws_pack_system_api_unregister_push_notification_service", array("service_name" => array("type" => "string", "required" => true)), elgg_echo("ws_pack:api:system:api:unregister_push_notification_service"), "POST", true, false);
}
Example #22
0
 * @return bool
 */
function group_forum_delete_reply($username, $id)
{
    $reply = elgg_get_annotation_from_id($id);
    $return['success'] = false;
    if (!$reply || $reply->name != 'group_topic_post') {
        $return['message'] = elgg_echo('discussion:reply:error:notdeleted');
        return $return;
    }
    $user = get_user_by_username($username);
    if (!$user) {
        $return['message'] = elgg_echo('registration:usernamenotvalid');
        return $return;
    }
    if (!$reply->canEdit($user->guid)) {
        $return['message'] = elgg_echo('discussion:error:permissions');
        return $return;
    }
    $result = $reply->delete();
    if ($result) {
        $return['success'] = true;
        $return['message'] = elgg_echo('discussion:reply:deleted');
        return $return;
    } else {
        $return['message'] = elgg_echo('discussion:reply:error:notdeleted');
        return $return;
    }
}
expose_function('group.forum.delete_reply', "group_forum_delete_reply", array('username' => array('type' => 'string'), 'id' => array('type' => 'string')), "Delete a reply from a group", 'POST', true, false);
Example #23
0
/**
 * Correctly initialise notifications and register the email handler.
 *
 */
function notification_init()
{
    // Register a notification handler for the default email method
    register_notification_handler("email", "email_notify_handler");
    // Add settings view to user settings & register action
    extend_elgg_settings_page('notifications/settings/usersettings', 'usersettings/user');
    register_plugin_hook('usersettings:save', 'user', 'notification_user_settings_save');
    //register_action("notifications/settings/usersettings/save");
    // Register some APIs
    expose_function('user.notification.get', 'get_user_notification_settings', array('user_guid' => array('type' => 'int')), elgg_echo('user.notification.get'));
    expose_function('user.notification.set', 'set_user_notification_settings', array('user_guid' => array('type' => 'int'), 'method' => array('type' => 'string'), 'value' => array('type' => 'bool')), elgg_echo('user.notification.set'));
}
Example #24
0
 */
function likes_count_number_of_likes($entity_guid)
{
    $entity = get_entity($entity_guid);
    return likes_count($entity);
}
expose_function('likes.count', "likes_count_number_of_likes", array('entity_guid' => array('type' => 'int')), "Count number of likes", 'GET', false, false);
/**
 * Web service to get users who liked an entity
 *
 * @param string $entity_guid guid of object 
 *
 * @return bool
 */
function likes_getusers($entity_guid)
{
    $entity = get_entity($entity_guid);
    if (likes_count($entity) > 0) {
        $list = elgg_get_annotations(array('guid' => $entity_guid, 'annotation_name' => 'likes', 'limit' => 99));
        foreach ($list as $singlelike) {
            $likes[$singlelike->id]['userid'] = $singlelike->owner_guid;
            $likes[$singlelike->id]['time_created'] = $singlelike->time_created;
            $likes[$singlelike->id]['access_id'] = $singlelike->access_id;
        }
    } else {
        $likes = elgg_echo('likes:userslikedthis', array(likes_count($entity)));
    }
    return $likes;
}
expose_function('likes.getusers', "likes_getusers", array('entity_guid' => array('type' => 'int')), "Get users who liked an entity", 'GET', false, false);
Example #25
0
 *
 * @param string $username  username
 * @param string $limit     (optional) default 10
 * @param string $offset    (optional) default 0
 *
 * @return array $file Array of files uploaded
 */
function file_get_files_by_friend($username, $limit = 10, $offset = 0)
{
    $user = get_user_by_username($username);
    if (!$user) {
        throw new InvalidParameterException('registration:usernamenotvalid');
    }
    $latest_file = get_user_friends_objects($user->guid, 'file', $limit, $offset);
    if ($latest_file) {
        foreach ($latest_file as $single) {
            $file[$single->guid]['title'] = $single->title;
            $file[$single->guid]['owner_guid'] = $single->owner_guid;
            $file[$single->guid]['container_guid'] = $single->container_guid;
            $file[$single->guid]['access_id'] = $single->access_id;
            $file[$single->guid]['time_created'] = $single->time_created;
            $file[$single->guid]['time_updated'] = $single->time_updated;
            $file[$single->guid]['last_action'] = $single->last_action;
        }
    } else {
        $file['error']['message'] = elgg_echo('file:none');
    }
    return $file;
}
expose_function('file.get_files_by_friend', "file_get_files_by_friend", array('username' => array('type' => 'string'), 'limit' => array('type' => 'int', 'required' => false), 'offset' => array('type' => 'int', 'required' => false)), "Get file uploaded by friends", 'GET', true, false);
Example #26
0
/**
 * Exposes the notifications functions
 *
 * @return void
 */
function ws_pack_notifications_expose_functions()
{
    expose_function("notifications.get_notifications", "ws_pack_get_notifications", array(), '', 'GET', true, true);
}
Example #27
0
        $return['message'] = elgg_echo('discussion:reply:deleted');
    } else {
        $msg = elgg_echo('discussion:reply:error:notdeleted');
        throw new InvalidParameterException($msg);
    }
    return $return;
}
expose_function('group.forum.delete_reply', "group_forum_delete_reply", array('id' => array('type' => 'string'), 'username' => array('type' => 'string', 'required' => false)), "Delete a reply from a group forum post", 'POST', true, true);
/**
 * Web service to get activity feed for a group
 *
 * @param int $guid - the guid of the group
 * @param int $limit default 10
 * @param int $offset default 0
 *
 * @return bool
 */
function group_activity($guid, $limit = 10, $offset = 0)
{
    $group = get_entity($guid);
    if (!$guid) {
        $msg = elgg_echo('groups:notfound');
        throw new InvalidParameterException($msg);
    }
    $db_prefix = elgg_get_config('dbprefix');
    global $jsonexport;
    $content = elgg_list_river(array('limit' => $limit, 'pagination' => false, 'joins' => array("JOIN {$db_prefix}entities e1 ON e1.guid = rv.object_guid"), 'wheres' => array("(e1.container_guid = {$group->guid})")));
    return $jsonexport['activity'];
}
expose_function('group.activity', "group_activity", array('guid' => array('type' => 'int'), 'limit' => array('type' => 'int', 'required' => false), 'offset' => array('type' => 'int', 'required' => false)), "Get the activity feed for a group", 'GET', false, false);
Example #28
0
 *
 */
/**
 * Heartbeat web service
 *
 * @return string $response Hello
 */
function site_test()
{
    $response['success'] = true;
    $response['message'] = "Hello";
    return $response;
}
expose_function('site.test', "site_test", array(), "Get site information", 'GET', false, false);
/**
 * Web service to get site information
 *
 * @return string $url URL of Elgg website
 * @return string $sitename Name of Elgg website
 * @return string $language Language of Elgg website
 */
function site_getinfo()
{
    $site = elgg_get_config('site');
    $siteinfo['url'] = elgg_get_site_url();
    $siteinfo['sitename'] = $site->name;
    $siteinfo['language'] = elgg_get_config('language');
    return $siteinfo;
}
expose_function('site.getinfo', "site_getinfo", array(), "Get site information", 'GET', false, false);
 protected function registerFunction($api_auth = false, $user_auth = false, $params = null)
 {
     $parameters = array('param1' => array('type' => 'int', 'required' => true), 'param2' => array('type' => 'bool', 'required' => false));
     if ($params == null) {
         $params = $parameters;
     }
     expose_function('test', 'elgg_echo', $params, '', 'POST', $api_auth, $user_auth);
 }
Example #30
0
/**
 * Exposes the members functions
 *
 * @return void
 */
function ws_pack_members_expose_functions()
{
    expose_function("members.get_friends", "ws_pack_get_friends", array(), '', 'GET', true, true);
    expose_function("members.search_members", "ws_pack_search_members", array("search_str" => array("type" => "string", "required" => true)), '', 'GET', true, true);
    expose_function("members.get_member", "ws_pack_get_member", array("guid" => array("type" => "string", "required" => true)), '', 'GET', true, true);
}