diff --git a/src/IDF/Commit.php b/src/IDF/Commit.php index 0e724ad..6be1a95 100644 --- a/src/IDF/Commit.php +++ b/src/IDF/Commit.php @@ -297,7 +297,7 @@ class IDF_Commit extends Pluf_Model 'creation_date' => $this->creation_dtime, ), 'project_id' => $project->id, - 'authkey' => $project->getPostCommitHookKey(), + 'authkey' => $project->getWebHookKey(), 'url' => $url, ); $item = new IDF_Queue(); diff --git a/src/IDF/Form/SourceConf.php b/src/IDF/Form/SourceConf.php index df2a6cc..5a9a183 100644 --- a/src/IDF/Form/SourceConf.php +++ b/src/IDF/Form/SourceConf.php @@ -49,13 +49,10 @@ class IDF_Form_SourceConf extends Pluf_Form 'widget' => 'Pluf_Form_Widget_PasswordInput', )); } - Pluf::loadFunction('Pluf_HTTP_URL_urlForView'); - $url = Pluf_HTTP_URL_urlForView('idf_faq').'#webhooks'; $this->fields['webhook_url'] = new Pluf_Form_Field_Url( array('required' => false, 'label' => __('Webhook URL'), 'initial' => $this->conf->getVal('webhook_url', ''), - 'help_text' => sprintf(__('Learn more about the post-commit web hooks.'), $url), 'widget_attrs' => array('size' => 35), )); diff --git a/src/IDF/Form/UploadConf.php b/src/IDF/Form/UploadConf.php index f6b4c7d..eec6788 100644 --- a/src/IDF/Form/UploadConf.php +++ b/src/IDF/Form/UploadConf.php @@ -60,10 +60,18 @@ Deprecated = Most users should NOT download this'; $this->fields['labels_download_one_max'] = new Pluf_Form_Field_Varchar( array('required' => false, 'label' => __('Each download may have at most one label with each of these classes'), - 'initial' => self::init_one_max, + 'initial' => self::init_one_max, 'widget_attrs' => array('size' => 60), )); + $this->conf = $extra['conf']; + $this->fields['upload_webhook_url'] = new Pluf_Form_Field_Url( + array('required' => false, + 'label' => __('Webhook URL'), + 'initial' => $this->conf->getVal('upload_webhook_url', ''), + 'widget_attrs' => array('size' => 60), + )); + } } diff --git a/src/IDF/Project.php b/src/IDF/Project.php index 598f4a3..ab25cf5 100644 --- a/src/IDF/Project.php +++ b/src/IDF/Project.php @@ -494,12 +494,12 @@ GROUP BY uid"; } /** - * Get the post commit hook key. + * Get the web hook key. * * The goal is to get something predictable but from which one * cannot reverse find the secret key. */ - public function getPostCommitHookKey() + public function getWebHookKey() { return md5($this->id.sha1(Pluf::f('secret_key')).$this->shortname); } diff --git a/src/IDF/Views/Project.php b/src/IDF/Views/Project.php index 70b2efa..54c52ee 100644 --- a/src/IDF/Views/Project.php +++ b/src/IDF/Views/Project.php @@ -375,8 +375,11 @@ class IDF_Views_Project $title = sprintf(__('%s Downloads Configuration'), (string) $prj); $conf = new IDF_Conf(); $conf->setProject($prj); + $extra = array( + 'conf' => $conf, + ); if ($request->method == 'POST') { - $form = new IDF_Form_UploadConf($request->POST); + $form = new IDF_Form_UploadConf($request->POST, $extra); if ($form->isValid()) { foreach ($form->cleaned_data as $key=>$val) { $conf->setVal($key, $val); @@ -388,7 +391,7 @@ class IDF_Views_Project } } else { $params = array(); - $keys = array('labels_download_predefined', 'labels_download_one_max'); + $keys = array('labels_download_predefined', 'labels_download_one_max', 'upload_webhook_url'); foreach ($keys as $key) { $_val = $conf->getVal($key, false); if ($_val !== false) { @@ -398,12 +401,13 @@ class IDF_Views_Project if (count($params) == 0) { $params = null; //Nothing in the db, so new form. } - $form = new IDF_Form_UploadConf($params); + $form = new IDF_Form_UploadConf($params, $extra); } return Pluf_Shortcuts_RenderToResponse('idf/admin/downloads.html', array( 'page_title' => $title, 'form' => $form, + 'hookkey' => $prj->getWebHookKey(), ), $request); } @@ -598,7 +602,7 @@ class IDF_Views_Project 'repository_size' => $prj->getRepositorySize(), 'page_title' => $title, 'form' => $form, - 'hookkey' => $prj->getPostCommitHookKey(), + 'hookkey' => $prj->getWebHookKey(), ), $request); } diff --git a/src/IDF/templates/idf/admin/downloads.html b/src/IDF/templates/idf/admin/downloads.html index c22be5e..a614484 100644 --- a/src/IDF/templates/idf/admin/downloads.html +++ b/src/IDF/templates/idf/admin/downloads.html @@ -1,5 +1,5 @@ {extends "idf/admin/base.html"} -{block docclass}yui-t1{assign $inDownloads = true}{/block} +{block docclass}yui-t3{assign $inDownloads = true}{/block} {block body}