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
0f5b95f0
Commit
0f5b95f0
authored
11 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Attach dynamic data to organization form
Don't save 'name' as dynamic data for organization form.
parent
c3bb3831
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/class.dynamic_forms.php
+19
-4
19 additions, 4 deletions
include/class.dynamic_forms.php
include/class.organization.php
+40
-2
40 additions, 2 deletions
include/class.organization.php
with
59 additions
and
6 deletions
include/class.dynamic_forms.php
+
19
−
4
View file @
0f5b95f0
...
...
@@ -18,6 +18,7 @@
**********************************************************************/
require_once
(
INCLUDE_DIR
.
'class.orm.php'
);
require_once
(
INCLUDE_DIR
.
'class.forms.php'
);
require_once
(
INCLUDE_DIR
.
'class.filter.php'
);
require_once
(
INCLUDE_DIR
.
'class.signal.php'
);
/**
...
...
@@ -607,14 +608,23 @@ class DynamicFormEntry extends VerySimpleModel {
// Add to list of answers
$this
->
_values
[]
=
$a
;
$this
->
_fields
[]
=
$field
;
$this
->
_form
=
null
;
// Omit fields without data
// For user entries, the name and email fields should not be
// saved with the rest of the data
if
(
!
(
$this
->
object_type
==
'U'
if
(
$this
->
object_type
==
'U'
&&
in_array
(
$field
->
get
(
'name'
),
array
(
'name'
,
'email'
)))
&&
$field
->
hasData
())
$a
->
save
();
$this
->
_form
=
null
;
continue
;
if
(
$this
->
object_type
==
'O'
&&
in_array
(
$field
->
get
(
'name'
),
array
(
'name'
)))
continue
;
if
(
!
$field
->
hasData
())
continue
;
$a
->
save
();
}
// Sort the form the way it is declared to be sorted
if
(
$this
->
_fields
)
...
...
@@ -634,6 +644,11 @@ class DynamicFormEntry extends VerySimpleModel {
if
(
$this
->
object_type
==
'U'
&&
in_array
(
$field
->
get
(
'name'
),
array
(
'name'
,
'email'
)))
continue
;
if
(
$this
->
object_type
==
'O'
&&
in_array
(
$field
->
get
(
'name'
),
array
(
'name'
)))
continue
;
$val
=
$field
->
to_database
(
$field
->
getClean
());
if
(
is_array
(
$val
))
{
$a
->
set
(
'value'
,
$val
[
0
]);
...
...
This diff is collapsed.
Click to expand it.
include/class.organization.php
+
40
−
2
View file @
0f5b95f0
...
...
@@ -13,6 +13,8 @@
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require_once
(
INCLUDE_DIR
.
'class.orm.php'
);
require_once
(
INCLUDE_DIR
.
'class.forms.php'
);
require_once
(
INCLUDE_DIR
.
'class.dynamic_forms.php'
);
class
OrganizationModel
extends
VerySimpleModel
{
static
$meta
=
array
(
...
...
@@ -125,6 +127,41 @@ class Organization extends OrganizationModel {
return
parent
::
delete
();
}
function
update
(
$vars
,
&
$errors
)
{
$valid
=
true
;
$forms
=
$this
->
getForms
(
$vars
);
foreach
(
$forms
as
$cd
)
{
if
(
!
$cd
->
isValid
())
$valid
=
false
;
if
(
$cd
->
get
(
'type'
)
==
'O'
&&
(
$form
=
$cd
->
getForm
(
$vars
))
&&
(
$f
=
$form
->
getField
(
'name'
))
&&
$f
->
getClean
()
&&
(
$o
=
Organization
::
lookup
(
array
(
'name'
=>
$f
->
getClean
())))
&&
$o
->
id
!=
$this
->
getId
())
{
$valid
=
false
;
$f
->
addError
(
'Organization with the same name already exists'
);
}
}
if
(
!
$valid
)
return
false
;
foreach
(
$this
->
getDynamicData
()
as
$cd
)
{
if
((
$f
=
$cd
->
getForm
())
&&
(
$f
->
get
(
'type'
)
==
'O'
)
&&
(
$name
=
$f
->
getField
(
'name'
)))
{
$this
->
name
=
$name
->
getClean
();
$this
->
save
();
}
$cd
->
save
();
}
return
true
;
}
static
function
fromVars
(
$vars
)
{
if
(
!
(
$org
=
Organization
::
lookup
(
array
(
'name'
=>
$vars
[
'name'
]))))
{
...
...
@@ -134,6 +171,7 @@ class Organization extends OrganizationModel {
'updated'
=>
new
SqlFunction
(
'NOW'
),
));
$org
->
save
(
true
);
$org
->
addDynamicData
(
$vars
);
}
return
$org
;
...
...
@@ -161,7 +199,7 @@ class Organization extends OrganizationModel {
}
class
Or
a
gnizationForm
extends
DynamicForm
{
class
Org
a
nizationForm
extends
DynamicForm
{
static
$instance
;
static
$form
;
...
...
@@ -172,7 +210,7 @@ class OragnizationForm extends DynamicForm {
static
function
getDefaultForm
()
{
if
(
!
isset
(
static
::
$form
))
{
if
(
$o
=
static
::
objects
())
if
(
(
$o
=
static
::
objects
())
&&
$o
[
0
])
static
::
$form
=
$o
[
0
];
else
//TODO: Remove the code below and move it to task??
static
::
$form
=
self
::
__loadDefaultForm
();
...
...
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