diff --git a/indefero/src/IDF/Form/ProjectRequest.php b/indefero/src/IDF/Form/ProjectRequest.php index f7fbfb2..3b2e14a 100644 --- a/indefero/src/IDF/Form/ProjectRequest.php +++ b/indefero/src/IDF/Form/ProjectRequest.php @@ -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) { diff --git a/indefero/src/IDF/Views/Admin.php b/indefero/src/IDF/Views/Admin.php index 895904d..f6770d8 100644 --- a/indefero/src/IDF/Views/Admin.php +++ b/indefero/src/IDF/Views/Admin.php @@ -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. * diff --git a/indefero/src/IDF/conf/urls.php b/indefero/src/IDF/conf/urls.php index cd702e7..09935ba 100644 --- a/indefero/src/IDF/conf/urls.php +++ b/indefero/src/IDF/conf/urls.php @@ -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', diff --git a/indefero/src/IDF/templates/idf/admin/approveprojects.html b/indefero/src/IDF/templates/idf/admin/approveprojects.html index 77dcd28..f415bb7 100644 --- a/indefero/src/IDF/templates/idf/admin/approveprojects.html +++ b/indefero/src/IDF/templates/idf/admin/approveprojects.html @@ -32,6 +32,9 @@