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 doAuth($info, $trusted = null, $fail_cancels = false) { if (!$info) { // There is no authentication information, so bail return authCancel(null); } $req_url = $info->identity; $user = getLoggedInUser(); setRequestInfo($info); if ($req_url != $user) { return login_render(array(), $req_url, $req_url); } $sites = getSessionSites(); $trust_root = $info->trust_root; $fail_cancels = $fail_cancels || isset($sites[$trust_root]); $trusted = isset($trusted) ? $trusted : isTrusted($req_url, $trust_root); if ($trusted) { setRequestInfo(); $server =& getServer(); $response =& $info->answer(true); $webresponse =& $server->encodeResponse($response); $new_headers = array(); foreach ($webresponse->headers as $k => $v) { $new_headers[] = $k . ": " . $v; } return array($new_headers, $webresponse->body); } elseif ($fail_cancels) { return authCancel($info); } else { return trust_render($info); } }
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 init($file) { if (!loggedIn()) { return false; } if (!is_a($file, "SocialApparatus\\File")) { return false; } $product = getEntity($file->container_guid); if (!is_a($product, "SocialApparatus\\Product")) { return false; } $user = getLoggedInUser(); if ($user->stripe_cust) { \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey()); $orders = \Stripe\Order::all(array("limit" => 300, "customer" => $user->stripe_cust)); foreach ($orders['data'] as $order) { foreach ($order->items as $item) { if ($item->description != "Taxes (included)" && $item->description != "Free shipping") { $sku = $item->parent; if ($sku == $product->stripe_sku) { return true; } } } } } return false; }
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() { $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); }
function __construct() { \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey()); $order_items = array(); $user = getLoggedInUser(); $stripe_cust = $user->stripe_cust; $cart = Cache::get("cart", "session"); if (!$stripe_cust) { try { $cu = \Stripe\Customer::create(array("description" => $user->email, "source" => getInput("stripeToken"))); } catch (Exception $e) { new SystemMessage("There has been an error. Please contact us."); forward("home"); } $user->stripe_cust = $cu->id; $user->save(); } else { $cu = \Stripe\Customer::retrieve($stripe_cust); try { $cu->source = getInput("stripeToken"); } catch (Exception $e) { new SystemMessage("There has been an error. Please contact us."); forward("home"); } $cu->save(); } foreach ($cart as $guid => $details) { $product = getEntity($guid); if ($product->interval == "one_time") { $order_item = array("type" => "sku", "parent" => $product->stripe_sku, "description" => $product->description . $details); $order_items[] = $order_item; } else { try { $cu->subscriptions->create(array("plan" => $guid)); } catch (Exception $e) { new SystemMessage("There has been an error. Please contact us."); forward("home"); } } } if (!empty($order_items)) { try { $order = \Stripe\Order::create(array("items" => $order_items, "currency" => "usd", "customer" => $cu->id)); $order->pay(array("customer" => $cu->id, "email" => $user->email)); } catch (Exception $e) { new SystemMessage("There has been an error. Please contact us."); forward("home"); } } $invoice = new Invoice(); $invoice->items = $cart; $invoice->status = "paid"; $invoice->owner_guid = getLoggedInUserGuid(); $invoice->stripe_order = $order->id; $invoice->save(); Cache::delete("cart", "session"); new SystemMessage("Your purchase is complete."); forward("billing"); }
function trust_render($info) { $current_user = getLoggedInUser(); $lnk = link_render($current_user); $trust_root = htmlspecialchars($info->trust_root); $trust_url = buildURL('trust', true); $form = sprintf(trust_form_pat, $lnk, $trust_root, $trust_url); return page_render($form, $current_user, 'Trust This Site'); }
public function __construct() { runHook("action:logout:before"); $user = getLoggedInUser(); if ($user) { $user->logout(); } runHook("action:logout:after"); new SystemMessage(translate("system_message:logged_out")); forward("home"); }
function sites_render($sites) { if ($sites) { $rows = siteList_render($sites); $form = sprintf(sites_form, buildURL('sites'), $rows); $body = $pre . $form; } else { $body = sprintf(sites_empty_message, link_render(buildURL(''), 'Return home')); } return page_render($body, getLoggedInUser(), 'Remembered Sites'); }
/** * Handle a standard OpenID server request */ function action_default() { header('X-XRDS-Location: ' . buildURL('idpXrds')); $server = getServer(); $method = $_SERVER['REQUEST_METHOD']; $request = null; if ($method == 'GET') { $request = $_GET; } else { $request = $_POST; } $request = $server->decodeRequest(); if (!$request) { return about_render(); } setRequestInfo($request); if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) { if ($request->idSelect()) { // Perform IDP-driven identifier selection if ($request->mode == 'checkid_immediate') { $response = $request->answer(false); } else { return trust_render($request); } } else { if (!$request->identity && !$request->idSelect()) { // No identifier used or desired; display a page saying // so. return noIdentifier_render(); } else { if ($request->immediate) { $response = $request->answer(false, buildURL()); } else { if (!getLoggedInUser()) { return login_render(); } return trust_render($request); } } } } else { $response = $server->handleRequest($request); } $webresponse = $server->encodeResponse($response); if ($webresponse->code != AUTH_OPENID_HTTP_OK) { header(sprintf("HTTP/1.1 %d ", $webresponse->code), true, $webresponse->code); } foreach ($webresponse->headers as $k => $v) { header("{$k}: {$v}"); } header(header_connection_close); print $webresponse->body; exit(0); }
/** * Render the about page, potentially with an error message */ function about_render($error = false, $internal = true) { $headers = array(); $body = sprintf(about_body, buildURL()); if ($error) { $headers[] = $internal ? http_internal_error : http_bad_request; $body .= sprintf(about_error_template, htmlspecialchars($error)); } $current_user = getLoggedInUser(); return page_render($body, $current_user, 'OpenID Server Endpoint'); }
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(); }
/** * Return whether the trust root is currently trusted * */ function isTrusted($identity_url, $trust_root, $return_to) { global $store; if ($identity_url != getLoggedInUser()) { return false; } $sites = $store->getTrustedSites($identity_url); if (empty($sites)) { return false; } else { return in_array($trust_root, $sites) && fnmatch($trust_root . '*', $return_to); } }
function trust_render($info) { $current_user = getLoggedInUser(); $lnk = link_render(idURL($current_user)); $trust_root = htmlspecialchars($info->trust_root); $trust_url = buildURL('trust', true); if ($info->idSelect()) { $prompt = id_select_pat; } else { $prompt = sprintf(normal_pat, $lnk, $trust_root); } $form = sprintf(trust_form_pat, $trust_url, $prompt); return page_render($form, $current_user, 'Trust This Site'); }
public function __construct() { $guid = pageArray(2); if (GroupsPlugin::loggedInUserCanJoin($guid)) { $membership = new Groupmembership(); $membership->group = $guid; $membership->member_guid = getLoggedInUserGuid(); $membership->save(); new SystemMessage("You have successfully joined a group"); $group = getEntity($guid); new Activity(getLoggedInUserGuid(), "group:joined", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $group->getURL(), $group->title), $guid, $group->access_id); forward(); } }
/** * Handle a standard OpenID server request */ function action_default() { global $store; $server =& getServer(); $method = $_SERVER['REQUEST_METHOD']; /*$request = null; if ($method == 'GET') { $request = $_GET; } else { $request = $_POST; } */ $request = $server->decodeRequest(); if (!$request) { return ""; //about_render(); } setRequestInfo($request); if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) { $identity = getLoggedInUser(); if (isTrusted($identity, $request->trust_root, $request->return_to)) { if ($request->message->isOpenID1()) { $response =& $request->answer(true); } else { $response =& $request->answer(true, false, getServerURL(), $identity); } } else { if ($request->immediate) { $response =& $request->answer(false, getServerURL()); } else { if (!getLoggedInUser()) { $_SESSION['last_forward_from'] = current_page_url() . '?' . http_build_query(Auth_OpenID::getQuery()); system_message(elgg_echo('openid_server:not_logged_in')); forward('login'); } return trust_render($request); } } addSregFields(&$response); } else { $response =& $server->handleRequest($request); } $webresponse =& $server->encodeResponse($response); foreach ($webresponse->headers as $k => $v) { header("{$k}: {$v}"); } header(header_connection_close); print $webresponse->body; exit(0); }
public function __construct($data) { $guid = $data['guid']; if (LikesPlugin::loggedInUserHasLiked($guid)) { die; } $entity = getEntity($guid); $owner_guid = $entity->owner_guid; $owner = getEntity($owner_guid); $like = new Like(); $like->container_guid = $guid; $like->owner_guid = getLoggedInUserGuid(); $like->save(); new Activity(getLoggedInUserGuid(), "activity:like", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $owner->getURL(), $owner->full_name, $entity->getURL(), translate($entity->type))); notifyUser("like", $guid, getLoggedInUserGuid(), $owner_guid); die; }
public function __construct() { $title = getInput("title"); $description = getInput("description"); Security::checkForEmptyFields(array("title")); $logged_in_user = getLoggedInUser(); $logged_in_user_guid = $logged_in_user->guid; $album = new Videoalbum(); $album->title = $title; $album->description = $description; $album->owner_guid = $logged_in_user_guid; $album->save(); $album->createAvatar(); new Activity(getLoggedInUserGuid(), "activity:video:album:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $album->getURL(), $album->title, $album->icon(EXTRALARGE, "img-responsive"))); new SystemMessage("Your album has been created."); forward("videos"); }
function login_render($errors = null, $input = null, $needed = null) { $current_user = getLoggedInUser(); if ($input === null) { $input = $current_user; } if ($needed) { $errors[] = sprintf(login_needed_pat, link_render($needed)); } $esc_input = htmlspecialchars($input, ENT_QUOTES); $login_url = buildURL('login', true); $body = sprintf(login_form_pat, $login_url, $esc_input); if ($errors) { $body = loginError_render($errors) . $body; } return page_render($body, $current_user, 'Log In', null, true); }
/** * Handle a standard OpenID server request */ function action_default() { $server =& getServer(); $method = $_SERVER['REQUEST_METHOD']; $request = null; if ($method == 'GET') { $request = $_GET; } else { $request = $_POST; } $request = Auth_OpenID::fixArgs($request); $request = $server->decodeRequest($request); if (!$request) { return about_render(); } setRequestInfo($request); if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) { if (isTrusted($request->identity, $request->trust_root)) { $response =& $request->answer(true); $sreg = getSreg($request->identity); if (is_array($sreg)) { foreach ($sreg as $k => $v) { $response->addField('sreg', $k, $v); } } } else { if ($request->immediate) { $response =& $request->answer(false, getServerURL()); } else { if (!getLoggedInUser()) { return login_render(); } return trust_render($request); } } } else { $response =& $server->handleRequest($request); } $webresponse =& $server->encodeResponse($response); foreach ($webresponse->headers as $k => $v) { header("{$k}: {$v}"); } header(header_connection_close); print $webresponse->body; exit(0); }
function doAuth($info, $trusted = null, $fail_cancels = false, $idpSelect = null) { if (!$info) { // There is no authentication information, so bail return authCancel(null); } if ($info->idSelect()) { if ($idpSelect) { $req_url = idURL($idpSelect); } else { $trusted = false; } } else { $req_url = $info->identity; } $user = getLoggedInUser(); setRequestInfo($info); if (!$info->idSelect() && $req_url != idURL($user)) { return login_render(array(), $req_url, $req_url); } $trust_root = $info->trust_root; if ($trusted) { setRequestInfo(); $server =& getServer(); $response =& $info->answer(true, null, $req_url); // Answer with some sample Simple Registration data. $sreg_data = array('fullname' => 'Example User', 'nickname' => 'example', 'dob' => '1970-01-01', 'email' => '*****@*****.**', 'gender' => 'F', 'postcode' => '12345', 'country' => 'ES', 'language' => 'eu', 'timezone' => 'America/New_York'); // Add the simple registration response values to the OpenID // response message. $sreg_request = Auth_OpenID_SRegRequest::fromOpenIDRequest($info); $sreg_response = Auth_OpenID_SRegResponse::extractResponse($sreg_request, $sreg_data); $sreg_response->toMessage($response->fields); // Generate a response to send to the user agent. $webresponse =& $server->encodeResponse($response); $new_headers = array(); foreach ($webresponse->headers as $k => $v) { $new_headers[] = $k . ": " . $v; } return array($new_headers, $webresponse->body); } elseif ($fail_cancels) { return authCancel($info); } else { return trust_render($info); } }
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(); }
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() { $editor = getInput("editor_id"); // Check if General album exists $album = getEntity(array("type" => "Videoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "General")))); $logged_in_user = getLoggedInUser(); $logged_in_user_guid = $logged_in_user->guid; $title = getInput("title"); $description = getInput("description"); if (!file_exists($_FILES['video_file']['tmp_name']) || !is_uploaded_file($_FILES['video_file']['tmp_name'])) { $video_type = "youtube"; } else { $video_type = "upload"; } $video = new Video(); $video->video_type = $video_type; $video->title = $title; $video->description = $description; $video->owner_guid = getLoggedInUserGuid(); $video->access_id = getInput("access_id"); $video->save(); if ($video_type == "youtube") { $video->url = getInput("url"); } else { $guid = VideosPlugin::processUploadedVideo("video_file", $video); $video->video_guid = $guid; $video->save(); $video->createAvatar(); } $video->save(); new Activity(getLoggedInUserGuid(), "activity:video:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $video->getURL(), $video->title, $video->getURL(), $video->icon(LARGE, "img-responsive"))); new SystemMessage("Your video has been uploaded."); if (!$album) { $album = new Videoalbum(); $album->title = "General"; $album->owner_guid = getLoggedInUserGuid(); $album->save(); } $video->container_guid = $album->guid; $video->save(); forward(false, array("insertvideo" => $video->guid, "editor" => $editor)); }