public function __construct()
 {
     $editor = getInput("editor_id");
     if (file_exists($_FILES['avatar']['tmp_name'])) {
         // Check if General album exists
         $album = getEntity(array("type" => "Photoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "General"))));
         $photo = new Photo();
         $photo->owner_guid = getLoggedInUserGuid();
         $photo->save();
         $photo->createAvatar();
         if (!$album) {
             $album = new Photoalbum();
             $album->title = "General";
             $album->owner_guid = getLoggedInUserGuid();
             $album->access_id = "public";
             Image::copyAvatar($photo, $album);
             $album->save();
         }
         $photo->container_guid = $album->guid;
         if (!$album->title != "Profile Avatars" && $album->title != "General") {
             new Activity(getLoggedInUserGuid(), "activity:add:photo", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $album->getURL(), $album->title, "<a href='" . $album->getURL() . "'>" . $photo->icon(EXTRALARGE, "img-responsive") . "</a>"), $album->access_id);
         }
         $photo->save();
         forward(false, array("insertphoto" => $photo->guid, "editor" => $editor));
     } else {
         forward();
     }
 }
 public function __construct()
 {
     gateKeeper();
     $title = getInput("title");
     $description = getInput("description");
     $access_id = getInput("access_id");
     $membership = getInput("membership");
     $group = new Group();
     $group->title = $title;
     $group->description = $description;
     $group->access_id = $access_id;
     $group->membership = $membership;
     $group->owner_guid = getLoggedInUserGuid();
     $group->save();
     $group->createAvatar();
     $test = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "group", "value" => $group->guid), array("name" => "member_guid", "value" => getLoggedInUserGuid()))));
     if (!$test) {
         $group_membership = new Groupmembership();
         $group_membership->group = $group->guid;
         $group_membership->member_guid = getLoggedInUserGuid();
         $group_membership->access_id = "system";
         $group_membership->save();
     }
     new Activity(getLoggedInUserGuid(), "group:created", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $group->getURL(), $group->title), $group->guid);
     new SystemMessage("Your group has been created.");
     forward("groups");
 }
 function __construct()
 {
     $guid = getInput("guid");
     $reply = getInput("reply");
     if (!$reply) {
         new SystemMessage("Message body cannot be left empty.");
         forward();
     }
     $message = getEntity($guid);
     $to = getLoggedInUserGuid() == $message->to ? $message->from : $message->to;
     $from = getLoggedInUserGuid();
     $to_user = getEntity($to);
     $from_user = getEntity($from);
     $message_element = new Messageelement();
     $message_element->message = $reply;
     $message_element->to = $to;
     $message_element->from = $from;
     $message_element->container_guid = $guid;
     $message_element->save();
     $link = getSiteURL() . "messages";
     notifyUser("message", $to, getLoggedInUserGuid(), $to);
     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("messages/" . $message->guid);
 }
 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 init($entity)
 {
     if ($entity->owner_guid == getLoggedInUserGuid()) {
         return true;
     }
     return false;
 }
 public function __construct()
 {
     gateKeeper();
     $user = getLoggedInUser();
     $user->createAvatar();
     if (isEnabledPlugin("photos")) {
         $album = getEntity(array("type" => "Photoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "Profile Avatars"))));
         $photo = new Photo();
         $photo->owner_guid = getLoggedInUserGuid();
         $photo_guid = $photo->save();
         Image::copyAvatar($user, $photo);
         $photo = getEntity($photo_guid);
         if (!$album) {
             $album = new Photoalbum();
             $album->owner_guid = getLoggedInUserGuid();
             $album->title = "Profile Avatars";
             $album_guid = $album->save();
             $album = getEntity($album_guid);
             Image::copyAvatar($photo, $album);
         }
         $photo->container_guid = $album->guid;
         $photo->save();
     }
     runHook("action:edit_avatar:after", array("user" => $user));
     new Activity(getLoggedInUserGuid(), "activity:avatar:updated", array($user->getURL(), $user->full_name));
     new SystemMessage("Your avatar has been uploaded.");
     forward("profile/" . $user->guid);
 }
 public function __construct()
 {
     gateKeeper();
     $guid = getInput("guid");
     $title = getInput("blog_title");
     $description = getInput("description");
     $access_id = getInput("access_id");
     $container_guid = getInput("container_guid");
     $owner_guid = getLoggedInUserGuid();
     if ($guid) {
         $blog = getEntity($guid);
     } else {
         $blog = new Blog();
     }
     $blog->title = $title;
     $blog->description = $description;
     $blog->access_id = $access_id;
     $blog->owner_guid = $owner_guid;
     $blog->status = "published";
     $blog->container_guid = $container_guid;
     $blog->save();
     new Activity(getLoggedInUserGuid(), "blog:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $blog->getURL(), $blog->title, truncate($blog->description)), "", $access_id);
     new SystemMessage("Your blog has been published");
     forward("blogs/all_blogs");
 }
 function __construct($data)
 {
     $guid = $data['guid'];
     $text = $data['text'];
     $chat_message = new Chatmessage();
     $chat_message->text = $text;
     $chat_message->owner_guid = getLoggedInUserGuid();
     $chat_message->container_guid = $guid;
     $chat_message->save();
     // If recipient is offline, send them an email
     $chat = getEntity($guid);
     if (getLoggedInUserGuid() == $chat->user_one) {
         $recipient_guid = $chat->user_two;
     } else {
         $recipient_guid = $chat->user_one;
     }
     $recipient = getEntity($recipient_guid);
     if ($recipient->online == "false") {
         $offline_chats = $recipient->offline_chats;
         if (!is_array($offline_chats)) {
             $offline_chats = array(getLoggedInUserGuid());
             $recipient->offline_chats = $offline_chats;
             $recipient->save();
         }
         if (!in_array(getLoggedInUserGuid(), $recipient->offline_chats)) {
             $recipient->offline_chats[] = getLoggedInUserGuid();
             $recipient->save();
         }
         $setting = $recipient->notify_offline_chat;
         if ($setting == "yes") {
             new Email(array("to" => array("name" => "", "email" => ""), "from" => array("name" => "", "email" => ""), "subject" => translate("offline_message_email_subject"), "body" => translate("offline_message_email_body"), "html" => true));
         }
     }
 }
 public function init($entity)
 {
     if (FriendsPlugin::friends($entity->owner_guid, getLoggedInUserGuid())) {
         return true;
     }
     return false;
 }
 public function __construct()
 {
     $title = getInput("title");
     $description = getInput("description");
     // Create filestore object to store file information
     $file = new File();
     $file->title = $title;
     $file->description = $description;
     $file->owner_guid = getLoggedInUserGuid();
     $file->access_id = "public";
     $file->container_guid = getInput("container_guid");
     $guid = $file->save();
     uploadFile("file", $guid, getLoggedInUserGuid());
     $file = getEntity($guid);
     Image::createThumbnail($file->guid, TINY);
     Image::createThumbnail($file->guid, SMALL);
     Image::createThumbnail($file->guid, MEDIUM);
     Image::createThumbnail($file->guid, LARGE);
     Image::createThumbnail($file->guid, EXTRALARGE);
     Image::createThumbnail($file->guid, HUGE);
     new Activity(getLoggedInUserGuid(), "action:upload:file", $guid);
     runHook("upload_file:redirect");
     new SystemMessage("Your file has been uploaded.");
     forward();
 }
 static function getNotificationCount($guid)
 {
     $access = getIgnoreAccess();
     setIgnoreAccess();
     $count = getEntities(array("type" => "Notification", "count" => true, "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()))));
     setIgnoreAccess($access);
     return $count;
 }
 static function loggedInUserHasLiked($guid)
 {
     $likes = getEntities(array("type" => "Like", "limit" => 1, "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "container_guid", "value" => $guid))));
     if ($likes) {
         return true;
     }
     return false;
 }
 public function __construct()
 {
     $title = $body = $button = NULL;
     switch (pageArray(1)) {
         case "all":
         default:
             if (loggedIn()) {
                 $admin_groups = Setting::get("admin_groups");
                 if (!$admin_groups) {
                     $admin_groups = "users";
                 }
                 if ($admin_groups == "admin" && adminLoggedIn() || $admin_groups == "user") {
                     $button = "<a href='" . getSiteURL() . "groups/create' class='btn btn-success'>Create a Group</a>";
                 }
             }
             $title = "Groups";
             $body = display("pages/groups");
             break;
         case "create":
             $admin_groups = Setting::get("admin_groups");
             if (!$admin_groups) {
                 $admin_groups = "user";
             }
             if ($admin_groups == "admin" && adminLoggedIn() || $admin_groups == "user") {
                 $title = "Create a Group";
                 $body = drawForm(array("name" => "create_group", "action" => "createGroup", "method" => "post", "files" => true));
             }
             break;
         case "view":
             $guid = pageArray(2);
             $group = getEntity($guid);
             $edit_url = getSiteURL() . "groups/edit/{$guid}";
             $delete_url = addTokenToURL(getSiteURL() . "action/deleteGroup/{$guid}");
             if ($group->ownerIsLoggedIn()) {
                 $button = "<a href='{$edit_url}' class='btn btn-warning'>Edit Group</a>";
                 $button .= "<a href='{$delete_url}' class='btn btn-danger confirm'>Delete Group</a>";
             }
             if (GroupsPlugin::loggedInUserCanJoin($group)) {
                 $join_group_url = addTokenToURL(getSiteURL() . "action/JoinGroup/" . $group->guid);
                 $button .= "<a href='{$join_group_url}' class='btn btn-success confirm'>Join Group</a>";
             }
             if ($group->loggedInUserIsMember() && $group->owner_guid != getLoggedInUserGuid()) {
                 $leave_group_url = addTokenToURL(getSiteURL() . "action/LeaveGroup/" . $group->guid);
                 $button .= "<a href='{$leave_group_url}' class='btn btn-danger confirm'>Leave Group</a>";
             }
             $title = $group->title;
             $body = display("pages/group");
             break;
         case "edit":
             $guid = pageArray(2);
             $group = getEntity($guid);
             $title = "Edit " . $group->title;
             $body = drawForm(array("name" => "edit_group", "action" => "editGroup", "method" => "post", "files" => true));
             break;
     }
     $this->html = drawPage(array("header" => $title, "body" => $body, "button" => $button));
 }
 static function createComment($container_guid, $comment_body)
 {
     $owner_guid = getLoggedInUserGuid();
     $comment = new Comment();
     $comment->container_guid = $container_guid;
     $comment->body = $comment_body;
     $comment->owner_guid = $owner_guid;
     $comment->save();
 }
 static function unblock($guid)
 {
     $blocked = getEntity(array("type" => "Blockeduser", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "container_guid", "value" => $guid))));
     if ($blocked) {
         $blocked->delete();
         return true;
     }
     return false;
 }
 function __construct()
 {
     $guid = pageArray(2);
     $membership = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "group", "value" => $guid), array("name" => "member_guid", "value" => getLoggedInUserGuid()))));
     if ($membership) {
         $membership->delete();
         new SystemMessage("You have successfully left the group");
     }
     forward();
 }
 public function __construct($data)
 {
     $guid = $data['guid'];
     if (!LikesPlugin::loggedInUserHasLiked($guid)) {
         die;
     }
     $like = getEntity(array("type" => "Like", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "container_guid", "value" => $guid))));
     $like->delete();
     die;
 }
 public function __construct()
 {
     $limit = getInput("limit", 10);
     $offset = getInput("offset", 0);
     $count = getEntities(array("type" => "File", "count" => true, "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "NULL", "operand" => "!="))));
     $files = listEntities(array("type" => "File", "limit" => $limit, "offset" => $offset, "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "NULL", "operand" => "!="))));
     $pagination = display("page_elements/pagination", array("count" => $count, "offset" => $offset, "limit" => $limit, "url" => getSiteURL() . "files"));
     $page = drawPage(array("header" => "Files", "body" => $files, "footer" => $pagination, "button" => "<a href='" . getSiteURL() . "file/upload' class='btn btn-success'>Upload a File</a>"));
     $this->html = $page;
 }
 public function __construct()
 {
     $guid = pageArray(1);
     if (!$guid) {
         forward("profile/" . getLoggedInUserGuid());
     }
     $user = getEntity($guid);
     classGateKeeper($user, "User");
     $body = display("pages/profile", array("guid" => $guid));
     $this->html = drawPage(NULL, $body);
 }
 public function __construct($data)
 {
     $guid = $data['guid'];
     $chat = getEntity($guid);
     if (getLoggedInUserGuid() == $chat->user_one) {
         $chat->user_one_maximized = true;
     } else {
         $chat->user_two_maximized = true;
     }
     $chat->save();
 }
 function __construct($data)
 {
     $guid = $data['guid'];
     $chat = getEntity($guid);
     if ($chat->user_one == getLoggedInUserGuid()) {
         $chat->user_one_closed = true;
     } else {
         $chat->user_two_closed = true;
     }
     $chat->save();
 }
 public function __construct()
 {
     $guid = pageArray(2);
     $request = getEntity($guid);
     classGateKeeper($request, "Friendrequest");
     if ($request->guid_two == getLoggedInUserGuid()) {
         $request->status = "declined";
         $request->save();
         new SystemMessage("You have successfully declined this friend request.");
     }
     forward();
 }
 public function __construct()
 {
     gateKeeper();
     $topic = new Forumtopic();
     $topic->title = getInput("title");
     $topic->description = getInput("description");
     $topic->container_guid = getInput("container_guid");
     $topic->save();
     new SystemMessage("Your topic has been posted.");
     new Activity(getLoggedInUserGuid(), "forum:topic:posted", $params = array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $topic->getURL(), $topic->title, getEntity($topic->container_guid)->getURL(), getEntity($topic->container_guid)->title), getInput("container_guid"));
     forward("forum/category/" . getInput("container_guid"));
 }
 public function __construct($data = NULL)
 {
     gateKeeper();
     $logged_in_user = getLoggedInUser();
     if (!$data) {
         // Get the comment body
         $comment_body = getInput("comment");
         // Get container url
         $container_guid = getInput("guid");
     } else {
         $comment_body = $data['comment_body'];
         $container_guid = $data['container_guid'];
     }
     $container = getEntity($container_guid);
     $container_owner_guid = $container->owner_guid;
     if ($container_owner_guid) {
         $container_owner = getEntity($container_owner_guid);
     }
     $url = $container->getURL();
     if (!$url) {
         $url = getSiteURL();
     }
     // Create the comment
     CommentsPlugin::createComment($container_guid, $comment_body);
     if ($container_owner_guid) {
         if ($container_owner_guid != getLoggedInUserGuid()) {
             $params = array("to" => array($container_owner->full_name, $container_owner->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
             switch ($logged_in_user->getSetting("notify_when_comment")) {
                 case "email":
                     sendEmail($params);
                     break;
                 case "none":
                     break;
                 case "site":
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
                 case "both":
                     sendEmail($params);
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
             }
         }
     }
     runHook("add:comment:after");
     if (getLoggedInUserGuid() != $container_owner_guid && $container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container_owner->getURL(), $container_owner->full_name, $container->getURL(), translate($container->type), truncate($comment_body)));
     } elseif (!$container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment:own", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container->getURL(), $container->title, translate($container->type), truncate($comment_body)));
     }
     // Return to container page.
     forward();
 }
 public function __construct()
 {
     gateKeeper();
     $email_users = array();
     $container_guid = getInput("container_guid");
     $topic = getEntity($container_guid);
     $category_guid = $topic->container_guid;
     $category = getEntity($category_guid);
     $description = getInput("comment");
     $comment = new Forumcomment();
     $comment->description = $description;
     $comment->container_guid = $container_guid;
     $comment->category_guid = $category_guid;
     $comment->owner_guid = getLoggedInUserGuid();
     $comment->save();
     new SystemMessage("Your comment has been posted.");
     new Activity(getLoggedInUserGuid(), "forum:comment:posted", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $topic->getURL(), $topic->title, truncate($comment->description)), $container_guid, $category->access_id);
     $all_comments = getEntities(array("type" => "Forumcomment", "metadata_name" => "container_guid", "metadata_value" => $container_guid));
     $notify_users = array($topic->owner_guid);
     $container_owner_guid = $topic->owner_guid;
     $container_owner = getEntity($container_owner_guid);
     if ($container_owner->notify_when_forum_comment_topic_i_own == "email" || $container_owner->notify_when_forum_comment_topic_i_own == "both") {
         $email_users[] = $container_guid;
     }
     foreach ($all_comments as $comment) {
         $user_guid = $comment->owner_guid;
         $user = getEntity($user_guid);
         switch ($user->notify_when_forum_comment_topic_i_own) {
             case "both":
                 $notify_users[] = $comment->owner_guid;
                 $email_users[] = $comment->owner_guid;
                 break;
             case "email":
                 $email_users[] = $comment->owner_guid;
                 break;
             case "site":
                 $notify_users[] = $comment->owner_guid;
                 break;
             case "none":
                 break;
         }
     }
     $notify_users = array_unique($notify_users);
     foreach ($notify_users as $user_guid) {
         notifyUser("forumcomment", $container_guid, getLoggedInUserGuid(), $user_guid);
     }
     foreach ($email_users as $user) {
         $params = array("to" => array($user->full_name, $user->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
         sendEmail($params);
     }
     forward();
 }
 public function __construct()
 {
     $guid = pageArray(2);
     if (getLoggedInUserGuid() == $guid) {
         $notifications = getEntities(array("type" => "Notification", "owner_guid" => $guid));
         if ($notifications) {
             foreach ($notifications as $notification) {
                 $notification->delete();
             }
         }
     }
     forward();
 }
 /**
  * Creates notification page html
  */
 public function __construct()
 {
     $user_guid = getLoggedInUserGuid();
     $access = getIgnoreAccess();
     setIgnoreAccess();
     $notifications = listEntities(array("type" => "Notification", "metadata_name" => "owner_guid", "metadata_value" => $user_guid));
     setIgnoreAccess($access);
     $buttons = getSiteURL() . "action/deleteAllNotifications/{$user_guid}";
     $buttons = addTokenToURL($buttons);
     $buttons = "<a href='{$buttons}' class='btn btn-danger'>Dismiss All</a>";
     $page = drawPage(array("header" => "Notifications", "body" => $notifications, "button" => $buttons));
     $this->html = $page;
 }
예제 #28
0
 public function loggedInUserIsMember($logged_in_user_guid = false)
 {
     if ($logged_in_user_guid) {
         $guid = $logged_in_user_guid;
     } else {
         $guid = getLoggedInUserGuid();
     }
     $test = getEntity(array("type" => "Groupmembership", "metadata_name_value_pairs" => array(array("name" => "member_guid", "value" => $guid), array("name" => "group", "value" => $this->guid))));
     if ($test) {
         return true;
     }
     return false;
 }
 function __construct()
 {
     gateKeeper();
     $guid = pageArray(2);
     $blog = getEntity($guid);
     classGateKeeper($blog, "blog");
     $owner_guid = $blog->owner_guid;
     if ($owner_guid == getLoggedInUserGuid()) {
         $blog->delete();
         new SystemMessage("Your blog has been deleted");
         forward("blogs");
     }
 }
 public function __construct()
 {
     $title = $buttons = $body = NULL;
     if (BlogsPlugin::userCanCreateBlog()) {
         $body = display("page_elements/blogs_tabs");
         $buttons = "<a href='" . getSiteURL() . "blogs/add' class='btn btn-success'>Add a Blog</a>";
     }
     switch (pageArray(1)) {
         case "all_blogs":
         default:
             $title = "Blogs";
             $body .= display("pages/all_blogs");
             break;
         case "friends_blogs":
             $title = translate("friends_blogs");
             $body .= display("pages/friends_blogs");
             break;
         case "my_blogs":
             $title = "My Blogs";
             $body .= display("pages/my_blogs");
             break;
         case "add":
             if (BlogsPlugin::userCanCreateBlog()) {
                 $title = "Add a Blog";
                 $body = drawForm(array("name" => "add_blog", "method" => "post", "action" => "addBlog"));
             }
             break;
         case "view":
             $guid = pageArray(2);
             $blog = getEntity($guid);
             if ($blog) {
                 $title = $blog->title;
             }
             $owner = getEntity($blog->owner_guid);
             $title .= " <small>by {$owner->full_name}</small>";
             $body = display("pages/blog");
             if (getLoggedInUserGuid() == $blog->owner_guid) {
                 $edit_url = getSiteURL() . "blogs/edit/{$guid}";
                 $delete_url = addTokenToURL(getSiteURL() . "action/deleteBlog/{$guid}");
                 $buttons = "<a href='{$edit_url}' class='btn btn-warning'>Edit</a>";
                 $buttons .= "<a href='{$delete_url}' class='btn btn-danger confirm'>Delete</a>";
             }
             break;
         case "edit":
             $buttons = NULL;
             $title = "Edit your blog";
             $body = drawForm(array("name" => "edit_blog", "method" => "post", "action" => "addBlog"));
             break;
     }
     $this->html = drawPage(array("header" => $title, "body" => $body, "button" => $buttons));
 }