«
Previous
|
Next
»
Revision 7da17f72
Added by Markus Döring over 16 years ago
- ID 7da17f72f1a1041371ad3e164434c64d7c56c87e
- Child 5137d01e
.gitattributes | ||
---|---|---|
1 |
* text=auto !eol |
|
2 |
module_patches/cck_field_perms/cck_field_perms-views0.1.patch -text |
|
3 |
module_patches/nodefamily/nodefamily_create-others-nodes.patch -text |
|
4 |
modules/countrypresence/country-earth.dbf -text |
|
5 |
modules/countrypresence/country-earth.prj -text |
|
6 |
modules/countrypresence/country-earth.shp -text |
|
7 |
modules/countrypresence/country-earth.shx -text |
|
8 |
modules/countrypresence/countrypresence.info -text |
|
9 |
modules/countrypresence/countrypresence.install -text |
|
10 |
modules/countrypresence/countrypresence.module -text |
|
11 |
modules/countrypresence/googleMapCreator.php -text |
|
12 |
modules/smtp/INSTALL.txt -text |
|
13 |
modules/smtp/LICENSE.txt -text |
|
14 |
modules/smtp/README.txt -text |
|
15 |
modules/smtp/smtp.info -text |
|
16 |
modules/smtp/smtp.module -text |
|
17 |
modules/softwareTracker/images/EDIT_icon.gif -text |
|
18 |
modules/softwareTracker/softwareTracker.css -text |
|
19 |
modules/softwareTracker/softwareTracker.info -text |
|
20 |
modules/softwareTracker/softwareTracker.install -text |
|
21 |
modules/softwareTracker/softwareTracker.module -text |
|
22 |
modules/softwareTracker/softwareTracker.sql -text |
|
23 |
modules/taxon_experts/README.txt -text |
|
24 |
modules/taxon_experts/noderef_parent.info -text |
|
25 |
modules/taxon_experts/noderef_parent.module -text |
|
26 |
modules/taxon_experts/resources/geography-ed2_to_taxomomyXML.php -text |
|
27 |
modules/taxon_experts/resources/geography_ed2.zip -text |
|
28 |
modules/taxon_experts/resources/taxonomy_expertdb_activity.xml -text |
|
29 |
modules/taxon_experts/resources/taxonomy_expertdb_environment.xml -text |
|
30 |
modules/taxon_experts/resources/taxonomy_expertdb_georegions.xml -text |
|
31 |
modules/taxon_experts/resources/taxonomy_expertdb_methods.xml -text |
|
32 |
modules/taxon_experts/resources/taxonomy_expertdb_taxomony.xml -text |
|
33 |
modules/taxon_experts/taxon_experts.info -text |
|
34 |
modules/taxon_experts/taxon_experts.module -text |
|
35 |
modules/taxon_experts/template.taxon_experts.php -text |
|
36 |
themes/garland_EDIT/block.tpl.php -text |
|
37 |
themes/garland_EDIT/color/base.png -text |
|
38 |
themes/garland_EDIT/color/color.inc -text |
|
39 |
themes/garland_EDIT/color/preview.css -text |
|
40 |
themes/garland_EDIT/color/preview.png -text |
|
41 |
themes/garland_EDIT/comment.tpl.php -text |
|
42 |
themes/garland_EDIT/expertsdb/logo.png -text |
|
43 |
themes/garland_EDIT/expertsdb/style.css -text |
|
44 |
themes/garland_EDIT/expertsdb/style_expertsdb.css -text |
|
45 |
themes/garland_EDIT/field-field_parent_person.tpl.php -text |
|
46 |
themes/garland_EDIT/field.tpl.php -text |
|
47 |
themes/garland_EDIT/fix-ie.css -text |
|
48 |
themes/garland_EDIT/images/bg-bar-white.png -text |
|
49 |
themes/garland_EDIT/images/bg-bar.png -text |
|
50 |
themes/garland_EDIT/images/bg-content-left.png -text |
|
51 |
themes/garland_EDIT/images/bg-content-right.png -text |
|
52 |
themes/garland_EDIT/images/bg-content.png -text |
|
53 |
themes/garland_EDIT/images/bg-navigation-item-hover.png -text |
|
54 |
themes/garland_EDIT/images/bg-navigation-item.png -text |
|
55 |
themes/garland_EDIT/images/bg-navigation.png -text |
|
56 |
themes/garland_EDIT/images/bg-tab.png -text |
|
57 |
themes/garland_EDIT/images/body.png -text |
|
58 |
themes/garland_EDIT/images/gradient-inner.png -text |
|
59 |
themes/garland_EDIT/images/menu-collapsed.gif -text |
|
60 |
themes/garland_EDIT/images/menu-expanded.gif -text |
|
61 |
themes/garland_EDIT/images/menu-leaf.gif -text |
|
62 |
themes/garland_EDIT/logo.png -text |
|
63 |
themes/garland_EDIT/minnelli/color/Thumbs.db -text |
|
64 |
themes/garland_EDIT/minnelli/color/base.png -text |
|
65 |
themes/garland_EDIT/minnelli/color/color.inc -text |
|
66 |
themes/garland_EDIT/minnelli/color/preview.png -text |
|
67 |
themes/garland_EDIT/minnelli/favicon.ico -text |
|
68 |
themes/garland_EDIT/minnelli/logo.png -text |
|
69 |
themes/garland_EDIT/minnelli/screenshot.png -text |
|
70 |
themes/garland_EDIT/minnelli/style.css -text |
|
71 |
themes/garland_EDIT/node-expertsdb_address.tpl.php -text |
|
72 |
themes/garland_EDIT/node-expertsdb_interest.tpl.php -text |
|
73 |
themes/garland_EDIT/node.tpl.php -text |
|
74 |
themes/garland_EDIT/page.tpl.php -text |
|
75 |
themes/garland_EDIT/print.css -text |
|
76 |
themes/garland_EDIT/screenshot.png -text |
|
77 |
themes/garland_EDIT/style.css -text |
|
78 |
themes/garland_EDIT/template.php -text |
|
79 |
themes/zen_EDIT/LICENSE.txt -text |
|
80 |
themes/zen_EDIT/Thumbs.db -text |
|
81 |
themes/zen_EDIT/block.tpl.php -text |
|
82 |
themes/zen_EDIT/box.tpl.php -text |
|
83 |
themes/zen_EDIT/comment.tpl.php -text |
|
84 |
themes/zen_EDIT/favicon.ico -text |
|
85 |
themes/zen_EDIT/icons.css -text |
|
86 |
themes/zen_EDIT/images/Thumbs.db -text |
|
87 |
themes/zen_EDIT/images/background.png -text |
|
88 |
themes/zen_EDIT/images/blog.png -text |
|
89 |
themes/zen_EDIT/images/blue_bullet.gif -text |
|
90 |
themes/zen_EDIT/images/cog.png -text |
|
91 |
themes/zen_EDIT/images/container_bg.png -text |
|
92 |
themes/zen_EDIT/images/dialog-information_i.gif -text |
|
93 |
themes/zen_EDIT/images/dialog-warning.gif -text |
|
94 |
themes/zen_EDIT/images/icon_user.gif -text |
|
95 |
themes/zen_EDIT/images/links.gif -text |
|
96 |
themes/zen_EDIT/images/menu-collapsed.gif -text |
|
97 |
themes/zen_EDIT/images/menu-expanded.gif -text |
|
98 |
themes/zen_EDIT/images/menu-leaf.gif -text |
|
99 |
themes/zen_EDIT/images/page_text.gif -text |
|
100 |
themes/zen_EDIT/images/tabs.gif -text |
|
101 |
themes/zen_EDIT/layout.css -text |
|
102 |
themes/zen_EDIT/logo.png -text |
|
103 |
themes/zen_EDIT/node-forum.tpl.php -text |
|
104 |
themes/zen_EDIT/node.tpl.php -text |
|
105 |
themes/zen_EDIT/page.tpl.php -text |
|
106 |
themes/zen_EDIT/screenshot-drupal.org.png -text |
|
107 |
themes/zen_EDIT/screenshot.large.png -text |
|
108 |
themes/zen_EDIT/screenshot.png -text |
|
109 |
themes/zen_EDIT/style.css -text |
|
110 |
themes/zen_EDIT/template.php -text |
|
111 |
themes/zen_EDIT/zen-fixed/Thumbs.db -text |
|
112 |
themes/zen_EDIT/zen-fixed/favicon.ico -text |
|
113 |
themes/zen_EDIT/zen-fixed/logo.png -text |
|
114 |
themes/zen_EDIT/zen-fixed/screenshot.png -text |
|
115 |
themes/zen_EDIT/zen-fixed/style.css -text |
.gitignore | ||
---|---|---|
1 |
/.cache |
|
2 |
/.project |
|
3 |
/.settings |
module_patches/cck_field_perms/cck_field_perms-views0.1.patch | ||
---|---|---|
1 |
### Eclipse Workspace Patch 1.0 |
|
2 |
#P cck_field_perms |
|
3 |
Index: cck_field_perms.module |
|
4 |
=================================================================== |
|
5 |
RCS file: /cvs/drupal-contrib/contributions/modules/cck_field_perms/cck_field_perms.module,v |
|
6 |
retrieving revision 1.3.2.27 |
|
7 |
diff -u -r1.3.2.27 cck_field_perms.module |
|
8 |
--- cck_field_perms.module 27 Aug 2007 21:25:36 -0000 1.3.2.27 |
|
9 |
+++ cck_field_perms.module 7 Nov 2007 18:51:24 -0000 |
|
10 |
@@ -81,8 +81,9 @@ |
|
11 |
if ($disallowed_fields) { |
|
12 |
foreach ($disallowed_fields[$type] as $disallowed_field => $value ) { |
|
13 |
if ($value == 0) {continue; } |
|
14 |
- if (!(user_access(_cfp_content_to_readable($type, $disallowed_field, "view")))) { |
|
15 |
- $node->$disallowed_field['#access'] = false; |
|
16 |
+ if (!(user_access(_cfp_content_to_readable($type, $disallowed_field, "view")))) { |
|
17 |
+ $field_array = &$node->$disallowed_field; |
|
18 |
+ $field_array['#access'] = false; |
|
19 |
$node->content[$disallowed_field]['#access'] = false; |
|
20 |
} |
|
21 |
} |
|
22 |
@@ -112,6 +113,20 @@ |
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
+/** |
|
27 |
+ * Implemenation of hook views_pre_view |
|
28 |
+ */ |
|
29 |
+function cck_field_perms_views_pre_view(&$view, $items){ |
|
30 |
+ foreach($view->field as $idx => $field){ |
|
31 |
+ $field_name = substr($field['field'], 0, ( strlen($field['field']) - strlen('_value')) ); |
|
32 |
+ if(!cck_field_perms_access(null, $field_name, 'view')){ |
|
33 |
+ unset($view->field[$idx]); |
|
34 |
+ unset($view->table_header[$idx]); |
|
35 |
+ } |
|
36 |
+ } |
|
37 |
+} |
|
38 |
+ |
|
39 |
+ |
|
40 |
/* ********************************************* */ |
|
41 |
/* CFP functions */ |
|
42 |
/* ********************************************* */ |
|
43 |
@@ -237,6 +252,36 @@ |
|
44 |
} |
|
45 |
|
|
46 |
|
|
47 |
+function cck_field_perms_access($type, $field_name, $verb){ |
|
48 |
+ |
|
49 |
+ global $disallowed; |
|
50 |
+ if(!isset($disallowed)){ |
|
51 |
+ $disallowed = unserialize(variable_get('cfp_values', null)); |
|
52 |
+ if(!$disallowed) { |
|
53 |
+ $disallowed = array(); |
|
54 |
+ } |
|
55 |
+ } |
|
56 |
+ if(!$type){ |
|
57 |
+ // -------------- hack for missing admin option to set permissions on fields per view |
|
58 |
+ foreach($disallowed as $fields){ |
|
59 |
+ if( isset($fields[$field_name]) && $fields[$field_name] != 0) { |
|
60 |
+ // return false if access to this field is denied for at least one content type |
|
61 |
+ if(!user_access(_cfp_content_to_readable($type, $field_name, $verb))){ |
|
62 |
+ return false; |
|
63 |
+ } |
|
64 |
+ } |
|
65 |
+ } |
|
66 |
+ // ----------------------------------------------------------------------------------- |
|
67 |
+ } else { |
|
68 |
+ if( isset($disallowed[$type][$field_name]) && $disallowed[$type][$field_name] != 0 ) { |
|
69 |
+ return user_access(_cfp_content_to_readable($type, $field_name, $verb)); |
|
70 |
+ } |
|
71 |
+ } |
|
72 |
+ return true; |
|
73 |
+} |
|
74 |
+ |
|
75 |
+ |
|
76 |
+ |
|
77 |
/* ************************ */ |
|
78 |
/* ADMIN Functions */ |
|
79 |
/* ************************ */ |
module_patches/nodefamily/nodefamily_create-others-nodes.patch | ||
---|---|---|
1 |
### Eclipse Workspace Patch 1.0 |
|
2 |
#P Drupal_CVS |
|
3 |
Index: nodefamily/nodefamily.module |
|
4 |
=================================================================== |
|
5 |
RCS file: /cvs/drupal-contrib/contributions/modules/nodefamily/nodefamily.module,v |
|
6 |
retrieving revision 1.19.2.14 |
|
7 |
diff -u -r1.19.2.14 nodefamily.module |
|
8 |
--- nodefamily/nodefamily.module 4 Oct 2007 08:53:48 -0000 1.19.2.14 |
|
9 |
+++ nodefamily/nodefamily.module 12 Nov 2007 16:41:57 -0000 |
|
10 |
@@ -31,6 +31,15 @@ |
|
11 |
return $items; |
|
12 |
} |
|
13 |
|
|
14 |
+/** |
|
15 |
+ * Additional permission to allow users to create profiles for other users |
|
16 |
+ */ |
|
17 |
+function nodefamily_perm() { |
|
18 |
+ return array( |
|
19 |
+ 'create others nodes', |
|
20 |
+ ); |
|
21 |
+} |
|
22 |
+ |
|
23 |
|
|
24 |
/** |
|
25 |
* Menu callback; provide the means to add and remove relations between |
|
26 |
@@ -183,7 +192,7 @@ |
|
27 |
break; |
|
28 |
|
|
29 |
case 'validate': |
|
30 |
- if (!$node->nid && user_access('administer nodes')) { |
|
31 |
+ if (!$node->nid && ( user_access('administer nodes') || user_access('create others nodes')) ) { |
|
32 |
if ($account = user_load(array('name' => $node->name))) { |
|
33 |
$node->uid = $account->uid; |
|
34 |
} |
|
35 |
@@ -198,7 +207,14 @@ |
|
36 |
} |
|
37 |
break; |
|
38 |
case 'submit': |
|
39 |
- if ($node->nid && user_access('administer nodes')) { |
|
40 |
+ // adjust uid if $node->nid && user_access('create others nodes'): |
|
41 |
+ // since node_submit() is not aware of 'create others nodes'!! |
|
42 |
+ if (!$node->nid && user_access('create others nodes')) { |
|
43 |
+ if ($account = user_load(array('name' => $node->name))) { |
|
44 |
+ $node->uid = $account->uid; |
|
45 |
+ } |
|
46 |
+ } |
|
47 |
+ if ($node->nid && ( user_access('administer nodes') || user_access('create others nodes') ) ) { |
|
48 |
$parents = nodefamily_get_parent_types($node->type); |
|
49 |
$children = nodefamily_get_child_types($node->type); |
|
50 |
$oldnode = node_load($node->nid); |
|
51 |
@@ -256,7 +272,7 @@ |
|
52 |
} |
|
53 |
else if (($form['#node_type']) && $form['#node_type']->type .'_node_form' == $form_id) { |
|
54 |
$node = $form['#node']; |
|
55 |
- if (!$node->nid && !user_access('administer nodes') && nodefamily_content_type_is_max($node->type, $node->uid)) { |
|
56 |
+ if (!$node->nid && !user_access('administer nodes') && !user_access('create others nodes') && nodefamily_content_type_is_max($node->type, $node->uid)) { |
|
57 |
drupal_set_message(t("You can't create any more nodes of this type."), 'error'); |
|
58 |
$form = NULL; |
|
59 |
} |
modules/countrypresence/country-earth.prj | ||
---|---|---|
1 |
GEOGCS["Unknown",DATUM["D_WGS_1984",SPHEROID["World_Geodetic_System_of_1984",6378137,298.257222932867]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] |
modules/countrypresence/countrypresence.info | ||
---|---|---|
1 |
; $Id$ |
|
2 |
name = Country Presence |
|
3 |
description = Provides a country presence data type which is plotted on a Google Map. |
|
4 |
version = "$Name$" |
|
5 |
package = "Edit" |
modules/countrypresence/countrypresence.install | ||
---|---|---|
1 |
<?php |
|
2 |
// $Id$ |
|
3 |
|
|
4 |
/** |
|
5 |
* Implementation of hook_install |
|
6 |
*/ |
|
7 |
function countrypresence_install() { |
|
8 |
drupal_set_message(t('Country Presence module - INSTALLED!')); |
|
9 |
switch ($GLOBALS['db_type']) { |
|
10 |
case 'mysql': |
|
11 |
case 'mysqli': |
|
12 |
db_query("CREATE TABLE {countrypresence} ( |
|
13 |
vid int unsigned NOT NULL default '0', |
|
14 |
country_id int unsigned NOT NULL default '0', |
|
15 |
PRIMARY KEY (vid, country_id) |
|
16 |
);"); |
|
17 |
break; |
|
18 |
} |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* Implementation of hook_uninstall() |
|
23 |
*/ |
|
24 |
function countrypresence_uninstall() { |
|
25 |
db_query('DROP TABLE {countrypresence}'); |
|
26 |
} |
modules/countrypresence/countrypresence.module | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/** |
|
6 |
* @file |
|
7 |
* Provides a "country presence" node type |
|
8 |
*/ |
|
9 |
|
|
10 |
/** |
|
11 |
* Implementation of hook_node_info() |
|
12 |
*/ |
|
13 |
function countrypresence_node_info() { |
|
14 |
// Return an array since a module can define multiple node types |
|
15 |
return array( |
|
16 |
'countrypresence' => array( |
|
17 |
'name' => t('Country Presence'), |
|
18 |
'module' => 'countrypresence', |
|
19 |
'description' => t('Enables a map of countries to be drawn for an object'), |
|
20 |
'has_title' => TRUE, |
|
21 |
'title_label' => t('Object'), |
|
22 |
'has_body' => FALSE |
|
23 |
) |
|
24 |
); |
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* Implementation of hook_menu() |
|
29 |
*/ |
|
30 |
function countrypresence_menu($may_cache) { |
|
31 |
$items=array(); |
|
32 |
|
|
33 |
// Do not cache this menu item during the development of this module |
|
34 |
if (!$may_cache) { |
|
35 |
$items[] = array( |
|
36 |
'path' => 'node/add/countrypresence', |
|
37 |
'title' => t('Country Presence'), |
|
38 |
'access' => user_access('create country presence') |
|
39 |
); |
|
40 |
} |
|
41 |
$items[] = array('path' => 'admin/content/countrypresence/import', |
|
42 |
'title' => t('Import'), |
|
43 |
'access' => user_access('create countrypresence content')||user_access('administer nodes'), |
|
44 |
'callback' => 'countrypresence_import'); |
|
45 |
return $items; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Implementation of hook_perm() |
|
50 |
*/ |
|
51 |
function countrypresence_perm() { |
|
52 |
return array('create country presence', 'edit country presence', 'edit own country presence'); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* Implementation of hook_access() |
|
57 |
*/ |
|
58 |
function countrypresence_access($op, $node) { |
|
59 |
global $user; |
|
60 |
|
|
61 |
if ($op=='create') { |
|
62 |
return (user_access('create country presence')); |
|
63 |
} |
|
64 |
|
|
65 |
if ($op == 'update' || $op == 'delete') { |
|
66 |
return ((user_access('edit own country presence') && ($user->uid == $node->uid))||user_access('edit country presence')); |
|
67 |
} |
|
68 |
if ($op == 'view') { |
|
69 |
return true; |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Implementation of hook_form() |
|
75 |
*/ |
|
76 |
function countrypresence_form($node) { |
|
77 |
// Get metadata for this node type |
|
78 |
// (we use it for labeling title and body fields) |
|
79 |
// We defined this in joke_node_info() |
|
80 |
$type = node_get_types('type', $node); |
|
81 |
|
|
82 |
$form['title'] = array( |
|
83 |
'#type' => 'textfield', |
|
84 |
'#title' => check_plain($type->title_label), |
|
85 |
'#default_value' => $node->title |
|
86 |
); |
|
87 |
|
|
88 |
$africa = array(3 => "Algeria", 5 => "Angola", 19 => "Benin", 24 => "Botswana", 28 => "Burkina Faso", 29 => "Burundi", 32 => "Cameroon", 34 => "Cape Verde", 35 => "Central African Republic", 36 => "Chad", 40 => "Comoros", 41 => "Congo", 48 => "Djibouti", 52 => "Egypt", 54 => "Equatorial Guinea", 55 => "Eritrea", 57 => "Ethiopia", 65 => "Gabon", 66 => "Gambia", 70 => "Ghana", 77 => "Guinea-Bissau", 76 => "Guinea", 93 => "Ivory Coast", 99 => "Kenya", 100 => "Kerguelen Islands", 109 => "Lesotho", 110 => "Liberia", 111 => "Libya", 117 => "Madagascar", 118 => "Malawi", 121 => "Mali", 124 => "Mauritania", 125 => "Mauritius", 130 => "Morocco", 130 => "Morocco", 131 => "Mozambique", 133 => "Namibia", 140 => "Nigeria", 139 => "Niger", 151 => "Portugal", 154 => "Reunion", 157 => "Rwanda", 159 => "Sao Tome and Principe", 161 => "Senegal", 162 => "Seychelles", 163 => "Sierra Leone", 168 => "Somalia", 169 => "South Africa", 170 => "Spain", 175 => "Sudan", 178 => "Swaziland", 184 => "Tanzania", 186 => "Togo", 189 => "Tunisia", 193 => "Uganda", 203 => "Western Sahara", 207 => "Democratic Republic of Congo", 208 => "Zambia", 209 => "Zimbabwe"); |
|
89 |
$asia = array(1 => "Afghanistan", 9 => "Armenia", 12 => "Azerbaijan", 14 => "Bahrain", 15 => "Bangladesh", 21 => "Bhutan", 26 => "Brunei", 31 => "Cambodia", 38 => "China", 45 => "Cyprus", 67 => "Gaza Strip", 68 => "Georgia", 81 => "Hong Kong", 84 => "India", 85 => "Indonesia", 86 => "Iran", 87 => "Iraq", 91 => "Israel", 96 => "Japan", 97 => "Jordan", 98 => "Kazakhstan", 104 => "Kuwait", 105 => "Kyrgyzstan", 106 => "Laos", 108 => "Lebanon", 115 => "Macau", 119 => "Malaysia", 120 => "Maldives", 129 => "Mongolia", 132 => "Myanmar [Burma]", 134 => "Nepal", 102 => "North Korea", 143 => "Oman", 144 => "Pakistan", 146 => "Papua New Guinea", 149 => "Philippines", 153 => "Qatar", 156 => "Russia", 160 => "Saudi Arabia", 164 => "Singapore", 103 => "South Korea", 171 => "Sri Lanka", 181 => "Syria", 182 => "Taiwan", 183 => "Tajikistan", 185 => "Thailand", 190 => "Turkey", 191 => "Turkmenistan", 195 => "United Arab Emirates", 199 => "Uzbekistan", 202 => "Vietnam", 205 => "Yemen"); |
|
90 |
$europe = array(2 => "Albania", 4 => "Andorra", 11 => "Austria", 17 => "Belgium", 17 => "Belgium", 23 => "Bosnia and Herzegovina", 27 => "Bulgaria", 30 => "Byelarus", 43 => "Croatia", 46 => "Czech Republic", 47 => "Denmark", 56 => "Estonia", 59 => "Faroe Islands", 61 => "Finland", 62 => "France", 62 => "France", 69 => "Germany", 71 => "Greece", 82 => "Hungary", 83 => "Iceland", 89 => "Ireland", 90 => "Isle of Man", 92 => "Italy", 92 => "Italy", 95 => "Jan Mayen", 107 => "Latvia", 112 => "Liechtenstein", 113 => "Lithuania", 114 => "Luxembourg", 114 => "Luxembourg", 116 => "Macedonia", 122 => "Malta", 127 => "Moldova", 128 => "Monaco", 135 => "Netherlands", 142 => "Norway", 150 => "Poland", 151 => "Portugal", 155 => "Romania", 158 => "San Marino", 165 => "Slovakia", 166 => "Slovenia", 170 => "Spain", 177 => "Svalbard", 179 => "Sweden", 180 => "Switzerland", 194 => "Ukraine", 196 => "United Kingdom", 206 => "Serbia and Montenegro"); |
|
91 |
$namerica = array(7 => "Antigua / Barbuda", 13 => "Bahamas", 16 => "Barbados", 18 => "Belize", 20 => "Bermuda", 33 => "Canada", 42 => "Costa Rica", 44 => "Cuba", 49 => "Dominica", 50 => "Dominican Republic", 53 => "El Salvador", 72 => "Greenland", 73 => "Grenada", 74 => "Guadalupe", 75 => "Guatemala", 79 => "Haiti", 80 => "Honduras", 94 => "Jamaica", 123 => "Martinique", 126 => "Mexico", 138 => "Nicaragua", 145 => "Panama", 152 => "Puerto Rico", 172 => "St. Kitts and Nevis", 173 => "St. Lucia", 174 => "St. Vincent and the Grenadines", 188 => "Trinidad and Tobago", 192 => "Turks and Caicos Islands", 197 => "United States of America"); |
|
92 |
$oceania = array(10 => "Australia", 60 => "Fiji", 64 => "French Polynesia", 101 => "Kiribati", 136 => "New Caledonia", 137 => "New Zealand", 141 => "Northern Mariana Islands", 146 => "Papua New Guinea", 167 => "Solomon Islands", 187 => "Tonga", 197 => "United States", 200 => "Vanuatu", 204 => "Western Samoa"); |
|
93 |
$samerica = array(8 => "Argentina", 22 => "Bolivia", 25 => "Brazil", 37 => "Chile", 39 => "Colombia", 51 => "Ecuador", 58 => "Falkland Islands", 63 => "French Guiana", 78 => "Guyana", 147 => "Paraguay", 148 => "Peru", 176 => "Suriname", 198 => "Uruguay", 201 => "Venezuela"); |
|
94 |
|
|
95 |
$form['africa'] = array( |
|
96 |
'#type' => 'fieldset', |
|
97 |
'#title' => 'Africa', |
|
98 |
'#collapsible' => TRUE, |
|
99 |
'#collapsed' => TRUE |
|
100 |
); |
|
101 |
$form['africa']['countries'] = array( |
|
102 |
'#title' => t('Countries'), |
|
103 |
'#type' => 'checkboxes', |
|
104 |
'#DANGEROUS_SKIP_CHECK' => TRUE, |
|
105 |
'#options' => $africa, |
|
106 |
'#default_value' => $node->countries |
|
107 |
); |
|
108 |
$form['asia'] = array( |
|
109 |
'#type' => 'fieldset', |
|
110 |
'#title' => 'Asia', |
|
111 |
'#collapsible' => TRUE, |
|
112 |
'#collapsed' => TRUE |
|
113 |
); |
|
114 |
$form['asia']['countries'] = array( |
|
115 |
'#title' => t('Countries'), |
|
116 |
'#type' => 'checkboxes', |
|
117 |
'#DANGEROUS_SKIP_CHECK' => TRUE, |
|
118 |
'#options' => $asia, |
|
119 |
'#default_value' => $node->countries |
|
120 |
); |
|
121 |
$form['europe'] = array( |
|
122 |
'#type' => 'fieldset', |
|
123 |
'#title' => 'Europe', |
|
124 |
'#collapsible' => TRUE, |
|
125 |
'#collapsed' => TRUE |
|
126 |
); |
|
127 |
$form['europe']['countries'] = array( |
|
128 |
'#title' => t('Countries'), |
|
129 |
'#type' => 'checkboxes', |
|
130 |
'#DANGEROUS_SKIP_CHECK' => TRUE, |
|
131 |
'#options' => $europe, |
|
132 |
'#default_value' => $node->countries |
|
133 |
); |
|
134 |
$form['namerica'] = array( |
|
135 |
'#type' => 'fieldset', |
|
136 |
'#title' => 'North America', |
|
137 |
'#collapsible' => TRUE, |
|
138 |
'#collapsed' => TRUE |
|
139 |
); |
|
140 |
$form['namerica']['countries'] = array( |
|
141 |
'#title' => t('Countries'), |
|
142 |
'#type' => 'checkboxes', |
|
143 |
'#DANGEROUS_SKIP_CHECK' => TRUE, |
|
144 |
'#options' => $namerica, |
|
145 |
'#default_value' => $node->countries |
|
146 |
); |
|
147 |
$form['oceania'] = array( |
|
148 |
'#type' => 'fieldset', |
|
149 |
'#title' => 'Oceania', |
|
150 |
'#collapsible' => TRUE, |
|
151 |
'#collapsed' => TRUE |
|
152 |
); |
|
153 |
$form['oceania']['countries'] = array( |
|
154 |
'#title' => t('Countries'), |
|
155 |
'#type' => 'checkboxes', |
|
156 |
'#DANGEROUS_SKIP_CHECK' => TRUE, |
|
157 |
'#options' => $oceania, |
|
158 |
'#default_value' => $node->countries |
|
159 |
); |
|
160 |
$form['samerica'] = array( |
|
161 |
'#type' => 'fieldset', |
|
162 |
'#title' => 'South America', |
|
163 |
'#collapsible' => TRUE, |
|
164 |
'#collapsed' => TRUE |
|
165 |
); |
|
166 |
$form['samerica']['countries'] = array( |
|
167 |
'#title' => t('Countries'), |
|
168 |
'#type' => 'checkboxes', |
|
169 |
'#DANGEROUS_SKIP_CHECK' => TRUE, |
|
170 |
'#options' => $samerica, |
|
171 |
'#default_value' => $node->countries |
|
172 |
); |
|
173 |
$form['submit'] = array( |
|
174 |
'#type' => 'submit', |
|
175 |
'#value' => t('Import'), |
|
176 |
); |
|
177 |
return $form; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* Implementation of hook_insert() |
|
182 |
*/ |
|
183 |
function countrypresence_insert($node) { |
|
184 |
foreach ($node->countries as $country) { |
|
185 |
if ($country!==0) |
|
186 |
db_query('INSERT INTO {countrypresence} (vid, country_id) VALUES (%d, %d)', $node->vid, $country); |
|
187 |
} |
|
188 |
db_query('INSERT INTO {content_type_countrypresence} (vid, nid) VALUES (%d, %d)', $node->vid, $node->nid); |
|
189 |
} |
|
190 |
/** |
|
191 |
* Implementation of hook_load() |
|
192 |
*/ |
|
193 |
function countrypresence_load($node) { |
|
194 |
$result = db_query('SELECT country_id FROM {countrypresence} WHERE vid = %d', $node->vid); |
|
195 |
while ($object = db_fetch_object($result)) { |
|
196 |
$node->countries[$object->country_id]=$object->country_id; |
|
197 |
} |
|
198 |
} |
|
199 |
/** |
|
200 |
* Implementation of hook_update() |
|
201 |
*/ |
|
202 |
function countrypresence_update($node) { |
|
203 |
if ($node->revision) { |
|
204 |
countrypresence_insert($node); |
|
205 |
} |
|
206 |
else { |
|
207 |
db_query('DELETE FROM {countrypresence} WHERE vid = %d', $node->vid); |
|
208 |
foreach ($node->countries as $country) { |
|
209 |
if ($country!==0) |
|
210 |
db_query("INSERT INTO {countrypresence} (vid, country_id) VALUES (%d, %d)", $node->vid, $country); |
|
211 |
} |
|
212 |
} |
|
213 |
} |
|
214 |
/** |
|
215 |
* Implementation of hook_delete() |
|
216 |
*/ |
|
217 |
function countrypresence_delete(&$node) { |
|
218 |
db_query('DELETE FROM {countrypresence} WHERE vid IN (SELECT vid FROM {content_type_countrypresence} WHERE nid = %d)', $node->nid); |
|
219 |
db_query('DELETE FROM {content_type_countrypresence} WHERE nid = %d', $node->nid); |
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
* Implementation of hook_view() |
|
224 |
*/ |
|
225 |
function countrypresence_view($node, $teaser = FALSE, $page=FALSE) { |
|
226 |
if (!$teaser) { |
|
227 |
// Use Drupal's default node view. |
|
228 |
$node = node_prepare($node, $teaser); |
|
229 |
|
|
230 |
$node->content['gmap'] = array( |
|
231 |
'#value' => theme('countrypresence_gmap', $node) |
|
232 |
); |
|
233 |
} |
|
234 |
if ($teaser) { |
|
235 |
// Use Drupal's default node view. |
|
236 |
$node = node_prepare($node, $teaser);// FIXME |
|
237 |
} |
|
238 |
return $node; |
|
239 |
} |
|
240 |
function theme_countrypresence_gmap($node) { |
|
241 |
$apikey = variable_get("googlemap_api_key", ""); |
|
242 |
$output =''; |
|
243 |
if (isset($node->countries[156])&&$node->countries[156]==156) { |
|
244 |
$output .='<p class="error">Unfortunately Russia is displaying incorrectly on this page. We hope to fix this soon.</p>'; |
|
245 |
} |
|
246 |
$output .= '<div id="map"></div><p>Maps are created using <a href="http://www.gdal.org/ogr/ogr2ogr.html">ogr2ogr</a>, and the excellent <a href="http://www.casa.ucl.ac.uk/software/googlemapcreator.asp">Google maps creator</a></p> |
|
247 |
<script type="text/javascript" |
|
248 |
src="http://maps.google.com/maps?file=api&v=2&key='. $apikey .'"> |
|
249 |
</script> |
|
250 |
<script type="text/javascript" |
|
251 |
src="/sites/all/modules/countrypresence/googleMapCreator.php?countries='; |
|
252 |
$output_string = ""; |
|
253 |
if (isset($node->countries)&&count($node->countries)>0) { |
|
254 |
foreach ($node->countries as $country) { |
|
255 |
if ($output_string!="") |
|
256 |
$output_string .=","; |
|
257 |
$output_string .=$country; |
|
258 |
} |
|
259 |
} |
|
260 |
$output .= $output_string .'&apikey='. $apikey .'">'; |
|
261 |
$output .=' |
|
262 |
</script> |
|
263 |
<script type="text/javascript"> |
|
264 |
load(); |
|
265 |
</script>'; |
|
266 |
return $output; |
|
267 |
} |
|
268 |
|
|
269 |
// Import Portion (Taken and edited from a previously created module). |
|
270 |
/** |
|
271 |
* Menu callback for the import page. |
|
272 |
*/ |
|
273 |
function countrypresence_import() { |
|
274 |
return drupal_get_form('countrypresence_import_form'); |
|
275 |
} |
|
276 |
|
|
277 |
/** |
|
278 |
* Imports the actual file. |
|
279 |
*/ |
|
280 |
function countrypresence_import_form_validate($form_id, $form_values) { |
|
281 |
if ($file = file_check_upload('data')) { |
|
282 |
$fd = fopen($file->filepath, "rb"); |
|
283 |
$info = fstat($fd); |
|
284 |
$len = $info["size"]; |
|
285 |
$text = fread($fd, $len); |
|
286 |
fclose($fd); |
|
287 |
if (!$fd) |
|
288 |
form_set_error('data', t('Import failed: file %filename cannot be read.', array('%filename' => $file->filename))); |
|
289 |
else |
|
290 |
countrypresence_parse($text); |
|
291 |
} |
|
292 |
else |
|
293 |
form_set_error('data', t('Vocabulary import failed: file was not uploaded.')); |
|
294 |
} |
|
295 |
/** |
|
296 |
* Builds the import form. |
|
297 |
*/ |
|
298 |
function countrypresence_import_form() { |
|
299 |
$form['data'] = array( |
|
300 |
'#type' => 'file', |
|
301 |
'#title' => t('File to import'), |
|
302 |
'#description' => t('Click "Browse..." to select a file to upload.'), |
|
303 |
'#required' => FALSE |
|
304 |
); |
|
305 |
$form['submit'] = array( |
|
306 |
'#type' => 'submit', |
|
307 |
'#value' => t('Import'), |
|
308 |
); |
|
309 |
$form['#attributes'] = array('enctype' => 'multipart/form-data'); |
|
310 |
return $form; |
|
311 |
} |
|
312 |
|
|
313 |
function countrypresence_parse($text) { |
|
314 |
// Let's parse the file. This relies on the first line being the countries (and their codes in Brakets), |
|
315 |
// with the first column being the specimen names (for each of which a new node will be created). |
|
316 |
|
|
317 |
// Firstly we need to know the next available "nid" and "vid", these are incremented for each node. |
|
318 |
// Let's first get the lowest value for "tid", upon which we will build all the |
|
319 |
// other values. |
|
320 |
$sql = "SELECT `id` FROM {sequences} WHERE `name`='node_nid';"; |
|
321 |
$result = db_query($sql); |
|
322 |
$nid = db_fetch_object($result); |
|
323 |
$nid = $nid->id+1; |
|
324 |
$sql = "SELECT `id` FROM {sequences} WHERE `name`='node_revisions_vid';"; |
|
325 |
$result = db_query($sql); |
|
326 |
$vid = db_fetch_object($result); |
|
327 |
$vid = $vid->id+1; |
|
328 |
|
|
329 |
$lines = preg_split("/[\n\r]+/", $text); |
|
330 |
$num_lines = count($lines); |
|
331 |
|
|
332 |
$countries = split(",", $lines[0]); |
|
333 |
$num_countries = count($countries); |
|
334 |
for ($i=1;$i<$num_countries;$i++) { |
|
335 |
$open_bracket_pos = strpos($countries[$i], "(")+1; |
|
336 |
$close_bracket_pos = strpos($countries[$i], ")"); |
|
337 |
$countries[$i] = substr($countries[$i], $open_bracket_pos, $close_bracket_pos-$open_bracket_pos); |
|
338 |
} |
|
339 |
// All of the lines must have the same number of parts as the first line (possibly with one less |
|
340 |
// as the final part could be missing. (i.e. name,1,1,1, - would split to "name","1","1","1" , only |
|
341 |
// four parts as opposed to five). |
|
342 |
|
|
343 |
// We need to add data to the following tables: |
|
344 |
// node |
|
345 |
// node_revisions |
|
346 |
// content_field_[continent]*7 |
|
347 |
// For each, therefore we need an SQL statement. |
|
348 |
|
|
349 |
// SQL: |
|
350 |
// node - INSERT INTO node (nid,vid,type,title,uid,created,changed) VALUES ( -- FILLED IN BELOW --); |
|
351 |
// node_revisions - INSERT INTO node_revisions (nid,vid,uid,title,timestamp) VALUES ( -- FILLED IN BELOW --); |
|
352 |
// countrypresence - INSERT INTO {countrypresence} (vid,country_id) VALUES "; |
|
353 |
// content_type_countrypresence - INSERT INTO content_type_countrypresence (nid,vid) VALUES ( -- FILLED IN BELOW --); |
|
354 |
$sql_statements = array(); |
|
355 |
$sql_statements['node'] = "INSERT INTO {node} (nid,vid,type,title,uid,created,changed) VALUES "; |
|
356 |
$sql_statements['revisions']="INSERT INTO {node_revisions} (nid,vid,uid,title,timestamp) VALUES "; |
|
357 |
$sql_statements['countrypresence']="INSERT INTO {countrypresence} (vid,country_id) VALUES "; |
|
358 |
$sql_statements['content_type_countrypresence']="INSERT INTO {content_type_countrypresence} (nid,vid) VALUES "; |
|
359 |
global $user; |
|
360 |
for ($i=1;$i<$num_lines;$i++) { |
|
361 |
// Split each subsequent line by "," and check it has the right number of parts |
|
362 |
$line_parts = split(",", $lines[$i]); |
|
363 |
$sql_statements['node'] .="($nid,$vid,'countrypresence','". $line_parts[0] ."',". $user->uid .",". time() .",". time() ."),"; |
|
364 |
$sql_statements['revisions'] .="($nid,$vid,". $user->uid .",'". $line_parts[0] ."',". time() ."),"; |
|
365 |
$sql_statements['content_type_countrypresence'] .="($nid,$vid),"; |
|
366 |
for ($j=1;$j<$num_countries;$j++) { |
|
367 |
// Next add the data to each of the fields tables, this relies on the data being present in the |
|
368 |
// headers of the file. |
|
369 |
if (isset($line_parts[$j]) && trim($line_parts[$j])==1) {// Check the value is set |
|
370 |
// The value is set, check against the country_data array to see what SQL to add |
|
371 |
$sql_statements['countrypresence'] .="($vid,". $countries[$j] ."),"; |
|
372 |
} |
|
373 |
} |
|
374 |
// increase nid and vid; |
|
375 |
$nid ++; |
|
376 |
$vid ++; |
|
377 |
} |
|
378 |
// Check that each SQL ends with a "," if not, ignore it, if it does, replace with ";" and execute. |
|
379 |
$sql =""; |
|
380 |
foreach ($sql_statements as $sql_statement) { |
|
381 |
if (substr($sql_statement, -1)==",") |
|
382 |
db_query(substr($sql_statement, 0, -1) .";"); |
|
383 |
} |
|
384 |
// Finally update the sequence table |
|
385 |
$sql = "UPDATE {sequences} SET `id`=$nid WHERE `name`='node_nid';"; |
|
386 |
db_query($sql); |
|
387 |
$sql = "UPDATE {sequences} SET `id`=$vid WHERE `name`='node_revisions_vid';"; |
|
388 |
db_query($sql); |
|
389 |
|
|
390 |
// Send the user to the last of the imports |
|
391 |
drupal_goto("node/". ($nid-1)); |
|
392 |
} |
modules/countrypresence/googleMapCreator.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/* |
|
4 |
* An attempt at automatic map generation using: |
|
5 |
* - ogr2ogr - which will combine shape files |
|
6 |
* - Google map creator - which will create the google maps from a single shape file. |
|
7 |
* |
|
8 |
* This script returns JavaScript, therefore it can be embedded on ANY page! |
|
9 |
*/ |
|
10 |
|
|
11 |
// We take as arguments to this script the two letter country codes of countries |
|
12 |
// we wish to include within out map. This means that we can easily expand this |
|
13 |
// to include any world countries (not just African ones), althoughh this may require |
|
14 |
// three letters! |
|
15 |
|
|
16 |
// Following temp filename is used in the configuration section, and therefore needs to come |
|
17 |
// before it. |
|
18 |
$tmp_file_name = tempnam("/tmp","googlemaps"); |
|
19 |
$tmp_file_name = substr($tmp_file_name,5); |
|
20 |
$tmp_file = "/tmp/".$tmp_file_name; |
|
21 |
|
|
22 |
// Configuration ----------------------------------------------------------------------- |
|
23 |
$earth_shape_file = dirname(__FILE__)."/country-earth.shp"; |
|
24 |
$maps_extensions = array("dbf","shp","shx","prj","xml"); // Not too sure which of these IS needed. |
|
25 |
$ogr2ogr_path = "/usr/share/fwtools/bin_safe/ogr2ogr"; |
|
26 |
$gmap_creator_path = "/var/www/html/sites/all/gmap/gmapcreator.jar"; |
|
27 |
if (!isset($_GET['apikey'])||$_GET['apikey']==""){ |
|
28 |
?>alert('EDIT GMap colourer: You must supply an API key');<?php |
|
29 |
exit; |
|
30 |
} |
|
31 |
$google_api_key = $_GET['apikey']; |
|
32 |
$gmap_settings_xml = "<gmapcreator> |
|
33 |
<apikey>".$google_api_key."</apikey> |
|
34 |
<apiversion>2</apiversion> |
|
35 |
<maptitle>Test Map</maptitle> |
|
36 |
<shpfilename>".$tmp_file_name.".shp</shpfilename> |
|
37 |
<outlinesenabled>true</outlinesenabled> |
|
38 |
<maxzoomlevel>5</maxzoomlevel> |
|
39 |
<datafield>IDR_ID</datafield> |
|
40 |
<limitarea>false</limitarea> |
|
41 |
<mapboundswgs84> |
|
42 |
<minlat>-55.72056961021754</minlat> |
|
43 |
<minlon>-180.0</minlon> |
|
44 |
<maxlat>83.62303161612134</maxlat> |
|
45 |
<maxlon>179.99981689453125</maxlon> |
|
46 |
</mapboundswgs84> |
|
47 |
<mapviewenvelope> |
|
48 |
<minx>-2.1397475258323826E7</minx> |
|
49 |
<maxx>2.139745487511628E7</maxx> |
|
50 |
<miny>-9944658.00979416</miny> |
|
51 |
<maxy>2.0852293210672483E7</maxy> |
|
52 |
</mapviewenvelope> |
|
53 |
<colourscale> |
|
54 |
<isdiscrete>true</isdiscrete> |
|
55 |
<colourThresholds> |
|
56 |
<colourThreshold> |
|
57 |
<colour>ff0000ff</colour> |
|
58 |
<threshold>0.0</threshold> |
|
59 |
<description>First Colour</description> |
|
60 |
</colourThreshold> |
|
61 |
</colourThresholds> |
|
62 |
</colourscale> |
|
63 |
</gmapcreator> |
|
64 |
"; |
|
65 |
if (!isset($_GET['countries'])){ |
|
66 |
|
|
67 |
// The countries have not been sent! Error. |
|
68 |
?>alert('EDIT GMap colourer: You haven\'t supplied any countries');<?php |
|
69 |
exit; |
|
70 |
} |
|
71 |
|
|
72 |
// Get the countries. |
|
73 |
$countries = split(",",$_GET['countries']); |
|
74 |
|
|
75 |
// Extract each country from the "Earth shape" and add it to the previous. |
|
76 |
// If this is the first country, there is no adding!) |
|
77 |
for($i=0;$i<count($countries);$i++){ |
|
78 |
$exec = $ogr2ogr_path . ' ' . $tmp_file . $i . '.shp -fid ' . ($countries[$i]-1) . ' ' . $earth_shape_file; |
|
79 |
exec($exec); |
|
80 |
if ($i==0){ |
|
81 |
$exec = $ogr2ogr_path . ' ' . $tmp_file . '.shp ' . $tmp_file . $i . '.shp'; |
|
82 |
exec($exec); |
|
83 |
} |
|
84 |
else{ |
|
85 |
$exec = $ogr2ogr_path . ' -update -append ' . $tmp_file.'.shp ' . $tmp_file . $i . '.shp -nln ' . $tmp_file_name; |
|
86 |
exec($exec); |
|
87 |
} |
|
88 |
} |
|
89 |
// Once this is done, we can have a go at creating the GoogleMap from the command line. |
|
90 |
// Firstly, create the settings file |
|
91 |
file_put_contents($tmp_file.".xml",$gmap_settings_xml); |
|
92 |
// Next copy the projection file |
|
93 |
copy($maps_directory."projection.prj",$tmp_file.".prj"); |
|
94 |
// Mv the temp files to the semi temp folder, don't forget to delete them afterwards! |
|
95 |
foreach($maps_extensions as $map_extension){ |
|
96 |
@copy($tmp_file.".".$map_extension,"/var/www/html/sites/all/gmap".$tmp_file.".".$map_extension); |
|
97 |
} |
|
98 |
$exec = "cd /var/www/html/sites/all/gmap/tmp && /usr/bin/java -jar ".$gmap_creator_path." -dfile=".$tmp_file_name.".xml"; |
|
99 |
exec($exec); |
|
100 |
?> |
|
101 |
var centreLat=3.477775573709623; |
|
102 |
var centreLon=10.218469619750977; |
|
103 |
var n_buttonText="Map"; //Text that shows up on the button for the custom layer (n=normal, s=sat) |
|
104 |
var s_buttonText="Satellite"; |
|
105 |
var mapBounds=new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)); |
|
106 |
var map; //the GMap2 itself |
|
107 |
var opacity=0.75; |
|
108 |
|
|
109 |
|
|
110 |
function customGetTileURL(a,b) { |
|
111 |
//converts tile x,y into keyhole string |
|
112 |
if (b>5) { return "/sites/all/gmap/tmp/<?php echo $tmp_file_name; ?>-tiles/blank-tile.png"; }; |
|
113 |
|
|
114 |
var c=Math.pow(2,b); |
|
115 |
var x=360/c*a.x-180; |
|
116 |
var y=180-360/c*a.y; |
|
117 |
var x2=x+360/c; |
|
118 |
var y2=y-360/c; |
|
119 |
var lon=x; //Math.toRadians(x); //would be lon=x+lon0, but lon0=0 degrees |
|
120 |
var lat=(2.0*Math.atan(Math.exp(y/180*Math.PI))-Math.PI/2.0)*180/Math.PI; //in degrees |
|
121 |
var lon2=x2; |
|
122 |
var lat2=(2.0*Math.atan(Math.exp(y2/180*Math.PI))-Math.PI/2.0)*180/Math.PI; //in degrees |
|
123 |
var tileBounds=new GLatLngBounds(new GLatLng(lat2,lon),new GLatLng(lat,lon2)); |
|
124 |
|
|
125 |
if (!tileBounds.intersects(mapBounds)) { return "/sites/all/gmap/tmp/<?php echo $tmp_file_name; ?>-tiles/blank-tile.png"; }; |
|
126 |
var d=a.x; |
|
127 |
var e=a.y; |
|
128 |
var f="t"; |
|
129 |
for(var g=0;g<b;g++){ |
|
130 |
c=c/2; |
|
131 |
if(e<c){ |
|
132 |
if(d<c){f+="q"} |
|
133 |
else{f+="r";d-=c} |
|
134 |
} |
|
135 |
else{ |
|
136 |
if(d<c){f+="t";e-=c} |
|
137 |
else{f+="s";d-=c;e-=c} |
|
138 |
} |
|
139 |
} |
|
140 |
return "/sites/all/gmap/tmp/<?php echo $tmp_file_name; ?>-tiles/"+f+".png" |
|
141 |
} |
|
142 |
|
|
143 |
function changeOpacity(op) { |
|
144 |
//this works as long as there are at least two map types |
|
145 |
var current=map.getCurrentMapType(); |
|
146 |
if (current==map.getMapTypes()[0]) |
|
147 |
map.setMapType(map.getMapTypes()[1]); |
|
148 |
else |
|
149 |
map.setMapType(map.getMapTypes()[0]); |
|
150 |
opacity=op; |
|
151 |
map.setMapType(current); //was map.getMapTypes()[1] |
|
152 |
} |
|
153 |
|
|
154 |
|
|
155 |
function getWindowHeight() { |
|
156 |
if (window.self&&self.innerHeight) { |
|
157 |
return self.innerHeight; |
|
158 |
} |
|
159 |
if (document.documentElement&&document.documentElement.clientHeight) { |
|
160 |
return document.documentElement.clientHeight; |
|
161 |
} |
|
162 |
return 0; |
|
163 |
} |
|
164 |
|
|
165 |
function resizeMapDiv() { |
|
166 |
//Resize the height of the div containing the map. |
|
167 |
//Do not call any map methods here as the resize is called before the map is created. |
|
168 |
var d=document.getElementById("map"); |
|
169 |
var offsetTop=0; |
|
170 |
for (var elem=d; elem!=null; elem=elem.offsetParent) { |
|
171 |
offsetTop+=elem.offsetTop; |
|
172 |
} |
|
173 |
var height=getWindowHeight()-offsetTop-16; |
|
174 |
if (height>=0) { |
|
175 |
d.style.height=height+"px"; |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
|
|
180 |
function load() { |
|
181 |
if (GBrowserIsCompatible()) { |
|
182 |
resizeMapDiv(); |
|
183 |
var copyright = new GCopyright(1, |
|
184 |
new GLatLngBounds(new GLatLng(-90, -180), |
|
185 |
new GLatLng(90, 180)), |
|
186 |
0, |
|
187 |
"<a href=\"http://www.casa.ucl.ac.uk\">CASA</a>"); |
|
188 |
var copyrightCollection = new GCopyrightCollection("GMapCreator"); |
|
189 |
copyrightCollection.addCopyright(copyright); |
|
190 |
|
|
191 |
//create a custom G_NORMAL_MAP layer |
|
192 |
var n_tileLayers = [ G_NORMAL_MAP.getTileLayers()[0], new GTileLayer(copyrightCollection , 0, 17)]; |
|
193 |
n_tileLayers[1].getTileUrl = customGetTileURL; |
|
194 |
n_tileLayers[1].isPng = function() { return false; }; |
|
195 |
n_tileLayers[1].getOpacity = function() { return opacity; }; |
|
196 |
var n_customMap = new GMapType(n_tileLayers, new GMercatorProjection(6), n_buttonText, |
|
197 |
{maxResolution:5, minResolution:0, errorMessage:"Data not available"}); |
|
198 |
|
|
199 |
//create a custom G_SATELLITE_MAP layer |
|
200 |
var s_tileLayers = [ G_SATELLITE_MAP.getTileLayers()[0], new GTileLayer(copyrightCollection , 0, 17)]; |
|
201 |
s_tileLayers[1].getTileUrl = customGetTileURL; |
|
202 |
s_tileLayers[1].isPng = function() { return false; }; |
|
203 |
s_tileLayers[1].getOpacity = function() { return opacity; }; |
|
204 |
var s_customMap = new GMapType(s_tileLayers, new GMercatorProjection(6), s_buttonText, |
|
205 |
{maxResolution:5, minResolution:0, errorMessage:"Data not available"}); |
|
206 |
|
|
207 |
//Now create the custom map. Would normally be G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP |
|
208 |
map = new GMap2(document.getElementById("map"),{mapTypes:[n_customMap,s_customMap]}); |
|
209 |
map.addControl(new GLargeMapControl()); |
|
210 |
map.addControl(new GMapTypeControl()); |
|
211 |
map.enableContinuousZoom(); |
|
212 |
map.setCenter(new GLatLng(centreLat, centreLon), 2, n_customMap); |
|
213 |
map.enableDoubleClickZoom(); |
|
214 |
/* |
|
215 |
var point = new GLatLng(0,0); |
|
216 |
var marker = new GMarker(point); |
|
217 |
GEvent.addListener(marker, "click", function() { |
|
218 |
marker.openInfoWindowHtml("More stuff"); |
|
219 |
}); |
|
220 |
map.addOverlay(marker); |
|
221 |
*/ |
|
222 |
} |
|
223 |
} |
modules/smtp/INSTALL.txt | ||
---|---|---|
1 |
// $Id: INSTALL.txt,v 1.5 2006/12/31 15:53:00 lukelast Exp $ |
|
2 |
|
|
3 |
INSTALL INSTRUCTIONS FOR SMTP.MODULE |
|
4 |
---- |
|
5 |
|
|
6 |
1. Copy smtp.module and smtp.info files to your Drupal modules/ folder. |
|
7 |
2. Login at site administrator. |
|
8 |
3. Activate smtp.module on the administer->modules page. |
|
9 |
4. Fill in required settings on the administer->Site configuration->SMTP support page. |
|
10 |
5. Enjoy. |
|
11 |
|
|
12 |
Notes: |
|
13 |
This version of the module is designed for DRUPAL 5.0 only. |
modules/smtp/LICENSE.txt | ||
---|---|---|
1 |
GNU GENERAL PUBLIC LICENSE |
|
2 |
|
|
3 |
Version 2, June 1991 |
|
4 |
|
|
5 |
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, |
|
6 |
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute |
|
7 |
verbatim copies of this license document, but changing it is not allowed. |
|
8 |
|
|
9 |
Preamble |
|
10 |
|
|
11 |
The licenses for most software are designed to take away your freedom to |
|
12 |
share and change it. By contrast, the GNU General Public License is |
|
13 |
intended to guarantee your freedom to share and change free software--to |
|
14 |
make sure the software is free for all its users. This General Public License |
|
15 |
applies to most of the Free Software Foundation's software and to any other |
|
16 |
program whose authors commit to using it. (Some other Free Software |
|
17 |
Foundation software is covered by the GNU Library General Public License |
|
18 |
instead.) You can apply it to your programs, too. |
|
19 |
|
|
20 |
When we speak of free software, we are referring to freedom, not price. Our |
|
21 |
General Public Licenses are designed to make sure that you have the |
|
22 |
freedom to distribute copies of free software (and charge for this service if |
|
23 |
you wish), that you receive source code or can get it if you want it, that you |
|
24 |
can change the software or use pieces of it in new free programs; and that |
|
25 |
you know you can do these things. |
|
26 |
|
|
27 |
To protect your rights, we need to make restrictions that forbid anyone to |
|
28 |
deny you these rights or to ask you to surrender the rights. These restrictions |
|
29 |
translate to certain responsibilities for you if you distribute copies of the |
|
30 |
software, or if you modify it. |
|
31 |
|
|
32 |
For example, if you distribute copies of such a program, whether gratis or for |
|
33 |
a fee, you must give the recipients all the rights that you have. You must make |
|
34 |
sure that they, too, receive or can get the source code. And you must show |
|
35 |
them these terms so they know their rights. |
|
36 |
|
|
37 |
We protect your rights with two steps: (1) copyright the software, and (2) |
|
38 |
offer you this license which gives you legal permission to copy, distribute |
|
39 |
and/or modify the software. |
|
40 |
|
|
41 |
Also, for each author's protection and ours, we want to make certain that |
|
42 |
everyone understands that there is no warranty for this free software. If the |
|
43 |
software is modified by someone else and passed on, we want its recipients |
|
44 |
to know that what they have is not the original, so that any problems |
|
45 |
introduced by others will not reflect on the original authors' reputations. |
|
46 |
|
|
47 |
Finally, any free program is threatened constantly by software patents. We |
|
48 |
wish to avoid the danger that redistributors of a free program will individually |
|
49 |
obtain patent licenses, in effect making the program proprietary. To prevent |
|
50 |
this, we have made it clear that any patent must be licensed for everyone's |
|
51 |
free use or not licensed at all. |
|
52 |
|
|
53 |
The precise terms and conditions for copying, distribution and modification |
|
54 |
follow. |
|
55 |
|
|
56 |
GNU GENERAL PUBLIC LICENSE |
|
57 |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND |
|
58 |
MODIFICATION |
|
59 |
|
|
60 |
0. This License applies to any program or other work which contains a notice |
|
61 |
placed by the copyright holder saying it may be distributed under the terms |
|
62 |
of this General Public License. The "Program", below, refers to any such |
|
63 |
program or work, and a "work based on the Program" means either the |
|
64 |
Program or any derivative work under copyright law: that is to say, a work |
|
65 |
containing the Program or a portion of it, either verbatim or with |
|
66 |
modifications and/or translated into another language. (Hereinafter, translation |
|
67 |
is included without limitation in the term "modification".) Each licensee is |
|
68 |
addressed as "you". |
|
69 |
|
|
70 |
Activities other than copying, distribution and modification are not covered |
|
71 |
by this License; they are outside its scope. The act of running the Program is |
|
72 |
not restricted, and the output from the Program is covered only if its contents |
|
73 |
constitute a work based on the Program (independent of having been made |
|
74 |
by running the Program). Whether that is true depends on what the Program |
|
75 |
does. |
|
76 |
|
|
77 |
1. You may copy and distribute verbatim copies of the Program's source |
|
78 |
code as you receive it, in any medium, provided that you conspicuously and |
|
79 |
appropriately publish on each copy an appropriate copyright notice and |
|
80 |
disclaimer of warranty; keep intact all the notices that refer to this License |
|
81 |
and to the absence of any warranty; and give any other recipients of the |
|
82 |
Program a copy of this License along with the Program. |
|
83 |
|
|
84 |
You may charge a fee for the physical act of transferring a copy, and you |
|
85 |
may at your option offer warranty protection in exchange for a fee. |
|
86 |
|
|
87 |
2. You may modify your copy or copies of the Program or any portion of it, |
|
88 |
thus forming a work based on the Program, and copy and distribute such |
|
89 |
modifications or work under the terms of Section 1 above, provided that you |
|
90 |
also meet all of these conditions: |
|
91 |
|
|
92 |
a) You must cause the modified files to carry prominent notices stating that |
|
93 |
you changed the files and the date of any change. |
|
94 |
|
|
95 |
b) You must cause any work that you distribute or publish, that in whole or in |
|
96 |
part contains or is derived from the Program or any part thereof, to be |
|
97 |
licensed as a whole at no charge to all third parties under the terms of this |
|
98 |
License. |
|
99 |
|
|
100 |
c) If the modified program normally reads commands interactively when run, |
|
101 |
you must cause it, when started running for such interactive use in the most |
|
102 |
ordinary way, to print or display an announcement including an appropriate |
|
103 |
copyright notice and a notice that there is no warranty (or else, saying that |
|
104 |
you provide a warranty) and that users may redistribute the program under |
|
105 |
these conditions, and telling the user how to view a copy of this License. |
|
106 |
(Exception: if the Program itself is interactive but does not normally print such |
|
107 |
an announcement, your work based on the Program is not required to print |
|
108 |
an announcement.) |
|
109 |
|
|
110 |
These requirements apply to the modified work as a whole. If identifiable |
|
111 |
sections of that work are not derived from the Program, and can be |
|
112 |
reasonably considered independent and separate works in themselves, then |
|
113 |
this License, and its terms, do not apply to those sections when you distribute |
|
114 |
them as separate works. But when you distribute the same sections as part |
|
115 |
of a whole which is a work based on the Program, the distribution of the |
|
116 |
whole must be on the terms of this License, whose permissions for other |
|
117 |
licensees extend to the entire whole, and thus to each and every part |
|
118 |
regardless of who wrote it. |
|
119 |
|
|
120 |
Thus, it is not the intent of this section to claim rights or contest your rights to |
|
121 |
work written entirely by you; rather, the intent is to exercise the right to |
|
122 |
control the distribution of derivative or collective works based on the |
|
123 |
Program. |
|
124 |
|
|
125 |
In addition, mere aggregation of another work not based on the Program |
|
126 |
with the Program (or with a work based on the Program) on a volume of a |
|
127 |
storage or distribution medium does not bring the other work under the scope |
|
128 |
of this License. |
|
129 |
|
|
130 |
3. You may copy and distribute the Program (or a work based on it, under |
|
131 |
Section 2) in object code or executable form under the terms of Sections 1 |
|
132 |
and 2 above provided that you also do one of the following: |
|
133 |
|
|
134 |
a) Accompany it with the complete corresponding machine-readable source |
|
135 |
code, which must be distributed under the terms of Sections 1 and 2 above |
|
136 |
on a medium customarily used for software interchange; or, |
|
137 |
|
|
138 |
b) Accompany it with a written offer, valid for at least three years, to give |
|
139 |
any third party, for a charge no more than your cost of physically performing |
|
140 |
source distribution, a complete machine-readable copy of the corresponding |
|
141 |
source code, to be distributed under the terms of Sections 1 and 2 above on |
|
142 |
a medium customarily used for software interchange; or, |
|
143 |
|
|
144 |
c) Accompany it with the information you received as to the offer to distribute |
|
145 |
corresponding source code. (This alternative is allowed only for |
|
146 |
noncommercial distribution and only if you received the program in object |
|
147 |
code or executable form with such an offer, in accord with Subsection b |
|
148 |
above.) |
|
149 |
|
|
150 |
The source code for a work means the preferred form of the work for |
|
151 |
making modifications to it. For an executable work, complete source code |
|
152 |
means all the source code for all modules it contains, plus any associated |
|
153 |
interface definition files, plus the scripts used to control compilation and |
|
154 |
installation of the executable. However, as a special exception, the source |
|
155 |
code distributed need not include anything that is normally distributed (in |
|
156 |
either source or binary form) with the major components (compiler, kernel, |
|
157 |
and so on) of the operating system on which the executable runs, unless that |
|
158 |
component itself accompanies the executable. |
|
159 |
|
|
160 |
If distribution of executable or object code is made by offering access to |
|
161 |
copy from a designated place, then offering equivalent access to copy the |
|
162 |
source code from the same place counts as distribution of the source code, |
|
163 |
even though third parties are not compelled to copy the source along with the |
|
164 |
object code. |
|
165 |
|
|
166 |
4. You may not copy, modify, sublicense, or distribute the Program except as |
|
167 |
expressly provided under this License. Any attempt otherwise to copy, |
|
168 |
modify, sublicense or distribute the Program is void, and will automatically |
|
169 |
terminate your rights under this License. However, parties who have received |
|
170 |
copies, or rights, from you under this License will not have their licenses |
|
171 |
terminated so long as such parties remain in full compliance. |
|
172 |
|
|
173 |
5. You are not required to accept this License, since you have not signed it. |
|
174 |
However, nothing else grants you permission to modify or distribute the |
|
175 |
Program or its derivative works. These actions are prohibited by law if you |
|
176 |
do not accept this License. Therefore, by modifying or distributing the |
|
177 |
Program (or any work based on the Program), you indicate your acceptance |
|
178 |
of this License to do so, and all its terms and conditions for copying, |
|
179 |
distributing or modifying the Program or works based on it. |
|
180 |
|
|
181 |
6. Each time you redistribute the Program (or any work based on the |
|
182 |
Program), the recipient automatically receives a license from the original |
|
183 |
licensor to copy, distribute or modify the Program subject to these terms and |
|
184 |
conditions. You may not impose any further restrictions on the recipients' |
|
185 |
exercise of the rights granted herein. You are not responsible for enforcing |
|
186 |
compliance by third parties to this License. |
|
187 |
|
|
188 |
7. If, as a consequence of a court judgment or allegation of patent |
|
189 |
infringement or for any other reason (not limited to patent issues), conditions |
|
190 |
are imposed on you (whether by court order, agreement or otherwise) that |
|
191 |
contradict the conditions of this License, they do not excuse you from the |
|
192 |
conditions of this License. If you cannot distribute so as to satisfy |
|
193 |
simultaneously your obligations under this License and any other pertinent |
|
194 |
obligations, then as a consequence you may not distribute the Program at all. |
|
195 |
For example, if a patent license would not permit royalty-free redistribution |
|
196 |
of the Program by all those who receive copies directly or indirectly through |
|
197 |
you, then the only way you could satisfy both it and this License would be to |
|
198 |
refrain entirely from distribution of the Program. |
|
199 |
|
|
200 |
If any portion of this section is held invalid or unenforceable under any |
|
201 |
particular circumstance, the balance of the section is intended to apply and |
|
202 |
the section as a whole is intended to apply in other circumstances. |
|
203 |
|
|
204 |
It is not the purpose of this section to induce you to infringe any patents or |
|
205 |
other property right claims or to contest validity of any such claims; this |
|
206 |
section has the sole purpose of protecting the integrity of the free software |
|
207 |
distribution system, which is implemented by public license practices. Many |
|
208 |
people have made generous contributions to the wide range of software |
|
209 |
distributed through that system in reliance on consistent application of that |
|
210 |
system; it is up to the author/donor to decide if he or she is willing to |
|
211 |
distribute software through any other system and a licensee cannot impose |
|
212 |
that choice. |
|
213 |
|
|
214 |
This section is intended to make thoroughly clear what is believed to be a |
|
215 |
consequence of the rest of this License. |
|
216 |
|
|
217 |
8. If the distribution and/or use of the Program is restricted in certain |
|
218 |
countries either by patents or by copyrighted interfaces, the original copyright |
|
219 |
holder who places the Program under this License may add an explicit |
|
220 |
geographical distribution limitation excluding those countries, so that |
|
221 |
distribution is permitted only in or among countries not thus excluded. In such |
|
222 |
case, this License incorporates the limitation as if written in the body of this |
|
223 |
License. |
|
224 |
|
|
225 |
9. The Free Software Foundation may publish revised and/or new versions |
|
226 |
of the General Public License from time to time. Such new versions will be |
|
227 |
similar in spirit to the present version, but may differ in detail to address new |
|
228 |
problems or concerns. |
|
229 |
|
|
230 |
Each version is given a distinguishing version number. If the Program specifies |
|
231 |
a version number of this License which applies to it and "any later version", |
|
232 |
you have the option of following the terms and conditions either of that |
|
233 |
version or of any later version published by the Free Software Foundation. If |
|
234 |
the Program does not specify a version number of this License, you may |
|
235 |
choose any version ever published by the Free Software Foundation. |
|
236 |
|
|
237 |
10. If you wish to incorporate parts of the Program into other free programs |
|
238 |
whose distribution conditions are different, write to the author to ask for |
|
239 |
permission. For software which is copyrighted by the Free Software |
|
240 |
Foundation, write to the Free Software Foundation; we sometimes make |
|
241 |
exceptions for this. Our decision will be guided by the two goals of |
|
242 |
preserving the free status of all derivatives of our free software and of |
|
243 |
promoting the sharing and reuse of software generally. |
|
244 |
|
|
245 |
NO WARRANTY |
|
246 |
|
|
247 |
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, |
|
248 |
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT |
|
249 |
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE |
|
250 |
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR |
|
251 |
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT |
|
252 |
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, |
|
253 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
|
254 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
255 |
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND |
|
256 |
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
|
257 |
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|
258 |
NECESSARY SERVICING, REPAIR OR CORRECTION. |
|
259 |
|
|
260 |
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR |
|
261 |
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR |
|
262 |
ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
263 |
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE |
|
264 |
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, |
|
265 |
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES |
|
266 |
ARISING OUT OF THE USE OR INABILITY TO USE THE |
|
267 |
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA |
|
268 |
OR DATA BEING RENDERED INACCURATE OR LOSSES |
|
269 |
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE |
|
270 |
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN |
|
271 |
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF |
|
272 |
THE POSSIBILITY OF SUCH DAMAGES. |
|
273 |
|
|
274 |
END OF TERMS AND CONDITIONS |
modules/smtp/README.txt | ||
---|---|---|
1 |
// $Id: README.txt,v 1.9 2007/02/15 19:37:30 lukelast Exp $ |
|
2 |
|
|
3 |
SMTP MODULE for DRUPAL 5.0 |
|
4 |
This module adds SMTP functionality to Drupal. |
|
5 |
|
|
6 |
INSTALL INSTRUCTIONS |
|
7 |
---- |
|
8 |
1. Copy smtp.module and smtp.info files to your Drupal modules/ folder. |
|
9 |
2. Login as site administrator. |
|
10 |
3. Activate smtp.module on the administer->modules page. |
|
11 |
4. Fill in required settings on the administer->Site configuration->SMTP support page. |
|
12 |
5. Enjoy. |
|
13 |
|
|
14 |
Notes: |
|
15 |
|
|
16 |
This module sends email by connecting to an SMTP server. |
|
17 |
Therefore you need to have access to an SMTP server for this module to work. |
|
18 |
|
|
19 |
Drupal will often use the email address entered into "Administrator>Site configuration>E-mail address" |
|
20 |
as the from address. It is important for this to be the correct address and some ISPs will block email |
|
21 |
that comes from an invalid address. |
|
22 |
|
|
23 |
Because this module includes PHPMailer it is rather large and may cause PHP to run out of memory if |
|
24 |
its memory limit is small. |
|
25 |
|
|
26 |
Connecting to an SMTP server using SSL is possible only if PHP's openssl extension is working. |
|
27 |
If the SMTP module detects openssl is available it will display the options in the modules settings page. |
|
28 |
|
|
29 |
Sending mail to gmail requires SSL or TLS. |
|
30 |
|
|
31 |
This module uses the smtp and mail class's from PHPMailer. |
|
32 |
http://phpmailer.sourceforge.net |
modules/smtp/smtp.info | ||
---|---|---|
1 |
; $Id: smtp.info,v 1.2 2007/02/15 19:37:03 lukelast Exp $ |
|
2 |
name = SMTP |
|
3 |
description = Allows the sending of site email to an SMTP server. |
|
4 |
package = "Mail" |
|
5 |
; Information added by drupal.org packaging script on 2007-06-24 |
|
6 |
version = "5.x-1.x-dev" |
|
7 |
project = "smtp" |
|
8 |
datestamp = "1182657130" |
|
9 |
|
modules/smtp/smtp.module | ||
---|---|---|
1 |
<?php |
|
2 |
// $Id: smtp.module,v 1.15 2007/05/28 20:02:41 lukelast Exp $ |
|
3 |
|
|
4 |
/** |
|
5 |
* @file |
|
6 |
* Enables drupal to send email directly to an SMTP server using authentication. |
|
7 |
* Uses the PHPMailer class by Brent R. Matzelle. |
|
8 |
* |
|
9 |
* Overriding mail handling in drupal requires setting the smtp_library variable with the |
|
10 |
* filename of a file containing a user_mail_wrapper() function. |
|
11 |
* This module sets the smtp_library value to point back to this file which contains the |
|
12 |
* user_mail_wrapper() function that uses the PHPMailer to send email instead of the |
|
13 |
* PHP mail() class. |
|
14 |
* |
|
15 |
* @link http://phpmailer.sourceforge.net |
|
16 |
*/ |
|
17 |
|
|
18 |
/** |
|
19 |
* Implementation of hook_menu(). |
|
20 |
*/ |
|
21 |
function smtp_menu($may_cache) { |
|
22 |
$items = array(); |
|
23 |
if ($may_cache) { |
|
24 |
$items[] = array( |
|
25 |
'path' => 'admin/settings/smtp', |
|
26 |
'title' => t('SMTP support'), |
|
27 |
'description' => t('Allows the sending of site email to an SMTP server of your choice.'), |
|
28 |
'callback' => 'drupal_get_form', |
|
29 |
'callback arguments' => 'smtp_admin_settings', |
|
30 |
'type' => MENU_NORMAL_ITEM, |
|
31 |
); |
|
32 |
} |
|
33 |
return $items; |
|
34 |
} |
|
35 |
|
|
36 |
/** |
|
37 |
* Settings Hook |
|
38 |
* |
|
39 |
* @return |
|
40 |
* An array containing form items to place on the module settings page. |
|
41 |
*/ |
|
42 |
function smtp_admin_settings() { |
|
43 |
// only administrators can access this module |
|
44 |
if (!user_access('administer site configuration')) { |
|
45 |
return message_access(); |
|
46 |
} |
|
47 |
|
|
48 |
//Override the smtp_library variable. |
|
49 |
if (variable_get('smtp_on', 0)) { |
|
50 |
$smtp_path = drupal_get_filename('module', 'smtp'); |
|
51 |
if ($smtp_path){ |
|
52 |
variable_set('smtp_library', $smtp_path); |
|
53 |
drupal_set_message(t('SMTP.module is active.')); |
|
54 |
} |
|
55 |
else { //If drupal can't find the path to the module. |
|
56 |
drupal_set_message(t("SMTP.module error: Can't find file."), 'error'); |
|
57 |
} |
|
58 |
} |
|
59 |
else { //If smtp is turned off delete the variable. |
|
60 |
variable_del('smtp_library'); |
|
61 |
drupal_set_message(t('SMTP.module is INACTIVE.')); |
|
62 |
} |
|
63 |
|
|
64 |
$form['onoff'] = array('#type' => 'fieldset', '#title' => t('Install options')); |
|
65 |
$form['onoff']['smtp_on'] = array( |
|
66 |
'#type' => 'radios', |
|
67 |
'#title' => t('Turn this module On or Off'), |
|
68 |
'#default_value' => variable_get('smtp_on', 1), |
|
69 |
'#options' => array(1 => 'On', 0 => 'Off'), |
|
70 |
'#description' => t('To uninstall this module you must turn it off here first.')); |
|
71 |
|
|
72 |
$form['server'] = array('#type' => 'fieldset', '#title' => t('SMTP server settings')); |
|
73 |
$form['server']['smtp_host'] = array( |
|
74 |
'#type' => 'textfield', |
|
75 |
'#title' => t('SMTP Server'), |
|
76 |
'#default_value' => variable_get('smtp_host', ''), |
|
77 |
'#description' => t('The address of your outgoing SMTP server.')); |
|
78 |
$form['server']['smtp_hostbackup'] = array( |
|
79 |
'#type' => 'textfield', |
|
80 |
'#title' => t('SMTP Backup Server'), |
|
81 |
'#default_value' => variable_get('smtp_hostbackup', ''), |
|
82 |
'#description' => t('The address of your outgoing SMTP backup server. If the primary server can\'t be found this one will be tried. This is optional.')); |
|
83 |
$form['server']['smtp_port'] = array( |
|
84 |
'#type' => 'textfield', |
|
85 |
'#title' => t('SMTP port'), |
|
86 |
'#size' => 4, |
|
87 |
'#maxlength' => 4, |
|
88 |
'#default_value' => variable_get('smtp_port', '25'), |
|
89 |
'#description' => t('The default SMTP port is 25, if that is being blocked try 80. Gmail uses 465.')); |
|
90 |
if (function_exists('openssl_open')){ //Only display the option if openssl is installed. |
|
91 |
$form['server']['smtp_protocol'] = array( |
|
92 |
'#type' => 'select', |
|
93 |
'#title' => t('Use encrypted protocol'), |
|
94 |
'#default_value' => variable_get('smtp_protocol', 'standard'), |
|
95 |
'#options' => array('standard' => t('No'), 'ssl' => t('Use SSL'), 'tls' => t('Use TLS')), |
|
96 |
'#description' => t('This allows connection to an SMTP server that requires SSL encryption such as gmail.')); |
|
97 |
} |
|
98 |
else{ //If openssl is not installed use normal protocol. |
|
99 |
variable_set('smtp_protocol', 'standard'); |
|
100 |
} |
|
101 |
|
|
102 |
$form['auth'] = array('#type' => 'fieldset', '#title' => t('SMTP Authentication'), '#description' => t('Leave blank if your SMTP server does not require authentication.')); |
|
103 |
$form['auth']['smtp_username'] = array( |
|
104 |
'#type' => 'textfield', |
|
105 |
'#title' => t('Username'), |
|
106 |
'#default_value' => variable_get('smtp_username', ''), |
|
107 |
'#description' => t('SMTP Username.')); |
|
108 |
$form['auth']['smtp_password'] = array( |
|
109 |
'#type' => 'textfield', |
|
110 |
'#title' => t('Password'), |
|
111 |
'#default_value' => variable_get('smtp_password', ''), |
|
112 |
'#description' => t('SMTP password.')); |
|
113 |
|
|
114 |
$form['email_options'] = array('#type' => 'fieldset', '#title' => t('E-mail options')); |
|
115 |
$form['email_options']['smtp_from'] = array( |
|
116 |
'#type' => 'textfield', |
|
117 |
'#title' => t('E-mail from'), |
|
118 |
'#default_value' => variable_get('smtp_from', ''), |
|
119 |
'#description' => t('The E-mail-address that all emails will be from.') |
|
120 |
); |
|
121 |
$form['email_options']['smtp_fromname'] = array( |
|
122 |
'#type' => 'textfield', |
|
123 |
'#title' => t('E-mail from Name'), |
|
124 |
'#default_value' => variable_get('smtp_fromname', ''), |
|
125 |
'#description' => t('The name that all emails will be from. If left blank will use the site name of: ') . variable_get('site_name', 'Drupal powered site')); |
|
126 |
|
|
127 |
//If an address was given, send a test email message. |
|
128 |
$test_address = variable_get('smtp_test_address', ''); |
|
129 |
if ($test_address != ''){ |
|
130 |
variable_del('smtp_test_address'); //Clear the variable so only one message is sent. |
|
131 |
drupal_mail('smtp-test', $test_address, t('Drupal test email'), t('If you receive this message it means your site is capable of sending email.'), variable_get('site_mail', ini_get('sendmail_from'))); |
|
132 |
drupal_set_message(t('A test E-mail has been sent to @email. You may want to !check for any error messages.', array('@email' => $test_address, '!check' => l(t('check the logs'), 'admin/logs/watchdog')))); |
|
133 |
} |
|
134 |
|
|
135 |
$form['email_test'] = array('#type' => 'fieldset', '#title' => t('Send test E-mail')); |
|
136 |
$form['email_test']['smtp_test_address'] = array( |
|
137 |
'#type' => 'textfield', |
|
138 |
'#title' => t('E-mail address to send test email too'), |
|
139 |
'#default_value' => '', |
|
140 |
'#description' => t('Type in an address to have a test email sent there.')); |
|
141 |
|
|
142 |
return system_settings_form($form); |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Sends out the email. |
|
147 |
* |
|
148 |
* @param $mailkey |
|
149 |
* A key to identify the mail sent, for altering. |
|
150 |
* @param $to |
|
151 |
* string email address to send to. |
|
152 |
* @param $subject |
|
153 |
* string subject of email. |
|
154 |
* @param $body |
|
155 |
* string body of message. |
|
156 |
* @param $header |
|
157 |
* string of header lines seperated by "\n". |
|
158 |
*/ |
|
159 |
function drupal_mail_wrapper($mailkey, $to, $subject, $body, $from, $header) { |
|
160 |
$mail = new phpmailer(); //Create a new phpmailer object. |
|
161 |
$username = variable_get('smtp_username', ''); |
|
162 |
$password = variable_get('smtp_password', ''); |
|
163 |
|
|
164 |
//Set the default name emails should be from. If value is not defined in settings use site_name. |
Also available in: Unified diff