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();
     }
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = getInput("guid");
     $title = getInput("title");
     $description = getInput('description');
     $price = getInput("price");
     $hidden = getInput("hidden") == 0 ? false : true;
     $product = getEntity($guid);
     $product->title = $title;
     $product->description = $description;
     $product->price = $price;
     $product->hidden = $hidden;
     $product->save();
     $product->createAvatar();
     if (isset($_FILES["download"]) && $_FILES["download"]["name"]) {
         $file = new File();
         $file->access_id = "product";
         $file->container_guid = $product->guid;
         $guid = $file->save();
         uploadFile("download", $guid, array("zip"));
         $product->download = $guid;
     }
     new SystemMessage("Your product has been updated.");
     forward("store");
 }
 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($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));
         }
     }
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $product = getEntity($guid);
     \Stripe\Stripe::setApiKey(EcommercePlugin::secretKey());
     if ($product->interval != "one_time") {
         try {
             $plan = \Stripe\Plan::retrieve($guid);
             $plan->delete();
         } catch (Exception $e) {
             forward();
         }
     } else {
         if ($product->stripe_sku) {
             $sku = \Stripe\SKU::retrieve($product->stripe_sku);
             $sku->delete();
         }
         if ($product->stripe_product_id) {
             $stripe_product = \Stripe\Product::retrieve($product->stripe_product_id);
             $stripe_product->delete();
         }
     }
     $product->delete();
     new SystemMessage("Your product has been deleted.");
     forward("store");
 }
 public function __construct()
 {
     runHook("action:login:before");
     $email = getInput("email");
     $access = getIgnoreAccess();
     $referer = getInput("referer");
     $user = getEntity(array("type" => "User", "metadata_name" => "email", "metadata_value" => $email), true, true);
     if ($user) {
         $password = getInput("password");
         $password1 = md5($password);
         $password2 = $user->password;
         if ($password1 == $password2) {
             $user->logIn();
             new SystemMessage(translate("system_message:logged_in"));
             runHook("action:login:after", array("user" => $user));
             if ($referer) {
                 forward($referer);
             }
         } else {
             new SystemMessage(translate("system_message:could_not_log_in"));
         }
     } else {
         new SystemMessage(translate("system_message:could_not_log_in"));
     }
     forward("home");
 }
 function __construct($notification)
 {
     $sender_guid = $notification->sender_guid;
     $sender = getEntity($sender_guid);
     $this->message = translate("friend_request_notification", array($sender->full_name));
     $this->link = $sender->getURL();
 }
