Overriding core engine/lib/access.php

I'm trying to override the core engine/lib/access.php with a plugin. I get an error message resulting from code in my start.php. Here my start.php:

function nopublic_init() {

// Extend system CSS with our own styles

extend_view('css','nopublic/css');

// Replace the default index page

register_plugin_hook('access_list','system','new_access_list');

 }

 

function new_access_list() {

    if (!@include_once(dirname(dirname(__FILE__))) . "/nopublic/access.php") return false;

   return true;

}

// Make sure the plugin has been registered

register_elgg_event_handler('init','system','nopublic_init');

What am I doing wrong?

  • hi evan

    thanks for the quick reply. 

    My problem was that annotations that i coded myself only were visible to the user that posted this comment. That was due to some access restrictions in the function mentioned above. here's my new function:

    function get_annotation($annotation_id) {

    global $CONFIG;

    $annotation_id = (int) $annotation_id;

    $access = get_access_sql_suffix("a");

            // EDIT: removed :  "and $access" -> display annotation for everybody!

    return row_to_elggannotation(get_data_row("SELECT a.*, n.string as name, v.string as value from {$CONFIG->dbprefix}annotations a JOIN {$CONFIG->dbprefix}metastrings n on a.name_id = n.id JOIN {$CONFIG->dbprefix}metastrings v on a.value_id = v.id where a.id=$annotation_id"));

    }

    for my own comment, here's some of the code i used:

    $annotation_id = $obj->annotate("comment", $comment, $vartype='text');
    add_to_river('river/comment', 'comment', $user_guid, $object_guid, '',$time, $annotation_id);

    the problem was in myplugin/views/river/comment (copied from other plugins)

    //grab the annotation, if one exists
    if ($vars['item']->annotation_id != 0) {
         $comment = get_annotation($vars['item']->annotation_id)->value;
    }

    as mentioned above: due to access restriction only the annotation owned by $_SESSION['user'] are displayed.

    Do you have any advise how to accomplish that without changing the core?

  • Create the annotation with public access. See create_annotation().

  • cool, that's what I was looking for!

    thanks a lot!