-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.php
160 lines (124 loc) · 6.37 KB
/
start.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
include_once(dirname(__FILE__) . '/models/model.php');
function hypeCompanies_init() {
global $CONFIG;
if (!is_plugin_enabled('hypeFramework')) {
register_error('hypeFramework is not enabled. hypeCompanies will not work properly. Visit www.hypeJunction.com for details');
}
register_action('company/get_companies', true, $CONFIG->pluginspath . 'hypeCompanies/actions/get_companies.php', false);
register_action('company/setlatlng', false, $CONFIG->pluginspath . 'hypeCompanies/actions/setlatlng.php', false);
register_action('company/save', false, $CONFIG->pluginspath . 'hypeCompanies/actions/save.php', false);
register_action('company/delete', false, $CONFIG->pluginspath . 'hypeCompanies/actions/delete.php', false);
register_action('company/savebranch', false, $CONFIG->pluginspath . 'hypeCompanies/actions/savebranch.php', false);
register_action('company/branchform', false, $CONFIG->pluginspath . 'hypeCompanies/actions/branchform.php', false);
register_entity_type('object', 'company');
register_entity_type('object', 'branchcompany');
register_page_handler('companies', 'hypeCompanies_page_handler');
register_entity_url_handler('hypeCompanies_url_handler', 'object', 'company');
register_entity_url_handler('hypeCompanies_branch_url_handler', 'object', 'branchcompany');
elgg_extend_view('profile/icon', 'hypeCompanies/icon');
register_plugin_hook('entity:icon:url', 'object', 'company_icon_hook');
elgg_extend_view('css', 'hypeCompanies/css');
elgg_extend_view('input', 'hypeCompanies/filter');
elgg_extend_view('page_elements/header', 'hypeCompanies/maps/metatags');
elgg_extend_view('index/righthandside', 'hypeCompanies/latest');
add_menu(elgg_echo('hypeCompanies:menu'), $CONFIG->wwwroot . 'pg/companies/all');
}
function hypeCompanies_pagesetup() {
global $CONFIG;
//add submenu options
if (get_context() == "companies") {
add_submenu_item(elgg_echo('hypeCompanies:everyone'), $CONFIG->wwwroot . "pg/companies/all/");
add_submenu_item(elgg_echo('hypeCompanies:neighbourhood'), $CONFIG->wwwroot . "pg/companies/neighbourhood");
if (isloggedin ()) {
add_submenu_item(elgg_echo('hypeCompanies:network'), $CONFIG->wwwroot . "pg/companies/network/" . $_SESSION['user']->username);
if (canCreateCompany(get_loggedin_user())) {
add_submenu_item(elgg_echo('hypeCompanies:your'), $CONFIG->wwwroot . "pg/companies/owner/" . $_SESSION['user']->username);
add_submenu_item(elgg_echo('hypeCompanies:addcompany'), $CONFIG->wwwroot . "pg/companies/new/{$_SESSION['user']->username}/");
}
}
}
}
function hypeCompanies_page_handler($page) {
global $CONFIG;
if (isset($page[0])) {
switch ($page[0]) {
case 'neighbourhood' :
include($CONFIG->pluginspath . 'hypeCompanies/views/default/hypeCompanies/pages/neighbourhood.php');
break;
case 'network' :
set_input('username', $page[1]);
include($CONFIG->pluginspath . 'hypeCompanies/views/default/hypeCompanies/pages/network.php');
break;
case 'owner' :
set_input('username', $page[1]);
include($CONFIG->pluginspath . 'hypeCompanies/views/default/hypeCompanies/pages/owner.php');
break;
case 'new' :
set_input('username', $page[1]);
include($CONFIG->pluginspath . 'hypeCompanies/views/default/hypeCompanies/pages/new.php');
break;
case 'edit' :
set_input('company_guid', $page[1]);
include($CONFIG->pluginspath . 'hypeCompanies/views/default/hypeCompanies/pages/edit.php');
break;
case 'icon':
if (isset($page[1])) {
set_input('company_guid', $page[1]);
}
if (isset($page[2])) {
set_input('size', $page[2]);
}
include($CONFIG->pluginspath . "hypeCompanies/graphics/hypeCompanies/icon.php");
break;
case 'view' :
set_input('company_guid', $page[1]);
include($CONFIG->pluginspath . 'hypeCompanies/views/default/hypeCompanies/pages/company.php');
break;
case 'all' :
default :
include($CONFIG->pluginspath . 'hypeCompanies/views/default/hypeCompanies/pages/all.php');
break;
}
} else {
register_error(elgg_echo('hypeCompanies:error'));
forward($_SERVER['HTTP_REFERER']);
}
}
function company_icon_hook($hook, $entity_type, $returnvalue, $params) {
global $CONFIG;
if ((!$returnvalue) && ($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggObject) && ($params['entity']->getSubtype() == 'company')) {
$entity = $params['entity'];
$size = $params['size'];
$filehandler = new ElggFile();
$filehandler->owner_guid = $entity->owner_guid;
$filehandler->setFilename("company/" . $entity->guid . $size . ".jpg");
$url = $CONFIG->url . "pg/companies/icon/{$entity->guid}/{$size}/company.jpg";
return $url;
}
if ((!$returnvalue) && ($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggObject) && ($params['entity']->getSubtype() == 'branchcompany')) {
$entity = $params['entity'];
$parent = get_entity($entity->container_guid);
$size = $params['size'];
$url = $CONFIG->url . "pg/companies/icon/{$parent->guid}/{$size}/company.jpg";
return $url;
}
}
function hypeCompanies_url_handler($company) {
global $CONFIG;
return $CONFIG->wwwroot . "pg/companies/view/" . $company->guid . '/' . friendly_title($company->title);
}
function hypeCompanies_branch_url_handler($branch) {
global $CONFIG;
return $CONFIG->wwwroot . "pg/companies/view/" . $branch->container_guid;
}
function hypeCompanies_user_address($event, $object_type, $object) {
if ($object instanceof ElggUser) {
$object->hypelatitude = '';
$object->hypelongitude = '';
}
}
register_elgg_event_handler('init', 'system', 'hypeCompanies_init');
register_elgg_event_handler('pagesetup', 'system', 'hypeCompanies_pagesetup');
register_elgg_event_handler('update', 'user', 'hypeCompanies_user_address');
?>