public function init($entity) { if (FriendsPlugin::friends($entity->owner_guid, getLoggedInUserGuid())) { return true; } return false; }
static function loggedInUserCanJoin($group) { if (!is_object($group)) { $group = getEntity($group); } $membership = $group->membership; // check to see if already a member $is_member = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "group", "value" => $group->guid), array("name" => "member_guid", "value" => getLoggedInuserGuid())))); if ($is_member) { return false; } switch ($membership) { case "public": return true; break; case "friends": if (isEnabledPlugin("Friends")) { if (FriendsPlugin::friends(getLoggedInUserGuid(), $group->owner_guid)) { return true; } } else { return true; } break; } }
public function __construct() { new Accesshandler("friends"); if (loggedIn()) { new MenuItem(array("name" => "friends", "label" => translate("friends"), "page" => "friends", "menu" => "my_account", "weight" => 50)); new MenuItem(array("name" => "friend_requests", "label" => translate("friend_requests"), "page" => "Friendrequests", "menu" => "my_account", "weight" => 100)); new Usersetting(array("name" => "notify_when_friend_request_sent", "field_type" => "dropdown", "options" => array("email" => "Email", "site" => "Site", "both" => "Both", "none" => "None"), "tab" => "notifications", "default_value" => "both")); new Usersetting(array("name" => "notify_when_friend_request", "field_type" => "dropdown", "options" => array("email" => "Email", "site" => "Site", "both" => "Both", "none" => "None"), "tab" => "notifications", "default_value" => "both")); if (currentPage() == "profile" && pageArray(1)) { if (pageArray(1) != getLoggedInUserGuid()) { if (!FriendsPlugin::requestSent(getLoggedInUserGuid(), pageArray(1))) { if (!FriendsPlugin::friends(pageArray(1), getLoggedInUserGuid())) { new MenuItem(array("name" => "add_friend", "label" => translate("add_friend"), "page" => addTokenToURL("action/addFriend/" . pageArray(1)), "menu" => "profile", "weight" => 10, "link_class" => "list-group-item list-group-item-info confirm")); } else { new MenuItem(array("name" => "remove_friend", "label" => translate("remove_friend"), "page" => addTokenToURL("action/removeFriend/" . pageArray(1)), "menu" => "profile", "weight" => 10, "link_class" => "list-group-item list-group-item-warning confirm")); } } else { new MenuItem(array("name" => "friend_request_sent", "label" => translate("friendship_requested"), "page" => "friend", "menu" => "profile", "weight" => 20, "link_class" => "list-group-item confirm")); } } } } new ViewExtension("profile/left", "friends/profile", "after"); new ViewExtension('pages/home_stats', 'pages/friend_stats'); new ViewExtension("user/buttons", "friends/friend_button"); }
public function __construct() { $request_guid = pageArray(2); $request = getEntity($request_guid); FriendsPlugin::addFriend($request->guid_one, $request->guid_two); $user1 = getEntity($request->guid_one); $user2 = getEntity($request->guid_two); $params = array($user1->getURL(), $user1->full_name, $user2->getURL(), $user2->full_name); $params2 = array($user2->getURL(), $user2->full_name, $user1->getURL(), $user1->full_name); if (getLoggedInUserGuid() == $request->guid_two) { new Activity($request->guid_one, "activity:friends:new", $params2); } else { new Activity($request->guid_two, "activity:friends:new", $params1); } forward("friends"); }
function __construct() { gateKeeper(); $to = getInput("to"); $from = getLoggedInUserGuid(); $subject = getInput("subject"); $message_body = getInput("message"); if (!$message_body) { new SystemMessage("Message body cannot be left blank."); forward(); } // Make sure recipient is a user $to_user = getEntity($to); classGateKeeper($to_user, "User"); // Make sure logged in user and to user are friends if (!FriendsPlugin::friends(getLoggedInUserGuid(), $to)) { forward(); } // Create a new message $message = new Message(); $message->to = $to; $message->from = $from; $message->subject = $subject; $message->save(); $message_element = new Messageelement(); $message_element->to = $to; $message_element->from = $from; $message_element->subject = $subject; $message_element->message = $message_body; $message_element->container_guid = $message->guid; $message_element->save(); $link = getSiteURL() . "messages"; $notify = $to_user->notify_when_message; if (!$notify) { $notify = "both"; } if ($notify == "both" || $notify == "site") { notifyUser("message", $to, $from, $to); } if ($notify == "both" || ($notify = "email")) { sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true)); } new SystemMessage("Your message has been sent."); forward(); }
function __construct() { if (loggedIn()) { if (currentPage() == "profile") { if (isEnabledPlugin("Friends")) { $user_one = pageArray(1); $user_two = getLoggedInUserGuid(); if (FriendsPlugin::friends($user_one, $user_two)) { new MenuItem(array("name" => "chat", "menu" => "profile", "label" => "Chat", "page" => "action/CreateChat/" . $user_one, "link_class" => "list-group-item list-group-item-success")); } } } } new ViewExtension("page_elements/foot", "chat/chat_boxes"); new CSS("chat", getSitePath() . "core_plugins/chat/assets/css/chat.css", 400); new FooterJS("chat", getSiteURL() . "core_plugins/chat/assets/js/chat.js", 400, true); new Usersetting(array("name" => "notify_offline_chat", "field_type" => "dropdown", "options" => array("yes" => "Yes", "no" => "No"), "default_value" => "yes", "tab" => "notifications")); }
function __construct() { adminGateKeeper(); $users = getEntities(array("type" => "User")); foreach ($users as $user1) { foreach ($users as $user2) { $test = getEntity(array("type" => "friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $user1->guid), array("name" => "guid_two", "value" => $user2->guid)))); if (!$test) { // No friendship, let's create one. FriendsPlugin::addFriend($user1->guid, $user2->guid); } } } $plugin = getEntity(array("type" => "Plugin", "metadata_name" => "name", "metadata_value" => "everyoneFriends")); $plugin->status = "disabled"; $plugin->save(); forward("admin"); }
public function __construct() { if (!pageArray(2)) { return false; } gateKeeper(); $user1 = getLoggedInUser(); $guid = pageArray(2); $user2 = getEntity($guid); if (!FriendsPlugin::friends($user1->guid, $user2->guid)) { // First check if the other user has already initiated a friend request $request = getEntity(array("type" => "Friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $guid), array("name" => "guid_two", "value" => $user1->guid), array("name" => "status", "value" => "new")))); if ($request) { FriendsPlugin::addFriend($user1->guid, $guid); forward(); } // Make sure there isn't already a friend request in the system $test = getEntities(array("type" => "Friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $user1->guid), array("name" => "guid_two", "value" => $guid)))); if (!$test) { $friend_request = new Friend(); $friend_request->guid_one = $user1->guid; $friend_request->guid_two = $guid; $friend_request->status = "requested"; $friend_request->requested_by = getLoggedInUserGuid(); $friend_request->save(); $friend_request = new Friend(); $friend_request->guid_one = $guid; $friend_request->guid_two = $user1->guid; $friend_request->status = "requested"; $friend_request->requested_by = getLoggedInUserGuid(); $friend_request->save(); new SystemMessage("Your friend request has been sent."); notifyUser("friend", $user2->guid, $user1->guid, $user2->guid); } forward(); } forward(); }
/** * Creates html for activity page */ public function __construct() { switch (pageArray(1)) { default: case "all": $this->params = array("type" => "Activity", "order_by" => "time_created", "order_reverse" => true, "offset" => getInput("offset", 0)); break; case "mine": $this->params = array("type" => "Activity", "order_by" => "time_created", "order_reverse" => true, "offset" => getInput("offset", 0), "metadata_name" => "owner_guid", "metadata_value" => getLoggedInUserGuid()); break; case "friends": $this->params = array("type" => "Activity", "order_by" => "time_created", "order_reverse" => true, "offset" => getInput("offset", 0), "metadata_name" => "owner_guid", "metadata_value" => "('" . FriendsPlugin::getFriendGuidCSString(getLoggedInUser()) . "')", "operand" => "IN"); break; } $this->params['count'] = true; $this->count = getEntities($this->params); unset($this->params['count']); $this->params['limit'] = 10; $entities = listEntities($this->params); $pagination = display("page_elements/pagination", array("count" => $this->count, "offset" => getInput("offset"), "limit" => $this->limit, "url" => "activity")); $this->tabs = display("page_elements/tabs", array("tabs" => array("All" => getSiteURL() . "activity", "Mine" => getSiteURL() . "activity/mine", "Friends" => getSiteURL() . "activity/friends"))); $this->html = drawPage(array("header" => "Activity", "body" => $this->tabs . $entities . $pagination)); }
<?php /* * *********************************************************************** * * SocialApparatus CONFIDENTIAL * __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); gateKeeper(); $owner = getLoggedInUser(); $limit = 9; $offset = getInput("offset", 0); $filter = getInput("filter", NULL); $friends = FriendsPlugin::getFriends($owner, $offset, $limit, $filter); $body = viewEntityList($friends, "list"); echo drawPage(array("header" => translate("friends"), "body" => $body, "button" => drawForm(array("name" => "friend_search", "method" => "get", "page" => "friends"))));
* All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $guid = Vars::get("guid"); if ($guid && loggedIn()) { if (getLoggedInUserGuid() != $guid) { if (FriendsPlugin::requestSent(getLoggedInUserGuid(), $guid)) { echo "<span class='btn btn-info btn-xs' title='Friendship Requested' data-toggle='tooltip'><i class='fa fa-user'></i></span>"; } else { if (FriendsPlugin::friends($guid, getLoggedInUserGuid())) { $remove_friend_url = addTokenToURL(getSiteURL() . "action/removeFriend/{$guid}"); echo "<a href='{$remove_friend_url}' data-toggle='tooltip' title='Remove Friend' class='btn btn-warning btn-xs'><i class='fa fa-minus'></i></a>"; } else { $add_friend_url = addTokenToURL(getSiteURL() . "action/addFriend/{$guid}"); echo "<a href='{$add_friend_url}' data-toggle='tooltip' title='Add Friend' class='btn btn-success btn-xs'><i class='fa fa-plus'></i></a>"; } } } }
/* * *********************************************************************** * * SocialApparatus CONFIDENTIAL * __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $vars = Vars::get("called_by"); $guid = pageArray(1); $owner = getEntity($guid); $friends = FriendsPlugin::getFriends($owner, 0, 1000); $friends_list = viewEntityList($friends, "gallery"); $find_friends_url = getSiteURL() . "members"; $search_friends_form = drawForm(array("name" => "search_friends", "method" => "get", "page" => "searchFriends", "class" => "form-inline")); $friends_text = translate("friends"); $find_friends_text = translate("find_friends"); echo display("page_elements/panel", array("heading" => "<a href='{$find_friends_url}' class='btn btn-success btn-xs pull-right'>{$find_friends_text}</a>{$friends_text}", "body" => $friends_list, "footer" => $search_friends_form));
/* * *********************************************************************** * * SocialApparatus CONFIDENTIAL * __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $activity_url = getSiteURL() . "activity"; $guid = Vars("guid"); $user = getEntity($guid); if (isEnabledPlugin("Friends")) { $friends = FriendsPlugin::getFriendGuidCSString($user); } if (isset($friends)) { $params = array("type" => "Activity", "order_by" => "time_created", "order_reverse" => true, "limit" => 8, "metadata_name" => "owner_guid", "metadata_value" => "(" . $friends . ")", "operand" => "IN"); echo display("ajax/entity_list", array("params" => $params, "wrapper" => "ul", "wrapper_class" => "timeline timeline-small", "title" => translate("latest_friends_activity"), "id" => "ajax_friends_activity", "panel" => true)); }
function acceptFriendRequest($var) { $request_guid = $var['request_guid']; $request = getEntity($request_guid); FriendsPlugin::addFriend($request->guid_one, $request->guid_two); $user1 = getEntity($request->guid_one); $user2 = getEntity($request->guid_two); $params = array($user1->getURL(), $user1->full_name, $user2->getURL(), $user2->full_name); $params2 = array($user2->getURL(), $user2->full_name, $user1->getURL(), $user1->full_name); if ($var['logged_in_guid'] == $request->guid_two) { new Activity($request->guid_one, "activity:friends:new", $params2); } else { new Activity($request->guid_two, "activity:friends:new", $params); } return "success"; }
* and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $guid = pageArray(1); $user = getEntity($guid); $guids = array($user->guid); $friends = FriendsPlugin::getFriends($user); $entities = array(); $body = NULL; if ($friends && !empty($friends)) { foreach ($friends as $friend) { $guids[] = $friend->guid; } } if ($guids) { $guids = join(',', $guids); $results = getEntities(array("type" => "Activity", "limit" => 10, "metadata_name" => "owner_guid", "metadata_value" => "(" . $guids . ")", "operand" => "IN", "order_by" => "time_created", "order_reverse" => true)); } $body = viewEntityList($results); echo <<<HTML <div class='panel panel-default'> <div class='panel-heading'>
* * SocialApparatus CONFIDENTIAL * __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $data = array(); $friends = FriendsPlugin::getFriends(getLoggedInUser()); if ($friends) { foreach ($friends as $friend) { $data[] = array("name" => $friend->full_name, "value" => $friend->guid); } } echo display("input/typeahead", array("name" => "to", "label" => "To:", "class" => "form-control", "data" => $data)); echo display("input/text", array("name" => "subject", "label" => "Subject:", "class" => "form-control", "required" => true)); echo display("input/editor", array("name" => "message", "label" => "Message:", "class" => "form-control", "required" => true)); echo display("input/submit", array("label" => "Send", "class" => "btn btn-success disabled"));
<?php /* * *********************************************************************** * * SocialApparatus CONFIDENTIAL * __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $friends = FriendsPlugin::getFriendGuidCSString(getLoggedInUser()); $blogs = listEntities(array("type" => "Blog", "limit" => 5, "offset" => getInput("offset", 0), "metadata_name" => "owner_guid", "metadata_value" => "(" . $friends . ")", "operand" => "IN")); $count = getEntities(array("type" => "Blog", "count" => true, "metadata_name" => "owner_guid", "metadata_value" => "(" . $friends . ")", "operand" => "IN")); echo $blogs; echo display("page_elements/pagination", array("url" => getSiteURL() . "blogs/my_blogs", "offset" => getInput("offset", 0), "limit" => 5, "count" => $count));