delete file for elgg_notify plugin

copy in start.php:

function notify_removeNew($guid) {

delete_entities("object", "notification", $guid);

}

function notify_removeNotify($guid) {

{

return delete_entity($guid);

}

 

copy in actions/delete.php:

<?php

 

gatekeeper();

 

$user = $_SESSION['user'];

$guid = get_input('guid');

$ajax = get_input('ajax');

if(!empty($guid)){

if(!super_notify_removeNotify($guid)) {

system_message(elgg_echo('notifications:delete:fail'));

}

// Just in case, remove the new notifies object

super_notify_removeNewNotifies($guid);

}

if(empty($ajax)) {

forward($_SERVER['HTTP_REFERER']);

}

?>

  • function new_notification($access_id = "",$user, $action_user, $desc) {

    $notify = new ElggObject();

     

    $notify->subtype = "notification";

     

    $notify->access_id = $access_id;

     

    //notify the person who needs to be notified

    $notify->to_id = $user;

     

     

    //who took the action

    $notify->action_user = $action_user;

     

    //message assigned by developer , eg. 'userx' wrote on your message board, must include html link!

    $notify->desc = $desc;

    //set it as not read

    $notify->read = 0;

     

     

    $notify->save();

    }

    function super_notify_removeNewNotifies($user) {

    delete_entities("object", "notification", $user->guid);

    }

    function super_notify_removeNotify($user, $guid) {

     

    $entity = get_entity($guid);

          

    if($entity->type == 'object' && get_subtype_from_id($entity->subtype)=='notification'){

    if($entity->owner_guid == $user->guid && $entity->container_guid == $user->guid) {

    return delete_entity($guid);

    }

    }

    return false;

    }