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
fd1df431
Commit
fd1df431
authored
Nov 13, 2006
by
Richard Mansfield
Browse files
Merge with
git+ssh://git.catalyst.net.nz/var/git/mahara.git
parents
9417b9f9
6e72807f
Changes
8
Hide whitespace changes
Inline
Side-by-side
htdocs/account/index.php
View file @
fd1df431
...
...
@@ -29,9 +29,73 @@ define('MENUITEM', 'account');
define
(
'SUBMENUITEM'
,
'accountprefs'
);
require
(
dirname
(
dirname
(
__FILE__
))
.
'/init.php'
);
require
(
'form.php'
);
$smarty
=
smarty
();
// load up user preferences
$prefs
=
(
object
)(
$SESSION
->
get
(
'accountprefs'
));
$prefsform
=
array
(
'name'
=>
'accountprefs'
,
'method'
=>
'post'
,
'ajaxpost'
=>
true
,
'plugintype '
=>
'core'
,
'pluginname'
=>
'account'
,
'elements'
=>
array
(
'friendscontrol'
=>
array
(
'type'
=>
'radio'
,
'value'
=>
$prefs
->
friendscontrol
,
'title'
=>
get_string
(
'friendsdescr'
,
'account'
),
'separator'
=>
HTML_BR
,
'options'
=>
array
(
'nobody'
=>
get_string
(
'friendsnobody'
,
'account'
),
'auth'
=>
get_string
(
'friendsauth'
,
'account'
),
'auto'
=>
get_string
(
'friendsauto'
,
'account'
)
),
'rules'
=>
array
(
'required'
=>
true
)
),
'wysiwyg'
=>
array
(
'type'
=>
'radio'
,
'value'
=>
$prefs
->
wysiwyg
,
'title'
=>
get_string
(
'wysiwygdescr'
,
'account'
),
'options'
=>
array
(
1
=>
get_string
(
'on'
,
'account'
),
0
=>
get_string
(
'off'
,
'account'
),
),
'rules'
=>
array
(
'required'
=>
true
)
),
'messages'
=>
array
(
'type'
=>
'radio'
,
'value'
=>
$prefs
->
messages
,
'title'
=>
get_string
(
'messagesdescr'
,
'account'
),
'options'
=>
array
(
'nobody'
=>
get_string
(
'messagesnobody'
,
'account'
),
'friends'
=>
get_string
(
'messagesfriends'
,
'account'
),
'allow'
=>
get_string
(
'messagesallow'
,
'account'
),
),
'rules'
=>
array
(
'required'
=>
true
)
),
'submit'
=>
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'save'
),
),
),
);
$smarty
=
smarty
();
$smarty
->
assign
(
'form'
,
form
(
$prefsform
));
$smarty
->
display
(
'account/index.tpl'
);
function
accountprefs_submit
(
$values
)
{
}
?>
htdocs/auth/session.php
View file @
fd1df431
...
...
@@ -71,7 +71,9 @@ class Session {
'firstname'
=>
''
,
'lastname'
=>
''
,
'prefname'
=>
''
,
'email'
=>
''
'email'
=>
''
,
'accountprefs'
=>
array
(),
'activityprefs'
=>
array
(),
);
// Resume an existing session if required
if
(
isset
(
$_COOKIE
[
'PHPSESSID'
]))
{
...
...
@@ -99,6 +101,33 @@ class Session {
return
$this
->
defaults
[
$key
];
}
/**
* This function returns a method for a particular
* activity type.
* or null if it's not set.
*
* @param string $key the activity type
*/
public
function
get_activity_preference
(
$key
)
{
if
(
isset
(
$_SESSION
[
'activityprefs'
][
$key
]))
{
return
$_SESSION
[
'activityprefs'
][
$key
];
}
return
null
;
}
/**
* This function returns a value for a particular
* account preference, or null if it's not set.
*
* @param string $key the field name
*/
public
function
get_account_preference
(
$key
)
{
if
(
isset
(
$_SESSION
[
'accountprefs'
][
$key
]))
{
return
$_SESSION
[
'accountprefs'
][
$key
];
}
return
null
;
}
/**
* Sets the session property keyed by $key.
*
...
...
@@ -115,6 +144,16 @@ class Session {
$_SESSION
[
$key
]
=
$value
;
}
function
set_account_preference
(
$field
,
$value
)
{
set_account_preference
(
$this
->
get
(
'id'
),
$field
,
$value
);
$_SESSION
[
'accountprefs'
][
$field
]
=
$value
;
}
function
set_activity_preference
(
$activity
,
$method
)
{
set_activity_preference
(
$this
->
get
(
'id'
),
$activity
,
$method
);
$_SESSION
[
'activityprefs'
][
$activity
]
=
$method
;
}
/**
* Logs in the given user.
*
...
...
@@ -132,6 +171,8 @@ class Session {
$this
->
set
(
$key
,
(
isset
(
$USER
->
{
$key
}))
?
$USER
->
{
$key
}
:
$this
->
defaults
[
$key
]);
}
$this
->
set
(
'logout_time'
,
time
()
+
get_config
(
'session_timeout'
));
$_SESSION
[
'activityprefs'
]
=
load_activity_preferences
(
$this
->
get
(
'id'
));
$_SESSION
[
'accountprefs'
]
=
load_account_preferences
(
$this
->
get
(
'id'
));
}
/**
...
...
htdocs/init.php
View file @
fd1df431
...
...
@@ -83,6 +83,7 @@ require('ddl.php');
require
(
'constants.php'
);
require
(
'web.php'
);
require
(
'activity.php'
);
require
(
'user.php'
);
// Database access functions
require
(
'adodb/adodb-exceptions.inc.php'
);
...
...
htdocs/js/mahara.js
View file @
fd1df431
...
...
@@ -53,7 +53,11 @@ function processingStop() {
// Autofocus the first element with a class of 'autofocus' on page load
addLoadEvent
(
function
()
{
getFirstElementByTagAndClassName
(
null
,
'
autofocus
'
,
document
.
body
).
focus
();
var
element
=
getFirstElementByTagAndClassName
(
null
,
'
autofocus
'
,
document
.
body
)
if
(
element
&&
typeof
(
element
.
focus
)
==
'
function
'
)
{
element
.
focus
();
}
});
// @todo remove this when we migrate to mochikit 1.4
...
...
htdocs/lang/en.utf8/account.php
0 → 100644
View file @
fd1df431
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined
(
'INTERNAL'
)
||
die
();
$string
[
'friendsnobody'
]
=
'Nobody may add me as a friend'
;
$string
[
'friendsauth'
]
=
'New friends require my authorisation'
;
$string
[
'friendsauto'
]
=
'New friends are automatically authorised'
;
$string
[
'friendsdescr'
]
=
'Friends control'
;
$string
[
'wysiwygdescr'
]
=
'Rich text editor'
;
$string
[
'on'
]
=
'On'
;
$string
[
'off'
]
=
'Off'
;
$string
[
'messagesdescr'
]
=
'Messages from other users'
;
$string
[
'messagesnobody'
]
=
'Allow no-one to message me'
;
$string
[
'messagesfriends'
]
=
'Allow people on my friends list to message me'
;
$string
[
'messagesallow'
]
=
'Allow anyone to message me'
;
?>
htdocs/lang/en.utf8/mahara.php
View file @
fd1df431
...
...
@@ -158,4 +158,5 @@ $string['changepassword'] = 'Change password';
$string
[
'activity'
]
=
'Recent activity'
;
$string
[
'emailname'
]
=
'Mahara System'
;
// robot!
$string
[
'save'
]
=
'Save'
;
?>
htdocs/lib/user.php
0 → 100644
View file @
fd1df431
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core
* @author Penny Leach <penny@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined
(
'INTERNAL'
)
||
die
();
/**
* loads up activity preferences for a given user
*
* @param int $userid to load preferences for
* @todo caching
*/
function
load_activity_preferences
(
$userid
)
{
$prefs
=
array
();
if
(
empty
(
$userid
))
{
throw
new
InvalidArgumentException
(
"couldn't load activity preferences, no user id specified"
);
}
if
(
$prefs
=
get_records
(
'usr_activity_preference'
,
'usr'
,
$userid
))
{
foreach
(
$prefs
as
$p
)
{
$prefs
[
$p
->
activity
]
=
$p
->
method
;
}
}
return
$prefs
;
}
/**
* loads up account preferences for a given user
* if you want them for the current user
* use $SESSION->accountprefs
*
* @param int $userid to load preferences for
* @todo caching
* @todo defaults?
*/
function
load_account_preferences
(
$userid
)
{
$prefs
=
array
();
$expectedprefs
=
expected_account_preferences
();
if
(
empty
(
$userid
))
{
throw
new
InvalidArgumentException
(
"couldn't load account preferences, no user id specified"
);
}
if
(
$prefs
=
get_records
(
'usr_account_preference'
,
'usr'
,
$userid
))
{
foreach
(
$prefs
as
$p
)
{
$prefs
[
$p
->
field
]
=
$p
->
value
;
}
}
foreach
(
$expectedprefs
as
$field
=>
$default
)
{
if
(
!
isset
(
$prefs
[
$field
]))
{
$prefs
[
$field
]
=
$default
;
}
}
return
$prefs
;
}
/**
* sets a user preference in the database
* if you want to set it in the session as well
* use SESSION->set_account_preference
*
* @param int $userid user id to set preference for
* @param string $field preference field to set
* @param string $value preference value to set.
*/
function
set_account_preference
(
$userid
,
$field
,
$value
)
{
if
(
record_exists
(
'usr_account_preference'
,
'usr'
,
$userid
,
'field'
,
$field
))
{
set_field
(
'usr_account_preference'
,
'value'
,
$value
,
'usr'
,
$userid
,
'field'
,
$field
);
}
else
{
try
{
$pref
=
new
StdClass
;
$pref
->
usr
=
$userid
;
$pref
->
field
=
$field
;
$pref
->
value
=
$value
;
insert_record
(
'usr_account_preference'
,
$pref
);
}
catch
(
Exception
$e
)
{
throw
new
InvalidArgumentException
(
"Failed to insert account preference "
.
"
$value
for
$field
for user
$userid
"
);
}
}
}
/**
* sets an activity preference in the database
* if you want to set it in the session as well
* use $SESSION->set_activity_preference
*
* @param int $userid user id to set preference for
* @param string $activity activity type to set
* @param string $method notification method to set.
*/
function
set_activity_preference
(
$userid
,
$activity
,
$method
)
{
if
(
record_exists
(
'usr_activity_preference'
,
'usr'
,
$userid
,
'activity'
,
$activity
))
{
set_field
(
'usr_activity_preference'
,
'method'
,
$method
,
'usr'
,
$userid
,
'activity'
,
$activity
);
}
else
{
try
{
$pref
=
new
StdClass
;
$pref
->
usr
=
$userid
;
$pref
->
activity
=
$activity
;
$pref
->
method
=
$method
;
insert_record
(
'usr_activity_preference'
,
$pref
);
}
catch
(
Exception
$e
)
{
throw
new
InvalidArgumentException
(
"Failed to insert activity preference "
.
"
$methodfor
$activity
for user
$userid
"
);
}
}
}
function
expected_account_preferences
()
{
return
array
(
'friendscontrol'
=>
'auth'
,
'wysiwyg'
=>
1
,
'messages'
=>
'allow'
,
'lang'
=>
'en.utf8'
);
}
?>
htdocs/theme/default/templates/account/index.tpl
View file @
fd1df431
...
...
@@ -5,7 +5,7 @@
<h2>
{
str
tag
=
"account"
}
</h2>
<div
class=
"content"
>
Content from database here
{
$form
}
</div>
{
include
file
=
"footer.tpl"
}
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