function pmproject_install in Drupal PM (Project Management) 7
Same name and namespace in other branches
- 8 pmproject/pmproject.install \pmproject_install()
- 7.3 pmproject/pmproject.install \pmproject_install()
- 7.2 pmproject/pmproject.install \pmproject_install()
Implements hook_install().
File
- pmproject/
pmproject.install, line 10 - Installation functions for the Project Management project module
Code
function pmproject_install() {
variable_set('node_options_pmproject', array(
'status',
));
variable_set('node_permissions_pmproject', 0);
// Uncache node types
node_types_rebuild();
// Fetch list of current node types and add body field to pmproject
$types = node_type_get_types();
node_add_body_field($types['pmproject'], 'Description');
// Add instance of date field.
field_create_instance(array(
'field_name' => 'pm_date',
'label' => 'Date',
'widget' => array(
'weight' => '-18',
'type' => 'date_text',
'module' => 'date',
'active' => 1,
'settings' => array(
'input_format' => 'm/d/Y - H:i:s',
'input_format_custom' => '',
'year_range' => '-3:+3',
'increment' => 15,
'label_position' => 'above',
'text_parts' => array(),
),
),
'settings' => array(
'default_value' => 'now',
'default_value_code' => '',
'default_value2' => 'same',
'default_value_code2' => '',
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'date_default',
'settings' => array(
'format_type' => 'long',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'fromto' => 'both',
),
'module' => 'date',
'weight' => 1,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 0,
'entity_type' => 'node',
'bundle' => 'pmproject',
));
// Set up instance of billing status field.
field_create_instance(array(
'field_name' => 'pm_billing_status',
'label' => 'Billing status',
'entity_type' => 'node',
'bundle' => 'pmexpense',
'widget' => array(
'weight' => -14,
'type' => 'options_select',
'module' => 'options',
'active' => 1,
'settings' => array(),
),
'required' => 1,
'description' => '',
'default_value' => array(
array(
'value' => variable_get('pmexpense_billable_default', 0) ? 'Billable' : 'Not billable',
),
),
));
$attributes = array();
$attributes['Project status'] = array(
'inserted' => 'inserted',
'in progress' => 'in progress',
'on hold' => 'on hold',
'completed' => 'completed',
);
$attributes['Project status search'] = array(
'-' => 'all',
'inserted,in progress,on hold' => 'open',
'inserted' => '-- inserted',
'in progress' => '-- in progress',
'on hold' => '-- on hold',
'completed' => 'completed',
);
$attributes['Project category'] = array(
'development' => 'development',
'support' => 'support',
);
$attributes['Project category search'] = array(
'-' => 'all',
'development' => 'development',
'support' => 'support',
);
$attributes['Project priority'] = array(
'1-low' => 'low',
'2-normal' => 'normal',
'3-high' => 'high',
'4-urgent' => 'urgent',
);
$attributes['Project priority search'] = array(
'-' => 'all',
'1-low' => 'low',
'2-normal' => 'normal',
'3-high' => 'high',
'4-urgent' => 'urgent',
);
$attributes['Duration unit'] = array(
'hour' => 'Hour',
'day' => 'Day',
);
$prevdomain = '';
$weight = 0;
foreach ($attributes as $domain => $attribute) {
if ($domain != $prevdomain) {
$weight = 0;
}
foreach ($attribute as $key => $value) {
db_insert('pmattribute')
->fields(array(
'domain' => $domain,
'akey' => $key,
'avalue' => $value,
'weight' => $weight,
))
->execute();
$weight++;
}
$prevdomain = $domain;
}
}