Joomla! Discussion Forums



It is currently Fri Nov 27, 2009 7:14 pm (All times are UTC )

 




Post new topic Reply to topic  [ 7 posts ] 
Author Message
Posted: Wed Nov 04, 2009 10:13 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon May 22, 2006 6:43 am
Posts: 7
Hi,

I'm developping a component in Joomla 1.5.11 in which I have to login to see the pages. Everything works well but when a visit a certain page in my component, I'm automatically logged out from the site and need to re-log. I've checked the session time which is fixed at 60 min. I've check my code and I never say in my code to logout when I arrive on this page or something with the security aspects, I don't know what to do, had somenone the same problem anytime?

Thanks for your help.


Last edited by ljeanmonod on Thu Nov 05, 2009 2:39 pm, edited 1 time in total.

Top
   
 
Posted: Thu Nov 05, 2009 8:52 am 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Fri Sep 09, 2005 2:13 pm
Posts: 6776
Location: The Netherlands
is this at all pages, or just some pages?
Can you post some code?

_________________
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards


Top
  E-mail  
 
Posted: Thu Nov 05, 2009 9:18 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon May 22, 2006 6:43 am
Posts: 7
It's just one page, always the same, the url of the page is like that :

index.php?option=com_annuaire&task=regions&layout=details&id=852&addresse=av.+du+Censuy+11%2C1020%2CRenens+VD%2CCH&Itemid=100036&lang=fr

The component in question is a directory of addresses, so I have a page where I list adresses and user can make some search on those addresses. When I click on an address, I want to display some details, so I go on a detail screen and at this moment i'm deconnected.

Let's see some code, here the fucntion display of my controller :

Code:
   function display()
   {
      $document =&JFactory::getDocument();
      $task = JRequest::getVar('task');
      $viewType = $document->getType();
      $config = &JFactory::getConfig();
      $lang    = $config->getValue('config.language');
      switch($this->getTask()){
         case 'regions': // onglet 1
            $viewName = 'regions';
            break;
         case 'cantons': //onglet 1 +
            $viewName = 'Cantons';
            break;
         case 'annuaire': //onglet 2
            $viewName = 'Annuaire';
            break;
         case 'detail': //onglet 2
            $viewName = 'Detail';
            break;
      }
      
      $view = &$this->getView($viewName, $viewType);
      $model =&$this->getModel($viewName, 'Model');
      if(!JError::isError($model))
      {
         $view->setModel($model, true);
      }
        $viewLayout= JRequest::getVar( 'layout', 'default' );
      $view->setLayout($viewLayout);
      $view->display();
   }


The task is "regions" so here is the code of the view.html.php file of regions :

