function stripe_init() { // Register Stripe js //elgg_register_js('stripe.js', 'https://js.stripe.com/v2/', 'head', 50); //elgg_load_js('stripe.js'); elgg_define_js('stripe', ['src' => 'https://js.stripe.com/v2/stripe.js']); elgg_require_js('stripe'); elgg_extend_view('js/initialize_elgg', 'js/stripe/config'); elgg_extend_view('js/elgg', 'js/stripe/cards'); elgg_extend_view('css/elgg', 'css/stripe/css'); elgg_extend_view('css/admin', 'css/stripe/css'); // Registering actions elgg_register_action('stripe/customers/sync', __DIR__ . '/actions/stripe/customers/sync.php', 'admin'); elgg_register_action('stripe/cards/add', __DIR__ . '/actions/stripe/cards/add.php', 'public'); elgg_register_action('stripe/cards/remove', __DIR__ . '/actions/stripe/cards/remove.php'); elgg_register_action('stripe/cards/set_default', __DIR__ . '/actions/stripe/cards/make_default.php'); elgg_register_action('stripe/subscriptions/cancel', __DIR__ . '/actions/stripe/subscriptions/cancel.php'); // Page handler elgg_register_page_handler('billing', 'stripe_page_handler'); elgg_register_plugin_hook_handler('register', 'menu:stripe-actions', 'stripe_actions_menu'); elgg_register_plugin_hook_handler('ping', 'stripe.events', 'stripe_ping_event'); elgg_register_plugin_hook_handler('customer.created', 'stripe.events', 'stripe_customer_created_event'); elgg_register_plugin_hook_handler('customer.deleted', 'stripe.events', 'stripe_customer_deleted_event'); elgg_register_plugin_hook_handler('charge.succeeded', 'stripe.events', 'stripe_charge_succeeded_event'); elgg_register_plugin_hook_handler('charge.failed', 'stripe.events', 'stripe_charge_failed_event'); elgg_register_plugin_hook_handler('charge.refunded', 'stripe.events', 'stripe_charge_refunded_event'); // Stripe Webhooks elgg_ws_expose_function('stripe.webhooks', 'stripe_webhook_handler', array('environment' => array('type' => 'string', 'required' => true)), 'Handles webhooks received from Stripe', 'POST', false, false); // Map newly registered users to their Stripe profiles if any elgg_register_event_handler('create', 'user', 'stripe_register_user'); }
/** * Exposes the TheWire functions * * @return void */ function ws_pack_thewire_expose_functions() { elgg_ws_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); elgg_ws_expose_function("thewire.get_wires", "ws_pack_get_wires", array("friends_only" => array("type" => "int", "required" => true)), '', 'GET', true, true); elgg_ws_expose_function("thewire.get_thread", "ws_pack_get_thread", array("thread_id" => array("type" => "string", "required" => false)), '', 'GET', true, true); elgg_ws_expose_function("thewire.delete_wire", "ws_pack_delete_wire", array("guid" => array("type" => "int", "required" => true)), '', 'POST', true, true); }
/** * Exposes the groups functions * * @return void */ function ws_pack_groups_expose_functions() { // get (all) groups /* elgg_ws_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 elgg_ws_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); }
/** * Exposes the authentication functions * * @return void */ function ws_pack_auth_expose_functions() { elgg_ws_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 elgg_ws_unexpose_function("auth.gettoken"); elgg_ws_expose_function("auth.gettoken", "ws_pack_auth_gettoken", array("username" => array("type" => "string"), "password" => array("type" => "string")), elgg_echo("auth.gettoken"), "POST", false, false); }
function profile_sync_init() { if (false == function_exists('elgg_ws_expose_function')) { return; } elgg_ws_expose_function('profile_sync.get_emails', 'profile_sync_get_emails', "Get list of user emails on the site", 'GET', false, false); }
/** * Exposes the messages functions * * @return void */ function ws_pack_messages_expose_functions() { elgg_ws_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); elgg_ws_expose_function("messages.get_messages", "ws_pack_get_messages", array(), '', 'GET', true, true); elgg_ws_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); elgg_ws_expose_function("messages.get_last_conversations", "ws_pack_get_last_conversations", array("user_guid" => array("type" => "int", "required" => false)), '', 'GET', true, true); elgg_ws_expose_function("messages.delete_message", "ws_pack_delete_message", array("guid" => array("type" => "int", "required" => true)), '', 'POST', true, true); }
/** * Exposes the discussions functions * * @return void */ function ws_pack_discussions_expose_functions() { elgg_ws_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); elgg_ws_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); elgg_ws_expose_function("discussions.get_discussions", "ws_pack_get_discussions", array("group_guid" => array("type" => "int", "required" => true)), '', 'GET', true, true); elgg_ws_expose_function("discussions.get_discussion", "ws_pack_get_discussion", array("guid" => array("type" => "int", "required" => true)), '', 'GET', true, true); elgg_ws_expose_function("discussions.delete_discussion", "ws_pack_delete_discussion", array("guid" => array("type" => "int", "required" => true)), '', 'POST', true, true); }
function ws_init() { $lib_dir = __DIR__ . "/lib"; elgg_register_library('elgg:ws', "{$lib_dir}/web_services.php"); elgg_register_library('elgg:ws:api_user', "{$lib_dir}/api_user.php"); elgg_register_library('elgg:ws:client', "{$lib_dir}/client.php"); elgg_register_library('elgg:ws:tokens', "{$lib_dir}/tokens.php"); elgg_register_library('elgg:ws:core', "{$lib_dir}/core.php"); elgg_register_library('elgg:ws:user', "{$lib_dir}/user.php"); elgg_register_library('elgg:ws:message', "{$lib_dir}/message.php"); elgg_register_library('elgg:ws:likes', "{$lib_dir}/likes.php"); elgg_register_library('elgg:ws:wire', "{$lib_dir}/wire.php"); elgg_register_library('elgg:ws:image', "{$lib_dir}/image.php"); elgg_register_library('elgg:ws:gcm_register', "{$lib_dir}/gcm_register.php"); elgg_register_library('elgg:ws:file', "{$lib_dir}/file.php"); elgg_register_library('elgg:ws:site', "{$lib_dir}/site.php"); elgg_register_library('elgg:ws:auth', "{$lib_dir}/auth.php"); elgg_register_library('elgg:ws:blog', "{$lib_dir}/blog.php"); elgg_register_library('elgg:ws:album', "{$lib_dir}/album.php"); elgg_register_library('elgg:ws:bookmark', "{$lib_dir}/bookmark.php"); elgg_register_library('elgg:ws:group', "{$lib_dir}/group.php"); elgg_register_library('elgg:ws:activity', "{$lib_dir}/activity.php"); elgg_load_library('elgg:ws:api_user'); elgg_load_library('elgg:ws:tokens'); elgg_load_library('elgg:ws:core'); elgg_load_library('elgg:ws:user'); elgg_load_library('elgg:ws:message'); elgg_load_library('elgg:ws:likes'); elgg_load_library('elgg:ws:wire'); elgg_load_library('elgg:ws:image'); elgg_load_library('elgg:ws:gcm_register'); elgg_load_library('elgg:ws:file'); elgg_load_library('elgg:ws:site'); elgg_load_library('elgg:ws:auth'); elgg_load_library('elgg:ws:blog'); elgg_load_library('elgg:ws:album'); elgg_load_library('elgg:ws:bookmark'); elgg_load_library('elgg:ws:group'); elgg_load_library('elgg:ws:activity'); elgg_register_page_handler('services', 'ws_page_handler'); // Register a service handler for the default web services // The name rest is a misnomer as they are not RESTful elgg_ws_register_service_handler('rest', 'ws_rest_handler'); // expose the list of api methods elgg_ws_expose_function("system.api.list", "list_all_apis", null, elgg_echo("system.api.list"), "GET", false, false); // The authentication token api elgg_ws_expose_function("auth.gettoken", "auth_gettoken", array('username' => array('type' => 'string'), 'password' => array('type' => 'string')), elgg_echo('auth.gettoken'), 'POST', false, false); elgg_register_plugin_hook_handler('unit_test', 'system', 'ws_unit_test'); elgg_register_plugin_hook_handler('send', 'notification:site', 'mobile_notifications_send'); elgg_register_plugin_hook_handler('rest:output', 'system.api.list', 'ws_system_api_list_hook'); }
function ws_init() { $lib_dir = elgg_get_plugins_path() . "web_services/lib"; elgg_register_library('elgg:ws', "{$lib_dir}/web_services.php"); elgg_register_library('elgg:ws:api_user', "{$lib_dir}/api_user.php"); elgg_register_library('elgg:ws:client', "{$lib_dir}/client.php"); elgg_register_library('elgg:ws:tokens', "{$lib_dir}/tokens.php"); elgg_load_library('elgg:ws:api_user'); elgg_load_library('elgg:ws:tokens'); elgg_register_page_handler('services', 'ws_page_handler'); // Register a service handler for the default web services // The name rest is a misnomer as they are not RESTful elgg_ws_register_service_handler('rest', 'ws_rest_handler'); // expose the list of api methods elgg_ws_expose_function("system.api.list", "list_all_apis", null, elgg_echo("system.api.list"), "GET", false, false); // The authentication token api elgg_ws_expose_function("auth.gettoken", "auth_gettoken", array('username' => array('type' => 'string'), 'password' => array('type' => 'string')), elgg_echo('auth.gettoken'), 'POST', false, false); elgg_register_plugin_hook_handler('unit_test', 'system', 'ws_unit_test'); }
/** * Exposes the community functions * * @return void */ function ws_pack_community_expose_functions() { elgg_ws_expose_function("community.get_plugins", "ws_pack_get_plugins", array(), '', 'GET', true, true); elgg_ws_expose_function("community.get_color_scheme", "ws_pack_get_color_scheme", array(), '', 'GET', true, true); }
/** * Exposes the entities functions * * @return void */ function ws_pack_entities_expose_functions() { elgg_ws_expose_function("entities.get_entity", "ws_pack_get_entity", array("id" => array("type" => "int", "required" => true)), '', 'GET', true, true); }
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; } elgg_ws_expose_function('test', 'elgg_echo', $params, '', 'POST', $api_auth, $user_auth); }
$return['message'] = 'leftGroup'; } else { $return['member'] = 'cantLeaveGroup'; $return['message'] = 'cantLeaveGroup'; } } else { $return['member'] = 'cantLeaveGroup'; $return['message'] = 'cantLeaveGroup'; } } else { $return['member'] = 'cantLeaveGroup'; $return['message'] = 'cantLeaveGroup'; } return $return; } elgg_ws_expose_function('group.leave_group', "group_leave_group", array('guid' => array('type' => 'string', 'required' => true)), "Leave group", 'POST', true, true); /** * @param $group * @param $user * @return bool */ function isMemberOf($group, $user) { $members = $group->getMembers(); $isMember = false; foreach ($members as $member) { if ($member->guid = $user->guid) { $isMember = true; return $isMember; } }
/** * Exposes the system functions * * @return void */ function ws_pack_system_expose_functions() { elgg_ws_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); elgg_ws_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); }
function auth_token_check($token, $username, $password) { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } if (validate_user_token($token, 1) == $user->guid) { $return['auth_token'] = 'OK'; $return['api_key'] = get_api_key(); $return['gcm_sender_id'] = get_gcm_sender_id(); } else { $return = auth_gettoken($username, $password); } return $return; } elgg_ws_expose_function('auth.token_check', "auth_token_check", array('token' => array('type' => 'string', 'required' => true), 'username' => array('type' => 'string', 'required' => true), 'password' => array('type' => 'string', 'required' => true)), "Post a auth token check", 'POST', true, false); function get_api_key() { $list = elgg_get_entities(array('type' => 'object', 'subtype' => 'api_key')); $api_key = ''; if ($list) { if (sizeof($list) === 1) { $entity = get_entity($list[0]->guid); $api_key = $entity->public; } else { foreach ($list as $item) { $entity = get_entity($item->get('guid')); if ($entity->title == 'android') { $api_key = $entity->public; } }
/** * Register a function as a web service method * * @deprecated 1.9 Enable the web services plugin and use elgg_ws_expose_function(). */ function expose_function($method, $function, array $parameters = NULL, $description = "", $call_method = "GET", $require_api_auth = false, $require_user_auth = false) { elgg_deprecated_notice("expose_function() deprecated for the function elgg_ws_expose_function() in web_services plugin", 1.9); if (!elgg_admin_notice_exists("elgg:ws:1.9")) { elgg_add_admin_notice("elgg:ws:1.9", "The web services are now a plugin in Elgg 1.9.\n\t\t\tYou must enable this plugin and update your web services to use elgg_ws_expose_function()."); } if (function_exists("elgg_ws_expose_function")) { return elgg_ws_expose_function($method, $function, $parameters, $description, $call_method, $require_api_auth, $require_user_auth); } }
/** * Exposes the settings functions * * @return void */ function ws_pack_settings_expose_functions() { elgg_ws_expose_function("settings.get_logged_in_user", "ws_pack_settings_get_logged_in_user", array(), elgg_echo("ws_pack:api:settings:get_logged_in_user"), "GET", true, true); elgg_ws_expose_function("settings.get_settings", "ws_pack_get_settings", array("service_name" => array("type" => "string", "required" => false), "settings" => array("type" => "array", "required" => false)), elgg_echo("ws_pack:api:settings:get_settings"), "GET", true, true); }
/** * Exposes the languages functions * * @return void */ function ws_pack_languages_expose_functions() { elgg_ws_expose_function('languages.get_lang_file', 'ws_pack_get_lang_file', [], '', 'GET', true, true); }
} elseif ($access == 'ACCESS_LOGGED_IN') { $access_id = 1; } elseif ($access == 'ACCESS_PUBLIC') { $access_id = 2; } else { $access_id = -2; } $guid = thewire_save_post($text, $user->guid, $access_id, $parent_guid, $wireMethod); if (!$guid) { $return['message'] = elgg_echo("thewire:error"); return $return; } $return['success'] = true; return $return; } elgg_ws_expose_function('wire.post_comment', "wire_post_comment", array('parent_guid' => array('type' => 'int'), 'text' => array('type' => 'string'), 'access' => array('type' => 'string', 'required' => false), 'wireMethod' => array('type' => 'string', 'required' => false), 'username' => array('type' => 'string', 'required' => false)), "Post a comment on a wire post", 'POST', true, true); ///////////////////////////////////////////////////////////////////////////////////// function get_elgg_comments(array $options = array(), $getter = 'elgg_get_entities') { global $autofeed; $autofeed = true; $offset_key = isset($options['offset_key']) ? $options['offset_key'] : 'offset'; $defaults = array('offset' => (int) max(get_input($offset_key, 0), 0), 'limit' => (int) max(get_input('limit', 10), 0), 'full_view' => TRUE, 'list_type_toggle' => FALSE, 'pagination' => TRUE); $options = array_merge($defaults, $options); $options['count'] = TRUE; $count = $getter($options); $options['count'] = FALSE; $entities = $getter($options); $options['count'] = $count; return $entities; }
global $CONFIG; // won't be able to serve anything if no joindate or guid if (!isset($_GET['joindate']) || !isset($_GET['guid'])) { header("HTTP/1.1 404 Not Found"); exit; } $join_date = (int) $_GET['joindate']; $last_cache = (int) $_GET['lastcache']; // icontime $guid = (int) $_GET['guid']; $filename = $_GET['name']; // If is the same ETag, content didn't changed. $etag = $last_cache . $guid; if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$etag}\"") { header("HTTP/1.1 304 Not Modified"); exit; } $filename = str_replace(array('\\'), '', $filename); $filesize = @filesize($filename); if ($filesize) { header("Content-type: image/jpeg"); header("Pragma: public"); header("Cache-Control: public"); header("Content-Length: {$filesize}"); header("ETag: \"{$etag}\""); readfile($filename); exit; } } elgg_ws_expose_function('image.get_post', "image_get_post", array('joindate' => array('type' => 'int'), 'guid' => array('type' => 'int'), 'name' => array('type' => 'string')), "Get image post", 'GET', true, true);
*/ function likes_count_number_of_likes($entity_guid) { $entity = get_entity($entity_guid); return likes_count($entity); } elgg_ws_expose_function('likes.count', "likes_count_number_of_likes", array('entity_guid' => array('type' => 'int')), "Count number of likes", 'GET', true, true); /** * 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; } elgg_ws_expose_function('likes.getusers', "likes_getusers", array('entity_guid' => array('type' => 'int')), "Get users who liked an entity", 'GET', true, true);
$path = elgg_get_plugins_path(); run_sql_script($path . "elgg_with_rest_api/schema/mysql.sql"); if ($account && $regId) { $elgg_post = 1; $elgg_message = 1; // Store user details in db include_once $path . 'elgg_with_rest_api/lib/DB_Register_Functions.php'; include_once $path . 'elgg_with_rest_api/lib/GCM.php'; $db = new DB_Register_Functions(); $gcm = new GCM(); if ($db->checkUser($regId)) { $res = $db->updateUser($name, $account, $regId, $elgg_post, $elgg_message); $response['status'] = 0; $response['result'] = "success update gcm regId and user info"; } else { $res = $db->storeUser($name, $account, $regId, $elgg_post, $elgg_message); $registration_ids = array($regId); $message = array("from_name" => "Core Server", "subject" => "Core App Notification", "message" => "Enable Receive Notification"); $result = $gcm->send_notification($registration_ids, $message); $response['status'] = 0; $response['result'] = "success Insert gcm regId and user info"; } } else { // user details missing $response['status'] = 1; $response['result'] = 'Missing name or reg id'; } return $response; } elgg_ws_expose_function('gcm.register', "gcm_register", array('regId' => array('type' => 'string', 'required' => true), 'account' => array('type' => 'string', 'required' => true), 'name' => array('type' => 'string', 'required' => true)), "GCM a Register for Notification", 'POST', true, true);
* @return array * @throws InvalidParameterException */ function user_river_short($username, $limit = 20, $offset = 0) { $login_user = elgg_get_logged_in_user_entity(); $user = get_user_by_username($username); if (!$login_user || !$user) { throw new InvalidParameterException('registration:username not valid'); } $options = array('offset' => $offset, 'limit' => $limit, 'subject_guid' => $user->guid); $activities = elgg_get_river($options); $handle = getRiverActivity($activities, $user, $login_user); return $handle; } elgg_ws_expose_function('count.like_comment', 'count_like_comment', array('entity_guid' => array('type' => 'int', 'required' => true)), "Get number count like and comment", 'GET', true, true); /** * @param $entity_guid * @return array * @throws InvalidParameterException * @internal param $username * @internal param int $limit * @internal param int $offset */ function count_like_comment($entity_guid) { $user = elgg_get_logged_in_user_entity(); if (!$user) { throw new InvalidParameterException('registration:username not valid'); } $like_count = likes_count_number_of_likes($entity_guid);
/** * Exposes the members functions * * @return void */ function ws_pack_members_expose_functions() { elgg_ws_expose_function("members.get_friends", "ws_pack_get_friends", array(), '', 'GET', true, true); elgg_ws_expose_function("members.search_members", "ws_pack_search_members", array("search_str" => array("type" => "string", "required" => true)), '', 'GET', true, true); elgg_ws_expose_function("members.get_member", "ws_pack_get_member", array("guid" => array("type" => "string", "required" => true)), '', 'GET', true, true); }
$album['time_create'] = time_ago($single->time_created); if ($single->description != null) { if (strlen($single->description) > 300) { $entityString = substr(strip_tags($single->description), 0, 300); $album['description'] = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...'; } else { $album['description'] = strip_tags($single->description); } } else { $album['description'] = ''; } $owner = get_entity($single->owner_guid); $album['owner']['guid'] = $owner->guid; $album['owner']['name'] = $owner->name; $album['owner']['username'] = $owner->username; $album['owner']['avatar_url'] = getProfileIcon($owner); //$owner->getIconURL('small'); // $photo['img_url'] = $img_url; $album['like_count'] = likes_count_number_of_likes($single->guid); $album['comment_count'] = api_get_image_comment_count($single->guid); $album['like'] = checkLike($single->guid, $loginUser->guid); $return[] = $album; } } else { $msg = elgg_echo('blog:none'); throw new InvalidParameterException($msg); } return $return; } elgg_ws_expose_function('album.get_posts', "album_get_posts", array('context' => array('type' => 'string'), 'limit' => array('type' => 'int', 'required' => false, 'default' => 20), 'offset' => array('type' => 'int', 'required' => false, 'default' => 0), 'username' => array('type' => 'string', 'required' => false)), "GET all the albums", 'GET', true, true);
$bookmark->description = $description; $bookmark->access_id = $access_id; $bookmark->tags = $tagarray; if ($bookmark->save()) { //add to river only if new if ($new) { elgg_create_river_item(array('view' => 'river/object/bookmarks/create', 'action_type' => 'create', 'subject_guid' => $user->guid, 'object_guid' => $bookmark->getGUID())); } $return['guid'] = $bookmark->guid; } else { register_error(elgg_echo('bookmarks:save:failed')); $return['guid'] = 0; } return $return; } elgg_ws_expose_function('bookmark.save_post', "bookmark_save_post", array('title' => array('type' => 'string', 'required' => true), 'address' => array('type' => 'string', 'required' => true), 'description' => array('type' => 'string', 'required' => true), 'access' => array('type' => 'string', 'required' => true, 'default' => ACCESS_FRIENDS), 'username' => array('type' => 'string', 'required' => true), 'tags' => array('type' => 'string', 'required' => false, 'default' => "")), "Post a bookmark post", 'POST', true, true); function getOwner($guid) { $entity = get_entity($guid); $owner['guid'] = $guid; $owner['name'] = $entity->name; $owner['username'] = $entity->username; $owner['avatar_url'] = getProfileIcon($entity); //$entity->getIconURL('small');; return $owner; } function getImageLink($description) { $doc = new DOMDocument(); @$doc->loadHTML($description); $tags = $doc->getElementsByTagName('img');
$message['guid'] = $guid; $message['message'] = 'success'; } $return[] = $message; } return $return; } elgg_ws_expose_function('messages.mark_all_as_unread', "messages_mark_all_as_unread", array('guidString' => array('type' => 'string', 'required' => true)), "Mark all select messages as unread", 'POST', true, true); function messages_multiple_delete($guidString) { $guidArray = string_to_tag_array($guidString); foreach ($guidArray as $guid) { $single = get_entity($guid); if (!elgg_instanceof($single, 'object', 'messages') || !$single->canEdit()) { $message['guid'] = $guid; $message['message'] = 'fail'; } else { if (!$single->delete()) { $message['guid'] = $guid; $message['message'] = 'success'; } else { $message['guid'] = $guid; $message['message'] = 'fail'; } } $return[] = $message; } return $return; } elgg_ws_expose_function('messages.multiple_delete', "messages_multiple_delete", array('guidString' => array('type' => 'string', 'required' => true)), "Multiple messages delete", 'POST', true, true);
return $return; } elgg_ws_expose_function('user.get_profile_fields', "user_get_profile_fields", array(), "Get user profile labels", 'GET', true, true); elgg_ws_expose_function('user.get_profile', "user_get_profile", array('username' => array('type' => 'string', 'required' => false)), "Get user profile information", 'GET', true, true); elgg_ws_expose_function('user.save_profile', "user_save_profile", array('username' => array('type' => 'string'), 'profile' => array('type' => 'array')), "Get user profile information with username", 'POST', true, true); elgg_ws_expose_function('user.get_user_by_email', "user_get_user_by_email", array('email' => array('type' => 'string')), "Get Username by email", 'GET', true, true); elgg_ws_expose_function('user.check_username_availability', "user_check_username_availability", array('username' => array('type' => 'string')), "Get Username by email", 'GET', true, true); elgg_ws_expose_function('user.register', "user_register", array('name' => array('type' => 'string'), 'email' => array('type' => 'string'), 'username' => array('type' => 'string'), 'password' => array('type' => 'string')), "Register user", 'GET', true, false); elgg_ws_expose_function('user.friend.add', "user_friend_add", array('friend' => array('type' => 'string'), 'username' => array('type' => 'string', 'required' => false)), "Add a user as friend", 'POST', true, true); elgg_ws_expose_function('user.friend.is.friend.of', "user_friend_is_friend_of", array('friend' => array('type' => 'string'), 'username' => array('type' => 'string', 'required' => false)), "Check a user is friend", 'POST', true, true); elgg_ws_expose_function('user.friend.remove', "user_friend_remove", array('friend' => array('type' => 'string'), 'username' => array('type' => 'string', 'required' => false)), "Remove friend", 'GET', true, true); elgg_ws_expose_function('user.friend.get_friends', "user_get_friends", array('username' => array('type' => 'string', 'required' => false), 'limit' => array('type' => 'int', 'required' => false), 'offset' => array('type' => 'int', 'required' => false)), "Register user", 'GET', false, false); elgg_ws_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', true, true); elgg_ws_expose_function('user.get_messageboard', "user_get_messageboard", array('limit' => array('type' => 'int', 'required' => false, 'default' => 10), 'offset' => array('type' => 'int', 'required' => false, 'default' => 0), 'username' => array('type' => 'string', 'required' => false)), "Get a users messageboard", 'GET', true, true); elgg_ws_expose_function('user.post_messageboard', "user_post_messageboard", array('text' => array('type' => 'string'), 'to' => array('type' => 'string', 'required' => false), 'from' => array('type' => 'string', 'required' => false)), "Post a messageboard post", 'POST', true, true); elgg_ws_expose_function('user.search', "user_search", array('username' => array('type' => 'string', 'required' => true), 'limit' => array('type' => 'int', 'required' => false), 'offset' => array('type' => 'int', 'required' => false), 'search_name' => array('type' => 'string', 'required' => true)), "search user", 'GET', true, true); function getProfileIcon($user, $size = 'small') { $site_url = get_config('wwwroot'); $profileUrl = $user->getIconURL($size); if (strpos($profileUrl, 'json/icons/user')) { $profileUrl = $site_url . 'mod/profile/icondirect.php?size=' . $size . '&guid=' . $user->guid; } else { if (strpos($profileUrl, 'json/file/icons')) { $icon_file_name = basename($profileUrl); $profileUrl = $site_url . 'mod/file/graphics/icons/' . $icon_file_name; } else { if (strpos($profileUrl, 'json/groups/')) { $icon_file_name = basename($profileUrl); $profileUrl = $site_url . 'mod/groups/graphics/' . $icon_file_name; }
/** * Exposes the notifications functions * * @return void */ function ws_pack_notifications_expose_functions() { elgg_ws_expose_function("notifications.get_notifications", "ws_pack_get_notifications", array(), '', 'GET', true, true); }
* @return mixed */ function site_getinfo() { $site = elgg_get_config('site'); $siteinfo['url'] = elgg_get_site_url(); $siteinfo['sitename'] = $site->name; $siteinfo['logo'] = elgg_get_plugin_setting('ws_get_logo', 'elgg_with_rest_api'); if ($site->description == null) { $siteinfo['description'] = ''; } else { $siteinfo['description'] = $site->description; } $siteinfo['time_created'] = time_ago($site->time_created); $siteinfo['language'] = elgg_get_config('language'); return $siteinfo; } function site_get_list_plugin() { $plugins = elgg_get_plugins($status = 'active', $site_guid = null); $return = array('messages' => false, 'thewire' => false, 'blog' => false, 'tidypics' => false, 'file' => false, 'bookmarks' => false, 'groups' => false); foreach ($plugins as $plugin) { $a = $plugin->title; if (array_key_exists($plugin->title, $return)) { $return[$plugin->title] = true; } } return $return; } elgg_ws_expose_function('site.get_list_plugin', "site_get_list_plugin", array(), "Get list site Plugin", 'GET', false, false);