| 1 |
<?php |
<?php |
| 2 |
// $Id: stormorganization.module,v 1.11.4.12 2008/08/03 17:55:11 robertogerola Exp $ |
// $Id: stormorganization.module,v 1.11.4.13 2008/08/25 09:04:45 robertogerola Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 10 |
|
|
| 11 |
switch ($path) { |
switch ($path) { |
| 12 |
case "admin/help#stormorganization": |
case "admin/help#stormorganization": |
| 13 |
$output = '<p>'. t("Provides organization support for Storm") .'</p>'; |
$output = '<p>'. storm_t("Provides organization support for Storm", 'organization') .'</p>'; |
| 14 |
break; |
break; |
| 15 |
} |
} |
| 16 |
|
|
| 141 |
function stormorganization_menu() { |
function stormorganization_menu() { |
| 142 |
$items = array(); |
$items = array(); |
| 143 |
$items['storm/organizations'] = array( |
$items['storm/organizations'] = array( |
| 144 |
'title' => t('Organizations'), |
'title' => storm_t('Organizations', 'organization'), |
| 145 |
'description' => t('Storm Organizations'), |
'description' => storm_t('Storm Organizations', 'organization'), |
| 146 |
'page callback' => 'stormorganization_list', |
'page callback' => 'stormorganization_list', |
| 147 |
'access arguments' => array('Storm organization: access'), |
'access arguments' => array('Storm organization: access'), |
| 148 |
'file' => 'stormorganization.admin.inc', |
'file' => 'stormorganization.admin.inc', |
| 175 |
function stormorganization_node_info() { |
function stormorganization_node_info() { |
| 176 |
return array( |
return array( |
| 177 |
'stormorganization' => array( |
'stormorganization' => array( |
| 178 |
'name' => t('Organization'), |
'name' => storm_t('Organization', 'organization'), |
| 179 |
'module' => 'stormorganization', |
'module' => 'stormorganization', |
| 180 |
'description' => t("An organization for Storm."), |
'description' => storm_t("An organization for Storm.", 'organization'), |
| 181 |
'title_label' => t("Name"), |
'title_label' => storm_t("Name", 'organization'), |
| 182 |
'body_label' => t("Note"), |
'body_label' => storm_t("Note", 'organization'), |
| 183 |
) |
) |
| 184 |
); |
); |
| 185 |
} |
} |
| 203 |
|
|
| 204 |
$form['group0']['iscustomer'] = array( |
$form['group0']['iscustomer'] = array( |
| 205 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 206 |
'#title' => t('Customer'), |
'#title' => storm_t('Customer', 'organization'), |
| 207 |
'#default_value' => $node->iscustomer, |
'#default_value' => $node->iscustomer, |
| 208 |
); |
); |
| 209 |
|
|
| 210 |
$form['group0']['isprovider'] = array( |
$form['group0']['isprovider'] = array( |
| 211 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 212 |
'#title' => t('Provider'), |
'#title' => storm_t('Provider', 'organization'), |
| 213 |
'#default_value' => $node->isprovider, |
'#default_value' => $node->isprovider, |
| 214 |
); |
); |
| 215 |
|
|
| 216 |
$form['group0']['isactive'] = array( |
$form['group0']['isactive'] = array( |
| 217 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 218 |
'#title' => t('Active'), |
'#title' => storm_t('Active', 'organization'), |
| 219 |
'#default_value' => $node->isactive, |
'#default_value' => $node->isactive, |
| 220 |
); |
); |
| 221 |
|
|
| 227 |
|
|
| 228 |
$form['group1']['prefix'] = array( |
$form['group1']['prefix'] = array( |
| 229 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 230 |
'#title' => t('Prefix'), |
'#title' => storm_t('Prefix', 'organization'), |
| 231 |
'#size' => 20, |
'#size' => 20, |
| 232 |
'#default_value' => $node->prefix, |
'#default_value' => $node->prefix, |
| 233 |
); |
); |
| 234 |
|
|
| 235 |
$form['group1']['fullname'] = array( |
$form['group1']['fullname'] = array( |
| 236 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 237 |
'#title' => t('Fullname'), |
'#title' => storm_t('Fullname', 'organization'), |
| 238 |
'#size' => 40, |
'#size' => 40, |
| 239 |
'#default_value' => $node->fullname, |
'#default_value' => $node->fullname, |
| 240 |
); |
); |
| 247 |
|
|
| 248 |
$form['group2']['country'] = array( |
$form['group2']['country'] = array( |
| 249 |
'#type' => 'select', |
'#type' => 'select', |
| 250 |
'#title' => t('Country'), |
'#title' => storm_t('Country', 'organization'), |
| 251 |
'#options' => stormattribute_attributes_bydomain('Country'), |
'#options' => stormattribute_attributes_bydomain('Country'), |
| 252 |
'#default_value' => $node->country, |
'#default_value' => $node->country, |
| 253 |
); |
); |
| 254 |
|
|
| 255 |
$form['group2']['provstate'] = array( |
$form['group2']['provstate'] = array( |
| 256 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 257 |
'#title' => t('Province / State'), |
'#title' => storm_t('Province / State', 'organization'), |
| 258 |
'#size' => 20, |
'#size' => 20, |
| 259 |
'#default_value' => $node->provstate, |
'#default_value' => $node->provstate, |
| 260 |
); |
); |
| 261 |
|
|
| 262 |
$form['group2']['city'] = array( |
$form['group2']['city'] = array( |
| 263 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 264 |
'#title' => t('City'), |
'#title' => storm_t('City', 'organization'), |
| 265 |
'#size' => 20, |
'#size' => 20, |
| 266 |
'#default_value' => $node->city, |
'#default_value' => $node->city, |
| 267 |
); |
); |
| 274 |
|
|
| 275 |
$form['group3']['zip'] = array( |
$form['group3']['zip'] = array( |
| 276 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 277 |
'#title' => t('Zip'), |
'#title' => storm_t('Zip', 'organization'), |
| 278 |
'#size' => 15, |
'#size' => 15, |
| 279 |
'#default_value' => $node->zip, |
'#default_value' => $node->zip, |
| 280 |
); |
); |
| 281 |
|
|
| 282 |
$form['group3']['address'] = array( |
$form['group3']['address'] = array( |
| 283 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 284 |
'#title' => t('Address'), |
'#title' => storm_t('Address', 'organization'), |
| 285 |
'#default_value' => $node->address, |
'#default_value' => $node->address, |
| 286 |
); |
); |
| 287 |
|
|
| 293 |
|
|
| 294 |
$form['group4']['currency'] = array( |
$form['group4']['currency'] = array( |
| 295 |
'#type' => 'select', |
'#type' => 'select', |
| 296 |
'#title' => t('Currency'), |
'#title' => storm_t('Currency', 'organization'), |
| 297 |
'#options' => stormattribute_attributes_bydomain('Currency'), |
'#options' => stormattribute_attributes_bydomain('Currency'), |
| 298 |
'#default_value' => $node->currency, |
'#default_value' => $node->currency, |
| 299 |
); |
); |
| 305 |
} |
} |
| 306 |
$form['group4']['orglanguage'] = array( |
$form['group4']['orglanguage'] = array( |
| 307 |
'#type' => 'select', |
'#type' => 'select', |
| 308 |
'#title' => t('Language'), |
'#title' => storm_t('Language', 'organization'), |
| 309 |
'#options' => $languages_options, |
'#options' => $languages_options, |
| 310 |
'#default_value' => $node->orglanguage, |
'#default_value' => $node->orglanguage, |
| 311 |
); |
); |
| 312 |
|
|
| 313 |
$form['group4']['vatid'] = array( |
$form['group4']['taxid'] = array( |
| 314 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 315 |
'#title' => t('VAT id'), |
'#title' => storm_t('Tax id', 'organization'), |
| 316 |
'#size' => 20, |
'#size' => 20, |
| 317 |
'#default_value' => $node->vatid, |
'#default_value' => $node->taxid, |
| 318 |
); |
); |
| 319 |
|
|
| 320 |
$form['group5'] = array( |
$form['group5'] = array( |
| 325 |
|
|
| 326 |
$form['group5']['www'] = array( |
$form['group5']['www'] = array( |
| 327 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 328 |
'#title' => t('WWW'), |
'#title' => storm_t('WWW', 'organization'), |
| 329 |
'#size' => 30, |
'#size' => 30, |
| 330 |
'#default_value' => $node->www, |
'#default_value' => $node->www, |
| 331 |
); |
); |
| 332 |
|
|
| 333 |
$form['group5']['email'] = array( |
$form['group5']['email'] = array( |
| 334 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 335 |
'#title' => t('Email'), |
'#title' => storm_t('Email', 'organization'), |
| 336 |
'#size' => 30, |
'#size' => 30, |
| 337 |
'#default_value' => $node->email, |
'#default_value' => $node->email, |
| 338 |
); |
); |
| 359 |
function stormorganization_insert($node) { |
function stormorganization_insert($node) { |
| 360 |
db_query("INSERT INTO {stormorganization} |
db_query("INSERT INTO {stormorganization} |
| 361 |
(vid, nid, prefix, fullname, country, www, email, currency, |
(vid, nid, prefix, fullname, country, www, email, currency, |
| 362 |
provstate, zip, city, address, vatid, orglanguage, iscustomer, isprovider, isactive |
provstate, zip, city, address, taxid, orglanguage, iscustomer, isprovider, isactive |
| 363 |
) VALUES |
) VALUES |
| 364 |
(%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', |
(%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', |
| 365 |
'%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d |
'%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d |
| 366 |
)", |
)", |
| 367 |
$node->vid, $node->nid, $node->prefix, $node->fullname, $node->country, $node->www, $node->email, $node->currency, |
$node->vid, $node->nid, $node->prefix, $node->fullname, $node->country, $node->www, $node->email, $node->currency, |
| 368 |
$node->provstate, $node->zip, $node->city, $node->address, $node->vatid, |
$node->provstate, $node->zip, $node->city, $node->address, $node->taxid, |
| 369 |
$node->orglanguage, $node->iscustomer, $node->isprovider, $node->isactive |
$node->orglanguage, $node->iscustomer, $node->isprovider, $node->isactive |
| 370 |
); |
); |
| 371 |
} |
} |
| 378 |
else { |
else { |
| 379 |
db_query("UPDATE {stormorganization} SET |
db_query("UPDATE {stormorganization} SET |
| 380 |
prefix = '%s', fullname = '%s', country='%s', www='%s', email='%s', currency = '%s', |
prefix = '%s', fullname = '%s', country='%s', www='%s', email='%s', currency = '%s', |
| 381 |
provstate = '%s', zip = '%s', city = '%s', address = '%s', vatid = '%s', orglanguage = '%s', |
provstate = '%s', zip = '%s', city = '%s', address = '%s', taxid = '%s', orglanguage = '%s', |
| 382 |
iscustomer=%d, isprovider=%d, isactive=%d WHERE vid = %d", |
iscustomer=%d, isprovider=%d, isactive=%d WHERE vid = %d", |
| 383 |
$node->prefix, $node->fullname, $node->country, $node->www, $node->email, $node->currency, |
$node->prefix, $node->fullname, $node->country, $node->www, $node->email, $node->currency, |
| 384 |
$node->provstate, $node->zip, $node->city, $node->address, $node->vatid, $node->orglanguage, |
$node->provstate, $node->zip, $node->city, $node->address, $node->taxid, $node->orglanguage, |
| 385 |
$node->iscustomer, $node->isprovider, $node->isactive, $node->vid); |
$node->iscustomer, $node->isprovider, $node->isactive, $node->vid); |
| 386 |
if ($node->title != $node->title_old) { |
if ($node->title != $node->title_old) { |
| 387 |
module_invoke_all('stormorganization_change', $node->nid, $node->title); |
module_invoke_all('stormorganization_change', $node->nid, $node->title); |
| 416 |
} |
} |
| 417 |
$form['storm_organization_nid'] = array( |
$form['storm_organization_nid'] = array( |
| 418 |
'#type' => 'select', |
'#type' => 'select', |
| 419 |
'#title' => t('Organization'), |
'#title' => storm_t('Organization', 'organization'), |
| 420 |
'#options' => $organizations, |
'#options' => $organizations, |
| 421 |
'#default_value' => variable_get('storm_organization_nid', 0), |
'#default_value' => variable_get('storm_organization_nid', 0), |
| 422 |
'#description' => t('The organization that owns this system'), |
'#description' => storm_t('The organization that owns this system', 'organization'), |
| 423 |
'#weight' => -30, |
'#weight' => -30, |
| 424 |
); |
); |
| 425 |
} |
} |