-
Notifications
You must be signed in to change notification settings - Fork 0
/
panopoly_news.install
46 lines (38 loc) · 1.26 KB
/
panopoly_news.install
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
<?php
/**
* @file
* Code for the Panopoly News installer.
*/
/**
* Implementation of hook_install()
*
* Need to set default user pic here instead of with strongarm
* @todo: figure out a way to revert back to this if overridden
*
*/
function panopoly_news_install() {
//Set default user pic
if (!variable_get('user_picture_default')) {
variable_set('user_picture_default', drupal_get_path('module', 'panopoly_news') . '/images/panopoly-news-user-pic-default.png');
}
//Set default article pic
//Get the article field
$prior_field = field_info_field('field_panopoly_news_image');
//Only set the default image if none has been set already
if(empty($prior_field['settings']['default_image']['fid'])){
$filepath = drupal_get_path('module', 'panopoly_news') . '/images/panopoly-news-article-pic-default.png';
//Create managed File object and associate with Image field.
$file = (object) array(
'uid' => 1,
'uri' => $filepath,
'filemime' => file_get_mimetype($filepath),
'status' => 1,
);
$field = $prior_field;
$field['settings']['default_image'] = $file;
image_field_update_field($field, $prior_field, FALSE);
}
//Enable demo content
//@todo: make this part of install process?
module_enable('panopoly_news_demo');
}