Example #8
0
    /**
     * Base sql request for calendar events
     * 
     * @param int calendar user id
     * @param int actioncomm object id
     * @return string
     */
    public function getSqlCalEvents($calid, $oid = false, $ouri = false)
    {
        // TODO : replace GROUP_CONCAT by
        $sql = 'SELECT 
					a.tms AS lastupd, 
					a.*, 
					s.nom AS soc_nom, 
					sp.firstname, 
					sp.lastname,
                    (SELECT GROUP_CONCAT(u.login) FROM ' . MAIN_DB_PREFIX . 'actioncomm_resources ar
						LEFT OUTER JOIN ' . MAIN_DB_PREFIX . 'user AS u ON (u.rowid=fk_element) 
						WHERE ar.element_type=\'user\' AND fk_actioncomm=a.id) AS other_users
                FROM ' . MAIN_DB_PREFIX . 'actioncomm AS a';
        if (!$this->user->rights->societe->client->voir) {
            $sql .= ' LEFT OUTER JOIN ' . MAIN_DB_PREFIX . 'societe_commerciaux AS sc ON (a.fk_soc = sc.fk_soc AND sc.fk_user='******')
                    LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON (s.rowid = sc.fk_soc)
                    LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople AS sp ON (sp.fk_soc = sc.fk_soc AND sp.rowid = a.fk_contact)
                    LEFT JOIN ' . MAIN_DB_PREFIX . 'actioncomm_cdav AS ac ON (a.id = ac.fk_object)';
        } else {
            $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON (s.rowid = a.fk_soc)
                    LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople AS sp ON (sp.rowid = a.fk_contact)
                    LEFT JOIN ' . MAIN_DB_PREFIX . 'actioncomm_cdav AS ac ON (a.id = ac.fk_object)';
        }
        $sql .= ' WHERE 	a.id IN (SELECT ar.fk_actioncomm FROM ' . MAIN_DB_PREFIX . 'actioncomm_resources ar WHERE ar.element_type=\'user\' AND ar.fk_element=' . intval($calid) . ')
						AND a.code IN (SELECT cac.code FROM ' . MAIN_DB_PREFIX . 'c_actioncomm cac WHERE cac.type<>\'systemauto\')
						AND a.entity IN (' . getEntity('societe', 1) . ')';
        if ($oid !== false) {
            if ($ouri === false) {
                $sql .= ' AND a.id = ' . intval($oid);
            } else {
                $sql .= ' AND (a.id = ' . intval($oid) . ' OR ac.uuidext = \'' . $this->db->escape($ouri) . '\')';
            }
        }
        return $sql;
    }
 public function __construct()
 {
     if (!pageArray(2)) {
         forward("admin/plugins");
     }
     $guid = pageArray(2);
     adminGateKeeper();
     $plugin = getEntity($guid);
     classGateKeeper($plugin, "Plugin");
     $plugin->status = "disabled";
     $plugin->save();
     Cache::clear();
     Cache::clear();
     Admintab::deleteAll();
     Setting::updateSettingsTable();
     clearCache();
     Cache::clear();
     Systemvariable::set("setup_complete", false);
     $translations = getEntities(array("type" => "Translationentity"));
     if ($translations) {
         foreach ($translations as $translation) {
             $translation->delete();
         }
     }
     new SystemMessage("Your plugin has been disabled.");
     forward("admin/plugins");
 }
Example #10
0
	/**
	 *	Charge indicateurs this->nb de tableau de bord
	 *
	 *	@return     int         <0 if KO, >0 if OK
	 */
	function load_state_board()
	{
		global $conf, $user;

		$this->nb=array();

		$sql = "SELECT count(p.rowid) as nb";
		$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
		$sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')';
		$sql.= " AND p.fk_product_type = 1";

		$resql=$this->db->query($sql);
		if ($resql)
		{
			while ($obj=$this->db->fetch_object($resql))
			{
				$this->nb["services"]=$obj->nb;
			}
			return 1;
		}
		else
		{
			dol_print_error($this->db);
			$this->error=$this->db->error();
			return -1;
		}
	}
 function __construct($notification)
 {
     $target_guid = $notification->target_guid;
     $target = getEntity($target_guid);
     $this->message = "There is new user reported content.";
     $this->link = $target->getURL();
 }
 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();
     $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();
     $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()
 {
     $guid = pageArray(2);
     adminGateKeeper();
     $plugin = getEntity($guid);
     Setting::updateSettingsTable();
     clearCache();
     Cache::clear();
     Cache::clear();
     if ($plugin->enable()) {
         new SystemMessage("Plugin Enabled");
         new Cache("enabled_plugins_", false, "site");
         new Cache("enabled_plugins_reversed", false, "site");
         Systemvariable::set("setup_complete", false);
         forward("admin/plugins");
     }
     Setting::updateSettingsTable();
     clearCache();
     Cache::clear();
     Cache::clear();
     Admintab::deleteAll();
     $translations = getEntities(array("type" => "Translationentity"));
     if ($translations) {
         foreach ($translations as $translation) {
             $translation->delete();
         }
     }
     new SystemMessage("Your plugin can't be enabled.  Check requirements");
     forward("admin/plugins");
 }
 public function __construct()
 {
     $password = getInput("password");
     $password2 = getInput("password2");
     if ($password != $password2) {
         new SystemMessage("Passwords must match.");
     }
     $guid = getInput("guid");
     $code = getInput("code");
     $access = getIgnoreAccess();
     setIgnoreAccess();
     $user = getEntity($guid);
     if ($user) {
         if ($user->password_reset_code == $code) {
             $user->password = password_hash($password, PASSWORD_BCRYPT);
             $user->password_reset_code = NULL;
             $user->save();
             new SystemMessage("Your password has been reset.");
             forward("home");
         }
     } else {
         new SystemMessage("No user found with that email.");
         forward("home");
     }
     setIgnoreAccess($access);
 }
 /**
  *  Load indicators into this->nb for board
  *
  *  @return     int         <0 if KO, >0 if OK
  */
 function load_state_board()
 {
     global $conf, $user;
     $this->nb = array("customers" => 0, "prospects" => 0);
     $clause = "WHERE";
     $sql = "SELECT count(s.rowid) as nb, s.client";
     $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
     if (!$user->rights->societe->client->voir && !$user->societe_id) {
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON s.rowid = sc.fk_soc";
         $sql .= " WHERE sc.fk_user = "******"AND";
     }
     $sql .= " " . $clause . " s.client IN (1,2,3)";
     $sql .= ' AND s.entity IN (' . getEntity($this->element, 1) . ')';
     $sql .= " GROUP BY s.client";
     $resql = $this->db->query($sql);
     if ($resql) {
         while ($obj = $this->db->fetch_object($resql)) {
             if ($obj->client == 1 || $obj->client == 3) {
                 $this->nb["customers"] += $obj->nb;
             }
             if ($obj->client == 2 || $obj->client == 3) {
                 $this->nb["prospects"] += $obj->nb;
             }
         }
         $this->db->free($resql);
         return 1;
     } else {
         dol_print_error($this->db);
         $this->error = $this->db->error();
         return -1;
     }
 }
 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();
 }
 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");
 }
 public function __construct($data)
 {
     if (isset($data['session'])) {
         $guid = $data['guid'];
         $title = $data['blog_title'];
         $description = $data['description'];
         $access_id = $data['access_id'];
         $user = getUserFromSession($data['session']);
         if (!$guid) {
             $blog = new Blog();
             $blog->owner_guid = $user->guid;
             $blog->save();
         } else {
             $blog = getEntity($guid);
         }
         if ($blog->owner_guid == $user->guid) {
             $blog->title = $title;
             $blog->description = $description;
             $blog->access_id = $access_id;
             $blog->status = "draft";
             $guid = $blog->save();
             $blog = getEntity($guid);
             echo json_encode(array("guid" => $guid, "timeago" => display("output/friendly_time", array("timestamp" => $blog->last_updated))));
         }
     }
 }
