We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28245
    • 20 Posts
    Hello!
    This is a problem I had with TinyMCE 2.0.8 but now when I upgraded to Evo1.0.0 and TinyMCE3.2.4.1 so it works no longer with the same changes.
    View previous topic. Sorry I forgot to write a reply in that topic. But it worked after the changes.
    I want my user to have their own links in the list of links in TinyMCE. Some one who can help me with this, or help me in the right direction.
    Have changed in tinymce.linklist.php
    <?php
    //-----------------------------------------
    require_once ("../../../manager/includes/protect.inc.php");
    //-----------------------------------------
    
    include_once ("../../../manager/includes/config.inc.php");
    
    //-----------------------------------------
    include_once(MODX_BASE_PATH."manager/includes/document.parser.class.inc.php");
    $modx = new DocumentParser;
    startCMSSession();
    //-----------------------------------------
    
    $allpages = getAllPages();
    foreach($allpages as $page){
        $caption = ($page['pagetitle'])?htmlspecialchars($page['pagetitle'],ENT_QUOTES):htmlspecialchars($page['menutitle'],ENT_QUOTES);
    	$list .=($list!='')?",\n":"\n";
    	$list.= "[\"".$caption." (".$page['id'].")"."\", \"[\"+\"~".$page['id']."~\"+\"]\"]";
    }
    $output = "var tinyMCELinkList = new Array(\n". $list .");";
    
    echo $output;
    
    function getAllPages($id=0, $sort='menuindex', $dir='ASC', $fields='pagetitle, id, menutitle') {
    
        global $database_type;
        global $database_server;
        global $database_user;
        global $database_password;
    	global $dbase;
    	global $table_prefix;
    //-----------------------------------------
    global $modx;
     $usid = $modx->getLoginUserID('mgr');
    //-----------------------------------------
        $tblsc = $dbase.".`".$table_prefix."site_content`";
        $tbldg = $dbase.".`".$table_prefix."document_groups`";
    
        // modify field names to use sc. table reference
        $fields = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$fields)));
        $sort = 'sc.'.implode(',sc.',preg_replace("/^\s/i","",explode(',',$sort)));
    
    	// Connecting, selecting database
    	$link = mysql_connect($database_server, $database_user, $database_password) or die('Could not connect: ' . mysql_error());
    	mysql_select_db(str_replace('`', '', $dbase)) or die('Could not select database');
    	@mysql_query("{$GLOBALS['database_connection_method']} {$GLOBALS['database_connection_charset']}");
    // ------------------------------------------------------------
        $sql = "SELECT DISTINCT $fields FROM $tblsc sc
          LEFT JOIN $tbldg dg on dg.document = sc.id
          WHERE sc.published=1 AND sc.deleted=0 AND sc.editedby ='$usid'
          ORDER BY $sort $dir;";
    //-----------------------------------------
    /*
    //
        $sql = "SELECT DISTINCT $fields FROM $tblsc sc
          LEFT JOIN $tbldg dg on dg.document = sc.id
          WHERE sc.published=1 AND sc.deleted=0
          ORDER BY $sort $dir;";
    */
        $result = mysql_query($sql) or die('Query failed: ' . mysql_error());
        $resourceArray = array();
        for($i=0;$i<@mysql_num_rows($result);$i++)  {
          array_push($resourceArray,mysql_fetch_assoc($result));
        }
    	// Free resultset
    	mysql_free_result($result);
    	
    	// Closing connection
    	mysql_close($link);
    	
    	sort($resourceArray);
    
        return $resourceArray;
    }
    ?>
    

    rows between //----------------------------------------- are changed or added.





    Would be very grateful if someone can help me with this.

    // Peter
      • 28245
      • 20 Posts
      Excuse me I forgot to write what does not work.
      It does not work to get $usid = $modx->getLoginUserID(’mgr’);
      but if I write $usid = 1; then links works

      //Peter
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        $modx->getLoginUserId only gets the ID of the current user if he’s logged in. It takes it from the $_SESSION array. So it only works if the user is logged in, otherwise it returns null.
        http://wiki.modxcms.com/index.php/API:getLoginUserID

        If you want to get the user ID of a given manager user, you need to query the database in a snippet:
        $usid = $modx->db->select("id", $modx->getFullTableName('manager_users'), "username = '". $usrname . "'");
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 28245
          • 20 Posts
          That is the sense that the UserID will be retrieved from the currently logged. But I can not get it to work