Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
267
modules/storm/stormorganization/stormorganization.admin.inc
Normal file
267
modules/storm/stormorganization/stormorganization.admin.inc
Normal file
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormorganization_list() {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (array_key_exists('name', $_GET)) {
|
||||
if ($_SESSION['stormorganization_list_filter']['name'] != $_GET['name']) {
|
||||
$_SESSION['stormorganization_list_filter']['name'] = $_GET['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormorganization';
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => t('Name'),
|
||||
'field' => 'n.title',
|
||||
'sort' => 'ASC',
|
||||
),
|
||||
array(
|
||||
'data' => t('Country'),
|
||||
'field' => 'sor.country',
|
||||
'sort' => '',
|
||||
),
|
||||
array(
|
||||
'data' => storm_icon_add_node($i, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
|
||||
$s = "SELECT n.*, sor.*, nre.format FROM {node} AS n
|
||||
INNER JOIN {stormorganization} AS sor ON n.vid=sor.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
WHERE n.status=1 AND n.type='stormorganization'";
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
$country = isset($_SESSION['stormorganization_list_filter']['country']) ? $_SESSION['stormorganization_list_filter']['country'] : '-';
|
||||
if ($country != '-') {
|
||||
$where[] = "sor.country='%s'";
|
||||
$args[] = $_SESSION['stormorganization_list_filter']['country'];
|
||||
$filterfields[] = t('Country');
|
||||
}
|
||||
|
||||
if (isset($_SESSION['stormorganization_list_filter']['name']) && $_SESSION['stormorganization_list_filter']['name'] != '') {
|
||||
$where[] = "LOWER(n.title) LIKE LOWER('%s')";
|
||||
$args[] = $_SESSION['stormorganization_list_filter']['name'];
|
||||
$filterfields[] = t('Name');
|
||||
}
|
||||
|
||||
$iscustomer = isset($_SESSION['stormorganization_list_filter']['iscustomer']) ? $_SESSION['stormorganization_list_filter']['iscustomer'] : '-';
|
||||
if ($iscustomer != '-') {
|
||||
if ($iscustomer == 'yes') {
|
||||
$where[] = "sor.iscustomer=1";
|
||||
}
|
||||
elseif ($iscustomer == 'no') {
|
||||
$where[] = "sor.iscustomer=0";
|
||||
}
|
||||
$filterfields[] = t('Customer');
|
||||
}
|
||||
|
||||
$isprovider = isset($_SESSION['stormorganization_list_filter']['isprovider']) ? $_SESSION['stormorganization_list_filter']['isprovider'] : '-';
|
||||
if ($isprovider != '-') {
|
||||
if ($isprovider == 'yes') {
|
||||
$where[] = "sor.isprovider=1";
|
||||
}
|
||||
elseif ($isprovider == 'no') {
|
||||
$where[] = "sor.isprovider=0";
|
||||
}
|
||||
$filterfields[] = t('Provider');
|
||||
}
|
||||
|
||||
$isactive = isset($_SESSION['stormorganization_list_filter']['isactive']) ? $_SESSION['stormorganization_list_filter']['isactive'] : '-';
|
||||
if ($isactive != '-') {
|
||||
if ($isactive == 'yes') {
|
||||
$where[] = "sor.isactive=1";
|
||||
}
|
||||
elseif ($isactive == 'no') {
|
||||
$where[] = "sor.isactive=0";
|
||||
}
|
||||
$filterfields[] = t('Active');
|
||||
}
|
||||
|
||||
// Sets value for fieldset label, does not affect filter itself.
|
||||
$itemsperpage = isset($_SESSION['stormorganization_list_filter']['itemsperpage']) ? $_SESSION['stormorganization_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
|
||||
if (count($filterfields) == 0) {
|
||||
$filterdesc = t('Not filtered');
|
||||
}
|
||||
else {
|
||||
$filterdesc = t('Filtered by !fields', array('!fields' => implode(", ", array_unique($filterfields))));
|
||||
}
|
||||
$filterdesc .= ' | '. t('!items items per page', array('!items' => $itemsperpage));
|
||||
|
||||
$o = drupal_get_form('stormorganization_list_filter', $filterdesc);
|
||||
|
||||
$s = stormorganization_access_sql($s, $where);
|
||||
$s = db_rewrite_sql($s);
|
||||
|
||||
$tablesort = tablesort_sql($header);
|
||||
$r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args);
|
||||
$organizations = array();
|
||||
while ($organization = db_fetch_object($r)) {
|
||||
$organizations[] = $organization;
|
||||
}
|
||||
|
||||
$o .= theme('stormorganization_list', $header, $organizations);
|
||||
$o .= theme('pager', NULL, $itemsperpage, 0);
|
||||
print theme('page', $o);
|
||||
}
|
||||
|
||||
function stormorganization_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$country_list = storm_attributes_bydomain('Country');
|
||||
$country = isset($_SESSION['stormorganization_list_filter']['country']) ? $_SESSION['stormorganization_list_filter']['country'] : '-';
|
||||
$_SESSION['stormorganization_list_filter']['country'] = $country;
|
||||
|
||||
$name = isset($_SESSION['stormorganization_list_filter']['name']) ? $_SESSION['stormorganization_list_filter']['name'] : '';
|
||||
$iscustomer = isset($_SESSION['stormorganization_list_filter']['iscustomer']) ? $_SESSION['stormorganization_list_filter']['iscustomer'] : NULL;
|
||||
$isprovider = isset($_SESSION['stormorganization_list_filter']['isprovider']) ? $_SESSION['stormorganization_list_filter']['isprovider'] : NULL;
|
||||
|
||||
$isactive = isset($_SESSION['stormorganization_list_filter']['isactive']) ? $_SESSION['stormorganization_list_filter']['isactive'] : 'yes';
|
||||
$_SESSION['stormorganization_list_filter']['isactive'] = $isactive;
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormorganization_list_filter']['itemsperpage']) ? $_SESSION['stormorganization_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormorganization_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$form = array();
|
||||
|
||||
$form['filter'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $filterdesc,
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#weight' => -20,
|
||||
);
|
||||
|
||||
$form['filter']['country'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Country'),
|
||||
'#default_value' => $country,
|
||||
'#options' => array('-' => t('-')) + $country_list['values'],
|
||||
);
|
||||
|
||||
$form['filter']['name'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Name'),
|
||||
'#default_value' => $name,
|
||||
'#autocomplete_path' => 'storm/organizations/autocomplete',
|
||||
);
|
||||
|
||||
$qs = '<div class="storm_quick_shortcuts"><ul class="storm_quick_shortcuts">';
|
||||
foreach (range(0, 9) as $n) {
|
||||
$qs .= '<li>'. l($n, 'organizations', array('query' => array('name' => $n .'%'))) .'</li>';
|
||||
}
|
||||
$qs .= '</ul></div>';
|
||||
$form['filter']['name_quick_shortcuts_numbers'] = array(
|
||||
'#type' => 'markup',
|
||||
'#value' => $qs,
|
||||
);
|
||||
$qs = '<div class="storm_quick_shortcuts"><ul class="storm_quick_shortcuts">';
|
||||
foreach (range('A', 'Z') as $l) {
|
||||
$qs .= '<li>'. l($l, 'organizations', array('query' => array('name' => $l .'%'))) .'</li>';
|
||||
}
|
||||
$qs .= '</ul></div>';
|
||||
$form['filter']['name_quick_shortcuts_letters'] = array(
|
||||
'#type' => 'markup',
|
||||
'#value' => $qs,
|
||||
);
|
||||
|
||||
$form['filter']['group0'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
);
|
||||
|
||||
$options = array(
|
||||
'-' => t('-'),
|
||||
'no' => t('no'),
|
||||
'yes' => t('yes')
|
||||
);
|
||||
$form['filter']['group0']['iscustomer'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#title' => t('Is customer'),
|
||||
'#default_value' => $iscustomer,
|
||||
);
|
||||
|
||||
$form['filter']['group0']['isprovider'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#title' => t('Is provider'),
|
||||
'#default_value' => $isprovider,
|
||||
);
|
||||
|
||||
$form['filter']['group0']['isactive'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => $options,
|
||||
'#title' => t('Is active'),
|
||||
'#default_value' => $isactive,
|
||||
);
|
||||
|
||||
$form['filter']['group1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#attributes' => array('class' => 'formgroup-submit'),
|
||||
);
|
||||
|
||||
$form['filter']['group1']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Filter'),
|
||||
'#submit' => array('stormorganization_list_filter_filter'),
|
||||
);
|
||||
|
||||
$form['filter']['group1']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Reset'),
|
||||
'#submit' => array('stormorganization_list_filter_reset'),
|
||||
);
|
||||
|
||||
$form['filter']['group1']['itemsperpage'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Items'),
|
||||
'#size' => 10,
|
||||
'#default_value' => $itemsperpage,
|
||||
'#prefix' => '<div class="container-inline">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormorganization_list_filter_filter($form, &$form_state) {
|
||||
$_SESSION['stormorganization_list_filter']['country'] = $form_state['values']['country'];
|
||||
$_SESSION['stormorganization_list_filter']['name'] = $form_state['values']['name'];
|
||||
$_SESSION['stormorganization_list_filter']['iscustomer'] = $form_state['values']['iscustomer'];
|
||||
$_SESSION['stormorganization_list_filter']['isprovider'] = $form_state['values']['isprovider'];
|
||||
$_SESSION['stormorganization_list_filter']['isactive'] = $form_state['values']['isactive'];
|
||||
$_SESSION['stormorganization_list_filter']['itemsperpage'] = $form_state['values']['itemsperpage'];
|
||||
}
|
||||
|
||||
function stormorganization_list_filter_reset($form, &$form_state) {
|
||||
unset($_SESSION['stormorganization_list_filter']);
|
||||
}
|
||||
|
||||
function stormorganization_autocomplete($string = '') {
|
||||
$matches = array();
|
||||
if ($string) {
|
||||
$s = "SELECT title FROM {node} AS n WHERE n.type='stormorganization' AND LOWER(title) LIKE LOWER('%s%%')";
|
||||
$s = stormorganization_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
|
||||
$result = db_query_range($s, $string, 0, 10);
|
||||
while ($org = db_fetch_object($result)) {
|
||||
$matches[$org->title] = check_plain($org->title);
|
||||
}
|
||||
}
|
||||
|
||||
drupal_json($matches);
|
||||
}
|
11
modules/storm/stormorganization/stormorganization.info
Normal file
11
modules/storm/stormorganization/stormorganization.info
Normal file
|
@ -0,0 +1,11 @@
|
|||
name = Storm Organization
|
||||
description = "Allows storing of organizations for use within SuiteDesk"
|
||||
dependencies[] = storm
|
||||
package = Storm
|
||||
core = 6.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-05
|
||||
version = "6.x-2.2"
|
||||
core = "6.x"
|
||||
project = "storm"
|
||||
datestamp = "1375697500"
|
655
modules/storm/stormorganization/stormorganization.install
Normal file
655
modules/storm/stormorganization/stormorganization.install
Normal file
|
@ -0,0 +1,655 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormorganization_install() {
|
||||
drupal_install_schema('stormorganization');
|
||||
variable_set('node_options_stormorganization', array('status'));
|
||||
|
||||
$attributes = array();
|
||||
|
||||
$attributes['Price mode'] = array(
|
||||
'not applicable' => 'Not Applicable',
|
||||
'hourly' => 'Hourly',
|
||||
'daily' => 'Daily',
|
||||
'fixed_price' => 'Fixed Price',
|
||||
);
|
||||
|
||||
$attributes['Currency'] = array(
|
||||
'USD' => 'US Dollar',
|
||||
'CAD' => 'Canadian Dollar',
|
||||
'EUR' => 'Euro',
|
||||
'GBP' => 'British Pound',
|
||||
'JPY' => 'Japanese Yen',
|
||||
'CHF' => 'Swiss Franc',
|
||||
);
|
||||
|
||||
$attributes['Country'] = array(
|
||||
'US' => 'United States of America',
|
||||
'AD' => 'Andorra',
|
||||
'AE' => 'United Arab Emirates',
|
||||
'AF' => 'Afghanistan',
|
||||
'AG' => 'Antigua and Barbuda',
|
||||
'AI' => 'Anguilla',
|
||||
'AL' => 'Albania',
|
||||
'AM' => 'Armenia',
|
||||
'AN' => 'Netherlands Antilles',
|
||||
'AO' => 'Angola',
|
||||
'AR' => 'Argentina',
|
||||
'AS' => 'American Samoa',
|
||||
'AT' => 'Austria',
|
||||
'AU' => 'Australia',
|
||||
'AW' => 'Aruba',
|
||||
'AX' => 'Åland Islands',
|
||||
'AZ' => 'Azerbaijan',
|
||||
'BA' => 'Bosnia and Herzegovina',
|
||||
'BB' => 'Barbados',
|
||||
'BD' => 'Bangladesh',
|
||||
'BE' => 'Belgium',
|
||||
'BF' => 'Burkina Faso',
|
||||
'BG' => 'Bulgaria',
|
||||
'BH' => 'Bahrain',
|
||||
'BI' => 'Burundi',
|
||||
'BJ' => 'Benin',
|
||||
'BL' => 'Saint-Barthélemy',
|
||||
'BM' => 'Bermuda',
|
||||
'BN' => 'Brunei Darussalam',
|
||||
'BO' => 'Bolivia',
|
||||
'BR' => 'Brazil',
|
||||
'BS' => 'Bahamas',
|
||||
'BT' => 'Bhutan',
|
||||
'BW' => 'Botswana',
|
||||
'BY' => 'Belarus',
|
||||
'BZ' => 'Belize',
|
||||
'CA' => 'Canada',
|
||||
'CD' => 'Democratic Republic of the Congo',
|
||||
'CF' => 'Central African Republic',
|
||||
'CG' => 'Congo',
|
||||
'CH' => 'Switzerland',
|
||||
'CI' => "Côte d'Ivoire",
|
||||
'CK' => 'Cook Islands',
|
||||
'CL' => 'Chile',
|
||||
'CM' => 'Cameroon',
|
||||
'CN' => 'China',
|
||||
'CO' => 'Colombia',
|
||||
'CR' => 'Costa Rica',
|
||||
'CU' => 'Cuba',
|
||||
'CV' => 'Cape Verde',
|
||||
'CY' => 'Cyprus',
|
||||
'CZ' => 'Czech Republic',
|
||||
'DE' => 'Germany',
|
||||
'DJ' => 'Djibouti',
|
||||
'DK' => 'Denmark',
|
||||
'DM' => 'Dominica',
|
||||
'DO' => 'Dominican Republic',
|
||||
'DZ' => 'Algeria',
|
||||
'EC' => 'Ecuador',
|
||||
'EE' => 'Estonia',
|
||||
'EG' => 'Egypt',
|
||||
'EH' => 'Western Sahara',
|
||||
'ER' => 'Eritrea',
|
||||
'ES' => 'Spain',
|
||||
'ET' => 'Ethiopia',
|
||||
'FI' => 'Finland',
|
||||
'FJ' => 'Fiji',
|
||||
'FK' => 'Falkland Islands (Malvinas)',
|
||||
'FM' => 'Micronesia, Federated States of',
|
||||
'FO' => 'Faeroe Islands',
|
||||
'FR' => 'France',
|
||||
'GA' => 'Gabon',
|
||||
'GB' => 'United Kingdom',
|
||||
'GD' => 'Grenada',
|
||||
'GE' => 'Georgia',
|
||||
'GF' => 'French Guiana',
|
||||
'GG' => 'Guernsey',
|
||||
'GH' => 'Ghana',
|
||||
'GI' => 'Gibraltar',
|
||||
'GL' => 'Greenland',
|
||||
'GM' => 'Gambia',
|
||||
'GN' => 'Guinea',
|
||||
'GP' => 'Guadeloupe',
|
||||
'GQ' => 'Equatorial Guinea',
|
||||
'GR' => 'Greece',
|
||||
'GT' => 'Guatemala',
|
||||
'GU' => 'Guam',
|
||||
'GW' => 'Guinea-Bissau',
|
||||
'GY' => 'Guyana',
|
||||
'HK' => 'Hong Kong Special Administrative Region of China',
|
||||
'HN' => 'Honduras',
|
||||
'HR' => 'Croatia',
|
||||
'HT' => 'Haiti',
|
||||
'HU' => 'Hungary',
|
||||
'ID' => 'Indonesia',
|
||||
'IE' => 'Ireland',
|
||||
'IL' => 'Israel',
|
||||
'IM' => 'Isle of Man',
|
||||
'IN' => 'India',
|
||||
'IQ' => 'Iraq, Republic of',
|
||||
'IR' => 'Iran, Islamic Republic of',
|
||||
'IS' => 'Iceland',
|
||||
'IT' => 'Italy',
|
||||
'JE' => 'Jersey',
|
||||
'JM' => 'Jamaica',
|
||||
'JO' => 'Jordan',
|
||||
'JP' => 'Japan',
|
||||
'KE' => 'Kenya',
|
||||
'KG' => 'Kyrgyzstan',
|
||||
'KH' => 'Cambodia',
|
||||
'KI' => 'Kiribati',
|
||||
'KM' => 'Comoros',
|
||||
'KN' => 'Saint Kitts and Nevis',
|
||||
'KP' => "Democratic People's Republic of Korea",
|
||||
'KR' => 'Republic of Korea',
|
||||
'KW' => 'Kuwait',
|
||||
'KY' => 'Cayman Islands',
|
||||
'KZ' => 'Kazakhstan',
|
||||
'LA' => "Lao People's Democratic Republic",
|
||||
'LB' => 'Lebanon',
|
||||
'LC' => 'Saint Lucia',
|
||||
'LI' => 'Liechtenstein',
|
||||
'LK' => 'Sri Lanka',
|
||||
'LR' => 'Liberia',
|
||||
'LS' => 'Lesotho',
|
||||
'LT' => 'Lithuania',
|
||||
'LU' => 'Luxembourg',
|
||||
'LV' => 'Latvia',
|
||||
'LY' => 'Libyan Arab Jamahiriya',
|
||||
'MA' => 'Morocco',
|
||||
'MC' => 'Monaco',
|
||||
'MD' => 'Moldova',
|
||||
'ME' => 'Montenegro',
|
||||
'MF' => 'Saint-Martin (French part)',
|
||||
'MG' => 'Madagascar',
|
||||
'MH' => 'Marshall Islands',
|
||||
'MK' => 'The former Yugoslav Republic of Macedonia',
|
||||
'ML' => 'Mali',
|
||||
'MM' => 'Myanmar',
|
||||
'MN' => 'Mongolia',
|
||||
'MO' => 'Macao Special Administrative Region of China',
|
||||
'MP' => 'Northern Mariana Islands',
|
||||
'MQ' => 'Martinique',
|
||||
'MR' => 'Mauritania',
|
||||
'MS' => 'Montserrat',
|
||||
'MT' => 'Malta',
|
||||
'MU' => 'Mauritius',
|
||||
'MV' => 'Maldives',
|
||||
'MW' => 'Malawi',
|
||||
'MX' => 'Mexico',
|
||||
'MY' => 'Malaysia',
|
||||
'MZ' => 'Mozambique',
|
||||
'NA' => 'Namibia',
|
||||
'NC' => 'New Caledonia',
|
||||
'NE' => 'Niger',
|
||||
'NF' => 'Norfolk Island',
|
||||
'NG' => 'Nigeria',
|
||||
'NI' => 'Nicaragua',
|
||||
'NL' => 'Netherlands',
|
||||
'NO' => 'Norway',
|
||||
'NP' => 'Nepal',
|
||||
'NR' => 'Nauru',
|
||||
'NU' => 'Niue',
|
||||
'NZ' => 'New Zealand',
|
||||
'OM' => 'Oman',
|
||||
'PA' => 'Panama',
|
||||
'PE' => 'Peru',
|
||||
'PF' => 'French Polynesia',
|
||||
'PG' => 'Papua New Guinea',
|
||||
'PH' => 'Philippines',
|
||||
'PK' => 'Pakistan',
|
||||
'PL' => 'Poland',
|
||||
'PM' => 'Saint Pierre and Miquelon',
|
||||
'PN' => 'Pitcairn',
|
||||
'PR' => 'Puerto Rico',
|
||||
'PS' => 'Occupied Palestinian Territory',
|
||||
'PT' => 'Portugal',
|
||||
'PW' => 'Palau',
|
||||
'PY' => 'Paraguay',
|
||||
'QA' => 'Qatar',
|
||||
'RE' => 'Réunion',
|
||||
'RO' => 'Romania',
|
||||
'RS' => 'Serbia',
|
||||
'RU' => 'Russian Federation',
|
||||
'RW' => 'Rwanda',
|
||||
'SA' => 'Saudi Arabia',
|
||||
'SB' => 'Solomon Islands',
|
||||
'SC' => 'Seychelles',
|
||||
'SD' => 'Sudan',
|
||||
'SE' => 'Sweden',
|
||||
'SG' => 'Singapore',
|
||||
'SH' => 'Saint Helena',
|
||||
'SI' => 'Slovenia',
|
||||
'SJ' => 'Svalbard and Jan Mayen Islands',
|
||||
'SK' => 'Slovakia',
|
||||
'SL' => 'Sierra Leone',
|
||||
'SM' => 'San Marino',
|
||||
'SN' => 'Senegal',
|
||||
'SO' => 'Somalia',
|
||||
'SR' => 'Suriname',
|
||||
'ST' => 'Sao Tome and Principe',
|
||||
'SV' => 'El Salvador',
|
||||
'SY' => 'Syrian Arab Republic',
|
||||
'SZ' => 'Swaziland',
|
||||
'TC' => 'Turks and Caicos Islands',
|
||||
'TD' => 'Chad',
|
||||
'TG' => 'Togo',
|
||||
'TH' => 'Thailand',
|
||||
'TJ' => 'Tajikistan',
|
||||
'TK' => 'Tokelau',
|
||||
'TL' => 'Timor-Leste',
|
||||
'TM' => 'Turkmenistan',
|
||||
'TN' => 'Tunisia',
|
||||
'TO' => 'Tonga',
|
||||
'TR' => 'Turkey',
|
||||
'TT' => 'Trinidad and Tobago',
|
||||
'TV' => 'Tuvalu',
|
||||
'TZ' => 'United Republic of Tanzania',
|
||||
'UA' => 'Ukraine',
|
||||
'UG' => 'Uganda',
|
||||
'UY' => 'Uruguay',
|
||||
'UZ' => 'Uzbekistan',
|
||||
'VA' => 'Holy See',
|
||||
'VC' => 'Saint Vincent and the Grenadines',
|
||||
'VE' => 'Venezuela (Bolivarian Republic of)',
|
||||
'VG' => 'British Virgin Islands',
|
||||
'VI' => 'United States Virgin Islands',
|
||||
'VN' => 'Viet Nam',
|
||||
'VU' => 'Vanuatu',
|
||||
'WF' => 'Wallis and Futuna Islands',
|
||||
'WS' => 'Samoa',
|
||||
'YE' => 'Yemen',
|
||||
'YT' => 'Mayotte',
|
||||
'ZA' => 'South Africa',
|
||||
'ZM' => 'Zambia',
|
||||
'ZW' => 'Zimbabwe',
|
||||
);
|
||||
|
||||
$s = "INSERT INTO {stormattribute} (domain, akey, avalue, weight) VALUES ('%s', '%s', '%s', %d)";
|
||||
$prevdomain = '';
|
||||
$weight = 0;
|
||||
foreach ($attributes as $domain => $attribute) {
|
||||
if ($domain != $prevdomain) $weight=0;
|
||||
foreach ($attribute as $key => $value) {
|
||||
db_query($s, $domain, $key, $value, $weight);
|
||||
$weight++;
|
||||
}
|
||||
$prevdomain = $domain;
|
||||
}
|
||||
}
|
||||
|
||||
function stormorganization_disable() {
|
||||
drupal_set_message(t('Nodes of type "Organization" have not been deleted on disabling SuiteDesk Organization. Please note that they will now have reduced functionality, and will not be protected by SuiteDesk Organization access controls.'), 'warning');
|
||||
}
|
||||
|
||||
function stormorganization_uninstall() {
|
||||
drupal_uninstall_schema('stormorganization');
|
||||
|
||||
db_query($s = "DELETE FROM {stormattribute} WHERE domain IN ('Price mode', 'Currency', 'Country')");
|
||||
}
|
||||
|
||||
function stormorganization_schema() {
|
||||
$schema['stormorganization'] = array(
|
||||
'fields' => array(
|
||||
'vid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'prefix' => array('type' => 'varchar', 'length' => 100),
|
||||
'fullname' => array('type' => 'varchar', 'length' => 100),
|
||||
'country' => array('type' => 'varchar', 'length' => 100),
|
||||
'orglanguage' => array('type' => 'varchar', 'length' => 100),
|
||||
'provstate' => array('type' => 'varchar', 'length' => 50),
|
||||
'city' => array('type' => 'varchar', 'length' => 100),
|
||||
'zip' => array('type' => 'varchar', 'length' => 10),
|
||||
'address' => array('type' => 'varchar', 'length' => 100),
|
||||
'taxid' => array('type' => 'varchar', 'length' => 50),
|
||||
'email' => array('type' => 'varchar', 'length' => 50),
|
||||
'www' => array('type' => 'varchar', 'length' => 100),
|
||||
'phone' => array('type' => 'varchar', 'length' => 100),
|
||||
'currency' => array('type' => 'varchar', 'length' => 100),
|
||||
'iscustomer' => array('type' => 'int', 'default' => 1),
|
||||
'isprovider' => array('type' => 'int', 'default' => 0),
|
||||
'isactive' => array('type' => 'int', 'default' => 1),
|
||||
'pricemode' => array('type' => 'varchar', 'length' => 20),
|
||||
'price' => array('type' => 'float'),
|
||||
),
|
||||
'primary key' => array('vid'),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid')
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
function stormorganization_update_1() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormorganization', 'iscustomer', array('type' => 'int', 'default' => 1));
|
||||
db_add_field($ret, 'stormorganization', 'isprovider', array('type' => 'int', 'default' => 0));
|
||||
db_add_field($ret, 'stormorganization', 'isactive', array('type' => 'int', 'default' => 1));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function stormorganization_update_2() {
|
||||
$ret = array();
|
||||
db_change_field($ret, 'stormorganization', 'vatid', 'taxid', array('type' => 'varchar', 'length' => 50));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function stormorganization_update_3() {
|
||||
$ret = array();
|
||||
db_query('UPDATE {stormorganization} SET iscustomer=1, isprovider=1, isactive=1');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function stormorganization_update_6104() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormorganization', 'pricemode', array('type' => 'varchar', 'length' => 20));
|
||||
db_add_field($ret, 'stormorganization', 'price', array('type' => 'float'));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* @function
|
||||
* Database update for issue #899970
|
||||
*/
|
||||
function stormorganization_update_6105() {
|
||||
$ret = array();
|
||||
|
||||
db_change_field($ret, 'stormorganization', 'orglanguage', 'orglanguage', array('type' => 'varchar', 'length' => 100));
|
||||
db_change_field($ret, 'stormorganization', 'currency', 'currency', array('type' => 'varchar', 'length' => 100));
|
||||
db_change_field($ret, 'stormorganization', 'pricemode', 'pricemode', array('type' => 'varchar', 'length' => 100));
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Improve primary keys and indexes
|
||||
*/
|
||||
function stormorganization_update_6201() {
|
||||
$return = array();
|
||||
db_drop_primary_key($return, 'stormorganization');
|
||||
db_add_primary_key($return, 'stormorganization', array('vid'));
|
||||
db_add_index($return, 'stormorganization', 'nid', array('nid'));
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move SuiteDesk Attribute module into component modules
|
||||
*/
|
||||
function stormorganization_update_6202() {
|
||||
// Only run this update if was not previously run as part of the legacy stormattribute module
|
||||
if (db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'stormattribute'")) < 2) {
|
||||
$attributes['Currency'] = array(
|
||||
'USD' => 'US Dollar',
|
||||
'CAD' => 'Canadian Dollar',
|
||||
'EUR' => 'Euro',
|
||||
'GBP' => 'British Pound',
|
||||
'JPY' => 'Japanese Yen',
|
||||
'CHF' => 'Swiss Franc',
|
||||
);
|
||||
|
||||
$attributes['Country'] = array(
|
||||
'AD' => 'Andorra',
|
||||
'AE' => 'United Arab Emirates',
|
||||
'AF' => 'Afghanistan',
|
||||
'AG' => 'Antigua and Barbuda',
|
||||
'AI' => 'Anguilla',
|
||||
'AL' => 'Albania',
|
||||
'AM' => 'Armenia',
|
||||
'AN' => 'Netherlands Antilles',
|
||||
'AO' => 'Angola',
|
||||
'AR' => 'Argentina',
|
||||
'AS' => 'American Samoa',
|
||||
'AT' => 'Austria',
|
||||
'AU' => 'Australia',
|
||||
'AW' => 'Aruba',
|
||||
'AX' => 'Åland Islands',
|
||||
'AZ' => 'Azerbaijan',
|
||||
'BA' => 'Bosnia and Herzegovina',
|
||||
'BB' => 'Barbados',
|
||||
'BD' => 'Bangladesh',
|
||||
'BE' => 'Belgium',
|
||||
'BF' => 'Burkina Faso',
|
||||
'BG' => 'Bulgaria',
|
||||
'BH' => 'Bahrain',
|
||||
'BI' => 'Burundi',
|
||||
'BJ' => 'Benin',
|
||||
'BL' => 'Saint-Barthélemy',
|
||||
'BM' => 'Bermuda',
|
||||
'BN' => 'Brunei Darussalam',
|
||||
'BO' => 'Bolivia',
|
||||
'BR' => 'Brazil',
|
||||
'BS' => 'Bahamas',
|
||||
'BT' => 'Bhutan',
|
||||
'BW' => 'Botswana',
|
||||
'BY' => 'Belarus',
|
||||
'BZ' => 'Belize',
|
||||
'CA' => 'Canada',
|
||||
'CD' => 'Democratic Republic of the Congo',
|
||||
'CF' => 'Central African Republic',
|
||||
'CG' => 'Congo',
|
||||
'CH' => 'Switzerland',
|
||||
'CI' => "Côte d'Ivoire",
|
||||
'CK' => 'Cook Islands',
|
||||
'CL' => 'Chile',
|
||||
'CM' => 'Cameroon',
|
||||
'CN' => 'China',
|
||||
'CO' => 'Colombia',
|
||||
'CR' => 'Costa Rica',
|
||||
'CU' => 'Cuba',
|
||||
'CV' => 'Cape Verde',
|
||||
'CY' => 'Cyprus',
|
||||
'CZ' => 'Czech Republic',
|
||||
'DE' => 'Germany',
|
||||
'DJ' => 'Djibouti',
|
||||
'DK' => 'Denmark',
|
||||
'DM' => 'Dominica',
|
||||
'DO' => 'Dominican Republic',
|
||||
'DZ' => 'Algeria',
|
||||
'EC' => 'Ecuador',
|
||||
'EE' => 'Estonia',
|
||||
'EG' => 'Egypt',
|
||||
'EH' => 'Western Sahara',
|
||||
'ER' => 'Eritrea',
|
||||
'ES' => 'Spain',
|
||||
'ET' => 'Ethiopia',
|
||||
'FI' => 'Finland',
|
||||
'FJ' => 'Fiji',
|
||||
'FK' => 'Falkland Islands (Malvinas)',
|
||||
'FM' => 'Micronesia, Federated States of',
|
||||
'FO' => 'Faeroe Islands',
|
||||
'FR' => 'France',
|
||||
'GA' => 'Gabon',
|
||||
'GB' => 'United Kingdom of Great Britain and Northern Ireland',
|
||||
'GD' => 'Grenada',
|
||||
'GE' => 'Georgia',
|
||||
'GF' => 'French Guiana',
|
||||
'GG' => 'Guernsey',
|
||||
'GH' => 'Ghana',
|
||||
'GI' => 'Gibraltar',
|
||||
'GL' => 'Greenland',
|
||||
'GM' => 'Gambia',
|
||||
'GN' => 'Guinea',
|
||||
'GP' => 'Guadeloupe',
|
||||
'GQ' => 'Equatorial Guinea',
|
||||
'GR' => 'Greece',
|
||||
'GT' => 'Guatemala',
|
||||
'GU' => 'Guam',
|
||||
'GW' => 'Guinea-Bissau',
|
||||
'GY' => 'Guyana',
|
||||
'HK' => 'Hong Kong Special Administrative Region of China',
|
||||
'HN' => 'Honduras',
|
||||
'HR' => 'Croatia',
|
||||
'HT' => 'Haiti',
|
||||
'HU' => 'Hungary',
|
||||
'ID' => 'Indonesia',
|
||||
'IE' => 'Ireland',
|
||||
'IL' => 'Israel',
|
||||
'IM' => 'Isle of Man',
|
||||
'IN' => 'India',
|
||||
'IQ' => 'Iraq, Republic of',
|
||||
'IR' => 'Iran, Islamic Republic of',
|
||||
'IS' => 'Iceland',
|
||||
'IT' => 'Italy',
|
||||
'JE' => 'Jersey',
|
||||
'JM' => 'Jamaica',
|
||||
'JO' => 'Jordan',
|
||||
'JP' => 'Japan',
|
||||
'KE' => 'Kenya',
|
||||
'KG' => 'Kyrgyzstan',
|
||||
'KH' => 'Cambodia',
|
||||
'KI' => 'Kiribati',
|
||||
'KM' => 'Comoros',
|
||||
'KN' => 'Saint Kitts and Nevis',
|
||||
'KP' => "Democratic People's Republic of Korea",
|
||||
'KR' => 'Republic of Korea',
|
||||
'KW' => 'Kuwait',
|
||||
'KY' => 'Cayman Islands',
|
||||
'KZ' => 'Kazakhstan',
|
||||
'LA' => "Lao People's Democratic Republic",
|
||||
'LB' => 'Lebanon',
|
||||
'LC' => 'Saint Lucia',
|
||||
'LI' => 'Liechtenstein',
|
||||
'LK' => 'Sri Lanka',
|
||||
'LR' => 'Liberia',
|
||||
'LS' => 'Lesotho',
|
||||
'LT' => 'Lithuania',
|
||||
'LU' => 'Luxembourg',
|
||||
'LV' => 'Latvia',
|
||||
'LY' => 'Libyan Arab Jamahiriya',
|
||||
'MA' => 'Morocco',
|
||||
'MC' => 'Monaco',
|
||||
'MD' => 'Moldova',
|
||||
'ME' => 'Montenegro',
|
||||
'MF' => 'Saint-Martin (French part)',
|
||||
'MG' => 'Madagascar',
|
||||
'MH' => 'Marshall Islands',
|
||||
'MK' => 'The former Yugoslav Republic of Macedonia',
|
||||
'ML' => 'Mali',
|
||||
'MM' => 'Myanmar',
|
||||
'MN' => 'Mongolia',
|
||||
'MO' => 'Macao Special Administrative Region of China',
|
||||
'MP' => 'Northern Mariana Islands',
|
||||
'MQ' => 'Martinique',
|
||||
'MR' => 'Mauritania',
|
||||
'MS' => 'Montserrat',
|
||||
'MT' => 'Malta',
|
||||
'MU' => 'Mauritius',
|
||||
'MV' => 'Maldives',
|
||||
'MW' => 'Malawi',
|
||||
'MX' => 'Mexico',
|
||||
'MY' => 'Malaysia',
|
||||
'MZ' => 'Mozambique',
|
||||
'NA' => 'Namibia',
|
||||
'NC' => 'New Caledonia',
|
||||
'NE' => 'Niger',
|
||||
'NF' => 'Norfolk Island',
|
||||
'NG' => 'Nigeria',
|
||||
'NI' => 'Nicaragua',
|
||||
'NL' => 'Netherlands',
|
||||
'NO' => 'Norway',
|
||||
'NP' => 'Nepal',
|
||||
'NR' => 'Nauru',
|
||||
'NU' => 'Niue',
|
||||
'NZ' => 'New Zealand',
|
||||
'OM' => 'Oman',
|
||||
'PA' => 'Panama',
|
||||
'PE' => 'Peru',
|
||||
'PF' => 'French Polynesia',
|
||||
'PG' => 'Papua New Guinea',
|
||||
'PH' => 'Philippines',
|
||||
'PK' => 'Pakistan',
|
||||
'PL' => 'Poland',
|
||||
'PM' => 'Saint Pierre and Miquelon',
|
||||
'PN' => 'Pitcairn',
|
||||
'PR' => 'Puerto Rico',
|
||||
'PS' => 'Occupied Palestinian Territory',
|
||||
'PT' => 'Portugal',
|
||||
'PW' => 'Palau',
|
||||
'PY' => 'Paraguay',
|
||||
'QA' => 'Qatar',
|
||||
'RE' => 'Réunion',
|
||||
'RO' => 'Romania',
|
||||
'RS' => 'Serbia',
|
||||
'RU' => 'Russian Federation',
|
||||
'RW' => 'Rwanda',
|
||||
'SA' => 'Saudi Arabia',
|
||||
'SB' => 'Solomon Islands',
|
||||
'SC' => 'Seychelles',
|
||||
'SD' => 'Sudan',
|
||||
'SE' => 'Sweden',
|
||||
'SG' => 'Singapore',
|
||||
'SH' => 'Saint Helena',
|
||||
'SI' => 'Slovenia',
|
||||
'SJ' => 'Svalbard and Jan Mayen Islands',
|
||||
'SK' => 'Slovakia',
|
||||
'SL' => 'Sierra Leone',
|
||||
'SM' => 'San Marino',
|
||||
'SN' => 'Senegal',
|
||||
'SO' => 'Somalia',
|
||||
'SR' => 'Suriname',
|
||||
'ST' => 'Sao Tome and Principe',
|
||||
'SV' => 'El Salvador',
|
||||
'SY' => 'Syrian Arab Republic',
|
||||
'SZ' => 'Swaziland',
|
||||
'TC' => 'Turks and Caicos Islands',
|
||||
'TD' => 'Chad',
|
||||
'TG' => 'Togo',
|
||||
'TH' => 'Thailand',
|
||||
'TJ' => 'Tajikistan',
|
||||
'TK' => 'Tokelau',
|
||||
'TL' => 'Timor-Leste',
|
||||
'TM' => 'Turkmenistan',
|
||||
'TN' => 'Tunisia',
|
||||
'TO' => 'Tonga',
|
||||
'TR' => 'Turkey',
|
||||
'TT' => 'Trinidad and Tobago',
|
||||
'TV' => 'Tuvalu',
|
||||
'TZ' => 'United Republic of Tanzania',
|
||||
'UA' => 'Ukraine',
|
||||
'UG' => 'Uganda',
|
||||
'UY' => 'Uruguay',
|
||||
'US' => 'United States of America',
|
||||
'UZ' => 'Uzbekistan',
|
||||
'VA' => 'Holy See',
|
||||
'VC' => 'Saint Vincent and the Grenadines',
|
||||
'VE' => 'Venezuela (Bolivarian Republic of)',
|
||||
'VG' => 'British Virgin Islands',
|
||||
'VI' => 'United States Virgin Islands',
|
||||
'VN' => 'Viet Nam',
|
||||
'VU' => 'Vanuatu',
|
||||
'WF' => 'Wallis and Futuna Islands',
|
||||
'WS' => 'Samoa',
|
||||
'YE' => 'Yemen',
|
||||
'YT' => 'Mayotte',
|
||||
'ZA' => 'South Africa',
|
||||
'ZM' => 'Zambia',
|
||||
'ZW' => 'Zimbabwe',
|
||||
);
|
||||
$s = "INSERT INTO {stormattribute} (domain, akey, avalue, weight) VALUES ('%s', '%s', '%s', %d)";
|
||||
$prevdomain = '';
|
||||
$weight = 0;
|
||||
foreach ($attributes as $domain => $attribute) {
|
||||
if ($domain != $prevdomain) $weight=0;
|
||||
foreach ($attribute as $key => $value) {
|
||||
db_query($s, $domain, $key, $value, $weight);
|
||||
$weight++;
|
||||
}
|
||||
$prevdomain = $domain;
|
||||
}
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
|
||||
if (db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'stormattribute'")) < 6110) {
|
||||
$ret[] = update_sql("INSERT INTO {stormattribute} (domain, akey, avalue, weight, isactive) VALUES ('Price mode', 'not applicable', 'Not Applicable', 0, 1)");
|
||||
}
|
||||
|
||||
if (db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'stormattribute'")) < 6112) {
|
||||
$ret[] = update_sql("INSERT INTO {stormattribute} (domain, akey, avalue, weight, isactive) VALUES ('Price mode', 'fixed_price', 'Fixed Price', 0, 1)");
|
||||
$ret[] = update_sql("UPDATE {stormorganization} set pricemode='fixed_price' where pricemode='fixed_timetracking'");
|
||||
$ret[] = update_sql("DELETE FROM {stormattribute} where domain = 'Price mode' and akey = 'fixed_timetracking'");
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
777
modules/storm/stormorganization/stormorganization.module
Normal file
777
modules/storm/stormorganization/stormorganization.module
Normal file
|
@ -0,0 +1,777 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormorganization_help($path, $arg) {
|
||||
$output = '';
|
||||
|
||||
switch ($path) {
|
||||
case "admin/help#stormorganization":
|
||||
$output = '<p>'. t("Provides organization support for SuiteDesk") .'</p>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function stormorganization_perm() {
|
||||
return array(
|
||||
'Storm organization: access',
|
||||
'Storm organization: add',
|
||||
'Storm organization: delete all',
|
||||
'Storm organization: delete own',
|
||||
'Storm organization: edit all',
|
||||
'Storm organization: edit own',
|
||||
'Storm organization: edit belonged',
|
||||
'Storm organization: view all',
|
||||
'Storm organization: view own',
|
||||
'Storm organization: view belonged',
|
||||
);
|
||||
}
|
||||
|
||||
function stormorganization_access($op, $node, $account = NULL) {
|
||||
if (empty($account)) {
|
||||
global $user;
|
||||
$account = $user;
|
||||
}
|
||||
|
||||
if ($op == 'create') {
|
||||
return user_access('Storm organization: add');
|
||||
}
|
||||
|
||||
if (is_numeric($node)) {
|
||||
$node = node_load($node);
|
||||
}
|
||||
|
||||
if (!isset($account->stormorganization_nid) && module_exists('stormperson')) {
|
||||
_stormperson_user_load($account);
|
||||
}
|
||||
|
||||
if ($op == 'delete') {
|
||||
if (user_access('Storm organization: delete all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm organization: delete own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'update') {
|
||||
if (user_access('Storm organization: edit all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm organization: edit own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm organization: edit belonged') && ($account->stormorganization_nid == $node->nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'view') {
|
||||
if (user_access('Storm organization: view all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm organization: view own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm organization: view belonged') && ($account->stormorganization_nid == $node->nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function stormorganization_access_sql($sql, $where = array()) {
|
||||
if (!user_access('Storm organization: view all')) {
|
||||
global $user;
|
||||
|
||||
$cond = '';
|
||||
if (user_access('Storm organization: view own')) {
|
||||
$cond .= 'n.uid = ' . $user->uid;
|
||||
}
|
||||
if (user_access('Storm organization: view belonged')) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= 'n.nid = ' . $user->stormorganization_nid;
|
||||
}
|
||||
$where[] = empty($cond) ? '0 = 1' : $cond;
|
||||
}
|
||||
|
||||
$where[] = "'storm_access' = 'storm_access'";
|
||||
return storm_rewrite_sql($sql, $where);
|
||||
}
|
||||
|
||||
function stormorganization_storm_rewrite_where_sql($query, $primary_table, $account) {
|
||||
static $conds = array();
|
||||
|
||||
if (isset($conds[$primary_table][$account->uid])) {
|
||||
return $conds[$primary_table][$account->uid];
|
||||
}
|
||||
|
||||
$cond = '';
|
||||
if (!preg_match("/'storm_access' = 'storm_access'/", $query)) {
|
||||
if (user_access('Storm organization: view all', $account)) {
|
||||
return '';
|
||||
}
|
||||
if (user_access('Storm organization: view own', $account)) {
|
||||
$cond .= "${primary_table}.uid = " . $account->uid;
|
||||
}
|
||||
if (user_access('Storm organization: view belonged', $account)) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
# If function is called without viewing an organization, this variable
|
||||
# may not be set. These lines check for that and set the organization
|
||||
# node id to zero if not otherwise set.
|
||||
if (!isset($account->stormorganization_nid)) {
|
||||
$account->stormorganization_nid = 0;
|
||||
}
|
||||
$cond .= ' sor1.nid = ' . $account->stormorganization_nid;
|
||||
}
|
||||
if ($cond) {
|
||||
$cond = " WHEN 'stormorganization' THEN (SELECT IF($cond, 1, 0) FROM {stormorganization} sor1 WHERE sor1.vid = ${primary_table}.vid) ";
|
||||
}
|
||||
else {
|
||||
$cond = " WHEN 'stormorganization' THEN 0 ";
|
||||
}
|
||||
}
|
||||
$conds[$primary_table][$account->uid] = $cond;
|
||||
return $cond;
|
||||
}
|
||||
|
||||
function stormorganization_menu() {
|
||||
$items = array();
|
||||
$items['organizations'] = array(
|
||||
'title' => 'Organizations',
|
||||
'description' => 'SuiteDesk organizations',
|
||||
'page callback' => 'stormorganization_list',
|
||||
'access arguments' => array('Storm organization: access'),
|
||||
'file' => 'stormorganization.admin.inc',
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
'weight' => 0,
|
||||
);
|
||||
|
||||
$items['storm/organizations/autocomplete'] = array(
|
||||
'title' => 'Organization autocomplete',
|
||||
'page callback' => 'stormorganization_autocomplete',
|
||||
'access arguments' => array('Storm organization: access'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'stormorganization.admin.inc',
|
||||
);
|
||||
|
||||
$items['admin/settings/suitedesk/organization'] = array(
|
||||
'title' => 'SuiteDesk organization',
|
||||
'description' => 'SuiteDesk organization administration page',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('stormorganization_admin_settings'),
|
||||
'access arguments' => array('Storm: access administration pages'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function stormorganization_theme() {
|
||||
return array(
|
||||
'stormorganization_list' => array(
|
||||
'file' => 'stormorganization.theme.inc',
|
||||
'arguments' => array('header', 'organizations'),
|
||||
),
|
||||
'stormorganization_view' => array(
|
||||
'file' => 'stormorganization.theme.inc',
|
||||
'arguments' => array('node', 'teaser', 'page'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function stormorganization_node_info() {
|
||||
return array(
|
||||
'stormorganization' => array(
|
||||
'name' => t('Organization'),
|
||||
'module' => 'stormorganization',
|
||||
'description' => t("An organization for SuiteDesk."),
|
||||
'title_label' => t("Name"),
|
||||
'body_label' => t("Note"),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function stormorganization_content_extra_fields($type_name) {
|
||||
if ($type_name == 'stormorganization') {
|
||||
return array(
|
||||
'group1' => array('label' => 'Customer/Provider/Active Group', 'weight' => -20),
|
||||
'group2' => array('label' => 'Prefix/Fullname Group', 'weight' => -19),
|
||||
'group3' => array('label' => 'Address Group', 'weight' => -18),
|
||||
'group4' => array('label' => 'Phone/WWW/Email Group', 'weight' => -17),
|
||||
'group5' => array('label' => 'Currency/Language/Tax ID Group', 'weight' => -16),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function stormorganization_form(&$node) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('Organizations'), 'organizations');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
$type = node_get_types('type', $node);
|
||||
|
||||
$form['#attributes']['class'] = 'stormcomponent_node_form';
|
||||
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => check_plain($type->title_label),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => $node->title,
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'title') : -18,
|
||||
);
|
||||
|
||||
$form['group1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
|
||||
$form['group1']['iscustomer'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Customer'),
|
||||
'#default_value' => $node->iscustomer,
|
||||
);
|
||||
|
||||
$form['group1']['isprovider'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Provider'),
|
||||
'#default_value' => $node->isprovider,
|
||||
);
|
||||
|
||||
$form['group1']['isactive'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Active'),
|
||||
'#default_value' => $node->isactive,
|
||||
);
|
||||
|
||||
$form['group2'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
|
||||
);
|
||||
|
||||
$form['group3'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -18,
|
||||
);
|
||||
|
||||
$form['group3']['address'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Address'),
|
||||
'#default_value' => isset($node->address) ? $node->address : NULL,
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$form['group3']['city'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('City'),
|
||||
'#size' => 20,
|
||||
'#default_value' => isset($node->city) ? $node->city : NULL,
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$form['group3']['provstate'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Province / State'),
|
||||
'#size' => 20,
|
||||
'#default_value' => isset($node->provstate) ? $node->provstate : NULL,
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$country_list = storm_attributes_bydomain('Country');
|
||||
$form['group3']['country'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Country'),
|
||||
'#options' => $country_list['values'],
|
||||
'#default_value' => $node->country,
|
||||
'#weight' => 4,
|
||||
);
|
||||
|
||||
$form['group3']['zip'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Zip'),
|
||||
'#size' => 15,
|
||||
'#default_value' => isset($node->zip) ? $node->zip : NULL,
|
||||
'#weight' => 5,
|
||||
);
|
||||
|
||||
$form['group4'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group4') : -17,
|
||||
);
|
||||
|
||||
$form['group4']['phone'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Phone'),
|
||||
'#default_value' => isset($node->phone) ? $node->phone : NULL,
|
||||
);
|
||||
|
||||
$form['group4']['www'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('WWW'),
|
||||
'#size' => 30,
|
||||
'#default_value' => isset($node->www) ? $node->www : NULL,
|
||||
);
|
||||
|
||||
$form['group4']['email'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Email'),
|
||||
'#size' => 30,
|
||||
'#default_value' => isset($node->email) ? $node->email : NULL,
|
||||
);
|
||||
|
||||
$form['group5'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group5') : -16,
|
||||
);
|
||||
|
||||
$currency_list = storm_attributes_bydomain('Currency');
|
||||
$form['group5']['currency'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Currency'),
|
||||
'#options' => $currency_list['values'],
|
||||
'#default_value' => $node->currency,
|
||||
);
|
||||
|
||||
$pricemode_list = storm_attributes_bydomain('Price mode');
|
||||
$form['group5']['pricemode'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Price mode'),
|
||||
'#default_value' => $node->pricemode,
|
||||
'#options' => $pricemode_list['values'],
|
||||
);
|
||||
|
||||
$form['group5']['price'] = array(
|
||||
'#title' => t('Price'),
|
||||
'#type' => 'textfield',
|
||||
'#size' => 15,
|
||||
'#default_value' => isset($node->price) ? $node->price : NULL,
|
||||
);
|
||||
|
||||
$languages = language_list('language', TRUE);
|
||||
$languages_options = array();
|
||||
foreach ($languages as $language_code => $language) {
|
||||
$languages_options[$language_code] = $language->name;
|
||||
}
|
||||
$form['group5']['orglanguage'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Language'),
|
||||
'#options' => $languages_options,
|
||||
'#default_value' => isset($node->orglanguage) ? $node->orglanguage : NULL,
|
||||
);
|
||||
|
||||
$form['group5']['taxid'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Tax ID'),
|
||||
'#size' => 20,
|
||||
'#default_value' => isset($node->taxid) ? $node->taxid : NULL,
|
||||
);
|
||||
|
||||
if ($type->has_body) {
|
||||
$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
|
||||
}
|
||||
|
||||
$form['title_old'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => isset($node->title_old) ? $node->title_old : NULL,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*/
|
||||
function stormorganization_form_stormorganization_node_form_alter(&$form, &$form_state) {
|
||||
global $conf;
|
||||
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$form['group3']['#access'] = FALSE;
|
||||
$form['group4']['#access'] = FALSE;
|
||||
$form['group5']['taxid']['#access'] = FALSE;
|
||||
$form['body_field']['#access'] = FALSE;
|
||||
|
||||
if (!empty($form['#node']->nid)) {
|
||||
$form['#after_build'][] = 'stormorganization_node_form_after_build';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stormorganization_node_form_after_build($form, &$form_state) {
|
||||
// https://www.silviogutierrez.com/blog/making-cck-fields-read-only-drupal-6:
|
||||
$form['title']['#attributes']['readonly'] = 'readonly';
|
||||
$form_state['values']['title'] = $form['title']['#default_value'];
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormorganization_insert($node) {
|
||||
db_query("INSERT INTO {stormorganization}
|
||||
(vid, nid, country, www, phone, email, currency,
|
||||
provstate, zip, city, address, taxid, orglanguage, iscustomer, isprovider, isactive, pricemode, price
|
||||
) VALUES
|
||||
(%d, %d, '%s', '%s', '%s', '%s', '%s',
|
||||
'%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %f
|
||||
)",
|
||||
$node->vid, $node->nid, $node->country, $node->www, $node->phone, $node->email, $node->currency,
|
||||
$node->provstate, $node->zip, $node->city, $node->address, $node->taxid,
|
||||
$node->orglanguage, $node->iscustomer, $node->isprovider, $node->isactive, $node->pricemode, $node->price
|
||||
);
|
||||
}
|
||||
|
||||
function stormorganization_update($node) {
|
||||
// if this is a new node or we're adding a new revision,
|
||||
if ($node->revision) {
|
||||
stormorganization_insert($node);
|
||||
}
|
||||
else {
|
||||
db_query("UPDATE {stormorganization} SET
|
||||
country='%s', www='%s', phone='%s', email='%s', currency = '%s',
|
||||
provstate = '%s', zip = '%s', city = '%s', address = '%s', taxid = '%s', orglanguage = '%s',
|
||||
iscustomer=%d, isprovider=%d, isactive=%d, pricemode='%s', price=%f WHERE vid = %d",
|
||||
$node->country, $node->www, $node->phone, $node->email, $node->currency,
|
||||
$node->provstate, $node->zip, $node->city, $node->address, $node->taxid, $node->orglanguage,
|
||||
$node->iscustomer, $node->isprovider, $node->isactive, $node->pricemode, $node->price, $node->vid);
|
||||
if ($node->title != $node->title_old) {
|
||||
module_invoke_all('stormorganization_change', $node->nid, $node->title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stormorganization_nodeapi(&$node, $op, $teaser, $page) {
|
||||
global $base_url, $conf;
|
||||
|
||||
if ($node->type != 'stormorganization') {
|
||||
return;
|
||||
}
|
||||
switch ($op) {
|
||||
case 'prepare':
|
||||
if (!isset($node->nid)) {
|
||||
$node->iscustomer = 1;
|
||||
$node->isprovider = 0;
|
||||
$node->isactive = 1;
|
||||
|
||||
$country_list = storm_attributes_bydomain('Country');
|
||||
$node->country = $country_list['default'];
|
||||
|
||||
$currency_list = storm_attributes_bydomain('Currency');
|
||||
$node->currency = $currency_list['default'];
|
||||
|
||||
$pricemode_list = storm_attributes_bydomain('Price mode');
|
||||
$node->pricemode = $pricemode_list['default'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'validate':
|
||||
$nid = $node->nid;
|
||||
$organization_name = $node->title;
|
||||
if (!$conf['storm_suitecrm'] || empty($organization_name)) {
|
||||
return;
|
||||
}
|
||||
// Checking if exists the organization in SuiteCRM:
|
||||
db_set_active('sugarcrm');
|
||||
db_query("SELECT id FROM accounts WHERE name = '%s' AND deleted = 0", $organization_name);
|
||||
$affected_rows = db_affected_rows();
|
||||
db_set_active('default');
|
||||
|
||||
if ($affected_rows == 0) {
|
||||
form_set_error('title', t('Account does not exists in SuiteCRM. Please check!'));
|
||||
} elseif ($affected_rows > 1) {
|
||||
form_set_error('title', t('More than one account with this name in SuiteCRM. Please check!'));
|
||||
} else {
|
||||
// Checking if there is another organization with the same name:
|
||||
$organization_nid = db_result(
|
||||
db_query(
|
||||
"SELECT nid FROM {node} WHERE type = 'stormorganization' AND title = '%s'" . (isset($nid) ? " AND nid != $nid" : '') . ' AND status = 1',
|
||||
$organization_name
|
||||
)
|
||||
);
|
||||
if (!empty($organization_nid)) {
|
||||
form_set_error('title',
|
||||
t('Already exists an !organization with this name. Please check!',
|
||||
array('!organization' => l(t('organization'), drupal_get_path_alias('node/' . $organization_nid)))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'presave':
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||
|
||||
db_set_active('sugarcrm');
|
||||
$query = 'SELECT a.id, a.date_modified, a.name, c.fullname_c, a.billing_address_street, a.billing_address_city, a.billing_address_state, a.billing_address_country, a.billing_address_postalcode, a.shipping_address_street, a.shipping_address_city, a.shipping_address_state, a.shipping_address_country, a.shipping_address_postalcode, a.phone_office, a.website, a.phone_alternate, a.phone_fax, addr.email_address, c.cif_c, c.linkedin_c, c.facebook_c, c.twitter_c, c.otherlink_c FROM accounts a LEFT JOIN accounts_cstm c ON (c.id_c = a.id) LEFT JOIN (email_addr_bean_rel bean, email_addresses addr) ON (bean.bean_id = a.id AND addr.id = bean.email_address_id AND bean.primary_address = 1) WHERE ';
|
||||
$query .= empty($sugarid) ? "a.name = '$node->title'" : "a.id = '$sugarid'";
|
||||
$query .= ' AND a.deleted = 0';
|
||||
$suitecrm_data = db_query($query);
|
||||
$affected_rows = db_affected_rows();
|
||||
db_set_active('default');
|
||||
|
||||
if ($affected_rows == 1) {
|
||||
$suitecrm_account = db_fetch_array($suitecrm_data);
|
||||
$node->field_stormorganization_sugarid[0]['value'] = $suitecrm_account['id'];
|
||||
$node->field_stormorganization_sugarmod[0]['value'] = $suitecrm_account['date_modified'];
|
||||
_stormorganization_suitecrm2node($suitecrm_account, $node);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'insert':
|
||||
case 'update':
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||
if (!empty($sugarid)) {
|
||||
db_set_active('sugarcrm');
|
||||
db_query("UPDATE accounts_cstm SET stormplus_c = '%s' WHERE id_c = '%s'", $base_url . '/organization/' . $node->nid, $sugarid);
|
||||
db_set_active('default');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||
if (!empty($sugarid)) {
|
||||
db_set_active('sugarcrm');
|
||||
db_query("UPDATE accounts_cstm SET stormplus_c = NULL WHERE id_c = '%s'", $sugarid);
|
||||
db_set_active('default');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete revision':
|
||||
// Notice that we're matching a single revision based on the node's vid.
|
||||
db_query('DELETE FROM {stormorganization} WHERE vid = %d', $node->vid);
|
||||
break;
|
||||
|
||||
case 'view':
|
||||
if ($conf['storm_suitecrm'] && !storm_cron_is_running()) {
|
||||
$sugarid = $node->field_stormorganization_sugarid[0]['value'];
|
||||
if (!empty($sugarid)) {
|
||||
db_set_active('sugarcrm');
|
||||
$suitecrm_data = db_query("SELECT id, date_modified FROM accounts WHERE id = '%s' AND deleted = 0", $sugarid);
|
||||
$affected_rows = db_affected_rows();
|
||||
db_set_active('default');
|
||||
|
||||
if ($affected_rows == 1) {
|
||||
$suitecrm_account = db_fetch_array($suitecrm_data);
|
||||
if ($node->field_stormorganization_sugarmod[0]['value'] != $suitecrm_account['date_modified']) {
|
||||
$node_update = node_load($node->nid);
|
||||
// Prepare node for a submit:
|
||||
$node_update = node_submit($node_update);
|
||||
node_save($node_update);
|
||||
drupal_set_message(t('SuiteCRM account has been updated, refresh to view changes.'));
|
||||
}
|
||||
} elseif ($page) {
|
||||
drupal_set_message(t('SuiteCRM account record associated not found.'), 'error');
|
||||
drupal_set_message(t('Account id !account does not exists in SuiteCRM.', array('!account' => "<strong>$sugarid</strong>")), 'error');
|
||||
drupal_set_message(t('Please contact your system administrator!'), 'error');
|
||||
}
|
||||
} elseif ($page) {
|
||||
drupal_set_message(t('There no SuiteCRM account record associated. Please check!'), 'error');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Before delete an organization.
|
||||
*/
|
||||
function _stormorganization_validate_predelete($node) {
|
||||
$nid = $node->nid;
|
||||
$items = array();
|
||||
|
||||
if (_storm_validate_predelete('stormperson', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/people">' . t('people') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormteam', "s.mnid = $nid")) {
|
||||
$items[] = '<a href="/teams">' . t('teams') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormproject', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/projects">' . t('projects') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormtask', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/tasks">' . t('tasks') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormticket', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/tickets">' . t('tickets') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormtimetracking', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/timetrackings">' . t('timetrackings') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormexpense', "s.organization_nid = $nid OR s.provider_nid = $nid")) {
|
||||
$items[] = '<a href="/expenses">' . t('expenses') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('storminvoice', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/invoices">' . t('invoices') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormdok', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/doks">' . t('documents') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormnote', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/notes">' . t('notes') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormevent', "s.organization_nid = $nid")) {
|
||||
$items[] = '<a href="/events">' . t('events') . '</a>';
|
||||
}
|
||||
|
||||
$nitems = count($items);
|
||||
if ($nitems > 0) {
|
||||
$elements = $items[0];
|
||||
if ($nitems > 2) {
|
||||
for ($i = 1; $i < $nitems - 1; $i++) {
|
||||
$elements .= ', ' . $items[$i];
|
||||
}
|
||||
}
|
||||
if ($nitems > 1) {
|
||||
$elements .= ' ' . t('and') . ' ' . $items[$nitems - 1];
|
||||
}
|
||||
form_set_error('title', t('Impossible to remove due to existing !elements associated to this organization!', array('!elements' => $elements)));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy SuiteCRM account data to node.
|
||||
*/
|
||||
function _stormorganization_suitecrm2node($suitecrm_data, &$node) {
|
||||
|
||||
$node->title = $suitecrm_data['name'];
|
||||
$node->field_stormorganization_fullname[0]['value'] = $suitecrm_data['fullname_c'];
|
||||
$node->taxid = $suitecrm_data['cif_c'];
|
||||
|
||||
$node->address = $suitecrm_data['billing_address_street'];
|
||||
$node->city = $suitecrm_data['billing_address_city'];
|
||||
$node->provstate = $suitecrm_data['billing_address_state'];
|
||||
$node->country = $suitecrm_data['billing_address_country'];
|
||||
$node->zip = $suitecrm_data['billing_address_postalcode'];
|
||||
$shipping_address =
|
||||
$suitecrm_data['billing_address_street'] != $suitecrm_data['shipping_address_street'] ||
|
||||
$suitecrm_data['billing_address_city'] != $suitecrm_data['shipping_address_city'] ||
|
||||
$suitecrm_data['billing_address_state'] != $suitecrm_data['shipping_address_state'] ||
|
||||
$suitecrm_data['billing_address_country'] != $suitecrm_data['shipping_address_country'] ||
|
||||
$suitecrm_data['billing_address_postalcode'] != $suitecrm_data['shipping_address_postalcode'];
|
||||
$node->field_stormorganization_address2[0]['value'] = $shipping_address ? $suitecrm_data['shipping_address_street'] : NULL;
|
||||
$node->field_stormorganization_city2[0]['value'] = $shipping_address ? $suitecrm_data['shipping_address_city'] : NULL;
|
||||
$node->field_stormorganization_provst2[0]['value'] = $shipping_address ? $suitecrm_data['shipping_address_state'] : NULL;
|
||||
$node->field_stormorganization_country2[0]['value'] = $shipping_address ? $suitecrm_data['shipping_address_country'] : NULL;
|
||||
$node->field_stormorganization_zip2[0]['value'] = $shipping_address ? $suitecrm_data['shipping_address_postalcode'] : NULL;
|
||||
|
||||
if (!valid_url($suitecrm_data['website'], TRUE)) {
|
||||
$suitecrm_data['website'] = valid_url('http://'. $suitecrm_data['website'], TRUE) ? 'http://'. $suitecrm_data['website'] : NULL;
|
||||
}
|
||||
if (!valid_url($suitecrm_data['linkedin_c'], TRUE)) {
|
||||
$suitecrm_data['linkedin_c'] = valid_url('http://'. $suitecrm_data['linkedin_c'], TRUE) ? 'http://'. $suitecrm_data['linkedin_c'] : NULL;
|
||||
}
|
||||
if (!valid_url($suitecrm_data['facebook_c'], TRUE)) {
|
||||
$suitecrm_data['facebook_c'] = valid_url('http://'. $suitecrm_data['facebook_c'], TRUE) ? 'http://'. $suitecrm_data['facebook_c'] : NULL;
|
||||
}
|
||||
if (!valid_url($suitecrm_data['twitter_c'], TRUE)) {
|
||||
$suitecrm_data['twitter_c'] = valid_url('http://'. $suitecrm_data['twitter_c'], TRUE) ? 'http://'. $suitecrm_data['twitter_c'] : NULL;
|
||||
}
|
||||
if (!valid_url($suitecrm_data['otherlink_c'], TRUE)) {
|
||||
$suitecrm_data['otherlink_c'] = valid_url('http://'. $suitecrm_data['otherlink_c'], TRUE) ? 'http://'. $suitecrm_data['otherlink_c'] : NULL;
|
||||
}
|
||||
|
||||
$node->phone = $suitecrm_data['phone_office'];
|
||||
$node->www = $suitecrm_data['website'];
|
||||
$node->email = $suitecrm_data['email_address'];
|
||||
|
||||
$node->field_stormorganization_tel2[0]['value'] = $suitecrm_data['phone_alternate'];
|
||||
$node->field_stormorganization_fax[0]['value'] = $suitecrm_data['phone_fax'];
|
||||
|
||||
$node->field_stormorganization_linkedin[0]['url'] = $suitecrm_data['linkedin_c'];
|
||||
$node->field_stormorganization_facebook[0]['url'] = $suitecrm_data['facebook_c'];
|
||||
$node->field_stormorganization_twitter[0]['url'] = $suitecrm_data['twitter_c'];
|
||||
$node->field_stormorganization_olink[0]['url'] = $suitecrm_data['otherlink_c'];
|
||||
}
|
||||
|
||||
function stormorganization_delete($node) {
|
||||
// Notice that we're matching all revision, by using the node's nid.
|
||||
db_query('DELETE FROM {stormorganization} WHERE nid = %d', $node->nid);
|
||||
}
|
||||
|
||||
function stormorganization_load($node) {
|
||||
$additions = db_fetch_object(db_query('SELECT * FROM {stormorganization} WHERE vid = %d', $node->vid));
|
||||
$additions->title_old = $node->title;
|
||||
return $additions;
|
||||
}
|
||||
|
||||
function stormorganization_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('Organizations'), 'organizations');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
return theme('stormorganization_view', $node, $teaser, $page);
|
||||
}
|
||||
|
||||
function stormorganization_admin_settings() {
|
||||
$form = array();
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormorganization} AS sor ON sor.nid=n.nid WHERE n.status=1 AND n.type='stormorganization' ORDER BY n.title";
|
||||
$s = stormorganization_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s);
|
||||
$organizations = array();
|
||||
while ($organization = db_fetch_object($r)) {
|
||||
$organizations[$organization->nid] = $organization->title;
|
||||
}
|
||||
|
||||
if (count($organizations) > 0) {
|
||||
$form['storm_organization_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Host organization'),
|
||||
'#options' => $organizations,
|
||||
'#default_value' => variable_get('storm_organization_nid', 0),
|
||||
'#description' => t('The organization that owns this system'),
|
||||
'#weight' => -30,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['storm_organization_nid'] = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('Host organization'),
|
||||
'#value' => t('There are no SuiteDesk Organizations in the system.') .'<br />'. l(t('Create a SuiteDesk Organization'), 'node/add/stormorganization'),
|
||||
);
|
||||
}
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
function stormorganization_views_api() {
|
||||
return array(
|
||||
'api' => 2,
|
||||
'path' => drupal_get_path('module', 'stormorganization'),
|
||||
);
|
||||
}
|
||||
|
||||
function stormorganization_storm_dashboard_links($type) {
|
||||
$links = array();
|
||||
if ($type == 'page' || $type == 'block') {
|
||||
$links[] = array(
|
||||
'theme' => 'storm_dashboard_link',
|
||||
'title' => t('Organizations'),
|
||||
'icon' => 'stormorganization-item',
|
||||
'path' => 'organizations',
|
||||
'params' => array(),
|
||||
'access_arguments' => 'Storm organization: access',
|
||||
'node_type' => 'stormorganization',
|
||||
'add_type' => 'stormorganization',
|
||||
'map' => array(),
|
||||
'weight' => 1,
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
156
modules/storm/stormorganization/stormorganization.test
Normal file
156
modules/storm/stormorganization/stormorganization.test
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk organization module
|
||||
*/
|
||||
class StormorganizationTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'SuiteDesk Organization functionality',
|
||||
'description' => 'Test the functionality of the SuiteDesk Organization module',
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormperson');
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm organization: add'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
}
|
||||
|
||||
public function testStormorganizationAccess() {
|
||||
$this->drupalGet('organizations');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Organizations list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('organizations');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk Organizations list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm organization: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('organizations');
|
||||
$this->assertText(t('Organizations'), t('Make sure the correct page has been displayed by checking that the title is "Organizations".'));
|
||||
}
|
||||
|
||||
public function testStormorganizationCreate() {
|
||||
$edit = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $edit, t('Save'));
|
||||
$this->assertText(t('Organization @title has been created.', array('@title' => $edit['title'])));
|
||||
}
|
||||
|
||||
public function testStormorganizationList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view all', 'Storm organization: edit all', 'Storm organization: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view belonged', 'Storm organization: edit belonged'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view own', 'Storm organization: edit own', 'Storm organization: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: access', 'Storm organization: view all', 'Storm organization: edit own', 'Storm organization: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$organization1 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $organization1, t('Save'));
|
||||
$organization1 = node_load(array('title' => $organization1['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $organization1->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create organization
|
||||
$this->drupalLogin($userOwn);
|
||||
$organization2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $organization2, t('Save'));
|
||||
$organization2 = node_load(array('title' => $organization2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$organization3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $organization3, t('Save'));
|
||||
$organization3 = node_load(array('title' => $organization3['title']));
|
||||
|
||||
// Test for 'Storm organization: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertLink($organization1->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
$this->assertLink($organization2->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
$this->assertLink($organization3->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
// Test for 'Storm organization: view belonged'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertLink($organization1->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($organization2->title, 'The Organization appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($organization3->title, 'The Organization does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm organization: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertNoLink($organization1->title, 'The Organization does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($organization2->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($organization3->title, 'The Organization does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm organization: view all', 'Storm organization: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('organizations');
|
||||
|
||||
$this->assertLink($organization1->title, 0, 'The Organization appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization1->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($organization2->title, 0, 'The Organization appears on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/edit', 'The Organization edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $organization2->nid .'/delete', 'The Organization edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($organization3->title, 0, 'The Organization appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/edit', 'The Organization edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $organization3->nid .'/delete', 'The Organization edit icon appears on the list');
|
||||
|
||||
}
|
||||
|
||||
}
|
193
modules/storm/stormorganization/stormorganization.theme.inc
Normal file
193
modules/storm/stormorganization/stormorganization.theme.inc
Normal file
|
@ -0,0 +1,193 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function theme_stormorganization_list($header, $organizations) {
|
||||
drupal_add_css(drupal_get_path('module', 'storm') .'/storm.css', 'module');
|
||||
|
||||
$rows = array();
|
||||
$countries = storm_attributes_bydomain('Country');
|
||||
foreach ($organizations as $key => $organization) {
|
||||
$rows[] = array(
|
||||
l($organization->title, 'node/'. $organization->nid),
|
||||
check_plain($countries['values'][$organization->country]),
|
||||
array(
|
||||
'data' => storm_icon_edit_node($organization, $_GET) .' '. storm_icon_delete_node($organization, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
}
|
||||
$o = theme('table', $header, $rows, array('id' => 'stormorganizations'));
|
||||
return $o;
|
||||
}
|
||||
|
||||
function theme_stormorganization_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
drupal_add_css(drupal_get_path('module', 'storm') . '/storm-node.css', 'module');
|
||||
|
||||
$node = node_prepare($node, $teaser);
|
||||
$l_pos = 1; // Used to increase the link position number (see issue 814820)
|
||||
|
||||
$node->content['links'] = array(
|
||||
'#prefix' => '<div class="stormlinks"><dl>',
|
||||
'#suffix' => '</dl></div>',
|
||||
'#weight' => -25,
|
||||
);
|
||||
|
||||
$node->content['links']['people'] = theme('storm_link', 'stormorganization', 'stormperson', $node->nid, $l_pos++);
|
||||
$node->content['links']['projects'] = theme('storm_link', 'stormorganization', 'stormproject', $node->nid, $l_pos++);
|
||||
$node->content['links']['tasks'] = theme('storm_link', 'stormorganization', 'stormtask', $node->nid, $l_pos++);
|
||||
$node->content['links']['tickets'] = theme('storm_link', 'stormorganization', 'stormticket', $node->nid, $l_pos++);
|
||||
$node->content['links']['doks'] = theme('storm_link', 'stormorganization', 'stormdok', $node->nid, $l_pos++);
|
||||
$node->content['links']['notes'] = theme('storm_link', 'stormorganization', 'stormnote', $node->nid, $l_pos++);
|
||||
$node->content['links']['events'] = theme('storm_link', 'stormorganization', 'stormevent', $node->nid, $l_pos++);
|
||||
$node->content['links']['expenses'] = theme('storm_link', 'stormorganization', 'stormexpense', $node->nid, $l_pos++);
|
||||
$node->content['links']['invoices'] = theme('storm_link', 'stormorganization', 'storminvoice', $node->nid, $l_pos++);
|
||||
$node->content['links']['timetrackings'] = theme('storm_link', 'stormorganization', 'stormtimetracking', $node->nid, $l_pos++);
|
||||
|
||||
$node->content['group2'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
|
||||
);
|
||||
|
||||
$node->content['group3'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -18,
|
||||
);
|
||||
|
||||
$node->content['group3']['address'] = array(
|
||||
'#prefix' => '<div class="address">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Address'), check_plain($node->address)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$node->content['group3']['city'] = array(
|
||||
'#prefix' => '<div class="city">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('City'), check_plain($node->city)),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group3']['provstate'] = array(
|
||||
'#prefix' => '<div class="provstate">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Province / State'), check_plain($node->provstate)),
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$node->content['group3'] ['country'] = array(
|
||||
'#prefix' => '<div class="country">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Country'), check_plain($node->country)),
|
||||
'#weight' => 4,
|
||||
);
|
||||
|
||||
$node->content['group3'] ['zip'] = array(
|
||||
'#prefix' => '<div class="zip">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Zip'), check_plain($node->zip)),
|
||||
'#weight' => 5,
|
||||
);
|
||||
|
||||
$node->content['group4'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group4') : -17,
|
||||
);
|
||||
|
||||
$node->content['group4']['phone'] = array(
|
||||
'#prefix' => '<div class="phone">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Phone'), check_plain($node->phone)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$node->content['group4']['www'] = array(
|
||||
'#prefix' => '<div class="www">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('WWW'), l($node->www, 'http://'. $node->www, array('absolute' => TRUE))),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group4']['email'] = array(
|
||||
'#prefix' => '<div class="email">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Email'), l($node->email, 'mailto:'. $node->email, array('absolute' => TRUE))),
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$node->content['group5'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group5') : -16,
|
||||
);
|
||||
|
||||
$node->content['group5']['currency'] = array(
|
||||
'#prefix' => '<div class="currency">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Currency'), check_plain($node->currency)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$languages = language_list('language', TRUE);
|
||||
$languages_options = array();
|
||||
foreach ($languages as $language_code => $language) {
|
||||
$languages_options[$language_code] = $language->name;
|
||||
}
|
||||
|
||||
$node->content['group5']['language'] = array(
|
||||
'#prefix' => '<div class="language">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Language'), check_plain($languages_options[$node->orglanguage])),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group5'] ['taxid'] = array(
|
||||
'#prefix' => '<div class="taxid">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Tax ID'), check_plain($node->taxid)),
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$node->content['group_item'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group_item') : -20,
|
||||
);
|
||||
$node->content['group_item']['author'] = array(
|
||||
'#prefix' => '<div class="author">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Submitted by'), theme('username', $node)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
$node->content['group_item']['created'] = array(
|
||||
'#prefix' => '<div class="created">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Created'), format_date($node->created, 'small')),
|
||||
'#weight' => 2,
|
||||
);
|
||||
if ($node->changed != $node->created) {
|
||||
$node->content['group_item']['modified'] = array(
|
||||
'#prefix' => '<div class="modified">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Modified'), format_date($node->changed, 'small')),
|
||||
'#weight' => 3,
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
$node->content['body_field'] = array(
|
||||
'#prefix' => '<div class="stormbody">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Note'), $node->content['body']['#value']),
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'body_field') : 0,
|
||||
);
|
||||
*/
|
||||
unset($node->content['body']);
|
||||
|
||||
return $node;
|
||||
}
|
320
modules/storm/stormorganization/stormorganization.views.inc
Normal file
320
modules/storm/stormorganization/stormorganization.views.inc
Normal file
|
@ -0,0 +1,320 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Functions to expose SuiteDesk organization data to views
|
||||
*/
|
||||
function stormorganization_views_data() {
|
||||
$data['stormorganization']['table']['group'] = 'SuiteDesk Organization';
|
||||
$data['stormorganization']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['prefix'] = array(
|
||||
'title' => t('Prefix'),
|
||||
'help' => t('SuiteDesk Organization Prefix'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['fullname'] = array(
|
||||
'title' => t('Fullname'),
|
||||
'help' => t('SuiteDesk Organization Fullname'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['country'] = array(
|
||||
'title' => t('Country'),
|
||||
'help' => t('SuiteDesk Organization Country'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['orglanguage'] = array(
|
||||
'title' => t('Language'),
|
||||
'help' => t('SuiteDesk Organization Language'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['provstate'] = array(
|
||||
'title' => t('Province / State'),
|
||||
'help' => t('SuiteDesk Organization Province / State'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['city'] = array(
|
||||
'title' => t('City'),
|
||||
'help' => t('SuiteDesk Organization City'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['zip'] = array(
|
||||
'title' => t('Zip'),
|
||||
'help' => t('SuiteDesk Organization Zip'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['address'] = array(
|
||||
'title' => t('Address'),
|
||||
'help' => t('SuiteDesk Organization Address'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['taxid'] = array(
|
||||
'title' => t('Tax ID'),
|
||||
'help' => t('SuiteDesk Organization Tax ID'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['email'] = array(
|
||||
'title' => t('Email'),
|
||||
'help' => t('SuiteDesk Organization Email'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['www'] = array(
|
||||
'title' => t('WWW'),
|
||||
'help' => t('SuiteDesk Organization WWW'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['phone'] = array(
|
||||
'title' => t('Phone'),
|
||||
'help' => t('SuiteDesk Organization Phone'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['currency'] = array(
|
||||
'title' => t('Currency'),
|
||||
'help' => t('SuiteDesk Organization Currency'),
|
||||
'field' => array(
|
||||
'handler' => 'storm_handler_field_attributes_domain',
|
||||
'domain' => 'Currency',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'storm_handler_filter_attributes_domain',
|
||||
'domain' => 'Currency',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['iscustomer'] = array(
|
||||
'title' => t('Is customer'),
|
||||
'help' => t('SuiteDesk Organization Is Customer'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['isprovider'] = array(
|
||||
'title' => t('Is provider'),
|
||||
'help' => t('SuiteDesk Organization Is Provider'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['isactive'] = array(
|
||||
'title' => t('Is active'),
|
||||
'help' => t('SuiteDesk Organization Is Active'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormorganization']['operation'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Edit/Delete link'),
|
||||
'help' => t('Provide a simple link to edit and delete the node.'),
|
||||
'handler' => 'storm_handler_field_operation',
|
||||
'type' => 'stormorganization',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function stormorganization_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
'handlers' => array(
|
||||
'storm_handler_field_attributes_domain' => array(
|
||||
'parent' => 'views_handler_field',
|
||||
),
|
||||
'storm_handler_filter_attributes_domain' => array(
|
||||
'parent' => 'views_handler_filter_in_operator',
|
||||
),
|
||||
'storm_handler_field_operation' => array(
|
||||
'parent' => 'views_handler_field_node_link',
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
Reference in a new issue