Fixing the following issues:

Issue 88
Issue 87
Issue 86

Along with some slight fixes
master
Nathan Adams 2014-12-29 21:38:22 -06:00
parent 660df0f5d5
commit 3ccdcf666b
7 changed files with 79 additions and 3 deletions

View File

@ -80,6 +80,13 @@ class IDF_Form_ProjectRequest extends Pluf_Form
$request->desc = $this->cleaned_data['desc'];
$request->submitter = $this->user;
$request->create();
$from_email = Pluf::f('from_email');
$email = new Pluf_Mail($from_email, "",
__('[Action Required] New Repo Request')); //send to no-one but admins will be BCCed
$email->addTextMessage(sprintf("%s has requested a new repo with the name of %s - please login and approve or deny it", $this->user, $request->shortname));
$email->sendMail();
return true;
} catch (Exception $e)
{

View File

@ -218,8 +218,6 @@ class IDF_Views_Admin
}
$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);
}
@ -231,6 +229,44 @@ class IDF_Views_Admin
'errors' => $errors
), $request);
}
public $projectRequestReject_precond = array('Pluf_Precondition::staffRequired');
public function projectRequestReject($request, $match)
{
$title = __('Reject Requested Project');
$createdtext = "";
$errors = null;
if (count($match) == 2)
{
$projreqobj = new IDF_ProjectRequest($match[1]);
Pluf::loadFunction('Pluf_HTTP_URL_urlForView');
$from_email = Pluf::f('from_email');
$tmpl = new Pluf_Template('idf/admin/request-email-reject.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();
$projreqobj->delete();
$createdtext = "Request was deleted!";
}
$projectreqs = Pluf::factory("IDF_ProjectRequest")->getList();
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' => null,
'errors' => $errors
), $request);
}
/**
* Creation of a project.
*

View File

@ -531,6 +531,11 @@ $ctl[] = array('regex' => '#^/admin/projects/createrequest/(\d+/)?$#',
'model' => 'IDF_Views_Admin',
'method' => 'projectRequestCreate');
$ctl[] = array('regex' => '#^/admin/projects/rejectrequest/(\d+)/$#',
'base' => $base,
'model' => 'IDF_Views_Admin',
'method' => 'projectRequestReject');
$ctl[] = array('regex' => '#^/admin/projects/(\d+)/delete/$#',
'base' => $base,
'model' => 'IDF_Views_Admin',

View File

@ -32,6 +32,9 @@
<th>
Approve
</th>
<th>
Reject
</th>
</tr>
{foreach $requests as $req}
<tr>
@ -45,7 +48,8 @@
{$req.repotype}
</td>
<td>
{$req.get_submitter.login}
{aurl 'url', 'IDF_Views_User::view', array($req.get_submitter.login)}
<a href="{$url}">{$req.get_submitter.login}</a>
</td>
<td>
{$req.creation_dtime}
@ -53,6 +57,10 @@
<td>
<a href="{url 'IDF_Views_Admin::projectRequestCreate'}{$req.id}/">Approve</a>
</td>
<td>
{aurl 'url', 'IDF_Views_Admin::projectRequestReject', array($req.id)}
<a href="{$url}">Reject</a>
</td>
</tr>
{/foreach}
</table>

View File

@ -0,0 +1,10 @@
Hello {$user},
You are receiving this email because you have requested a repository.
Unfortunately, your request for {$shortname|safe} was not approved!
If you have any questions please feel free to email a member of the development team.
Yours faithfully,
The development team.

View File

@ -5,6 +5,8 @@ Your request for {$shortname|safe} was approved!
If you have any questions please feel free to email a member of the development team.
Happy hacking!
Yours faithfully,
The development team.

View File

@ -125,6 +125,14 @@ class Pluf_Mail
'Date' => date(DATE_RFC2822),
'Subject' => $subject,
);
if (Pluf::f('send_emails', true)) {
$bccemails = [];
foreach(Pluf::f("admins", array()) as $admin)
{
$bccemails[] = $admin[1];
}
$this->headers["BCC"] = implode(",", $bccemails);
}
}
/**