Author Topic: Help Needed!  (Read 5807 times)

Offline viper58

  • Newbie
  • *
  • Posts: 7
Help Needed!
« on: January 09, 2008, 11:19:25 AM »
Okay so my website is completely php based and uses php for navigation. I have customized the original login page to match our website in an html version, this works perfectly. I have the login based directly into my website. The problem I am having now is that because I now use an entirely php mysql based website I need to change the login.html to a login.php page to work properly. I now find myself with a weird login button with code as text instead of the login fields. If anyone is able to convert the following code that roundcube initially uses, into a java script code this would be greatly appreciated:

Code: [Select]
<TABLE class=control width=&quot;90%&quot; align=center>
<tr>
<td>
<roundcube:object name=&quot;message&quot; id=&quot;message&quot; />
<div id=&quot;login-form&quot; align=left>
<div class=&quot;boxtitle&quot; align=left></div>
<div class=&quot;boxcontent&quot; align=left>

<form name=&quot;form&quot; action=&quot;./&quot; method=&quot;post&quot;>
<roundcube:object name=&quot;loginform&quot; form=&quot;form&quot; />

<div style=&quot;text-align:left;&quot;><input type=&quot;submit&quot; class=&quot;button&quot; value=&quot;<roundcube:label name='login' />&quot; /></div>

</form>
</div>
</div>
</td>
</tr>
</table>

As well I am also trying to locate the file in roundcube that directs the user to the login.html page of the template, as I now need this to say login.php. If anyone can direct me on how to change that as well.

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Help Needed!
« Reply #1 on: January 09, 2008, 03:08:56 PM »
Everything runs through index.php, so if a user isn't logged in, that's where it would be decided to show them the login page ;)

But login.html is just a template. It's not meant to be a scripted page. What exactly are you trying to do?

If you notice the page, you see some things like: ?='****' />
These are interpreted by the Roundcube templating engine and changed to whatever HTML elements they are supposed to be. For example:

Will be return a string with the localized value for "login". So now the login button is localized to whatever language(s) are chosen.
 
  

Offline viper58

  • Newbie
  • *
  • Posts: 7
Re: Help Needed!
« Reply #2 on: January 09, 2008, 11:18:58 PM »
yes I do understand that, however that code snippet is all that is needed besides a little java script in the header to create the login form. However, that code snippet does NOT work in a php file (which I need, instead of the login.html page in the template folder I have chosen).

My second question is since I am using a php file instead of the default login.html file in the template folder I have chosen, there has got to be a file somewhere in roundcube which is directing the original index.php page to locate that file. I need to change it to locate the php file instead. However I have been unable to locate which file is calling the page.

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Help Needed!
« Reply #3 on: January 10, 2008, 12:29:43 AM »
Okay, in /index.php of roundcube, at the very bottom there is this:
$OUTPUT->send($_task);
Depending upon the task, that does the work for the templating. Now, if you go up to line 241 or so, you should see this:
// not logged in -> show login page
if (!$_SESSION['user_id'])
{
 
$OUTPUT->task 'login';
 
$OUTPUT->send('login');
 exit;
}


So now I can say: the $OUTPUT object has a "send" method that is using the parameter "login" to include the "login.html" template file and parse it. So now let's track down where $OUTPUT is instantiated. I know that the "include/main.inc" file has a function rcmail_load_gui(). So if I look in there, I see this:
$OUTPUT = new rcmail_template($CONFIG$GLOBALS['_task']);
Okay, so now we need to look at rcmail_template() to see how it deals with the "login" task.

So we open up include/rcmail_template.inc and see that $OUTPUT::send('login') forwards the work on to $OUTPUT::parse('login') which is where you see this:
 function parse($name='main'$exit=true)
 {
  
$skin_path $this->config['skin_path'];

  
// read template file
  
$templ '';
  
$path "$skin_path/templates/$name.html";


So you'll have to add a conditional to test if $name is "login" or not. Something like this should work:
  $skin_path $this->config['skin_path'];
  
$ext 'html';
  
  if(
$name == 'login')
   
$ext 'php';

  
// read template file
  
$templ '';
  
$path "$skin_path/templates/$name.$ext";


That should get you what you need for your second question. I'm still baffled by your first question though. Why on earth are you doing it this way? What is your goal? To wrap the login page into your site? The login page redirects to itself, so if you just wrap it, then you'll only be wrapping the login page, and the rest of the interface will be roundcube. If you're going to "skin" your site, then do that instead.
 
  

Offline viper58

  • Newbie
  • *
  • Posts: 7
Re: Help Needed!
« Reply #4 on: January 10, 2008, 12:44:25 AM »
okay jsut want to let you know, that little fix of your actually fixed up my second issue :)
unfortunately I am now left with a 3rd issue. The path call, "reads" the file and displays. However it does not actually parse the php code, so none of the php code actually calls (reads in as text, displays as text, view source of the page, you can see the php calls).

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Help Needed!
« Reply #5 on: January 10, 2008, 09:53:24 AM »
Well, there is a method inside of "include/rcmail_template.inc" or "include/rcmail_html.inc" which is called "parse" which takes the template name as a parameter. You could instantiate your own object, call the parse() method, use the login form, and then display that on the page.

But for what you're trying to do, it seems a bit much. From what I can tell, you're trying to actually just have a form where users can log in, and are redirected to the Roundcube install on your server. If that's correct, then just use the form from roundcube instead of trying to parse the template ;)

Code: [Select]
<form name=&quot;form&quot; action=&quot;path/to/roundcube/root/index.php&quot; method=&quot;post&quot;>
 <input type=&quot;hidden&quot; name=&quot;_action&quot; value=&quot;login&quot; />
 <label for=&quot;rcmloginuser&quot;>Username</label>
 <input name=&quot;_user&quot; id=&quot;rcmloginuser&quot; size=&quot;30&quot; value=&quot;&quot; type=&quot;text&quot; /><br />
 <input name=&quot;_user&quot; id=&quot;rcmloginuser&quot; size=&quot;30&quot; value=&quot;&quot; type=&quot;text&quot; />
 <input name=&quot;_pass&quot; id=&quot;rcmloginpwd&quot; size=&quot;30&quot; type=&quot;password&quot; /><br />
 <input type=&quot;submit&quot; class=&quot;button&quot; value=&quot;Login&quot; />
</form>

It can't be much easier than that ;) And there's no fiddeling with template parsing. This works (I know for a fact) because I did something similar to this a while ago. Maybe later on down the line I can add a method to rcmail_template to return a parsed template file, just for this purpose.
 
  

Offline viper58

  • Newbie
  • *
  • Posts: 7
Re: Help Needed!
« Reply #6 on: January 10, 2008, 11:20:27 AM »
Thats exactly what I needed, moved the roundcube files up 1 directory, added my login page at root level, and edited the logout from the template as a redirection. Works perfectly. Thanks for the help :)

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Help Needed!
« Reply #7 on: January 10, 2008, 11:29:59 AM »
Glad you got it working :)