× Feature Requests

Please do NOT use this section of the forum to request help if Joomdle does not work for you in some particular way. Your post will be deleted.

[Closed] Login Modules

12 years 1 month ago 8 years 11 months ago by Antonio Durán.
red
Posts: 38
More
Topic Author
[Closed] Login Modules #1
On my site ive created a nifty setup but it requires some hacking...

Ive put the login module in the header of both sites. so now you can login from everywhere.

This is a brute force hack. but it can be refined and perhaps added to joomdle.

joomla login module: you need to change "moodle" to your moodle directory. just use find/replace.

/templates/<YOUR THEME>/html/mod_login/default.php
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<?php if($type == 'logout') : ?>

<table border="0" cellpadding="5px" class="profileblock">
  <tr>
    <td align="right" valign="middle"> 
 <?PHP
echo '<ul>';
echo '<li><a href="'.$CFG->wwwroot.'moodle/my">My page</a></li>';
echo '<li><a href="'.$CFG->wwwroot.'moodle/user/view.php">Profile</a></li>';
?><li><form action="index.php" method="post" name="login" id="form-login">
        <input type="submit" name="Submit" class="button" value="<?php echo JText::_( 'BUTTON_LOGOUT'); ?>" />
        <input type="hidden" name="option" value="com_user" />
        <input type="hidden" name="task" value="logout" />
        <input type="hidden" name="return" value="<?php echo $return; ?>" />
</form></li></ul>
    </td>
        <td rowspan="2" align="center" valign="middle">
        <?PHP

echo '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->get('username').'"><img src="'.$CFG->wwwroot.'moodle/user/pix.php?file=/'.$user->get('username').'/f1.jpg" width="60px" height="60px" title="'.$user->get('name').'" alt="'.$user->get('name').'" /><br>'.$user->get('name').'</a>'; 
//$user->get('name')
?>
</td>
  </tr>
  </table>

<?php else : ?>
<?php if(JPluginHelper::isEnabled('authentication', 'openid')) : ?>
<?php JHTML::_('script', 'openid.js'); ?>
<?php endif; ?>
<form action="<?php echo JRoute::_( 'index.php', true, $params->get('usesecure')); ?>" method="post" name="form-login" id="form-login" >
						<ul>
						<li><input id="modlogin_username" type="text" name="username" value="<?php echo JText::_('USERNAME'); ?>"  onblur="if(this.value=='') this.value='<?php echo JText::_('USERNAME');?>'" onfocus="if(this.value=='<?php echo JText::_('USERNAME'); ?>') this.value='';" class="inputbox" alt="username" size="15" />&nbsp;&nbsp;<li>
						<li><input id="modlogin_passwd" type="password" name="passwd" value="<?php echo JText::_('PASSWORD'); ?>" onblur="if(this.value=='') this.value='<?php echo JText::_('PASSWORD'); ?>'" onfocus="if(this.value=='<?php echo JText::_('PASSWORD'); ?>') this.value='';" class="inputbox" size="15" alt="password" />&nbsp;&nbsp;<li>
               </ul><ul>
              <?php if(JPluginHelper::isEnabled('system', 'remember')) : ?>
                       <li> <input id="modlogin_remember" type="checkbox" name="remember" class="inputbox" value="yes" alt="Remember Me" />&nbsp;&nbsp;
                        <label for="modlogin_remember"><?php echo JText::_('Remember me') ?></label>&nbsp;&nbsp;</li>
                <?php endif; ?>
                <li><input type="submit" name="Submit" class="button" value="<?php echo JText::_('LOGIN') ?>" />&nbsp;&nbsp;</li>
</ul><br>
                       <ul>
                        <?php
		$usersConfig = &JComponentHelper::getParams( 'com_users' );
		if ($usersConfig->get('allowUserRegistration')) : ?>
                        <li><a href="<?php echo JRoute::_( 'index.php?option=com_user&task=register' ); ?>">
                                <?php echo JText::_('REGISTER'); ?></a>&nbsp;&#x2022;</li>
                <?php endif; ?>
                
						<li><a href="<?php echo JRoute::_( 'index.php?option=com_user&view=reset' ); ?>">
                                <?php echo JText::_('FORGOT_YOUR_PASSWORD'); ?></a>&nbsp;</li>
                  <?php /*              
						<li><a href="<?php echo JRoute::_( 'index.php?option=com_user&view=remind' ); ?>">
                                <?php echo JText::_('FORGOT_YOUR_USERNAME'); ?></a>&nbsp;
                        */?>
               </ul>	
               
               <?php echo $params->get('posttext'); ?>

	<input type="hidden" name="option" value="com_user" />
	<input type="hidden" name="task" value="login" />
	<input type="hidden" name="return" value="<?php echo $return; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>

</form>
<?php endif; ?>

hack in moodle to make it possible to see pix by username and not just id:
/moodle/user/pix.php
<?PHP // $Id: pix.php,v 1.16.4.3 2008/11/01 22:28:54 skodak Exp $
      // This function fetches user pictures from the data directory
      // Syntax:   pix.php/userid/f1.jpg or pix.php/userid/f2.jpg
      //     OR:   ?file=userid/f1.jpg or ?file=userid/f2.jpg

    require_once('../config.php');
    require_once($CFG->libdir.'/filelib.php');

    if (!empty($CFG->forcelogin) and !isloggedin()) {
        // protect images if login required and not logged in;
        // do not use require_login() because it is expensive and not suitable here anyway
        redirect($CFG->pixpath.'/u/f1.png');
    }

    // disable moodle specific debug messages
    disable_debugging();

    $relativepath = get_file_argument('pix.php');

    $args = explode('/', trim($relativepath, '/'));

    if (count($args) == 2) {
        $userid   = (integer)$args[0];
        // do not serve images of deleted users
        if ($user = get_record('user', 'id', $userid, 'deleted', 0, 'picture', 1)) {
            $image    = $args[1];
            $pathname = make_user_directory($userid, true) . "/$image";
            if (file_exists($pathname) and !is_dir($pathname)) {
                send_file($pathname, $image);
            }
        } else if ($user = get_record('user', 'username', $args[0], 'deleted', 0, 'picture', 1)) {
       
            $image    = $args[1];
            $pathname = make_user_directory($user->id, true) . "/$image";
            if (file_exists($pathname) and !is_dir($pathname)) {
                send_file($pathname, $image);
            }
        }

    }

    // picture was deleted - use default instead
    redirect($CFG->pixpath.'/u/f1.png');
?>

and, on the moodle side you can see what i did here:
joomdle.com/index.php?option=com_kunena&...id=14&id=981&lang=en k
The topic has been locked.
12 years 1 month ago
Chris
Posts: 2118
More
[Closed] Login Modules #2
thanks very much for your effort and sharing with the community ...
The topic has been locked.