Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
2195616a
Commit
2195616a
authored
Jan 16, 2007
by
Richard Mansfield
Browse files
Merge with
git+ssh://git.catalyst.net.nz/var/git/mahara.git
parents
eab3253f
ba5606eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/auth/user.php
View file @
2195616a
...
...
@@ -64,6 +64,8 @@ class User {
'inactivemailsent'
=>
0
,
'staff'
=>
false
,
'admin'
=>
false
,
'quota'
=>
0
,
'quotaused'
=>
0
,
'firstname'
=>
''
,
'lastname'
=>
''
,
'preferredname'
=>
''
,
...
...
@@ -104,6 +106,9 @@ class User {
if
(
!
isset
(
$this
->
defaults
[
$key
]))
{
throw
new
InvalidArgumentException
(
$key
);
}
if
(
$key
==
'quotaused'
)
{
throw
new
InvalidArgumentException
(
'quotaused should be set via the quota_* methods'
);
}
$this
->
SESSION
->
set
(
"user/
$key
"
,
$value
);
}
...
...
@@ -205,6 +210,37 @@ class User {
return
$this
->
stdclass
;
}
public
function
quota_add
(
$bytes
)
{
if
(
!
is_numeric
(
$bytes
)
||
$bytes
<
0
)
{
throw
new
InvalidArgumentException
(
'parameter must be a positive integer to add to the quota'
);
}
if
(
!
$this
->
quota_allowed
(
$bytes
))
{
throw
new
QuotaExceededException
(
'Adding '
.
$bytes
.
' bytes would exceed the user\'s quota'
);
}
$newquota
=
$this
->
get
(
'quotaused'
)
+
$bytes
;
$this
->
SESSION
->
set
(
"user/quotaused"
,
$newquota
);
update_record
(
'usr'
,
array
(
'quotaused'
=>
$newquota
),
array
(
'id'
=>
$this
->
get
(
'id'
)));
}
public
function
quota_remove
(
$bytes
)
{
if
(
!
is_numeric
(
$bytes
)
||
$bytes
<
0
)
{
throw
new
InvalidArgumentException
(
'parameter must be a positive integer to remove from the quota'
);
}
$newquota
=
$this
->
get
(
'quotaused'
)
-
$bytes
;
if
(
$newquota
<
0
)
{
$newquota
=
0
;
}
$this
->
SESSION
->
set
(
"user/quotaused"
,
$newquota
);
update_record
(
'usr'
,
array
(
'quotaused'
=>
$newquota
),
array
(
'id'
=>
$this
->
get
(
'id'
)));
}
public
function
quota_allowed
(
$bytes
)
{
if
(
$this
->
get
(
'quotaused'
)
+
$bytes
>
$this
->
get
(
'quota'
))
{
return
false
;
}
return
true
;
}
}
...
...
htdocs/lib/errors.php
View file @
2195616a
...
...
@@ -648,6 +648,11 @@ class UserNotFoundException extends UserException {}
*/
class
CommunityNotFoundException
extends
UserException
{}
/**
* Exception - fired when something happens that would make the user exceed their quota
*/
class
QuotaExceededException
extends
UserException
{}
/**
* Exception - anything to do with template parsing
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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