Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-19142

ezcontenobject ezcontentobjecttreenode::checkAccess add new parameter userID

    XMLWordPrintable

Details

    Description

      In some cases you want to check from php or tpl if a special user has access to a node or contentobject.

      The function checkAccess which is used for object->attribute('can_read') ... or node->attribue('can_read')
      uses the current user.
      It would be usefull to make the user id optional. It it is set use it otherwise use as default the currentuserid.

      current code: ezcontenobject

      function checkAccess( $functionName, $originalClassID = false, $parentClassID = false, $returnAccessList = false, $language = false )
          {
              $classID = $originalClassID;
              $user = eZUser::currentUser();
              $userID = $user->attribute( 'contentobject_id' );
      
      

      improved code

      function checkAccess( $functionName, $originalClassID = false, $parentClassID = false, $returnAccessList = false, $language = false, $userID = false )
          {
              $classID = $originalClassID;
      
              if ( $userID == false )
              {
                    $user = eZUser::currentUser();
                    $userID = $user->attribute( 'contentobject_id' );
              }
              else
              {
                    $user = eZUser::fetch( $userID );
                    if ( !is_object( $user ) )
                         return 0;
      
              }
      }
      
      

      eZContentObjectTreeNode::checkAccess should be updated, too.

      Attachments

        Activity

          People

            unknown unknown
            4d91e976-d41f-487b-ae85-f7216bd06dac@accounts.ibexa.co Felix Woldt
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: