/[drupal]/contributions/modules/signit/signit.inc
ViewVC logotype

Diff of /contributions/modules/signit/signit.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.4, Thu Jan 3 03:57:09 2008 UTC revision 1.1.2.5, Fri Jan 4 15:41:51 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  // $Id: signit.inc,v 1.1.2.3 2008/01/03 01:47:49 arthuregg Exp $  // $Id: signit.inc,v 1.1.2.4 2008/01/03 03:57:09 arthuregg Exp $
4    
5  /**  /**
6   * this file contains all the implementations of signit hook operations   * this file contains all the implementations of signit hook operations
# Line 44  function signit_signit_message_create($s Line 44  function signit_signit_message_create($s
44    $form['signit_email_from'] = array(    $form['signit_email_from'] = array(
45      '#type' => 'textfield',      '#type' => 'textfield',
46      '#title' => t('Email from'),      '#title' => t('Email from'),
47      '#default_value' => $node->signit['email_from'] ? $node->signit['email_from']: variable_get("site_mail", null),      '#default_value' => $signit['email_from'] ? $signit['email_from']: variable_get("site_mail", null),
48      '#description'   => t('Enter the email address that will appear in the "From: " header of sent messages. This is <em>only</em> used when sending a list of signatures.'),      '#description'   => t('Enter the email address that will appear in the "From: " header of sent messages. This is <em>only</em> used when sending a list of signatures.'),
49    );    );
50    $form['signit_email_subject_set'] = array(    $form['signit_email_subject_set'] = array(
51      '#type' => 'checkbox',      '#type' => 'checkbox',
52      '#title' => t('Allow users to set email subject.'),      '#title' => t('Allow users to set email subject.'),
53      '#options' => array('Enabled'),      '#options' => array('Enabled'),
54      '#default_value' => $node->signit['email_subject_set'] ? 1 : 0,      '#default_value' => $signit['email_subject_set'] ? 1 : 0,
55      '#description' => t('If this is not set, the subject will be populated by the below value'),      '#description' => t('If this is not set, the subject will be populated by the below value'),
56    );    );
57    
# Line 59  function signit_signit_message_create($s Line 59  function signit_signit_message_create($s
59    $form['signit_email_subject'] = array(    $form['signit_email_subject'] = array(
60      '#type'          => 'textfield',      '#type'          => 'textfield',
61      '#title'         => t('Email subject'),      '#title'         => t('Email subject'),
62      '#default_value' => $node->signit['email_subject'] ? $node->signit['email_subject'] : "My SignIt ",      '#default_value' => $signit['email_subject'] ? $signit['email_subject'] : "My SignIt ",
63      '#description'   => t('Subject of auto-response email message to be sent.'),      '#description'   => t('Subject of auto-response email message to be sent.'),
64    );    );
65    
# Line 67  function signit_signit_message_create($s Line 67  function signit_signit_message_create($s
67    $form['signit_message_filter']['signit_message'] = array(    $form['signit_message_filter']['signit_message'] = array(
68      '#type'          => 'textarea',      '#type'          => 'textarea',
69      '#title'         => t('Email message'),      '#title'         => t('Email message'),
70      '#default_value' => $node->signit['message'],      '#default_value' => $signit['message'],
71      '#description'   => t('Body of auto-response email message to be sent. Please note, changes to this do not effect already collected signatures.'),      '#description'   => t('Body of auto-response email message to be sent. Please note, changes to this do not effect already collected signatures.'),
72    );    );
73    // add a filter form to to the body    // add a filter form to to the body
74    $form['signit_message_filter']['signit_message_format'] = filter_form($node->signit['message_format'], null, array('signit_message_filter'));    $form['signit_message_filter']['signit_message_format'] = filter_form($signit['message_format'], null, array('signit_message_filter'));
75    
   
76    $form['signit_personal_message'] = array(    $form['signit_personal_message'] = array(
77      '#type' => 'checkbox',      '#type' => 'checkbox',
78      '#title' => t('Allow users to add personal messages.'),      '#title' => t('Allow users to add personal messages.'),
79      '#options' => array('Enabled'),      '#options' => array('Enabled'),
80      '#default_value' => $node->signit['personal_message'] ? 1 : 0,      '#default_value' => $signit['personal_message'] ? 1 : 0,
81      '#description' => t('Gives user the ability to add a personal message to the email template. ')      '#description' => t('Gives user the ability to add a personal message to the email template. ')
82    );    );
83    
# Line 86  function signit_signit_message_create($s Line 85  function signit_signit_message_create($s
85      '#type' => 'checkbox',      '#type' => 'checkbox',
86      '#title' => t('Allow users to add a comment.'),      '#title' => t('Allow users to add a comment.'),
87      '#options' => array('Enabled'),      '#options' => array('Enabled'),
88      '#default_value' => $node->signit['comment_allow'] ? 1 : 0,      '#default_value' => $signit['comment_allow'] ? 1 : 0,
89      '#description' => t('Gives user the ability to leave a comment along with their message. This can be displayed on the list of signatures.')      '#description' => t('Gives user the ability to leave a comment along with their message. This can be displayed on the list of signatures.')
90    );    );
91    
# Line 94  function signit_signit_message_create($s Line 93  function signit_signit_message_create($s
93      '#type' => 'checkbox',      '#type' => 'checkbox',
94      '#title' => t('Allow HTML in comment form.'),      '#title' => t('Allow HTML in comment form.'),
95      '#options' => array('Enabled'),      '#options' => array('Enabled'),
96      '#default_value' => $node->signit['comment_allow_html'] ? 1 : 0,      '#default_value' => $signit['comment_allow_html'] ? 1 : 0,
97      '#description' => t('If this is checked, non-anonymous users will be allowed to have HTML tags in the comment form. Anonymous users are <em>never</em> allowed to enter HTML.'),      '#description' => t('If this is checked, non-anonymous users will be allowed to have HTML tags in the comment form. Anonymous users are <em>never</em> allowed to enter HTML.'),
98    );    );
99    
100      $form['signit_sign_reciept'] = array(
101        '#type' => 'checkbox',
102        '#title' => t('Send reciept on signing.'),
103        '#options' => array('Enabled'),
104        '#default_value' => $signit['signit_sign_reciept'] ? 1 : 0,
105        '#description' => t('Sends the user a message when they\'ve signed a SignIt.')
106      );
107    
108      $form['signit_sign_reciept_subject'] = array(
109        '#type'          => 'textarea',
110        '#title'         => t('Signing email message subject'),
111        '#default_value' => $signit['message'],
112        '#description'   => t('Subject of auto-response email message to be sent to user when they sign a SignIt.'),
113      );
114    
115      $form['signit_sign_reciept_message'] = array(
116        '#type'          => 'textarea',
117        '#title'         => t('Signing email message body'),
118        '#default_value' => $signit['message'],
119        '#description'   => t('Body of auto-response email message to be sent to user when they sign a SignIt.'),
120      );
121    
122    return $form;    return $form;
123  }  }
124    
# Line 316  function signit_signit_control_create($s Line 338  function signit_signit_control_create($s
338    
339    return $form;    return $form;
340  }  }
341    
342    
343    /* ******************************************** */
344    /* Signing functions */
345    /* ******************************************** */
346    
347    /**
348     * implementation of the hook_signit_sign
349     * @param $op string that defines what operation to call
350     * @param $form_values is the array of submitted form data
351     * @param $signit is the signit array associated with this form
352     */
353    function signit_signit_sign($op, $form_values = array(), $signit = array()){
354      switch ($op) {
355        case 'admin':
356          return signit_sign_validate($form_values);
357        break;
358        case 'create':
359          return signit_sign_sign($form_values);
360      }
361    }
362    
363    /**
364     * does validation for all the signit create form functions in this include file
365     */
366    function signit_sign_validate($form_values) {
367    
368      // check email address
369      if (! valid_email_address($form_values['user_email'])) {
370        form_set_error('user_email', t('Please enter a valid email address'));
371      }
372    
373      // check targets
374    
375      // check dates
376    
377      // check process
378    
379    }
380    
381    
382    /**
383     * fires when a SignIt is signed
384     * @param $signit is a signit array
385     */
386    function signit_sign_sign ($form_values, $signit) {
387    
388      // check and see if we should send message to user
389      if ($signit['signit_sign_reciept']) {
390        drupal_mail('signit_sign_reciept', $signit['user_email'], $signit['signit_sign_reciept_subject'], $signit['signit_sign_reciept_message']);
391      }
392    
393    }

Legend:
Removed from v.1.1.2.4  
changed lines
  Added in v.1.1.2.5

  ViewVC Help
Powered by ViewVC 1.1.2