| 1 |
<?php
|
| 2 |
// $Id: market.install,v 1.6 2008/03/10 00:48:24 greggles Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Install the initial schema.
|
| 6 |
*/
|
| 7 |
function market_install() {
|
| 8 |
// TODO some other stuff?
|
| 9 |
|
| 10 |
// Create the cck nodes - NOTE: Order of these is important due to node reference fields
|
| 11 |
_market_install_create_content(_market_portfolio_content_type());
|
| 12 |
_market_install_create_content(_market_item_content_type());
|
| 13 |
_market_install_create_content(_market_item_count_content_type());
|
| 14 |
_market_install_create_content(_market_trade_content_type());
|
| 15 |
|
| 16 |
// Create a role
|
| 17 |
db_query("INSERT INTO {role} (name) VALUES ('%s')", 'Market admin');
|
| 18 |
$market_admin_role = db_result(db_query("SELECT rid FROM {role} WHERE name = 'Market Admin'"));
|
| 19 |
|
| 20 |
|
| 21 |
// Create the workflows (which can use the content types and trades)
|
| 22 |
/* You must build the workflow for your trades.
|
| 23 |
Admin > Build > Workflow > Add workflow "Trading" (name isn't important)
|
| 24 |
Make it the workflow for "Trades"
|
| 25 |
Add the following States
|
| 26 |
State Weight
|
| 27 |
Open 0
|
| 28 |
Cancelled 1
|
| 29 |
Partially Executed 2
|
| 30 |
Executed 3
|
| 31 |
Invalid 4
|
| 32 |
|
| 33 |
Then edit the workflow
|
| 34 |
Creation -> Open author/admin
|
| 35 |
Open -> Cancelled author/admin
|
| 36 |
Open -> Partially Executed admin
|
| 37 |
Open -> Executed admin
|
| 38 |
Open -> Invalid admin
|
| 39 |
|
| 40 |
For testing it can be useful to let the admin move trades from any state back to open.
|
| 41 |
|
| 42 |
Workflow tab permissions for author and admin
|
| 43 |
*/
|
| 44 |
|
| 45 |
$trading_wid = workflow_create('Trading');
|
| 46 |
$trading_creation = db_result(db_query("SELECT sid FROM {workflow_states} WHERE state = '(creation)' AND wid = %d", $trading_wid));
|
| 47 |
|
| 48 |
$state_values = array();
|
| 49 |
$state_values['wid'] = $trading_wid;
|
| 50 |
$state_values['state'] = 'Open';
|
| 51 |
$state_values['weight'] = 0;
|
| 52 |
$trading_open = workflow_state_save($state_values);
|
| 53 |
|
| 54 |
$state_values['wid'] = $trading_wid;
|
| 55 |
$state_values['state'] = 'Cancelled';
|
| 56 |
$state_values['weight'] = 1;
|
| 57 |
$trading_cancelled = workflow_state_save($state_values);
|
| 58 |
|
| 59 |
$state_values['wid'] = $trading_wid;
|
| 60 |
$state_values['state'] = 'Partially Executed';
|
| 61 |
$state_values['weight'] = 2;
|
| 62 |
$trading_partially_executed = workflow_state_save($state_values);
|
| 63 |
|
| 64 |
$state_values['wid'] = $trading_wid;
|
| 65 |
$state_values['state'] = 'Executed';
|
| 66 |
$state_values['weight'] = 3;
|
| 67 |
$trading_executed = workflow_state_save($state_values);
|
| 68 |
|
| 69 |
$state_values['wid'] = $trading_wid;
|
| 70 |
$state_values['state'] = 'Invalid';
|
| 71 |
$state_values['weight'] = 4;
|
| 72 |
$trading_invalid = workflow_state_save($state_values);
|
| 73 |
|
| 74 |
// Configure our variables
|
| 75 |
variable_set('market_state_trade_open', $trading_open);
|
| 76 |
variable_set('market_state_trade_executed', $trading_executed);
|
| 77 |
variable_set('market_state_trade_invalid', $trading_invalid);
|
| 78 |
variable_set('market_state_trade_partially_executed', $trading_partially_executed);
|
| 79 |
variable_set('market_state_trade_cancelled', $trading_cancelled);
|
| 80 |
|
| 81 |
$workflow_edit = array();
|
| 82 |
$workflow_edit['wid'] = $trading_wid;
|
| 83 |
$workflow_edit['wf_name'] = 'Trading';
|
| 84 |
$workflow_edit['tab_roles']['author'] = 'author';
|
| 85 |
$workflow_edit['tab_roles'][1] = 0;
|
| 86 |
$workflow_edit['tab_roles'][2] = 0;
|
| 87 |
$workflow_edit['tab_roles'][$market_admin_role] = 1;
|
| 88 |
|
| 89 |
// These take the form of [transitions][from_sid][to_sid][rid] = 1
|
| 90 |
$workflow_edit['transitions'][$trading_creation][$trading_open]['author'] = 1;
|
| 91 |
$workflow_edit['transitions'][$trading_creation][$trading_open][1] = 0;
|
| 92 |
$workflow_edit['transitions'][$trading_creation][$trading_open][2] = 0;
|
| 93 |
$workflow_edit['transitions'][$trading_creation][$trading_open][$market_admin_role] = 1;
|
| 94 |
|
| 95 |
$workflow_edit['transitions'][$trading_open][$trading_cancelled]['author'] = 1;
|
| 96 |
$workflow_edit['transitions'][$trading_open][$trading_cancelled][1] = 0;
|
| 97 |
$workflow_edit['transitions'][$trading_open][$trading_cancelled][2] = 0;
|
| 98 |
$workflow_edit['transitions'][$trading_open][$trading_cancelled][$market_admin_role] = 1;
|
| 99 |
|
| 100 |
$workflow_edit['transitions'][$trading_open][$trading_partially_executed]['author'] = 0;
|
| 101 |
$workflow_edit['transitions'][$trading_open][$trading_partially_executed][1] = 0;
|
| 102 |
$workflow_edit['transitions'][$trading_open][$trading_partially_executed][2] = 0;
|
| 103 |
$workflow_edit['transitions'][$trading_open][$trading_partially_executed][$market_admin_role] = 1;
|
| 104 |
|
| 105 |
$workflow_edit['transitions'][$trading_open][$trading_executed]['author'] = 0;
|
| 106 |
$workflow_edit['transitions'][$trading_open][$trading_executed][1] = 0;
|
| 107 |
$workflow_edit['transitions'][$trading_open][$trading_executed][2] = 0;
|
| 108 |
$workflow_edit['transitions'][$trading_open][$trading_executed][$market_admin_role] = 1;
|
| 109 |
|
| 110 |
$workflow_edit['transitions'][$trading_open][$trading_invalid]['author'] = 0;
|
| 111 |
$workflow_edit['transitions'][$trading_open][$trading_invalid][1] = 0;
|
| 112 |
$workflow_edit['transitions'][$trading_open][$trading_invalid][2] = 0;
|
| 113 |
$workflow_edit['transitions'][$trading_open][$trading_invalid][$market_admin_role] = 1;
|
| 114 |
|
| 115 |
_market_workflow_save($workflow_edit, 'trade');
|
| 116 |
|
| 117 |
// Item expiration workflow
|
| 118 |
/*
|
| 119 |
State Weight
|
| 120 |
Open 0
|
| 121 |
Pending Decision 1
|
| 122 |
Closed Success 2
|
| 123 |
Closed Fail 3
|
| 124 |
|
| 125 |
Then edit the workflow
|
| 126 |
Creation -> Open author/admin
|
| 127 |
Open -> Pending Decision admin (maybe author)
|
| 128 |
Pending Decision -> Open Success admin (maybe author)
|
| 129 |
Pending Decision -> Closed Fail admin (maybe author)
|
| 130 |
All other transitions admin (probably useful, but not completely necessary)
|
| 131 |
*/
|
| 132 |
|
| 133 |
$item_wid = workflow_create('Item Expiration');
|
| 134 |
$item_creation = db_result(db_query("SELECT sid FROM {workflow_states} WHERE state = '(creation)' AND wid = %d", $item_wid));
|
| 135 |
|
| 136 |
$state_values['wid'] = $item_wid;
|
| 137 |
$state_values['state'] = 'Open';
|
| 138 |
$state_values['weight'] = 0;
|
| 139 |
$item_open = workflow_state_save($state_values);
|
| 140 |
|
| 141 |
$state_values['wid'] = $item_wid;
|
| 142 |
$state_values['state'] = 'Pending Decision';
|
| 143 |
$state_values['weight'] = 1;
|
| 144 |
$item_pending_decision = workflow_state_save($state_values);
|
| 145 |
|
| 146 |
$state_values['wid'] = $item_wid;
|
| 147 |
$state_values['state'] = 'Closed Success';
|
| 148 |
$state_values['weight'] = 2;
|
| 149 |
$item_closed_success = workflow_state_save($state_values);
|
| 150 |
|
| 151 |
$state_values['wid'] = $item_wid;
|
| 152 |
$state_values['state'] = 'Closed Fail';
|
| 153 |
$state_values['weight'] = 3;
|
| 154 |
$item_closed_fail = workflow_state_save($state_values);
|
| 155 |
|
| 156 |
variable_set('market_state_item_open', $item_open);
|
| 157 |
variable_set('market_state_item_pending_decision', $item_pending_decision);
|
| 158 |
variable_set('market_state_item_closed_success', $item_closed_success);
|
| 159 |
variable_set('market_state_item_closed_fail', $item_closed_fail);
|
| 160 |
|
| 161 |
$workflow_edit['wid'] = $item_wid;
|
| 162 |
$workflow_edit['wf_name'] = 'Item Expiration';
|
| 163 |
$workflow_edit['tab_roles']['author'] = 'author';
|
| 164 |
$workflow_edit['tab_roles'][1] = 0;
|
| 165 |
$workflow_edit['tab_roles'][2] = 0;
|
| 166 |
$workflow_edit['tab_roles'][$market_admin_role] = 1;
|
| 167 |
|
| 168 |
// These take the form of [transitions][from_sid][to_sid][rid] = 1
|
| 169 |
$workflow_edit['transitions'][$item_creation][$item_open]['author'] = 1;
|
| 170 |
$workflow_edit['transitions'][$item_creation][$item_open][1] = 0;
|
| 171 |
$workflow_edit['transitions'][$item_creation][$item_open][2] = 0;
|
| 172 |
$workflow_edit['transitions'][$item_creation][$item_open][$market_admin_role] = 1;
|
| 173 |
|
| 174 |
$workflow_edit['transitions'][$item_open][$item_pending_decision]['author'] = 0;
|
| 175 |
$workflow_edit['transitions'][$item_open][$item_pending_decision][1] = 0;
|
| 176 |
$workflow_edit['transitions'][$item_open][$item_pending_decision][2] = 0;
|
| 177 |
$workflow_edit['transitions'][$item_open][$item_pending_decision][$market_admin_role] = 1;
|
| 178 |
|
| 179 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_success]['author'] = 0;
|
| 180 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_success][1] = 0;
|
| 181 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_success][2] = 0;
|
| 182 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_success][$market_admin_role] = 1;
|
| 183 |
|
| 184 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_fail]['author'] = 0;
|
| 185 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_fail][1] = 0;
|
| 186 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_fail][2] = 0;
|
| 187 |
$workflow_edit['transitions'][$item_pending_decision][$item_closed_fail][$market_admin_role] = 1;
|
| 188 |
|
| 189 |
_market_workflow_save($workflow_edit, 'item');
|
| 190 |
|
| 191 |
/*
|
| 192 |
Create a workflow for "Portfolio Expiration" (name isn't important)
|
| 193 |
Make it the workflow for "Portfolios"
|
| 194 |
Add the Following States
|
| 195 |
State Weight
|
| 196 |
Open 0
|
| 197 |
Closed 1
|
| 198 |
|
| 199 |
Then edit the workflow
|
| 200 |
Creation -> Open author/admin
|
| 201 |
Open -> Closed admin (maybe author)
|
| 202 |
All other transitions admin (probably useful, but not completely necessary)
|
| 203 |
*/
|
| 204 |
|
| 205 |
$portfolio_wid = workflow_create('Portfolio Expiration');
|
| 206 |
$portfolio_creation = db_result(db_query("SELECT sid FROM {workflow_states} WHERE state = '(creation)' AND wid = %d", $portfolio_wid));
|
| 207 |
|
| 208 |
$state_values['wid'] = $portfolio_wid;
|
| 209 |
$state_values['state'] = 'Open';
|
| 210 |
$state_values['weight'] = 0;
|
| 211 |
$portfolio_open = workflow_state_save($state_values);
|
| 212 |
|
| 213 |
$state_values['wid'] = $portfolio_wid;
|
| 214 |
$state_values['state'] = 'Closed';
|
| 215 |
$state_values['weight'] = 1;
|
| 216 |
$portfolio_closed = workflow_state_save($state_values);
|
| 217 |
|
| 218 |
variable_set('market_state_portfolio_open', $portfolio_open);
|
| 219 |
variable_set('market_state_portfolio_closed', $portfolio_closed);
|
| 220 |
|
| 221 |
$workflow_edit['wid'] = $portfolio_wid;
|
| 222 |
$workflow_edit['wf_name'] = 'Portfolio Expiration';
|
| 223 |
$workflow_edit['tab_roles']['author'] = 'author';
|
| 224 |
$workflow_edit['tab_roles'][1] = 0;
|
| 225 |
$workflow_edit['tab_roles'][2] = 0;
|
| 226 |
$workflow_edit['tab_roles'][$market_admin_role] = 1;
|
| 227 |
|
| 228 |
// These take the form of [transitions][from_sid][to_sid][rid] = 1
|
| 229 |
$workflow_edit['transitions'][$portfolio_creation][$portfolio_open]['author'] = 1;
|
| 230 |
$workflow_edit['transitions'][$portfolio_creation][$portfolio_open][1] = 0;
|
| 231 |
$workflow_edit['transitions'][$portfolio_creation][$portfolio_open][2] = 0;
|
| 232 |
$workflow_edit['transitions'][$portfolio_creation][$portfolio_open][$market_admin_role] = 1;
|
| 233 |
|
| 234 |
$workflow_edit['transitions'][$portfolio_open][$portfolio_closed]['author'] = 0;
|
| 235 |
$workflow_edit['transitions'][$portfolio_open][$portfolio_closed][1] = 0;
|
| 236 |
$workflow_edit['transitions'][$portfolio_open][$portfolio_closed][2] = 0;
|
| 237 |
$workflow_edit['transitions'][$portfolio_open][$portfolio_closed][$market_admin_role] = 1;
|
| 238 |
|
| 239 |
_market_workflow_save($workflow_edit, 'portfolio');
|
| 240 |
|
| 241 |
// TODO make a user
|
| 242 |
$account = array('name' => 'market_robot',
|
| 243 |
'mail' => 'robot@openpredictionmarkets.org',
|
| 244 |
'pass' => user_password(),
|
| 245 |
'status' => 1,
|
| 246 |
'init' => 'robot@openpredictionmarkets.org',
|
| 247 |
'roles' => array( $market_admin_role => $market_admin_role)
|
| 248 |
);
|
| 249 |
|
| 250 |
$robot_user = user_save(new stdClass(), $account);
|
| 251 |
variable_set('market_robot_uid', $robot_user->uid);
|
| 252 |
|
| 253 |
// Create some handy custom links
|
| 254 |
$link = new stdClass();
|
| 255 |
$link->link_key = 'buy-this-item';
|
| 256 |
$link->title = 'Buy this item';
|
| 257 |
$link->check_html = 0;
|
| 258 |
$link->path = 'node/add/trade';
|
| 259 |
$link->querystring = 'edit[field_item][nids]=[nid]&edit[field_action][key]=buy';
|
| 260 |
$link->fragment = '';
|
| 261 |
$link->display = 2;
|
| 262 |
$link->node_type = 'item';
|
| 263 |
$link->author_perm = 'create trade content';
|
| 264 |
$link->viewer_perm = 'create trade content';
|
| 265 |
$link->query = '';
|
| 266 |
_custom_links_save_link($link);
|
| 267 |
// MAYBEDO use drupal_execute instead of _custom_links_save_link to get the benefits of validation... ?
|
| 268 |
|
| 269 |
$link = new stdClass();
|
| 270 |
$link->link_key = 'buy-this-portfolio';
|
| 271 |
$link->title = 'Buy this portfolio';
|
| 272 |
$link->check_html = 0;
|
| 273 |
$link->path = 'node/add/trade';
|
| 274 |
$link->querystring = 'edit[field_item][nids]=[nid]&edit[field_action][key]=buy&edit[field_price][0][value]=100';
|
| 275 |
$link->fragment = '';
|
| 276 |
$link->display = 2;
|
| 277 |
$link->node_type = 'portfolio';
|
| 278 |
$link->author_perm = 'create trade content';
|
| 279 |
$link->viewer_perm = 'create trade content';
|
| 280 |
$link->query = '';
|
| 281 |
_custom_links_save_link($link);
|
| 282 |
|
| 283 |
$link = new stdClass();
|
| 284 |
$link->link_key = 'portfolio-item-add';
|
| 285 |
$link->title = 'Create item in this portfolio';
|
| 286 |
$link->check_html = 0;
|
| 287 |
$link->path = 'node/add/item';
|
| 288 |
$link->querystring = 'edit[field_portfolio][nids]=[nid]';
|
| 289 |
$link->fragment = '';
|
| 290 |
$link->display = 2;
|
| 291 |
$link->node_type = 'portfolio';
|
| 292 |
$link->author_perm = 'create trade content';
|
| 293 |
$link->viewer_perm = 'create trade content';
|
| 294 |
$link->query = '';
|
| 295 |
_custom_links_save_link($link);
|
| 296 |
|
| 297 |
/*
|
| 298 |
$link = new stdClass();
|
| 299 |
$link->link_key = '';
|
| 300 |
$link->title = '';
|
| 301 |
$link->check_html = 0;
|
| 302 |
$link->path = '';
|
| 303 |
$link->querystring = '';
|
| 304 |
$link->fragment = '';
|
| 305 |
$link->display = 2;
|
| 306 |
$link->node_type = '';
|
| 307 |
$link->author_perm = 'create trade content';
|
| 308 |
$link->viewer_perm = 'create trade content';
|
| 309 |
$link->query = '';
|
| 310 |
_custom_links_save_link($link);
|
| 311 |
*/
|
| 312 |
|
| 313 |
return;
|
| 314 |
}
|
| 315 |
|
| 316 |
/**
|
| 317 |
* Implementation of hook_uninstall().
|
| 318 |
*/
|
| 319 |
function market_uninstall() {
|
| 320 |
return;
|
| 321 |
//db_query('DROP TABLE {market}');
|
| 322 |
}
|
| 323 |
|
| 324 |
function _market_workflow_save($workflow_edit, $type) {
|
| 325 |
workflow_update($workflow_edit['wid'], $workflow_edit['wf_name'], array_filter($workflow_edit['tab_roles']));
|
| 326 |
workflow_update_transitions($workflow_edit['transitions']);
|
| 327 |
workflow_types_save(array($type, $workflow_edit['wid']));
|
| 328 |
}
|
| 329 |
|
| 330 |
function _market_install_create_content($content, $type_name = '<create>') {
|
| 331 |
$type = $content['type']['type'];
|
| 332 |
global $_market_install_macro;
|
| 333 |
$_market_install_macro[$type] = $content;
|
| 334 |
include_once drupal_get_path('module', 'node') .'/content_types.inc';
|
| 335 |
include_once drupal_get_path('module', 'content') .'/content_admin.inc';
|
| 336 |
$macro = 'global $_market_install_macro; $content = $_market_install_macro['. $type .'];';
|
| 337 |
drupal_execute('content_copy_import_form', array('type_name' => $type_name, 'macro' => $macro));
|
| 338 |
content_clear_type_cache();
|
| 339 |
}
|
| 340 |
|
| 341 |
function _market_portfolio_content_type() {
|
| 342 |
$content[type] = array (
|
| 343 |
'name' => 'Portfolio',
|
| 344 |
'type' => 'portfolio',
|
| 345 |
'description' => 'A portfolio of related items to trade. Used to create a prediction market basket where all of the items in the portfolio represent a complete set of outcomes.',
|
| 346 |
'title_label' => 'Title',
|
| 347 |
'body_label' => 'Description',
|
| 348 |
'min_word_count' => '0',
|
| 349 |
'help' => '',
|
| 350 |
'node_options' => array (
|
| 351 |
'status' => true,
|
| 352 |
'promote' => true,
|
| 353 |
'revision' => true,
|
| 354 |
'sticky' => false,
|
| 355 |
),
|
| 356 |
'comment' => '0',
|
| 357 |
'old_type' => 'portfolio',
|
| 358 |
'orig_type' => '',
|
| 359 |
'module' => 'node',
|
| 360 |
'custom' => '1',
|
| 361 |
'modified' => '1',
|
| 362 |
'locked' => '0',
|
| 363 |
'ant' => 0,
|
| 364 |
'ant_pattern' => '',
|
| 365 |
'ant_php' => '',
|
| 366 |
);
|
| 367 |
|
| 368 |
return $content;
|
| 369 |
}
|
| 370 |
|
| 371 |
function _market_item_content_type(){
|
| 372 |
$content[type] = array (
|
| 373 |
'name' => 'Item',
|
| 374 |
'type' => 'item',
|
| 375 |
'description' => 'An item which can be traded. Generally should be precise and mutually exclusive with other items in a portfolio.',
|
| 376 |
'title_label' => 'Title',
|
| 377 |
'body_label' => 'Description',
|
| 378 |
'min_word_count' => '0',
|
| 379 |
'help' => '',
|
| 380 |
'node_options' =>
|
| 381 |
array (
|
| 382 |
'status' => true,
|
| 383 |
'revision' => true,
|
| 384 |
'promote' => false,
|
| 385 |
'sticky' => false,
|
| 386 |
),
|
| 387 |
'comment' => '0',
|
| 388 |
'old_type' => 'item',
|
| 389 |
'orig_type' => '',
|
| 390 |
'module' => 'node',
|
| 391 |
'custom' => '1',
|
| 392 |
'modified' => '1',
|
| 393 |
'locked' => '0',
|
| 394 |
'ant' => 0,
|
| 395 |
'ant_pattern' => '',
|
| 396 |
'ant_php' => '',
|
| 397 |
);
|
| 398 |
$content[fields] = array (
|
| 399 |
0 =>
|
| 400 |
array (
|
| 401 |
'widget_type' => 'number',
|
| 402 |
'label' => 'Price Estimate',
|
| 403 |
'weight' => '0',
|
| 404 |
'description' => 'When creating, enter a suggested starting price based on your estimate or enter 0 (zero) if you are unsure. The system periodically updates this number with the current price as trades are made.',
|
| 405 |
'default_value_widget' =>
|
| 406 |
array (
|
| 407 |
'field_price_estimate' =>
|
| 408 |
array (
|
| 409 |
0 =>
|
| 410 |
array (
|
| 411 |
'value' => '',
|
| 412 |
),
|
| 413 |
),
|
| 414 |
),
|
| 415 |
'default_value_php' => '',
|
| 416 |
'required' => '0',
|
| 417 |
'multiple' => '0',
|
| 418 |
'min' => '0',
|
| 419 |
'max' => '100',
|
| 420 |
'prefix' => '',
|
| 421 |
'suffix' => '',
|
| 422 |
'allowed_values' => '',
|
| 423 |
'allowed_values_php' => '',
|
| 424 |
'field_name' => 'field_price_estimate',
|
| 425 |
'field_type' => 'number_integer',
|
| 426 |
'module' => 'number',
|
| 427 |
'default_value' =>
|
| 428 |
array (
|
| 429 |
0 =>
|
| 430 |
array (
|
| 431 |
'value' => '',
|
| 432 |
),
|
| 433 |
),
|
| 434 |
),
|
| 435 |
1 =>
|
| 436 |
array (
|
| 437 |
'widget_type' => 'nodereference_select',
|
| 438 |
'label' => 'Portfolio',
|
| 439 |
'weight' => '1',
|
| 440 |
'description' => '',
|
| 441 |
'default_value_widget' =>
|
| 442 |
array (
|
| 443 |
'field_portfolio' =>
|
| 444 |
array (
|
| 445 |
'nids' =>
|
| 446 |
array (
|
| 447 |
0 => '0',
|
| 448 |
),
|
| 449 |
),
|
| 450 |
),
|
| 451 |
'default_value_php' => '',
|
| 452 |
'required' => '1',
|
| 453 |
'multiple' => '0',
|
| 454 |
'referenceable_types' =>
|
| 455 |
array (
|
| 456 |
'portfolio' => true,
|
| 457 |
0 => 1,
|
| 458 |
'item' => false,
|
| 459 |
'item_count' => false,
|
| 460 |
'page' => false,
|
| 461 |
'trade' => false,
|
| 462 |
),
|
| 463 |
'advanced_view' => '--',
|
| 464 |
'advanced_view_args' => '',
|
| 465 |
'field_name' => 'field_portfolio',
|
| 466 |
'field_type' => 'nodereference',
|
| 467 |
'module' => 'nodereference',
|
| 468 |
),
|
| 469 |
);
|
| 470 |
|
| 471 |
return $content;
|
| 472 |
}
|
| 473 |
|
| 474 |
function _market_item_count_content_type(){
|
| 475 |
$content[type] = array (
|
| 476 |
'name' => 'Item Count',
|
| 477 |
'type' => 'item_count',
|
| 478 |
'description' => 'You probably should not create this manually. This is used internally by the system to keep track of how many items a particular user owns.',
|
| 479 |
'title_label' => 'Title',
|
| 480 |
'body_label' => '',
|
| 481 |
'min_word_count' => '0',
|
| 482 |
'help' => '',
|
| 483 |
'node_options' =>
|
| 484 |
array (
|
| 485 |
'revision' => true,
|
| 486 |
'status' => false,
|
| 487 |
'promote' => false,
|
| 488 |
'sticky' => false,
|
| 489 |
),
|
| 490 |
'comment' => '0',
|
| 491 |
'old_type' => 'item_count',
|
| 492 |
'orig_type' => '',
|
| 493 |
'module' => 'node',
|
| 494 |
'custom' => '1',
|
| 495 |
'modified' => '1',
|
| 496 |
'locked' => '0',
|
| 497 |
'ant' => 1,
|
| 498 |
'ant_pattern' => '[author-name] ownership of [field_owned_items-title]',
|
| 499 |
'ant_php' => 0,
|
| 500 |
);
|
| 501 |
$content[fields] = array (
|
| 502 |
0 =>
|
| 503 |
array (
|
| 504 |
'widget_type' => 'number',
|
| 505 |
'label' => 'item_count',
|
| 506 |
'weight' => '0',
|
| 507 |
'description' => '',
|
| 508 |
'default_value_widget' =>
|
| 509 |
array (
|
| 510 |
'field_item_count' =>
|
| 511 |
array (
|
| 512 |
0 =>
|
| 513 |
array (
|
| 514 |
'value' => '',
|
| 515 |
),
|
| 516 |
),
|
| 517 |
),
|
| 518 |
'default_value_php' => '',
|
| 519 |
'required' => '1',
|
| 520 |
'multiple' => '0',
|
| 521 |
'min' => '0',
|
| 522 |
'max' => '',
|
| 523 |
'prefix' => '',
|
| 524 |
'suffix' => '',
|
| 525 |
'allowed_values' => '',
|
| 526 |
'allowed_values_php' => '',
|
| 527 |
'field_name' => 'field_item_count',
|
| 528 |
'field_type' => 'number_integer',
|
| 529 |
'module' => 'number',
|
| 530 |
'default_value' =>
|
| 531 |
array (
|
| 532 |
0 =>
|
| 533 |
array (
|
| 534 |
'value' => '',
|
| 535 |
),
|
| 536 |
),
|
| 537 |
),
|
| 538 |
1 =>
|
| 539 |
array (
|
| 540 |
'widget_type' => 'nodereference_select',
|
| 541 |
'label' => 'Owned Items',
|
| 542 |
'weight' => '0',
|
| 543 |
'description' => '',
|
| 544 |
'default_value_widget' =>
|
| 545 |
array (
|
| 546 |
'field_owned_items' =>
|
| 547 |
array (
|
| 548 |
'nids' => '',
|
| 549 |
),
|
| 550 |
),
|
| 551 |
'default_value_php' => '',
|
| 552 |
'required' => '1',
|
| 553 |
'multiple' => '0',
|
| 554 |
'referenceable_types' =>
|
| 555 |
array (
|
| 556 |
'item' => true,
|
| 557 |
1 => 1,
|
| 558 |
0 => 1,
|
| 559 |
'item_count' => false,
|
| 560 |
'page' => false,
|
| 561 |
'portfolio' => false,
|
| 562 |
'trade' => false,
|
| 563 |
),
|
| 564 |
'advanced_view' => '--',
|
| 565 |
'advanced_view_args' => '',
|
| 566 |
'field_name' => 'field_owned_items',
|
| 567 |
'field_type' => 'nodereference',
|
| 568 |
'module' => 'nodereference',
|
| 569 |
),
|
| 570 |
);
|
| 571 |
|
| 572 |
return $content;
|
| 573 |
}
|
| 574 |
|
| 575 |
function _market_trade_content_type(){
|
| 576 |
$content[type] = array (
|
| 577 |
'name' => 'Trade',
|
| 578 |
'type' => 'trade',
|
| 579 |
'description' => 'Place a trade for a portfolio of items or for a specific item.',
|
| 580 |
'title_label' => 'Title',
|
| 581 |
'body_label' => '',
|
| 582 |
'min_word_count' => '0',
|
| 583 |
'help' => '',
|
| 584 |
'node_options' =>
|
| 585 |
array (
|
| 586 |
'status' => true,
|
| 587 |
'revision' => true,
|
| 588 |
'promote' => false,
|
| 589 |
'sticky' => false,
|
| 590 |
),
|
| 591 |
'comment' => '0',
|
| 592 |
'old_type' => 'trade',
|
| 593 |
'orig_type' => '',
|
| 594 |
'module' => 'node',
|
| 595 |
'custom' => '1',
|
| 596 |
'modified' => '1',
|
| 597 |
'locked' => '0',
|
| 598 |
'ant' => 1,
|
| 599 |
'ant_pattern' => '[author-name] to trade [field_quantity-formatted] of [field_item-title] id# [field_item-nid] for [field_price-formatted]',
|
| 600 |
'ant_php' => 0,
|
| 601 |
);
|
| 602 |
$content[fields] = array (
|
| 603 |
0 =>
|
| 604 |
array (
|
| 605 |
'widget_type' => 'options_buttons',
|
| 606 |
'label' => 'Buy / Sell',
|
| 607 |
'weight' => '0',
|
| 608 |
'description' => '',
|
| 609 |
'default_value_widget' =>
|
| 610 |
array (
|
| 611 |
'field_action' =>
|
| 612 |
array (
|
| 613 |
'key' => '',
|
| 614 |
),
|
| 615 |
),
|
| 616 |
'default_value_php' => '',
|
| 617 |
'required' => '1',
|
| 618 |
'multiple' => '0',
|
| 619 |
'text_processing' => '0',
|
| 620 |
'max_length' => '',
|
| 621 |
'allowed_values' => 'buy|Buy
|
| 622 |
sell|Sell',
|
| 623 |
'allowed_values_php' => '',
|
| 624 |
'field_name' => 'field_action',
|
| 625 |
'field_type' => 'text',
|
| 626 |
'module' => 'text, optionwidgets',
|
| 627 |
'default_value' =>
|
| 628 |
array (
|
| 629 |
0 =>
|
| 630 |
array (
|
| 631 |
'value' => '',
|
| 632 |
),
|
| 633 |
),
|
| 634 |
),
|
| 635 |
1 =>
|
| 636 |
array (
|
| 637 |
'widget_type' => 'number',
|
| 638 |
'label' => 'Price',
|
| 639 |
'weight' => '0',
|
| 640 |
'description' => 'This is the price at which you want to buy or sell the contract. If you are purchasing an entire contract the price must be 100.',
|
| 641 |
'default_value_widget' =>
|
| 642 |
array (
|
| 643 |
'field_price' =>
|
| 644 |
array (
|
| 645 |
0 =>
|
| 646 |
array (
|
| 647 |
'value' => '',
|
| 648 |
),
|
| 649 |
),
|
| 650 |
),
|
| 651 |
'default_value_php' => '',
|
| 652 |
'required' => '1',
|
| 653 |
'multiple' => '0',
|
| 654 |
'min' => '0',
|
| 655 |
'max' => '100',
|
| 656 |
'prefix' => '',
|
| 657 |
'suffix' => '',
|
| 658 |
'allowed_values' => '',
|
| 659 |
'allowed_values_php' => '',
|
| 660 |
'field_name' => 'field_price',
|
| 661 |
'field_type' => 'number_integer',
|
| 662 |
'module' => 'number',
|
| 663 |
),
|
| 664 |
2 =>
|
| 665 |
array (
|
| 666 |
'widget_type' => 'number',
|
| 667 |
'label' => 'Quantity',
|
| 668 |
'weight' => '0',
|
| 669 |
'description' => '',
|
| 670 |
'default_value_widget' =>
|
| 671 |
array (
|
| 672 |
'field_quantity' =>
|
| 673 |
array (
|
| 674 |
0 =>
|
| 675 |
array (
|
| 676 |
'value' => '',
|
| 677 |
),
|
| 678 |
),
|
| 679 |
),
|
| 680 |
'default_value_php' => '',
|
| 681 |
'required' => '1',
|
| 682 |
'multiple' => '0',
|
| 683 |
'min' => '0',
|
| 684 |
'max' => '',
|
| 685 |
'prefix' => '',
|
| 686 |
'suffix' => '',
|
| 687 |
'allowed_values' => '',
|
| 688 |
'allowed_values_php' => '',
|
| 689 |
'field_name' => 'field_quantity',
|
| 690 |
'field_type' => 'number_integer',
|
| 691 |
'module' => 'number',
|
| 692 |
),
|
| 693 |
3 =>
|
| 694 |
array (
|
| 695 |
'widget_type' => 'number',
|
| 696 |
'label' => 'remaining items',
|
| 697 |
'weight' => '0',
|
| 698 |
'description' => '',
|
| 699 |
'default_value_widget' =>
|
| 700 |
array (
|
| 701 |
'field_remaining' =>
|
| 702 |
array (
|
| 703 |
0 =>
|
| 704 |
array (
|
| 705 |
'value' => '',
|
| 706 |
),
|
| 707 |
),
|
| 708 |
),
|
| 709 |
'default_value_php' => '',
|
| 710 |
'required' => '0',
|
| 711 |
'multiple' => '0',
|
| 712 |
'min' => '0',
|
| 713 |
'max' => '',
|
| 714 |
'prefix' => '',
|
| 715 |
'suffix' => '',
|
| 716 |
'allowed_values' => '',
|
| 717 |
'allowed_values_php' => '',
|
| 718 |
'field_name' => 'field_remaining',
|
| 719 |
'field_type' => 'number_integer',
|
| 720 |
'module' => 'number',
|
| 721 |
),
|
| 722 |
4 =>
|
| 723 |
array (
|
| 724 |
'widget_type' => 'nodereference_select',
|
| 725 |
'label' => 'Item to Trade',
|
| 726 |
'weight' => '1',
|
| 727 |
'description' => '',
|
| 728 |
'default_value_widget' =>
|
| 729 |
array (
|
| 730 |
'field_item' =>
|
| 731 |
array (
|
| 732 |
'nids' =>
|
| 733 |
array (
|
| 734 |
0 => '0',
|
| 735 |
),
|
| 736 |
),
|
| 737 |
),
|
| 738 |
'default_value_php' => '',
|
| 739 |
'required' => '1',
|
| 740 |
'multiple' => '0',
|
| 741 |
'referenceable_types' =>
|
| 742 |
array (
|
| 743 |
'item' => true,
|
| 744 |
'portfolio' => true,
|
| 745 |
0 => 1,
|
| 746 |
'item_count' => false,
|
| 747 |
'page' => false,
|
| 748 |
'trade' => false,
|
| 749 |
),
|
| 750 |
'advanced_view' => '--',
|
| 751 |
'advanced_view_args' => '',
|
| 752 |
'field_name' => 'field_item',
|
| 753 |
'field_type' => 'nodereference',
|
| 754 |
'module' => 'nodereference',
|
| 755 |
),
|
| 756 |
);
|
| 757 |
|
| 758 |
return $content;
|
| 759 |
}
|