Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
290b3c02
Commit
290b3c02
authored
11 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add forms getter
Add update routine Add updated date getter
parent
5d54e8c3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/class.dynamic_forms.php
+1
-1
1 addition, 1 deletion
include/class.dynamic_forms.php
include/class.user.php
+68
-1
68 additions, 1 deletion
include/class.user.php
with
69 additions
and
2 deletions
include/class.dynamic_forms.php
+
1
−
1
View file @
290b3c02
...
@@ -70,7 +70,7 @@ class DynamicForm extends VerySimpleModel {
...
@@ -70,7 +70,7 @@ class DynamicForm extends VerySimpleModel {
function
getField
(
$name
)
{
function
getField
(
$name
)
{
foreach
(
$this
->
getDynamicFields
()
as
$f
)
foreach
(
$this
->
getDynamicFields
()
as
$f
)
if
(
!
strcasecmp
(
$f
->
get
(
'name'
),
$name
))
if
(
!
strcasecmp
(
$f
->
get
(
'name'
),
$name
))
return
$f
;
return
$f
->
getImpl
()
;
}
}
function
hasField
(
$name
)
{
function
hasField
(
$name
)
{
...
...
This diff is collapsed.
Click to expand it.
include/class.user.php
+
68
−
1
View file @
290b3c02
...
@@ -67,6 +67,7 @@ class UserModel extends VerySimpleModel {
...
@@ -67,6 +67,7 @@ class UserModel extends VerySimpleModel {
class
User
extends
UserModel
{
class
User
extends
UserModel
{
var
$_entries
;
var
$_entries
;
var
$_forms
;
function
__construct
(
$ht
)
{
function
__construct
(
$ht
)
{
parent
::
__construct
(
$ht
);
parent
::
__construct
(
$ht
);
...
@@ -119,11 +120,16 @@ class User extends UserModel {
...
@@ -119,11 +120,16 @@ class User extends UserModel {
return
new
PersonsName
(
$this
->
name
);
return
new
PersonsName
(
$this
->
name
);
}
}
function
getUpdateDate
()
{
return
$this
->
updated
;
}
function
to_json
()
{
function
to_json
()
{
$info
=
array
(
$info
=
array
(
'id'
=>
$this
->
getId
(),
'id'
=>
$this
->
getId
(),
'name'
=>
(
string
)
$this
->
getName
());
'name'
=>
(
string
)
$this
->
getName
(),
'email'
=>
(
string
)
$this
->
getEmail
());
return
JsonDataEncoder
::
encode
(
$info
);
return
JsonDataEncoder
::
encode
(
$info
);
}
}
...
@@ -154,6 +160,67 @@ class User extends UserModel {
...
@@ -154,6 +160,67 @@ class User extends UserModel {
return
$this
->
_entries
;
return
$this
->
_entries
;
}
}
function
getForms
(
$populate
=
true
)
{
if
(
!
isset
(
$this
->
_forms
))
{
$this
->
_forms
=
array
();
foreach
(
$this
->
getDynamicData
()
as
$cd
)
{
$cd
->
addMissingFields
();
if
(
$populate
&&
(
$form
=
$cd
->
getForm
())
&&
$form
->
get
(
'type'
)
==
'U'
)
{
foreach
(
$cd
->
getFields
()
as
$f
)
{
if
(
$f
->
get
(
'name'
)
==
'name'
)
$f
->
value
=
$this
->
getFullName
();
elseif
(
$f
->
get
(
'name'
)
==
'email'
)
$f
->
value
=
$this
->
getEmail
();
}
}
$this
->
_forms
[]
=
$cd
->
getForm
();
}
}
return
$this
->
_forms
;
}
function
updateInfo
(
$vars
,
&
$errors
)
{
$valid
=
true
;
$forms
=
$this
->
getForms
(
false
);
foreach
(
$forms
as
$cd
)
{
if
(
!
$cd
->
isValid
())
$valid
=
false
;
elseif
((
$f
=
$cd
->
getField
(
'email'
))
&&
$cd
->
get
(
'type'
)
==
'U'
&&
(
$u
=
User
::
lookup
(
array
(
'emails__address'
=>
$f
->
getClean
())))
&&
$u
->
id
!=
$this
->
getId
())
{
$valid
=
false
;
$f
->
addError
(
'Email is assigned to another user'
);
}
}
if
(
!
$valid
)
return
false
;
foreach
(
$this
->
getDynamicData
()
as
$cd
)
{
if
((
$f
=
$cd
->
getForm
())
&&
$f
->
get
(
'type'
)
==
'U'
)
{
if
((
$name
=
$f
->
getField
(
'name'
)))
{
$this
->
name
=
$name
->
getClean
();
$this
->
save
();
}
if
((
$email
=
$f
->
getField
(
'email'
)))
{
$this
->
default_email
->
address
=
$email
->
getClean
();
$this
->
default_email
->
save
();
}
}
$cd
->
save
();
}
return
true
;
}
function
save
(
$refetch
=
false
)
{
function
save
(
$refetch
=
false
)
{
// Drop commas and reorganize the name without them
// Drop commas and reorganize the name without them
$parts
=
array_map
(
'trim'
,
explode
(
','
,
$this
->
name
));
$parts
=
array_map
(
'trim'
,
explode
(
','
,
$this
->
name
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment