diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/profile/actions/edit.php | 22 | ||||
-rw-r--r-- | mod/profile/languages/en.php | 6 | ||||
-rw-r--r-- | mod/profile/start.php | 17 | ||||
-rw-r--r-- | mod/profile/views/default/profile/edit.php | 53 | ||||
-rw-r--r-- | mod/profile/views/default/user/user.php | 41 |
5 files changed, 71 insertions, 68 deletions
diff --git a/mod/profile/actions/edit.php b/mod/profile/actions/edit.php index 4bcecdb56..7ace0a22b 100644 --- a/mod/profile/actions/edit.php +++ b/mod/profile/actions/edit.php @@ -10,22 +10,28 @@ * @link http://elgg.com/
*/
+ // Load configuration
+ global $CONFIG;
+
// Get profile fields
- $aboutme = get_input('aboutme');
- $location = string_to_tag_array(get_input('location'));
- $skills = string_to_tag_array(get_input('skills'));
- $interests = string_to_tag_array(get_input('interests'));
+ $input = array();
+ foreach($CONFIG->profile as $shortname => $valuetype) {
+ $input[$shortname] = get_input($shortname);
+ if ($valuetype == 'tags')
+ $input[$shortname] = string_to_tag_array($input[$shortname]);
+ }
// Save stuff if we can, and forward to the user's profile
$user = $_SESSION['user'];
if ($user->canEdit()) {
// Save stuff
- $user->description = $aboutme;
+ if (sizeof($input) > 0)
+ foreach($input as $shortname => $value) {
+ $user->$shortname = $value;
+ }
$user->save();
- $user->location = $location;
- $user->skills = $skills;
- $user->interests = $interests;
+
system_message(elgg_echo("profile:saved"));
// Forward to the user's profile
diff --git a/mod/profile/languages/en.php b/mod/profile/languages/en.php index 8459c41af..79a3300cf 100644 --- a/mod/profile/languages/en.php +++ b/mod/profile/languages/en.php @@ -22,10 +22,14 @@ 'profile:edit' => "Edit profile",
- 'profile:aboutme' => "About me",
+ 'profile:description' => "About me",
'profile:location' => "Location",
'profile:skills' => "Skills",
'profile:interests' => "Interests",
+ 'profile:contactemail' => "Contact email",
+ 'profile:phone' => "Telephone",
+ 'profile:mobile' => "Mobile phone",
+ 'profile:website' => "Website",
/**
* Status messages
diff --git a/mod/profile/start.php b/mod/profile/start.php index baebf802f..03fe0eda1 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -34,6 +34,23 @@ ));
}
+ // For now, we'll hard code the profile items as follows:
+ // TODO make this user configurable
+ $CONFIG->profile = array(
+
+ // Language short codes must be of the form "profile:key"
+ // where key is the array key below
+ 'description' => 'longtext',
+ 'location' => 'tags',
+ 'interests' => 'tags',
+ 'skills' => 'tags',
+ 'contactemail' => 'email',
+ 'phone' => 'text',
+ 'mobile' => 'text',
+ 'website' => 'url',
+
+ );
+
// Register a page handler, so we can have nice URLs
register_page_handler('profile','profile_page_handler');
diff --git a/mod/profile/views/default/profile/edit.php b/mod/profile/views/default/profile/edit.php index 0cd648bf6..685793bff 100644 --- a/mod/profile/views/default/profile/edit.php +++ b/mod/profile/views/default/profile/edit.php @@ -10,48 +10,37 @@ * @link http://elgg.com/
*
* @uses $vars['entity'] The user entity
+ * @uses $vars['profile'] Profile items from $CONFIG->profile, defined in profile/start.php for now
*/
?>
<form action="<?php echo $vars['url']; ?>action/profile/edit" method="post">
+<?php
+
+ //var_export($vars['profile']);
+ if (is_array($vars['profile']) && sizeof($vars['profile']) > 0)
+ foreach($vars['profile'] as $shortname => $valtype) {
+
+?>
+
<p>
<label>
- <?php echo elgg_echo("profile:aboutme"); ?><br />
- <?php echo elgg_view("input/longtext",array(
- 'internalname' => 'aboutme',
- 'value' => $vars['entity']->description,
- )); ?>
- </label>
- </p>
- <p>
- <label>
- <?php echo elgg_echo("profile:location"); ?><br />
- <?php echo elgg_view("input/tags",array(
- 'internalname' => 'location',
- 'value' => $vars['entity']->location,
- )); ?>
- </label>
- </p>
- <p>
- <label>
- <?php echo elgg_echo("profile:skills"); ?><br />
- <?php echo elgg_view("input/tags",array(
- 'internalname' => 'skills',
- 'value' => $vars['entity']->skills,
- )); ?>
- </label>
- </p>
- <p>
- <label>
- <?php echo elgg_echo("profile:interests"); ?><br />
- <?php echo elgg_view("input/tags",array(
- 'internalname' => 'interests',
- 'value' => $vars['entity']->interests,
- )); ?>
+ <?php echo elgg_echo("profile:{$shortname}") ?><br />
+ <?php echo elgg_view("input/{$valtype}",array(
+ 'internalname' => $shortname,
+ 'value' => $vars['entity']->$shortname,
+ )); ?>
</label>
</p>
+
+<?php
+
+ }
+
+?>
+
<p>
<input type="submit" value="<?php echo elgg_echo("save"); ?>" />
</p>
diff --git a/mod/profile/views/default/user/user.php b/mod/profile/views/default/user/user.php index 2c64ac0df..d2411c3d9 100644 --- a/mod/profile/views/default/user/user.php +++ b/mod/profile/views/default/user/user.php @@ -28,46 +28,33 @@ <?php
}
-
+ if (is_array($vars['profile']) && sizeof($vars['profile']) > 0)
+ foreach($vars['profile'] as $shortname => $valtype) {
+ if ($shortname != "description") {
+ $value = $vars['entity']->$shortname;
+ if (!empty($value)) {
+
?>
- <p>
- <b><?php
-
- echo elgg_echo("profile:location");
-
- ?>: </b>
- <?php
- echo elgg_view('output/tags',array('tags' => $vars['entity']->location));
-
- ?>
- </p>
<p>
<b><?php
-
- echo elgg_echo("profile:skills");
-
- ?>: </b>
- <?php
- echo elgg_view('output/tags',array('tags' => $vars['entity']->skills));
-
- ?>
- </p>
- <p>
- <b><?php
-
- echo elgg_echo("profile:interests");
+ echo elgg_echo("profile:{$shortname}");
?>: </b>
<?php
- echo elgg_view('output/tags',array('tags' => $vars['entity']->interests));
+ echo elgg_view("output/{$valtype}",array('value' => $vars['entity']->$shortname));
?>
+
</p>
- <?php
+ <?php
+ }
+ }
+ }
+
if ($vars['entity']->canEdit()) {
?>
|