[Elgg 1.8-1.12 & 2.X: Gifts] v1.8.0beta1

Release Notes

Initial release! Please test it before using on a productive site!

  • Updated Gifts plugin for Elgg 1.8,
  • Several fixes since Elgg 1.7 version.
  • I get an issue where even though the user has UserPoints, the ammount the ycan utilise for Gifts shows as 0, hence I can't send a gift ?

    The Userpoints plugin is above this plugin i nthe plugin list and is working fine.

    Also it's not clear what image format the gifts should be. Even when it's a jpg it appear to have transparency..

    Please advise.

  • @Andy: have you upgraded the Userpoints plugin to version 1.8.1beta4? I found a bug in a function the Gifts plugin uses and fixed it with beta4. This should fix the issue with always 0 points showing.

    The transparency issue is new to me. Jpg images should work (and I believe jpg doesn't support transparency, or does it?). The Gifts plugin utilizes Elgg's built-in resizing mechanism for images when uploading them (i.e. the resizing is done by the GD php extension). Apart from creating resized versions of the images they are not changed by the Gifts plugin. Have you tested the same image(s) when uploading them for example to the files section? Do they show transparency there, too?

  • private gifts are not showing......plz help.

    remaining all works gud

  • @Amit: this "bug" was already included in earlier versions. The reason is that an Elgg entity can only have one owner. In case of the gifts plugin the owner of the gift entity is the sender. This results in the problem that a gift sent with access level private is invisible for the receiver as he's not the owner.

    I found a solution to display private gifts at least on the "My gifts" page also for the receiver. I will post an updated version soon. I only want to do a bit of brainstorming if private gifts can also be displayed in "All gifts" and in the gifts widget. The problem here is that there's no easy way to filter the receiver of a gift depending on the user viewing the page (as a private gift should only be shown in case receiver = viewer).

  • @iionly, why don't you create a hook handler for permissions can edit? In theory a gift received can be deleted by the recipient, in which case it will delete it for both...

  • Nudeler2

    Recommended addon!

  • Thanks Ismayil. Good idea. I'll try to implement it. Though I might take a bit to finish it as my holiday is over now and it's back to work tomorrow... Less time for Elgg. :(

  • Is there a way to allow the user's to "buy" points to send gifts?

  • iionly im trying to make it so that when a gift is sent it says the gift in the river like this

    so the user chooses to send the banana gift

    UserA Has Sent A Banana To UserB

    right now it says

    UserA has Sent A Gift To UserB

    and the word gift has a link that goes to the users gifts, that would be fine i just want the word gift to be the gift being sents name

  • @Flexx:

    The only way to "buy" points is to be active on the site to receive userpoints for these actions. Implementing a "shortcut" to be able to "buy" points seems to contradict the idea to motivate the users by being active to be able to send gifts. Of course, you could configure some gifts to cost no userpoints, so the users will be able to send these gifts without being active while the still need to be active to be able to send the other gifts. Implementing a "buy" mechanism might be best solved by another separate plugin, if you really need that feature. I would suggest to add a simple page that does this transaction and then add a certain amount of userpoints for performing this action. You would need to modify the userpoints plugin and to write this "cashcow" plugin. Unfortunately, I don't have the time to do that.

    @Jpardee:

    To be able to include the name of the gift in the river entry you first need to modify the add_to_river() call in /action/send.php because this function only allows to include two Elgg object guids to be used in the river entry. Currently, the user sending the gift is included as "subject_guid" and the user receiving the gift is included as "object_guid". Unfortunately, it's not possible to retrieve the gift name later on using these Elgg objects. But by changing the line to

    add_to_river('river/object/gifts/create','gifts',$gift->owner_guid,$gift->getGUID());

    the gift name will be accessible and the receiver name can also be retrieved.

    The second problem is to handle river entries for gifts sent that were created prior the change. Unfortunately, these entries will not be changeable and will still not include the gift name. So, the file views/default/river/object/create.php has to be modified accordingly:

    <?php
    /**
     * Elgg Gifts plugin
     * Send gifts to you friends
     *
     * @package Gifts
     * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
     * @author Christian Heckelmann
     * @copyright Christian Heckelmann
     * @link http://www.heckelmann.info
     */

    // THANK YOU DDFUSION
    // Added Fix from DDFusion

    $performed_by = get_entity($vars['item']->subject_guid);

    $gift = get_entity($vars['item']->object_guid);
    if($gift->receiver) {
        $performed_on = get_entity($gift->receiver);
        $object = get_entity($gift->receiver);
        $gifttext = elgg_get_plugin_setting('gift_'.$gift->gift_id, 'gifts');
    } else {
        $performed_on = get_entity($vars['item']->object_guid);
        $object = get_entity($vars['item']->object_guid);
        $gifttext = elgg_echo("gifts:gift");
    }

    $person_link = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
    $object_link = "<a href=\"{$performed_on->getURL()}\">{$performed_on->name}</a>";
    $gift = "<a href=\"{$vars['url']}gifts/{$_SESSION['user']->username}/index\">{$gifttext}</a>";

    $string = sprintf(elgg_echo("gifts:river"), $object_link, $gift)  . " <a href=\"{$performed_by->getURL()}\">" . $performed_by->name . "</a> ";

    echo elgg_view('river/elements/layout', array(
            'item' => $vars['item'],
            'message' => $string,
    ));

    You might also want to modify the language strings accordingly, or even include two different strings for old and new river entries. Additionally, it seems necessary to add the language string

    'river:gifts:object:default'  =>  "A new gift was sent!",

    to the language file, because this string is called by Elgg automatically (maybe starting with Elgg 1.8.3?).

  • Thanks iionly, its not really a "cashcow" plugin, my kind of buying is not with "real  cash". Im trying to make it so my users will use things like coupon codes to redeem points. Note its not really coupon codes really, just use that as an example, but they will be requred to input a code to purchase points to use on the site, they will have to do other stuff on the its to get those codes, its a kind of way to get them to do more without them knowing it... Ill see if i can make my idea come alive. Thanks for your input though.

  • @Flexx:

    The userpoints plugins has functions to handle the points management (e.g. adding points to the userpoints budget of a certain user account). The gifts plugin uses this functions to substract the points a gift costs from the user's budget after checking if there are enough points in the first place. You could implement the same mechanism in a plugin that handles your coupon management. Part of this plugin would be a form that takes a code as input and the action on this form would be to add a certain amount of userpoints to the user's budget. Of course, there would be other things necessary, for example checking if the code entered is valid, the creation of the code in the first place etc.

  • One suggestion: create a "reverse gift" plugin where the users can shop gifts using your userpoints! :D

    Would be great!

  • @luizz: I don't see the reason to let the receiver of a gift pay for it with his own userpoints. Do you have a reason for needing such a reverse gift plugin? Unfortunately, I don't have the time for coding it anyway, but feel free to fork the gift plugin and implement the reverse payment on your own.

  • Coupon codes to redeem points...? I'm on it!

  • where i can find link 1.8.1beta4 ?

  • @packetrock: there's no 1.8.1beta4 release of the Gifts plugin. The "1.8.1beta4" version mentioned above refers to the Elggx Userpoints plugin that will add the userpoints/gifts cost feature to the Gifts plugin. In the meantime version 1.8.2 of the Elggx Userpoints plugin has been released. You can download it here:

    http://community.elgg.org/plugins/813379/1.8.2

  • is it posible to make gift in the river show image ?

  • @packetrock: The short answer is "yes"... it's possible to show the gift image in the river entries. I can't give the long answer (i.e. how to do it) right now as I need to test out how exactly it works for myself. The code posted above regarding including the name of a gift in the river entries is already a good starting point. Then you only need to get the url of the gift image based on the gift id and display it within the river entry. For the code to output the image you can take a look at content.php of the gift widget. It'll take at least until next week before I have the time to test out and post the code in more detail.

  • @iioni

    foreach($ogifts as $gift) {
    if($vars['item']->posted == ($gift->time_updated + 1))
    {
    $imagefile = "gift_".$gift->gift_id."_default.jpg";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"".$vars['url'].'mod/gifts/images/'.$imagefile."\" />";
    }
    }

    i use this and its work. but when i upload to webhost the image dindt show.

    do you know why?

  • @packetrock: I don't know what exactly your code does. But the update time used seems a rather strange way here.

    You could try the following code:

    1. in action/send.php modify the add_to_river call to this:

    add_to_river('river/object/gifts/create','gifts',$gift->owner_guid,$gift->getGUID());

    2. Then replace the content of views/default/river/object/create.php with

    <?php
    /**
     * Elgg Gifts plugin
     * Send gifts to you friends
     *
     * @package Gifts
     * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
     * @author Christian Heckelmann
     * @copyright Christian Heckelmann
     * @link http://www.heckelmann.info
     */

    // THANK YOU DDFUSION
    // Added Fix from DDFusion

    $performed_by = get_entity($vars['item']->subject_guid);

    $gift = get_entity($vars['item']->object_guid);
    $gift_link = '';
    $logged_in_user = elgg_get_logged_in_user_entity()->username;
    if($gift->receiver) {
        $performed_on = get_entity($gift->receiver);
        $object = get_entity($gift->receiver);

        $gifttext = elgg_get_plugin_setting('gift_'.$gift->gift_id, 'gifts');
        $imagefile = "gift_".$gift->gift_id."_tiny.jpg";
        $imgfile =  dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))."/images/".$imagefile;

        if (file_exists($imgfile)) {
            $gift_link = "<a href=\"{$vars['url']}gifts/" . $gift->receiver . "/singlegift?guid={$gift->guid}\"><img src=\"".$vars['url'].'mod/gifts/images/'.$imagefile."\" alt=\"{$gifttext}\" /></a>";
        } else {
            $gift_link = "<a href=\"{$vars['url']}gifts/{$logged_in_user}/index\">{$gifttext}</a>";
        }

    } else {
        $performed_on = get_entity($vars['item']->object_guid);
        $object = get_entity($vars['item']->object_guid);
        $gifttext = elgg_echo("gifts:gift");
        $gift_link = "<a href=\"{$vars['url']}gifts/{$logged_in_user}/index\">{$gifttext}</a>";
    }

    $person_link = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
    $object_link = "<a href=\"{$performed_on->getURL()}\">{$performed_on->name}</a>";

    $string = sprintf(elgg_echo("gifts:river"), $object_link, $gift_link)  . "$person_link";

    echo elgg_view('river/elements/layout', array(
            'item' => $vars['item'],
            'message' => $string,
    ));

    You might need to modify this code slightly to suit your needs and also adjust the language string used for river entries. Additionally, 'river:gifts:object:default'  =>  "A new gift was sent!", should be added to the language file.

     

     

  • This plugin doesnt deduct the users points after they purchase a gift

  • @Miks101: I beg your pardon but it works for me! Which userpoints plugin do you use, which Elgg version? You need to use Elggx Userpoints for Elgg 1.8 (best would be latest version). It works for me in all recent Elgg 1.8 versions (up to Elgg 1.8.8).

    Have you entered the amount of userpoints a gift should cost?

  • @iionly Sorry for my blunt comment earlier, this is a great plugina dn thanks for sharing it. I use user points plugin 1.8.2 and elgg version 1.8.4, the plugin itself seems to be running fine standalone but when I enable userpoints and add a value it doesnt subtract the amount from the total user points that user has. I'm going to give it another try now, also how do i remove gifts that I have added?

  • @Miks101: it might help to place the gifts plugin below the userpoints plugin in the plugin list - if you have not already done so... Does it work now? If not, do the number of userpoints of a user and the gift costs show correctly on the "Send gift" page? The removal of a gift from the gift list is currently not possible. I don't know if I can add such an option. The problem is that all gifts sent by users using this gift would get deleted, too - actually, I have not yet tested what exactly would happen. Also, changing the name (and/or image) of a gift also influences all gifts sent using this gift slot.

Stats

  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2018-6-2
  • Downloads: 5369
  • Recommendations: 24

Other Projects

View iionly's plugins