Code:
   function display($tpl = null)
   {
      global $option;
        if($this->getLayout() == 'details') {
            //echo $this->_task;
            $this->detailsDisplay($tpl);
            return;
        }
............
.............
.............


At first i check the layout var and redirect to the good function, in this case the function detailsDisplay, here is the code of this function :

Code:
function detailsDisplay($tpl = null)
    {
        global $option;
        $user =& JFactory::getUser();
        $iduser    = $user->get('id');
        $id= JRequest::getVar('id');
        $this->_id =$id;
        $region= JRequest::getVar('region');
        $this->_region =$region;
        $canton= JRequest::getVar('canton');
        $this->_canton =$canton;
        $ville= JRequest::getVar('ville');
        $this->_ville =$ville;
        $type= JRequest::getVar('type');
        $this->_type =$type;
        $npa= JRequest::getVar('npa');
        $this->_npa=$npa;
        $flag= JRequest::getVar('flag');
        $this->_flag=$flag;
       
        $model = &$this->getModel();
        $list_region = $model->getListDetail($this->_id);
        $user=$model->getUser($iduser);
        $this->assignRef('user', $user);
        $this->assignRef('mb_regions', $list_region);
        $this->assignRef('region', $this->_region); //pour le mettre en hidden
        $this->assignRef('canton', $this->_canton); //pour le mettre en hidden
        $this->assignRef('ville', $this->_ville); //pour le mettre en hidden
        $this->assignRef('type', $this->_type); //pour le mettre en hidden
        $this->assignRef('npa', $this->_npa); //pour le mettre en hidden
        $this->assignRef('flag', $this->_flag); //pour savoir sur quel page retourner (dans le template de Detail)
       
        parent::display($tpl);
    }


In this function, you can see that I call to functions from my model : getUser and getListDetails, here is the code of those 2 functions :

Code:
    function getUser($iduser){
         $db = $this->getDBO();
        $query="SELECT * FROM #__users WHERE id=".$iduser;
            $db->setQuery($query);
            $this->_user = $db->loadObject();
            return $this->_user;
    }

    function getListDetail($id)
    {
        $query='SELECT * FROM #__courtiers WHERE id='.$id;
        $this->_courtiers = $this->_getList($query,0,0);
        return $this->_courtiers;
    }


And final, I display the template detailsDisplay, here is the code :

Code:
<?php defined('_JEXEC') or die();?>
<h1><?php echo JText::_( 'Détails courtier' ); ?></h1>
<div class="ann_navigation">
    <a class="ann_left" href="javascript:history.back()" title="Retour" class="languages"><< <?php echo JText::_( 'RETOUR' ); ?></a>
</div>
<div class="ann_main">
    <?php foreach($this->mb_regions as $mb): ?>
    <p>
        Si vous voulez faire de cette personne votre conseiller, il faut vous inscrire sur <a href="http://www.nakama.ch/myb_espace_perso">l'espace personnel</a>.
    </p>

    <h6 class="ann"><?php echo $mb->Societe;?></h6>
    <table id="ann_detail">
        <tr>
            <td>
                <?php echo JText::_( 'ADRESSE' ); ?>:
            </td>
            <td>
                <?php if($mb->Rue){ ?>
                <?php echo $mb->Rue; ?><?php } ?>
            </td>
            <td class="ann_adresse2">
                <?php if($mb->Rue2){ ?>
                <?php echo JText::_( 'ADRESSE2' ); ?>:
            </td>
            <td>
                <?php echo $mb->Rue2; ?><?php } ?>
            </td>
        </tr>
        <tr>
            <td>
               
        <?php //echo JText::_( 'VILLE' ); ?>
            </td>
            <td>
                <?php if($mb->Ville){ ?>
                <?php echo $mb->NPA.'&nbsp;'.$mb->Ville; ?><?php } ?>
            </td>
            <td>
           
            </td>
            <td>
                <?php if($mb->Ville2){ ?>
                <?php echo $mb->NPA2.'&nbsp;'.$mb->Ville2; ?><?php } ?>
            </td>
        </tr>
        <tr>
            <td>
                <br/>
                <?php if($mb->Tel){ ?>
                <?php echo JText::_( 'TEL' ); ?>:
            </td>
            <td>
                <br/>
                <?php echo $mb->Tel; ?><?php } ?>
            </td>
            <td colspan="2" rowspan="4" class="ann_adresse2">
                <div class="ann_ville">
                    <?php $this->getTypesCourtier($mb->id);?>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <?php if($mb->Fax){ ?>
                <?php echo JText::_( 'FAX' ); ?>:
            </td>
            <td>
                <?php echo $mb->Fax; ?><?php } ?>
            </td>
           
        </tr>
        <tr>
            <td>
                <?php if($mb->Email){ ?>
                <?php echo JText::_( 'EMAIL' ); ?>:
            </td>
            <td>
                <?php echo $mb->Email; ?><?php } ?>
            </td>
           
        </tr>
        <tr>
            <td>
                <?php if($mb->SiteWeb){ ?>
                <?php echo JText::_( 'SITEWEB' ); ?>:
            </td>
            <td>
                <?php echo $mb->SiteWeb; ?>    <br/><?php } ?>
            </td>
           
        </tr>
    </table>
    <table id="ann_detail">
        <tr>
            <td colspan="6" >
                <?php if($mb->DescSociete){ ?>
                <?php echo JText::_( 'PRESENTATION' ); ?>:
                <?php echo $mb->DescSociete; ?>
                <br/><br/><?php } ?>
            </td>
        </tr>
        <tr>
            <td colspan="6">
            <?php if($mb->Photo1){ ?>
                <?php echo JText::_( 'NOS_CONSEILLERS' ); ?><?php } ?>
            </td>
        </tr>
        <tr>
            <td>
                <?php if($mb->Photo1){ ?>
                <img src="images/annuaire/<?php echo $mb->Photo1; ?>" /><?php } ?>
            </td>
            <td class="ann_leg">
                <?php if($mb->legende1){ ?>
                <?php echo $mb->legende1; ?><?php } ?>
            </td>
            <td>
                <?php if($mb->Photo2){ ?>
                <img src="images/annuaire/<?php echo $mb->Photo2; ?>" /><?php } ?>
            </td>
            <td class="ann_leg">
                <?php if($mb->legende2){ ?>
                <?php echo $mb->legende2; ?><?php } ?>
            </td>
            <td>
                <?php if($mb->Photo3){ ?>
                <img src="images/annuaire/<?php echo $mb->Photo3; ?>" /><?php } ?>
            </td>
            <td class="ann_leg">
                <?php if($mb->legende3){ ?>
                <?php echo $mb->legende3; ?><?php } ?>
            </td>
        </tr>
        <tr>
           
            <td>
                <?php if($mb->Photo4){ ?>
                <img src="images/annuaire/<?php echo $mb->Photo4; ?>" /><?php } ?>
            </td>
            <td class="ann_leg">
                <?php if($mb->legende4){ ?>
                <?php echo $mb->legende4; ?><?php } ?>
            </td>
            <td>
                <?php if($mb->Photo5){ ?>
                <img src="images/annuaire/<?php echo $mb->Photo5; ?>" /><?php } ?>
            </td>
            <td class="ann_leg">
                <?php if($mb->legende5){ ?>
                <?php echo $mb->legende5; ?><?php } ?>
            </td>
            <td colspan="2">
            </td>
        </tr>
        <tr>
            <td colspan="6">
                <?php echo JText::_( 'SITUATION' ); ?>
               
                <div id="map">
                <img src="http://maps.google.com/maps/api/staticmap
                ?center=<?php echo $mb->Rue; ?>+<?php echo $mb->NPA; ?>+<?php echo $mb->Ville; ?>&zoom=13&size=500x300&maptype=roadmap
                &markers=color:red|color:red|label:.|<?php echo $mb->Rue; ?>+<?php echo $mb->NPA; ?>+<?php echo $mb->Ville; ?>
                &sensor=false
                &key=ABQIAAAADZzYHfJ8GUBvcCWtyZn4mRT7eXjnWH0h2AQzLVrdi3QyRIc7dBRYtR4P4vEu5GAsA2Ul0lVNYQ1g8Q"/>
                </div>
            </td>
        </tr>
    </table>
    <?php endforeach;?>
</div>


Then you have all the way my code goes for this screen, do you see something wrong?

Your help is very appreciated, thanks!


Top
   
 
Posted: Thu Nov 05, 2009 9:25 am 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Fri Sep 09, 2005 2:13 pm
Posts: 6776
Location: The Netherlands
very strange, I don't see any code that will logout the user..

_________________
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards


Top
  E-mail  
 
Posted: Thu Nov 05, 2009 9:36 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon May 22, 2006 6:43 am
Posts: 7
Yes very strange, you can view the site here (it's a development environment so no problem to test and manipulate) :

http://www.nakama.ch/myb_espace_perso/
login : test
password : test

You have to login to go on the pages "Mes comparatifs", "Mes contrats" and "Mon conseiller". The problem is when you go to "Mon conseiller", make some search and then click to an item to see the details. You can go to the details page but when you want fo exemaple come back to "Mes contrats", user is logged out, try it yourself.


Top
   
 
Posted: Thu Nov 05, 2009 2:17 pm 
User avatar
Joomla! Exemplar
Joomla! Exemplar
Offline

Joined: Thu Jul 17, 2008 3:10 pm
Posts: 7697
Location: Europe
Hi,

try to change this code:
Code:
        $user=$model->getUser($iduser);
        $this->assignRef('user', $user);


to this one:
Code:
        $tmp_user=$model->getUser($iduser);
        $this->assignRef('user', $tmp_user);


You are overwriting the JUser Object with a different Object, and therefore logging the user out.

Olaf

_________________
Olaf Offick
Learn Skills - a world of learning at your fingertips
http://learn-skills.org


Top
   
 
Posted: Thu Nov 05, 2009 2:34 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon May 22, 2006 6:43 am
Posts: 7
Yes it works, thanks so much Ooffick, you're a genius! ;) I really didn't see that, and the worst in this story is that I never used this variable in my template, I can remove this from my code.

Well, thanks again for your help everybody!


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

Quick reply

 



Who is online

Users browsing this forum: ianmac, skdmarx, smicky, toivo and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group