Skip to content

Bypass jOOmla acl for automatic publishing

You knows that with jOOmla only publishers can publish there are situations with small groups I had requests for lowering the acl and permits to publish their articles also for authors. This is a very simple trick to do.

Locate these lines near the top of components/com_content/content.php

PHP:
  1. // Editor usertype check
  2. $access = new stdClass();
  3. $access->canEdit    = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'all' );
  4. $access->canEditOwn = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'own' );
  5. $access->canPublish = $acl->acl_check( 'action', 'publish', 'users', $my->usertype, 'content', 'all' );

And replace with:

PHP:
  1. // Editor usertype check
  2. $access = new stdClass();
  3. // ---------------------------------------------------------------------------
  4. // Marco 05.12.2005
  5. // Show publish in frontend even for authors
  6. // http://blog.nospace.net/
  7. // ---------------------------------------------------------------------------
  8. $acl->_mos_add_acl( 'action', 'publish', 'users', 'editor', 'content', 'all' );
  9. $acl->_mos_add_acl( 'action', 'publish', 'users', 'author', 'content', 'all' );
  10. // ---------------------------------------------------------------------------
  11. $access->canEdit    = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'all' );
  12. $access->canEditOwn = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'own' );
  13. $access->canPublish = $acl->acl_check( 'action', 'publish', 'users', $my->usertype, 'content', 'all' );

And then locate this lines:

PHP:
  1. } else {
  2.         $row->sectionid = $sectionid;
  3.         $row->version = 0;
  4.         $row->state = 0; // <<<<----------- replace 0 with 1 if you wish publish checkbox auto checked
  5.         $row->ordering = 0;
  6.         $row->images = array();
  7.         $row->publish_up = date( 'Y-m-d', time() );
  8.         $row->publish_down = 'Mai';
  9.         $row->creator = 0;
  10.         $row->modifier = 0;
  11.         $row->frontpage = 0;
  12.     }

that's all.

{ 8 } Comments

  1. Anthony | May 26, 2007 at 11:51 am | Permalink

    Thanks for this - its very helpful.

  2. Marco | May 27, 2007 at 8:58 am | Permalink

    Hello Anthony I am glad this is useful for you.

  3. Frank | May 30, 2007 at 12:19 am | Permalink

    Great help - thx a lot..

    Now what is needed is a way for a author to see own unpublished items.. or ...to be able to restrict a editor to edit only own items

    Do You know where the standard rights are defined ? As I understand your method is to add 2 new access rules to an existing list..

    Anyway - your tip has given me the minimum usable solution - so txh again!

  4. Marco | May 30, 2007 at 7:17 am | Permalink

    Thanks Frank.
    The standard Access Controls rights are defined in includes/gacl.class.php.
    I dunno if I have fully understand but I think that this component myContent can help you a lot.
    After discovered I have no jOOmla site without it.
    http://joomlicious.com/index.php?option=com_content&task=view&id=3&Itemid=25

  5. Reini | May 31, 2007 at 7:15 pm | Permalink

    That was a really good tip. thank you very much.

  6. Chris | March 10, 2008 at 3:08 pm | Permalink

    This is for Joomla 1.0.x; any idea for J! 1.5?

  7. Andrej | October 10, 2008 at 6:28 pm | Permalink

    > This is for Joomla 1.0.x; any idea for J! 1.5?

    In Joomla 1.5, you can do this by:
    - locate and open libraries/joomla/user/authorization.php,
    - locate function (constructor) JAuthorization($options = NULL) and a series of $this->addACL( ... ) within that function,
    - now, add the following line:
    $this->addACL( 'com_content', 'publish', 'users', 'author', 'content', 'all' );

    That's it.

    Alternatively you could edit libraries/joomla/user/user.php to modify function authorize(...) to look something like this:
    function authorize( $acoSection, $aco, $axoSection = null, $axo = null )
    {
    /* This is a hack to enable authors to publish content automatically
    * (without the content beeing waited for aproval)
    /*
    if (strcasecmp($acoSection, "com_content") == 0 && strcasecmp($aco, "publish") == 0
    && strcasecmp($axoSection, "content") == 0 && strcasecmp($axo, "all") == 0) {
    if (strcasecmp($this->usertype, "Author") == 0) { // here you can also check against a specific user ID to enable only certain users to do that
    return True;
    }
    }
    */

    // the native calls (Check Mode 1) work on the user id, not the user type
    $acl = & JFactory::getACL();
    $value = $acl->getCheckMode() == 1 ? $this->id : $this->usertype;

    return $acl->acl_check( $acoSection, $aco, 'users', $value, $axoSection, $axo );
    }

  8. admin | October 13, 2008 at 7:21 am | Permalink

    Thanks Andrej.
    Very useful contribute.
    Marco

Post a Comment

You must be logged in to post a comment.