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"); }
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")); }
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(); }
* 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>"; } } } }
function members($params) { $returnarray = array(); $members = getEntitiesArray($params); $logged_in_user_guid = $params['logged_in_user_guid']; $logged_in_user = getEntity($logged_in_user_guid); foreach ($members as $member) { $returnarray[] = array("member" => $member, "isFriend" => FriendsPlugin::friends($logged_in_user_guid, $member['guid'])); } return $returnarray; }