public function __construct() { gateKeeper(); $message = NULL; $user = getLoggedInUser(); $user->profile_complete = true; $profile_type = $user->profile_type; $fields = ProfileField::get($profile_type); foreach ($fields as $key => $field) { if ($field['required'] == "true" && !getInput($key)) { $message .= "{$field['label']} cannot be empty."; } } if ($message) { new SystemMessage($message); forward("editProfile"); } foreach ($fields as $key => $field) { $user->{$key} = getInput($key); } $user->save(); new Activity($user->guid, "activity:profile:updated", array($user->getURL(), $user->full_name)); new SystemMessage("Your profile has been updated."); forward("profile/{$user->guid}"); }
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"); }
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() { gateKeeper(); $guid = pageArray(2); BlockUserPlugin::block($guid); new SystemMessage("User has been blocked."); forward(); }
public function __construct() { $title = $body = $buttons = $breadcrumbs = NULL; switch (pageArray(1)) { default: $body = display("pages/forum"); $title = "Forum Categories"; if (adminLoggedIn()) { $add_category_url = getSiteURL() . "forum/add_category"; $buttons = "<a href='{$add_category_url}' class='btn btn-danger'>Add a Category</a>"; } $breadcrumbs = array(array("link" => getSiteURL() . "forum", "label" => "Categories")); break; case 'add_category': adminGateKeeper(); $body = drawForm(array("name" => "add_category", "method" => "post", "action" => "addCategory")); $title = "Add a Forum Category"; break; case 'category': $guid = pageArray(2); if ($guid) { $category = getEntity($guid); $body = display("forum/category"); if (loggedIn()) { $add_topic_url = getSiteURL() . "forum/add_topic/{$guid}"; $buttons = "<a href='{$add_topic_url}' class='btn btn-success'>Add Topic</a>"; } } $breadcrumbs = array(array("link" => getSiteURL() . "forum", "label" => "Categories"), array("link" => getSiteURL() . "forum/category/" . $category->guid, "label" => $category->title)); break; case "add_topic": gateKeeper(); $category_guid = pageArray(2); $category = getEntity($category_guid); $body = drawForm(array("name" => "add_topic", "method" => "post", "action" => "addTopic")); $title = "Add a topic to {$category->title}"; break; case "topic": $topic = getEntity(pageArray(2)); $category = getEntity($topic->container_guid); $breadcrumbs = array(array("link" => getSiteURL() . "forum", "label" => "Categories"), array("link" => getSiteURL() . "forum/category/" . $category->guid, "label" => $category->title), array("link" => getSiteURL() . "forum/topic/" . $topic->guid, "label" => $topic->title)); $body = display("forum/topic"); break; case "editCategory": adminGateKeeper(); $title = "Edit Forum Category"; $body = drawForm(array("name" => "edit_category", "method" => "post", "action" => "editCategory'")); break; case "editTopic": adminGateKeeper(); $title = "Edit Forum Topic"; $body = drawForm(array("name" => "edit_topic", "method" => "post", "action" => "editTopic")); break; } $this->html = drawPage(array("header" => $title, "body" => $body, "button" => $buttons, "breadcrumbs" => $breadcrumbs)); }
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() { 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($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(); }
function __construct() { gateKeeper(); $user = getLoggedInUser(); $subscription = pageArray(2); if ($subscription && $user->stripe_cust) { \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey()); $cu = \Stripe\Customer::retrieve($user->stripe_cust); $cu->subscriptions->retrieve($subscription)->cancel(); new SystemMessage("Your subscription has been canceled."); } forward(); }
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"); } }
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() { gateKeeper(); $page = getInput("p"); $name = getInput("name"); $reason = getInput("reason"); $r = new Reportedcontent(); $r->page = $page; $r->name = $name; $r->reason = $reason; $r->owner_guid = getLoggedInUserGuid(); $r->save(); $admin_guids = getAdminGuidarray(); foreach ($admin_guids as $admin_guid) { notifyUser("reportedcontent", $r->guid, getLoggedInUserGuid(), $admin_guid); } forward("reportThis/reportSent"); }
public function __construct() { gateKeeper(); $tab = getInput("tab"); $settings = Cache::get("user_settings", "session"); if (!$settings) { $settings = array(); } $user = getLoggedInUser(); foreach ($settings as $name => $setting) { if ($setting['tab'] == $tab) { $user->{$name} = getInput($name); } } $user->save(); new SystemMessage("Your preferences have been saved."); forward(); }
public function __construct() { gateKeeper(); $guid = getInput("guid"); $title = getInput("title"); $description = getInput("description"); $access_id = getInput("access_id"); $membership = getInput("membership"); $group = getEntity($guid); $group->title = $title; $group->description = $description; $group->access_id = $access_id; $group->membership = $membership; $group->owner_guid = getLoggedInUserGuid(); $group->save(); if (isset($_FILES['avatar']['tmp_name'])) { $group->createAvatar(); } new SystemMessage("Your group has been updated."); forward("groups"); }
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(); }
public function __construct($data = array()) { gateKeeper(); $guid = getInput("guid"); if (!$guid) { $guid = $data['guid']; } $user = getLoggedInUser(); $status = getInput("status"); if (!$status) { $status = $data['status']; } else { Security::checkForEmptyFields(array("status")); } if ($guid == $user->guid) { if (strpos($status, "<img") == false || strpos($status, "<img") == false) { $user->profile_status = $status; $user->save(); } } $status = display("output/editor", array("value" => $status)); $s = new Profilestatus(); $s->description = $status; $s->owner_guid = getLoggedInUserGuid(); $s->container_guid = $guid; $s->owner_full_name = getLoggedInUser()->full_name; $s->owner_icon = getLoggedInUser()->icon; $s->save(); $owner = getEntity($guid); if ($guid == $user->guid) { new Activity($guid, "activity:status:update:self", array($user->getURL(), $user->full_name, truncate($status))); } else { new Activity($user->guid, "activity:status:update:friend", array($user->getURL(), $user->full_name, $owner->getURL(), $owner->full_name, truncate($status))); } forward(); }
public function __construct() { if (!pageArray(2)) { return false; } gateKeeper(); $user1 = getLoggedInUser(); $guid = pageArray(2); $user2 = getEntity($guid); $relationships = getEntities(array("type" => "Friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $user1->guid), array("name" => "guid_two", "value" => $guid)))); $relationships2 = getEntities(array("type" => "Friend", "metadata_name_value_pairs" => array(array("name" => "guid_one", "value" => $guid), array("name" => "guid_two", "value" => $user1->guid)))); if ($relationships) { foreach ($relationships as $relationship) { $relationship->delete(); } } if ($relationships2) { foreach ($relationships2 as $relationship) { $relationship->delete(); } } new SystemMessage(translate("remove:friend:success", $user2->first_name . " " . $user2->last_name)); forward(); }
function __construct() { $header = $body = NULL; switch (pageArray(1)) { default: gateKeeper(); $header = "Report this page to the site admin."; $body = drawForm(array("name" => "reportThis", "action" => "reportThis", "method" => "post")); break; case "reportSent": $header = "Your report has been sent."; $body = "<p>Thank you for your report. Our community relies on users like you to keep it safe.</p><p>We will review your report, and make a decision within 24 hours.</p>"; break; case "view": switch (pageArray(2)) { default: break; case "": break; } break; } $this->html = drawPage(array("header" => $header, "body" => $body)); }
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * * * @author Shane Barron <*****@*****.**> * @author Aaustin Barron <*****@*****.**> * @copyright 2015 SocialApparatus * @license http://opensource.org/licenses/MIT MIT * @version 1 * @link http://socialapparatus.com */ namespace SocialApparatus; denyDirect(); gateKeeper(); $user = getLoggedInUser(); if ($user->stripe_cust) { \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey()); $subscriptions = \Stripe\Customer::retrieve($user->stripe_cust)->subscriptions->all(array('limit' => 300)); $orders = \Stripe\Order::all(array("limit" => 300, "customer" => $user->stripe_cust)); ?> <h2>Orders</h2> <table class='table table-striped table-hover table-bordered'> <tr> <th>Date</th> <th>Order ID</th> <th>Amount</th> <th>Status</th> <th>Details</th> </tr>
function __construct() { gateKeeper(); $page = display("pages/messages"); $this->html = drawPage(array("header" => NULL, "body" => $page)); }
/** * Creates html for my settings page */ public function __construct() { gateKeeper(); $this->html = display("pages/settings"); }
public function __construct() { gateKeeper(); $title = $body = $button = $wrapper_class = NULL; switch (pageArray(1)) { case "view": $guid = pageArray(2); $video = getEntity($guid); if ($video) { if ($video->title) { $title = $video->title; } else { $title = " "; } if (getLoggedInUserGuid() == $video->owner_guid || adminLoggedIn()) { $delete_url = addTokenToURL(getSiteURL() . "action/deleteVideo/{$guid}"); $button = "<a class='btn btn-info' href='" . getSiteURL() . "videos/edit/{$guid}'>Edit</a>"; $button .= "<a class='btn btn-danger confirm' href='{$delete_url}'>Delete</a>"; } $body = display("pages/video"); } else { forward(); } break; case "edit": $title = "Edit Video Details"; $body = drawForm(array("name" => "edit_video", "method" => "post", "action" => "editVideo")); break; case "add": $title = "Add a Video"; $body = drawForm(array("name" => "add_video", "method" => "post", "action" => "AddVideo", "enctype" => "multipart/form-data")); break; default: case "albums": switch (pageArray(2)) { default: $guid = pageArray(1); if (!$guid) { $guid = getLoggedInUserGuid(); } $user = getEntity($guid); if ($guid == getLoggedInUserGuid()) { $name = "My"; } else { $name = $user->full_name . "'s"; } $title = $name . " Video Albums"; $body = display("pages/video_albums"); $button = "<a class='btn btn-success' href='" . getSiteURL() . "videos/albums/add'>Create an Album</a>"; break; case "add": $title = "Add a Video Album"; $body = drawForm(array("name" => "add_video_album", "method" => "post", "action" => "addVideoalbum", "class" => "add_video_album_form", "enctype" => "multipart/form-data")); break; case "view": $guid = pageArray(3); $album = getEntity($guid); $title = $album->title; $body = display("pages/video_album"); $delete_url = getSiteURL() . "action/deleteVideoalbum/{$guid}"; $delete_url = addTokenToURL($delete_url); if (getLoggedInUserGuid() == $album->owner_guid || adminLoggedIn()) { $button = "<a class='btn btn-info' href='" . getSiteURL() . "videos/albums/edit/{$guid}'>Edit Album</a>"; $button .= "<a class='btn btn-danger' href='{$delete_url}'>Delete Album</a>"; } $button .= "<a class='btn btn-success' href='" . getSiteURL() . "videos/add/{$guid}'>Add Video</a>"; $wrapper_class = "masonry4col"; break; case "edit": $body = drawForm(array("name" => "edit_video_album", "method" => "post", "action" => "editVideoalbum", "enctype" => "multipart/form-data")); $title = "Edit Album"; break; } } $this->html = drawPage(array("header" => $title, "body" => $body, "button" => $button, "wrapper_class" => $wrapper_class)); }