Example #1
0
function amr_set_defaults()
{
    global $amr_calprop;
    global $amr_colheading;
    global $amr_compprop;
    global $amr_groupings;
    global $amr_components;
    global $amr_limits, $amr_listtype;
    global $amr_formats;
    global $amr_general;
    global $amr_globaltz;
    global $ical_timezone;
    global $eventtaxonomies;
    global $amr_options, $locale;
    $amr_listtype = '1';
    // global default
    $amr_options = array('ngiyabonga' => false, 'own_css' => false, 'feed_css' => true, 'cssfile' => ICALSTYLEURL, 'date_localise' => 'amr', 'noeventsmessage' => 'No events found within criteria', 'lookmoremessage' => 'Look for more', 'lookprevmessage' => 'Look for previous', 'amr-ical-events-list', 'resetmessage' => 'Reset', 'amr-ical-events-list', 'freebusymessage' => '✖');
    // if they don't have the gettext function the translation scanners will not pick the strings up for inclusion in the .pot/.po file
    $fakeforautolangtranslation = array('noeventsmessage' => __('No events found within criteria', 'amr-ical-events-list'), 'lookmoremessage' => __('Look for more', 'amr-ical-events-list'), 'lookprevmessage' => __('Look for previous', 'amr-ical-events-list'), 'resetmessage' => __('Reset', 'amr-ical-events-list'), 'freebusymessage' => __('Busy', 'amr-ical-events-list'), __("Year", 'amr-ical-events-list'), __("Quarter", 'amr-ical-events-list'), __("Astronomical Season", 'amr-ical-events-list'), __("Traditional Season", 'amr-ical-events-list'), __("Western Zodiac", 'amr-ical-events-list'), __("Month", 'amr-ical-events-list'), __("Week", 'amr-ical-events-list'), __("Day", 'amr-ical-events-list'));
    if (defined('AMR_ICAL_VERSION')) {
        $amr_options['ngiyabonga'] = true;
    }
    //do not show credit link
    $alreadyhave = false;
    //	if ($locale === 'en_US' )  $amr_options['date_localise'] = 'none';   // v4.0.9 commented out - multi lingual situations may have en as base, but will need localisation
    //	else
    $amr_options['date_localise'] = 'wp';
    //
    amr_set_defaults_for_datetime();
    $amr_general = array('name' => __('Default', 'amr-ical-events-list'), 'Description' => __('A default calendar list. This one set to tables with lists in the cells.  Usually needs the css file enabled. If you configure it, I suggest changing this description to aid your memory of how/why it is configured the way that it is. ', 'amr-ical-events-list'), "Default Event URL" => '', 'ListHTMLStyle' => 'table', 'customHTMLstylefile' => '');
    $amr_limits = array("events" => 30, "days" => 90, "cache" => 24, "eventscache" => 0.5);
    // must not set start here
    $amr_components = array("VEVENT" => true, "VTODO" => true, "VJOURNAL" => false, "VFREEBUSY" => true);
    $amr_groupings = amr_define_possible_groupings();
    $amr_colheading = array('1' => __('When', 'amr-ical-events-list'), '2' => __('What', 'amr-ical-events-list'), '3' => __('Where', 'amr-ical-events-list'));
    $dfalse = array('Column' => 0, 'Order' => 999, 'Before' => '', 'After' => '');
    $dtrue = array('Column' => 1, 'Order' => 1, 'Before' => '', 'After' => '');
    $dtrue2 = array('Column' => 2, 'Order' => 1, 'Before' => '', 'After' => '');
    // check if we have any taxonomies that we may wish to assign an event to
    $eventtaxonomies = amr_define_possible_taxonomies();
    foreach ($eventtaxonomies as $i => $tax) {
        $eventtaxonomiesprop[$tax] = array('Column' => 2, 'Order' => 200, 'Before' => '', 'After' => ' ');
    }
    $amr_calprop = array('X-WR-CALNAME' => array('Column' => 1, 'Order' => 1, 'Before' => '', 'After' => ''), 'X-WR-CALDESC' => $dfalse, 'X-WR-TIMEZONE' => array('Column' => 0, 'Order' => 40, 'Before' => '', 'After' => ''), 'icsurl' => array('Column' => 2, 'Order' => 20, 'Before' => '', 'After' => ''), 'addtogoogle' => array('Column' => 2, 'Order' => 10, 'Before' => '', 'After' => ''), 'icalrefresh' => array('Column' => 0, 'Order' => 30, 'Before' => '', 'After' => ''), 'LAST-MODIFIED' => $dtrue);
    /* NB need to switch some field s on for initial plugin view.  This will be common default for all, then some are customised separately */
    $amr_compprop = array('Descriptive' => array_merge(array('SUMMARY' => array('Column' => 2, 'Order' => 10, 'Before' => '<b>', 'After' => '</b>'), 'DESCRIPTION' => array('Column' => 2, 'Order' => 20, 'Before' => '', 'After' => ''), 'excerpt' => array('Column' => 0, 'Order' => 30, 'Before' => '<br />', 'After' => ''), 'postthumbnail' => array('Column' => 0, 'Order' => 35, 'Before' => '<br />', 'After' => ''), 'LOCATION' => array('Column' => 2, 'Order' => 41, 'Before' => '', 'After' => ''), 'map' => array('Column' => 2, 'Order' => 40, 'Before' => '', 'After' => ''), 'addevent' => array('Column' => 2, 'Order' => 1, 'Before' => '', 'After' => ''), 'subscribeevent' => array('Column' => 2, 'Order' => 2, 'Before' => '', 'After' => ''), 'subscribeseries' => array('Column' => 2, 'Order' => 3, 'Before' => '', 'After' => ''), 'GEO' => $dfalse, 'ATTACH' => array('Column' => 2, 'Order' => 150, 'Before' => __('More info: ', 'amr-ical-events-list'), 'After' => '<br />'), 'CATEGORIES' => array('Column' => 2, 'Order' => 200, 'Before' => '', 'After' => ''), 'CLASS' => array('Column' => 0, 'Order' => 210, 'Before' => '', 'After' => ''), 'COMMENT' => $dfalse, 'PERCENT-COMPLETE' => $dfalse, 'PRIORITY' => array('Column' => 0, 'Order' => 220, 'Before' => '', 'After' => ''), 'RESOURCES' => $dfalse, 'STATUS' => array('Column' => 0, 'Order' => 230, 'Before' => '', 'After' => '')), $eventtaxonomiesprop), 'Date and Time' => array('EventDate' => array('Column' => 1, 'Order' => 1, 'Before' => '', 'After' => ''), 'StartTime' => array('Column' => 1, 'Order' => 2, 'Before' => ' ', 'After' => ' '), 'EndDate' => array('Column' => 1, 'Order' => 3, 'Before' => __(' to', 'amr-ical-events-list') . '&nbsp;', 'After' => ''), 'EndTime' => array('Column' => 1, 'Order' => 4, 'Before' => ' ', 'After' => ''), 'DTSTART' => $dfalse, 'DTEND' => $dfalse, 'DUE' => $dfalse, 'DURATION' => array('Column' => 0, 'Order' => 50, 'Before' => '', 'After' => ''), 'allday' => array('Column' => 1, 'Order' => 4, 'Before' => '&nbsp;', 'After' => ''), 'timezone' => $dfalse, 'COMPLETED' => $dfalse, 'FREEBUSY' => $dfalse, 'TRANSP' => $dfalse), 'Relationship' => array('CONTACT' => array('Column' => 0, 'Order' => 350, 'Before' => '', 'After' => ''), 'ORGANIZER' => array('Column' => 0, 'Order' => 360, 'Before' => '', 'After' => ''), 'ATTENDEE' => array('Column' => 0, 'Order' => 370, 'Before' => '', 'After' => ''), 'Attendee-counts' => array('Column' => 0, 'Order' => 380, 'Before' => '', 'After' => ''), 'RECURRENCE-ID' => $dfalse, 'RELATED-TO' => $dfalse, 'URL' => array('Column' => 0, 'Order' => 150, 'Before' => '', 'After' => ''), 'UID' => $dfalse), 'Recurrence' => array('EXDATE' => $dfalse, 'EXRULE' => $dfalse, 'RDATE' => $dfalse, 'RRULE' => $dfalse), 'Alarm' => array('ACTION' => $dfalse, 'REPEAT' => $dfalse, 'TRIGGER' => $dfalse), 'Change Management' => array('CREATED' => $dfalse, 'DTSTAMP' => $dfalse, 'SEQUENCE' => $dfalse, 'LAST-MODIFIED' => $dfalse));
    //		if (function_exists ('amr_indicate_attendance')) {    //pluggable does not exist yet
    //		}
    if (function_exists('amr_rsvp')) {
        $amr_compprop['Relationship']['declined'] = array('Column' => 0, 'Order' => 400, 'Before' => '', 'After' => '');
        $amr_compprop['Relationship']['rsvp'] = array('Column' => 0, 'Order' => 410, 'Before' => '', 'After' => '');
        $amr_compprop['Relationship']['rsvpwithcomment'] = array('Column' => 0, 'Order' => 420, 'Before' => '', 'After' => '');
        $amr_compprop['Relationship']['going_ornot_ormaybe'] = array('Column' => 0, 'Order' => 430, 'Before' => '', 'After' => '');
        $amr_compprop['Relationship']['total_attending'] = array('Column' => 0, 'Order' => 510, 'Before' => '', 'After' => '');
        $amr_compprop['Relationship']['total_maybe'] = array('Column' => 0, 'Order' => 510, 'Before' => '', 'After' => '');
        $amr_compprop['Relationship']['total_declined'] = array('Column' => 0, 'Order' => 510, 'Before' => '', 'After' => '');
    }
    //
    for ($i = 1; $i <= 13; $i++) {
        /* setup some list type defaults if we have empty list type arrays */
        $amr_options['listtypes'][$i] = new_listtype();
        // set up basic
        $amr_options['listtypes'][$i] = customise_listtype($i);
        /* then tweak */
    }
    //		add_option('amr-ical-events-list', $amr_options);  // hmm what to do - if we autosave, then they do not pickup new defaults automatically
}
Example #2
0
function amrical_validate_manage_listings()
{
    global $amr_options;
    $nonce = $_REQUEST['_wpnonce'];
    if (!wp_verify_nonce($nonce, 'amr-ical-events-list')) {
        die("Cancelled due to failed security check");
    }
    if (!empty($_POST['calendar_preview_url'])) {
        if (!filter_var($_POST['calendar_preview_url'], FILTER_VALIDATE_URL)) {
            amr_invalid_url();
        } else {
            $url = filter_var($_POST['calendar_preview_url'], FILTER_SANITIZE_URL);
            $sticky_url = amr_make_sticky_url($url);
            if (!$sticky_url) {
                $calendar_preview_url = $url;
            } else {
                $calendar_preview_url = $sticky_url;
            }
            update_option('amr-ical-calendar_preview_url', $calendar_preview_url);
        }
    } else {
        update_option('amr-ical-calendar_preview_url', '');
    }
    //----- list numbers
    $dupcheck = array();
    // clear it out
    if (!empty($_POST['listnumber'])) {
        foreach ($_POST['listnumber'] as $i => $n) {
            if ($n === '') {
                break;
            }
            $nn = abs(intval($n));
            if ($nn === 0) {
                echo '<div class="error">' . __('Please use numbers > 1', 'amr-ical-events-list') . '</div>';
                return;
            }
            if (in_array($nn, $dupcheck)) {
                echo '<b>Duplicate List Number was entered - please ensure all list numbers are unique.</b>';
            } else {
                $listnumber[$i] = $nn;
                $dupcheck[$nn] = $nn;
                // keep a record of the numbers
                if (empty($_POST['prevnumber'][$i]) or $_POST['prevnumber'][$i] === '') {
                    // if we have no listtype for the  existing number, then must be new
                    $amr_options['listtypes'][$nn] = new_listtype();
                    $amr_options['listtypes'][$nn]['Id'] = $nn;
                    $amr_options['listtypes'][$nn]['general']['name'] .= $nn;
                    $amr_options['listtypes'][$nn] = customise_listtype($nn);
                    // includes the fix, need till we drop away old compatibility
                    echo '<br />Create new ' . $nn;
                } else {
                    // we are changing a list number, copy the list type to the new number
                    $prev = $_POST['prevnumber'][$i];
                    if (!($prev == $nn)) {
                        $amr_options['listtypes'][$nn] = $amr_options['listtypes'][$prev];
                        $amr_options['listtypes'][$nn]['Id'] = $nn;
                        unset($amr_options['listtypes'][$prev]);
                    }
                }
            }
        }
        ksort($amr_options['listtypes']);
    }
    // ---------------------- imported lists
    if (isset($_POST['import'])) {
        $import = $_POST['import'];
        foreach ($import as $i => $il) {
            if (!empty($il)) {
                //var_dump($il);
                $importedlist = unserialize(base64_decode($il));
                $importedlist['Id'] = $i;
                // use the id just pasted into
                if (!is_array($importedlist) or empty($importedlist['general'])) {
                    echo '<div class="error"><p>' . sprintf(__('Imported settings for list %s invalid - not saved', 'amr-ical-events-list'), $i) . '</p></div';
                } else {
                    $amr_options['listtypes'][$i] = $importedlist;
                    echo '<div class="updated"><p>' . sprintf(__('List %s will be saved with imported data', 'amr-ical-events-list'), $i) . '</p></div';
                }
            }
        }
    }
    update_option('amr-ical-events-list', $amr_options);
}