Esempio n. 1
0
/**
*   Get information about a specific item.
*
*   @param  array   $args       Item Info (pi_name, item_type, item_id)
*   @param  array   &$output    Array of output data
*   @param  string  &$svc_msg   Unused
*   @return integer     Return value
*/
function service_productinfo_evlist($args, &$output, &$svc_msg)
{
    global $_TABLES, $_CONF, $LANG_EVLIET;
    $retval = PLG_RET_OK;
    // Create a return array with values to be populated later.
    // The actual paypal product ID is evlist:type:id
    $output = array('product_id' => implode(':', $args), 'name' => 'Unknown', 'short_description' => 'Unknown Evlist Item', 'price' => '0.00');
    if (!is_array($args) || !isset($args[2])) {
        return $output;
    }
    $product_id = $args[1];
    $item_id = $args[2];
    switch ($product_id) {
        case 'eventfee':
            $item_parts = explode('/', $item_id);
            $ev_id = $item_parts[0];
            $tick_type = isset($item_parts[1]) ? $item_parts[1] : 0;
            $rp_id = isset($item_parts[2]) ? $item_parts[2] : 0;
            if ($tick_type == 0) {
                return PLG_RET_ERROR;
            }
            USES_evlist_class_tickettype();
            USES_evlist_class_event();
            $Tick = new evTicketType($tick_type);
            $Ev = new evEvent($ev_id);
            if (isset($Ev->ptions['tickets'][$tick_type])) {
                $fee = (double) $Ev->options['tickets'][$tick_type];
            } else {
                $fee = 0;
            }
            $short_desc = $Tick->description . ': ' . $Ev->Detail->title;
            if ($rp_id > 0) {
                USES_evlist_class_repeat();
                $Ev = new evRepeat($rp_id);
                if ($Ev->rp_id == $rp_id) {
                    // valid repeat ID
                    $short_desc .= ', ' . $Ev->start_date1 . ' ' . $Ev->start_time1;
                } else {
                    return PLG_RET_ERROR;
                }
            }
            $output['name'] = $short_desc;
            $output['short_description'] = $short_desc;
            $output['price'] = (double) $fee;
            break;
    }
    return $retval;
}
Esempio n. 2
0
/**
*   Import data from the Calendar plugin into evList
*   @author     Mark R. Evans mark AT glfusion DOT org
*   @copyright  Copyright (c) 2008 - 2010 Mark R. Evans mark AT glfusion DOT org
*   @package    evlist
*   @version    1.3.0
*   @license    http://opensource.org/licenses/gpl-2.0.php
*               GNU Public License v2 or later
*   @filesource
*/
// this file can't be used on its own
if (!defined('GVERSION')) {
    die('This file can not be used on its own.');
}
/** Import the event class */
USES_evlist_class_event();
/**
*   Import events from the Calendar plugin to evList.
*   This function checks that the event ID isn't already in use to avoid
*   re-importing events.
*
*   @return integer     0 = success, -1 = event table missing, >0 = error count
*/
function evlist_import_calendar_events()
{
    global $_TABLES, $LANG_EVLIST;
    if (!isset($_TABLES['events']) || empty($_TABLES['events'])) {
        return -1;
    }
    $errors = 0;
    // Keep track of errors
Esempio n. 3
0
/**
*   Upgrade to version 1.3.0
*   Many changes in this version, so a function was created to
*   hold them all.
*
*   @return boolean     True on success, False on failure
*/
function evlist_upgrade_1_3_0()
{
    global $_CONF, $_EV_CONF, $_TABLES, $_DB_dbms, $c, $CONF_EVLIST_DEFAULT;
    USES_evlist_class_event();
    $c->add('default_view', $CONF_EVLIST_DEFAULT['default_view'], 'select', 0, 1, 14, 90, true, 'evlist');
    $c->add('max_upcoming_days', $CONF_EVLIST_DEFAULT['max_upcoming_days'], 'text', 0, 1, 0, 100, true, 'evlist');
    // Combine users allowed to add events into one variable
    $can_add = 0;
    if ($EV_CONF['allow_anon_add'] > 0) {
        $can_add += EV_ANON_CAN_ADD;
    }
    if ($EV_CONF['allow_user_add'] > 0) {
        $can_add += EV_USER_CAN_ADD;
    }
    $c->add('can_add', $can_add, 'select', 0, 1, 15, 20, true, 'evlist');
    $c->del('allow_user_add', 'evlist');
    $c->del('allow_anon_add', 'evlist');
    // Add new options for plugin integration
    $c->add('use_locator', $CONF_EVLIST_DEFAULT['use_locator'], 'select', 0, 1, 0, 110, true, 'evlist');
    $c->add('use_weather', $CONF_EVLIST_DEFAULT['use_weather'], 'select', 0, 1, 0, 120, true, 'evlist');
    // Date & Time formats moved from the DB to simple $_CONF  variables
    $format = DB_getItem($_TABLES['evlist_dateformat'], 'format', "id='{$_EV_CONF['date_format']}'");
    if (empty($format)) {
        $format = '%a %b %d, %Y';
    }
    $c->set_default('date_format', $format, 'evlist');
    $c->set('date_format', $format, 'evlist');
    $format = DB_getItem($_TABLES['evlist_timeformat'], 'format', "id='{$_EV_CONF['date_format']}'");
    if (empty($format)) {
        $format = '%I:%M %p';
    }
    $c->set_default('time_format', $format, 'evlist');
    $c->set('time_format', $format, 'evlist');
    DB_query("DROP TABLE {$_TABLES['evlist_dateformat']}");
    DB_query("DROP TABLE {$_TABLES['evlist_timeformat']}");
    // Change feature name
    DB_query("UPDATE {$_TABLES['features']}\n                SET ft_name='evlist.admin' WHERE ft_name='evlist.edit'");
    // Add new "submit" feature & map to Root group
    DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr)\n            VALUES ('evlist.submit', \n                    'Allowed to bypass the evList submission queue')", 1);
    if (!DB_error()) {
        $ft_id = (int) DB_insertId();
        if ($ft_id > 0) {
            DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id)\n                    VALUES('{$ft_id}', '1')");
        }
    }
    EVLIST_do_upgrade_sql('1.3.0');
    // Add the new fields to the event & submission tables
    /*$new_sql = "ADD det_id int(10) NOT NULL,
              ADD show_upcoming tinyint(1) unsigned NOT NULL DEFAULT '1',
              ADD cal_id int(10) unsigned NOT NULL DEFAULT '1',
              ADD options varchar(255)";
      DB_query("ALTER TABLE {$_TABLES['evlist_events']} $new_sql");
      DB_query("ALTER TABLE {$_TABLES['evlist_submissions']} $new_sql");*/
    // Create the new tables
    /*DB_query($_SQL['evlist_repeat']);
      DB_query($_SQL['evlist_calendars']);
      DB_query($_SQL['evlist_detail']);
      DB_query($DEFVALUES['evlist_calendars']);*/
    // Now split out the detail and create the repeats
    $result = DB_query("SELECT * FROM {$_TABLES['evlist_events']}");
    $error = 0;
    while ($A = DB_fetchArray($result, false)) {
        $A = array_map('DB_escapeString', $A);
        $sql = "INSERT INTO {$_TABLES['evlist_detail']} (\n                    ev_id, title, summary, full_description, url, location,\n                    street, city, province, country, postal, contact,\n                    email, phone\n                ) VALUES (\n                    '{$A['id']}', '{$A['title']}', '{$A['summary']}', \n                    '{$A['full_description']}', '{$A['url']}',\n                    '{$A['location']}', '{$A['street']}',\n                    '{$A['city']}', '{$A['province']}',\n                    '{$A['country']}', '{$A['postal']}',\n                    '{$A['contact']}', '{$A['email']}','{$A['phone']}'\n                )";
        DB_query($sql, 1);
        if (DB_error()) {
            $error = 1;
            break;
        } else {
            $DB_det_id = DB_insertID();
        }
        $rec_data = array();
        if ($A['recurring'] == 1) {
            $rec_data['type'] = $A['rec_option'];
            switch ($A['rec_option']) {
                case EV_RECUR_DAILY:
                case EV_RECUR_MONTHLY:
                case EV_RECUR_YEARLY:
                    list($stop, $skip) = explode(';', $A['rec_data']);
                    if (!empty($skip)) {
                        $rec_data['skip'] = (int) $skip;
                    }
                    break;
                case EV_RECUR_WEEKLY:
                    list($listdays, $stop) = explode(';', $A['rec_data']);
                    $rec_data['listdays'] = explode(',', $listdays);
                    break;
                case EV_RECUR_DOM:
                    list($interval, $weekday, $stop) = explode(';', $A['rec_data']);
                    $rec_data['weekday'] = $weekday;
                    $rec_data['interval'] = $interval;
                    break;
                case EV_RECUR_DATES:
                    $rec_data['custom'] = explode(',', $A['rec_data']);
                    $stop = 'XX';
                    // unused flag
                    break;
            }
            // switch recurring type
            // Check the stop date for validity and format it properly
            if ($stop != 'XX') {
                if (strtotime($stop) > strtotime('2037-01-01') || $stop < '1970-01-01') {
                    $stop = '2037-12-31';
                }
                list($y, $m, $d) = explode('-', $stop);
                $rec_data['stop'] = sprintf('%d-%02d-%02d', $y, $m, $d);
            }
        } else {
            // not a recurring event
            $rec_data['type'] = 0;
        }
        $DB_rec_data = DB_escapeString(serialize($rec_data));
        $sql = "UPDATE {$_TABLES['evlist_events']} SET\n                    rec_data = '{$DB_rec_data}',\n                    det_id = '{$DB_det_id}'\n                WHERE id='{$A['id']}'";
        DB_query($sql, 1);
        if (DB_error()) {
            $error = 1;
            break;
        }
        // Now that the updated info is saved to the event record,
        // use the evEvent class to create the repeats
        $Ev = new evEvent($A['id']);
        $Ev->UpdateRepeats();
    }
    // for each event record
    if ($error == 0) {
        // Now drop the no-longer-used fields
        $alter_sql = "DROP title, DROP summary, DROP full_description,\n                DROP date_start2, DROP date_end2,\n                DROP url, DROP location, DROP street, DROP city,\n                DROP province, DROP country, DROP postal, DROP contact,\n                DROP email, DROP phone";
        DB_query("ALTER TABLE {$_TABLES['evlist_events']} {$alter_sql}");
        DB_query("ALTER TABLE {$_TABLES['evlist_submissions']} {$alter_sql}");
        DB_query("ALTER TABLE {$_TABLES['evlist_remlookup']}\n                DROP id,\n                ADD rp_id int(10) unsigned NOT NULL default 0 AFTER eid,\n                DROP date_start,\n                DROP timestamp");
        // Add new options.  Set values to emulate current behavior.
        $options = array('contactlink' => 1);
        $opt_str = DB_escapeString(serialize($options));
        DB_query("UPDATE {$_TABLES['evlist_events']} SET options='{$opt_str}'");
        DB_query("UPDATE {$_TABLES['evlist_submissions']} SET options='{$opt_str}'");
    }
    CTL_clearCache();
    // Clear cache to activate new configuration items.
    return $error;
}
Esempio n. 4
0
/**
*   Import events from a CSV file into the database.
*
*   @return string      Completion message
*/
function EVLIST_importEvents()
{
    global $_CONF, $_TABLES, $LANG_EVLIST, $_USER;
    // Setting this to true will cause import to print processing status to
    // webpage and to the error.log file
    $verbose_import = true;
    $retval = '';
    // First, upload the file
    USES_class_upload();
    $upload = new upload();
    $upload->setPath($_CONF['path_data']);
    $upload->setAllowedMimeTypes(array('text/plain' => '.txt, .csv', 'application/octet-stream' => '.txt, .csv'));
    $upload->setFileNames('evlist_import_file.txt');
    $upload->setFieldName('importfile');
    if ($upload->uploadFiles()) {
        // Good, file got uploaded, now install everything
        $filename = $_CONF['path_data'] . 'evlist_import_file.txt';
        if (!file_exists($filename)) {
            // empty upload form
            $retval = $LANG_EVLIST['err_invalid_import'];
            return $retval;
        }
    } else {
        // A problem occurred, print debug information
        $retval .= $upload->printErrors(false);
        return $retval;
    }
    $fp = fopen($filename, 'r');
    if (!$fp) {
        $retval = $LANG_EVLIST['err_invalid_import'];
        return $retval;
    }
    USES_evlist_class_event();
    $success = 0;
    $failures = 0;
    // Set owner_id to the current user and group_id to the default
    $owner_id = (int) $_USER['uid'];
    if ($owner_id < 2) {
        $owner_id = 2;
    }
    // last resort, use Admin
    $group_id = (int) DB_getItem($_TABLES['groups'], 'grp_id', 'grp_name="evList Admin"');
    if ($group_id < 2) {
        $group_id = 2;
    }
    // last resort, use Root
    while (($event = fgetcsv($fp)) !== false) {
        $Ev = new evEvent();
        $Ev->isNew = true;
        $i = 0;
        $A = array('date_start1' => $event[$i++], 'date_end1' => $event[$i++], 'time_start1' => $event[$i++], 'time_end1' => $event[$i++], 'title' => $event[$i++], 'summary' => $event[$i++], 'full_description' => $event[$i++], 'url' => $event[$i++], 'location' => $event[$i++], 'street' => $event[$i++], 'city' => $event[$i++], 'province' => $event[$i++], 'country' => $event[$i++], 'postal' => $event[$i++], 'contact' => $event[$i++], 'email' => $event[$i++], 'phone' => $event[$i++], 'cal_id' => 1, 'status' => 1, 'hits' => 0, 'recurring' => 0, 'split' => 0, 'time_start2' => '00:00:00', 'time_end2' => '00:00:00', 'owner_id' => $owner_id, 'group_id' => $group_id);
        if ($_CONF['hour_mode'] == 12) {
            list($hour, $minute, $second) = explode(':', $A['time_start1']);
            if ($hour > 12) {
                $hour -= 12;
                $am = 'pm';
            } elseif ($hour == 0) {
                $hour = 12;
                $am = 'am';
            } else {
                $am = 'am';
            }
            $A['start1_ampm'] = $am;
            $A['starthour1'] = $hour;
            $A['startminute1'] = $minute;
            list($hour, $minute, $second) = explode(':', $A['time_end1']);
            if ($hour > 12) {
                $hour -= 12;
                $am = 'pm';
            } elseif ($hour == 0) {
                $hour = 12;
                $am = 'am';
            } else {
                $am = 'am';
            }
            $A['end1_ampm'] = $am;
            $A['endhour1'] = $hour;
            $A['endminute1'] = $minute;
        }
        if ($A['time_start1'] == '00:00:00' && $A['time_end1'] == '00:00:00') {
            $A['allday'] = 1;
        } else {
            $A['allday'] = 0;
        }
        $msg = $Ev->Save($A);
        if (empty($msg)) {
            $successes++;
        } else {
            $failures++;
        }
    }
    return "{$successes} Succeeded<br />{$failures} Failed";
}
Esempio n. 5
0
/**
*   Post-installation activity.
*   Create the repeating event records for the sample data that was loaded.
*/
function X_plugin_postinstall_evlist()
{
    global $_TABLES, $_CONF, $_EV_CONF;
    require_once $_CONF['path'] . '/plugins/evlist/functions.inc';
    // Now create the repeat records for the default events
    USES_evlist_class_event();
    $sql = "SELECT id FROM {$_TABLES['evlist_events']}";
    $res = DB_query($sql);
    $Ev = new evEvent();
    while ($A = DB_fetchArray($res, false)) {
        $Ev->Read($A['id']);
        $Ev->UpdateRepeats();
    }
    // Clear the template cache since we've introduced some new css.
    // Might not be needed outside of testing where the plugin is repeatedly
    // installed & removed, but doesn't hurt.
    CTL_clearCache();
}