Indefero

Indefero Commit Details


Date:2010-12-04 18:22:32 (14 years 17 days ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:784c9718eba0b4844a7b8bba587e295cf3e15032
Parents: 874b5aa7e9c4eeef72c8ae8e89e0f564c0999f57
Message:Implemented an extended user profile based on a patch from Jethro Carr (issue 510).

Changes with respect to the original patch:
- use Gconf instead of separate table / data scheme
- better form validation for URLs and emails
- no htmlentity-encoded contents in the database (pluf automatically safe-encodes
stuff before it writes out contents into templates)
- add visual separators in the form views to have a distinct view of basic
(important) data and other data which are only displayed in the public profile
- give a hint about the maximum display size of 60x60 px^2 and use max-width and
max-height in the templates to avoid nasty distortions by the browser
- use target=_blank and rel=nofollow on the twitter and website links in the profile
- some whitespace / formatting / code style fixes
Changes:

File differences

src/IDF/Form/Admin/UserUpdate.php
2424
2525
2626
27
27
2828
2929
3030
3131
3232
3333
34
35
3436
3537
3638
......
6668
6769
6870
69
71
7072
7173
7274
......
9395
9496
9597
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
96158
97159
98160
......
136198
137199
138200
201
139202
140203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
141232
142233
143234
......
170261
171262
172263
173
264
174265
175266
176267
......
183274
184275
185276
186
277
187278
188279
189280
......
201292
202293
203294
295
296
297
298
299
300
301
302
303
304
305
204306
205
307
206308
207309
208310
209
311
210312
211313
212314
/**
* Update user's details.
*/
class IDF_Form_Admin_UserUpdate extends Pluf_Form
class IDF_Form_Admin_UserUpdate extends Pluf_Form
{
public $user = null;
public function initFields($extra=array())
{
$this->user = $extra['user'];
$user_data = IDF_UserData::factory($this->user);
$this->fields['first_name'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('First name'),
'initial' => $this->user->language,
'widget' => 'Pluf_Form_Widget_SelectInput',
'widget_attrs' => array(
'choices' =>
'choices' =>
Pluf_L10n::getInstalledLanguages()
),
));
),
));
$this->fields['description'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Description'),
'initial' => $user_data->description,
'widget_attrs' => array('rows' => 3,
'cols' => 40),
'widget' => 'Pluf_Form_Widget_TextareaInput',
));
$this->fields['twitter'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Twitter username'),
'initial' => $user_data->twitter,
'widget_attrs' => array(
'maxlength' => 50,
'size' => 15,
),
));
$this->fields['public_email'] = new Pluf_Form_Field_Email(
array('required' => false,
'label' => __('Public email address'),
'initial' => $user_data->public_email,
'widget_attrs' => array(
'maxlength' => 50,
'size' => 15,
),
));
$this->fields['website'] = new Pluf_Form_Field_Url(
array('required' => false,
'label' => __('Website URL'),
'initial' => $user_data->website,
'widget_attrs' => array(
'maxlength' => 50,
'size' => 15,
),
));
$this->fields['custom_avatar'] = new Pluf_Form_Field_File(
array('required' => false,
'label' => __('Upload custom avatar'),
'initial' => '',
'max_size' => Pluf::f('max_upload_size', 2097152),
'move_function_params' => array('upload_path' => Pluf::f('upload_path').'/avatars',
'upload_path_create' => true,
'upload_overwrite' => true,
'file_name' => 'user_'.$this->user->id.'_%s'),
'help_text' => __('An image file with a width and height not larger than 60 pixels (bigger images are scaled down).'),
));
$this->fields['remove_custom_avatar'] = new Pluf_Form_Field_Boolean(
array('required' => false,
'label' => __('Remove custom avatar'),
'initial' => false,
'widget' => 'Pluf_Form_Widget_CheckboxInput',
'widget_attrs' => array(),
'help_text' => __('Tick this to delete the custom avatar.'),
));
if ($extra['request']->user->administrator) {
$this->fields['staff'] = new Pluf_Form_Field_Boolean(
array('required' => false,
$update_pass = true;
}
$this->user->setFromFormData($this->cleaned_data);
if ($commit) {
$this->user->update();
// FIXME: go the extra mile and check the input lengths for
// all fields here!
// FIXME: this is all doubled in UserAccount!
$user_data = IDF_UserData::factory($this->user);
// Add or remove avatar - we need to do this here because every
// single setter directly leads to a save in the database
if ($user_data->avatar != '' &&
($this->cleaned_data['remove_custom_avatar'] == 1 ||
$this->cleaned_data['custom_avatar'] != '')) {
$avatar_path = Pluf::f('upload_path').'/avatars/'.basename($user_data->avatar);
if (basename($avatar_path) != '' && is_file($avatar_path)) {
unlink($avatar_path);
}
$user_data->avatar = '';
}
if ($this->cleaned_data['custom_avatar'] != '') {
$user_data->avatar = $this->cleaned_data['custom_avatar'];
}
$user_data->description = $this->cleaned_data['description'];
$user_data->twitter = $this->cleaned_data['twitter'];
$user_data->public_email = $this->cleaned_data['public_email'];
$user_data->website = $this->cleaned_data['website'];
if ($update_pass) {
/**
* [signal]
{
$last_name = trim($this->cleaned_data['last_name']);
if ($last_name == mb_strtoupper($last_name)) {
return mb_convert_case(mb_strtolower($last_name),
return mb_convert_case(mb_strtolower($last_name),
MB_CASE_TITLE, 'UTF-8');
}
return $last_name;
throw new Pluf_Form_Invalid(__('--- is not a valid first name.'));
}
if ($first_name == mb_strtoupper($first_name)) {
$first_name = mb_convert_case(mb_strtolower($first_name),
$first_name = mb_convert_case(mb_strtolower($first_name),
MB_CASE_TITLE, 'UTF-8');
}
return $first_name;
return $email;
}
function clean_custom_avatar()
{
// Just png, jpeg/jpg or gif
if (!preg_match('/\.(png|jpg|jpeg|gif)$/i', $this->cleaned_data['custom_avatar']) &&
$this->cleaned_data['custom_avatar'] != '') {
@unlink(Pluf::f('upload_path').'/avatars/'.$this->cleaned_data['custom_avatar']);
throw new Pluf_Form_Invalid(__('For security reason, you cannot upload a file with this extension.'));
}
return $this->cleaned_data['custom_avatar'];
}
/**
* Check to see if the 2 passwords are the same.
* Check to see if the two passwords are the same.
*/
public function clean()
{
if (!isset($this->errors['password'])
if (!isset($this->errors['password'])
&& !isset($this->errors['password2'])) {
$password1 = $this->cleaned_data['password'];
$password2 = $this->cleaned_data['password2'];
src/IDF/Form/UserAccount.php
3333
3434
3535
36
37
3638
3739
3840
......
9294
9395
9496
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
95157
96158
97159
......
138200
139201
140202
141
203
142204
143205
144206
......
157219
158220
159221
222
160223
161224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
162253
163254
164255
......
266357
267358
268359
360
361
362
363
364
365
366
367
368
369
370
371
372
269373
270374
271375
......
322426
323427
324428
429
430
325431
public function initFields($extra=array())
{
$this->user = $extra['user'];
$user_data = IDF_UserData::factory($this->user);
$this->fields['first_name'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('First name'),
),
));
$this->fields['description'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Description'),
'initial' => $user_data->description,
'widget_attrs' => array('rows' => 3,
'cols' => 40),
'widget' => 'Pluf_Form_Widget_TextareaInput',
));
$this->fields['twitter'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Twitter username'),
'initial' => $user_data->twitter,
'widget_attrs' => array(
'maxlength' => 50,
'size' => 15,
),
));
$this->fields['public_email'] = new Pluf_Form_Field_Email(
array('required' => false,
'label' => __('Public email address'),
'initial' => $user_data->public_email,
'widget_attrs' => array(
'maxlength' => 50,
'size' => 15,
),
));
$this->fields['website'] = new Pluf_Form_Field_Url(
array('required' => false,
'label' => __('Website URL'),
'initial' => $user_data->website,
'widget_attrs' => array(
'maxlength' => 50,
'size' => 15,
),
));
$this->fields['custom_avatar'] = new Pluf_Form_Field_File(
array('required' => false,
'label' => __('Upload custom avatar'),
'initial' => '',
'max_size' => Pluf::f('max_upload_size', 2097152),
'move_function_params' => array('upload_path' => Pluf::f('upload_path').'/avatars',
'upload_path_create' => true,
'upload_overwrite' => true,
'file_name' => 'user_'.$this->user->id.'_%s'),
'help_text' => __('An image file with a width and height not larger than 60 pixels (bigger images are scaled down).'),
));
$this->fields['remove_custom_avatar'] = new Pluf_Form_Field_Boolean(
array('required' => false,
'label' => __('Remove custom avatar'),
'initial' => false,
'widget' => 'Pluf_Form_Widget_CheckboxInput',
'widget_attrs' => array(),
'help_text' => __('Tick this to delete the custom avatar.'),
));
$this->fields['public_key'] = new Pluf_Form_Field_Varchar(
array('required' => false,
'label' => __('Add a public key'),
'email' => $new_email,
'user'=> $this->user,
)
);
);
$tmpl = new Pluf_Template('idf/user/changeemail-email.txt');
$text_email = $tmpl->render($context);
$email = new Pluf_Mail(Pluf::f('from_email'), $new_email,
$key->create();
}
}
if ($commit) {
$this->user->update();
// FIXME: go the extra mile and check the input lengths for
// all fields here!
// FIXME: this is all doubled in admin/UserUpdate!
$user_data = IDF_UserData::factory($this->user);
// Add or remove avatar - we need to do this here because every
// single setter directly leads to a save in the database
if ($user_data->avatar != '' &&
($this->cleaned_data['remove_custom_avatar'] == 1 ||
$this->cleaned_data['custom_avatar'] != '')) {
$avatar_path = Pluf::f('upload_path').'/avatars/'.basename($user_data->avatar);
if (basename($avatar_path) != '' && is_file($avatar_path)) {
unlink($avatar_path);
}
$user_data->avatar = '';
}
if ($this->cleaned_data['custom_avatar'] != '') {
$user_data->avatar = $this->cleaned_data['custom_avatar'];
}
$user_data->description = $this->cleaned_data['description'];
$user_data->twitter = $this->cleaned_data['twitter'];
$user_data->public_email = $this->cleaned_data['public_email'];
$user_data->website = $this->cleaned_data['website'];
if ($update_pass) {
/**
* [signal]
return $key;
}
function clean_custom_avatar()
{
// Just png, jpeg/jpg or gif
if (!preg_match('/\.(png|jpg|jpeg|gif)$/i', $this->cleaned_data['custom_avatar']) &&
$this->cleaned_data['custom_avatar'] != '') {
@unlink(Pluf::f('upload_path').'/avatars/'.$this->cleaned_data['custom_avatar']);
throw new Pluf_Form_Invalid(__('For security reason, you cannot upload a file with this extension.'));
}
return $this->cleaned_data['custom_avatar'];
}
function clean_last_name()
{
$last_name = trim($this->cleaned_data['last_name']);
return $this->cleaned_data;
}
}
src/IDF/Gconf.php
4646
4747
4848
49
49
5050
5151
5252
......
108108
109109
110110
111
111
112112
113113
114114
......
121121
122122
123123
124
124
125125
126126
127127
array(
'type' => 'Pluf_DB_Field_Sequence',
//It is automatically added.
'blank' => true,
'blank' => true,
),
'model_class' =>
array(
*/
function setVal($key, $value)
{
if (!is_null($this->getVal($key, null))
if (!is_null($this->getVal($key, null))
and $value == $this->getVal($key)) {
return;
}
$this->datacache[$key] = $value;
return;
}
}
}
// we insert
$conf = new IDF_Gconf();
$conf->model_class = $this->_mod->_model;
src/IDF/IssueComment.php
4141
4242
4343
44
44
4545
46
46
4747
4848
4949
......
5757
5858
5959
60
60
6161
6262
6363
......
7979
8080
8181
82
82
8383
8484
8585
......
119119
120120
121121
122
122
123123
124124
125125
......
129129
130130
131131
132
132
133133
134134
135135
......
168168
169169
170170
171
171
172172
173173
174174
......
176176
177177
178178
179
179
180180
181181
182182
......
196196
197197
198198
199
200
201
202
203
199204
'id' =>
array(
'type' => 'Pluf_DB_Field_Sequence',
'blank' => true,
'blank' => true,
),
'issue' =>
'issue' =>
array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'IDF_Issue',
'blank' => false,
'verbose' => __('comment'),
),
'submitter' =>
'submitter' =>
array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'Pluf_User',
'verbose' => __('creation date'),
),
);
$this->_a['idx'] = array(
$this->_a['idx'] = array(
'creation_dtime_idx' =>
array(
'col' => 'creation_dtime',
$sql = new Pluf_SQL('issue=%s', array($this->issue));
$co = Pluf::factory('IDF_IssueComment')->getList(array('filter'=>$sql->gen()));
if ($co->count() > 1) {
IDF_Timeline::insert($this, $this->get_issue()->get_project(),
IDF_Timeline::insert($this, $this->get_issue()->get_project(),
$this->get_submitter());
}
}
public function timelineFragment($request)
{
$issue = $this->get_issue();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($request->project->shortname,
$issue->id));
$url .= '#ic'.$this->id;
}
$out .= '</td></tr>';
$out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Comment on <a href="%s" class="%s">issue&nbsp;%d</a>, by %s'), $url, $ic, $issue->id, $user).'</div></td></tr>';
<div class="helptext right">'.sprintf(__('Comment on <a href="%s" class="%s">issue&nbsp;%d</a>, by %s'), $url, $ic, $issue->id, $user).'</div></td></tr>';
return Pluf_Template::markSafe($out);
}
{
$issue = $this->get_issue();
$url = Pluf::f('url_base')
.Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
.Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($request->project->shortname,
$issue->id));
$title = sprintf(__('%s: Comment on issue %d - %s'),
$tmpl = new Pluf_Template('idf/issues/feedfragment.xml');
return $tmpl->render($context);
}
public function get_submitter_data()
{
return IDF_UserData::factory($this->get_submitter());
}
}
src/IDF/Review/Comment.php
2525
2626
2727
28
28
2929
3030
3131
3232
33
33
3434
3535
3636
......
4545
4646
4747
48
48
4949
50
50
5151
5252
5353
......
6161
6262
6363
64
64
6565
6666
6767
......
118118
119119
120120
121
122
121
122
123123
124124
125125
......
127127
128128
129129
130
130
131131
132132
133133
......
138138
139139
140140
141
141
142142
143143
144144
145145
146146
147147
148
148
149149
150150
151151
......
221221
222222
223223
224
225
226
227
228
224229
* A comment set on a review.
*
* A comment is associated to a patch as a review can have many
* patches associated to it.
* patches associated to it.
*
* A comment is also tracking the changes in the review in the same
* way the issue comment is tracking the changes in the issue.
*
*
*
*/
class IDF_Review_Comment extends Pluf_Model
{
'id' =>
array(
'type' => 'Pluf_DB_Field_Sequence',
'blank' => true,
'blank' => true,
),
'patch' =>
'patch' =>
array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'IDF_Review_Patch',
'blank' => true, // if only commented on lines
'verbose' => __('comment'),
),
'submitter' =>
'submitter' =>
array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'Pluf_User',
function postSave($create=false)
{
if ($create) {
IDF_Timeline::insert($this,
$this->get_patch()->get_review()->get_project(),
IDF_Timeline::insert($this,
$this->get_patch()->get_review()->get_project(),
$this->get_submitter());
}
}
public function timelineFragment($request)
{
$review = $this->get_patch()->get_review();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
array($request->project->shortname,
$review->id));
$out = '<tr class="log"><td><a href="'.$url.'">'.
$ic = (in_array($review->status, $request->project->getTagIdsByStatus('closed'))) ? 'issue-c' : 'issue-o';
$out .= sprintf(__('<a href="%1$s" class="%2$s" title="View review">Review %3$d</a>, %4$s'), $url, $ic, $review->id, Pluf_esc($review->summary)).'</td>';
$out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Update of <a href="%s" class="%s">review&nbsp;%d</a>, by %s'), $url, $ic, $review->id, $user).'</div></td></tr>';
<div class="helptext right">'.sprintf(__('Update of <a href="%s" class="%s">review&nbsp;%d</a>, by %s'), $url, $ic, $review->id, $user).'</div></td></tr>';
return Pluf_Template::markSafe($out);
}
public function feedFragment($request)
{
$review = $this->get_patch()->get_review();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
array($request->project->shortname,
$review->id));
$title = sprintf(__('%s: Updated review %d - %s'),
}
Pluf_Translation::loadSetLocale($current_locale);
}
public function get_submitter_data()
{
return IDF_UserData::factory($this->get_submitter());
}
}
src/IDF/UserData.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008 Céondo Ltd and contributors.
#
# InDefero 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.
#
# InDefero 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
#
# ***** END LICENSE BLOCK ***** */
/**
* Thin wrapper around the general purpose Gconf data driver
* to model a userdata object as key value store
*/
class IDF_UserData extends IDF_Gconf
{
/** columns for the underlying model for which we do not want to
override __get and __set */
private static $protectedVars =
array('id', 'model_class', 'model_id', 'vkey', 'vdesc');
function __set($key, $value)
{
if (in_array($key, self::$protectedVars))
{
parent::__set($key, $value);
return;
}
$this->setVal($key, $value);
}
function __get($key)
{
if (in_array($key, self::$protectedVars))
return parent::__get($key);
return $this->getVal($key, null);
}
public static function factory($user)
{
$conf = new IDF_UserData();
$conf->setModel((object) array('_model'=>'IDF_UserData', 'id' => $user->id));
$conf->initCache();
return $conf;
}
}
src/IDF/Views.php
8686
8787
8888
89
89
90
91
92
9093
9194
9295
$title = __('Create Your Account');
$params = array('request'=>$request);
if ($request->method == 'POST') {
$form = new IDF_Form_Register($request->POST, $params);
$form = new IDF_Form_Register(array_merge(
(array)$request->POST,
(array)$request->FILES
), $params);
if ($form->isValid()) {
$user = $form->save(); // It is sending the confirmation email
$url = Pluf_HTTP_URL_urlForView('IDF_Views::registerInputKey');
src/IDF/Views/Admin.php
268268
269269
270270
271
271
272
273
272274
273275
274276
......
299301
300302
301303
302
304
305
306
303307
304308
305309
}
if ($request->method == 'POST') {
$form = new IDF_Form_Admin_UserUpdate($request->POST, $params);
$form = new IDF_Form_Admin_UserUpdate(array_merge($request->POST,
$request->FILES),
$params);
if ($form->isValid()) {
$form->save();
$request->user->setMessage(__('The user has been updated.'));
'request' => $request,
);
if ($request->method == 'POST') {
$form = new IDF_Form_Admin_UserCreate($request->POST, $params);
$form = new IDF_Form_Admin_UserCreate(array_merge($request->POST,
$request->FILES),
$params);
if ($form->isValid()) {
$cuser = $form->save();
$request->user->setMessage(sprintf(__('The user %s has been created.'), (string) $cuser));
src/IDF/Views/Issue.php
279279
280280
281281
282
282283
283284
284285
......
290291
291292
292293
293
294
294295
295296
296297
$form = new IDF_Form_IssueUpdate(null, $params);
}
}
$arrays = self::autoCompleteArrays($prj);
return Pluf_Shortcuts_RenderToResponse('idf/issues/view.html',
array_merge(
'page_title' => $title,
'closed' => $closed,
'preview' => $preview,
'interested' =>$interested->count(),
'interested' => $interested->count(),
),
$arrays),
$request);
src/IDF/Views/Review.php
8989
9090
9191
92
92
9393
9494
95
95
9696
9797
9898
......
155155
156156
157157
158
158
159159
160160
161
161
162162
163163
164164
......
181181
182182
183183
184
184
185185
186186
187187
......
192192
193193
194194
195
195196
196197
197198
......
219220
220221
221222
222
223
223224
224225
225226
));
if ($form->isValid()) {
$review = $form->save();
$urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
$urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
array($prj->shortname, $review->id));
$request->user->setMessage(sprintf(__('The <a href="%s">code review %d</a> has been created.'), $urlr, $review->id));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index',
array($prj->shortname));
return new Pluf_HTTP_Response_Redirect($url);
}
if ($form->isValid()) {
$review_comment = $form->save();
$review = $patch->get_review();
$urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
$urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
array($prj->shortname, $review->id));
$request->user->setMessage(sprintf(__('Your <a href="%s">code review %d</a> has been published.'), $urlr, $review->id));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index',
array($prj->shortname));
$review_comment->notify($request->conf);
return new Pluf_HTTP_Response_Redirect($url);
foreach ($cts as $ct) {
$reviewers[] = $ct->get_comment()->get_submitter();
}
if (count($def['chunks'])) {
if (count($def['chunks'])) {
$orig_file = ($fileinfo) ? $scm->getFile($fileinfo) : '';
$files[$filename] = array(
$diff->fileCompare($orig_file, $def, $filename),
$files[$filename] = array('', $form->f->{md5($filename)}, $cts);
}
}
$reviewers = Pluf_Model_RemoveDuplicates($reviewers);
return Pluf_Shortcuts_RenderToResponse('idf/review/view.html',
array_merge(
*/
function IDF_Views_Review_SummaryAndLabels($field, $review, $extra='')
{
$edit = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
$edit = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view',
array($review->shortname, $review->id));
$tags = array();
foreach ($review->get_tags_list() as $tag) {
src/IDF/Views/User.php
3333
3434
3535
36
36
3737
3838
3939
4040
4141
42
42
4343
4444
4545
......
110110
111111
112112
113
113
114
115
116
114117
115118
116119
......
121124
122125
123126
124
127
125128
126129
127
130
131
128132
129133
130134
......
170174
171175
172176
173
177
174178
175179
176180
177
181
178182
179183
180184
......
208212
209213
210214
211
215
212216
213217
214218
215
216
217
219
220
221
222
223
224
225
218226
219227
220228
......
230238
231239
232240
233
241
234242
235243
236244
237
245
238246
239247
240248
class IDF_Views_User
{
/**
* Dashboard of a user.
* Dashboard of a user.
*
* Shows all the open issues assigned to the user.
*
* TODO: This views is a SQL horror. What needs to be done to cut
* by many the number of SQL queries:
* - Add a table to cache the open/closed status ids for all the
* - Add a table to cache the open/closed status ids for all the
* projects.
* - Left join the issues with the project to get the shortname.
*
$ext_pass = substr(sha1($request->user->password.Pluf::f('secret_key')), 0, 8);
$params = array('user' => $request->user);
if ($request->method == 'POST') {
$form = new IDF_Form_UserAccount($request->POST, $params);
$form = new IDF_Form_UserAccount(array_merge(
(array)$request->POST,
(array)$request->FILES
), $params);
if ($form->isValid()) {
$user = $form->save();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_User::myAccount');
} else {
$data = $request->user->getData();
unset($data['password']);
$form = new IDF_Form_UserAccount($data, $params);
$form = new IDF_Form_UserAccount(null, $params);
}
$keys = $request->user->get_idf_key_list();
return Pluf_Shortcuts_RenderToResponse('idf/user/myaccount.html',
return Pluf_Shortcuts_RenderToResponse('idf/user/myaccount.html',
array('page_title' => __('Your Account'),
'api_key' => $api_key,
'ext_pass' => $ext_pass,
} else {
$form = new IDF_Form_UserChangeEmail();
}
return Pluf_Shortcuts_RenderToResponse('idf/user/changeemail.html',
return Pluf_Shortcuts_RenderToResponse('idf/user/changeemail.html',
array('page_title' => __('Confirm The Email Change'),
'form' => $form),
$request);
}
/**
public function view($request, $match)
{
$sql = new Pluf_SQL('login=%s', array($match[1]));
$users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen()));
$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('idf/user/public.html',
array('page_title' => (string) $users[0],
'member' => $users[0],
$user = $users[0];
$user_data = IDF_UserData::factory($user);
return Pluf_Shortcuts_RenderToResponse('idf/user/public.html',
array('page_title' => (string) $user,
'member' => $user,
'user_data' => $user_data,
),
$request);
}
function IDF_Views_IssueSummaryAndLabels($field, $issue, $extra='')
{
$project = $issue->get_project();
$edit = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
$edit = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($project->shortname, $issue->id));
$tags = array();
foreach ($issue->get_tags_list() as $tag) {
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::listLabel',
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::listLabel',
array($project->shortname, $tag->id, 'open'));
$tags[] = sprintf('<a class="label" href="%s">%s</a>', $url, Pluf_esc((string) $tag));
}
src/IDF/relations.php
4343
4444
4545
46
47
4648
4749
4850
$m['IDF_Commit'] = array('relate_to' => array('IDF_Project', 'Pluf_User'));
$m['IDF_Scm_Cache_Git'] = array('relate_to' => array('IDF_Project'));
$m['IDF_UserData'] = array('relate_to' => array('Pluf_User'));
Pluf_Signal::connect('Pluf_Template_Compiler::construct_template_tags_modifiers',
array('IDF_Middleware', 'updateTemplateTagsModifiers'));
src/IDF/templates/idf/gadmin/users/update.html
99
1010
1111
12
12
1313
1414
1515
......
5151
5252
5353
54
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
5596
5697
5798
......
69110
70111
71112
72
113
73114
74115
75116
{/if}
</div>
{/if}
<form method="post" action=".">
<form method="post" enctype="multipart/form-data" action=".">
<table class="form" summary="">
<tr>
<th>{trans 'Login:'}</th>{aurl 'url', 'IDF_Views_User::view', array($cuser.login)}
<td>{if $form.f.password2.errors}{$form.f.password2.fieldErrors}{/if}
{$form.f.password2|unsafe}
</td>
</tr>{if $user.administrator}
</tr>
<tr><td colspan="2" class="separator">{trans "Public Profile"}</td></tr>
<tr>
<th>{$form.f.description.labelTag}:</th>
<td>{if $form.f.description.errors}{$form.f.description.fieldErrors}{/if}
{$form.f.description|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.twitter.labelTag}:</th>
<td>{if $form.f.twitter.errors}{$form.f.twitter.fieldErrors}{/if}
{$form.f.twitter|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.public_email.labelTag}:</th>
<td>{if $form.f.public_email.errors}{$form.f.public_email.fieldErrors}{/if}
{$form.f.public_email|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.website.labelTag}:</th>
<td>{if $form.f.website.errors}{$form.f.website.fieldErrors}{/if}
{$form.f.website|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.custom_avatar.labelTag}:</th>
<td>{if $form.f.custom_avatar.errors}{$form.f.custom_avatar.fieldErrors}{/if}
{$form.f.custom_avatar|unsafe}<br />
<span class="helptext">{$form.f.custom_avatar.help_text}</span>
</td>
</tr>
<tr>
<th>{if $form.f.remove_custom_avatar.errors}{$form.f.remove_custom_avatar.fieldErrors}{/if}
{$form.f.remove_custom_avatar|unsafe}
</th>
<td>{$form.f.remove_custom_avatar.labelTag}<br />
<span class="helptext">{$form.f.remove_custom_avatar.help_text}</span></td>
</tr>
{if $user.administrator}
<tr><td colspan="2" class="separator">{trans "Administrative"}</td></tr>
<tr>
<th>{if $form.f.staff.errors}{$form.f.staff.fieldErrors}{/if}
{$form.f.staff|unsafe}
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value="{trans 'Update User'}" name="submit" />
<input type="submit" value="{trans 'Update User'}" name="submit" />
| <a href="{url 'IDF_Views_Admin::users'}">{trans 'Cancel'}</a>
</td>
</tr>
src/IDF/templates/idf/issues/view.html
33
44
55
6
7
6
7
8
9
10
11
12
13
14
815
916
1017
{block body}
{assign $i = 0}
{assign $nc = $comments.count()}
{foreach $comments as $c}{ashowuser 'submitter', $c.get_submitter(), $request}{assign $who = $c.get_submitter()}
<div class="issue-comment{if $i == 0} issue-comment-first{/if}{if $i == ($nc-1)} issue-comment-last{/if}" id="ic{$c.id}"><img style="float:right; position: relative;" src="http://www.gravatar.com/avatar/{$who.email|md5}.jpg?s=60&amp;d={media}/idf/img/spacer.gif" alt=" " />
{foreach $comments as $c}{ashowuser 'submitter', $c.get_submitter(), $request}
{assign $submitter = $c.get_submitter()}
{assign $submitter_data = $c.get_submitter_data()}
<div class="issue-comment{if $i == 0} issue-comment-first{/if}{if $i == ($nc-1)} issue-comment-last{/if}" id="ic{$c.id}">
{if $submitter_data.avatar != ''}
<img style="float:right; position: relative; max-height: 60px; max-width: 60px;" src="{media}/upload/avatars/{$submitter_data.avatar}" alt=" " />
{else}
<img style="float:right; position: relative; max-height: 60px; max-width: 60px;" src="http://www.gravatar.com/avatar/{$submitter.email|md5}.jpg?s=60&amp;d={media}/idf/img/spacer.gif" alt=" " />
{/if}
{if $i == 0}
<p>{blocktrans}Reported by {$submitter}, {$c.creation_dtime|date}{/blocktrans}</p>
{else}
src/IDF/templates/idf/review/view.html
7979
8080
8181
82
82
8383
84
84
8585
8686
8787
......
101101
102102
103103
104
105
104
105
106106
107107
108108
109
110
109
110
111
112
113
114
115
111116
112117
113118
......
118123
119124
120125
121
126
122127
123128
124129
125
130
126131
127132
128133
</tbody>
</table>
{assign $fcomments = $def[2]}
{assign $nc = $fcomments.count()}
{assign $nc = $fcomments.count()}
{assign $i = 1}
{foreach $fcomments as $c}
{foreach $fcomments as $c}
<div class="issue-comment{if $i == 1} issue-comment-first{/if}{if $i == $nc} issue-comment-last{/if}" id="ic{$c.id}">{assign $who = $c.get_comment().get_submitter()}{aurl 'whourl', 'IDF_Views_User::view', array($who.login)}
{aurl 'url', 'IDF_Views_Review::view', array($project.shortname, $review.id)}
{assign $id = $c.id}
</tr></table>{/if}
{/foreach}
{assign $i = 1}
{assign $nc = $comments.count()}
{assign $i = 1}
{assign $nc = $comments.count()}
{if $nc}<hr align="left" class="attach" />
<h2>{trans 'General Comments'}</h2>
{/if}
{foreach $comments as $c}{ashowuser 'submitter', $c.get_submitter(), $request}{assign $who = $c.get_submitter()}
<div class="issue-comment{if $i == 1} issue-comment-first{/if}{if $i == ($nc)} issue-comment-last{/if}" id="ic{$c.id}"><img style="float:right; position: relative;" src="http://www.gravatar.com/avatar/{$who.email|md5}.jpg?s=60&amp;d={media}/idf/img/spacer.gif" alt=" " />
{foreach $comments as $c}{ashowuser 'submitter', $c.get_submitter(), $request}{assign $submitter = $c.get_submitter()}{assign $submitter_data = $c.get_submitter_data()}
<div class="issue-comment{if $i == 1} issue-comment-first{/if}{if $i == ($nc)} issue-comment-last{/if}" id="ic{$c.id}">
{if $submitter_data.avatar != ''}
<img style="float:right; position: relative; max-height: 60px; max-width: 60px;" src="{media}/upload/avatars/{$submitter_data.avatar}" alt=" " />
{else}
<img style="float:right; position: relative;" src="http://www.gravatar.com/avatar/{$submitter.email|md5}.jpg?s=60&amp;d={media}/idf/img/spacer.gif" alt=" " />
{/if}
{aurl 'url', 'IDF_Views_Review::view', array($project.shortname, $review.id)}
{assign $id = $c.id}
{assign $url = $url~'#ic'~$c.id}
{if strlen($c.content) > 0}<pre class="issue-comment-text">{issuetext $c.content, $request}</pre>{/if}
{if $c.changedReview()}
<div class="issue-changes">
<div class="issue-changes">
{foreach $c.changes as $w => $v}
<strong>{if $w == 'su'}{trans 'Summary:'}{/if}{if $w == 'st'}{trans 'Status:'}{/if}</strong> {$v}<br />
{/foreach}
</div>
</div>
{/if}
</div>{assign $i = $i + 1}{if $i == $nc+1 and $user.isAnonymous()}
<div class="issue-comment-signin">
src/IDF/templates/idf/user/myaccount.html
99
1010
1111
12
12
1313
1414
1515
......
5353
5454
5555
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
5696
5797
5898
</div>
{/if}
<form method="post" action=".">
<form method="post" enctype="multipart/form-data" action=".">
<table class="form" summary="">
<tr>
<th>{trans 'Login:'}</th>{aurl 'url', 'IDF_Views_User::view', array($user.login)}
{$form.f.password2|unsafe}
</td>
</tr>
<tr><td colspan="2" class="separator">{trans "Public Profile"}</td></tr>
<tr>
<th>{$form.f.description.labelTag}:</th>
<td>{if $form.f.description.errors}{$form.f.description.fieldErrors}{/if}
{$form.f.description|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.twitter.labelTag}:</th>
<td>{if $form.f.twitter.errors}{$form.f.twitter.fieldErrors}{/if}
{$form.f.twitter|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.public_email.labelTag}:</th>
<td>{if $form.f.public_email.errors}{$form.f.public_email.fieldErrors}{/if}
{$form.f.public_email|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.website.labelTag}:</th>
<td>{if $form.f.website.errors}{$form.f.website.fieldErrors}{/if}
{$form.f.website|unsafe}
</td>
</tr>
<tr>
<th>{$form.f.custom_avatar.labelTag}:</th>
<td>{if $form.f.custom_avatar.errors}{$form.f.custom_avatar.fieldErrors}{/if}
{$form.f.custom_avatar|unsafe}<br />
<span class="helptext">{$form.f.custom_avatar.help_text}</span>
</td>
</tr>
<tr>
<th>{if $form.f.remove_custom_avatar.errors}{$form.f.remove_custom_avatar.fieldErrors}{/if}
{$form.f.remove_custom_avatar|unsafe}
</th>
<td>{$form.f.remove_custom_avatar.labelTag}<br />
<span class="helptext">{$form.f.remove_custom_avatar.help_text}</span></td>
</tr>
<tr><td colspan="2" class="separator">{trans "Key Management"}</td></tr>
<tr>
<th>{$form.f.public_key.labelTag}:</th>
<td>{if $form.f.public_key.errors}{$form.f.public_key.fieldErrors}{/if}
src/IDF/templates/idf/user/public.html
22
33
44
5
5
6
7
8
9
10
611
712
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
838
939
1040
{block body}
<table class="form" summary="">
<tr>
<th></th>
<th style="text-align: right">{if $user_data.avatar != ''}
<img style="max-height: 60px; max-width: 60px;" src="{media}/upload/avatars/{$user_data.avatar}" alt=" " />
{else}
<img src="http://www.gravatar.com/avatar/{$member.email|md5}.jpg?s=60&amp;d={media}/idf/img/spacer.gif" alt=" " />
{/if}
</th>
<td>{$member}</td>
</tr>
{if $user_data.description != ''}
<tr>
<th>{trans 'Description:'}</th>
<td>{$user_data.description}</td>
</tr>
{/if}
{if $user_data.twitter != ''}
<tr>
<th>{trans 'Twitter:'}</th>
<td><a rel="nofollow" target="_blank" href='http://twitter.com/{$user_data.twitter}'>{$user_data.twitter}</a></td>
</tr>
{/if}
{if $user_data.public_email != ''}
<tr>
<th>{trans 'Public Email:'}</th>
<td><a href='mailto:{$user_data.public_email}'>{$user_data.public_email}</a></td>
</tr>
{/if}
{if $user_data.website != ''}
<tr>
<th>{trans 'Website:'}</th>
<td><a rel="nofollow" target="_blank" href='{$user_data.website}'>{$user_data.website}</a></td>
</tr>
{/if}
<tr>
<th>{trans 'Last time seen:'}</th>
<td>{$member.last_login|dateago}</td>
www/media/idf/css/style.css
104104
105105
106106
107
108
109
110
111
107112
108113
109114
font-weight: normal;
}
table.form td.separator {
font-weight: bold;
text-align: center;
}
.px-message-error {
padding-left: 37px;
background: url("../img/dialog-error.png");

Archive Download the corresponding diff file

Page rendered in 0.15888s using 14 queries.