]> dev.renevier.net Git - syp.git/blobdiff - inc/templates_admin.php
interface to change password
[syp.git] / inc / templates_admin.php
index ce7e3b4230069f83bcfb124307bdae92a3210105..589ca5f3a328ad36c9521dd789ae8ca9fee11610 100644 (file)
@@ -2,11 +2,14 @@
 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
    license. */
 
-require_once ("./inc/settings.php");
+$error = false;
+
+if (!@include_once ("./inc/settings.php")) {
+    $error = true;
+}
 require_once ("./inc/db/mysql.php");
 require_once ("./inc/utils.php");
 
-$error = false;
 try {
     $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
     $usrtblexists = $connection->users_table_exists ();
@@ -21,7 +24,7 @@ if (!$usrtblexists || !$itemstblexists) {
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">  
-<html>
+<html lang="<?php echo $lang?>">
 <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
       <title><?php ptrans('SYP admin')?></title>
@@ -29,16 +32,20 @@ if (!$usrtblexists || !$itemstblexists) {
 </head>
 <body>
     <p class="error center"><?php ptrans('SYP is not correctly installed. Please follow README.txt instructions
-       and go to <a href="wizard.en.php">wizard</a>.')?></p>
+       and go to <a href="install.en.php">wizard</a>.')?></p>
 </body>
 </html>
 <?php
     exit ();
     } // if ($error)
+
+    $user = $_COOKIE [sprintf ("%suser", DBPREFIX)];
+    $pwd = $_COOKIE [sprintf ("%sauth", DBPREFIX)];
+    $logged = ($connection->checkpwdmd5 ($user, $pwd));
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">  
-<html>
+<html lang="<?php echo $lang?>">
 <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
       <title><?php ptrans('SYP admin');?></title>
@@ -60,16 +67,20 @@ if (!$usrtblexists || !$itemstblexists) {
             UnauthorizedError: "<?php ptrans('Password is not correct.')?>",
             NotimageError: "<?php ptrans('File does not look like an image.')?>",
             UnconsistentError: "<?php ptrans('Server reply was inconsistent.')?>",
-            UnknownError: "<?php ptrans('There was an unknown error.')?>",
             DelSucces: "<?php ptrans('Removal took place correctly.')?>",
-            UpdateSucces: "<?php ptrans('Save took place correctly.')?>"
+            UpdateSucces: "<?php ptrans('Save took place correctly.')?>",
+            userPasswordmatchError: "<?php ptrans('Passwords do not match.')?>",
+            changeSamePass: "<?php ptrans('New password is the same as old password.')?>",
+            changePassBadPass: "<?php ptrans('Bad password.')?>",
+            changePassSuccess: "<?php ptrans('Password changed correctly.')?>",
+            newUserNonameError: "<?php ptrans('User name has not been set.')?>",
+            newUserExistsError: "<?php ptrans('User already exists in database.')?>",
+            newUserSuccess: "<?php ptrans('User added correctly.')?>"
         };
 
-        <?php 
-            $bbox = $connection->mbr ();
-            printf ("var sypOrig = [%.18F, %.18F, %.18F, %.18F];\n",
-                    $bbox [0], $bbox [1], $bbox [2], $bbox [3]); 
-        ?>
+        var sypSettings =  {
+            loggedUser: <?php printf ($logged ? "\"$user\"": "null")?>
+        };
 
       </script>
       <script src="./js/jquery-1.3.2.js" type="text/javascript"></script>
@@ -94,7 +105,52 @@ if (!$usrtblexists || !$itemstblexists) {
 
     <div id="header">
     <?php other_languages($lang) ?>
-    <p id="logout"><a href="logout.php"><?php ptrans('Logout')?></a></p>
+    <div id="user_management">
+        <p id="logout" class="user_link"><a href="logout.php"><?php ptrans('Logout')?></a></p>
+        <p id="change_pass" class="user_link"><a href=""><?php ptrans('Change my password')?></a></p>
+        <p id="add_user" class="user_link"><a href=""><?php ptrans('Add a co-administrator')?></a></p>
+    </div>
+        <div id="user_area">
+            <input id="user_close" type="image" src="openlayers/theme/default/img/close.gif"
+                        title="<?php ptrans('close without saving')?>" alt="<?php ptrans('close')?>">
+            <form id="changepass" method="post">
+                <label for="pass_current"><?php ptrans('current password:')?></label>
+                <br>
+                <input id="pass_current" name="pass_current" type="password">
+                <br>
+                <label for="pass_new"><?php ptrans('new password:')?></label>
+                <br>
+                <input id="pass_new" name="pass_new" type="password">
+                <br>
+                <label for="pass_new_confirm"><?php ptrans('confirm new password:')?></label>
+                <br>
+                <input id="pass_new_confirm" name="pass_new_confirm" type="password">
+                <br>
+                <input id="pass_submit" name="pass_submit" type="submit" value="<?php ptrans('Validate password')?>">
+                <input type="hidden" name="request" value="changepass">
+            </form>
+            <form id="newuser" method="post">
+                <label for="newuser_name"><?php ptrans('user name:')?></label>
+                <br>
+                <input id="newuser_name" name="newuser_name">
+                <br>
+                <label for="newuser_password"><?php ptrans('user password:')?></label>
+                <br>
+                <input id="newuser_password" name="newuser_password" type="password" value="">
+                <br>
+                <label for="newuser_password_confirm"><?php ptrans('confirm password:')?></label>
+                <br>
+                <input id="newuser_password_confirm" name="newuser_password_confirm" type="password">
+                <br>
+                <input id="newuser_submit" name="newuser_submit" type="submit" value="<?php ptrans('Validate user')?>">
+                <input type="hidden" name="request" value="newuser">
+                </form>
+                <p id="user_comm" class="center"></p>
+                <p id="user_throbber" class="throbber center">
+                    <?php ptrans('Connecting')?>
+                    <img src="media/newuser-throbber.gif">
+                </p>
+        </div>
     </div>
 
 
@@ -135,12 +191,15 @@ if (!$usrtblexists || !$itemstblexists) {
             <input type="hidden" name="request" value="del">
             <input type="hidden" name="fid">
         </form>
+        <p id="editor_throbber" class="throbber center">
+            <?php ptrans('Connecting')?>
+            <img src="media/editor-throbber.gif">
+        </p>
     </div>
 
       <div id="login_area"
         <?php 
-        if ($connection->checkpwdmd5 ("admin", 
-                               $_COOKIE [sprintf ("%sauth", DBPREFIX)])) {
+        if ($logged) {
             echo ' class="hidden"';
         }
       ?>>
@@ -148,7 +207,12 @@ if (!$usrtblexists || !$itemstblexists) {
      <div id="login_padding"></div>
      <div id="login_content">
         <form id="login_form" method="post">
+        <div id="cookie_warning" class="center warn"><?php ptrans('You need to have cookies enabled to administrate SYP')?></div>
             <table>
+                <tr>
+                    <td><label for="user"><?php ptrans('user')?></label></td>
+                    <td style="width: 100%"><input id="user" name="user"></td>
+                </tr>
                 <tr>
                     <td><label for="password"><?php ptrans('password')?></label></td>
                     <td style="width: 100%"><input id="password" name="password" type="password"></td>
@@ -160,7 +224,7 @@ if (!$usrtblexists || !$itemstblexists) {
             </p>
             <p id="pwd_throbber" class="throbber center">
                 <?php ptrans('Connecting')?>
-                <img src="media/pwd_throbber.gif" alt="throbber">
+                <img src="media/pwd-throbber.gif" alt="throbber">
             </p>
             <p class="error center" id="login_error"></p>
         </form>