Example #1
0
 function setUp()
 {
     $this->api =& DIA_API::create();
     $now = date('mdHi');
     $this->test_string = DIA_TEST_DATA_PREFIX . $now;
     $this->test_email_domain = '@radicaldesigns.org';
 }
Example #2
0
 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;
 }
Example #3
0
 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);
 }
Example #4
0
 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);
 }
Example #5
0
 function init($options = null)
 {
     $this->_initDIAUrls();
     if (isset($options['user'])) {
         $this->_username = $options['user'];
     }
     if (isset($options['password'])) {
         $this->_password = $options['password'];
     }
     if (isset($options['organization_key'])) {
         $this->_organization_key = $options['organization_key'];
     }
     return parent::init();
 }
Example #6
0
 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;
 }
Example #7
0
 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;
 }
Example #8
0
 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();
 }
Example #9
0
 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']);
 }
Example #10
0
 function setUP()
 {
     $this->api =& DIA_API::create('HTTP_Request');
 }
Example #11
0
#!/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);
}
Example #12
0
 function &interface($api = null)
 {
     if (isset($api)) {
         $this->_interface =& DIA_API::create($api);
     }
     return $this->_interface;
 }
Example #13
0
 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();
 }
Example #14
0
 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];
 }
Example #15
0
function calendar_output_detail_rsvp_mapped($dbcon, $id)
{
    $q = "select calendar.* from calendar where calendar.id = {$id}";
    $event = $dbcon->CacheGetAll($q);
    foreach ($event as $e) {
        if (isset($e['dia_key']) && $e['dia_key']) {
            $meat .= '<a href="' . DIA_API::getEventIndex() . '?event_KEY=' . $e['dia_key'] . '">RSVP</a>&nbsp; ';
        } elseif ($e['registration_modin'] > 0) {
            $meat .= "<br><a href=\"modinput4.php?modin=" . $e['registration_modin'] . "&calid={$id}\">RSVP</a>";
        }
        $meat .= "<p><span class=title>" . $e['event'] . '</span>';
        if ($e['recurring_options'] == 1) {
            $meat .= "<br/><i>Multi-Day Event</i>";
        }
        if ($e['recurring_options'] == 2) {
            $meat .= "<br/><i>Weekly Event </i>";
        }
        if ($e['recurring_options'] == 3) {
            $meat .= "<br/><i>Monthly Event </i>";
        }
        if ($e['recurring_options'] == 4) {
            $meat .= "<br/><i>Annual Event</i>";
        }
        if ($e['recurring_options'] > 0 && $e['recurring_description'] != NULL) {
            $meat .= ", " . $e['recurring_description'];
        }
        if ($e['date'] != '0000-00-00' || $e['time'] != '') {
            $meat .= '<br>
				<span class="eventsubtitle">' . DoDate($e['date'], 'l, F jS Y') . ' ';
            if ($e['time'] != '00:00 ') {
                $meat .= $e['time'];
            }
        }
        $meat .= '<br>' . $e['lcity'] . ',&nbsp;' . $e['lstate'] . '  ' . $e['lcountry'] . '</span><br><br>
				<span class="text">';
        if ($e['shortdesc'] != '' && $e['fulldesc'] == '') {
            $meat .= converttext(trim($e['shortdesc'])) . '<br>';
        }
        $meat .= converttext(trim($e['fulldesc'])) . '<br>';
        if ($e['location'] != $null) {
            $meat .= '<br><br>
				<b>Location:&nbsp;</b><br>' . $e['location'] . '&nbsp;' . $e['laddress'] . '&nbsp;' . $e['lcity'] . '&nbsp;' . $e['lstate'] . '&nbsp;' . $e['lzip'] . '&nbsp;';
        }
        if ($e['contact1'] != '' or $e['phone1'] != '' or $e['email1'] != '') {
            $meat .= '<br><br><b>Contact:</b>';
        }
        if ($e['contact1'] != '') {
            $meat .= '<br>' . $e['contact1'];
        }
        if ($e['email1'] != '') {
            $meat .= '<br><a href="mailto:' . $e['email1'] . '">' . $e['email1'] . '</a>';
        }
        if ($e['phone1'] != '') {
            $meat .= '<br>' . $e['phone1'];
        }
        if ($e['org'] != '') {
            $meat .= '<br><br><b>Sponsored By:</b><br>' . $e['org'];
        }
        if ($e['url'] != '' and $e['url'] != 'http://') {
            $meat .= ' <a href="' . $e['url'] . '">' . $e['url'] . '</a>';
        }
        $meat .= '</span></p>';
        //
        //insert map
        //var_dump($event);
        /* broken and not always valid: buh-bye
        		if ($e['lat']&&$e['lon']) {
        			$map_lat=$e['lat'];$map_long=$e['lon']; 
        			$mapcode = "mapgen?lon=" .  $map_long . "&lat=" .  $map_lat . "&wid=0.035&ht=0.035&iht=320&iwd=320&mark=" .  $map_long . "," .  $map_lat . ",redpin";
        			$meat .= str_replace('$map_long',$map_long,str_replace('$map_lat',$map_lat,file_get_contents('http://'.$_SERVER['SERVER_NAME'].'/scripts/geocode.js')));
        			$meat .= str_replace('$mapcode',$mapcode,file_get_contents('includes/geocode.inc.php'));
        		}
                
        		$meat .= '<p class="eventsubtitle">Event followups and comments:</p>';
        		// read in results for this calendar id here
        		if (!$resultspresent) {$meat .= '<p class="text">No results entered yet for this event.</p>';};
        
        		$meat .= '<p class="eventsubtitle">Event photos:</p>';
        		// read in photos for this calendar id here
        		if (!$photospresent) {$meat .= '<p class="text">No photos entered yet for this event.</p>';};
                    */
    }
    return $meat;
}
Example #16
0
 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;
}