We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16085
    • 203 Posts
    Simple file switch for non admins who login in to the manager. So rather then modify the welcome.html have a welcome_mod.html then modify the tabs so non admin types aren’t faced with ’MODx News, Configuration etc etc’. It’s works for something I had to do.

    Modification for the welcome.static.php page. It’s a hack to a core file sad but if anyone had got any ideas on how to make it a OnManger plugin event that would be cool.

    Find and comment out:
    // load template file
    $tplFile = $base_path.'manager/media/style/'.$manager_theme.'/welcome.html';
    $handle = fopen($tplFile, "r");
    $tpl = fread($handle, filesize($tplFile));
    fclose($handle);
    
    // merge placeholders
    $tpl = $modx->mergePlaceholderContent($tpl);
    $tpl = preg_replace('~\[\+(.*?)\+\]~', '', $tpl); //cleanup
    
    //echo $tpl;

    Replace with:
    // Welcome page switch - START
    $role = $_SESSION['mgrRole'];
    
    // Mod welcome
    $tplWelcomeMod = $base_path.'manager/media/style/'.$manager_theme.'/welcome_mod.html';
    $handle1 = fopen($tplWelcomeMod, "r");
    $tplMod = fread($handle1, filesize($tplWelcomeMod));
    fclose($handle1);
    
    $tplMod = $modx->mergePlaceholderContent($tplMod);
    $tplMod = preg_replace('~\[\+(.*?)\+\]~', '', $tplMod); //cleanup
    
    $tplFile = $base_path.'manager/media/style/'.$manager_theme.'/welcome.html';
    $handle2 = fopen($tplFile, "r");
    $tpl = fread($handle2, filesize($tplFile));
    fclose($handle2);
    
    $tpl = $modx->mergePlaceholderContent($tpl);
    $tpl = preg_replace('~\[\+(.*?)\+\]~', '', $tpl); //cleanup
    
        if ( $role != '1' )
            echo $tplMod;
    	else
    		echo $tpl;
    // Welcome page switch - END
      • 30223
      • 1,010 Posts
      Not without it’s perils, but here’s a start.

      Plugin event: OnManagerPageInit

      //<?php
      GLOBAL $manager_theme,$action;
      
      $e = & $modx->Event;
      switch ($e->name) {
         case 'OnManagerPageInit':
           $role = $_SESSION['mgrRole'];
           if($action==2 && $role!=1){
               $manager_theme .= '/nonadmin';
           }
          break;
      }
      

      This should change the theme ($manager_theme) folder for the welcome page only and only for non-admin manager users.

      Create a ’nonadmin’ folder underneath each theme and place a custom welcome.html (and any related style/image files) in there. A warning though. You’ll have to figure out what styles and images are affected and which are not.


        • 16085
        • 203 Posts
        @TobyL, thanks for the input. I’ve not yet checked how/if evolution can do this out of the box. ManagerManager has been great for customising, which for the project I had left the welcome.html page. Initially I thought a plugin event would be better then messing with a core file, so more proof of concept but I shall give you code a try. Thanks again!

        >> Okay I see what you mean about images and styles getting missed! Based on MODxLight theme copying style.css to /nonadmin keep the style working, although I can’t find the original referral to root .css. Copying the file work nevertheless.

        Had a annoying problem with the MODx logo, if you add "media/style/[+theme+]/../images/misc/logo.png" you don’t need to duplicate the images.

        The only thing that is not playing is the first tab. None of the ’secuirty, backup icons show. Although this post clears up where to find the code referrals for the icons - http://modxcms.com/forums/index.php?topic=29480.0. Just not sure how to go about this with hardcoding as per sottwell’s comment.



          • 16085
          • 203 Posts
          Okay the icon+links you can have on the front page work now for non-admins, you just need to make sure the appropriate permissions are set in the Roles.

          This is what I found switching roles on/off.

          [table]
          [tr]
          [td]Name[/td]
          [td]Icon Ref[/td]
          [td]Roles Section[/td]
          [td]Other[/td]
          [/tr]
          [tr]
          [td]Security[/td]
          [td][+SecurityIcon+][/td]
          [td]User management[/td]
          [td][/td]
          [/tr]
          [tr]
          [td]Web Users [/td]
          [td][+WebUserIcon+][/td]
          [td]Web user management[/td]
          [td][/td]
          [/tr]
          [tr]
          [td]Modules[/td]
          [td][+ModulesIcon+][/td]
          [td]Module management[/td]
          [td][/td]
          [/tr]
          [tr]
          [td]Plugins[/td]
          [td][+ResourcesIcon+][/td]
          [td]Plugin management[/td]
          [td][/td]
          [/tr]
          [tr]
          [td]Backup[/td]
          [td][+BackupIcon+][/td]
          [td]Configuration management[/td]
          [td]Use the Backup Manager[/td]
          [/tr]
          [tr]
          [td]Inbox[/td]
          [td][+MessageInfo+][/td]
          [td]General[/td]
          [td]View and send messages[/td]
          [/tr]
          [/table]
            • 45496
            • 1 Posts
            Quote from: TobyL at Apr 26, 2009, 04:19 PM
            Not without it's perils, but here's a start.

            Plugin event: OnManagerPageInit

            //<!--?php
            GLOBAL $manager_theme,$action;
            
            $e = & $modx--->Event;
            switch ($e->name) {
               case 'OnManagerPageInit':
                 $role = $_SESSION['mgrRole'];
                 if($action==2 && $role!=1){
                     $manager_theme .= '/nonadmin';
                 }
                break;
            }
            

            This should change the theme ($manager_theme) folder for the welcome page only and only for non-admin manager users.

            Create a 'nonadmin' folder underneath each theme and place a custom welcome.html (and any related style/image files) in there. A warning though. You'll have to figure out what styles and images are affected and which are not.



            Great! This thread is a bit outdated, i know, nevertheless in welcome.static.php we see php is checking for the existence of a welcome.tpl two times using an url constructed with "$modx->config['manager_theme']". So when we change the value of $modx->config['manager_theme'] with some random non existent directory ('monkeypoo') it will not find any file causing it to process the last else statement:

            }
            	else {
            		$target = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl';
            		$welcome_tpl = file_get_contents($target);	
            	}


            Just modify only this $target file. This way you do not need to copy any files or have to create a directory