[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r4274 - in phpcompta/trunk: html include
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r4274 - in phpcompta/trunk: html include |
Date: |
Sun, 30 Oct 2011 00:19:51 +0200 (CEST) |
Author: danydb
Date: 2011-10-30 00:19:49 +0200 (Sun, 30 Oct 2011)
New Revision: 4274
Modified:
phpcompta/trunk/html/do.php
phpcompta/trunk/html/style-color.css
phpcompta/trunk/include/class_user.php
phpcompta/trunk/include/pref.inc.php
Log:
#420: R?\195?\169?\195?\169criture pr?\195?\169ference
Modified: phpcompta/trunk/html/do.php
===================================================================
--- phpcompta/trunk/html/do.php 2011-10-29 20:59:04 UTC (rev 4273)
+++ phpcompta/trunk/html/do.php 2011-10-29 22:19:49 UTC (rev 4274)
@@ -29,6 +29,7 @@
require_once('user_common.php');
require_once('ac_common.php');
require_once 'function_javascript.php';
+if (isset ($_POST["style_user"])){$_SESSION['g_theme']=$_POST['style_user'];}
html_page_start();
global $g_user, $cn;
Modified: phpcompta/trunk/html/style-color.css
===================================================================
--- phpcompta/trunk/html/style-color.css 2011-10-29 20:59:04 UTC (rev
4273)
+++ phpcompta/trunk/html/style-color.css 2011-10-29 22:19:49 UTC (rev
4274)
@@ -768,7 +768,7 @@
.button {
font-size:10;
- color:black;
+ color:white;
text-decoration:none;
font-family: helvetica,arial,sans-serif;
background-color:#DFDFDF;
Modified: phpcompta/trunk/include/class_user.php
===================================================================
--- phpcompta/trunk/include/class_user.php 2011-10-29 20:59:04 UTC (rev
4273)
+++ phpcompta/trunk/include/class_user.php 2011-10-29 22:19:49 UTC (rev
4274)
@@ -159,7 +159,7 @@
}
$sql="insert into audit_connect
(ac_user,ac_ip,ac_module,ac_url,ac_state) values ($1,$2,$3,$4,$5)";
-
+
if ( $res == 0 )
{
$cn->exec_sql($sql,array($_SESSION['g_user'],$_SERVER["REMOTE_ADDR"],$from,$_SERVER['REQUEST_URI'],'FAIL'));
@@ -388,7 +388,7 @@
$sql=sprintf("insert into user_local_pref
(user_id,parameter_value,parameter_type)
values ('%s','%d','PERIODE')",
- $this->id,$pid);
+ $this->login,$pid);
$Res=$this->db->exec_sql($sql);
}
@@ -442,16 +442,35 @@
}
+ function save_global_preference($key,$value)
+ {
+ $repo=new Database();
+ $count=$repo->get_value("select count(*)
+ from
+ user_global_pref
+ where
+ parameter_type=$1 and user_id=$2",
+ array($key,$this->login));
+ if ( $count == 1 )
+ {
+ $repo->exec_sql("update user_global_pref set parameter_value=$1
+ where parameter_type=$2 and user_id=$3",
+ array($value,$key,$this->login));
+ } elseif($count == 0)
+ {
+ $repo->exec_sql("insert into
user_global_pref(user_id,parameter_type,parameter_value)
+ values($1,$2,$3)",array($this->login,$key,$value));
+ }
+ }
-
/*!
* \brief Get the default user's preferences
* \return array of (parameter_type => parameter_value)
*/
function get_preference ()
{
- $sql="select parameter_type,parameter_value from user_local_pref where
user_id='".$this->id."'";
- $Res=$this->db->exec_sql($sql);
+ $sql="select parameter_type,parameter_value from user_local_pref where
user_id=$1";
+ $Res=$this->db->exec_sql($sql,array($this->id));
$l_array=array();
for ( $i =0;$i < Database::num_row($Res);$i++)
{
Modified: phpcompta/trunk/include/pref.inc.php
===================================================================
--- phpcompta/trunk/include/pref.inc.php 2011-10-29 20:59:04 UTC (rev
4273)
+++ phpcompta/trunk/include/pref.inc.php 2011-10-29 22:19:49 UTC (rev
4274)
@@ -31,41 +31,66 @@
require_once('class_periode.php');
echo '<DIV class="content">';
//----------------------------------------------------------------------
-// Change password
-if ( isset ($_POST['val']))
+//
+global $g_user;
+$inside_dossier = false;
+
+if (isset($_REQUEST['gDossier']))
{
- /*
- * @todo save the preference
- */
- var_dump($_POST);
+ $g_user->load_global_pref();
+ $msg = "";
+ $cn = new Database($_REQUEST['gDossier']);
+ $g_user->cn = $cn;
+ $inside_dossier = true;
+ $local_pref=$g_user->get_preference();
}
-if (isset($_POST['pass_1'])
- && strlen(trim($_POST['pass_1'])) != 0)
+//// Save value
+if (isset($_POST['val']))
{
- if ($_POST['pass_1'] != $_POST['pass_2'])
+ extract($_POST);
+
+ if (strlen(trim($pass_1)) != 0 && strlen(trim($pass_2)) != 0)
{
- alert(_("Les mots de passe ne correspondent pas. Mot de passe
inchangé"));
+ if ($pass_1 == $pass_2)
+ {
+ $repo = new Database();
+ $l_pass = md5($_POST['pass_1']);
+ $repo->exec_sql("update ac_users set use_pass=$1 where
use_login=$2", array($l_pass, $_SESSION['g_user']));
+ $_SESSION['g_pass'] = $_POST['pass_1'];
+ echo "<i>" . _('Mot de passe est modifiée') . "</i>";
+ }
+ else
+ {
+ alert(_("Les mots de passe ne correspondent pas. Mot de passe
inchangé"));
+ }
}
- else
+ if ($inside_dossier)
{
- $Rep = new Database();
- $l_pass = md5($_POST['pass_1']);
- $Res = $Rep->exec_sql("update ac_users set use_pass='$l_pass' where
use_login='" . $_SESSION['g_user'] . "'");
- $pass = $_POST['pass_1'];
- $_SESSION['g_pass'] = $_POST['pass_1'];
- $g_pass = $_POST['pass_1'];
- echo "<i>" . _('Mot de passe est modifiée') . "</i>";
+ $g_user->set_periode($period);
+ $g_user->save_global_preference('THEME', $style_user);
+ $g_user->save_global_preference('LANG', $lang);
+ $g_user->save_global_preference('PAGESIZE', $p_size);
+ $g_user->set_mini_report($minirap);
+ $_SESSION['g_theme']=$style_user;
+ $_SESSION['g_pagesize']=$p_size;
+ $_SESSION['g_lang']=$lang;
}
}
-if (!isset($_REQUEST['gDossier']))
-{
- echo HtmlInput::button_anchor(_('Retour'), 'user_login.php?');
-}
-else
-{
+//////////////////////////////////////////////////////////////////////////
+// Theme
+//////////////////////////////////////////////////////////////////////////
+
+ $repo = new Database();
+// charge tous les styles
+ $res = $repo->exec_sql("select the_name from theme
+ order by the_name");
+ $style = new ISelect('style_user');
+ $style->value = $repo->make_array("select the_name,the_name
+ from theme
+ order by the_name");
+ $style->selected =$_SESSION['g_theme'];
echo '<h2 class="info2">' . _('Changez vos préférences') . '</h2>';
-}
?>
<div class="content">
@@ -80,67 +105,24 @@
<input type="password" value="" class="input_type"
name="pass_2" nohistory>
</td>
</tr>
-<?php
- $Rep = new Database();
-// charge tous les styles
- $res = $Rep->exec_sql("select the_name from theme
- order by the_name");
- $astyle = array();
- for ($i = 0; $i < Database::num_row($res); $i++)
- {
- $st = Database::fetch_array($res, $i);
- $astyle[] = $st['the_name'];
- }
-// Formatte le display
- $disp_style = "<SELECT NAME=\"style_user\" >";
- foreach ($astyle as $st)
- {
- if ($st == $_SESSION['g_theme'])
- {
- $disp_style.='<OPTION VALUE="' . $st . '" SELECTED>' .
$st;
- }
- else
- {
- $disp_style.='<OPTION VALUE="' . $st . '">' . $st;
- }
- }
- $disp_style.="</SELECT>";
- ?>
- <p>
+
<tr>
<td>
- <?php echo _('Thème');
- ?>
+ <?php echo _('Thème');?>
</td>
<td>
- <?php print $disp_style;
- ?>
+ <?php echo $style->input();?>
</td>
</tr>
<?php
- global $g_user;
- $inside_dossier = false;
-// Si utilise un dossier alors propose de changer
-// la periode par defaut
- if (isset($_REQUEST['gDossier']))
+ if ($inside_dossier)
{
- $inside_dossier = true;
- $msg = "";
- $cn = new Database($_REQUEST['gDossier']);
- $g_user->cn = $cn;
-
- if (isset($_POST['period']))
- {
- $periode = $_POST["period"];
- $g_user->set_periode($periode);
- }
-
$l_user_per = $g_user->get_periode();
if ($l_user_per == "")
$l_user_per = $cn->get_value("select min(p_id) from
parm_periode where p_closed='f'");
- // if periode is closed then warns the users
+// if periode is closed then warns the users
$period = new Periode($cn, $l_user_per);
$period->p_id = $l_user_per;
@@ -151,7 +133,6 @@
$msg = '<h2 class="notice">' . $msg . '</h2>';
}
-
$period = new IPeriod("period");
$period->user = $g_user;
$period->cn = $cn;
@@ -160,88 +141,85 @@
$period->type = ALL;
$l_form_per = $period->input();
?>
- <tr><td><?php echo _('Période');
- ?></td>
+ <tr><td><?php echo _('Période');?></td>
<td>
- <?php printf(' %s ', $l_form_per);?>
+ <?php printf(' %s ', $l_form_per);?>
</td>
<td> <?php echo $msg;?></td>
- <?php
- }
- ?>
+ <tr>
+ <td><? echo _('Taille des pages');?></td>
+ <td>
+ <SELECT NAME="p_size">
+ <option value="15">15
+ <option value="25">25
+ <option value="50">50
+ <option value="100">100
+ <option value="150">150
+ <option value="200">200
+ <option value="-1"><?php echo _('Illimité');?>
+ <?php
+ $label = ($_SESSION['g_pagesize'] == -1) ?
_('Illimité') : $_SESSION['g_pagesize'];
+ echo '<option value="' .
$_SESSION['g_pagesize'] . '" selected>' . $label;
+ ?>
+ </SELECT>
- <tr>
- <td><? echo _('Taille des pages');
- ?></td>
- <td>
- <SELECT NAME="p_size">
- <option value="15">15
- <option value="25">25
- <option value="50">50
- <option value="100">100
- <option value="150">150
- <option value="200">200
- <option value="-1"><?php echo _('Illimité');?>
-<?php
-$label = ($_SESSION['g_pagesize'] == -1) ? _('Illimité') :
$_SESSION['g_pagesize'];
-echo '<option value="' . $_SESSION['g_pagesize'] . '" selected>' . $label;
-?>
- </SELECT>
-
- </td>
- </tr>
+ </td>
+ </tr>
+ <?
+ }
+ ?>
</table>
</fieldset>
-<?php
-if ($inside_dossier)
-{
- /* Pref for welcome page */
- echo '<fieldset>';
- echo '<legend>' . _('Options pour la page d\'accueil') . '</legend>';
- echo _('Mini-Rapport : ');
- $rapport = new Acc_Report($cn);
- $aRapport = $rapport->make_array();
- $aRapport[] = array("value" => 0, "label" => _('Aucun mini rapport'));
- $wRapport = new ISelect();
- $wRapport->name = "minirap";
- $wRapport->selected = $g_user->get_mini_report();
- $wRapport->value = $aRapport;
- echo $wRapport->input();
- echo '<span class="notice">' . _('Le mini rapport est un rapport qui
s\'affiche sur votre page d\'accueil') . '</span>';
- echo '</fieldset>';
-}
+ <?php
+ if ($inside_dossier)
+ {
+ /* Pref for welcome page */
+ echo '<fieldset>';
+ echo '<legend>' . _('Options pour la page d\'accueil') .
'</legend>';
+ echo _('Mini-Rapport : ');
+ $rapport = new Acc_Report($cn);
+ $aRapport = $rapport->make_array();
+ $aRapport[] = array("value" => 0, "label" => _('Aucun mini
rapport'));
+ $wRapport = new ISelect();
+ $wRapport->name = "minirap";
+ $wRapport->selected = $g_user->get_mini_report();
+ $wRapport->value = $aRapport;
+ echo $wRapport->input();
+ echo '<span class="notice">' . _('Le mini rapport est un rapport
qui s\'affiche sur votre page d\'accueil') . '</span>';
+ echo '</fieldset>';
+ }
-echo '<fieldset>';
-echo '<legend>' . _('Langue') . '</legend>';
-echo _('Selectionnez votre langue');
-$aLang = array(array(_('Français'), 'fr_FR.utf8'),
- array(_('Anglais'), 'en_US.utf8'),
- array(_('Néerlandais'), 'nl_NL.utf8'),
- );
-echo '<select name="lang" id="l">';
-for ($i = 0; $i < count($aLang); $i++)
-{
-$sel = "";
-if ($aLang[$i][1] == $_SESSION['g_lang'])
- $sel = " selected ";
-printf('<option value="%s" %s>%s</option>', $aLang[$i][1], $sel,
$aLang[$i][0]);
-}
-echo '</select>';
-echo '</fieldset>';
+ echo '<fieldset>';
+ echo '<legend>' . _('Langue') . '</legend>';
+ echo _('Selectionnez votre langue');
+ $aLang = array(array(_('Français'), 'fr_FR.utf8'),
+ array(_('Anglais'), 'en_US.utf8'),
+ array(_('Néerlandais'), 'nl_NL.utf8'),
+ );
+ echo '<select name="lang" id="l">';
+ for ($i = 0; $i < count($aLang); $i++)
+ {
+ $sel = "";
+ if ($aLang[$i][1] == $_SESSION['g_lang'])
+ $sel = " selected ";
+ printf('<option value="%s" %s>%s</option>', $aLang[$i][1], $sel,
$aLang[$i][0]);
+ }
+ echo '</select>';
+ echo '</fieldset>';
-echo HtmlInput::submit("val", _("Valider"));
-echo '</form>';
+ echo HtmlInput::submit("val", _("Valider"));
+ echo '</form>';
-if (!$inside_dossier)
-{
-echo HtmlInput::button_anchor(_('Retour'), 'user_login.php?');
-}
+ if (!$inside_dossier)
+ {
+ echo HtmlInput::button_anchor(_('Retour'), 'user_login.php?');
+ }
-echo "</DIV>";
-?>
+ echo "</DIV>";
+ ?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r4274 - in phpcompta/trunk: html include,
phpcompta-dev <=