Disable editable fields for admin users with no edit rigths

bic Member, Translator
They can't actually edit those fields, but the layout of the page is the same as for admin with edit rigths. For example printTags() gives to ALL admin users a not styled list of tags with no link to the proper search. If no tags are present they also see the (no tags) label.

Comments

  • acrylian Administrator, Developer
    What theme?
  • bic Member, Translator
    I've noticed it with a custom theme but it also occurs with zenpage default. I think it's not theme related.
    PrintTags() function in template-functions checks for zp_loggedin():
    `
    if ($editable && zp_loggedin()) {
    printEditable($object, '_update_tags', true, $editclass, $tagstring);
    `
    So that also an admin user with no rights sees the editable (but not really editable) field.

    I know that I can disable this using `false` in the proper variable field of the printTags function, but then i loose this usefull feature for admins with edit rights.

    The `if` statement should be replaced with something like:
    `if ($editable && zp_loggedin(has the proper edit rights)) {`
  • bic Member, Translator
    `if ($editable && zp_loggedin(EDIT_RIGHTS)) {`
    But what happens if the given user has edit rights only on certain albums?

    Edit:
    I've checked. It happens that a working editable object appears in the albums where the user has edit rights and a (not editable) editable object appears in the other albums.

    This seems to work in all cases:
    `if ($editable && zp_loggedin() && isMyAlbum($_zp_current_album->name, EDIT_RIGHTS)) {`

    after adding to global $_zp_current_album and modifying a few lines above:

    `if ( $messageIfEmpty === true && $editable && zp_loggedin()`

    with:

    `if ( $messageIfEmpty === true && $editable && zp_loggedin() && isMyAlbum($_zp_current_album->name, EDIT_RIGHTS) ) {`

    to prevent the 'no tags' text if there are no tags
  • bic Member, Translator
    This could be the modifyed part of printTags() function:
    `
    function printTags($option='links', $preText=NULL, $class='taglist', $separator=', ', $editable=TRUE, $editclass='', $messageIfEmpty = true ) {
    global $_zp_current_search, $_zp_current_album ;
    $editrgs = isMyAlbum($_zp_current_album->name, EDIT_RIGHTS);
    $singletag = getTags();
    $tagstring = implode(', ', $singletag);
    if ($tagstring === '' or $tagstring === NULL ) {
    $preText = '';
    if ( $messageIfEmpty === true && $editable && $editrgs ) {
    $tagstring = gettext('(No tags...)');
    } elseif ( is_string($messageIfEmpty)) {
    $tagstring = $messageIfEmpty;
    }
    }

    $object = in_context(ZP_IMAGE) ? 'image' : 'album' ;
    if ($editable && $editrgs ) {
    printEditable($object, '_update_tags', true, $editclass, $tagstring);
    } else {
    ...
    `
  • bic Member, Translator
    Ok, I've found an easy theme based solution so don't bother with my request.
    In album.php and image.php I have defined the variable:

    `$editrgs = isMyAlbum($_zp_current_album->name, EDIT_RIGHTS);`

    so that I can use it to pass the proper true or false value to all the print editable functions of the page, included album and image description.
  • acrylian Administrator, Developer
    Everything that works for you is fine..:-) I had no time to check on this at all yet.
Sign In or Register to comment.