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
192
modules/storm/stormperson/stormperson.admin.inc
Normal file
192
modules/storm/stormperson/stormperson.admin.inc
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormperson_list() {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (array_key_exists('organization_nid', $_GET) &&
|
||||
($_SESSION['stormperson_list_filter']['organization_nid'] != $_GET['organization_nid'])) {
|
||||
$_SESSION['stormperson_list_filter']['organization_nid'] = $_GET['organization_nid'];
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormperson';
|
||||
|
||||
$params = $_GET;
|
||||
$params['organization_nid'] = isset($_SESSION['stormperson_list_filter']['organization_nid']) ? $_SESSION['stormperson_list_filter']['organization_nid'] : NULL;
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => t('Organization'),
|
||||
'field' => 'spe.organization_title',
|
||||
),
|
||||
array(
|
||||
'data' => t('Name'),
|
||||
'field' => 'n.title',
|
||||
),
|
||||
array(
|
||||
'data' => t('Email'),
|
||||
'field' => 'spe.email',
|
||||
),
|
||||
array(
|
||||
'data' => storm_icon_add_node($i, $params),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
$s = "SELECT n.*, spe.*, nre.format FROM {node} AS n
|
||||
INNER JOIN {stormperson} AS spe ON n.vid=spe.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
WHERE n.status=1 AND n.type='stormperson' ";
|
||||
if (isset($_SESSION['stormperson_list_filter']['organization_nid']) && $_SESSION['stormperson_list_filter']['organization_nid'] != 0) {
|
||||
$where[] = 'spe.organization_nid=%d';
|
||||
$args[] = $_SESSION['stormperson_list_filter']['organization_nid'];
|
||||
$filterfields[] = t('Organization');
|
||||
}
|
||||
if (isset($_SESSION['stormperson_list_filter']['name']) && $_SESSION['stormperson_list_filter']['name'] != '') {
|
||||
$where[] = "LOWER(n.title) LIKE LOWER('%%%s%%')";
|
||||
$args[] = $_SESSION['stormperson_list_filter']['name'];
|
||||
$filterfields[] = t('Name');
|
||||
}
|
||||
|
||||
// Sets $itemsperpage for fieldset label, but this section does not control storing of session variable.
|
||||
$itemsperpage = isset($_SESSION['stormperson_list_filter']['itemsperpage']) ? $_SESSION['stormperson_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('stormperson_list_filter', $filterdesc);
|
||||
|
||||
$s = stormperson_access_sql($s, $where);
|
||||
$s = db_rewrite_sql($s);
|
||||
|
||||
$tablesort = tablesort_sql($header);
|
||||
$r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args);
|
||||
|
||||
$people = array();
|
||||
while ($person = db_fetch_object($r)) {
|
||||
$people[] = $person;
|
||||
}
|
||||
|
||||
$o .= theme('stormperson_list', $header, $people);
|
||||
$o .= theme('pager', NULL, $itemsperpage, 0);
|
||||
print theme('page', $o);
|
||||
}
|
||||
|
||||
function stormperson_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$organization_nid = isset($_SESSION['stormperson_list_filter']['organization_nid']) ? $_SESSION['stormperson_list_filter']['organization_nid'] : 0;
|
||||
$name = isset($_SESSION['stormperson_list_filter']['name']) ? $_SESSION['stormperson_list_filter']['name'] : '';
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormperson_list_filter']['itemsperpage']) ? $_SESSION['stormperson_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
$_SESSION['stormperson_list_filter']['itemsperpage'] = $itemsperpage;
|
||||
|
||||
$form = array();
|
||||
|
||||
$form['filter'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $filterdesc,
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
$form['filter']['group1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => -20,
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} n INNER JOIN {stormorganization} sor ON sor.vid=n.vid 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;
|
||||
}
|
||||
$organizations = array(0 => t('All')) + $organizations;
|
||||
$form['filter']['group1']['organization_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Organization'),
|
||||
'#default_value' => $organization_nid,
|
||||
'#options' => $organizations,
|
||||
);
|
||||
|
||||
$form['filter']['group1']['name'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Name'),
|
||||
'#default_value' => $name,
|
||||
'#size' => 30,
|
||||
);
|
||||
|
||||
$form['filter']['group2'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#attributes' => array('class' => 'formgroup-submit'),
|
||||
);
|
||||
|
||||
$form['filter']['group2']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Filter'),
|
||||
'#submit' => array('stormperson_list_filter_filter'),
|
||||
);
|
||||
|
||||
$form['filter']['group2']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Reset'),
|
||||
'#submit' => array('stormperson_list_filter_reset'),
|
||||
);
|
||||
|
||||
$form['filter']['group2']['itemsperpage'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Items'),
|
||||
'#size' => 10,
|
||||
'#default_value' => $itemsperpage,
|
||||
'#prefix' => '<div class="container-inline">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormperson_list_filter_filter($form, &$form_state) {
|
||||
$_SESSION['stormperson_list_filter']['organization_nid'] = $form_state['values']['organization_nid'];
|
||||
$_SESSION['stormperson_list_filter']['name'] = $form_state['values']['name'];
|
||||
$_SESSION['stormperson_list_filter']['itemsperpage'] = $form_state['values']['itemsperpage'];
|
||||
}
|
||||
|
||||
function stormperson_list_filter_reset($form, &$form_state) {
|
||||
unset($_SESSION['stormperson_list_filter']);
|
||||
}
|
||||
|
||||
function _stormperson_organization_people_js($organization_nid=0) {
|
||||
$people = array();
|
||||
|
||||
if ($organization_nid) {
|
||||
$s = "SELECT n.nid, n.title FROM {node} n INNER JOIN {stormperson} AS spe ON n.vid=spe.vid WHERE n.status=1 AND n.type='stormperson' AND spe.organization_nid=%d ORDER BY n.title";
|
||||
$s = stormperson_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s, $organization_nid);
|
||||
|
||||
while ($item = db_fetch_object($r)) {
|
||||
$nid = $item->nid;
|
||||
$people[$nid] = $item->title;
|
||||
}
|
||||
}
|
||||
print drupal_to_js($people);
|
||||
exit();
|
||||
}
|
||||
|
12
modules/storm/stormperson/stormperson.info
Normal file
12
modules/storm/stormperson/stormperson.info
Normal file
|
@ -0,0 +1,12 @@
|
|||
name = Storm Person
|
||||
description = "Allows storage of people within organizations, and linking of these to Drupal user accounts."
|
||||
dependencies[] = storm
|
||||
dependencies[] = stormorganization
|
||||
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"
|
57
modules/storm/stormperson/stormperson.install
Normal file
57
modules/storm/stormperson/stormperson.install
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormperson_install() {
|
||||
drupal_install_schema('stormperson');
|
||||
variable_set('node_options_stormperson', array('status'));
|
||||
}
|
||||
|
||||
function stormperson_disable() {
|
||||
drupal_set_message(t('Nodes of type "Person" have not been deleted on disabling SuiteDesk Person. Please note that they will now have reduced functionality, and will not be protected by SuiteDesk Person access controls.'), 'warning');
|
||||
}
|
||||
|
||||
function stormperson_uninstall() {
|
||||
drupal_uninstall_schema('stormperson');
|
||||
}
|
||||
|
||||
function stormperson_schema() {
|
||||
$schema['stormperson'] = array(
|
||||
'fields' => array(
|
||||
'vid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'organization_nid' => array('type' => 'int'),
|
||||
'organization_title' => array('type' => 'varchar', 'length' => 150),
|
||||
'prefix' => array('type' => 'varchar', 'length' => 100),
|
||||
'fullname' => array('type' => 'varchar', 'length' => 100),
|
||||
'email' => array('type' => 'varchar', 'length' => 50),
|
||||
'www' => array('type' => 'varchar', 'length' => 100),
|
||||
'phone' => array('type' => 'varchar', 'length' => 100),
|
||||
'im' => array('type' => 'varchar', 'length' => 100),
|
||||
'user_uid' => array('type' => 'int'),
|
||||
),
|
||||
'primary key' => array('vid'),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'organization_nid' => array('organization_nid'),
|
||||
'user_uid' => array('user_uid'),
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Improve primary keys and indexes
|
||||
*/
|
||||
function stormperson_update_6201() {
|
||||
$return = array();
|
||||
db_drop_primary_key($return, 'stormperson');
|
||||
db_add_primary_key($return, 'stormperson', array('vid'));
|
||||
db_add_index($return, 'stormperson', 'nid', array('nid'));
|
||||
db_add_index($return, 'stormperson', 'organization_nid', array('organization_nid'));
|
||||
db_add_index($return, 'stormperson', 'user_uid', array('user_uid'));
|
||||
return $return;
|
||||
}
|
19
modules/storm/stormperson/stormperson.js
Normal file
19
modules/storm/stormperson/stormperson.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
function stormperson_organization_people(_organization_select, _person_select_id, _with_all_option, _all_text) {
|
||||
var person_select = $("#" + _person_select_id).get(0);
|
||||
storm_empty_select(person_select);
|
||||
var organization_nid = _organization_select.value;
|
||||
if (!organization_nid) organization_nid=0;
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
async: true,
|
||||
url: Drupal.settings.storm.organization_people_url + Drupal.encodeURIComponent(organization_nid),
|
||||
dataType: "string",
|
||||
success: function (data) {
|
||||
var items = Drupal.parseJson(data);
|
||||
storm_fill_select(person_select, items, _with_all_option, _all_text);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
834
modules/storm/stormperson/stormperson.module
Normal file
834
modules/storm/stormperson/stormperson.module
Normal file
|
@ -0,0 +1,834 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormperson_help($path, $arg) {
|
||||
$o = '';
|
||||
|
||||
switch ($path) {
|
||||
case "admin/help#stormperson":
|
||||
$o = '<p>'. t("Provides person support for SuiteDesk") .'</p>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function stormperson_init() {
|
||||
if (function_exists('drupal_set_content')) {
|
||||
global $user;
|
||||
if ($user->uid && !isset($user->stormorganization_nid) || !isset($user->stormperson_nid)) {
|
||||
_stormperson_user_load($user);
|
||||
}
|
||||
if (!$user->uid || !isset($user->stormperson_nid)) {
|
||||
$user->stormperson_nid = -1;
|
||||
}
|
||||
if (!$user->uid || !isset($user->stormorganization_nid)) {
|
||||
$user->stormorganization_nid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
'storm' => array(
|
||||
'organization_people_url' => url('storm/organization_people_js/')
|
||||
),
|
||||
);
|
||||
drupal_add_js($settings, 'setting');
|
||||
drupal_add_js(drupal_get_path('module', 'storm') .'/storm.js', 'module', 'header', FALSE);
|
||||
drupal_add_js(drupal_get_path('module', 'stormperson') .'/stormperson.js', 'module', 'header', FALSE);
|
||||
}
|
||||
|
||||
function stormperson_perm() {
|
||||
return array(
|
||||
'Storm person: access',
|
||||
'Storm person: add',
|
||||
'Storm person: delete all',
|
||||
'Storm person: delete own',
|
||||
'Storm person: delete of user organization',
|
||||
'Storm person: delete when linked to own user account',
|
||||
'Storm person: edit all',
|
||||
'Storm person: edit own',
|
||||
'Storm person: edit of user organization',
|
||||
'Storm person: edit when linked to own user account',
|
||||
'Storm person: view all',
|
||||
'Storm person: view own',
|
||||
'Storm person: view of user organization',
|
||||
'Storm person: view when linked to own user account',
|
||||
);
|
||||
}
|
||||
|
||||
function stormperson_access($op, $node, $account = NULL) {
|
||||
if (empty($account)) {
|
||||
global $user;
|
||||
$account = $user;
|
||||
}
|
||||
|
||||
if ($op == 'create') {
|
||||
return user_access('Storm person: add');
|
||||
}
|
||||
|
||||
if (is_numeric($node)) {
|
||||
$node = node_load($node);
|
||||
}
|
||||
|
||||
if ($op == 'delete') {
|
||||
if (user_access('Storm person: delete all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: delete own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: delete of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: delete when linked to own user account') && ($account->uid == $node->user_uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'update') {
|
||||
if (user_access('Storm person: edit all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: edit own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: edit of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: edit when linked to own user account') && ($account->uid == $node->user_uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'view') {
|
||||
if (user_access('Storm person: view all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: view own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: view of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm person: view when linked to own user account') && ($account->uid == $node->user_uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function stormperson_access_sql($sql, $where = array()) {
|
||||
if (!user_access('Storm person: view all')) {
|
||||
global $user;
|
||||
|
||||
$cond = '';
|
||||
if (user_access('Storm person: view own')) {
|
||||
$cond .= 'n.uid = ' . $user->uid;
|
||||
}
|
||||
if (user_access('Storm person: view of user organization')) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= 'spe.organization_nid = ' . $user->stormorganization_nid;
|
||||
}
|
||||
if (user_access('Storm person: view when linked to own user account')) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= 'spe.user_uid = ' . $user->uid;
|
||||
}
|
||||
$where[] = empty($cond) ? '0 = 1' : $cond;
|
||||
}
|
||||
|
||||
$where[] = "'storm_access' = 'storm_access'";
|
||||
return storm_rewrite_sql($sql, $where);
|
||||
}
|
||||
|
||||
function stormperson_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 person: view all', $account)) {
|
||||
return '';
|
||||
}
|
||||
if (user_access('Storm person: view own', $account)) {
|
||||
$cond .= " ${primary_table}.uid = " . $account->uid;
|
||||
}
|
||||
if (user_access('Storm person: view of user organization', $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 .= ' spe1.organization_nid = ' . $account->stormorganization_nid;
|
||||
}
|
||||
if (user_access('Storm person: view when linked to own user account', $account)) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= ' spe1.user_uid = ' . $account->uid;
|
||||
}
|
||||
if ($cond) {
|
||||
$cond = " WHEN 'stormperson' THEN (SELECT IF($cond, 1, 0) FROM {stormperson} spe1 WHERE spe1.vid = ${primary_table}.vid) ";
|
||||
}
|
||||
else {
|
||||
$cond = " WHEN 'stormperson' THEN 0 ";
|
||||
}
|
||||
}
|
||||
$conds[$primary_table][$account->uid] = $cond;
|
||||
return $cond;
|
||||
}
|
||||
|
||||
function stormperson_menu() {
|
||||
$items['people'] = array(
|
||||
'title' => 'People',
|
||||
'description' => 'SuiteDesk people',
|
||||
'page callback' => 'stormperson_list',
|
||||
'access arguments' => array('Storm person: access'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
'file' => 'stormperson.admin.inc',
|
||||
'weight' => 1,
|
||||
);
|
||||
|
||||
$items['storm/organization_people_js/%'] = array(
|
||||
'title' => 'People',
|
||||
'page callback' => '_stormperson_organization_people_js',
|
||||
'page arguments' => array(2),
|
||||
'access callback' => TRUE,
|
||||
'file' => 'stormperson.admin.inc',
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['storm/stormperson_js'] = array(
|
||||
'title' => 'Stormperson - User autocomplete',
|
||||
'page callback' => 'stormperson_user_autocomplete',
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array('access user profiles'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function stormperson_theme() {
|
||||
return array(
|
||||
'stormperson_list' => array(
|
||||
'file' => 'stormperson.theme.inc',
|
||||
'arguments' => array('header', 'people'),
|
||||
),
|
||||
'stormperson_people' => array(
|
||||
'file' => 'stormperson.theme.inc',
|
||||
'arguments' => array('header', 'people'),
|
||||
),
|
||||
'stormperson_view' => array(
|
||||
'file' => 'stormperson.theme.inc',
|
||||
'arguments' => array('node', 'teaser', 'page'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function stormperson_node_info() {
|
||||
return array(
|
||||
'stormperson' => array(
|
||||
'name' => t('Person'),
|
||||
'module' => 'stormperson',
|
||||
'description' => t("A person for SuiteDesk."),
|
||||
'title_label' => t("Name"),
|
||||
'body_label' => t("Description"),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function stormperson_content_extra_fields($type_name) {
|
||||
if ($type_name == 'stormperson') {
|
||||
return array(
|
||||
'group1' => array('label' => 'Prefix/Name Group', 'weight' => -20),
|
||||
'group2' => array('label' => 'Organization/User Group', 'weight' => -19),
|
||||
'group3' => array('label' => 'Email/WWW Group', 'weight' => -18),
|
||||
'group4' => array('label' => 'Phone/IM Group', 'weight' => -17),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function stormperson_stormorganization_change($organization_nid, $organization_title) {
|
||||
$s = "UPDATE {stormperson} SET organization_title='%s' WHERE organization_nid=%d AND organization_title <> '%s'";
|
||||
db_query($s, $organization_title, $organization_nid, $organization_title);
|
||||
}
|
||||
|
||||
function stormperson_form(&$node) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('People'), 'people');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (arg(1)=='add') {
|
||||
if (array_key_exists('organization_nid', $_GET) && !$node->organization_nid) {
|
||||
$node->organization_nid = $_GET['organization_nid'];
|
||||
}
|
||||
|
||||
if (!empty($_SESSION['stormperson_list_filter']['organization_nid']) && !$node->organization_nid) {
|
||||
$node->organization_nid = $_SESSION['stormperson_list_filter']['organization_nid'];
|
||||
}
|
||||
}
|
||||
|
||||
$type = node_get_types('type', $node);
|
||||
|
||||
$form['#attributes']['class'] = 'stormcomponent_node_form';
|
||||
|
||||
$form['group1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
|
||||
$form['group1']['prefix'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Prefix'),
|
||||
'#size' => 20,
|
||||
'#default_value' => isset($node->prefix) ? $node->prefix : '',
|
||||
);
|
||||
|
||||
$form['group1']['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => check_plain($type->title_label),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => $node->title,
|
||||
'#size' => 40,
|
||||
);
|
||||
|
||||
$form['group2'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormorganization} AS sor ON sor.vid=n.vid 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 (!isset($node->organization_nid)) $node->organization_nid = $organization->nid;
|
||||
}
|
||||
$form['group2']['organization_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Organization'),
|
||||
'#default_value' => $node->organization_nid,
|
||||
'#options' => $organizations,
|
||||
'#required' => TRUE,
|
||||
'#attributes' => array('onchange' => "stormperson_organization_project_tasks(this, 'edit-project-nid', 'edit-parent-nid', true, '-')"),
|
||||
);
|
||||
|
||||
$form['group2']['user_name'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('User'),
|
||||
'#default_value' => isset($node->user_name) ? $node->user_name : '',
|
||||
'#autocomplete_path' => 'storm/stormperson_js',
|
||||
'#size' => 40,
|
||||
);
|
||||
|
||||
$form['group3'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -18,
|
||||
);
|
||||
|
||||
$form['group3']['email'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Email'),
|
||||
'#size' => 30,
|
||||
'#default_value' => isset($node->email) ? $node->email : '',
|
||||
);
|
||||
|
||||
$form['group3']['www'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('WWW'),
|
||||
'#size' => 30,
|
||||
'#default_value' => isset($node->www) ? $node->www : '',
|
||||
);
|
||||
|
||||
$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'),
|
||||
'#size' => 30,
|
||||
'#default_value' => isset($node->phone) ? $node->phone : '',
|
||||
);
|
||||
|
||||
$form['group4']['im'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('IM'),
|
||||
'#size' => 30,
|
||||
'#default_value' => isset($node->im) ? $node->im : '',
|
||||
);
|
||||
|
||||
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 stormperson_form_stormperson_node_form_alter(&$form, &$form_state) {
|
||||
global $conf;
|
||||
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$form['group1']['#access'] = FALSE;
|
||||
$form['group3']['#access'] = FALSE;
|
||||
$form['group4']['#access'] = FALSE;
|
||||
# $form['group2']['user_name']['#required'] = TRUE;
|
||||
$form['body_field']['#access'] = FALSE;
|
||||
|
||||
if (!empty($form['#node']->nid)) {
|
||||
$form['#after_build'][] = 'stormperson_node_form_after_build';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stormperson_node_form_after_build($form, &$form_state) {
|
||||
// https://www.silviogutierrez.com/blog/making-cck-fields-read-only-drupal-6:
|
||||
$form['field_stormperson_name'][0]['value']['#attributes']['readonly'] = 'readonly';
|
||||
$form_state['values']['field_stormperson_name'][0]['value'] = $form['field_stormperson_name']['#default_value']['value'];
|
||||
$form['field_stormperson_lastname'][0]['value']['#attributes']['readonly'] = 'readonly';
|
||||
$form_state['values']['field_stormperson_lastname'][0]['value'] = $form['field_stormperson_lastname']['#default_value']['value'];
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormperson_validate($node, &$form) {
|
||||
if (!empty($node->user_name)) {
|
||||
$ass_user = user_load(array('name' => $node->user_name));
|
||||
if (!empty($ass_user)) {
|
||||
$result = db_query("SELECT n.nid, n.title FROM {node} n JOIN {stormperson} stp ON (n.nid = stp.nid) WHERE stp.user_uid = %d", $ass_user->uid);
|
||||
$row = db_fetch_array($result);
|
||||
if ($row && (empty($form['#node']->user_name) || ($form['#node']->user_name != $node->user_name))) {
|
||||
form_set_error('user_name', t('This Drupal user is already assigned to a SuiteDesk person (!link). The same Drupal user can not be assigned to two SuiteDesk people.', array('!link' => l($row['title'], 'node/'. $row['nid']))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stormperson_user_autocomplete($string = '') {
|
||||
$matches = array();
|
||||
if ($string) {
|
||||
$result = db_query_range("SELECT name FROM {users} WHERE name LIKE '%s%%' AND uid NOT IN (SELECT user_uid FROM {stormperson})", $string, 0, 10);
|
||||
while ($user = db_fetch_object($result)) {
|
||||
$matches[$user->name] = check_plain($user->name);
|
||||
}
|
||||
}
|
||||
|
||||
drupal_json($matches);
|
||||
}
|
||||
|
||||
function stormperson_insert($node) {
|
||||
_stormperson_beforesave($node);
|
||||
|
||||
db_query("INSERT INTO {stormperson}
|
||||
(vid, nid, organization_nid, organization_title,
|
||||
prefix, email, www, phone, im, user_uid)
|
||||
VALUES
|
||||
(%d, %d, %d, '%s',
|
||||
'%s', '%s', '%s', '%s', '%s', %d)",
|
||||
$node->vid, $node->nid, $node->organization_nid, $node->organization_title,
|
||||
$node->prefix, $node->email, $node->www, $node->phone, $node->im, $node->user_uid);
|
||||
_stormperson_aftersave($node);
|
||||
}
|
||||
|
||||
function stormperson_update($node) {
|
||||
// if this is a new node or we're adding a new revision,
|
||||
if ($node->revision) {
|
||||
stormperson_insert($node);
|
||||
}
|
||||
else {
|
||||
_stormperson_beforesave($node);
|
||||
|
||||
db_query("UPDATE {stormperson} SET
|
||||
organization_nid=%d, organization_title='%s',
|
||||
prefix='%s', email='%s', www='%s',
|
||||
phone='%s', im='%s', user_uid=%d
|
||||
WHERE vid = %d",
|
||||
$node->organization_nid, $node->organization_title,
|
||||
$node->prefix, $node->email, $node->www,
|
||||
$node->phone, $node->im, $node->user_uid,
|
||||
$node->vid);
|
||||
|
||||
_stormperson_aftersave($node);
|
||||
|
||||
if ($node->title != $node->title_old) {
|
||||
module_invoke_all('stormperson_change', $node->nid, $node->title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _stormperson_beforesave(&$node) {
|
||||
$ass_user = user_load(array('name' => $node->user_name));
|
||||
$node->user_uid = $ass_user->uid;
|
||||
if (!$node->email) {
|
||||
$node->email = $ass_user->mail;
|
||||
}
|
||||
|
||||
$s = "SELECT n.title FROM {node} AS n INNER JOIN {stormorganization} AS p ON n.nid=p.nid
|
||||
WHERE type='stormorganization' AND n.nid=%d";
|
||||
$r = db_query($s, $node->organization_nid);
|
||||
$o = db_fetch_object($r);
|
||||
$node->organization_title = $o->title;
|
||||
}
|
||||
|
||||
function _stormperson_aftersave(&$node) {
|
||||
global $user;
|
||||
if ($user->uid == $node->user_uid) {
|
||||
$user->stormperson_nid = $node->user_nid;
|
||||
$user->stormorganization_nid = $node->organization_nid;
|
||||
}
|
||||
}
|
||||
|
||||
function stormperson_nodeapi(&$node, $op, $teaser, $page) {
|
||||
global $base_url, $conf;
|
||||
|
||||
if ($node->type != 'stormperson') {
|
||||
return;
|
||||
}
|
||||
switch ($op) {
|
||||
case 'validate':
|
||||
$nid = $node->nid;
|
||||
$name = $node->field_stormperson_name[0]['value'];
|
||||
$lastname = $node->field_stormperson_lastname[0]['value'];
|
||||
$fullname = empty($lastname) ? $name : $lastname . ', ' . $name;
|
||||
if (!$conf['storm_suitecrm'] || empty($fullname)) {
|
||||
return;
|
||||
}
|
||||
// Checking if exists the contact in SuiteCRM:
|
||||
db_set_active('sugarcrm');
|
||||
db_query("SELECT id FROM contacts WHERE first_name = '%s' AND last_name = '%s' AND deleted = 0", $name, $lastname);
|
||||
$affected_rows = db_affected_rows();
|
||||
db_set_active('default');
|
||||
|
||||
if ($affected_rows == 0) {
|
||||
form_set_error('title', t('Contact does not exists in SuiteCRM. Please check!'));
|
||||
} elseif ($affected_rows > 1) {
|
||||
form_set_error('title', t('More than one contact with this name and lastname in SuiteCRM. Please check!'));
|
||||
} else {
|
||||
// Checking if there is another contact with the same name:
|
||||
$person_nid = db_result(
|
||||
db_query(
|
||||
"SELECT nid FROM {node} WHERE type = 'stormperson' AND title = '%s'" . (isset($nid) ? " AND nid != $nid" : '') . ' AND status = 1',
|
||||
$fullname
|
||||
)
|
||||
);
|
||||
if (!empty($person_nid)) {
|
||||
form_set_error('title',
|
||||
t('Already exists a !person with this name. Please check!',
|
||||
array('!person' => l(t('person'), drupal_get_path_alias('node/' . $person_nid)))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'presave':
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||
|
||||
db_set_active('sugarcrm');
|
||||
$query = 'SELECT c.id, c.date_modified, c.salutation, c.first_name, c.last_name, c.primary_address_street, c.primary_address_city, c.primary_address_state, c.primary_address_country, c.primary_address_postalcode, c.alt_address_street, c.alt_address_city, c.alt_address_state, c.alt_address_country, c.alt_address_postalcode, c.phone_work, c.phone_mobile, c.phone_fax, addr.email_address, c.department, c.title, cc.website_c, cc.linkedin_c, cc.facebook_c, cc.twitter_c, cc.otherlink_c FROM contacts c LEFT JOIN contacts_cstm cc ON (cc.id_c = c.id) LEFT JOIN (email_addr_bean_rel bean, email_addresses addr) ON (bean.bean_id = c.id AND addr.id = bean.email_address_id AND bean.primary_address = 1 AND bean.deleted = 0) WHERE ';
|
||||
$query .= empty($sugarid) ? "c.first_name = '" . $node->field_stormperson_name[0]['value'] . "' AND c.last_name = '" . $node->field_stormperson_lastname[0]['value'] . "'" : "c.id = '$sugarid'";
|
||||
$query .= ' AND c.deleted = 0';
|
||||
$suitecrm_data = db_query($query);
|
||||
$affected_rows = db_affected_rows();
|
||||
db_set_active('default');
|
||||
|
||||
if ($affected_rows == 1) {
|
||||
$suitecrm_person = db_fetch_array($suitecrm_data);
|
||||
$node->field_stormperson_sugarid[0]['value'] = $suitecrm_person['id'];
|
||||
$node->field_stormperson_sugarmod[0]['value'] = $suitecrm_person['date_modified'];
|
||||
_stormperson_suitecrm2node($suitecrm_person, $node);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'insert':
|
||||
case 'update':
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||
if (!empty($sugarid)) {
|
||||
db_set_active('sugarcrm');
|
||||
db_query("UPDATE contacts_cstm SET stormplus_c = '%s' WHERE id_c = '%s'", $base_url . '/people/' . $node->nid, $sugarid);
|
||||
db_set_active('default');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if ($conf['storm_suitecrm']) {
|
||||
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||
if (!empty($sugarid)) {
|
||||
db_set_active('sugarcrm');
|
||||
db_query("UPDATE contacts_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 {stormperson} WHERE vid = %d', $node->vid);
|
||||
break;
|
||||
|
||||
case 'view':
|
||||
if ($conf['storm_suitecrm'] && !storm_cron_is_running()) {
|
||||
$sugarid = $node->field_stormperson_sugarid[0]['value'];
|
||||
if (!empty($sugarid)) {
|
||||
db_set_active('sugarcrm');
|
||||
$suitecrm_data = db_query("SELECT id, date_modified FROM contacts WHERE id = '%s' AND deleted = 0", $sugarid);
|
||||
$affected_rows = db_affected_rows();
|
||||
db_set_active('default');
|
||||
|
||||
if ($affected_rows == 1) {
|
||||
$suitecrm_contact = db_fetch_array($suitecrm_data);
|
||||
if ($node->field_stormperson_sugarmod[0]['value'] != $suitecrm_contact['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 contact has been updated, refresh to view changes.'));
|
||||
}
|
||||
} elseif ($page) {
|
||||
drupal_set_message(t('SuiteCRM contact record associated not found.'), 'error');
|
||||
drupal_set_message(t('Contact id !contact does not exists in SuiteCRM.', array('!contact' => "<strong>$sugarid</strong>")), 'error');
|
||||
drupal_set_message(t('Please contact your system administrator!'), 'error');
|
||||
}
|
||||
} elseif ($page) {
|
||||
drupal_set_message(t('There no SuiteCRM contact record associated. Please check!'), 'error');
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Before delete a person.
|
||||
*/
|
||||
function _stormperson_validate_predelete($node) {
|
||||
$nid = $node->nid;
|
||||
$items = array();
|
||||
|
||||
if (_storm_validate_predelete('stormteam', "s.mnid = $nid")) {
|
||||
$items[] = '<a href="/teams">' . t('teams') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormproject', "s.manager_nid = $nid OR s.assigned_nid = $nid")) {
|
||||
$items[] = '<a href="/projects">' . t('projects') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormtask', "s.assigned_nid = $nid")) {
|
||||
$items[] = '<a href="/tasks">' . t('tasks') . '</a>';
|
||||
}
|
||||
if (_storm_validate_predelete('stormticket', "s.assigned_nid = $nid")) {
|
||||
$items[] = '<a href="/tickets">' . t('tickets') . '</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 person!', array('!elements' => $elements)));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy SuiteCRM contact data to node.
|
||||
*/
|
||||
function _stormperson_suitecrm2node($suitecrm_data, &$node) {
|
||||
|
||||
$node->prefix = $suitecrm_data['salutation'];
|
||||
$node->field_stormperson_name[0]['value'] = $suitecrm_data['first_name'];
|
||||
$node->field_stormperson_lastname[0]['value'] = $suitecrm_data['last_name'];
|
||||
$node->title = empty($suitecrm_data['last_name']) ? $suitecrm_data['first_name'] : $suitecrm_data['last_name'] . ', ' . $suitecrm_data['first_name'];
|
||||
|
||||
$node->field_stormperson_depart[0]['value'] = $suitecrm_data['department'];
|
||||
$node->field_stormperson_job[0]['value'] = $suitecrm_data['title'];
|
||||
|
||||
$node->field_stormperson_address[0]['value'] = $suitecrm_data['primary_address_street'];
|
||||
$node->field_stormperson_city[0]['value'] = $suitecrm_data['primary_address_city'];
|
||||
$node->field_stormperson_provst[0]['value'] = $suitecrm_data['primary_address_state'];
|
||||
$node->field_stormperson_country[0]['value'] = $suitecrm_data['primary_address_country'];
|
||||
$node->field_stormperson_zip[0]['value'] = $suitecrm_data['primary_address_postalcode'];
|
||||
$alt_address =
|
||||
$suitecrm_data['primary_address_street'] != $suitecrm_data['alt_address_street'] ||
|
||||
$suitecrm_data['primary_address_city'] != $suitecrm_data['alt_address_city'] ||
|
||||
$suitecrm_data['primary_address_state'] != $suitecrm_data['alt_address_state'] ||
|
||||
$suitecrm_data['primary_address_country'] != $suitecrm_data['alt_address_country'] ||
|
||||
$suitecrm_data['primary_address_postalcode'] != $suitecrm_data['alt_address_postalcode'];
|
||||
$node->field_stormperson_address2[0]['value'] = $alt_address ? $suitecrm_data['alt_address_street'] : NULL;
|
||||
$node->field_stormperson_city2[0]['value'] = $alt_address ? $suitecrm_data['alt_address_city'] : NULL;
|
||||
$node->field_stormperson_provst2[0]['value'] = $alt_address ? $suitecrm_data['alt_address_state'] : NULL;
|
||||
$node->field_stormperson_country2[0]['value'] = $alt_address ? $suitecrm_data['alt_address_country'] : NULL;
|
||||
$node->field_stormperson_zip2[0]['value'] = $alt_address ? $suitecrm_data['alt_address_postalcode'] : NULL;
|
||||
|
||||
if (!valid_url($suitecrm_data['website_c'], TRUE)) {
|
||||
$suitecrm_data['website_c'] = valid_url('http://'. $suitecrm_data['website_c'], TRUE) ? 'http://'. $suitecrm_data['website_c'] : 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->www = $suitecrm_data['website_c'];
|
||||
$node->email = $suitecrm_data['email_address'];
|
||||
$node->phone = $suitecrm_data['phone_work'];
|
||||
|
||||
$node->field_stormperson_celular[0]['value'] = $suitecrm_data['phone_mobile'];
|
||||
$node->field_stormperson_fax[0]['value'] = $suitecrm_data['phone_fax'];
|
||||
|
||||
$node->field_stormperson_linkedin[0]['url'] = $suitecrm_data['linkedin_c'];
|
||||
$node->field_stormperson_facebook[0]['url'] = $suitecrm_data['facebook_c'];
|
||||
$node->field_stormperson_twitter[0]['url'] = $suitecrm_data['twitter_c'];
|
||||
$node->field_stormperson_olink[0]['url'] = $suitecrm_data['otherlink_c'];
|
||||
}
|
||||
|
||||
function stormperson_delete($node) {
|
||||
// Notice that we're matching all revision, by using the node's nid.
|
||||
db_query('DELETE FROM {stormperson} WHERE nid = %d', $node->nid);
|
||||
global $user;
|
||||
if ($user->uid == $node->user_uid) {
|
||||
$user->stormperson_nid = -1;
|
||||
$user->stormorganization_nid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
function stormperson_load($node) {
|
||||
$additions = db_fetch_object(db_query('SELECT * FROM {stormperson} WHERE vid = %d', $node->vid));
|
||||
$ass_user = user_load(array('uid' => $additions->user_uid));
|
||||
$additions->user_name = $ass_user->name;
|
||||
$additions->title_old = $node->title;
|
||||
return $additions;
|
||||
}
|
||||
|
||||
function stormperson_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
$breadcrumb[] = l(t('People'), 'people');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
return theme('stormperson_view', $node, $teaser, $page);
|
||||
}
|
||||
|
||||
function _stormperson_people_access($node=NULL) {
|
||||
if ($node == NULL) return FALSE;
|
||||
if ($node->type == 'stormorganization') return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function stormperson_user($type, &$edit, &$account, $category = NULL) {
|
||||
switch ($type) {
|
||||
case 'load':
|
||||
return _stormperson_user_load($account);
|
||||
case 'delete':
|
||||
return _stormperson_user_delete($account);
|
||||
}
|
||||
}
|
||||
|
||||
function _stormperson_user_load(&$account) {
|
||||
static $loaded_persons = array();
|
||||
if (isset($loaded_persons[$account->uid])) {
|
||||
if (is_object($loaded_persons[$account->uid])) {
|
||||
$account->stormperson_nid = $loaded_persons[$account->uid]->nid;
|
||||
$account->stormorganization_nid = $loaded_persons[$account->uid]->organization_nid;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$a = db_fetch_object(db_query("SELECT nid, organization_nid FROM {stormperson} WHERE user_uid=%d", $account->uid));
|
||||
if ($a) {
|
||||
$loaded_persons[$account->uid] = new stdClass();
|
||||
$loaded_persons[$account->uid]->nid = $a->nid;
|
||||
$loaded_persons[$account->uid]->organization_nid = $a->organization_nid;
|
||||
$account->stormperson_nid = $loaded_persons[$account->uid]->nid;
|
||||
$account->stormorganization_nid = $loaded_persons[$account->uid]->organization_nid;
|
||||
}
|
||||
else {
|
||||
$loaded_persons[$account->uid] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _stormperson_user_delete(&$account) {
|
||||
db_query("UPDATE {stormperson} SET user_uid=NULL WHERE user_uid=%d", $account->uid);
|
||||
}
|
||||
|
||||
function stormperson_views_api() {
|
||||
return array(
|
||||
'api' => 2,
|
||||
'path' => drupal_get_path('module', 'stormperson'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function
|
||||
* A helper function to return the email address of a stormperson
|
||||
*/
|
||||
function stormperson_primary_email($node) {
|
||||
if ($node->type !== 'stormperson') {
|
||||
return NULL;
|
||||
}
|
||||
// If there is a Drupal user account use that email
|
||||
if ($node->user_uid) {
|
||||
$stormperson_person = user_load($node->user_uid);
|
||||
return $stormperson_person->mail;
|
||||
}
|
||||
// Else use the stormperson email
|
||||
elseif ($node->email) {
|
||||
return $node->email;
|
||||
}
|
||||
}
|
||||
|
||||
function stormperson_storm_dashboard_links($type) {
|
||||
$links = array();
|
||||
if ($type == 'page' || $type == 'block') {
|
||||
$links[] = array(
|
||||
'theme' => 'storm_dashboard_link',
|
||||
'title' => t('People'),
|
||||
'icon' => 'stormperson-item',
|
||||
'path' => 'people',
|
||||
'params' => array(),
|
||||
'access_arguments' => 'Storm person: access',
|
||||
'node_type' => 'stormperson',
|
||||
'add_type' => 'stormperson',
|
||||
'map' => array(),
|
||||
'weight' => 2,
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
224
modules/storm/stormperson/stormperson.test
Normal file
224
modules/storm/stormperson/stormperson.test
Normal file
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Person module.
|
||||
*/
|
||||
class StormpersonTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'SuiteDesk Person functionality',
|
||||
'description' => 'Test the functionality of the SuiteDesk Person module',
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormperson');
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: add'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
}
|
||||
|
||||
public function testStormpersonAccess() {
|
||||
$this->drupalGet('people');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk People list for anonymous user'));
|
||||
|
||||
$basic_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($basic_user);
|
||||
$this->drupalGet('people');
|
||||
$this->assertResponse(403, t('Make sure access is denied to SuiteDesk People list for basic user'));
|
||||
|
||||
$privileged_user = $this->drupalCreateUser(array('Storm person: access'));
|
||||
$this->drupalLogin($privileged_user);
|
||||
$this->drupalGet('people');
|
||||
$this->assertText(t('People'), t('Make sure the correct page has been displayed by checking that the title is "People".'));
|
||||
}
|
||||
|
||||
public function testStormpersonCreate() {
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$person = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormperson', $person, t('Save'));
|
||||
$this->assertText(t('Person @title has been created.', array('@title' => $person['title'])));
|
||||
}
|
||||
|
||||
public function testStormpersonList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view all', 'Storm person: edit all', 'Storm person: delete all'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view of user organization', 'Storm person: edit of user organization', 'Storm person: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view own', 'Storm person: edit own', 'Storm person: delete own'));
|
||||
$userLinked = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view when linked to own user account', 'Storm person: edit when linked to own user account', 'Storm person: delete when linked to own user account'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm person: access', 'Storm person: add', 'Storm person: view all', 'Storm person: edit own', 'Storm person: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create persons
|
||||
$person1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person1, t('Save'));
|
||||
$person1 = node_load(array('title' => $person1['title']));
|
||||
|
||||
$person4 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'user_name' => $userLinked->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person4, t('Save'));
|
||||
$person4 = node_load(array('title' => $person4['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$person2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person2, t('Save'));
|
||||
$person2 = node_load(array('title' => $person2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$person3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $person3, t('Save'));
|
||||
$person3 = node_load(array('title' => $person3['title']));
|
||||
|
||||
// Test for 'Storm person: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertLink($person1->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person3->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
// Test for 'Storm person: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertLink($person1->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person1->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($person3->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
// Test for 'Storm person: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertNoLink($person1->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person2->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertNoLink($person3->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($person4->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm person: view all', 'Storm invoice: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertLink($person1->title, 0, 'The Person appears on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person2->title, 0, 'The Person appears on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person3->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/edit', 'The Person edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $person3->nid .'/delete', 'The Person edit icon appears on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person4->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm person: view when linked to own user account'
|
||||
$this->drupalLogin($userLinked);
|
||||
$this->drupalGet('people');
|
||||
|
||||
$this->assertNoLink($person1->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person1->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($person2->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person2->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertNoLink($person3->title, 'The Person does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $person3->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($person4->title, 0, 'The Person appears on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/edit', 'The Person edit icon does not appear on the list');
|
||||
$this->assertRaw('node/'. $person4->nid .'/delete', 'The Person edit icon does not appear on the list');
|
||||
|
||||
}
|
||||
}
|
124
modules/storm/stormperson/stormperson.theme.inc
Normal file
124
modules/storm/stormperson/stormperson.theme.inc
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function theme_stormperson_list($header, $people) {
|
||||
$rows = array();
|
||||
foreach ($people as $person) {
|
||||
$rows[] = array(
|
||||
l($person->organization_title, 'node/'. $person->organization_nid),
|
||||
l($person->title, 'node/'. $person->nid) . theme('mark', node_mark($person->nid, $person->changed)),
|
||||
l($person->email, 'mailto:'. $person->email),
|
||||
array(
|
||||
'data' => storm_icon_edit_node($person, $_GET) .' '. storm_icon_delete_node($person, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
}
|
||||
$o = theme('table', $header, $rows, array('id' => 'stormpeople'));
|
||||
return $o;
|
||||
}
|
||||
|
||||
function theme_stormperson_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
drupal_add_css(drupal_get_path('module', 'storm') . '/storm-node.css', 'module');
|
||||
|
||||
$node = node_prepare($node, $teaser);
|
||||
|
||||
$node->content['links'] = array(
|
||||
'#prefix' => '<div class="stormlinks"><dl>',
|
||||
'#suffix' => '</dl></div>',
|
||||
'#weight' => -25,
|
||||
);
|
||||
|
||||
$node->content['group1'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
|
||||
$node->content['group1']['organization'] = array(
|
||||
'#prefix' => '<div id="organization">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Organization'), l($node->organization_title, 'node/'. $node->organization_nid)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$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']['email'] = array(
|
||||
'#prefix' => '<div id="email">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Email'), l($node->email, 'mailto:'. $node->email, array('absolute' => TRUE))),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$node->content['group3']['www'] = array(
|
||||
'#prefix' => '<div id="www">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('WWW'), l($node->www, $node->www, array('absolute' => TRUE))),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$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 id="phone">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Phone'), check_plain($node->phone)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$node->content['group4']['im'] = array(
|
||||
'#prefix' => '<div id="im">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('IM'), check_plain($node->im)),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$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('Description'), $node->content['body']['#value']),
|
||||
# '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'body_field') : -18,
|
||||
# );
|
||||
|
||||
unset($node->content['body']);
|
||||
|
||||
return $node;
|
||||
}
|
166
modules/storm/stormperson/stormperson.views.inc
Normal file
166
modules/storm/stormperson/stormperson.views.inc
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Functions to expose SuiteDesk Person module data to the Views module.
|
||||
*/
|
||||
function stormperson_views_data() {
|
||||
$data['stormperson']['table']['group'] = 'SuiteDesk Person';
|
||||
$data['stormperson']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormperson']['organization_nid'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('Person -> Organization'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Person -> Organization'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormperson']['organization_title'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('SuiteDesk Person Organization (title only)'),
|
||||
'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['stormperson']['prefix'] = array(
|
||||
'title' => t('Prefix'),
|
||||
'help' => t('SuiteDesk Person 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['stormperson']['email'] = array(
|
||||
'title' => t('Email'),
|
||||
'help' => t('SuiteDesk Person 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['stormperson']['www'] = array(
|
||||
'title' => t('WWW'),
|
||||
'help' => t('SuiteDesk Person 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['stormperson']['phone'] = array(
|
||||
'title' => t('Phone'),
|
||||
'help' => t('SuiteDesk Person Phone'),
|
||||
'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['stormperson']['im'] = array(
|
||||
'title' => t('IM'),
|
||||
'help' => t('SuiteDesk Person IM'),
|
||||
'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['stormperson']['user_uid'] = array(
|
||||
'title' => t('Drupal user'),
|
||||
'help' => t('SuiteDesk Person -> Drupal User'),
|
||||
'relationship' => array(
|
||||
'base' => 'users',
|
||||
'field' => 'uid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Person -> User'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormperson']['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' => 'stormperson',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function stormperson_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
'handlers' => array(
|
||||
'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