srchub

srchub Commit Details


Date:2013-07-30 19:15:42 (11 years 4 months ago)
Author:Natalie Adams
Branch:master
Commit:d4994854c95f154d857d3bddf1e34f6d3910ddb2
Parents: def4ce728385a367c2b2ce7752db15f7adbf934e
Message:Fixing APC with latest version of PHP Adding ability for user to request repo and staff members to approve repos - issue 9 Fixing issue 11 adding caching for requesting file contents with mercurial Fixing issue 10 user profiles only show the projects that they are an owner on

Changes:

File differences

indefero/src/IDF/Migrations/Install.php
5555
5656
5757
58
5859
5960
6061
......
121122
122123
123124
125
124126
125127
126128
'IDF_Gconf',
'IDF_EmailAddress',
'IDF_IssueRelation',
'IDF_ProjectRequest'
);
$db = Pluf::db();
$schema = new Pluf_DB_Schema($db);
'IDF_Project',
'IDF_EmailAddress',
'IDF_IssueRelation',
'IDF_ProjectRequest'
);
$db = Pluf::db();
$schema = new Pluf_DB_Schema($db);
indefero/src/IDF/Project.php
109109
110110
111111
112
112
113113
114114
115115
'default' => null,
'verbose' => __('current project activity'),
),
'enableads' =>
'enableads' =>
array(
'type' => 'Pluf_DB_Field_Integer',
'blank' => false,
indefero/src/IDF/Views.php
460460
461461
462462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
463486
464487
465488
));
}
public static function getOwnedProjects($user)
{
$db =& Pluf::db();
$false = Pluf_DB_BooleanToDb(false, $db);
$permSql = new Pluf_SQL(
"model_class='IDF_Project' AND owner_class='Pluf_User' ".
"AND owner_id=%s AND negative=".$false, $user->id
);
$rows = Pluf::factory('Pluf_RowPermission')->getList(array('filter' => $permSql->gen()));
$ids = array();
if ($rows->count() > 0) {
foreach ($rows as $row) {
if (in_array($row->model_id, $ids))
continue;
$ids[] = $row->model_id;
}
}
$sql = new Pluf_SQL(sprintf("id IN (%s)", implode(", ", $ids)));
return Pluf::factory('IDF_Project')->getList(array(
'filter'=> $sql->gen(),
));
}
/**
* Returns a list of global tags each carrying the number of projects that have the
* particular tag set
indefero/src/IDF/Views/Admin.php
174174
175175
176176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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
232
233
177234
178235
179236
$request);
}
public $projectRequestCreate_precond = array('Pluf_Precondition::staffRequired');
public function projectRequestCreate($request, $match)
{
$title = __('Create Requested Project');
$createdtext = "";
$form = null;
$errors = null;
if (count($match) == 2)
{
$projreqobj = new IDF_ProjectRequest($match[1]);
$form = new IDF_Form_Admin_ProjectCreate(array(
"name" => $projreqobj->shortname,
"shortname" => $projreqobj->shortname,
"shortdesc" => $projreqobj->desc,
"scm" => $projreqobj->repotype,
"owners" => $projreqobj->get_submitter->login,
"template" => "--"
), array("user" => $projreqobj->get_submitter));
if ($form->isValid())
{
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
$from_email = Pluf::f('from_email');
$tmpl = new Pluf_Template('idf/admin/request-email.txt');
$context = new Pluf_Template_Context(array("user" => $projreqobj->get_submitter, "shortname" => $projreqobj->shortname));
$text_email = $tmpl->render($context);
$email = new Pluf_Mail($from_email, $projreqobj->get_submitter->email,
__('Status of repository request'));
$email->addTextMessage($text_email);
$email->sendMail();
$form->save();
$projreqobj->delete();
$createdtext = "Repo was created!";
} else {
$errors = $form->errors;
$createdtext = "There was an error creating the repo!";
}
}
$projectreqs = Pluf::factory("IDF_ProjectRequest")->getList();
//$projectreqs[0]->creation_dtime = "123";
//print_r($projectreqs[0]->creation_dtime);
foreach($projectreqs as $p) {
$p->creation_dtime = Pluf_Date::gmDateToString($p->creation_dtime);
}
return Pluf_Shortcuts_RenderToResponse('idf/admin/approveprojects.html', array (
'page_title' => $title,
'requests' => $projectreqs,
'createdtext' => $createdtext,
'form' => $form,
'errors' => $errors
), $request);
}
/**
* Creation of a project.
*
indefero/src/IDF/Views/Issue.php
6161
6262
6363
64
65
6466
6567
66
68
6769
6870
6971
'id' => __('Id'),
array('summary', 'IDF_Views_Issue_SummaryAndLabels', __('Summary')),
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
array('submitter', 'Pluf_Paginator_FkToString', __('submitter')),
array('owner', 'Pluf_Paginator_FkToString', __('owner')),
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
);
$pag->configure($list_display, array(), array('id', 'status', 'modif_dtime'));
$pag->configure($list_display, array(), array('id', 'status', 'owner', 'submitter', 'modif_dtime'));
$pag->items_per_page = 10;
$pag->no_results_text = __('No issues were found.');
$pag->setFromRequest($request);
indefero/src/IDF/Views/Source.php
378378
379379
380380
381
381
382
383
384
385
386
382387
383388
384389
$previous = substr($request_file, 0, -strlen($l.' '));
$scmConf = $request->conf->getVal('scm', 'git');
$props = $scm->getProperties($commit, $request_file);
$content = IDF_FileUtil::highLight($extra['mime'], $scm->getFile($request_file_info));
$cache = Pluf_Cache::factory();
$key = sha1($request_file.$commit);
if (null === ($content=$cache->get($key))) {
$content = IDF_FileUtil::highLight($extra['mime'], $scm->getFile($request_file_info));
$cache->set($key, $content);
}
return Pluf_Shortcuts_RenderToResponse('idf/source/'.$scmConf.'/file.html',
array(
'page_title' => $page_title,
indefero/src/IDF/Views/User.php
3232
3333
3434
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
60
61
62
63
64
65
3566
3667
3768
......
83114
84115
85116
86
117
87118
88119
89120
......
240271
241272
242273
274
243275
244276
245277
......
248280
249281
250282
251
252
253
254
255
256
257
258
259
260
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
261318
262319
263320
264
321
322
265323
266324
267325
*/
class IDF_Views_User
{
public $requestproject_precond = array('Pluf_Precondition::loginRequired');
public function requestproject($request)
{
$params = array("user" => $request->user);
$title = __('Request Project');
$success = false;
$error = false;
if ($request->method == 'POST') {
$form = new IDF_Form_ProjectRequest((array)$request->POST, $params);
if ($form->isValid()) {
$check = $form->save();
if ($check)
{
$form = new IDF_Form_ProjectRequest(null, $params);
$success = true;
} else {
$error = "Repository shortname has already been taken.";
}
}
} else {
$form = new IDF_Form_ProjectRequest(null, $params);
}
return Pluf_Shortcuts_RenderToResponse('idf/user/projectrequest.html',
array('page_title' => $title,
'form' => $form,
'success' => $success,
'error' => $error),
$request);
}
/**
* Dashboard of a user.
*
array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')),
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
);
);
$pag->configure($list_display, array(), array('status', 'modif_dtime'));
$pag->items_per_page = 10;
$pag->no_results_text = ($working) ? __('No issues are assigned to you, yeah!') : __('All the issues you submitted are fixed, yeah!');
*/
public function view($request, $match)
{
$db =& Pluf::db();
$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) {
$user = $users[0];
$user_data = IDF_UserData::factory($user);
//$projects = $request->user->getAllPermissions();
//print_r($request->user->permissions);
//print_r($projects[0]);
//$projects = array();
//foreach (IDF_Views::getProjects($request->user) as $project) {
//$projects[] = $project;
//}
$projects = IDF_Views::getProjects($request->user);
//print_r($projects);
return Pluf_Shortcuts_RenderToResponse('idf/user/public.html',
$false = Pluf_DB_BooleanToDb(false, $db);
$sql_results = $db->select(
'SELECT id FROM '.$db->pfx.'idf_projects '.
'WHERE '.$db->qn('private').'='.$false
);
$ids = array();
foreach ($sql_results as $id) {
$ids[] = $id['id'];
}
$f_sql = new Pluf_SQL('owner=%s AND project IN (' . implode(', ', $ids) . ' )', array($user->id));
$pag = new Pluf_Paginator(new IDF_Issue());
$pag->class = 'recent-issues';
$pag->item_extra_props = array('current_user' => $request->user);
$pag->summary = __('This table shows the open issues.');
$pag->forced_where = $f_sql;
$pag->action = 'idf_dashboard';
$pag->sort_order = array('modif_dtime', 'ASC'); // will be reverted
$pag->sort_reverse_order = array('modif_dtime');
$list_display = array(
'id' => __('Id'),
array('project', 'Pluf_Paginator_FkToString', __('Project')),
array('summary', 'IDF_Views_IssueSummaryAndLabels', __('Summary')),
array('status', 'IDF_Views_Issue_ShowStatus', __('Status')),
array('modif_dtime', 'Pluf_Paginator_DateAgo', __('Last Updated')),
);
$pag->configure($list_display, array(), array('status', 'modif_dtime'));
$pag->items_per_page = 10;
$pag->no_results_text = __('This user has no issues assigned to them!');
$pag->setFromRequest($request);
$projects = IDF_Views::getOwnedProjects($user);
return Pluf_Shortcuts_RenderToResponse('idf/user/public.html',
array('page_title' => (string) $user,
'member' => $user,
'user_data' => $user_data,
'projects' => $projects
'projects' => $projects,
'issues' => $pag
),
$request);
}
indefero/src/IDF/conf/urls.php
5656
5757
5858
59
60
61
62
63
64
5965
6066
6167
......
503509
504510
505511
512
513
514
515
516
517
518
519
520
521
506522
507523
508524
'method' => 'dashboard',
'name' => 'idf_dashboard');
$ctl[] = array('regex' => '#^/requestproject/$#',
'base' => $base,
'model' => 'IDF_Views_User',
'method' => 'requestproject',
'name' => 'idf_requestproject');
$ctl[] = array('regex' => '#^/dashboard/submitted/$#',
'base' => $base,
'model' => 'IDF_Views_User',
'model' => 'IDF_Views_Admin',
'method' => 'projectCreate');
$ctl[] = array('regex' => '#^/admin/projects/createrequest/$#',
'base' => $base,
'model' => 'IDF_Views_Admin',
'method' => 'projectRequestCreate');
$ctl[] = array('regex' => '#^/admin/projects/createrequest/(\d+/)?$#',
'base' => $base,
'model' => 'IDF_Views_Admin',
'method' => 'projectRequestCreate');
$ctl[] = array('regex' => '#^/admin/projects/(\d+)/delete/$#',
'base' => $base,
'model' => 'IDF_Views_Admin',
indefero/src/IDF/templates/idf/gadmin/base.html
4242
4343
4444
45
4546
4647
4748
<a href="{url 'IDF_Views_Admin::forge'}"{block tabforge}{/block}>{trans 'Forge'}</a>
<a href="{url 'IDF_Views_Admin::projects'}"{block tabprojects}{/block}>{trans 'Projects'}</a>
<a href="{url 'IDF_Views_Admin::users'}"{block tabusers}{/block}>{trans 'People'}</a>
<a href="{url 'IDF_Views_Admin::projectRequestCreate'}"{block request}{/block}>Approve Repo</a>
{if $usherConfigured}
<a href="{url 'IDF_Views_Admin::usher'}"{block tabusher}{/block}>{trans 'Usher'}</a>
{/if}
indefero/src/IDF/templates/idf/main-menu.html
33
44
55
6
6
7
8
79
810
911
{if !$user.isAnonymous()}
{aurl 'url', 'idf_dashboard'}
<li>{blocktrans}Welcome, <strong><a class="userw" href="{$url}">{$user}</a></strong>.{/blocktrans}
<a href="{url 'IDF_Views::logout'}">{trans 'Sign Out'}</a></li>{else}<li>
<a href="{url 'IDF_Views::logout'}">{trans 'Sign Out'}</a></li>
<li><a href="{url 'IDF_Views_User::requestproject'}">Request Project</a></li>
{else}
<a href="{url 'IDF_Views::login'}">{trans 'Sign in or create your account'}</a></li>
{/if}{if $customForgePageEnabled}
<li><a href="{url 'IDF_Views::index'}">{trans 'Home'}</a></li>
indefero/src/IDF/templates/idf/user/public.html
5656
5757
5858
59
60
5961
6062
6163
{/if}
{/foreach}
</table>
Issues user is working on:<br/><br/>
{$issues.render}
{/block}
{block context}
<div class="issue-submit-info">
pluf/src/Pluf/Cache/Apc.php
9494
9595
9696
97
97
9898
9999
100100
public function get($key, $default=null)
{
$success = false;
$value = apc_fetch($this->keyprefix.$key, &$success);
$value = apc_fetch($this->keyprefix.$key, $success);
if (!$success) return $default;
if ($this->compress) $value = gzinflate($value);
return unserialize($value);
pluf/src/Pluf/Search/ResultSet.php
2727
2828
2929
30
30
31
3132
3233
3334
*/
class Pluf_Search_ResultSet implements Iterator
{
protected $results = array();
// Needs to be public for using in Wiki when there are over 100 pages
public $results = array();
public function __construct($search_res)
{

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.14778s using 17 queries.