/[drupal]/contributions/modules/node_expire/node_expire.ntype.inc
ViewVC logotype

Contents of /contributions/modules/node_expire/node_expire.ntype.inc

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


Revision 1.3 - (show annotations) (download) (as text)
Sat Jan 31 01:26:53 2009 UTC (9 months, 3 weeks ago) by brmassa
Branch: MAIN
CVS Tags: DRUPAL-6--2-03, HEAD
Changes since 1.2: +4 -3 lines
File MIME type: text/x-php
New features:
* Node expiration REQUIRE option
1 <?php
2 // $Id: node_expire.ntype.inc,v 1.2 2009/01/29 21:01:33 brmassa Exp $
3
4 /**
5 * @file
6 * Node type integration.
7 */
8
9 /**
10 * Implementation of hook_form_alter().
11 */
12 function _node_expire_form_node_type_form_alter_validate(&$form, &$form_state) {
13 $node_expire = &$form_state['values']['node_expire'];
14 if (!empty($node_expire) and !strtotime($node_expire)) {
15 form_set_error('node_expire', 'This values should be in PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.');
16 }
17
18 $node_expire_max = &$form_state['values']['node_expire_max'];
19 if (!empty($node_expire_max)) {
20 if (!strtotime($node_expire_max)) {
21 form_set_error('node_expire_max', 'This values should be in PHP <a href="http://www.php.net/strtotime" target="_blank">strtotime format</a>.');
22 }
23 elseif (strtotime($node_expire) > strtotime($node_expire_max)) {
24 form_set_error('node_expire_max', 'This value cannot be earlier then the default value.');
25 }
26 }
27 }
28
29
30 /**
31 * Implementation of hook_form_alter().
32 */
33 function _node_expire_form_node_type_form_alter_submit(&$form, &$form_state) {
34 $ntypes = variable_get('node_expire_ntypes', array());
35 $ntypes[$form_state['values']['type']]['default'] = $form_state['values']['node_expire'];
36 $ntypes[$form_state['values']['type']]['max'] = $form_state['values']['node_expire_max'];
37 $ntypes[$form_state['values']['type']]['required'] = $form_state['values']['node_expire_required'];
38 variable_set('node_expire_ntypes', $ntypes);
39 }

  ViewVC Help
Powered by ViewVC 1.1.2