Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
fd3a89ee
Commit
fd3a89ee
authored
Apr 09, 2014
by
Penom Nom
Browse files
update user info
parent
b65baf6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
ui/nG6/class.tx_nG6_eid.php
View file @
fd3a89ee
...
...
@@ -562,7 +562,28 @@ class tx_nG6_eid {
}
}
}
elseif
(
$type
==
'runs_table'
)
{
}
else
if
(
$type
==
'update_user'
){
$email
=
trim
(
t3lib_div
::
_GP
(
'email'
));
$first_name
=
trim
(
t3lib_div
::
_GP
(
'first_name'
));
$last_name
=
trim
(
t3lib_div
::
_GP
(
'last_name'
));
$group_name
=
trim
(
t3lib_div
::
_GP
(
'title'
));
$location
=
trim
(
t3lib_div
::
_GP
(
'location'
));
$organism
=
trim
(
t3lib_div
::
_GP
(
'organism'
));
$id
=
trim
(
t3lib_div
::
_GP
(
'id'
));
$password
=
trim
(
t3lib_div
::
_GP
(
'password'
));
$clearpassword
=
trim
(
t3lib_div
::
_GP
(
'clearpassword'
));
$cruser_id
=
trim
(
t3lib_div
::
_GP
(
'creator'
));
if
(
tx_nG6_db
::
update_user
(
$id
,
$first_name
,
$last_name
,
$email
,
$group_name
,
$organism
,
$location
,
$password
)
==
1
)
{
print
'1'
;
}
else
{
print
'2'
;
}
}
elseif
(
$type
==
'runs_table'
)
{
$smarty
=
new
Smarty
();
$smarty
->
setTemplateDir
(
t3lib_extMgm
::
extPath
(
'nG6'
)
.
'/pi1'
);
$smarty
->
setCompileDir
(
t3lib_extMgm
::
extPath
(
'nG6'
)
.
'/res/smarty/templates_c'
);
...
...
ui/nG6/lib/class.tx_nG6_db.php
View file @
fd3a89ee
...
...
@@ -2062,6 +2062,39 @@ class tx_nG6_db {
}
/**
* Update user informations
*
* @param $id the id of the user to update
* @param array $user_data the user array
*/
function
update_user
(
$id
,
$first_name
,
$last_name
,
$email
,
$group_name
,
$organism
,
$location
,
$password
){
$user_datas
=
array
(
'first_name'
=>
$first_name
,
'last_name'
=>
$last_name
,
'email'
=>
$email
,
'password'
=>
$password
);
foreach
(
$user_datas
as
$key
=>
$value
)
{
if
(
isset
(
$value
)
and
!
empty
(
$value
))
{
tx_nG6_db
::
update_field
(
'fe_users'
,
$id
,
$key
,
$value
);
}
}
// if group does not exists, create group
if
(
isset
(
$group_name
)
and
!
empty
(
$group_name
))
{
$group_id
=
tx_nG6_db
::
get_group_id
(
$group_name
);
if
(
!
isset
(
$group_id
)
){
$cruser_id
=
trim
(
t3lib_div
::
_GP
(
'creator'
));
tx_nG6_db
::
create_new_group
(
$cruser_id
,
$group_name
,
$organism
,
$location
);
}
}
return
1
;
}
/**
* Tell if the group name exists in the DB.
*
...
...
ui/nG6/pi1/project_view.tpl
View file @
fd3a89ee
...
...
@@ -137,8 +137,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tr
id=
"tr_user_
{
$user_values.id
}
"
class=
"
{
$emphasis
}
"
>
{
if
(
$projects
[
key
(
$projects
)].
is_admin
&&
$user_values.id
!
=
$user_id
)
||
(
$
projects
[
key
(
$projects
)].
is_manager
&&
$user_values.id
!=
$user_id
&&
$user_values.right_id
!=
'2'
)
}
{
if
(
$user_values.
cruser_
id
=
=
$user_id
)
||
(
$
user_values.cruser_id
!=
$user_id
&&
$user_values.id
==
$user_id
&&
(
$projects
[
key
(
$projects
)].
is_admin
||
$projects
[
key
(
$projects
)].
is_manager
)
)
}
<td><center><input
type=
"checkbox"
id=
"chk_user_
{
$user_values.id
}
"
value=
"user_
{
$user_values.id
}
"
/></center></td>
{
elseif
$needs_action
}
<td></td>
...
...
@@ -207,10 +207,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div
class=
"btn-group"
>
<button
id=
"add_user"
type=
"button"
class=
"btn nou-selection-btn btn-small"
><i
class=
"icon-plus"
></i>
add user
</button>
<button
id=
"del_user"
type=
"button"
class=
"btn multipleu-selection-btn btn-small"
><i
class=
"icon-minus"
></i>
delete user
</button>
<button
id=
"update_user"
type=
"button"
class=
"btn singleu-selection-btn btn-small"
><i
class=
"icon-refresh"
></i>
update user
</button>
</div>
</th>
</tr>
</tfoot>
{
elseif
$user_values.id
==
$user_id
}
<tfoot>
<tr>
<th
align=
"left"
colspan=
"7"
>
With selection :
<button
id=
"update_user"
type=
"button"
class=
"btn btn-small"
><i
class=
"icon-refresh"
></i>
update user
</button>
</th>
</tr>
</tfoot>
{/
if
}
</table>
</div>
...
...
ui/nG6/res/js/tx_nG6_pi1.js
View file @
fd3a89ee
...
...
@@ -372,6 +372,215 @@ $(function () {
}
});
//update user properties
$
(
"
:button[id=update_user]
"
).
click
(
function
(){
var
user_id
=
null
,
user_login
=
null
;
// current user is creator
if
(
$
(
'
:checked[id^=chk_user]
'
).
size
()
==
1
)
{
user_id
=
$
(
'
:checked[id^=chk_user]
'
).
val
().
split
(
"
_
"
,
2
)[
1
];
user_login
=
$
(
'
#tr_user_
'
+
user_id
+
'
td:eq(1)
'
).
html
();
}
// to many selected user to update
else
if
(
$
(
'
:checked[id^=chk_user]
'
).
size
()
>
1
){
return
;
}
// member
else
{
user_id
=
$
(
"
#user_id
"
).
val
();
user_login
=
$
(
"
#user_login
"
).
val
();
}
$
(
"
#modal-label-tmpl
"
).
html
(
"
Update user <small>
"
+
user_login
+
"
</small>
"
);
var
update_user_html
=
'
<div id="error_message" class="alert alert-error"><button class="close" data-dismiss="alert" type="button">x</button></div>
'
;
update_user_html
=
'
<div>
'
;
update_user_html
+=
'
<form class="form-horizontal" id="update_user_form">
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">First name</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<input type="text" id="first_name_val" name="first_name_val" placeholder="First name"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">Last name</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<input type="text" id="last_name_val" name="last_name_val" placeholder="Last name"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">Email</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<input type="text" id="email_val" name="email_val" placeholder="Email"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">Password</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<div class="input-append">
'
;
update_user_html
+=
'
<input type="password" id="user_password_pwd_val" name="user_password_pwd_val" placeholder="Password"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">Confirm password</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<div class="input-append">
'
;
update_user_html
+=
'
<input type="password" id="user_password_pwd2_val" name="user_password_pwd2_val" placeholder="Confirm password"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">Laboratory</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<input type="text" id="title_val" class="group_typeahead" name="title_val" placeholder="Laboratory"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">Organism</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<input type="text" id="organism_val" class="group_typeahead" name="organism_val" placeholder="Organism"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
<div class="control-group">
'
;
update_user_html
+=
'
<label class="control-label">Location</label>
'
;
update_user_html
+=
'
<div class="controls">
'
;
update_user_html
+=
'
<input type="text" id="location_val" class="group_typeahead" name="location_val" placeholder="Location"/>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</div>
'
;
update_user_html
+=
'
</form>
'
;
$
(
"
#modal-body-tmpl
"
).
html
(
update_user_html
);
$
(
"
#modal-foot-tmpl
"
).
html
(
'
<button class="btn" id="raz_form"><i class="icon-repeat"></i> Clear form</a>
'
+
'
<button id="modal-btn-updateuser" class="btn btn-primary"><i class="icon-ok icon-white"></i> Save</button>
'
);
// show modal box
$
(
"
#ng6modal
"
).
modal
().
ready
(
function
()
{
$
(
"
#error_message
"
).
hide
();
$
(
'
.group_typeahead
'
).
typeahead
({
minLength
:
2
,
onselect
:
function
(
item
)
{
if
(
item
.
hasOwnProperty
(
'
title
'
)
)
{
$
(
"
#title_val
"
).
val
(
item
.
title
);
$
(
"
#organism_val
"
).
val
(
item
.
organism
);
$
(
"
#location_val
"
).
val
(
item
.
location
);
lock_group_fields
(
1
);
}
else
if
(
item
.
hasOwnProperty
(
'
organism
'
)
)
{
$
(
"
#organism_val
"
).
val
(
item
.
organism
);
}
else
if
(
item
.
hasOwnProperty
(
'
location
'
)
)
{
$
(
"
#location_val
"
).
val
(
item
.
location
);
}
},
source
:
function
(
typeahead
,
query
)
{
var
gender
=
$
(
typeahead
[
"
$element
"
][
0
]).
attr
(
"
id
"
).
split
(
"
_val
"
)[
0
];
$
.
ajax
({
url
:
"
index.php?eID=tx_nG6&type=autocomplete&gender=
"
+
gender
+
"
&project_id=
"
+
$
(
"
#current_project_id
"
).
val
()
+
"
&name_start=
"
+
query
,
dataType
:
'
json
'
,
success
:
function
(
users
)
{
var
data
=
new
Array
();
for
(
index
in
users
)
{
users
[
index
][
'
value
'
]
=
users
[
index
][
gender
];
data
.
push
(
users
[
index
]);
}
typeahead
.
process
(
data
);
}
});
}
});
// lock/unlock fields when autocomplete
function
lock_group_fields
(
order
){
// lock fields
if
(
order
==
1
){
$
(
"
#title_val
"
).
attr
(
'
disabled
'
,
'
disabled
'
);
$
(
"
#organism_val
"
).
attr
(
'
disabled
'
,
'
disabled
'
);
$
(
"
#location_val
"
).
attr
(
'
disabled
'
,
'
disabled
'
);
// unlock fields
}
else
if
(
order
==
0
){
$
(
"
#title_val
"
).
removeAttr
(
'
disabled
'
);
$
(
"
#organism_val
"
).
removeAttr
(
'
disabled
'
);
$
(
"
#location_val
"
).
removeAttr
(
'
disabled
'
);
}
}
$
(
"
#raz_form
"
).
click
(
function
(){
$
(
"
#last_name_val
"
).
val
(
""
);
$
(
"
#first_name_val
"
).
val
(
""
);
$
(
"
#user_password_pwd_val
"
).
val
(
""
);
$
(
"
#email_val
"
).
val
(
""
);
$
(
"
#title_val
"
).
val
(
""
);
$
(
"
#organism_val
"
).
val
(
""
);
$
(
"
#location_val
"
).
val
(
""
);
lock_group_fields
(
0
);
// unlock fields
$
(
"
#error_message
"
).
hide
();
});
$
(
"
#update_user_form
"
).
validate
({
rules
:
{
email_val
:
{
email
:
true
},
user_password_pwd2_val
:
{
equalTo
:
"
#user_password_pwd_val
"
},
},
messages
:
{
email_val
:
null
,
user_password_pwd2_val
:
"
Same password is required
"
,
},
submitHandler
:
function
(
form
)
{
var
val_url
=
"
index.php?eID=tx_nG6&type=update_user
"
;
val_url
+=
"
&last_name=
"
+
$
(
"
#last_name_val
"
).
val
();
val_url
+=
"
&first_name=
"
+
$
(
"
#first_name_val
"
).
val
();
val_url
+=
"
&email=
"
+
$
(
"
#email_val
"
).
val
();
val_url
+=
"
&title=
"
+
$
(
"
#title_val
"
).
val
();
val_url
+=
"
&organism=
"
+
$
(
"
#organism_val
"
).
val
();
val_url
+=
"
&location=
"
+
$
(
"
#location_val
"
).
val
();
val_url
+=
"
&creator=
"
+
$
(
"
#user_id
"
).
val
();
if
(
$
(
"
#user_password_pwd_val
"
).
val
())
{
val_url
+=
"
&password=
"
+
MD5
(
$
(
"
#user_password_pwd_val
"
).
val
());
val_url
+=
"
&clearpassword=
"
+
$
(
"
#user_password_pwd_val
"
).
val
();
}
val_url
+=
"
&id=
"
+
user_id
;
$
.
ajax
({
url
:
val_url
,
success
:
function
(
val
,
status
,
xhr
)
{
if
(
val
==
'
1
'
)
{
$
(
"
#ng6modal
"
).
modal
(
'
hide
'
);
if
(
!
endsWith
(
location
.
href
,
"
active_tab=users
"
))
{
location
.
assign
(
location
.
href
+
"
&active_tab=users
"
);
}
else
{
location
.
assign
(
location
.
href
);
}
}
else
{
//something went wrong
$
(
"
#error_message
"
).
html
(
"
Can't update this user informations ,
"
+
val
+
"
,
"
+
status
).
show
();
}
}
});
}
});
});
//Submit the form
$
(
"
#modal-btn-updateuser
"
).
click
(
function
()
{
$
(
"
#update_user_form
"
).
submit
();
});
});
/* add user to project option */
$
(
"
:button[id=add_user]
"
).
click
(
function
(){
...
...
@@ -856,6 +1065,14 @@ function updateUsersButtonStatus() {
$
(
this
).
removeAttr
(
'
disabled
'
);
}
});
$
(
'
.singleu-selection-btn
'
).
each
(
function
(){
if
(
$
(
"
:checked[id^=chk_user_]
"
).
size
()
!=
1
)
{
$
(
this
).
attr
(
'
disabled
'
,
'
disabled
'
);
}
else
{
$
(
this
).
removeAttr
(
'
disabled
'
);
}
});
$
(
"
.nou-selection-btn
"
).
each
(
function
(){
$
(
this
).
removeAttr
(
'
disabled
'
);
});
}
...
...
@@ -1623,4 +1840,4 @@ function addAnalysisHandler(){
$
(
"
#reset_workflow
"
).
bind
(
'
click
'
,
resetAnalysisWorkflowHandler
);
$
(
"
#run_workflow
"
).
bind
(
'
click
'
,
runAnalysisWorkflowHandler
);
$
(
"
#refresh_workflow_status
"
).
bind
(
'
click
'
,
refreshAnalysisWorkflowHandler
);
}
\ No newline at end of file
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment