function setUp() { $this->api =& DIA_API::create(); $now = date('mdHi'); $this->test_string = DIA_TEST_DATA_PREFIX . $now; $this->test_email_domain = '@radicaldesigns.org'; }
function &init_api($options = array()) { if (isset($this->_dia_api)) { return $this->_dia_api; } $this->_dia_api =& DIA_API::create(null, $options); return $this->_dia_api; }
function TestEventRead() { $this->UnitTestCase('Dia Event Read'); $api = DIA_API::create(null, $this->dia_account); $now = time(); $now -= $now % 60; //round to nearest minute $event = array('Status' => 'Active', 'Event_Name' => 'my cool event', 'Start' => dia_formatdate($now), 'End' => dia_formatdate($now + 360), 'This_Event_Costs_Money' => true, 'Ticket_Price' => 5, 'Contact_Email' => '*****@*****.**', 'Directions' => 'take a left at the tree', 'Address' => '123 sesame st', 'City' => 'san francisco', 'State' => 'CA', 'Zip' => 94110, 'Description' => 'this is the description', 'distributed_event_KEY' => 142); $this->event_key = $api->addEvent($event); $this->event = $api->getEvent($this->event_key); }
function _init_api() { $api_options = array(); if (defined('DIA_API_ORGANIZATION_KEY')) { $api_options['organization_key'] = DIA_API_ORGANIZATION_KEY; } if (defined('DIA_API_USERNAME')) { $api_options['user'] = DIA_API_USERNAME; } if (defined('DIA_API_PASSWORD')) { $api_options['password'] = DIA_API_PASSWORD; } $this->_api = DIA_API::create(null, $api_options); }
function execute($options = array()) { $options = array_merge($this->getOptions(), $options); if (!(isset($options['dia_event_key']) && $options['dia_event_key'])) { return false; } $key = $options['dia_event_key']; //accepts passed API options for testing purposes $api =& DIA_API::create(null, $options); if ($event = $api->getEvent($key)) { $local_data = $this->translate($event); $this->setData($local_data); #AMP_varDump( $this->getData( )); return true; } return false; }
function &_init_api($options = array()) { if (isset($this->_dia_api)) { return $this->_dia_api; } if (!(isset($options['orgKey']) && $options['orgKey']) && defined('DIA_API_ORGANIZATION_KEY')) { $options['orgKey'] = DIA_API_ORGANIZATION_KEY; } if (!(isset($options['user']) && $options['user']) && defined('DIA_API_USERNAME')) { $options['user'] = DIA_API_USERNAME; } if (!(isset($options['password']) && $options['password']) && defined('DIA_API_PASSWORD')) { $options['password'] = DIA_API_PASSWORD; } $this->_dia_api =& DIA_API::create(); $this->_dia_api->init(array('user' => $options['user'], 'password' => $options['password'], 'organization_key' => $options['orgKey'])); return $this->_dia_api; }
function save($data, $options = array()) { #$this->notice('entering diaevent save plugin'); $options = array_merge($options, $this->getOptions()); if (!defined('DIA_API_ORGANIZATION_KEY') && isset($options['orgKey'])) { define('DIA_API_ORGANIZATION_KEY', $options['orgKey']); } if (!defined('DIA_API_USERNAME') && isset($options['user'])) { define('DIA_API_USERNAME', $options['user']); } if (!defined('DIA_API_PASSWORD') && isset($options['password'])) { define('DIA_API_PASSWORD', $options['password']); } $supporter_save =& $this->udm->registerPlugin('DIA', 'Save'); if (!($supporter_key = $supporter_save->getSupporterKey())) { $this->error("couldn't retrieve supporter key", E_USER_ERROR); return false; } $data['supporter_KEY'] = $supporter_key; $data = $this->translate($data); $data = $this->_addDIAOptions($data, $options); $api_options = $options; if (isset($options['orgKey'])) { $api_options['organization_key'] = $options['orgKey']; } $api =& DIA_API::create(null, $api_options); if (!($event_key = $api->addEvent($data))) { $this->error('api failed to save event', E_USER_ERROR); return false; } $this->setEventKey($event_key); $event_id = isset($data['id']) ? $data['id'] : false; $this->_calendar_plugin->updateDIAKey($event_key, $event_id); $this->error('returning event key: ' . $this->getEventKey(), E_USER_NOTICE); return $this->getEventKey(); }
function testDefaultCapacity() { $save = $this->_udm->getPlugin('DIA', 'Save'); @$this->assertTrue($save->execute()); $this->assertTrue($save->getSupporterKey()); $this->_udm->uid = 1; $cal_save = $this->_udm->getPlugin('AMPCalendar', 'Save'); $this->assertTrue($cal_save->execute()); $cal_id = $cal_save->cal->id; $dia_save = $this->_udm->getPlugin('DIAEvent', 'Save'); $options = $dia_save->getOptions(); @($event_key = $dia_save->execute()); $this->assertTrue($event_key); $api = DIA_API::create(null, $this->dia_account); @($event = $api->getEvent($event_key)); $this->assertEqual($event['Maximum_Attendees'], $options['capacity']); }
function setUP() { $this->api =& DIA_API::create('HTTP_Request'); }
#!/usr/bin/php <?php if (!defined('PEAR_INCLUDE_PATH')) { define('PEAR_INCLUDE_PATH', '../../'); } $current_path = ini_get("include_path"); ini_set("include_path", "{$current_path}:" . PEAR_INCLUDE_PATH); if (2 == $argc && ($table = $argv[1])) { define('DIA_API_USERNAME', 'demo'); define('DIA_API_PASSWORD', 'demo'); require_once '../API.php'; require_once 'XML/Unserializer.php'; $api =& DIA_API::create('HTTP_Request'); $xml = $api->describe($table); $xmlparser =& new XML_Unserializer(); $status = $xmlparser->unserialize($xml); $desc = $xmlparser->getUnserializedData(); $file = "<?php\n\nrequire_once('DIA/Object.php');\n\nclass DIA_" . ucfirst($table) . " extends DIA_Object {\n\n var \$_table = '{$table}';\n\n"; foreach ($desc[$table]['Field'] as $field) { $function = join('', array_map('ucfirst', split('_', strtolower($field)))); $parameter = '$' . join('_', split('_', strtolower($field))); $file .= "\tfunction get" . $function . "() {\n\t\treturn \$this->getProperty('" . $field . "');\n\t}\n\n\tfunction set" . $function . "({$parameter}) {\n\t\treturn \$this->setProperty('{$field}', {$parameter});\n\t}\n\n"; } $file .= "}\n\n?>"; $handle = fopen(ucfirst($table) . '.php', 'w'); fwrite($handle, $file); fclose($handle); }
function &interface($api = null) { if (isset($api)) { $this->_interface =& DIA_API::create($api); } return $this->_interface; }
function getEventIndex() { if (defined('DIA_EVENT_INDEX_URL')) { return DIA_EVENT_INDEX_URL; } $organization = null; if (defined('DIA_ORGANIZATION_BASE_URL')) { $url = DIA_ORGANIZATION_BASE_URL; } else { if (!isset($this)) { $api = DIA_API::create(); } else { $api = $this; } $organization = $api->get('organization'); if (isset($organization['Base_URL'])) { $url = $organization['Base_URL']; } else { $url = 'http://www.democracyinaction.org/'; } } $url .= 'dia/organizations/'; if (defined('DIA_ORGANIZATION_SHORT_NAME')) { $url .= DIA_ORGANIZATION_SHORT_NAME . '/'; } else { if (!isset($organization)) { if (!isset($this)) { $api = DIA_API::create(); } else { $api = $this; } $organization = $api->get('organization'); } if (isset($organization['READONLY_Short_Name'])) { $url .= $organization['READONLY_Short_Name'] . '/'; } else { //boo $this->error('getEventIndex couldn\'t get short name'); return false; } } if (defined('DIA_EVENT_INDEX_CONTROLLER')) { $url .= DIA_EVENT_INDEX_CONTROLLER; } else { $url .= 'event/index.jsp'; } return $url; }
function AMP_subscribe_to_list($addresses, $list_id) { if (AMP_MODULE_BLAST == 'PHPlist') { require_once 'Modules/Blast/API.inc.php'; $_PHPlist = new PHPlist_API($this->dbcon); return $_PHPlist->add_subscribers($addresses, $list_id); } if (AMP_MODULE_BLAST == 'DIA') { require_once 'DIA/API.php'; if (!isset($api)) { $api = DIA_API::create(); } $result = $api->addMembersByEmail($addresses, $list_id); return sizeof($result); } return false; }
function AMPSystemLookup_Lists() { if (isset($GLOBALS['MM_listtable'])) { $this->datatable = $GLOBALS['MM_listtable']; $this->criteria = 'active=1'; } if (defined('AMP_MODULE_BLAST')) { if (AMP_MODULE_BLAST == 'PHPlist') { $this->datatable = 'phplist_list'; $this->criteria = 'active=1'; } if (AMP_MODULE_BLAST == 'Listserve') { $this->criteria = "publish=1 and !isnull( subscribe_address) and subscribe_address != ''"; } if (AMP_MODULE_BLAST == 'DIA') { require_once 'DIA/API.php'; $api = DIA_API::create(); $groups = $api->getGroupNamesAssoc(); $this->dataset = isset($groups) ? $groups : array(); if (!$groups) { return false; } //update our local copy of available DIA lists $dbcon = AMP_Registry::getDbcon(); foreach ($groups as $id => $name) { $list = array('id' => $id, 'name' => $name, 'description' => 'DIA Group', 'service_type' => 'DIA'); $dbcon->Replace('lists', $list, array('id', 'service_type'), $quote = true); } return; } } $this->init(); }
function subscribe_set($set, $api = null) { if (!(isset($_POST['blastlist_id']) && ($list_id = $_POST['blastlist_id']))) { return 'Please select a list'; } $ids = split(",", $set); $emailSet =& AMPSystem_Lookup::instance('userDataEmails'); $new_subscribers =& array_combine_key($ids, $emailSet); if (AMP_MODULE_BLAST == 'PHPlist') { require_once 'Modules/Blast/API.inc.php'; $_PHPlist = new PHPlist_API($this->dbcon); $count = $_PHPlist->add_subscribers($new_subscribers, $list_id); } elseif (AMP_MODULE_BLAST == 'DIA') { require_once 'DIA/API.php'; if (!isset($api)) { $api = DIA_API::create(); } $result = $api->addMembersByEmail($new_subscribers, $list_id); $count = sizeof($result); } $listSet =& AMPSystem_Lookup::instance('lists'); return $count . ' users subscribed to ' . $listSet[$list_id]; }