projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed default startup_up app to be in user preferences. Default 'Sales'.
[fa-stable.git]
/
admin
/
db
/
users_db.inc
diff --git
a/admin/db/users_db.inc
b/admin/db/users_db.inc
index 53f3c40cdf1f22624f54be4168459eb63347f13d..ebb9c8f6936e716fb1b9c1c2186bda3c2a4cbf75 100644
(file)
--- a/
admin/db/users_db.inc
+++ b/
admin/db/users_db.inc
@@
-1,13
+1,13
@@
<?php
/**********************************************************************
Copyright (C) FrontAccounting, LLC.
<?php
/**********************************************************************
Copyright (C) FrontAccounting, LLC.
- Released under the terms of the GNU
Affero General Public License,
- AGPL, as published by the Free Software Foundation, either version
-
3
of the License, or (at your option) any later version.
+ Released under the terms of the GNU
General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the License here <http://www.gnu.org/licenses/
a
gpl-3.0.html>.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
function add_user($user_id, $real_name, $password, $phone, $email, $full_access,
***********************************************************************/
function add_user($user_id, $real_name, $password, $phone, $email, $full_access,
@@
-25,17
+25,17
@@
function add_user($user_id, $real_name, $password, $phone, $email, $full_access,
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
-function update_user_password($user_id, $password)
+function update_user_password($
id, $
user_id, $password)
{
{
- $sql = "UPDATE ".TB_PREF."users SET password=".db_escape($password) . "
-
WHERE user_id = ".db_escape($user_
id);
+ $sql = "UPDATE ".TB_PREF."users SET password=".db_escape($password) . "
,
+
user_id = ".db_escape($user_id). " WHERE id=".db_escape($
id);
db_query($sql, "could not update user password for $user_id");
}
//-----------------------------------------------------------------------------------------------
db_query($sql, "could not update user password for $user_id");
}
//-----------------------------------------------------------------------------------------------
-function update_user($user_id, $real_name, $phone, $email, $full_access,
+function update_user($
id, $
user_id, $real_name, $phone, $email, $full_access,
$language, $profile, $rep_popup, $pos)
{
$sql = "UPDATE ".TB_PREF."users SET real_name=".db_escape($real_name).
$language, $profile, $rep_popup, $pos)
{
$sql = "UPDATE ".TB_PREF."users SET real_name=".db_escape($real_name).
@@
-45,16
+45,18
@@
function update_user($user_id, $real_name, $phone, $email, $full_access,
language=".db_escape($language).",
print_profile=".db_escape($profile).",
rep_popup=$rep_popup,
language=".db_escape($language).",
print_profile=".db_escape($profile).",
rep_popup=$rep_popup,
- pos=$pos
- WHERE user_id = ".db_escape($user_id);
+ pos=$pos,
+ user_id = " . db_escape($user_id)
+ . " WHERE id=" . db_escape($id);
db_query($sql, "could not update user for $user_id");
}
//-----------------------------------------------------------------------------------------------
db_query($sql, "could not update user for $user_id");
}
//-----------------------------------------------------------------------------------------------
-function update_user_display_prefs($
user_
id, $price_dec, $qty_dec, $exrate_dec,
+function update_user_display_prefs($id, $price_dec, $qty_dec, $exrate_dec,
$percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep,
$percent_dec, $showgl, $showcodes, $date_format, $date_sep, $tho_sep,
- $dec_sep, $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size, $graphic_links)
+ $dec_sep, $theme, $pagesize, $show_hints, $profile, $rep_popup, $query_size,
+ $graphic_links, $lang, $stickydate, $startup_tab)
{
$sql = "UPDATE ".TB_PREF."users SET
prices_dec=".db_escape($price_dec).",
{
$sql = "UPDATE ".TB_PREF."users SET
prices_dec=".db_escape($price_dec).",
@@
-73,40
+75,56
@@
function update_user_display_prefs($user_id, $price_dec, $qty_dec, $exrate_dec,
print_profile=".db_escape($profile).",
rep_popup=$rep_popup,
query_size=$query_size,
print_profile=".db_escape($profile).",
rep_popup=$rep_popup,
query_size=$query_size,
- graphic_links=$graphic_links
- WHERE user_id = ".db_escape($user_id);
+ graphic_links=$graphic_links,
+ language=".db_escape($lang).",
+ sticky_doc_date=".db_escape($stickydate).",
+ startup_tab=".db_escape($startup_tab)."
+ WHERE id = ".db_escape($id);
- db_query($sql, "could not update user display prefs for $
user_
id");
+ db_query($sql, "could not update user display prefs for $id");
}
//-----------------------------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------------------------
-function get_users()
+function get_users(
$all=false
)
{
$sql = "SELECT * FROM ".TB_PREF."users";
{
$sql = "SELECT * FROM ".TB_PREF."users";
+ if (!$all) $sql .= " WHERE !inactive";
return db_query($sql, "could not get users");
}
//-----------------------------------------------------------------------------------------------
return db_query($sql, "could not get users");
}
//-----------------------------------------------------------------------------------------------
-function get_user($
user_
id)
+function get_user($id)
{
{
- $sql = "SELECT * FROM ".TB_PREF."users WHERE
user_id = '$user_id'"
;
+ $sql = "SELECT * FROM ".TB_PREF."users WHERE
id=".db_escape($id)
;
- $result = db_query($sql, "could not get user
for $user_
id");
+ $result = db_query($sql, "could not get user
$
id");
return db_fetch($result);
}
//-----------------------------------------------------------------------------------------------
return db_fetch($result);
}
//-----------------------------------------------------------------------------------------------
+// This function is necessary for admin prefs update after upgrade from 2.1
+//
+function get_user_by_login($user_id)
+{
+ $sql = "SELECT * FROM ".TB_PREF."users WHERE user_id=".db_escape($user_id);
+
+ $result = db_query($sql, "could not get user $user_id");
+
+ return db_fetch($result);
+}
-function delete_user($user_id)
+//-----------------------------------------------------------------------------------------------
+
+function delete_user($id)
{
{
- $sql="DELETE FROM ".TB_PREF."users WHERE
user_id='$user_id'"
;
+ $sql="DELETE FROM ".TB_PREF."users WHERE
id=".db_escape($id)
;
- db_query($sql, "could not delete user $
user_
id");
+ db_query($sql, "could not delete user $id");
}
//-----------------------------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------------------------
@@
-115,7
+133,10
@@
function get_user_for_login($user_id, $password)
{
set_global_connection();
{
set_global_connection();
- $sql = "SELECT * FROM ".TB_PREF."users WHERE user_id = '$user_id' AND password='$password'";
+// do not exclude inactive records or you lost access after source upgrade
+// on sites using pre 2.2 database
+ $sql = "SELECT * FROM ".TB_PREF."users WHERE user_id = '$user_id' AND"
+ ." password='$password'";
return db_query($sql, "could not get validate user login for $user_id");
}
return db_query($sql, "could not get validate user login for $user_id");
}
@@
-131,5
+152,13
@@
function update_user_visitdate($user_id)
}
//-----------------------------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------------------------
+function check_user_activity($id)
+{
+ $sql = "SELECT COUNT(*) FROM ".TB_PREF."audit_trail WHERE audit_trail.user="
+ . db_escape($id);
+ $result = db_query($sql,"Cant check user activity");
+ $ret = db_fetch($result);
+ return $ret[0];
+}
?>
\ No newline at end of file
?>
\ No newline at end of file