This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cos_impact_tools.add.inc
75 lines (70 loc) · 2 KB
/
cos_impact_tools.add.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* @file
* Adds a new row to the cos impact tools box.
*/
/**
* Implements hook_form().
*/
function cos_impact_add_form($form, &$form_state) {
$form['toolbox_icon'] = array(
'#type' => 'select',
'#title' => t('Icon to be shown.'),
'#description' => t('The font awesome Icon to be used'),
'#options' => array(
'fa-facebook' => t('Facebook'),
'fa-graduation-cap' => t('Graduation Cap'),
'fa-life-ring' => t('Life Preserver'),
'fa-list' => t('List'),
'fa-medkit' => t('Med Kit'),
'fa-money' => t('Money'),
'fa-paper-plane' => t('Paper Airplane'),
'fa-twitter' => t('Twitter'),
),
'#required' => TRUE,
);
$form['toolbox_icon_title'] = array(
'#type' => 'textfield',
'#title' => t('Toolbox Title'),
'#required' => TRUE,
'#size' => 20,
'#title_display' => 'before',
'#description' => t('Title will show up below the Icon'),
);
$form['toolbox_icon_url'] = array(
'#type' => 'textfield',
'#title' => t('Toolbox URL'),
'#required' => TRUE,
'#title_display' => 'before',
'#description' => t('Can be relative to Drupal or external.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Add'),
);
return $form;
}
/**
* Implements hook_form_validate().
*/
function cos_impact_add_form_validate($form, &$form_state) {
}
/**
* Implements ho0k_form_submit().
*/
function cos_impact_add_form_submit($form, &$form_state) {
$fields_array = array(
'icon' => $form_state['values']['toolbox_icon'],
'title' => $form_state['values']['toolbox_icon_title'],
'url' => $form_state['values']['toolbox_icon_url'],
);
db_insert('cos_impact_blocks')
->fields($fields_array)
->execute();
// Unset destination, we will be using a redirect.
unset($_GET['destination']);
// Unset rebuild so we go to the destination we want.
unset($form_state['rebuild']);
$form_state['redirect'] = 'admin/config/impact/manage';
drupal_set_message(t('Added new Tool box'), 'status');
}