diff --git a/src/IDF/Form/UserAccount.php b/src/IDF/Form/UserAccount.php
new file mode 100644
index 0000000..dc2c49f
--- /dev/null
+++ b/src/IDF/Form/UserAccount.php
@@ -0,0 +1,136 @@
+user = $extra['user'];
+ $this->fields['first_name'] = new Pluf_Form_Field_Varchar(
+ array('required' => false,
+ 'label' => __('First name'),
+ 'initial' => $this->user->first_name,
+ 'widget_attrs' => array(
+ 'maxlength' => 50,
+ 'size' => 15,
+ ),
+ ));
+ $this->fields['last_name'] = new Pluf_Form_Field_Varchar(
+ array('required' => true,
+ 'label' => __('Last name'),
+ 'initial' => $this->user->last_name,
+ 'widget_attrs' => array(
+ 'maxlength' => 50,
+ 'size' => 20,
+ ),
+ ));
+ $this->fields['password'] = new Pluf_Form_Field_Varchar(
+ array('required' => false,
+ 'label' => __('Your password'),
+ 'initial' => '',
+ 'widget' => 'Pluf_Form_Widget_PasswordInput',
+ 'help_text' => Pluf_Template::markSafe(__('Leave blank if you do not want to change your password.').'
'.__('Your password must be hard for other people to find it, but easy for you to remember.')),
+ 'widget_attrs' => array(
+ 'maxlength' => 50,
+ 'size' => 15,
+ ),
+ ));
+ $this->fields['password2'] = new Pluf_Form_Field_Varchar(
+ array('required' => false,
+ 'label' => __('Confirm your password'),
+ 'initial' => '',
+ 'widget' => 'Pluf_Form_Widget_PasswordInput',
+ 'widget_attrs' => array(
+ 'maxlength' => 50,
+ 'size' => 15,
+ ),
+ ));
+
+
+ }
+
+
+ /**
+ * Save the model in the database.
+ *
+ * @param bool Commit in the database or not. If not, the object
+ * is returned but not saved in the database.
+ * @return Object Model with data set from the form.
+ */
+ function save($commit=true)
+ {
+ if (!$this->isValid()) {
+ throw new Exception(__('Cannot save the model from an invalid form.'));
+ }
+ unset($this->cleaned_data['password2']);
+ if (strlen($this->cleaned_data['password']) == 0) {
+ unset($this->cleaned_data['password']);
+ }
+ $this->user->setFromFormData($this->cleaned_data);
+ if ($commit) {
+ $this->user->update();
+ }
+ return $this->user;
+ }
+
+ function clean_last_name()
+ {
+ $last_name = trim($this->cleaned_data['last_name']);
+ if ($last_name == mb_strtoupper($last_name)) {
+ return mb_convert_case(mb_strtolower($last_name),
+ MB_CASE_TITLE, 'UTF-8');
+ }
+ return $last_name;
+ }
+
+ function clean_first_name()
+ {
+ $first_name = trim($this->cleaned_data['first_name']);
+ if ($first_name == mb_strtoupper($first_name)) {
+ return mb_convert_case(mb_strtolower($first_name),
+ MB_CASE_TITLE, 'UTF-8');
+ }
+ return $first_name;
+ }
+
+ /**
+ * Check to see if the 2 passwords are the same.
+ */
+ public function clean()
+ {
+ if (!isset($this->errors['password'])
+ && !isset($this->errors['password2'])) {
+ $password1 = $this->cleaned_data['password'];
+ $password2 = $this->cleaned_data['password2'];
+ if ($password1 != $password2) {
+ throw new Pluf_Form_Invalid(__('The passwords do not match. Please give them again.'));
+ }
+ }
+ return $this->cleaned_data;
+ }
+}
diff --git a/src/IDF/Views/User.php b/src/IDF/Views/User.php
new file mode 100644
index 0000000..c1e9e7b
--- /dev/null
+++ b/src/IDF/Views/User.php
@@ -0,0 +1,78 @@
+ $request->user);
+ if ($request->method == 'POST') {
+ $form = new IDF_Form_UserAccount($request->POST, $params);
+ if ($form->isValid()) {
+ $user = $form->save();
+ $url = Pluf_HTTP_URL_urlForView('IDF_Views::index');
+ $request->user->setMessage(__('Your personal information have been updated.'));
+ return new Pluf_HTTP_Response_Redirect($url);
+ }
+ } else {
+ $form = new IDF_Form_UserAccount($request->user->getData(), $params);
+ }
+ return Pluf_Shortcuts_RenderToResponse('user/myaccount.html',
+ array('page_title' => __('Your Account'),
+ 'form' => $form),
+ $request);
+ }
+
+ /**
+ * Public profile of a user.
+ */
+ public function view($request, $match)
+ {
+ $projects = Pluf::factory('IDF_Project')->getList();
+ $sql = new Pluf_SQL('login=%s', array($match[1]));
+ $users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen()));
+ if (count($users) != 1 or !$users[0]->active) {
+ throw new Pluf_HTTP_Error404();
+ }
+ return Pluf_Shortcuts_RenderToResponse('user/public.html',
+ array('page_title' => (string) $users[0],
+ 'member' => $users[0],
+ 'projects' => $projects,
+ ),
+ $request);
+ }
+
+}
\ No newline at end of file
diff --git a/src/IDF/conf/views.php b/src/IDF/conf/views.php
index 6fa1a85..4bb7e62 100644
--- a/src/IDF/conf/views.php
+++ b/src/IDF/conf/views.php
@@ -37,6 +37,18 @@ $ctl[] = array('regex' => '#^/login/$#',
'method' => 'login',
'name' => 'login_view');
+$ctl[] = array('regex' => '#^/preferences/$#',
+ 'base' => $base,
+ 'priority' => 4,
+ 'model' => 'IDF_Views_User',
+ 'method' => 'myAccount');
+
+$ctl[] = array('regex' => '#^/u/(.*)/$#',
+ 'base' => $base,
+ 'priority' => 4,
+ 'model' => 'IDF_Views_User',
+ 'method' => 'view');
+
$ctl[] = array('regex' => '#^/register/$#',
'base' => $base,
'priority' => 4,
diff --git a/src/IDF/templates/base-simple.html b/src/IDF/templates/base-simple.html
index 27d6962..729639a 100644
--- a/src/IDF/templates/base-simple.html
+++ b/src/IDF/templates/base-simple.html
@@ -34,7 +34,7 @@
-{if !$user.isAnonymous()}{blocktrans}Welcome, {$user.first_name} {$user.last_name}.{/blocktrans} {trans 'Sign Out'}{else}{trans 'Sign in or create your account'}{/if} +{if !$user.isAnonymous()}{aurl 'url', 'IDF_Views_User::myAccount'}{blocktrans}Welcome, {$user}.{/blocktrans} {trans 'Sign Out'}{else}{trans 'Sign in or create your account'}{/if} | {trans 'Help'}
{*-{if !$user.isAnonymous()}{blocktrans}Welcome, {$user.first_name} {$user.last_name}.{/blocktrans} {trans 'Sign Out'}{else}{trans 'Sign in or create your account'}{/if} +{if !$user.isAnonymous()}{aurl 'url', 'IDF_Views_User::myAccount'}{blocktrans}Welcome, {$user}.{/blocktrans} {trans 'Sign Out'}{else}{trans 'Sign in or create your account'}{/if} | {trans 'Help'}
{blocktrans}Reported by {$who}, {$c.creation_dtime|date}{/blocktrans}
-{else}{assign $who = $c.get_submitter()} +{blocktrans}Reported by {$who}, {$c.creation_dtime|date}{/blocktrans}
+{else} {aurl 'url', 'IDF_Views_Issue::view', array($project.shortname, $issue.id)} {assign $id = $c.id} {assign $url = $url~'#ic'~$c.id} -{blocktrans}Comment {$i} by {$who}, {$c.creation_dtime|date}{/blocktrans}
+{blocktrans}Comment {$i} by {$who}, {$c.creation_dtime|date}{/blocktrans}
{/if} @@ -91,15 +91,15 @@ {/block} {block context}{trans 'Created:'} {$issue.creation_dtime|dateago} {blocktrans}by {$submitter}{/blocktrans}
+{assign $submitter = $issue.get_submitter()}{aurl 'url', 'IDF_Views_User::view', array($submitter.login)} +{trans 'Created:'} {$issue.creation_dtime|dateago} {blocktrans}by {$submitter}{/blocktrans}
{if $issue.modif_dtime != $issue.creation_dtime}{trans 'Updated:'} {$issue.modif_dtime|dateago}
{/if}{trans 'Status:'} {$issue.get_status.name}
--{trans 'Owner:'} {if $issue.get_owner == null}{trans 'No owner'}{else}{$issue.get_owner}{/if} -
{assign $tags = $issue.get_tags_list()}{if $tags.count()} +{if $issue.get_owner != null}{aurl 'url', 'IDF_Views_User::view', array($issue.get_owner().login)} +{trans 'Owner:'} {$issue.get_owner} +
{/if}{assign $tags = $issue.get_tags_list()}{if $tags.count()}{trans 'Labels:'}
{foreach $tags as $tag}{aurl 'url', 'IDF_Views_Issue::listLabel', array($project.shortname, $tag.id, 'open')} diff --git a/src/IDF/templates/project-home.html b/src/IDF/templates/project-home.html index 8bfe128..ee2b80a 100644 --- a/src/IDF/templates/project-home.html +++ b/src/IDF/templates/project-home.html @@ -21,13 +21,13 @@ {assign $km = 'members'}
{trans 'Development Team'}
diff --git a/src/IDF/templates/user/myaccount.html b/src/IDF/templates/user/myaccount.html new file mode 100644 index 0000000..32dc86c --- /dev/null +++ b/src/IDF/templates/user/myaccount.html @@ -0,0 +1,59 @@ +{extends "base-simple.html"} +{block body} +{if $form.errors} + +{/if} + + +{/block} +{block context} +{trans 'Admins'}
-{foreach $team[$ko] as $owner} -{$owner}
+{foreach $team[$ko] as $owner}{aurl 'url', 'IDF_Views_User::view', array($owner.login)} +{$owner}
{/foreach} {if count($team[$km]) > 0} {trans 'Happy Crew'}
-{foreach $team[$km] as $member} -{$member}
+{foreach $team[$km] as $member}{aurl 'url', 'IDF_Views_User::view', array($member.login)} +{$member}
{/foreach} {/if}
{trans 'If possible, use your real name. By using your real name, people will have more trust in your comments and remarks.'}
+{blocktrans}You are looking at the public profile of {$member}.{/blocktrans}
+{trans 'Projects'}
+{foreach $projects as $p} +- {$p}
+{/foreach}
+{/block} + + diff --git a/www/media/idf/css/style.css b/www/media/idf/css/style.css index 8b9e3a0..3b39a4f 100644 --- a/www/media/idf/css/style.css +++ b/www/media/idf/css/style.css @@ -37,6 +37,10 @@ color: #a00; } +a.userw { + color: #000; +} + .mono { font-family: monospace; }