'. t("Provides attributes support for Storm") .'
';
$output .= ''. t("Price Modes - Price modes are used calculate the price of the Storm node when added to an invoice. A price mode can be added to any Storm node type and any type can be added to an invoice. When a node is added to an invoice it looks for a price mode in the following order:") .'
';
$output .= ''. t("Ticket, Task, Project, Organization.") .'
';
$output .= ''. t("It will take the price mode for it's current node or the first valid node type above in it's tree. e.g. For a task node type, if that node doesn't have a price mode it will look at the project and then the organization and take the first one it finds. This means you can define a price mode for the organization and it will be used for all nodes under that organization unless it's given a different one.") .'
';
$output .= ''. t("The following price modes keys are defined:") .'
';
$output .= '
';
$output .= '- '. t("not applicable - This is ignored by the system. This means that no price mode is defined.") .'
';
$output .= '- '. t("fixed - Price of 0 is used (so the invoice would need to be manually updated.") .'
';
$output .= '- '. t("hourly - Price taken from node and multiplied by billing duration.") .'
';
$output .= '- '. t("daily - Price given is for daily rate. This price is divided by 8 hours and then multiplied by the billing duration.") .'
';
$output .= '- '. t("fixed_price - Will use the price given as the fixed price for that invoice item.") .'
';
$output .= '
';
break;
}
return $output;
}
function stormattribute_menu() {
$items['storm/attributes'] = array(
'title' => 'Attributes',
'description' => 'Storm Attributes',
'page callback' => 'stormattribute_list',
'access arguments' => array('Storm: access administration pages'),
'file' => 'stormattribute.admin.inc',
'type' => MENU_NORMAL_ITEM,
'weight' => 11,
);
$items['storm/attributes/add'] = array(
'title' => 'Add a new attribute',
'description' => 'Storm Attributes',
'page callback' => 'drupal_get_form',
'page arguments' => array('stormattribute_add'),
'access arguments' => array('Storm: access administration pages'),
'file' => 'stormattribute.admin.inc',
'type' => MENU_CALLBACK);
$items['storm/attributes/edit/%'] = array(
'title' => 'Edit an attribute',
'description' => 'Storm Attributes',
'page callback' => 'drupal_get_form',
'page arguments' => array('stormattribute_edit', 3),
'access arguments' => array('Storm: access administration pages'),
'file' => 'stormattribute.admin.inc',
'type' => MENU_CALLBACK);
$items['storm/attributes/delete/%'] = array(
'title' => 'Delete an attribute',
'description' => 'Storm Attributes',
'page callback' => 'drupal_get_form',
'page arguments' => array('stormattribute_delete', 3),
'access arguments' => array('Storm: access administration pages'),
'file' => 'stormattribute.admin.inc',
'type' => MENU_CALLBACK);
$items['storm/attributes/domain/autocomplete'] = array(
'title' => 'List of attributes',
'description' => 'Storm Attributes',
'page callback' => '_stormattribute_domain_autocomplete',
'page arguments' => array(4),
'access arguments' => array('Storm: access administration pages'),
'file' => 'stormattribute.admin.inc',
'type' => MENU_CALLBACK);
return $items;
}
function stormattribute_theme() {
return array(
'stormattribute_list' => array(
'file' => 'stormattribute.theme.inc',
'arguments' => array('form'),
),
);
}
function stormattribute_access($op, $item=NULL, $account=NULL) {
if (empty($account)) {
global $user;
$account = $user;
}
if ($op == 'create') {
return user_access('Storm: access administration pages');
}
if ($op == 'delete') {
return user_access('Storm: access administration pages');
}
if ($op == 'update') {
return user_access('Storm: access administration pages');
}
return FALSE;
}
function stormattribute_attributes_bydomain($domain) {
static $attributes_cache = array();
$attributes = array();
if (array_key_exists($domain, $attributes_cache)) return $attributes_cache[$domain];
$s = "SELECT * FROM {stormattribute} WHERE LOWER(domain) LIKE LOWER('%s') AND isactive=1 ORDER BY weight, avalue";
$r = db_query($s, $domain);
$attributes['values'] = array();
while ($attribute = db_fetch_object($r)) {
// The variable is deliberately passed through t() for translatability
$attributes['values'][$attribute->akey] = t($attribute->avalue);
if ($attribute->isdefault) {
$attributes['default'] = $attribute->akey;
}
}
if (is_array($attributes['values']) && !array_key_exists('default', $attributes)) {
$v = array_flip($attributes['values']);
$attributes['default'] = array_shift($v);
}
$attributes_cache[$domain] = $attributes;
return $attributes;
}
function stormattribute_value($domain, $key) {
$attributes_array = stormattribute_attributes_bydomain($domain);
$attributes = $attributes_array['values'];
if (array_key_exists($key, $attributes)) {
return $attributes[$key];
}
return $key;
}