/[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.3, Thu Jan 3 01:47:49 2008 UTC revision 1.1.2.4, Thu Jan 3 03:57:09 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  // $Id: $  // $Id: signit.inc,v 1.1.2.3 2008/01/03 01:47:49 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 205  function signit_signit_targets_admin() { Line 205  function signit_signit_targets_admin() {
205    
206    return $form;    return $form;
207  }  }
208    
209    /* ******************************************** */
210    /* Display Control functions */
211    /* ******************************************** */
212    
213    /**
214     * implementation of the hook_signit_control
215     */
216    function signit_signit_control($op, $data = array()){
217      switch ($op) {
218        case 'admin':
219          return signit_signit_control_admin();
220        break;
221        case 'create':
222          return signit_signit_control_create($data);
223      }
224    }
225    
226    /**
227     * builds form for the admin settings page
228     */
229    function signit_signit_control_admin() {
230      $form['signit_display_enabled'] = array(
231        '#type' => 'checkbox',
232        '#title' => t('Show enabled box'),
233        '#default_value' => variable_get('signit_display_enabled', true),
234        '#description' => t('Allow SignIt creators to enable and disable their SignIts.'),
235      );
236    
237      $form['signit_display_date'] = array(
238        '#type' => 'checkbox',
239        '#title' => t('Show date ranges'),
240        '#default_value' => variable_get('signit_display_date', true),
241        '#description' => t('Allow SignIt creators to enable date ranges for their signits.'),
242      );
243    
244      return $form;
245    }
246    
247    /**
248     * builds form for the signit create
249     */
250    function signit_signit_control_create($signit) {
251    
252      if (variable_get('signit_display_enabled', true)) {
253        $form['signit_status'] = array(
254          '#type' => 'checkbox',
255          '#title' => t('This SignIt is enabled.'),
256          '#options' => array('Enabled'),
257          '#default_value' => $signit['status'] ? 1 : 0,
258          '#description' => t('If this is set, users may sign this node.'),
259        );
260      }
261      else {
262        $form['signit_status'] = array(
263          '#type' => 'hidden',
264          '#default_value' => $signit['status'],
265        );
266      }
267    
268      if (variable_get('signit_display_date', true)) {
269        $form['dates'] = array(
270          '#type' => 'fieldset',
271          '#title' => t('SignIt dates'),
272          '#collapsible' => true,
273        );
274    
275        $form['dates']['signit_use_dates'] = array(
276          '#type' => 'checkbox',
277          '#title' => t('Enable date control.'),
278          '#options' => array('Enabled'),
279          '#default_value' => $signit['use_dates'] ? 1 : 0,
280          '#description' => t('If this is set, users can only sign a SignIt between these dates. If this is not set, users can always add signatures.'),
281        );
282    
283        $default_date = array('day' => format_date(time(), 'custom', 'j'),
284          'month' => format_date(time(), 'custom', 'n'),
285          'year' => format_date(time(), 'custom', 'Y'));
286    
287        $form['dates']['signit_start'] = array(
288          '#type' => 'date',
289          '#title' => t('SignIt start'),
290          '#description' => t('Date when the SignIt can be signed.'),
291          '#prefix' => '<div id="signit_dates">',
292          '#default_value' => $node->signit['start'] ? array(
293            'day' => format_date($node->signit['start'], 'custom', 'j'),
294            'month' => format_date($node->signit['start'], 'custom', 'n'),
295            'year' => format_date($node->signit['start'], 'custom', 'Y')) : $default_date
296        );
297    
298        $form['dates']['signit_end'] = array(
299          '#type' => 'date',
300          '#title' => t('SignIt end'),
301          '#description' => t('Date when the SignIt can no longer be signed.'),
302          '#suffix' => '</div>',
303          '#default_value' => $node->signit['end'] ? array(
304            'day' => format_date($node->signit['end'], 'custom', 'j'),
305            'month' => format_date($node->signit['end'], 'custom', 'n'),
306            'year' => format_date($node->signit['end'], 'custom', 'Y')) : $default_date
307        );
308      }
309      else {
310        $form['signit_status'] = array(
311          '#type' => 'hidden',
312          '#default_value' => $signit['status'],
313        );
314      }
315    
316    
317      return $form;
318    }

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

  ViewVC Help
Powered by ViewVC 1.1.2