Configuration/hooks/local index not logged in

From Davical
Jump to: navigation, search

To provide your own login screen you can define a function like:

function local_index_not_logged_in()  {
   echo '<p>Username: <input name="username" type="text">';
   ... etc...
 } 

You can completely override all of the home page except the headers (the inc/page-header.php file is included before this function is checked for existence).

See inc/DAViCalSession.php around line 130 for where this masterpiece is invoked from.

The normal login screen provides input for three fields in a form, like:

<form action="/" method="post">
 <table>
  <tr>
   <th class="prompt">User Name:</th>
   <td class="entry"><input class="text" type="text" name="username" size="12" /></td>
  </tr>
  <tr>
   <th class="prompt">Password:</th>
   <td class="entry">
    <input class="password" type="password" name="password" size="12" />  
    <label>forget me not: <input class="checkbox" type="checkbox" name="remember" value="1" /></label>
   </td>
  </tr>
  <tr>
   <th class="prompt"> </th>
   <td class="entry">
    <input type="submit" value="GO!"
           title="Enter your username and password then click here to log in." name="submit" class="submit" />
   </td>
  </tr>
 </table>
 <p>
  If you have forgotten your password then:
     <input type="submit"
        value="Help! I've forgotten my password!"
        title="Enter a username,  if you know it, and click here, to be e-mailed a temporary password."
        name="lostpass" class="submit" />
 </p>
</form>

You can use this to change any text on the login screen. The function should return control to the caller which will finish the page normally by include inc/page-footer.php.

Example of local index without forgotten password links

Using that text, here's a quick and dirty example of a function you could include in your configuration file which would remove the "I forgot my password" block.

function local_index_not_logged_in() {
?>
<form action="/" method="post">
 <table>
  <tr>
   <th class="prompt">User Name:</th>
   <td class="entry"><input class="text" type="text" name="username" size="12" /></td>
  </tr>
  <tr>
   <th class="prompt">Password:</th>
   <td class="entry">
    <input class="password" type="password" name="password" size="12" />  
    <label>forget me not: <input class="checkbox" type="checkbox" name="remember" value="1" /></label>
   </td>
  </tr>
  <tr>
   <th class="prompt"> </th>
   <td class="entry">
    <input type="submit" value="GO!"
           title="Enter your username and password then click here to log in." name="submit" class="submit" />
   </td>
  </tr>
 </table>
</form>
<?php
}