Bladeren bron

#656: rendre l'adresse d'envoi des demandes d'inscription aux cours parametrable.

FGM 15 jaren geleden
bovenliggende
commit
8fc540d4d3
2 gewijzigde bestanden met toevoegingen van 75 en 12 verwijderingen
  1. 50 0
      fgcf.admin.inc
  2. 25 12
      fgcf.module

+ 50 - 0
fgcf.admin.inc

@@ -0,0 +1,50 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Admin pages for FGCF module
+ *
+ * @copyright (c) 2010 Ouest Systemes Informatiques (OSInet)
+ *
+ * @license General Public License version 2 or later
+ *
+ * @author Frederic G. MARAND (fgm@osinet.fr)
+ *
+ */
+
+/**
+ * Implement the former hook_settings().
+ *
+ * @see fgcf_admin_settings_validate()
+ *
+ * @return array
+ */
+function fgcf_admin_settings() {
+
+  $form = array();
+
+  $mail_destination = 'fgcf_mail_destination';
+  $form[$mail_destination] = array(
+    '#type' => 'textfield',
+    '#title' => t("Destinataire des demandes d'inscription aux formations"),
+    '#default_value' => variable_get($mail_destination, variable_get('site_mail', 'support@osinet.fr')),
+  );
+
+  $ret = system_settings_form($form);
+  return $ret;
+}
+
+/**
+ * Validation handler for fgcf_admin_settings().
+ *
+ * @param array $form
+ * @param array $form_state
+ *
+ * @return void
+ */
+function fgcf_admin_settings_validate($form, &$form_state) {
+  $mail_destination = 'fgcf_mail_destination';
+  if (!valid_email_address($form_state['values'][$mail_destination])) {
+    form_set_error($mail_destination, t('Invalid email address'));
+  }
+}

+ 25 - 12
fgcf.module

@@ -7,6 +7,15 @@
  */
 include_once('fgcf.features.inc');
 
+/**
+ * Implementation of hook_init().
+ */
+function fgcf_init() {
+  if (arg(0) == 'fgcf') {
+    drupal_add_css(drupal_get_path('module', 'fgcf') .'/theme/css/fgcf.css');
+  }
+}
+
 /**
  * Implementation of hook_menu().
  */
@@ -15,6 +24,20 @@ function fgcf_menu() {
 
   $items = array();
 
+  $items['admin/settings/fg'] = array(
+    'title'            => 'France Galop',
+    'description'      => 'Réglages des modules France Galop',
+    'access arguments' => array('administer site configuration'),
+    'page callback'    => 'drupal_get_form',
+    'page arguments'   => array('fgcf_admin_settings'),
+    'file'             => 'fgcf.admin.inc',
+  );
+  $items['admin/settings/fg/fgcf'] = array(
+    'title'            => 'Catalogue formations',
+    'description'      => 'Réglages du catalogue de formations',
+    'type'             => MENU_DEFAULT_LOCAL_TASK,
+  );
+
   $items['fgcf'] = array(
     'title' => 'Catalogue formations',
     'page callback' => 'fgcf_page_home',
@@ -47,16 +70,6 @@ function fgcf_menu() {
   return $items;
 }
 
-/**
- * Implementation of hook_init().
- */
-function fgcf_init() {
-  if (arg(0) == 'fgcf') {
-    drupal_add_css(drupal_get_path('module', 'fgcf') .'/theme/css/fgcf.css');
-  }
-}
-
-
 /**
  * Implementation of hook_perm().
  */
@@ -358,7 +371,7 @@ function fgcf_subscribe_form_submit($form, &$form_state) {
 
   // Prevent flooding.
   if (flood_is_allowed('fgcg_subscribe', 10)) {
-    $to = variable_get('site_mail', ini_get('sendmail_from'));
+    $to = variable_get('fgcf_mail_destination', variable_get('site_mail', ini_get('sendmail_from')));
     $params = array(
       'account' => $user,
       'node' => $form_state['values']['node'],
@@ -373,7 +386,7 @@ function fgcf_subscribe_form_submit($form, &$form_state) {
 }
 
 /**
- * Implemanbtation of hook_mail().
+ * Implementation of hook_mail().
  */
 function fgcf_mail($key, &$message, $params) {
   $language = $message['language'];