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
091aae59
Commit
091aae59
authored
11 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
orm: Map relationships to business logic class instead of models
parent
f83a4a96
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.organization.php
+6
-17
6 additions, 17 deletions
include/class.organization.php
include/class.user.php
+15
-42
15 additions, 42 deletions
include/class.user.php
with
21 additions
and
59 deletions
include/class.organization.php
+
6
−
17
View file @
091aae59
...
...
@@ -23,24 +23,15 @@ class OrganizationModel extends VerySimpleModel {
'pk'
=>
array
(
'id'
),
'joins'
=>
array
(
'users'
=>
array
(
'reverse'
=>
'UserAccount
Model
.org'
,
'reverse'
=>
'UserAccount.org'
,
),
)
);
var
$users
;
function
getId
()
{
return
$this
->
id
;
}
}
class
Organization
extends
OrganizationModel
{
var
$_entries
;
var
$_forms
;
//XXX: Shouldn't getName use magic get method to figure this out?
function
getName
()
{
return
$this
->
name
;
}
...
...
@@ -52,6 +43,11 @@ class Organization extends OrganizationModel {
function
getCreateDate
()
{
return
$this
->
created
;
}
}
class
Organization
extends
OrganizationModel
{
var
$_entries
;
var
$_forms
;
function
addDynamicData
(
$data
)
{
...
...
@@ -115,11 +111,6 @@ class Organization extends OrganizationModel {
return
(
string
)
$this
->
getName
();
}
function
delete
()
{
//TODO: delete or reset intrumented list.
return
parent
::
delete
();
}
function
update
(
$vars
,
&
$errors
)
{
$valid
=
true
;
...
...
@@ -242,7 +233,5 @@ class OrganizationForm extends DynamicForm {
}
}
Organization
::
_inspect
();
?>
This diff is collapsed.
Click to expand it.
include/class.user.php
+
15
−
42
View file @
091aae59
...
...
@@ -74,12 +74,6 @@ class UserModel extends VerySimpleModel {
)
);
static
function
objects
()
{
$qs
=
parent
::
objects
();
#$qs->select_related('default_email');
return
$qs
;
}
function
getId
()
{
return
$this
->
id
;
}
...
...
@@ -98,15 +92,6 @@ class User extends UserModel {
var
$_entries
;
var
$_forms
;
var
$_account
;
function
__construct
(
$ht
)
{
parent
::
__construct
(
$ht
);
// TODO: Make this automatic with select_related()
if
(
isset
(
$ht
[
'default_email_id'
]))
$this
->
default_email
=
UserEmail
::
lookup
(
$ht
[
'default_email_id'
]);
}
static
function
fromVars
(
$vars
)
{
// Try and lookup by email address
$user
=
User
::
lookup
(
array
(
'emails__address'
=>
$vars
[
'email'
]));
...
...
@@ -553,19 +538,13 @@ class UserAccountModel extends VerySimpleModel {
'joins'
=>
array
(
'user'
=>
array
(
'null'
=>
false
,
'constraint'
=>
array
(
'user_id'
=>
'User
Model
.id'
)
'constraint'
=>
array
(
'user_id'
=>
'User.id'
)
),
'org'
=>
array
(
'constraint'
=>
array
(
'org_id'
=>
'Organization
Model
.id'
)
'constraint'
=>
array
(
'org_id'
=>
'Organization.id'
)
),
),
);
}
class
UserAccount
extends
UserAccountModel
{
var
$_options
=
null
;
var
$_user
;
var
$_org
;
const
CONFIRMED
=
0x0001
;
const
LOCKED
=
0x0002
;
...
...
@@ -615,10 +594,6 @@ class UserAccount extends UserAccountModel {
return
!
$this
->
hasStatus
(
self
::
FORBID_PASSWD_RESET
);
}
function
hasPassword
()
{
return
(
bool
)
$this
->
get
(
'passwd'
);
}
function
getStatus
()
{
return
$this
->
get
(
'status'
);
}
...
...
@@ -636,12 +611,8 @@ class UserAccount extends UserAccountModel {
}
function
getUser
()
{
if
(
!
isset
(
$this
->
_user
))
{
if
(
$this
->
_user
=
User
::
lookup
(
$this
->
getUserId
()))
$this
->
_user
->
set
(
'account'
,
$this
);
}
return
$this
->
_user
;
$this
->
user
->
set
(
'account'
,
$this
);
return
$this
->
user
;
}
function
getOrgId
()
{
...
...
@@ -649,24 +620,26 @@ class UserAccount extends UserAccountModel {
}
function
getOrganization
()
{
if
(
!
isset
(
$this
->
_org
))
$this
->
_org
=
Organization
::
lookup
(
$this
->
getOrgId
());
return
$this
->
_org
;
return
$this
->
org
;
}
function
setOrganization
(
$org
)
{
if
(
!
$org
instanceof
Organization
)
return
false
;
$this
->
set
(
'org_id'
,
$org
->
getId
());
$this
->
_org
=
null
;
$this
->
set
(
'org'
,
$org
);
$this
->
save
();
return
true
;
}
}
}
class
UserAccount
extends
UserAccountModel
{
function
hasPassword
()
{
return
(
bool
)
$this
->
get
(
'passwd'
);
}
function
sendResetEmail
()
{
return
static
::
sendUnlockEmail
(
'pwreset-client'
)
===
true
;
...
...
@@ -891,5 +864,5 @@ class UserList implements IteratorAggregate, ArrayAccess {
}
require_once
(
INCLUDE_DIR
.
'class.organization.php'
);
User
::
_inspect
();
UserAccount
::
_inspect
();
?>
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