Example #21
0
 /**
  *  Load data into info_box_contents array to show array later.
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 5)
 {
     global $user, $langs, $db, $conf;
     $langs->load("boxes");
     $this->max = $max;
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
     if ($user->rights->societe->lire) {
         $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status";
         $sql .= ", s.nom as socname";
         $sql .= ", s.code_client";
         $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as sp";
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON sp.fk_soc = s.rowid";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= " WHERE sp.entity IN (" . getEntity('societe', 1) . ")";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = "******" AND sp.fk_soc = " . $user->societe_id;
         }
         $sql .= " ORDER BY sp.tms DESC";
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $contactstatic = new Contact($db);
             $societestatic = new Societe($db);
             $line = 0;
             while ($line < $num) {
                 $objp = $db->fetch_object($result);
                 $datec = $db->jdate($objp->datec);
                 $datem = $db->jdate($objp->tms);
                 $contactstatic->id = $objp->id;
                 $contactstatic->lastname = $objp->lastname;
                 $contactstatic->firstname = $objp->firstname;
                 $contactstatic->civility_id = $objp->civility_id;
                 $contactstatic->statut = $objp->status;
                 $societestatic->id = $objp->fk_soc;
                 $societestatic->code_client = $objp->code_client;
                 $societestatic->name = $objp->socname;
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $contactstatic->getNomUrl(1), 'asis' => 1);
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : '', 'asis' => 1);
                 $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day"));
                 $this->info_box_contents[$line][] = array('td' => 'align="right" class="nowrap" width="18"', 'text' => $contactstatic->getLibStatut(3), 'asis' => 1);
                 $line++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedContacts"));
             }
             $db->free($result);
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     } else {
         $this->info_box_contents[0][0] = array('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
 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");
 }
 static function get($handler)
 {
     $return = getEntity(array("type" => "Accesshandler", "metadata_name" => "handler", "metadata_value" => $handler));
     if ($return) {
         return $return->handler;
     }
     return false;
 }
 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;
 }
 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));
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $report = getEntity($guid);
     $report->closed = true;
     $report->save();
     forward("admin/reported_content");
 }
 static function isCallable($function)
 {
     $test = getEntity(array("type" => "Exposedfunction", "metadata_name" => "name", "metadata_value" => $function));
     if ($test) {
         return true;
     } else {
         return false;
     }
 }
 public function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $activity = getEntity($guid);
     $activity->delete();
     new SystemMessage("Your activity has been deleted.");
     forward();
 }
 function __construct()
 {
     adminGateKeeper();
     $guid = pageArray(2);
     $page = getEntity($guid);
     $page->delete();
     new SystemMessage("Your page has been deleted.");
     forward("admin/custom_pages");
 }
 function __construct($notification)
 {
     $target_guid = $notification->target_guid;
     $target = getEntity($target_guid);
     $sender_guid = $notification->sender_guid;
     $sender = getEntity($sender_guid);
     $this->message = translate("like_notification", array($sender->full_name));
     $this->link = $target->getURL();
 }