Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • For anybody else who is having a problem with the recent changes to drawio here is what I did that worked for me.

    BTW This involves changing the various php files and a javascript files

    First the php part
    ==========================
    1. open “drawit.php” in an editor

    2. replace wherever you find "https://www.draw.io" replace with "https://embed.diagrams.net"

    2. Add a time stamp to the “drawit.js” enqueued script to make sure your javascript is not cached so find the function media_menu_handler()

    See the “?v=’.time()” below. This is what I have added to ensure your javascript gets updated, without this you will probably find you are dealing with an old cached js file

    public function media_menu_handler() {
            $errors = '';
            wp_enqueue_script($this->plugin_slug . '-js', plugins_url('js/' . $this->plugin_slug . '.js?v='.time(), __FILE__));
            if(current_user_can('manage_options')) {
                wp_enqueue_style($this->plugin_slug . '-css', plugins_url('css/' . $this->plugin_slug . '.css', __FILE__), array(), $this->plugin_version);
            } else {
                wp_enqueue_style($this->plugin_slug . '-css', plugins_url('css/' . $this->plugin_slug . '.min.css', __FILE__), array(), $this->plugin_version);
     return wp_iframe(array($this, 'iframe'), $errors);
        }
            }

    3. Then save that file

    4. Then Open “drawit.js”
    wherever you find "https://www.draw.io" replace with "https://embed.diagrams.net"

    5. Save

    6. Refresh page

    You should now see it working, at least that is my experience

    Cheers

    • This reply was modified 3 years, 7 months ago by patsam.
    • This reply was modified 3 years, 7 months ago by patsam.

    Hi, did you find a solution to this? I am having the same problem, we use this extensively as well.
    Hope you did, would appreciate any pointers. Cheers

    Thread Starter patsam

    (@patsam)

    Solved

    Just found out the reason and its to do with the plugin s3_uploads_master which is a plugin to connect your media to an amazon s3 bucket.

    The issue is to do with a call to “filter_sideload_move_temp_file_to_s3()” in this plugin which is triggered by the filter “wp_handle_sideload” (called within drawit) .

    Apparently this is no longer needed and the latest version has or will have this removed.

    In the meantime I just returned the file unchanged

    public function filter_sideload_move_temp_file_to_s3( array $file ) {
    
            return $file; // get out with out changing anything
    
            // it seems this function is not needed since 4.4 in fact it causes an issue with drawit plugin
    
    		$upload_dir = wp_upload_dir();
    		$new_path   = $upload_dir['basedir'] . '/tmp/' . basename( $file['tmp_name'] );
    
    		if(is_super_admin()){
    		    echo '<PRE>'.$file['tmp_name'].'- NEW PATH='.$new_path.'</PRE>';
            }
    
    		copy( $file['tmp_name'], $new_path );
    		unlink( $file['tmp_name'] );
    		$file['tmp_name'] = $new_path;
    
    		return $file;
    	}
    

    Hope this helps anyone else with this issue when using this great plugin

    Thread Starter patsam

    (@patsam)

    Hi Alex,

    Thanks for the feedback. This is what I have done to do what I need

    Some background to what I am trying to do:
    I simply want to create a list of all users and show or count which posts that each user can or cannot access.

    In the end I changed the AccessHandler.php source and created some new functions which allows me to provide a user as opposed to the default current user

    See code below, this works for me but for the next version it would be nice if the we could call getExcludedPosts() using a specified user and include arguments so we could exclude checking of IPaddress and maybe some other settings (can’t think of others at the moment)

    Thank you for all your work on this plugin and would be more than happy to contribute as needed

    Regards Pat (see my code below)

        public function checkUserAccess_tko($oCurrentUser,$allowedCapability = false)
        {
            $currentUser = $oCurrentUser;
    
            if ($this->wordpress->isSuperAdmin($currentUser->ID) === true
                || $allowedCapability !== false && $currentUser->has_cap($allowedCapability) === true
            ) {
                return true;
            }
    
            $roles = $this->getUserRole($currentUser);
            $rolesMap = array_flip($roles);
    
            $orderedRoles = [UserGroup::NONE_ROLE, 'subscriber', 'contributor', 'author', 'editor', 'administrator'];
            $orderedRolesMap = array_flip($orderedRoles);
    
            $userRoles = array_intersect_key($orderedRolesMap, $rolesMap);
            $rightsLevel = (count($userRoles) > 0) ? end($userRoles) : -1;
            $fullAccessRole = $this->config->getFullAccessRole();
    
            return (isset($orderedRolesMap[$fullAccessRole]) === true && $rightsLevel >= $orderedRolesMap[$fullAccessRole]
                || isset($rolesMap['administrator']) === true
            );
        }
    
        public function getExcludedPosts_tko($user)
        {
            /**
             * Call this in TKO like this ,
             *    $excluded_posts = $userAccessManager->getAccessHandler()->getExcludedPosts_tko(get_user_by('ID',$user_id));
             */
    
            /*
            if ($this->checkUserAccess('manage_user_groups')) {
                // if you have these capabilities then get out as you can access everything
                $this->excludedPosts = [];
            }
            */
    
            if ($this->checkUserAccess_tko($user,'manage_user_groups')) {
                // if you have these capabilities then get out as you can access everything
                $ret_excludedPosts = [];
            }
    
            if ($ret_excludedPosts === null) {
                $excludedPosts = [];
    
                // get all user groups
                $userGroups = $this->getUserGroups();
    
                // get all groups that the current user belongs to
                $userUserGroups = $this->getUserGroupsForUser_tko( isset($user) ? $user : null);
    
                // place all posts assigned to each user group into excludedPosts array
                foreach ($userGroups as $userGroup) {
                    $excludedPosts += $userGroup->getFullPosts();
                }
    
                // Subtract from the excludedPosts array, all posts that belong to groups that the current user belongs to
                foreach ($userUserGroups as $userGroup) {
                    $excludedPosts = array_diff_key($excludedPosts, $userGroup->getFullPosts());
                }
    
                // if not in wp-admin (e.g. currently the front end) then
    
                $noneHiddenPostTypes = [];
                $postTypes = $this->objectHandler->getPostTypes();
    
                foreach ($postTypes as $postType) {
                    if ($this->config->hidePostType($postType) === false) {
                        $noneHiddenPostTypes[$postType] = $postType;
                    }
                }
    
                foreach ($excludedPosts as $postId => $type) {
                    if (isset($noneHiddenPostTypes[$type]) === true) {
                        unset($excludedPosts[$postId]);
                    }
                }
    
                $postIds = array_keys($excludedPosts);
                $ret_excludedPosts = array_combine($postIds, $postIds);
            }
    
            return $ret_excludedPosts;
        }
    
        /**
         * Returns the user groups for the user.
         *
         * @return UserGroup[]
         */
        public function getUserGroupsForUser_tko($user, $access='read' )
        {
            /**
             * * TKO Change - was
             * *    Original had no args
             */
    
            if ($this->checkUserAccess_tko($user,'manage_user_groups') === true ) {
                return $this->getUserGroups();
            }
    
            if ($this->userGroupsForUser === null) {
                /**
                 * TKO Change - was
                 *   $currentUser = $this->wordpress->getCurrentUser();
                 */
                $currentUser = isset($user)? $user: $this->wordpress->getCurrentUser();
                $userGroupsForUser = $this->getUserGroupsForObject(
                    ObjectHandler::GENERAL_USER_OBJECT_TYPE,
                    $currentUser->ID
                );
    
                $userGroups = $this->getUserGroups();
    
                /**
                 * This next one can catch you out becuase
                 *  - if the user is currently editing a document (e.g. $this->config->atAdminPanel() === true )
                 *  - and a certain group/s allows write access (e.g. $userGroup->getWriteAccess() === 'all' )
                 *  - then it will distort the excludedposts_tko result
                 *
                 *  NOTE THIS ONLY AFFECTS - getexcludedposts_tko
                 */
    
                $is_admin =  ( $this->config->atAdminPanel() === true );
    
                foreach ($userGroups as $userGroup) {
    
                    $_this_userGroup_is_notin_assigned_user_groups = ( isset($userGroupsForUser[$userGroup->getId()]) === false );
    
                    $but_read_access_is_allowed = ( $userGroup->getReadAccess() === 'all' );
    
                    $but_write_access_is_allowed = ( $userGroup->getWriteAccess() === 'all' );
    
                    $it_must = $_this_userGroup_is_notin_assigned_user_groups;
    
                    /*
                    $_this_IP_is_allowed = ( $this->isIpInRange($_SERVER['REMOTE_ADDR'], $userGroup->getIpRangeArray()) );
    
                    $condition_1_or = $_this_IP_is_allowed;
    
                    $condition_2_or = ( ! $is_admin && $but_read_access_is_allowed );
    
                    $condition_3 = ( $is_admin && $but_write_access_is_allowed );
                    */
    
                    if($access == 'read'){
                        $add_to_usergroup = $it_must && ( $but_read_access_is_allowed  );
                    } else {
                        $add_to_usergroup = $it_must && ( $but_write_access_is_allowed );
                    }
    
                    /*if (isset($userGroupsForUser[$userGroup->getId()]) === false
                        && ($this->isIpInRange($_SERVER['REMOTE_ADDR'], $userGroup->getIpRangeArray())
                            || $this->config->atAdminPanel() === false && $userGroup->getReadAccess() === 'all'
                            || $this->config->atAdminPanel() === true && $userGroup->getWriteAccess() === 'all')
                    ) */
    
                    if($add_to_usergroup)
                    {
                        $userGroupsForUser[$userGroup->getId()] = $userGroup;
                    }
                }
    
                $this->userGroupsForUser = $userGroupsForUser;
            }
    
            return $this->userGroupsForUser;
        }
    
    }
    Thread Starter patsam

    (@patsam)

    It turns out that there were conflicting css styles in another plugin I had that caused the no show. All fixed now

    Yes I am having the same problem the groups page is blank however the widget appears in the post edit screen.

    Are you using wordpress 4.0?

    I am, maybe it’s not yet compatible with this, it was working on a previous site of mine under 3.9.2

    I hope the developer can shed some light on this soon.

    I found that by using the hacky solution above that it did remove the error but then I noticed that the search box woould no longer drop down from the site menu

    e.g.
    <div class=”search-expand” style=”display: ..

    Has anyone since found a solution?

Viewing 7 replies - 1 through 7 (of 7 total)