We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    The whole user_documents_permissions.class.php class was not working correct it would alway return true for (as far as I can see) 2 bugs in that script.
    Resulting in the bug that even if you are not alowed to edit a page that you are alowed to delete, move, publish, unpublish etc
    I found this bug wile working with Maxigallery that showed the managepictures button to manager users taht where not alowed to edit the page.

    first this line (33):
    		if($GLOBALS['use_udperms']==0 || $GLOBALS['use_udperms']=="" || !isset($GLOBALS['use_udperms'])) {
    			return true; // permissions aren't in use
    		}
    


    this will always return true because $GLOBALS[’use_udperms’] does not exist it must be $modx->config[’use_udperms’], like this:

    		if($modx->config['use_udperms']==0 || $modx->config['use_udperms']=="" || !isset($modx->config['use_udperms'])) {
    			return true; // permissions aren't in use
    		}
    


    these line must be changed also for the last part to work right:
    from:
    		if($_SESSION['mgrDocgroups']) {
    			$docgrp = implode(",",$_SESSION['mgrDocgroups']);
    		}
    


    to:
    		if($_SESSION['mgrDocgroups']) {
    			$docgrp = implode(" || dg.document_group = ",$_SESSION['mgrDocgroups']);
    		}
    

    this comes in to play when more then one docgroup is asigned to a user

    the last problem is the last db query that somhow always ended up being 1 also always returned true:
    		$tblsc = $dbase.".`".$table_prefix."site_content`";
    		$tbldg = $dbase.".`".$table_prefix."document_groups`";
    		$tbldgn = $dbase.".`".$table_prefix."documentgroup_names`";
    		$sql = "SELECT DISTINCT sc.id 
    				FROM $tblsc sc 
    				LEFT JOIN $tbldg dg on dg.document = sc.id
    				LEFT JOIN $tbldgn dgn ON dgn.id = dg.document_group
    				WHERE sc.id = $document 
    				AND (1='' OR NOT(dgn.private_memgroup<=>1)".(!$docgrp ? "":" OR dg.document_group IN ($docgrp)").");";
    				   // ^ MySQL 4.1 will not return the correct result if this statement is removed! ???
    		$rs = mysql_query($sql);
    		$limit = mysql_num_rows($rs);
    

    this should be in my opinion this:
    		$tblsc = $dbase.".`".$table_prefix."site_content`";
    		$tbldg = $dbase.".`".$table_prefix."document_groups`";
    		$tbldgn = $dbase.".`".$table_prefix."documentgroup_names`";
                    $sql = "SELECT DISTINCT sc.id 
    				FROM $tblsc sc 
    				LEFT JOIN $tbldg dg on dg.document = sc.id
    				LEFT JOIN $tbldgn dgn ON dgn.id = dg.document_group
    				WHERE sc.id = $document 
    				AND (dg.document_group = $docgrp || sc.privatemgr = 0)";
    				   
    		$rs = mysql_query($sql);
    		$limit = mysql_num_rows($rs);
    


    in my config it works great now.

    this bug is in all versions from 091 as far as I can see also in the new version

    Greets Dimmy

    fixed a nothe bug in my fix... (when does the hurting stop!)

      follow me on twitter: @dimmy01
      • 10487 MODX Staff
      • 1,535 Posts
      Garry Nutting Reply #2, 18 years ago
      Nice catch smiley I’ll test the fixes out and we should make sure that these definitely make it into the pending 0.9.6.3 release (can’t do much until the MODx SVN server comes back online)
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 7923
        • 4,213 Posts
        Yeah, good job Dimmy and great that you took the time to look into it!


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 7455
          • 2,204 Posts
          found a bug in my fix hehe but fixed that again see first post.
            follow me on twitter: @dimmy01
            • 7231
            • 4,205 Posts
            That is a good catch. grin
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 7455
              • 2,204 Posts
              I like to add this to jira but looks like its down.

              found another bug that needs fixing but I do not know if that bug is already noticed by someone

              Dimmy
                follow me on twitter: @dimmy01
                • 7455
                • 2,204 Posts
                looks like my fix for the recent bug forgets something... if its set to all then its not added to any group so false.

                let me look in to that


                of fixed that also
                if no group is set (so it public voor manager) then you are also alowed to edit now.
                  follow me on twitter: @dimmy01
                  • 23491 ☆ A M B ☆
                  • 1,056 Posts
                    Mike Reid - www.pixelchutes.com
                    MODx Ambassador / Contributor
                    [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                    ________________________________
                    Where every pixel matters.