Go Back   Web Scribble Forums » Joomla » jConnector
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-07-2009, 09:13 AM
Junior Member
 
Join Date: Dec 2009
Posts: 7
Default jconnector_server.php includes...

Why is it so retro?.. I fixed it up, because I'm having problems getting it to integrate with another plugin. This follows Joomla! style formatting a lot more.

jconnector_server.php:
PHP Code:
define'_JEXEC');
define'DS'DIRECTORY_SEPARATOR );
$parts explodeDSdirname(__FILE__) );
array_pop$parts );
array_pop$parts );
define'JPATH_BASE'implodeDS$parts ) );

require_once ( 
JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( 
JPATH_BASE .DS.'includes'.DS.'framework.php' );
include_once ( 
JPATH_BASE .DS.'components'.DS.'com_user'.DS.'controller.php');
include_once ( 
JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'base'.DS.'observable.php');
include_once ( 
JPATH_BASE .DS.'modules'.DS.'mod_jconnector'.DS.'extension_detector.php');
include_once ( 
JPATH_BASE .DS.'modules'.DS.'mod_jconnector'.DS.'classes.php');
include_once ( 
JPATH_BASE .DS.'modules'.DS.'mod_jconnector'.DS.'facebook'.DS.'php'.DS.'facebook.php'); 
The include for facebook.php was moved up from the middle of the code.

I had problems integrating this module with another plugin (because that plugin changed the way module helper worked), so I removed the module helper include, and manually included it in the classes.php file.

Classes.php:
After the class jconnector_registration, I added the J_ModuleHelper class (J! 1.5 JModuleHelper version renamed):
PHP Code:
/**
 * Module helper class
 *
 * @static
 * @package        Joomla.Framework
 * @subpackage    Application
 * @since        1.5
 */
class J_ModuleHelper
{
    
/**
     * Get module by name (real, eg 'Breadcrumbs' or folder, eg 'mod_breadcrumbs')
     *
     * @access    public
     * @param    string     $name    The name of the module
     * @param    string    $title    The title of the module, optional
     * @return    object    The Module object
     */
    
function &getModule($name$title null )
    {
        
$result        null;
        
$modules    =& J_ModuleHelper::_load();
        
$total        count($modules);
        for (
$i 0$i $total$i++)
        {
            
// Match the name of the module
            
if ($modules[$i]->name == $name)
            {
                
// Match the title if we're looking for a specific instance of the module
                
if ( ! $title || $modules[$i]->title == $title )
                {
                    
$result =& $modules[$i];
                    break;    
// Found it
                
}
            }
        }

        
// if we didn't find it, and the name is mod_something, create a dummy object
        
if (is_null$result ) && substr$name0) == 'mod_')
        {
            
$result                = new stdClass;
            
$result->id            0;
            
$result->title        '';
            
$result->module        $name;
            
$result->position    '';
            
$result->content    '';
            
$result->showtitle    0;
            
$result->control    '';
            
$result->params        '';
            
$result->user        0;
        }

        return 
$result;
    }
    
/**
     * Load published modules
     *
     * @access    private
     * @return    array
     */
    
function &_load()
    {
        global 
$mainframe$Itemid;

        static 
$modules;

        if (isset(
$modules)) {
            return 
$modules;
        }

        
$user    =& JFactory::getUser();
        
$db        =& JFactory::getDBO();

        
$aid    $user->get('aid'0);

        
$modules    = array();

        
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' '';

        
$query 'SELECT id, title, module, position, content, showtitle, control, params'
            
' FROM #__modules AS m'
            
' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
            
' WHERE m.published = 1'
            
' AND m.access <= '. (int)$aid
            
' AND m.client_id = '. (int)$mainframe->getClientId()
            . 
$wheremenu
            
' ORDER BY position, ordering';

        
$db->setQuery$query );

        if (
null === ($modules $db->loadObjectList())) {
            
JError::raiseWarning'SOME_ERROR_CODE'JText::_'Error Loading Modules' ) . $db->getErrorMsg());
            return 
false;
        }

        
$total count($modules);
        for(
$i 0$i $total$i++)
        {
            
//determine if this is a custom module
            
$file                    $modules[$i]->module;
            
$custom                 substr$file0) == 'mod_' ?  1;
            
$modules[$i]->user      $custom;
            
// CHECK: custom module name is given by the title field, otherwise it's just 'om' ??
            
$modules[$i]->name        $custom $modules[$i]->title substr$file);
            
$modules[$i]->style        null;
            
$modules[$i]->position    strtolower($modules[$i]->position);
        }

        return 
$modules;
    }

With this change, I made sure to change the call to this class in jconnector_server.php to reflect the class name change from JModuleHelper to J_ModuleHelper.
PHP Code:
$module J_ModuleHelper::getModule('jconnector'''); 
I hope a similar change is made in future versions. Thank you, looking forward to it!
Reply With Quote
  #2 (permalink)  
Old 12-08-2009, 04:50 PM
Junior Member
 
Join Date: Oct 2009
Posts: 16
Default

question on your suggested changes for jconnector_server.php:
what lines in the original file will your new code be replacing?
do we need your line array_pop( $parts ); twice?

I am hoping this may make jconnector work on my site... Thanks
Reply With Quote
  #3 (permalink)  
Old 12-08-2009, 05:43 PM
Junior Member
 
Join Date: Dec 2009
Posts: 7
Default

Uhhh.. let's seee...
in jconnector_server.php, I replaced lines 14-28, and line 50 with the first block of code.

Because of the conflict I had when I added a plugin called "Modules Anywhere", I changed line 39 that calls class JModuleHelper in jconnector_server.php, to J_ModuleHelper, and added the second block of code to the end of classes.php just before the closing curly brace. Hope this helps...


I'm still having problems with this though from trying to get it to work right with passing through Community Builder registration of a new user...
Reply With Quote
  #4 (permalink)  
Old 12-08-2009, 05:47 PM
Junior Member
 
Join Date: Dec 2009
Posts: 7
Default

oops.. I meant I had conflict with the plugin "Advanced Modules".. not "Modules Anywhere".
Reply With Quote
  #5 (permalink)  
Old 12-08-2009, 09:38 PM
Junior Member
 
Join Date: Oct 2009
Posts: 16
Default

Thank you
I tried your changes
Still does not work...
Reply With Quote
Reply

Tags
advanced modules, advancedmodules, includes, jconnector server, jconnector_server

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 07:20 AM.