예제 #1
0
function calendar_arrived($form_pid)
{
    $Today = date('Y-m-d');
    //Take all recurring events relevent for today.
    $result_event = sqlStatement("SELECT * FROM openemr_postcalendar_events WHERE pc_recurrtype='1' and pc_pid =? and pc_endDate!='0000-00-00' \n\t\tand pc_eventDate < ? and pc_endDate >= ? ", array($form_pid, $Today, $Today));
    if (sqlNumRows($result_event) == 0) {
        $result_event = sqlStatement("SELECT * FROM openemr_postcalendar_events WHERE pc_pid =?\tand pc_eventDate = ?", array($form_pid, $Today));
        if (sqlNumRows($result_event) == 0) {
            echo "<br><br><br>" . htmlspecialchars(xl('Sorry No Appointment is Fixed'), ENT_QUOTES) . ". " . htmlspecialchars(xl('No Encounter could be created'), ENT_QUOTES) . ".";
            die;
        } else {
            $enc = todaysEncounterCheck($form_pid);
            //create encounter
            $zero_enc = 0;
            sqlStatement("UPDATE openemr_postcalendar_events SET pc_apptstatus ='@' WHERE pc_pid =? and pc_eventDate = ?", array($form_pid, $Today));
        }
    } else {
        while ($row_event = sqlFetchArray($result_event)) {
            $pc_eid = $row_event['pc_eid'];
            $pc_eventDate = $row_event['pc_eventDate'];
            $pc_recurrspec_array = unserialize($row_event['pc_recurrspec']);
            while (1) {
                if ($pc_eventDate == $Today) {
                    if (!($exist_eid = check_event_exist($pc_eid))) {
                        update_event($pc_eid);
                    } else {
                        sqlStatement("UPDATE openemr_postcalendar_events SET pc_apptstatus = '@' WHERE pc_eid = ?", array($exist_eid));
                    }
                    $enc = todaysEncounterCheck($form_pid);
                    //create encounter
                    $zero_enc = 0;
                    break;
                } elseif ($pc_eventDate > $Today) {
                    echo "<br><br><br>" . htmlspecialchars(xl('Sorry No Appointment is Fixed'), ENT_QUOTES) . ". " . htmlspecialchars(xl('No Encounter could be created'), ENT_QUOTES) . ".";
                    die;
                    break;
                }
                $pc_eventDate_array = split('-', $pc_eventDate);
                //Find the next day as per the frequency definition.
                $pc_eventDate =& __increment($pc_eventDate_array[2], $pc_eventDate_array[1], $pc_eventDate_array[0], $pc_recurrspec_array['event_repeat_freq'], $pc_recurrspec_array['event_repeat_freq_type']);
            }
        }
    }
    return $enc;
}
function bigbluebutton_update_instance($bigbluebutton)
{
    $bigbluebutton->timemodified = time();
    $bigbluebutton->id = $bigbluebutton->instance;
    if ($returnid = update_record('bigbluebutton', $bigbluebutton)) {
        $event = NULL;
        if ($event->id = get_field('event', 'id', 'modulename', 'bigbluebutton', 'instance', $bigbluebutton->id)) {
            $event->courseid = $bigbluebutton->course;
            $event->name = $bigbluebutton->name;
            $event->meetingname = $bigbluebutton->meetingname;
            $event->meetingid = $bigbluebutton->meetingid;
            $event->attendeepw = $bigbluebutton->attendeepw;
            $event->moderatorpw = $bigbluebutton->moderatorpw;
            $event->autologin = $bigbluebutton->autologin;
            $event->newwindow = $bigbluebutton->newwindow;
            $event->welcomemsg = $bigbluebutton->welcomemsg;
            update_event($event);
        }
    }
    return $returnid;
}
function certificate_update_instance($certificate)
{
    $certificate->timemodified = time();
    $certificate->id = $certificate->instance;
    if ($returnid = update_record('certificate', $certificate)) {
        if ($event->id = get_field('event', 'id', 'modulename', 'certificate', 'instance', $certificate->id)) {
            $event->name = $certificate->name;
            update_event($event);
        } else {
            $event = NULL;
            $event->name = $certificate->name;
            $event->courseid = $certificate->course;
            $event->groupid = 0;
            $event->userid = 0;
            $event->modulename = 'certificate';
            $event->instance = $certificate->id;
            add_event($event);
        }
    } else {
        delete_records('event', 'modulename', 'certificate', 'instance', $certificate->id);
    }
    return $returnid;
}
예제 #4
0
/**
 * Update certificate instance.
 *
 * @param stdClass $certificate
 * @return bool true
 */
function certificate_update_instance($certificate)
{
    global $DB;
    // Update the certificate
    $certificate->timemodified = time();
    $certificate->id = $certificate->instance;
    $DB->update_record('certificate', $certificate);
    // Update the event if it exists, else create
    if ($event = $DB->get_record('event', array('modulename' => 'certificate', 'instance' => $certificate->id))) {
        $event->name = $certificate->name;
        update_event($event);
    } else {
        $event = new stdClass();
        $event->name = $certificate->name;
        $event->description = '';
        $event->courseid = $certificate->course;
        $event->groupid = 0;
        $event->userid = 0;
        $event->modulename = 'certificate';
        $event->instance = $certificate->id;
        add_event($event);
    }
    return true;
}
예제 #5
0
파일: function.php 프로젝트: bketnick/hoop
    $header = array('Authorization' => $_SESSION['token'], 'Content-Type' => 'application/json', 'Accept' => 'application/json');
    $response = $client->fetch($baseApiUrl . '/api/v1/people/' . $details['id'], json_encode($params), 'PUT', $header, 0);
    header('Location: index.php');
}
function update_event($details)
{
    global $client, $baseApiUrl, $baseSiteSlug;
    $params = array('event' => array('name' => $details['name'], 'status' => $details['status'], 'start_time' => $details['start_time'], 'end_time' => $details['end_time']));
    $header = array('Authorization' => $_SESSION['token'], 'Content-Type' => 'application/json', 'Accept' => 'application/json');
    $response = $client->fetch($baseApiUrl . '/api/v1/sites/' . $baseSiteSlug . '/pages/events/' . $details['id'], json_encode($params), 'PUT', $header, 0);
    header('Location: index.php');
}
function delete_person($id)
{
    global $client, $baseApiUrl;
    $response = $client->fetch($baseApiUrl . '/api/v1/people/' . $id, array(), 'DELETE');
    header('Location: index.php');
}
if (isset($_GET['create']) && $_GET['create'] == 'create') {
    create_person($_GET);
} elseif (isset($_GET['update']) && $_GET['update'] == 'update') {
    update_person($_GET);
} elseif (isset($_GET['delete'])) {
    delete_person($_GET['delete']);
} elseif (isset($_GET['updateEvent'])) {
    if (isset($_GET['id'])) {
        update_event($_GET);
    } else {
        create_event($_GET);
    }
}
예제 #6
0
파일: lib.php 프로젝트: e-rasvet/reader
function quiz_refresh_events($courseid = 0)
{
    // This standard function will check all instances of this module
    // and make sure there are up-to-date events created for each of them.
    // If courseid = 0, then every quiz event in the site is checked, else
    // only quiz events belonging to the course specified are checked.
    // This function is used, in its new format, by restore_refresh_events()
    if ($courseid == 0) {
        if (!($quizzes = get_records("quiz"))) {
            return true;
        }
    } else {
        if (!($quizzes = get_records("quiz", "course", $courseid))) {
            return true;
        }
    }
    $moduleid = get_field('modules', 'id', 'name', 'quiz');
    foreach ($quizzes as $quiz) {
        $event = NULL;
        $event2 = NULL;
        $event2old = NULL;
        if ($events = get_records_select('event', "modulename = 'quiz' AND instance = '{$quiz->id}' ORDER BY timestart")) {
            $event = array_shift($events);
            if (!empty($events)) {
                $event2old = array_shift($events);
                if (!empty($events)) {
                    foreach ($events as $badevent) {
                        delete_records('event', 'id', $badevent->id);
                    }
                }
            }
        }
        $event->name = addslashes($quiz->name);
        $event->description = addslashes($quiz->intro);
        $event->courseid = $quiz->course;
        $event->groupid = 0;
        $event->userid = 0;
        $event->modulename = 'quiz';
        $event->instance = $quiz->id;
        $event->visible = instance_is_visible('quiz', $quiz);
        $event->timestart = $quiz->timeopen;
        $event->eventtype = 'open';
        $event->timeduration = $quiz->timeclose - $quiz->timeopen;
        if ($event->timeduration > QUIZ_MAX_EVENT_LENGTH) {
            /// Set up two events
            $event2 = $event;
            $event->name = addslashes($quiz->name) . ' (' . get_string('quizopens', 'quiz') . ')';
            $event->timeduration = 0;
            $event2->name = addslashes($quiz->name) . ' (' . get_string('quizcloses', 'quiz') . ')';
            $event2->timestart = $quiz->timeclose;
            $event2->eventtype = 'close';
            $event2->timeduration = 0;
            if (empty($event2old->id)) {
                unset($event2->id);
                add_event($event2);
            } else {
                $event2->id = $event2old->id;
                update_event($event2);
            }
        } else {
            if (!empty($event2old->id)) {
                delete_event($event2old->id);
            }
        }
        if (empty($event->id)) {
            if (!empty($event->timestart)) {
                add_event($event);
            }
        } else {
            update_event($event);
        }
    }
    return true;
}
예제 #7
0
파일: index.php 프로젝트: nikosv/openeclass
     $agdx->store($id);
     redirect_to_home_page("modules/agenda/index.php?course=$course_code&v=1");
 }
 if (isset($_POST['event_title'])) {
     register_posted_variables(array('startdate' => true, 'event_title' => true, 'content' => true, 'duration' => true));
     $content = purify($content);
     if (isset($_POST['id']) and !empty($_POST['id'])) {  // update event
         $id = $_POST['id'];
         $recursion = null;
         if (!empty($_POST['frequencyperiod']) && intval($_POST['frequencynumber']) > 0 && !empty($_POST['enddate'])) {
             $recursion = array('unit' => $_POST['frequencyperiod'], 'repeat' => $_POST['frequencynumber'], 'end' => $_POST['enddate']);
         }            
         if(isset($_POST['rep']) && $_POST['rep'] == 'yes'){
             $resp = update_recursive_event($id, $event_title, $startdate, $duration, $content, $recursion);
         } else {
             $resp = update_event($id, $event_title, $startdate, $duration, $content, $recursion);
         }
         $agdx->store($id);
     } else { // add new event
         $recursion = null;            
         if (!empty($_POST['frequencyperiod']) && intval($_POST['frequencynumber']) > 0 && !empty($_POST['enddate'])) {
             $recursion = array('unit' => $_POST['frequencyperiod'], 'repeat' => $_POST['frequencynumber'], 'end' => $_POST['enddate']);
         }            
         $ev = add_event($event_title, $content, $startdate, $duration, $recursion);                                   
         foreach($ev['event'] as $id) {
             $agdx->store($id);                
         }
     }
     Session::Messages($langStoredOK, 'alert-success');
     redirect_to_home_page("modules/agenda/index.php?course=$course_code");
 } elseif (isset($_GET['delete']) && $_GET['delete'] == 'yes') {
예제 #8
0
<?php

/**
 * Created by PhpStorm.
 * User: Jason
 * Date: 11/11/2015
 * Time: 6:31 PM
 */
require 'db_cn.inc';
require 'db_access.inc';
//This file contains php code that will be executed after the
//insert operation is done.
require 'update_event_result_ui.inc';
// Main control logic
update_event();
//-------------------------------------------------------------
function update_event()
{
    connect_and_select_db(DB_SERVER, DB_UN, DB_PWD, DB_NAME);
    // Get the bannerid and other data sent by the user from the query
    $eventCode = $_REQUEST['eventCode'];
    $name = mysql_real_escape_string($_POST["eventName"]);
    $startDate = mysql_real_escape_string($_POST["startDate"]);
    $endDate = mysql_real_escape_string($_POST["endDate"]);
    $description = mysql_real_escape_string($_POST["description"]);
    $type = mysql_real_escape_string($_POST["type"]);
    $updateStmt = "update AdEvent\n\tset  AdEvent.Name = '" . $name . "', StartDate = '" . $startDate . "', EndDate = '" . $endDate . "',\n\tDescription = '" . $description . "', AdType = '" . $type . "'" . "WHERE  EventCode = '" . $eventCode . "'";
    $result = execute_SQL_query_with_no_error_report($updateStmt);
    $message = "";
    if (!$result) {
        $message .= "Error in updating Event: " . $eventCode . " in database.<br />" . mysql_error() . "<hr />";
예제 #9
0
function chat_update_chat_times($chatid = 0)
{
    /// Updates chat records so that the next chat time is correct
    $timenow = time();
    if ($chatid) {
        if (!($chats[] = get_record_select("chat", "id = '{$chatid}' AND chattime <= '{$timenow}' AND schedule > '0'"))) {
            return;
        }
    } else {
        if (!($chats = get_records_select("chat", "chattime <= '{$timenow}' AND schedule > '0'"))) {
            return;
        }
    }
    foreach ($chats as $chat) {
        unset($chat->name);
        unset($chat->intro);
        switch ($chat->schedule) {
            case 1:
                // Single event - turn off schedule and disable
                $chat->chattime = 0;
                $chat->schedule = 0;
                break;
            case 2:
                // Repeat daily
                $chat->chattime += 24 * 3600;
                break;
            case 3:
                // Repeat weekly
                $chat->chattime += 7 * 24 * 3600;
                break;
        }
        update_record("chat", $chat);
        $event = NULL;
        // Update calendar too
        if ($event->id = get_field('event', 'id', 'modulename', 'chat', 'instance', $chat->id)) {
            $event->timestart = $chat->chattime;
            update_event($event);
        }
    }
}
예제 #10
0
function workshop_update_instance($workshop)
{
    // Given an object containing all the necessary data,
    // (defined by the form in mod.html) this function
    // will update an existing instance with new data.
    global $CFG;
    $workshop->timemodified = time();
    $workshop->submissionstart = make_timestamp($workshop->submissionstartyear, $workshop->submissionstartmonth, $workshop->submissionstartday, $workshop->submissionstarthour, $workshop->submissionstartminute);
    $workshop->assessmentstart = make_timestamp($workshop->assessmentstartyear, $workshop->assessmentstartmonth, $workshop->assessmentstartday, $workshop->assessmentstarthour, $workshop->assessmentstartminute);
    $workshop->submissionend = make_timestamp($workshop->submissionendyear, $workshop->submissionendmonth, $workshop->submissionendday, $workshop->submissionendhour, $workshop->submissionendminute);
    $workshop->assessmentend = make_timestamp($workshop->assessmentendyear, $workshop->assessmentendmonth, $workshop->assessmentendday, $workshop->assessmentendhour, $workshop->assessmentendminute);
    $workshop->releasegrades = make_timestamp($workshop->releaseyear, $workshop->releasemonth, $workshop->releaseday, $workshop->releasehour, $workshop->releaseminute);
    if (!workshop_check_dates($workshop)) {
        return get_string('invaliddates', 'workshop');
    }
    // set the workshop's type
    $wtype = 0;
    // 3 phases, no grading grades
    if ($workshop->includeself or $workshop->ntassessments) {
        $wtype = 1;
    }
    // 3 phases with grading grades
    if ($workshop->nsassessments) {
        $wtype = 2;
    }
    // 5 phases with grading grades
    $workshop->wtype = $wtype;
    // encode password if necessary
    if (!empty($workshop->password)) {
        $workshop->password = md5($workshop->password);
    } else {
        unset($workshop->password);
    }
    $workshop->id = $workshop->instance;
    if ($returnid = update_record("workshop", $workshop)) {
        $dates = array('submissionstart' => $workshop->submissionstart, 'submissionend' => $workshop->submissionend, 'assessmentstart' => $workshop->assessmentstart, 'assessmentend' => $workshop->assessmentend);
        $moduleid = get_field('modules', 'id', 'name', 'workshop');
        foreach ($dates as $type => $date) {
            if ($event = get_record('event', 'modulename', 'workshop', 'instance', $workshop->id, 'eventtype', $type)) {
                $event->name = get_string($type . 'event', 'workshop', $workshop->name);
                $event->description = $workshop->description;
                $event->eventtype = $type;
                $event->timestart = $date;
                update_event($event);
            } else {
                if ($date) {
                    $event = NULL;
                    $event->name = get_string($type . 'event', 'workshop', $workshop->name);
                    $event->description = $workshop->description;
                    $event->courseid = $workshop->course;
                    $event->groupid = 0;
                    $event->userid = 0;
                    $event->modulename = 'workshop';
                    $event->instance = $workshop->instance;
                    $event->eventtype = $type;
                    $event->timestart = $date;
                    $event->timeduration = 0;
                    $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $workshop->id);
                    add_event($event);
                }
            }
        }
    }
    if (time() > $workshop->assessmentstart) {
        // regrade all the submissions...
        set_field("workshop_submissions", "nassessments", 0, "workshopid", $workshop->id);
        workshop_grade_assessments($workshop);
    }
    return $returnid;
}
예제 #11
0
파일: lib.php 프로젝트: ajv/Offline-Caching
 /**
  * Updates a new assignment activity
  *
  * Given an object containing all the necessary data,
  * (defined by the form in mod_form.php) this function
  * will update the assignment instance and return the id number
  * The due date is updated in the calendar
  * This is common to all assignment types.
  *
  * @global object
  * @global object
  * @param object $assignment The data from the form on mod_form.php
  * @return int The assignment id
  */
 function update_instance($assignment)
 {
     global $COURSE, $DB;
     $assignment->timemodified = time();
     $assignment->id = $assignment->instance;
     $assignment->courseid = $assignment->course;
     $DB->update_record('assignment', $assignment);
     if ($assignment->timedue) {
         $event = new object();
         if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'assignment', 'instance' => $assignment->id))) {
             $event->name = $assignment->name;
             $event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
             $event->timestart = $assignment->timedue;
             update_event($event);
         } else {
             $event = new object();
             $event->name = $assignment->name;
             $event->description = format_module_intro('assignment', $assignment, $assignment->coursemodule);
             $event->courseid = $assignment->course;
             $event->groupid = 0;
             $event->userid = 0;
             $event->modulename = 'assignment';
             $event->instance = $assignment->id;
             $event->eventtype = 'due';
             $event->timestart = $assignment->timedue;
             $event->timeduration = 0;
             add_event($event);
         }
     } else {
         $DB->delete_records('event', array('modulename' => 'assignment', 'instance' => $assignment->id));
     }
     // get existing grade item
     assignment_grade_item_update($assignment);
     return true;
 }
예제 #12
0
function wwassignment_refresh_events($courseid = 0)
{
    error_log('wwassignment_refresh_events called');
    if ($courseid == 0) {
        if (!($wwassignment = get_records('wwassignment'))) {
            return true;
        }
    } else {
        if (!($wwassignment = get_records('wwassignment', 'course', $courseid))) {
            return true;
        }
    }
    $moduleid = get_field('modules', 'id', 'name', 'wwassignment');
    foreach ($wwassignment as $wwassignment) {
        $event = NULL;
        $event->name = addslashes($wwassignment->name);
        $event->description = addslashes($wwassignment->description);
        $event->timestart = $wwassignment->timedue;
        if ($event->id = get_field('event', 'id', 'modulename', 'wwassignment', 'instance', $wwassignment->id)) {
            update_event($event);
        } else {
            $event->courseid = $wwassignment->course;
            $event->groupid = 0;
            $event->userid = 0;
            $event->modulename = 'wwassignment';
            $event->instance = $wwassignment->id;
            $event->eventtype = 'due';
            $event->timeduration = 0;
            $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $wwassignment->id);
            add_event($event);
        }
    }
    return true;
}
예제 #13
0
파일: index.php 프로젝트: hhgr/uksoccer
function event_espresso_manage_events()
{
    global $wpdb, $org_options;
    ?>
	<div id="configure_organization_form" class="wrap meta-box-sortables ui-sortable">
		<div id="event_reg_theme" class="wrap">
			<div id="icon-options-event" class="icon32"></div>
			<h2>
				<?php 
    if ($_REQUEST['page'] == 'events' && isset($_REQUEST['event_admin_reports'])) {
        switch ($_REQUEST['event_admin_reports']) {
            case 'charts':
                _e('Attendee Reports', 'event_espresso');
                break;
            case 'event_list_attendees':
            case 'resend_email':
            case 'list_attendee_payments':
                _e('Attendee Reports', 'event_espresso');
                if (!empty($_REQUEST['event_id']) && $_REQUEST['event_admin_reports'] != 'add_new_attendee') {
                    echo '<a href="admin.php?page=events&amp;event_admin_reports=add_new_attendee&amp;event_id=' . $_REQUEST['event_id'] . '" class="button add-new-h2" style="margin-left: 20px;">' . __('Add New Attendee', 'event_espresso') . '</a>';
                }
                break;
            case 'edit_attendee_record':
                _e('Edit Attendee Data', 'event_espresso');
                break;
            case 'enter_attendee_payments':
                _e('Edit Attendee Payment Record', 'event_espresso');
                break;
            case 'add_new_attendee':
                _e('Add New Attendee', 'event_espresso');
                break;
            case 'event_newsletter':
                _e('Email Event Attendees', 'event_espresso');
                break;
        }
    } else {
        _e('Event Overview', 'event_espresso');
        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'edit' || $_REQUEST['action'] == 'add_new_event')) {
        } else {
            echo '<a href="admin.php?page=events&amp;action=add_new_event" class="button add-new-h2" style="margin-left: 20px;">' . __('Add New Event', 'event_espresso') . '</a>';
        }
    }
    ?>
			</h2>
			<?php 
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'copy_event') {
        require_once "copy_event.php";
        copy_event();
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
        event_espresso_delete_event();
    }
    //Delete recurrence series of events
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_recurrence_series') {
        $r = $wpdb->get_results("SELECT id FROM " . EVENTS_DETAIL_TABLE . " ed WHERE recurrence_id = " . $_REQUEST['recurrence_id']);
        if ($wpdb->num_rows > 0) {
            foreach ($r as $row) {
                event_espresso_delete_event($row->id);
            }
        }
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'csv_import') {
        require_once 'csv_import.php';
        csv_import();
    }
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
        require_once "insert_event.php";
        add_event_to_db();
    }
    //Update the event
    if (isset($_REQUEST['edit_action']) && $_REQUEST['edit_action'] == 'update') {
        require_once "update_event.php";
        update_event();
    }
    //If we need to add or edit a new event then we show the add or edit forms
    if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'add_new_event' || $_REQUEST['action'] == 'edit')) {
        ?>
				<form id="espresso_event_editor" name="form" method="post" action="<?php 
        echo $_SERVER["REQUEST_URI"];
        ?>
">
					<?php 
        if ($_REQUEST['action'] == 'edit') {
            //show the edit form
            require_once "edit_event.php";
            edit_event($_REQUEST['event_id']);
        } else {
            //Show the add new event form
            require_once "add_new_event.php";
            add_new_event();
        }
        ?>
					<br class="clear" />
				</form>
				<!-- /event_reg_theme -->
				<?php 
    } else {
        //If we are not adding or editing an event then show the list of events
        if (isset($_REQUEST['event_admin_reports'])) {
            switch ($_REQUEST['event_admin_reports']) {
                case 'charts':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/charts.php";
                    espresso_charts();
                    break;
                case 'list_attendee_payments':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    event_list_attendees();
                    break;
                case 'event_list_attendees':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    event_list_attendees();
                    break;
                case 'edit_attendee_record':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/edit_attendee_record.php";
                    edit_attendee_record();
                    break;
                case 'enter_attendee_payments':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/enter_attendee_payments.php";
                    enter_attendee_payments();
                    break;
                case 'add_new_attendee':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/event_list_attendees.php";
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-reports/add_new_attendee.php";
                    add_new_attendee($_REQUEST['event_id']);
                    break;
                case 'event_newsletter':
                    if (file_exists(EVENT_ESPRESSO_INCLUDES_DIR . "admin-files/event_newsletter.php")) {
                        require_once EVENT_ESPRESSO_INCLUDES_DIR . "admin-files/event_newsletter.php";
                        event_newsletter($_REQUEST['event_id']);
                    } else {
                        require_once "event_newsletter.php";
                    }
                    break;
                case 'resend_email':
                    require_once EVENT_ESPRESSO_INCLUDES_DIR . "/admin-reports/event_list_attendees.php";
                    echo '<div id="message" class="updated fade"><p><strong>Resending email to attendee.</strong></p></div>';
                    event_espresso_email_confirmations(array('registration_id' => $_REQUEST['registration_id'], 'send_admin_email' => 'false', 'send_attendee_email' => 'true'));
                    event_list_attendees();
                    break;
                default:
                    event_espresso_edit_list();
                    break;
            }
        } else {
            event_espresso_edit_list();
        }
    }
    //Do not remove anything below this line. These are the color box popups.
    ?>
</div>
	</div>
	<div id="email_manager_info" style="display:none">
		<h2><?php 
    _e('Pre-existing Emails', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('These emails will override the custom email if a pre-existing email is selected. You must select "Yes" in the "Send custom confirmation emails for this event?" above.', 'event_espresso');
    ?>
</p>
	</div>
	<div id="coupon_code_info" style="display:none">
		<h2><?php 
    _e('Coupon/Promo Code', 'event_espresso');
    ?>
</h2><p><?php 
    _e('This is used to apply discounts to events.', 'event_espresso');
    ?>
</p><p><?php 
    _e('A coupon or promo code could can be anything you want. For example: Say you have an event that costs', 'event_espresso');
    ?>
 <?php 
    echo $org_options['currency_symbol'];
    ?>
200. <?php 
    _e('If you supplied a promo like "PROMO50" and entered 50.00 into the "Discount w/Promo Code" field your event will be discounted', 'event_espresso');
    ?>
  <?php 
    echo $org_options['currency_symbol'];
    ?>
50.00, <?php 
    _e('Bringing the cost of the event to', 'event_espresso');
    ?>
 <?php 
    echo $org_options['currency_symbol'];
    ?>
150. </p>
			<p><?php 
    _e("Note: Promo Codes which are marked to 'apply to all events', although not explicitly enumerated, can also be used for this event, provided it allows promo codes.", "event_espresso");
    ?>
</p>
	</div>
	<div id="unique_id_info" style="display:none">
		<h2><?php 
    _e('Event Identifier', 'event_espresso');
    ?>
</h2><p><?php 
    _e('This should be a unique identifier for the event. Example: "Event1" (without quotes.)</p><p>The unique ID can also be used in individual pages using the', 'event_espresso');
    ?>
 [SINGLEEVENT single_event_id="<?php 
    _e('Unique Event ID', 'event_espresso');
    ?>
"] <?php 
    _e('shortcode', 'event_espresso');
    ?>
.</p>
	</div>
	<div id="secondary_info" style="display:none">
		<h2><?php 
    _e('Waitlist Events', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('These types of events can be used as a overflow or waiting list events.', 'event_espresso');
    ?>
</p>
		<p><?php 
    _e('If an event is set up as an "Waitlist Event," it can be set to not appear in your event listings template. You may need to customize your event_listing.php file to make this work. For more information, please', 'event_espresso');
    ?>
 <a href="http://eventespresso.com/forums/?p=512" target="_blank"><?php 
    _e('visit the forums', 'event_espresso');
    ?>
</a>.</p>
	</div>
	<div id="external_URL_info" style="display:none">
		<h2><?php 
    _e('Off-site Registration Page', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('If an off-site registration page is entered, it will override your registration page and send attendees to the URL that is entered.', 'event_espresso');
    ?>
</p>
	</div>
	<div id="alt_email_info" style="display:none">
		<h2><?php 
    _e('Alternate Email Address', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('If an alternate email address is entered. Admin email notifications wil be sent to this address instead.', 'event_espresso');
    ?>
</p>
	</div>
	<div id="status_types_info" style="display:none;">
		<h2><?php 
    _e('Event Status Types', 'event_espresso');
    ?>
</h2>
		<ul>
			<li><strong><?php 
    _e('Public', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This type if event will appear in the event listings. It is a live event (not deleted, ongoing or secondary.)', 'event_espresso');
    ?>
</li>
			<li><strong><?php 
    _e('Waitlist', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This type of event can be hidden and used as a waiting list for a primary event. Template customizations may be required. For more information, please', 'event_espresso');
    ?>
 <a href="http://eventespresso.com/forums/?p=512" target="_blank"><?php 
    _e('visit the forums', 'event_espresso');
    ?>
</a></li>
			<li><strong><?php 
    _e('Ongoing', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This type of an event can be set to appear in your event listings and display a registration page. Template customizations are required. For more information, please', 'event_espresso');
    ?>
 <a href="http://eventespresso.com/forums/?p=518" target="_blank"><?php 
    _e('visit the forums', 'event_espresso');
    ?>
</a></li>
			<li><strong><?php 
    _e('Deleted', 'event_espresso');
    ?>
</strong><br /><?php 
    _e('This is event type will not appear in the event listings and will not dispaly a registrations page. Deleted events can still be accessed in the', 'event_espresso');
    ?>
 <a href="admin.php?page=events"><?php 
    _e('Attendee Reports', 'event_espresso');
    ?>
</a> <?php 
    _e('page', 'event_espresso');
    ?>
.</li>
		</ul>
	</div>
	<?php 
    echo event_espresso_custom_email_info();
}
예제 #14
0
파일: lib.php 프로젝트: kai707/ITSA-backup
function dimdim_update_dimdim_times($dimdimid = 0)
{
    /// Updates dimdim records so that the next dimdim time is correct
    $timenow = time();
    if ($dimdimid) {
        if (!($dimdims[] = get_record_select('dimdim', "id = '{$dimdimid}' AND dimdimtime <= '{$timenow}' AND schedule > '0'"))) {
            return;
        }
    } else {
        if (!($dimdims = get_records_select('dimdim', "dimdimtime <= '{$timenow}' AND schedule > '0'"))) {
            return;
        }
    }
    foreach ($dimdims as $dimdim) {
        unset($dimdim->name);
        unset($dimdim->intro);
        switch ($dimdim->schedule) {
            case 1:
                // Single event - turn off schedule and disable
                $dimdim->dimdimtime = 0;
                $dimdim->schedule = 0;
                break;
            case 2:
                // Repeat daily
                $dimdim->dimdimtime += 24 * 3600;
                break;
            case 3:
                // Repeat weekly
                $dimdim->dimdimtime += 7 * 24 * 3600;
                break;
        }
        update_record('dimdim', $dimdim);
        $event = NULL;
        // Update calendar too
        if ($event->id = get_field('event', 'id', 'modulename', 'dimdim', 'instance', $dimdim->id)) {
            $event->timestart = $dimdim->dimdimtime;
            update_event($event);
        }
    }
}
예제 #15
0
$calself = basename($PHP_SELF);
displayPageHeader($color);
//load calendar menu
calendar_header();
echo html_tag('tr', '', '', $color[0]) . html_tag('td', '', 'left') . html_tag('table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"') . html_tag('tr') . html_tag('td', date_intl(_("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"');
if (!isset($updated)) {
    //get changes to event
    readcalendardata();
    update_event_form();
} else {
    if (!isset($confirmed)) {
        //confirm changes
        readcalendardata();
        confirm_update();
    } else {
        update_event("{$month}{$day}{$year}", "{$hour}{$minute}");
        echo html_tag('tr', html_tag('td', _("Event updated!"), 'left')) . "\n";
        echo html_tag('tr', html_tag('td', "<a href=\"day.php?year={$year}&amp;month={$month}&amp;day={$day}\">" . _("Day View") . "</a>", 'left')) . "\n";
        $fixdate = date('mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
        //if event has been moved to different year then act accordingly
        if ($year == $event_year) {
            $calendardata["{$fixdate}"]["{$event_hour}{$event_minute}"] = array('length' => $event_length, 'priority' => $event_priority, 'title' => $event_title, 'message' => $event_text);
            writecalendardata();
        } else {
            writecalendardata();
            $year = $event_year;
            $calendardata = array();
            readcalendardata();
            $calendardata["{$fixdate}"]["{$event_hour}{$event_minute}"] = array('length' => $event_length, 'priority' => $event_priority, 'title' => $event_title, 'message' => $event_text);
            writecalendardata();
        }
예제 #16
0
function update_event($recurrence_arr = array())
{
    //print_r($_REQUEST);
    global $wpdb, $org_options, $current_user, $espresso_premium;
    $wpdb->show_errors();
    /*
     * Begin Recurrence handling
     *
     * Will clean up in V 1.2.0
     *
     */
    if (get_option('event_espresso_re_active') == 1) {
        require_once EVENT_ESPRESSO_RECURRENCE_FULL_PATH . "functions/re_functions.php";
        if ($_POST['recurrence_id'] > 0) {
            /*
             * If the array is empty, then find the recurring dates
             */
            if (count($recurrence_arr) == 0) {
                // Prepare the parameters array for use with various RE functions
                $re_params = array('start_date' => $_POST['recurrence_start_date'], 'event_end_date' => $_POST['recurrence_event_end_date'], 'end_date' => $_POST['recurrence_end_date'], 'registration_start' => $_POST['recurrence_regis_start_date'], 'registration_end' => $_POST['recurrence_regis_end_date'], 'frequency' => $_POST['recurrence_frequency'], 'interval' => $_POST['recurrence_interval'], 'recurrence_type' => $_POST['recurrence_type'], 'weekdays' => $_POST['recurrence_weekday'], 'repeat_by' => $_POST['recurrence_repeat_by'], 'recurrence_regis_date_increment' => $_POST['recurrence_regis_date_increment'], 'recurrence_manual_dates' => $_POST['recurrence_manual_dates'], 'recurrence_manual_end_dates' => $_POST['recurrence_manual_end_dates'], 'recurrence_visibility' => $_POST['recurrence_visibility'], 'recurrence_id' => $_POST['recurrence_id']);
                //$re_params['adding_to_db'] = 'Y';
                //Has the form been modified
                $recurrence_form_modified = recurrence_form_modified($re_params);
                //echo ($recurrence_form_modified) ? "Yes" : 'No';
                if ($_POST['recurrence_apply_changes_to'] == 2) {
                    //Update all events in the series based on recurrence id
                    $recurrence_dates = $_POST['recurrence_type'] == 'm' ? find_recurrence_manual_dates($re_params) : find_recurrence_dates($re_params);
                    //$DEL_SQL = 'UPDATE ' . EVENTS_DETAIL_TABLE . " SET event_status = 'D' WHERE start_date NOT IN (" . $delete_in . ") AND recurrence_id = " . $wpdb->escape($_POST['recurrence_id']);
                    $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE recurrence_id = %d AND NOT event_status = 'D'";
                } else {
                    //Update this and upcoming events based on recurrence id and start_date >=start_date
                    $re_params['start_date'] = $_POST['start_date'];
                    $recurrence_dates = find_recurrence_dates($re_params);
                    //$DEL_SQL = 'UPDATE ' . EVENTS_DETAIL_TABLE . " SET event_status = 'D' WHERE start_date >='" . $wpdb->escape($_POST['start_date']) . "' AND start_date NOT IN (" . $delete_in . ") AND recurrence_id = " . $_POST['recurrence_id'];
                    $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE start_date >='" . $wpdb->escape($_POST['start_date']) . "' AND recurrence_id = %d and NOT event_status = 'D' ";
                }
                //Recurrence Form modified and changes need to apply to all
                if ($recurrence_form_modified && $_POST['recurrence_apply_changes_to'] > 1) {
                    //Update the recurrence table record with the new RE selections
                    update_recurrence_master_record();
                    /*
                     * Delete the records that don't belong in the formula
                     */
                    if (count($recurrence_dates) > 0) {
                        $delete_in = '';
                        foreach ($recurrence_dates as $k => $v) {
                            $delete_in .= "'" . $k . "',";
                        }
                        $delete_in = substr($delete_in, 0, -1);
                    }
                    if ($_POST['recurrence_apply_changes_to'] == 2) {
                        //Update all events in the series based on recurrence id
                        //$DEL_SQL = 'UPDATE ' . EVENTS_DETAIL_TABLE . " SET event_status = 'D' WHERE start_date NOT IN (" . $delete_in . ") AND recurrence_id = " . $_POST['recurrence_id'];
                        $DEL_SQL = 'DELETE EDT, EAT FROM ' . EVENTS_DETAIL_TABLE . " EDT\n                            LEFT JOIN " . EVENTS_ATTENDEE_TABLE . " EAT\n                                ON EDT.id = EAT.event_id\n                            WHERE EAT.id IS NULL\n                            AND EDT.start_date NOT IN (" . $delete_in . ")\n                            AND recurrence_id = " . $_POST['recurrence_id'];
                        $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE recurrence_id = %d and NOT event_status = 'D' ORDER BY start_date";
                    } else {
                        //Update this and upcoming events based on recurrence id and start_date >=start_date
                        //$DEL_SQL = 'UPDATE ' . EVENTS_DETAIL_TABLE . " SET event_status = 'D' WHERE start_date >='" . $wpdb->escape($_POST['start_date']) . "' AND start_date NOT IN (" . $delete_in . ") AND recurrence_id = " . $_POST['recurrence_id'];
                        $DEL_SQL = 'DELETE EDT, EAT FROM ' . EVENTS_DETAIL_TABLE . " EDT\n                            LEFT JOIN " . EVENTS_ATTENDEE_TABLE . " EAT\n                                ON EDT.id = EAT.event_id\n                            WHERE EAT.id IS NULL\n                            AND EDT.start_date >='" . $wpdb->escape($_POST['start_date']) . "'\n                            AND start_date NOT IN (" . $delete_in . ")\n                            AND recurrence_id = " . $_POST['recurrence_id'];
                        $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE start_date >='" . $wpdb->escape($_POST['start_date']) . "' AND recurrence_id = %d AND NOT event_status = 'D'  ORDER BY start_date";
                    }
                    if ($delete_in != '') {
                        $wpdb->query($DEL_SQL);
                    }
                    /*
                     * Add the new records based on the new formula
                     * The $recurrence_dates array will contain the new dates
                     */
                    if (!function_exists('add_event_to_db')) {
                        require_once 'insert_event.php';
                    }
                    foreach ($recurrence_dates as $k => $v) {
                        $result = $wpdb->get_row($wpdb->prepare("SELECT ID FROM " . EVENTS_DETAIL_TABLE . " WHERE recurrence_id = %d and start_date = %s and NOT event_status = 'D'", array($_POST['recurrence_id'], $k)));
                        if ($wpdb->num_rows == 0) {
                            add_event_to_db(array('recurrence_id' => $_POST['recurrence_id'], 'recurrence_start_date' => $v['start_date'], 'recurrence_event_end_date' => $v['end_date'], 'recurrence_end_date' => $v['start_date'], 'registration_start' => $v['registration_start'], 'registration_end' => $v['registration_end']));
                        } else {
                        }
                    }
                    /*
                     * Find all the event ids in the series and feed into the $recurrence_dates array
                     * This array will be used at the end of this document to invoke the recursion of update_event function so all the events in the series
                     * can be updated with the information.
                     */
                }
                $result = $wpdb->get_results($wpdb->prepare($UPDATE_SQL, array($_POST['recurrence_id'])));
                foreach ($result as $row) {
                    if ($row->start_date != '') {
                        $recurrence_dates[$row->start_date]['event_id'] = $row->id;
                        $recurrence_dates[$row->start_date]['event_identifier'] = $row->event_identifier;
                    }
                }
            }
        }
    }
    //  echo_f('rd',$recurrence_dates);
    if (defined('EVENT_ESPRESSO_RECURRENCE_MODULE_ACTIVE') && !empty($_POST['recurrence']) && $_POST['recurrence'] == 'Y' && count($recurrence_arr) == 0 && $_POST['recurrence_apply_changes_to'] > 1) {
        //skip the first update
    } else {
        $event_mata = array();
        //will be used to hold event meta data
        $event_id = array_key_exists('event_id', $recurrence_arr) ? $recurrence_arr['event_id'] : $_REQUEST['event_id'];
        $event_name = $_REQUEST['event'];
        //$event_identifier=array_key_exists('event_identifier', $recurrence_arr)?$recurrence_arr['event_identifier']:($_REQUEST['event_identifier'] == '') ? $event_identifier = sanitize_title_with_dashes($event_name.'-'.rand()) : $event_identifier = sanitize_title_with_dashes($_REQUEST['event_identifier']);
        $event_desc = $_REQUEST['event_desc'];
        $display_desc = $_REQUEST['display_desc'];
        $display_reg_form = $_REQUEST['display_reg_form'];
        $reg_limit = $_REQUEST['reg_limit'];
        $allow_multiple = $_REQUEST['allow_multiple'];
        $overflow_event_id = empty($_REQUEST['overflow_event_id']) ? '0' : $_REQUEST['overflow_event_id'];
        $allow_overflow = empty($_REQUEST['allow_overflow']) ? 'N' : $_REQUEST['allow_overflow'];
        $additional_limit = $_REQUEST['additional_limit'];
        //$member_only=$_REQUEST['member_only'];
        $member_only = empty($_REQUEST['member_only']) ? 'N' : $_REQUEST['member_only'];
        $is_active = $_REQUEST['is_active'];
        $event_status = $_REQUEST['event_status'];
        $address = !empty($_REQUEST['address']) ? esc_html($_REQUEST['address']) : '';
        $address2 = !empty($_REQUEST['address2']) ? esc_html($_REQUEST['address2']) : '';
        $city = !empty($_REQUEST['city']) ? esc_html($_REQUEST['city']) : '';
        $state = !empty($_REQUEST['state']) ? esc_html($_REQUEST['state']) : '';
        $zip = !empty($_REQUEST['zip']) ? esc_html($_REQUEST['zip']) : '';
        $country = !empty($_REQUEST['country']) ? esc_html($_REQUEST['country']) : '';
        $phone = !empty($_REQUEST['phone']) ? esc_html($_REQUEST['phone']) : '';
        $externalURL = !empty($_REQUEST['externalURL']) ? esc_html($_REQUEST['externalURL']) : '';
        //$event_location = $address . ' ' . $city . ', ' . $state . ' ' . $zip;
        $event_location = ($address != '' ? $address . ' ' : '') . ($city != '' ? '<br />' . $city : '') . ($state != '' ? ', ' . $state : '') . ($zip != '' ? '<br />' . $zip : '') . ($country != '' ? '<br />' . $country : '');
        //Get the first instance of the start and end times
        $start_time = $_REQUEST['start_time'][0];
        $end_time = $_REQUEST['end_time'][0];
        // Add registration times
        $registration_startT = event_date_display($_REQUEST['registration_startT'], 'H:i');
        $registration_endT = event_date_display($_REQUEST['registration_endT'], 'H:i');
        //Add timezone
        $timezone_string = empty($_REQUEST['timezone_string']) ? '' : $_REQUEST['timezone_string'];
        //Early discounts
        $early_disc = $_REQUEST['early_disc'];
        $early_disc_date = $_REQUEST['early_disc_date'];
        $early_disc_percentage = $_REQUEST['early_disc_percentage'];
        $conf_mail = $_REQUEST['conf_mail'];
        $use_coupon_code = $_REQUEST['use_coupon_code'];
        $alt_email = $_REQUEST['alt_email'];
        $send_mail = $_REQUEST['send_mail'];
        $email_id = empty($_REQUEST['email_name']) ? '' : $_REQUEST['email_name'];
        $event_category = serialize(empty($_REQUEST['event_category']) ? '' : $_REQUEST['event_category']);
        $event_discount = serialize(empty($_REQUEST['event_discount']) ? '' : $_REQUEST['event_discount']);
        $registration_start = array_key_exists('registration_start', $recurrence_arr) ? $recurrence_arr['registration_start'] : $_REQUEST['registration_start'];
        $registration_end = array_key_exists('registration_end', $recurrence_arr) ? $recurrence_arr['registration_end'] : $_REQUEST['registration_end'];
        $start_date = array_key_exists('recurrence_start_date', $recurrence_arr) ? $recurrence_arr['recurrence_start_date'] : ($_REQUEST['start_date'] == '' ? $_REQUEST['recurrence_start_date'] : $_REQUEST['start_date']);
        $end_date = array_key_exists('recurrence_event_end_date', $recurrence_arr) ? $recurrence_arr['recurrence_event_end_date'] : ($_REQUEST['end_date'] == '' ? $_REQUEST['recurrence_start_date'] : $_REQUEST['end_date']);
        $visible_on = array_key_exists('visible_on', $recurrence_arr) ? $recurrence_arr['visible_on'] : empty($_REQUEST['visible_on']) ? '' : $_REQUEST['visible_on'];
        //Venue Information
        $venue_title = isset($_REQUEST['venue_title']) ? $_REQUEST['venue_title'] : '';
        $venue_url = isset($_REQUEST['venue_url']) ? $_REQUEST['venue_url'] : '';
        $venue_phone = isset($_REQUEST['venue_phone']) ? $_REQUEST['venue_phone'] : '';
        $venue_image = isset($_REQUEST['venue_image']) ? $_REQUEST['venue_image'] : '';
        //Virtual location
        $virtual_url = isset($_REQUEST['virtual_url']) ? $_REQUEST['virtual_url'] : '';
        $virtual_phone = isset($_REQUEST['virtual_phone']) ? $_REQUEST['virtual_phone'] : '';
        if (isset($reg_limit) && $reg_limit == '') {
            $reg_limit = 999999;
        }
        $question_groups = serialize($_REQUEST['question_groups']);
        $add_attendee_question_groups = serialize(empty($_REQUEST['add_attendee_question_groups']) ? '' : $_REQUEST['add_attendee_question_groups']);
        $event_mata['default_payment_status'] = $_REQUEST['default_payment_status'];
        $event_mata['venue_id'] = empty($_REQUEST['venue_id']) ? '' : $_REQUEST['venue_id'][0];
        $event_mata['additional_attendee_reg_info'] = $_REQUEST['additional_attendee_reg_info'];
        $event_mata['add_attendee_question_groups'] = empty($_REQUEST['add_attendee_question_groups']) ? '' : $_REQUEST['add_attendee_question_groups'];
        $event_mata['date_submitted'] = $_REQUEST['date_submitted'];
        /*
         * Added for seating chart addon
         */
        if (isset($_REQUEST['seating_chart_id'])) {
            $cls_seating_chart = new seating_chart();
            $seating_chart_result = $cls_seating_chart->associate_event_seating_chart($_REQUEST['seating_chart_id'], $event_id);
            $tmp_seating_chart_id = $_REQUEST['seating_chart_id'];
            if ($tmp_seating_chart_id > 0) {
                if ($seating_chart_result === false) {
                    $tmp_seating_chart_row = $wpdb->get_row("select seating_chart_id from " . EVENTS_SEATING_CHART_EVENT_TABLE . " where event_id = {$event_id}");
                    if ($tmp_seating_chart_row !== NULL) {
                        $tmp_seating_chart_id = $tmp_seating_chart_row->seating_chart_id;
                    } else {
                        $tmp_seating_chart_id = 0;
                    }
                }
                if ($_REQUEST['allow_multiple'] == 'Y' && isset($_REQUEST['seating_chart_id']) && $tmp_seating_chart_id > 0) {
                    $event_mata['additional_attendee_reg_info'] = 3;
                }
            }
        }
        /*
         * End
         */
        if ($_REQUEST['emeta'] != '') {
            foreach ($_REQUEST['emeta'] as $k => $v) {
                $event_mata[$v] = $_REQUEST['emetad'][$k];
            }
        }
        $event_mata = serialize($event_mata);
        ############ Added by wp-developers ######################
        $require_pre_approval = 0;
        if (isset($_REQUEST['require_pre_approval'])) {
            $require_pre_approval = $_REQUEST['require_pre_approval'];
        }
        ################# END #################
        //When adding colums to the following arrays, be sure both arrays have equal values.
        $sql = array('event_name' => $event_name, 'event_desc' => $event_desc, 'display_desc' => $display_desc, 'display_reg_form' => $display_reg_form, 'address' => $address, 'address2' => $address2, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country, 'phone' => $phone, 'virtual_url' => $virtual_url, 'virtual_phone' => $virtual_phone, 'venue_title' => $venue_title, 'venue_url' => $venue_url, 'venue_phone' => $venue_phone, 'venue_image' => $venue_image, 'registration_start' => $registration_start, 'registration_end' => $registration_end, 'start_date' => $start_date, 'end_date' => $end_date, 'allow_multiple' => $allow_multiple, 'send_mail' => $send_mail, 'is_active' => $is_active, 'event_status' => $event_status, 'conf_mail' => $conf_mail, 'use_coupon_code' => $use_coupon_code, 'member_only' => $member_only, 'externalURL' => $externalURL, 'early_disc' => $early_disc, 'early_disc_date' => $early_disc_date, 'early_disc_percentage' => $early_disc_percentage, 'alt_email' => $alt_email, 'question_groups' => $question_groups, 'allow_overflow' => $allow_overflow, 'overflow_event_id' => $overflow_event_id, 'additional_limit' => $additional_limit, 'reg_limit' => $reg_limit, 'email_id' => $email_id, 'registration_startT' => $registration_startT, 'registration_endT' => $registration_endT, 'event_meta' => $event_mata, 'require_pre_approval' => $require_pre_approval, 'timezone_string' => $timezone_string);
        $sql_data = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s');
        $update_id = array('id' => $event_id);
        /* echo 'Debug: <br />';
           print_r($sql);
           echo '<br />';
           print 'Number of vars: ' . count ($sql);
           echo '<br />';
           print 'Number of cols: ' . count($sql_data); */
        if (function_exists('event_espresso_add_event_to_db_groupon')) {
            $sql = event_espresso_add_event_to_db_groupon($sql, $_REQUEST['use_groupon_code']);
            ///print count ($sql);
            $sql_data = array_merge((array) $sql_data, (array) '%s');
            //print count($sql_data);
            $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
            /* echo 'Debug: <br />';
               print 'Number of vars: ' . count ($sql);
               echo '<br />';
               print 'Number of cols: ' . count($sql_data); */
        } else {
            $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
            /* echo 'Debug: <br />';
               print 'Number of vars: ' . count ($sql);
               echo '<br />';
               print 'Number of cols: ' . count($sql_data); */
        }
        //print $wpdb->print_error();
        $del_cats = "DELETE FROM " . EVENTS_CATEGORY_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($del_cats);
        if (!empty($_REQUEST['event_category'])) {
            foreach ($_REQUEST['event_category'] as $k => $v) {
                if ($v != '') {
                    $sql_cat = "INSERT INTO " . EVENTS_CATEGORY_REL_TABLE . " (event_id, cat_id) VALUES ('" . $event_id . "', '" . $v . "')";
                    //echo "$sql_cat <br>";
                    $wpdb->query($sql_cat);
                }
            }
        }
        $del_ppl = "DELETE FROM " . EVENTS_PERSONNEL_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($del_ppl);
        if (!empty($_REQUEST['event_person'])) {
            foreach ($_REQUEST['event_person'] as $k => $v) {
                if ($v != '') {
                    $sql_ppl = "INSERT INTO " . EVENTS_PERSONNEL_REL_TABLE . " (event_id, person_id) VALUES ('" . $event_id . "', '" . $v . "')";
                    //echo "$sql_ppl <br>";
                    $wpdb->query($sql_ppl);
                }
            }
        }
        $del_venues = "DELETE FROM " . EVENTS_VENUE_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($del_venues);
        if (!empty($_REQUEST['venue_id'])) {
            foreach ($_REQUEST['venue_id'] as $k => $v) {
                if ($v != '' && $v != 0) {
                    $sql_venues = "INSERT INTO " . EVENTS_VENUE_REL_TABLE . " (event_id, venue_id) VALUES ('" . $event_id . "', '" . $v . "')";
                    //echo "$sql_venues <br>";
                    $wpdb->query($sql_venues);
                }
            }
        }
        $del_discounts = "DELETE FROM " . EVENTS_DISCOUNT_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($del_discounts);
        if (!empty($_REQUEST['event_discount'])) {
            foreach ($_REQUEST['event_discount'] as $k => $v) {
                if ($v != '') {
                    $sql_discount = "INSERT INTO " . EVENTS_DISCOUNT_REL_TABLE . " (event_id, discount_id) VALUES ('" . $event_id . "', '" . $v . "')";
                    //echo "$sql_discount <br>";
                    $wpdb->query($sql_discount);
                }
            }
        }
        $del_times = "DELETE FROM " . EVENTS_START_END_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($del_times);
        if ($_REQUEST['start_time'] != '') {
            foreach ($_REQUEST['start_time'] as $k => $v) {
                if ($v != '') {
                    $time_qty = empty($_REQUEST['time_qty'][$k]) ? '0' : "'" . $_REQUEST['time_qty'][$k] . "'";
                    $sql_times = "INSERT INTO " . EVENTS_START_END_TABLE . " (event_id, start_time, end_time, reg_limit) VALUES ('" . $event_id . "', '" . event_date_display($v, 'H:i') . "', '" . event_date_display($_REQUEST['end_time'][$k], 'H:i') . "', " . $time_qty . ")";
                    //echo "$sql_times <br>";
                    $wpdb->query($sql_times);
                }
            }
        }
        $del_prices = "DELETE FROM " . EVENTS_PRICES_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($del_prices);
        if (!empty($_REQUEST['event_cost'])) {
            foreach ($_REQUEST['event_cost'] as $k => $v) {
                if ($v != '') {
                    $price_type = $_REQUEST['price_type'][$k] != '' ? $_REQUEST['price_type'][$k] : __('General Admission', 'event_espresso');
                    $member_price_type = !empty($_REQUEST['member_price_type'][$k]) ? $_REQUEST['member_price_type'][$k] : __('Members Admission', 'event_espresso');
                    $member_price = !empty($_REQUEST['member_price'][$k]) ? $_REQUEST['member_price'][$k] : $v;
                    $sql_prices = "INSERT INTO " . EVENTS_PRICES_TABLE . " (event_id, event_cost, surcharge, surcharge_type, price_type, member_price, member_price_type) VALUES ('" . $event_id . "', '" . $v . "', '" . $_REQUEST['surcharge'][$k] . "', '" . $_REQUEST['surcharge_type'][$k] . "', '" . $price_type . "', '" . $member_price . "', '" . $member_price_type . "')";
                    //echo "$sql_prices <br>";
                    $wpdb->query($sql_prices);
                }
            }
        } else {
            $sql_price = "INSERT INTO " . EVENTS_PRICES_TABLE . " (event_id, event_cost, surcharge, price_type, member_price, member_price_type) VALUES ('" . $event_id . "', '0.00', '0.00', '" . __('Free', 'event_espresso') . "', '0.00', '" . __('Free', 'event_espresso') . "')";
            if (!$wpdb->query($sql_price)) {
                $error = true;
            }
        }
        ############# MailChimp Integration ###############
        if (get_option('event_mailchimp_active') == 'true' && $espresso_premium == true) {
            MailChimpController::update_event_list_rel($event_id);
        }
        if (function_exists('espresso_fb_createevent') == 'true' && $espresso_premium == true) {
            espresso_fb_updateevent($event_id);
        }
        /// Create Event Post Code Here
        switch ($_REQUEST['create_post']) {
            case $_REQUEST['create_post'] == 'N':
                $sql = " SELECT * FROM " . EVENTS_DETAIL_TABLE;
                $sql .= " WHERE id = '" . $event_id . "' ";
                $wpdb->get_results($sql);
                $post_id = $wpdb->last_result[0]->post_id;
                if ($wpdb->num_rows > 0 && !empty($_REQUEST['delete_post']) && $_REQUEST['delete_post'] == 'Y') {
                    $sql = array('post_id' => '', 'post_type' => '');
                    $sql_data = array('%d', '%s');
                    $update_id = array('id' => $event_id);
                    $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
                    wp_delete_post($post_id, 'true');
                }
                break;
            case $_REQUEST['create_post'] == 'Y':
                $post_type = $_REQUEST['espresso_post_type'];
                if ($post_type == 'post') {
                    if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "event_post.php") || file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . "templates/event_post.php")) {
                        // Load message from template into message post variable
                        ob_start();
                        if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "event_post.php")) {
                            require_once EVENT_ESPRESSO_TEMPLATE_DIR . "event_post.php";
                        } else {
                            require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/event_post.php";
                        }
                        $post_content = ob_get_contents();
                        ob_end_clean();
                    } else {
                        _e('There was error finding a post template. Please verify your post templates are available.', 'event_espresso');
                    }
                } elseif ($post_type == 'espresso_event') {
                    ob_start();
                    echo $event_desc;
                    $post_content = ob_get_contents();
                    ob_end_clean();
                }
                $my_post = array();
                $sql = " SELECT * FROM " . EVENTS_DETAIL_TABLE;
                $sql .= " WHERE id = '" . $event_id . "' ";
                $wpdb->get_results($sql);
                $post_id = $wpdb->last_result[0]->post_id;
                $post_type = $_REQUEST['espresso_post_type'];
                if ($post_id > 0) {
                    $my_post['ID'] = $post_id;
                }
                $my_post['post_title'] = esc_html($_REQUEST['event']);
                $my_post['post_content'] = $post_content;
                $my_post['post_status'] = 'publish';
                $my_post['post_author'] = $_REQUEST['user'];
                $my_post['post_category'] = $_REQUEST['post_category'];
                //print_r ($my_post['post_category']);
                $my_post['tags_input'] = $_REQUEST['post_tags'];
                $my_post['post_type'] = $post_type;
                //print_r($my_post);
                // Insert the post into the database
                if ($post_id > 0) {
                    $post_id = wp_update_post($my_post);
                    update_post_meta($post_id, 'event_id', $event_id);
                    update_post_meta($post_id, 'event_identifier', $event_identifier);
                    update_post_meta($post_id, 'event_start_date', $start_date);
                    update_post_meta($post_id, 'event_end_date', $end_date);
                    update_post_meta($post_id, 'event_location', $event_location);
                    update_post_meta($post_id, 'virtual_url', $virtual_url);
                    update_post_meta($post_id, 'virtual_phone', $virtual_phone);
                    //
                    update_post_meta($post_id, 'event_address', $address);
                    update_post_meta($post_id, 'event_address2', $address2);
                    update_post_meta($post_id, 'event_city', $city);
                    update_post_meta($post_id, 'event_state', $state);
                    update_post_meta($post_id, 'event_country', $country);
                    update_post_meta($post_id, 'event_phone', $phone);
                    update_post_meta($post_id, 'venue_title', $venue_title);
                    update_post_meta($post_id, 'venue_url', $venue_url);
                    update_post_meta($post_id, 'venue_phone', $venue_phone);
                    update_post_meta($post_id, 'venue_image', $venue_image);
                    update_post_meta($post_id, 'event_externalURL', $externalURL);
                    update_post_meta($post_id, 'event_reg_limit', $reg_limit);
                    update_post_meta($post_id, 'event_start_time', time_to_24hr($start_time));
                    update_post_meta($post_id, 'event_end_time', time_to_24hr($end_time));
                    update_post_meta($post_id, 'event_registration_start', $registration_start);
                    update_post_meta($post_id, 'event_registration_end', $registration_end);
                    update_post_meta($post_id, 'event_registration_startT', $registration_startT);
                    update_post_meta($post_id, 'event_registration_endT', $registration_endT);
                    //update_post_meta( $post_id, 'timezone_string', $timezone_string );
                } else {
                    $post_id = wp_insert_post($my_post);
                    add_post_meta($post_id, 'event_id', $event_id);
                    add_post_meta($post_id, 'event_identifier', $event_identifier);
                    add_post_meta($post_id, 'event_start_date', $start_date);
                    add_post_meta($post_id, 'event_end_date', $end_date);
                    add_post_meta($post_id, 'event_location', $event_location);
                    add_post_meta($post_id, 'virtual_url', $virtual_url);
                    add_post_meta($post_id, 'virtual_phone', $virtual_phone);
                    //
                    add_post_meta($post_id, 'event_address', $address);
                    add_post_meta($post_id, 'event_address2', $address2);
                    add_post_meta($post_id, 'event_city', $city);
                    add_post_meta($post_id, 'event_state', $state);
                    add_post_meta($post_id, 'event_country', $country);
                    add_post_meta($post_id, 'event_phone', $phone);
                    add_post_meta($post_id, 'venue_title', $venue_title);
                    add_post_meta($post_id, 'venue_url', $venue_url);
                    add_post_meta($post_id, 'venue_phone', $venue_phone);
                    add_post_meta($post_id, 'venue_image', $venue_image);
                    add_post_meta($post_id, 'event_externalURL', $externalURL);
                    add_post_meta($post_id, 'event_reg_limit', $reg_limit);
                    add_post_meta($post_id, 'event_start_time', time_to_24hr($start_time));
                    add_post_meta($post_id, 'event_end_time', time_to_24hr($end_time));
                    add_post_meta($post_id, 'event_registration_start', $registration_start);
                    add_post_meta($post_id, 'event_registration_end', $registration_end);
                    add_post_meta($post_id, 'event_registration_startT', $registration_startT);
                    add_post_meta($post_id, 'event_registration_endT', $registration_endT);
                    //add_post_meta( $post_id, 'timezone_string', $timezone_string );
                }
                // Store the POST ID so it can be displayed on the edit page
                $sql = array('post_id' => $post_id, 'post_type' => $post_type);
                $sql_data = array('%d', '%s');
                $update_id = array('id' => $event_id);
                $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
                break;
        }
        ?>
        <div id="message" class="updated fade"><p><strong><?php 
        _e('Event details updated for', 'event_espresso');
        ?>
 <a href="<?php 
        echo espresso_reg_url($event_id);
        ?>
" target="_blank"><?php 
        echo stripslashes_deep($_REQUEST['event']);
        ?>
 for <?php 
        echo date("m/d/Y", strtotime($start_date));
        ?>
</a>.</strong></p></div>
        
        <?php 
        /*
         * Added for seating chart addon
         */
        if (isset($seating_chart_result) && $seating_chart_result === false) {
            ?>
        <p>Failed to associate new seating chart with this event. (Seats from current seating chart might have been used by some attendees)</p>
        <?php 
        }
        /*
         * End
         */
        ?>
   
        
        <?php 
    }
    /*
     * With the recursion of this function, additional recurring events will be updated
     */
    if (isset($recurrence_dates) && count($recurrence_dates) > 0 && $_POST['recurrence_apply_changes_to'] > 1) {
        //$recurrence_dates = array_shift($recurrence_dates); //Remove the first item from the array since it will be added after this recursion
        foreach ($recurrence_dates as $r_d) {
            if ($r_d['event_id'] != '' && count($r_d) > 2) {
                update_event(array('event_id' => $r_d['event_id'], 'event_identifier' => $r_d['event_identifier'], 'recurrence_id' => $r_d['recurrence_id'], 'recurrence_start_date' => $r_d['start_date'], 'recurrence_event_end_date' => $r_d['event_end_date'], 'registration_start' => $r_d['registration_start'], 'registration_end' => $r_d['registration_end'], 'visible_on' => $r_d['visible_on']));
            }
        }
    }
    /*
     * End recursion, as part of recurring events.
     */
}
예제 #17
0
파일: event.php 프로젝트: pecey/Edge2k15
$contacts = get_all_contacts();
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $event = get_event($_GET['id']);
} else {
    if (isset($_POST['id'])) {
        if (!isset($_FILES['pdf']) || !file_exists($_FILES['pdf']['tmp_name']) || !is_uploaded_file($_FILES['pdf']['tmp_name'])) {
            update_event($_POST['id'], stripslashes($_POST['description']));
        } else {
            $info = pathinfo($_FILES['pdf']['name']);
            $ext = $info['extension'];
            // get the extension of the file
            $newname = $_POST['id'] . "." . $ext;
            $target = 'pdfs/' . $newname;
            move_uploaded_file($_FILES['pdf']['tmp_name'], $target);
            update_event($_POST['id'], stripslashes($_POST['description']), $target);
        }
        $id = $_POST['id'];
        $contact_id1 = $_POST['contact_id1'];
        $contact_id2 = $_POST['contact_id2'];
        if ($contact_id1 == -1) {
            $contact_id1 = false;
        }
        if ($contact_id2 == -1) {
            $contact_id2 = false;
        }
        set_event_contacts($id, $contact_id1, $contact_id2);
        $event = get_event($_POST['id']);
    } else {
        redirect('events.php');
    }
function update_event($recurrence_arr = array())
{
    //print_r($_REQUEST);
    global $wpdb, $org_options, $current_user, $espresso_premium;
    //Security check using nonce
    if (empty($_POST['nonce_verify_update_event']) || !wp_verify_nonce($_POST['nonce_verify_update_event'], 'espresso_verify_update_event_nonce')) {
        if ($recurrence_arr['bypass_nonce'] == FALSE) {
            print '<h3 class="error">' . __('Sorry, there was a security error and your event was not updated.', 'event_espresso') . '</h3>';
            return;
        }
    }
    $wpdb->show_errors();
    /*
     * Begin Recurrence handling
     *
     * Will clean up in V 1.2.0
     *
     */
    if (defined('EVENT_ESPRESSO_RECURRENCE_TABLE')) {
        require_once EVENT_ESPRESSO_RECURRENCE_FULL_PATH . "functions/re_functions.php";
        if ($_POST['recurrence_id'] > 0) {
            /*
             * If the array is empty, then find the recurring dates
             */
            if (count($recurrence_arr) == 0) {
                // Prepare the parameters array for use with various RE functions
                $re_params = array('start_date' => !empty($_POST['recurrence_start_date']) ? sanitize_text_field($_POST['recurrence_start_date']) : '', 'event_end_date' => !empty($_POST['recurrence_event_end_date']) ? sanitize_text_field($_POST['recurrence_event_end_date']) : '', 'end_date' => !empty($_POST['recurrence_end_date']) ? sanitize_text_field($_POST['recurrence_end_date']) : '', 'registration_start' => !empty($_POST['recurrence_regis_start_date']) ? sanitize_text_field($_POST['recurrence_regis_start_date']) : '', 'registration_end' => !empty($_POST['recurrence_regis_end_date']) ? sanitize_text_field($_POST['recurrence_regis_end_date']) : '', 'frequency' => !empty($_POST['recurrence_frequency']) ? sanitize_text_field($_POST['recurrence_frequency']) : '', 'interval' => !empty($_POST['recurrence_interval']) ? sanitize_text_field($_POST['recurrence_interval']) : '', 'recurrence_type' => !empty($_POST['recurrence_type']) ? sanitize_text_field($_POST['recurrence_type']) : '', 'weekdays' => !empty($_POST['recurrence_weekday']) ? $_POST['recurrence_weekday'] : '', 'repeat_by' => !empty($_POST['recurrence_repeat_by']) ? $_POST['recurrence_repeat_by'] : '', 'recurrence_manual_dates' => !empty($_POST['recurrence_manual_dates']) ? $_POST['recurrence_manual_dates'] : '', 'recurrence_manual_end_dates' => !empty($_POST['recurrence_manual_end_dates']) ? $_POST['recurrence_manual_end_dates'] : '', 'recurrence_id' => !empty($_POST['recurrence_id']) ? $_POST['recurrence_id'] : '', 'recurrence_regis_date_increment' => !empty($_POST['recurrence_regis_date_increment']) ? $_POST['recurrence_regis_date_increment'] : '');
                //$re_params['adding_to_db'] = 'Y';
                //Has the form been modified
                $recurrence_form_modified = recurrence_form_modified($re_params);
                //echo ($recurrence_form_modified) ? "Yes" : 'No';
                if ($_POST['recurrence_apply_changes_to'] == 2) {
                    //Update all events in the series based on recurrence id
                    $recurrence_dates = $_POST['recurrence_type'] == 'm' ? find_recurrence_manual_dates($re_params) : find_recurrence_dates($re_params);
                    $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE recurrence_id = %d AND NOT event_status = 'D'";
                } else {
                    //Update this and upcoming events based on recurrence id and start_date >=start_date
                    $re_params['start_date'] = sanitize_text_field($_POST['start_date']);
                    $recurrence_dates = find_recurrence_dates($re_params);
                    $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE start_date >='" . sanitize_text_field($_POST['start_date']) . "' AND recurrence_id = %d and NOT event_status = 'D' ";
                }
                //Recurrence Form modified and changes need to apply to all
                if ($recurrence_form_modified && $_POST['recurrence_apply_changes_to'] > 1) {
                    //Update the recurrence table record with the new RE selections
                    update_recurrence_master_record();
                    /*
                     * Delete the records that don't belong in the formula
                     */
                    if (count($recurrence_dates) > 0) {
                        $delete_in = '';
                        foreach ($recurrence_dates as $k => $v) {
                            $delete_in .= "'" . $k . "',";
                        }
                        $delete_in = substr($delete_in, 0, -1);
                    }
                    if ($_POST['recurrence_apply_changes_to'] == 2) {
                        //Update all events in the series based on recurrence id
                        //$DEL_SQL = 'UPDATE ' . EVENTS_DETAIL_TABLE . " SET event_status = 'D' WHERE start_date NOT IN (" . $delete_in . ") AND recurrence_id = " . $_POST['recurrence_id'];
                        $DEL_SQL = 'DELETE EDT, EAT FROM ' . EVENTS_DETAIL_TABLE . " EDT\n                            LEFT JOIN " . EVENTS_ATTENDEE_TABLE . " EAT\n                                ON EDT.id = EAT.event_id\n                            WHERE EAT.id IS NULL\n                            AND EDT.start_date NOT IN (" . $delete_in . ")\n                            AND recurrence_id = " . sanitize_text_field($_POST['recurrence_id']);
                        $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE recurrence_id = %d and NOT event_status = 'D' ORDER BY start_date";
                    } else {
                        $DEL_SQL = 'DELETE EDT, EAT FROM ' . EVENTS_DETAIL_TABLE . " EDT\n                            LEFT JOIN " . EVENTS_ATTENDEE_TABLE . " EAT\n                                ON EDT.id = EAT.event_id\n                            WHERE EAT.id IS NULL\n                            AND EDT.start_date >='" . esc_sql(sanitize_text_field($_POST['start_date'])) . "'\n                            AND EDT.start_date NOT IN (" . $delete_in . ")\n                            AND recurrence_id = " . $_POST['recurrence_id'];
                        $UPDATE_SQL = "SELECT id,start_date,event_identifier FROM " . EVENTS_DETAIL_TABLE . " WHERE start_date >='" . sanitize_text_field($_POST['start_date']) . "' AND recurrence_id = %d AND NOT event_status = 'D'  ORDER BY start_date";
                    }
                    if ($delete_in != '') {
                        $wpdb->query($wpdb->prepare($DEL_SQL, NULL));
                    }
                    /*
                     * Add the new records based on the new formula
                     * The $recurrence_dates array will contain the new dates
                     */
                    if (!function_exists('add_event_to_db')) {
                        require_once 'insert_event.php';
                    }
                    foreach ($recurrence_dates as $k => $v) {
                        $result = $wpdb->get_row($wpdb->prepare("SELECT ID FROM " . EVENTS_DETAIL_TABLE . " WHERE recurrence_id = %d and start_date = %s and NOT event_status = 'D'", array($_POST['recurrence_id'], $k)));
                        if ($wpdb->num_rows == 0) {
                            add_event_to_db(array('recurrence_id' => sanitize_text_field($_POST['recurrence_id']), 'recurrence_start_date' => $v['start_date'], 'recurrence_event_end_date' => $v['event_end_date'], 'recurrence_end_date' => $v['start_date'], 'registration_start' => $v['registration_start'], 'registration_end' => $v['registration_end'], 'bypass_nonce' => TRUE));
                        } else {
                        }
                    }
                    /*
                     * Find all the event ids in the series and feed into the $recurrence_dates array
                     * This array will be used at the end of this document to invoke the recursion of update_event function so all the events in the series
                     * can be updated with the information.
                     */
                }
                $result = $wpdb->get_results($wpdb->prepare($UPDATE_SQL, array(sanitize_text_field($_POST['recurrence_id']))));
                foreach ($result as $row) {
                    if ($row->start_date != '') {
                        $recurrence_dates[$row->start_date]['event_id'] = $row->id;
                        $recurrence_dates[$row->start_date]['event_identifier'] = $row->event_identifier;
                    }
                }
            }
        }
    }
    //  echo_f('rd',$recurrence_dates);
    if (defined('EVENT_ESPRESSO_RECURRENCE_MODULE_ACTIVE') && !empty($_POST['recurrence']) && $_POST['recurrence'] == 'Y' && count($recurrence_arr) == 0 && $_POST['recurrence_apply_changes_to'] > 1) {
        //skip the first update
    } else {
        //Filters the event description based on user level
        $user_access = apply_filters('filter_hook_espresso_event_unfiltered_description', current_user_can('administrator'));
        $_REQUEST['event_desc'] = is_admin() || $user_access ? $_REQUEST['event_desc'] : apply_filters('filter_hook_espresso_event_wp_kses_post_description', wp_kses_post($_REQUEST['event_desc']));
        $event_meta = array();
        //will be used to hold event meta data
        $event_id = array_key_exists('event_id', $recurrence_arr) ? $recurrence_arr['event_id'] : (int) $_REQUEST['event_id'];
        $event_name = sanitize_text_field($_REQUEST['event']);
        $event_desc = !empty($_REQUEST['event_desc']) ? $_REQUEST['event_desc'] : '';
        $display_desc = sanitize_text_field($_REQUEST['display_desc']);
        $display_reg_form = sanitize_text_field($_REQUEST['display_reg_form']);
        $externalURL = !empty($_REQUEST['externalURL']) ? esc_html($_REQUEST['externalURL']) : '';
        $reg_limit = (int) $_REQUEST['reg_limit'];
        $allow_multiple = $_REQUEST['allow_multiple'];
        $overflow_event_id = empty($_REQUEST['overflow_event_id']) ? '0' : (int) $_REQUEST['overflow_event_id'];
        $allow_overflow = empty($_REQUEST['allow_overflow']) ? 'N' : sanitize_text_field($_REQUEST['allow_overflow']);
        $additional_limit = !empty($_REQUEST['additional_limit']) && $_REQUEST['additional_limit'] > 0 ? (int) $_REQUEST['additional_limit'] : '5';
        $member_only = empty($_REQUEST['member_only']) ? 'N' : sanitize_text_field($_REQUEST['member_only']);
        $is_active = !empty($_REQUEST['is_active']) ? sanitize_text_field($_REQUEST['is_active']) : 'Y';
        $event_status = !empty($_REQUEST['event_status']) ? sanitize_text_field($_REQUEST['event_status']) : 'A';
        //Get the first instance of the start and end times
        $start_time = sanitize_text_field($_REQUEST['start_time'][0]);
        $end_time = sanitize_text_field($_REQUEST['end_time'][0]);
        // Add registration times
        $registration_startT = event_date_display(sanitize_text_field($_REQUEST['registration_startT']), 'H:i');
        $registration_endT = event_date_display(sanitize_text_field($_REQUEST['registration_endT']), 'H:i');
        //Add timezone
        $timezone_string = empty($_REQUEST['timezone_string']) ? '' : sanitize_text_field($_REQUEST['timezone_string']);
        //Early discounts
        $early_disc = !empty($_REQUEST['early_disc']) ? sanitize_text_field($_REQUEST['early_disc']) : '';
        $early_disc_date = !empty($_REQUEST['early_disc_date']) ? sanitize_text_field($_REQUEST['early_disc_date']) : '';
        $early_disc_percentage = !empty($_REQUEST['early_disc_percentage']) ? sanitize_text_field($_REQUEST['early_disc_percentage']) : '';
        $conf_mail = esc_html($_REQUEST['conf_mail']);
        $use_coupon_code = !empty($_REQUEST['use_coupon_code']) ? sanitize_text_field($_REQUEST['use_coupon_code']) : '';
        $alt_email = isset($_REQUEST['alt_email']) && !empty($_REQUEST['alt_email']) ? sanitize_text_field($_REQUEST['alt_email']) : '';
        $send_mail = sanitize_text_field($_REQUEST['send_mail']);
        $email_id = isset($_REQUEST['email_name']) ? (int) $_REQUEST['email_name'] : '0';
        $ticket_id = isset($_REQUEST['ticket_id']) ? (int) $_REQUEST['ticket_id'] : '0';
        $event_category = empty($_REQUEST['event_category']) ? '' : serialize(sanitize_text_field($_REQUEST['event_category']));
        $event_discount = empty($_REQUEST['event_discount']) ? '' : serialize(sanitize_text_field($_REQUEST['event_discount']));
        $registration_start = array_key_exists('registration_start', $recurrence_arr) ? $recurrence_arr['registration_start'] : sanitize_text_field($_REQUEST['registration_start']);
        $registration_end = array_key_exists('registration_end', $recurrence_arr) ? $recurrence_arr['registration_end'] : sanitize_text_field($_REQUEST['registration_end']);
        $start_date = array_key_exists('recurrence_start_date', $recurrence_arr) ? $recurrence_arr['recurrence_start_date'] : (empty($_REQUEST['start_date']) ? $_REQUEST['recurrence_start_date'] : sanitize_text_field($_REQUEST['start_date']));
        $end_date = array_key_exists('recurrence_event_end_date', $recurrence_arr) ? $recurrence_arr['recurrence_event_end_date'] : (empty($_REQUEST['end_date']) ? sanitize_text_field($_REQUEST['recurrence_start_date']) : sanitize_text_field($_REQUEST['end_date']));
        $question_groups = serialize($_REQUEST['question_groups']);
        $add_attendee_question_groups = empty($_REQUEST['add_attendee_question_groups']) ? '' : $_REQUEST['add_attendee_question_groups'];
        //Venue Information
        $venue_title = isset($_REQUEST['venue_title']) ? sanitize_text_field($_REQUEST['venue_title']) : '';
        $venue_url = isset($_REQUEST['venue_url']) ? sanitize_text_field($_REQUEST['venue_url']) : '';
        $venue_phone = isset($_REQUEST['venue_phone']) ? sanitize_text_field($_REQUEST['venue_phone']) : '';
        $venue_image = isset($_REQUEST['venue_image']) ? sanitize_text_field($_REQUEST['venue_image']) : '';
        //Virtual location
        $virtual_url = isset($_REQUEST['virtual_url']) ? sanitize_text_field($_REQUEST['virtual_url']) : '';
        $virtual_phone = isset($_REQUEST['virtual_phone']) ? sanitize_text_field($_REQUEST['virtual_phone']) : '';
        //Address/venue information
        $address = !empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '';
        $address2 = !empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '';
        $city = !empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '';
        $state = !empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
        $zip = !empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '';
        $country = !empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
        $phone = !empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '';
        $event_location = '';
        if (!empty($address)) {
            $event_location .= $address . ' ';
        }
        if (!empty($address2)) {
            $event_location .= '<br />' . $address2;
        }
        if (!empty($city)) {
            $event_location .= '<br />' . $city;
        }
        if (!empty($state)) {
            $event_location .= ', ' . $state;
        }
        if (!empty($zip)) {
            $event_location .= ', ' . $state;
        }
        if (!empty($country)) {
            $event_location .= '<br />' . $country;
        }
        if (isset($reg_limit) && empty($reg_limit)) {
            $reg_limit = 999999;
        }
        $event_meta['default_payment_status'] = !empty($_REQUEST['default_payment_status']) ? sanitize_text_field($_REQUEST['default_payment_status']) : '';
        $event_meta['venue_id'] = empty($_REQUEST['venue_id']) ? '' : (int) $_REQUEST['venue_id'][0];
        $event_meta['additional_attendee_reg_info'] = !empty($_REQUEST['additional_attendee_reg_info']) ? sanitize_text_field($_REQUEST['additional_attendee_reg_info']) : '';
        $event_meta['add_attendee_question_groups'] = $add_attendee_question_groups;
        $event_meta['date_submitted'] = sanitize_text_field($_REQUEST['date_submitted']);
        //Added for seating chart addon
        if (isset($_REQUEST['seating_chart_id'])) {
            $cls_seating_chart = new seating_chart();
            $seating_chart_result = $cls_seating_chart->associate_event_seating_chart((int) $_REQUEST['seating_chart_id'], $event_id);
            $tmp_seating_chart_id = (int) $_REQUEST['seating_chart_id'];
            if ($tmp_seating_chart_id > 0) {
                if ($seating_chart_result === false) {
                    $tmp_seating_chart_row = $wpdb->get_row($wpdb->prepare("select seating_chart_id from " . EVENTS_SEATING_CHART_EVENT_TABLE . " where event_id = {$event_id}", NULL));
                    if ($tmp_seating_chart_row !== NULL) {
                        $tmp_seating_chart_id = $tmp_seating_chart_row->seating_chart_id;
                    } else {
                        $tmp_seating_chart_id = 0;
                    }
                }
                if ($_REQUEST['allow_multiple'] == 'Y' && isset($_REQUEST['seating_chart_id']) && $tmp_seating_chart_id > 0) {
                    $event_meta['additional_attendee_reg_info'] = 3;
                }
            }
        }
        //Process thumbnail image
        $event_thumbnail_url = '';
        if (isset($_REQUEST['upload_image']) && !empty($_REQUEST['upload_image'])) {
            $event_meta['event_thumbnail_url'] = sanitize_text_field($_REQUEST['upload_image']);
            $event_thumbnail_url = sanitize_text_field($event_meta['event_thumbnail_url']);
        }
        if (!empty($_REQUEST['emeta'])) {
            foreach ($_REQUEST['emeta'] as $k => $v) {
                $event_meta[$v] = sanitize_text_field($_REQUEST['emetad'][$k]);
            }
        }
        //Filter to update the event meta as needed
        $event_meta = apply_filters('filter_hook_espresso_update_event_update_meta', $event_meta, $event_id);
        //print_r($_REQUEST['emeta'] );
        $event_meta = serialize($event_meta);
        ############ Added by wp-developers ######################
        $require_pre_approval = 0;
        if (isset($_REQUEST['require_pre_approval'])) {
            $require_pre_approval = sanitize_text_field($_REQUEST['require_pre_approval']);
        }
        ################# END #################
        //When adding colums to the following arrays, be sure both arrays have equal values.
        $sql = array('event_name' => $event_name, 'event_desc' => $event_desc, 'display_desc' => $display_desc, 'display_reg_form' => $display_reg_form, 'address' => $address, 'address2' => $address2, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country, 'phone' => $phone, 'virtual_url' => $virtual_url, 'virtual_phone' => $virtual_phone, 'venue_title' => $venue_title, 'venue_url' => $venue_url, 'venue_phone' => $venue_phone, 'venue_image' => $venue_image, 'registration_start' => $registration_start, 'registration_end' => $registration_end, 'start_date' => $start_date, 'end_date' => $end_date, 'allow_multiple' => $allow_multiple, 'send_mail' => $send_mail, 'is_active' => $is_active, 'event_status' => $event_status, 'conf_mail' => $conf_mail, 'use_coupon_code' => $use_coupon_code, 'member_only' => $member_only, 'externalURL' => $externalURL, 'early_disc' => $early_disc, 'early_disc_date' => $early_disc_date, 'early_disc_percentage' => $early_disc_percentage, 'alt_email' => $alt_email, 'question_groups' => $question_groups, 'allow_overflow' => $allow_overflow, 'overflow_event_id' => $overflow_event_id, 'additional_limit' => $additional_limit, 'reg_limit' => $reg_limit, 'email_id' => $email_id, 'registration_startT' => $registration_startT, 'registration_endT' => $registration_endT, 'event_meta' => $event_meta, 'require_pre_approval' => $require_pre_approval, 'timezone_string' => $timezone_string, 'ticket_id' => $ticket_id);
        $sql_data = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d');
        $update_id = array('id' => $event_id);
        /* echo 'Debug: <br />';
           print_r($sql);
           echo '<br />';
           print 'Number of vars: ' . count ($sql);
           echo '<br />';
           print 'Number of cols: ' . count($sql_data); */
        if (function_exists('event_espresso_add_event_to_db_groupon')) {
            $sql = event_espresso_add_event_to_db_groupon($sql, $_REQUEST['use_groupon_code']);
            ///print count ($sql);
            $sql_data = array_merge((array) $sql_data, (array) '%s');
            //print count($sql_data);
            $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
            /* echo 'Debug: <br />';
               print 'Number of vars: ' . count ($sql);
               echo '<br />';
               print 'Number of cols: ' . count($sql_data); */
        } else {
            $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
            /* echo 'Debug: <br />';
               print 'Number of vars: ' . count ($sql);
               echo '<br />';
               print 'Number of cols: ' . count($sql_data); */
        }
        //print $wpdb->print_error();
        //BEGIN CATEGORY MODIFICATION
        //We first delete the previous entry then we get the category id's of the event and put them in events_detail_table.category_id as a well-formatted string (id,n id)
        $del_cats = "DELETE FROM " . EVENTS_CATEGORY_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($wpdb->prepare($del_cats, NULL));
        $update_event_detail_category_id = "UPDATE " . EVENTS_DETAIL_TABLE . " SET category_id = NULL WHERE id='" . $event_id . "'";
        $wpdb->query($wpdb->prepare($update_event_detail_category_id, NULL));
        $string_cat = '';
        if (!empty($_REQUEST['event_category'])) {
            foreach ($_REQUEST['event_category'] as $k => $v) {
                if (!empty($v)) {
                    $sql_cat = "INSERT INTO " . EVENTS_CATEGORY_REL_TABLE . " (event_id, cat_id) VALUES ('" . $event_id . "', '" . (int) $v . "')";
                    $wpdb->query($wpdb->prepare($sql_cat, array()));
                    $string_cat .= sanitize_text_field($v) . ",";
                }
            }
            if (!empty($string_cat) && $string_cat != ",") {
                $cleaned_string_cat = substr($string_cat, 0, -1);
                $tmp = explode(",", $cleaned_string_cat);
                sort($tmp);
                $cleaned_string_cat = implode(",", $tmp);
                trim($cleaned_string_cat);
                $sql_update_event_detail_category_id = "UPDATE " . EVENTS_DETAIL_TABLE . " SET category_id = '" . $cleaned_string_cat . "' WHERE id='" . $event_id . "'";
                $wpdb->query($wpdb->prepare($sql_update_event_detail_category_id, NULL));
            }
        }
        //END CATEGORY MODIFICATION
        //Staff
        $update_all_staff = FALSE;
        if (isset($_POST['rem_apply_to_all_staff']) && $_POST['recurrence_apply_changes_to'] == 2) {
            $update_all_staff = TRUE;
        }
        if ($_POST['event_id'] == $event_id || $update_all_staff == TRUE) {
            $del_ppl = "DELETE FROM " . EVENTS_PERSONNEL_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
            $wpdb->query($wpdb->prepare($del_ppl, NULL));
            if (!empty($_REQUEST['event_person'])) {
                foreach ($_REQUEST['event_person'] as $k => $v) {
                    if (!empty($v)) {
                        $sql_ppl = "INSERT INTO " . EVENTS_PERSONNEL_REL_TABLE . " (event_id, person_id) VALUES ('" . $event_id . "', '" . (int) $v . "')";
                        $wpdb->query($wpdb->prepare($sql_ppl, array()));
                    }
                }
            }
        }
        //Venues
        $del_venues = "DELETE FROM " . EVENTS_VENUE_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($wpdb->prepare($del_venues, NULL));
        if (!empty($_REQUEST['venue_id'])) {
            foreach ($_REQUEST['venue_id'] as $k => $v) {
                if (!empty($v) && $v != 0) {
                    $sql_venues = "INSERT INTO " . EVENTS_VENUE_REL_TABLE . " (event_id, venue_id) VALUES ('" . $event_id . "', '" . (int) $v . "')";
                    $wpdb->query($wpdb->prepare($sql_venues, array()));
                }
            }
        }
        //Discounts
        $del_discounts = "DELETE FROM " . EVENTS_DISCOUNT_REL_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($wpdb->prepare($del_discounts, NULL));
        if (!empty($_REQUEST['event_discount']) && $_REQUEST['use_coupon_code'] == 'Y') {
            //only re-add the coupon codes if they've specified to use all global coupon codes
            //and 'specific' coupon codes
            foreach ($_REQUEST['event_discount'] as $k => $v) {
                if (!empty($v)) {
                    $sql_discount = "INSERT INTO " . EVENTS_DISCOUNT_REL_TABLE . " (event_id, discount_id) VALUES ('" . $event_id . "', '" . (int) $v . "')";
                    $wpdb->query($wpdb->prepare($sql_discount, array()));
                }
            }
        }
        $del_times = "DELETE FROM " . EVENTS_START_END_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($wpdb->prepare($del_times, NULL));
        if (!empty($_REQUEST['start_time'])) {
            foreach ($_REQUEST['start_time'] as $k => $v) {
                if (!empty($v)) {
                    $time_qty = empty($_REQUEST['time_qty'][$k]) ? '0' : "'" . (int) $_REQUEST['time_qty'][$k] . "'";
                    $sql_times = "INSERT INTO " . EVENTS_START_END_TABLE . " (event_id, start_time, end_time, reg_limit) VALUES ('" . $event_id . "', '" . event_date_display(sanitize_text_field($v), 'H:i') . "', '" . event_date_display(sanitize_text_field($_REQUEST['end_time'][$k]), 'H:i') . "', " . $time_qty . ")";
                    $wpdb->query($wpdb->prepare($sql_times, array()));
                }
            }
        }
        $del_prices = "DELETE FROM " . EVENTS_PRICES_TABLE . " WHERE event_id = '" . $event_id . "'";
        $wpdb->query($wpdb->prepare($del_prices, NULL));
        if (!empty($_REQUEST['event_cost'])) {
            foreach ($_REQUEST['event_cost'] as $k => $v) {
                if (!empty($v)) {
                    $v = (double) preg_replace('/[^0-9\\.]/ui', '', $v);
                    //Removes non-integer characters
                    $price_type = $_REQUEST['price_type'][$k] != '' ? sanitize_text_field(stripslashes_deep($_REQUEST['price_type'][$k])) : __('General Admission', 'event_espresso');
                    $member_price_type = !empty($_REQUEST['member_price_type'][$k]) ? sanitize_text_field(stripslashes_deep($_REQUEST['member_price_type'][$k])) : __('Members Admission', 'event_espresso');
                    $member_price = !empty($_REQUEST['member_price'][$k]) ? (double) $_REQUEST['member_price'][$k] : $v;
                    $sql_price = array('event_id' => $event_id, 'event_cost' => $v, 'surcharge' => sanitize_text_field($_REQUEST['surcharge'][$k]), 'surcharge_type' => sanitize_text_field($_REQUEST['surcharge_type'][$k]), 'price_type' => $price_type, 'member_price' => $member_price, 'member_price_type' => $member_price_type);
                    $sql_price_data = array('%d', '%s', '%s', '%s', '%s', '%s', '%s');
                    if (!$wpdb->insert(EVENTS_PRICES_TABLE, $sql_price, $sql_price_data)) {
                        $error = true;
                    }
                }
            }
        } else {
            $sql_price = "INSERT INTO " . EVENTS_PRICES_TABLE . " (event_id, event_cost, surcharge, price_type, member_price, member_price_type) VALUES ('" . $event_id . "', '0.00', '0.00', '" . __('Free', 'event_espresso') . "', '0.00', '" . __('Free', 'event_espresso') . "')";
            if (!$wpdb->query($wpdb->prepare($sql_price, array()))) {
                $error = true;
            }
        }
        ############# MailChimp Integration ###############
        if (defined('EVENTS_MAILCHIMP_ATTENDEE_REL_TABLE') && $espresso_premium == true) {
            MailChimpController::update_event_list_rel($event_id);
        }
        // Create Event Post Code Here
        if (isset($_REQUEST['create_post'])) {
            switch ($_REQUEST['create_post']) {
                case 'N':
                    $sql = " SELECT * FROM " . EVENTS_DETAIL_TABLE;
                    $sql .= " WHERE id = '" . $event_id . "' ";
                    $wpdb->get_results($wpdb->prepare($sql, NULL));
                    $post_id = $wpdb->last_result[0]->post_id;
                    if ($wpdb->num_rows > 0 && !empty($_REQUEST['delete_post']) && $_REQUEST['delete_post'] == 'Y') {
                        $sql = array('post_id' => '', 'post_type' => '');
                        $sql_data = array('%d', '%s');
                        $update_id = array('id' => $event_id);
                        $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
                        wp_delete_post($post_id, 'true');
                    }
                    break;
                case 'Y':
                    $post_type = $_REQUEST['espresso_post_type'];
                    if ($post_type == 'post') {
                        if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "event_post.php") || file_exists(EVENT_ESPRESSO_PLUGINFULLPATH . "templates/event_post.php")) {
                            // Load message from template into message post variable
                            ob_start();
                            if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR . "event_post.php")) {
                                require_once EVENT_ESPRESSO_TEMPLATE_DIR . "event_post.php";
                            } else {
                                require_once EVENT_ESPRESSO_PLUGINFULLPATH . "templates/event_post.php";
                            }
                            $post_content = ob_get_contents();
                            ob_end_clean();
                        } else {
                            _e('There was error finding a post template. Please verify your post templates are available.', 'event_espresso');
                        }
                    } elseif ($post_type == 'espresso_event') {
                        ob_start();
                        echo $event_desc;
                        $post_content = ob_get_contents();
                        ob_end_clean();
                        // if there's a cart link shortcode in the post, replace the shortcode with one that includes the event_id
                        if (preg_match("/ESPRESSO_CART_LINK/", $post_content)) {
                            $post_content = preg_replace('/ESPRESSO_CART_LINK/', 'ESPRESSO_CART_LINK event_id=' . $event_id, $post_content);
                        }
                    }
                    $my_post = array();
                    $sql = " SELECT * FROM " . EVENTS_DETAIL_TABLE;
                    $sql .= " WHERE id = '" . $event_id . "' ";
                    $wpdb->get_results($wpdb->prepare($sql, NULL));
                    $post_id = $wpdb->last_result[0]->post_id;
                    $post_type = $_REQUEST['espresso_post_type'];
                    if ($post_id > 0) {
                        $my_post['ID'] = $post_id;
                    }
                    $my_post['post_title'] = sanitize_text_field($_REQUEST['event']);
                    $my_post['post_content'] = $post_content;
                    $my_post['post_status'] = 'publish';
                    $my_post['post_author'] = !empty($_REQUEST['user']) ? (int) $_REQUEST['user'] : '';
                    $my_post['post_category'] = !empty($_REQUEST['post_category']) ? $_REQUEST['post_category'] : '';
                    $my_post['tags_input'] = !empty($_REQUEST['post_tags']) ? $_REQUEST['post_tags'] : '';
                    $my_post['post_type'] = !empty($post_type) ? $post_type : 'post';
                    //print_r($my_post);
                    // Insert the post into the database
                    if ($post_id > 0) {
                        $post_id = wp_update_post($my_post);
                        update_post_meta($post_id, 'event_id', $event_id);
                        update_post_meta($post_id, 'event_meta', $event_meta);
                        update_post_meta($post_id, 'event_identifier', $event_identifier);
                        update_post_meta($post_id, 'event_start_date', $start_date);
                        update_post_meta($post_id, 'event_end_date', $end_date);
                        update_post_meta($post_id, 'event_location', $event_location);
                        update_post_meta($post_id, 'event_thumbnail_url', $event_thumbnail_url);
                        update_post_meta($post_id, 'virtual_url', $virtual_url);
                        update_post_meta($post_id, 'virtual_phone', $virtual_phone);
                        //
                        update_post_meta($post_id, 'event_address', $address);
                        update_post_meta($post_id, 'event_address2', $address2);
                        update_post_meta($post_id, 'event_city', $city);
                        update_post_meta($post_id, 'event_state', $state);
                        update_post_meta($post_id, 'event_country', $country);
                        update_post_meta($post_id, 'event_phone', $phone);
                        update_post_meta($post_id, 'venue_title', $venue_title);
                        update_post_meta($post_id, 'venue_url', $venue_url);
                        update_post_meta($post_id, 'venue_phone', $venue_phone);
                        update_post_meta($post_id, 'venue_image', $venue_image);
                        update_post_meta($post_id, 'event_externalURL', $externalURL);
                        update_post_meta($post_id, 'event_reg_limit', $reg_limit);
                        update_post_meta($post_id, 'event_start_time', time_to_24hr($start_time));
                        update_post_meta($post_id, 'event_end_time', time_to_24hr($end_time));
                        update_post_meta($post_id, 'event_registration_start', $registration_start);
                        update_post_meta($post_id, 'event_registration_end', $registration_end);
                        update_post_meta($post_id, 'event_registration_startT', $registration_startT);
                        update_post_meta($post_id, 'event_registration_endT', $registration_endT);
                    } else {
                        $post_id = wp_insert_post($my_post);
                        add_post_meta($post_id, 'event_id', $event_id);
                        add_post_meta($post_id, 'event_meta', $event_meta);
                        add_post_meta($post_id, 'event_identifier', $event_identifier);
                        add_post_meta($post_id, 'event_start_date', $start_date);
                        add_post_meta($post_id, 'event_end_date', $end_date);
                        add_post_meta($post_id, 'event_location', $event_location);
                        add_post_meta($post_id, 'event_thumbnail_url', $event_thumbnail_url);
                        add_post_meta($post_id, 'virtual_url', $virtual_url);
                        add_post_meta($post_id, 'virtual_phone', $virtual_phone);
                        //
                        add_post_meta($post_id, 'event_address', $address);
                        add_post_meta($post_id, 'event_address2', $address2);
                        add_post_meta($post_id, 'event_city', $city);
                        add_post_meta($post_id, 'event_state', $state);
                        add_post_meta($post_id, 'event_country', $country);
                        add_post_meta($post_id, 'event_phone', $phone);
                        add_post_meta($post_id, 'venue_title', $venue_title);
                        add_post_meta($post_id, 'venue_url', $venue_url);
                        add_post_meta($post_id, 'venue_phone', $venue_phone);
                        add_post_meta($post_id, 'venue_image', $venue_image);
                        add_post_meta($post_id, 'event_externalURL', $externalURL);
                        add_post_meta($post_id, 'event_reg_limit', $reg_limit);
                        add_post_meta($post_id, 'event_start_time', time_to_24hr($start_time));
                        add_post_meta($post_id, 'event_end_time', time_to_24hr($end_time));
                        add_post_meta($post_id, 'event_registration_start', $registration_start);
                        add_post_meta($post_id, 'event_registration_end', $registration_end);
                        add_post_meta($post_id, 'event_registration_startT', $registration_startT);
                        add_post_meta($post_id, 'event_registration_endT', $registration_endT);
                    }
                    // Store the POST ID so it can be displayed on the edit page
                    $sql = array('post_id' => $post_id, 'post_type' => $post_type);
                    $sql_data = array('%d', '%s');
                    $update_id = array('id' => $event_id);
                    $wpdb->update(EVENTS_DETAIL_TABLE, $sql, $update_id, $sql_data, array('%d'));
                    break;
            }
        }
        ?>
        <div id="message" class="updated fade"><p><strong><?php 
        _e('Event details updated for', 'event_espresso');
        ?>
 <a href="<?php 
        echo espresso_reg_url($event_id);
        ?>
" target="_blank">
		<?php 
        echo htmlentities(stripslashes(sanitize_text_field($_REQUEST['event'])), ENT_QUOTES, 'UTF-8');
        ?>
 for <?php 
        echo date("m/d/Y", strtotime($start_date));
        ?>
</a>.</strong></p></div>
        
        <?php 
        /*
         * Added for seating chart addon
         */
        if (isset($seating_chart_result) && $seating_chart_result === false) {
            echo '<p>Failed to associate new seating chart with this event. (Seats from current seating chart might have been used by some attendees)</p>';
        }
    }
    /*
     * With the recursion of this function, additional recurring events will be updated
     */
    if (isset($recurrence_dates) && count($recurrence_dates) > 0 && $_POST['recurrence_apply_changes_to'] > 1) {
        //$recurrence_dates = array_shift($recurrence_dates); //Remove the first item from the array since it will be added after this recursion
        foreach ($recurrence_dates as $r_d) {
            if ($r_d['event_id'] != '' && count($r_d) > 2) {
                update_event(array('event_id' => $r_d['event_id'], 'event_identifier' => $r_d['event_identifier'], 'recurrence_id' => $r_d['recurrence_id'], 'recurrence_start_date' => $r_d['start_date'], 'recurrence_event_end_date' => $r_d['event_end_date'], 'registration_start' => $r_d['registration_start'], 'registration_end' => $r_d['registration_end'], 'visible_on' => $r_d['visible_on'], 'bypass_nonce' => TRUE));
            }
        }
    }
    /*
     * End recursion, as part of recurring events.
     */
    do_action('action_hook_espresso_update_event_success', $_REQUEST);
}
예제 #19
0
//dev
foreach ($event_posts as $one_event) {
    if (isset($one_event->meta['_thumbnail_id'])) {
        // print_r($one_event->meta['_thumbnail_id']);
    }
}
$fetched_mbid_arr = array();
// FOREACH EVENT (CLASS) IN MINDBODY FEED,
foreach ($result->GetClassesResult->Classes->Class as $mb_event) {
    //  IF THERE IS NO POST WITH THAT MBID, CREATE ONE
    if (!isset($existing_posts_mbids_arr[$mb_event->ID])) {
        insert_new_event($mb_event);
    } else {
        // else update the post.  See note 1
        $post_id = $existing_posts_mbids_arr[$mb_event->ID];
        update_event($mb_event, $post_id);
    }
    // store fetched mbid (as key so ) so we can see if any posts no longer have MB entries and have to be trashed.
    $fetched_mbid_arr[$mb_event->ID] = true;
    // store as key for quicker lookup.  Anything useful we can put in the val?
}
// print_r($existing_posts_mbids_arr);
// print_r($fetched_mbid_arr);
foreach ($existing_posts_mbids_arr as $mbid => $post_id) {
    // NOTE: THIS ONLY WORKS IF THE FEED AND THE POST SELECTIONS USE THE SAME DATE RANGE.
    if (!isset($fetched_mbid_arr[$mbid])) {
        log_it("Deleted post {$post_id} because mbid {$mbid} is was not in feed");
        wp_trash_post($post_id);
        // use trash instead of delete, which will actually delete if post type isn't page or post
    }
}
예제 #20
0
 /**
  * Update existing group of recursive events and logs the action
  * @param int $eventid id in table personal_calendar
  * @param string $title event title
  * @param string $start event datetime
  * @param text $content event details
  * @param string $reference_obj_id refernced object by note. It contains the object type (from $ref_object_types) and object id (id in the corresponding db table), e.g., video_link:5
  */
 public static function update_recursive_event($eventid, $title, $start, $duration, $content, $reference_obj_id = NULL)
 {
     global $langNotValidInput;
     $rec_eventid = Database::get()->query('SELECT source_event_id FROM personal_calendar WHERE id=?d', $eventid);
     if ($rec_eventid) {
         return update_event($rec_eventid, $title, $start, $duration, $content, true, $reference_obj_id);
     } else {
         return array('success' => false, 'message' => $langNotValidInput);
     }
 }
예제 #21
0
/**
 * Processes the data passed by the part update form from the summary page
 *
 * @param object $cm The moodle course module object for this instance
 * @param object $turnitintool The turnitintool object is for this activity
 * @param array $post The post array from the part update form
 * @return array A notice array contains error details for display on page load in the case of an error nothing returned if no errors occur
 */
function turnitintool_update_partnames($cm, $turnitintool, $post)
{
    global $CFG, $USER;
    if (has_capability('mod/turnitintool:grade', turnitintool_get_context('MODULE', $cm->id))) {
        $notice['message'] = '';
        $error = false;
        $dtstart = make_timestamp($post["dtstart"]["year"], $post["dtstart"]["month"], $post["dtstart"]["day"], $post["dtstart"]["hour"], $post["dtstart"]["minute"], 0, get_user_timezone());
        $dtdue = make_timestamp($post["dtdue"]["year"], $post["dtdue"]["month"], $post["dtdue"]["day"], $post["dtdue"]["hour"], $post["dtdue"]["minute"], 0, get_user_timezone());
        $dtpost = make_timestamp($post["dtpost"]["year"], $post["dtpost"]["month"], $post["dtpost"]["day"], $post["dtpost"]["hour"], $post["dtpost"]["minute"], 0, get_user_timezone());
        if ($dtstart >= $dtdue) {
            $notice['message'] .= get_string('partstarterror', 'turnitintool');
            $error = true;
        }
        if ($dtpost < $dtstart) {
            $notice['message'] .= get_string('partdueerror', 'turnitintool');
            $error = true;
        }
        if (empty($post['partname'])) {
            $notice['message'] .= get_string('partnameerror', 'turnitintool');
            $error = true;
        }
        if (strlen($post['partname']) > 35) {
            $input = new stdClass();
            $input->length = 35;
            $input->field = get_string('partname', 'turnitintool');
            $notice['message'] .= get_string('maxlength', 'turnitintool', $input);
            $error = true;
        }
        if (!preg_match("/^[-]?[0-9]+([\\.][0-9]+)?\$/", $post['maxmarks'])) {
            // ENTRY IS NOT A NUMBER
            $notice['message'] .= get_string('partmarkserror', 'turnitintool');
            $error = true;
        }
        if ($error) {
            $notice['error'] = $post['submitted'];
            $notice['post'] = $post;
        }
        if (!$error) {
            // Update Turnitin Assignment via the API [[[[
            $tiipost = new stdClass();
            $tiipost->ctl = turnitintool_getCTL($turnitintool->course);
            $tiipost->dtstart = $dtstart;
            $tiipost->dtdue = $dtdue;
            $tiipost->dtpost = $dtpost;
            if (turnitintool_is_owner($turnitintool->course)) {
                $owner = $USER;
            } else {
                $owner = turnitintool_get_owner($turnitintool->course);
            }
            if (!($course = turnitintool_get_record('course', 'id', $turnitintool->course))) {
                turnitintool_print_error('coursegeterror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
                exit;
            }
            $loaderbar = new turnitintool_loaderbarclass(3);
            $tii = new turnitintool_commclass(turnitintool_getUID($owner), $owner->firstname, $owner->lastname, $owner->email, 2, $loaderbar);
            $tii->startSession();
            turnitintool_usersetup($owner, get_string('userprocess', 'turnitintool'), $tii, $loaderbar);
            turnitintool_classsetup($course, $owner, get_string('classprocess', 'turnitintool'), $tii, $loaderbar);
            if ($tii->getRerror()) {
                if ($tii->getAPIunavailable()) {
                    turnitintool_print_error('apiunavailable', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
                } else {
                    turnitintool_print_error($tii->getRmessage(), NULL, NULL, NULL, __FILE__, __LINE__);
                }
                exit;
            }
            $tiipost->cid = turnitintool_getCID($turnitintool->course);
            $tiipost->assignid = turnitintool_getAID($post['submitted']);
            $tiipost->s_view_report = $turnitintool->studentreports;
            $tiipost->max_points = $post['maxmarks'];
            $tiipost->anon = $turnitintool->anon;
            $tiipost->report_gen_speed = $turnitintool->reportgenspeed;
            $tiipost->late_accept_flag = $turnitintool->allowlate;
            $tiipost->submit_papers_to = $turnitintool->submitpapersto;
            $tiipost->s_paper_check = $turnitintool->spapercheck;
            $tiipost->internet_check = $turnitintool->internetcheck;
            $tiipost->journal_check = $turnitintool->journalcheck;
            // Add in Exclude small matches, biblio, quoted etc 20102009
            $tiipost->exclude_biblio = $turnitintool->excludebiblio;
            $tiipost->exclude_quoted = $turnitintool->excludequoted;
            $tiipost->exclude_value = $turnitintool->excludevalue;
            $tiipost->exclude_type = $turnitintool->excludetype;
            // Add in the erater settings
            $tiipost->erater = $turnitintool->erater;
            $tiipost->erater_handbook = $turnitintool->erater_handbook;
            $tiipost->erater_dictionary = $turnitintool->erater_dictionary;
            $tiipost->erater_spelling = $turnitintool->erater_spelling;
            $tiipost->erater_grammar = $turnitintool->erater_grammar;
            $tiipost->erater_usage = $turnitintool->erater_usage;
            $tiipost->erater_mechanics = $turnitintool->erater_mechanics;
            $tiipost->erater_style = $turnitintool->erater_style;
            $tiipost->transmatch = $turnitintool->transmatch;
            $tiipost->name = $turnitintool->name . ' - ' . $post['partname'] . ' (Moodle ' . $tiipost->assignid . ')';
            $tiipost->currentassign = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($post['submitted']) . ' (Moodle ' . $tiipost->assignid . ')';
            $tii->createAssignment($tiipost, 'UPDATE', get_string('assignmentupdate', 'turnitintool', ''));
            if ($tii->getRerror()) {
                if ($tii->getRcode() == TURNITINTOOL_DB_UNIQUEID_ERROR) {
                    $reason = get_string('assignmentdoesnotexist', 'turnitintool');
                } else {
                    $reason = $tii->getAPIunavailable() ? get_string('apiunavailable', 'turnitintool') : $tii->getRmessage();
                }
                turnitintool_print_error('<strong>' . get_string('updateerror', 'turnitintool') . '</strong><br />' . $reason);
                exit;
            }
            $part = new stdClass();
            $part->id = $post['submitted'];
            $part->dtstart = $dtstart;
            $part->dtdue = $dtdue;
            $part->dtpost = $dtpost;
            $part->partname = $post['partname'];
            $part->maxmarks = $post['maxmarks'];
            $part->deleted = 0;
            $event = new stdClass();
            $event->timestart = $part->dtdue;
            $event->name = $turnitintool->name . ' - ' . $part->partname;
            $currentevent = $turnitintool->name . ' - ' . turnitintool_partnamefromnum($post['submitted']);
            if (!($dbpart = turnitintool_update_record('turnitintool_parts', $part, false))) {
                turnitintool_print_error('partdberror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
            }
            if ($events = turnitintool_get_record_select('event', "modulename='turnitintool' AND instance = ? AND name = ?", array($turnitintool->id, $currentevent))) {
                $event->id = $events->id;
                if (method_exists('calendar_event', 'update')) {
                    $calendarevent = calendar_event::load($event->id);
                    $calendarevent->update($event);
                } else {
                    update_event($event);
                }
            }
            @(include_once $CFG->dirroot . "/lib/gradelib.php");
            // Set the view time for Grade Book viewing
            if (function_exists('grade_update')) {
                $lastpart = turnitintool_get_record('turnitintool_parts', 'turnitintoolid', $turnitintool->id, '', '', '', '', 'max(dtpost)');
                $lastpart = current($lastpart);
                $params['hidden'] = $lastpart;
                grade_update('mod/turnitintool', $turnitintool->course, 'mod', 'turnitintool', $turnitintool->id, 0, NULL, $params);
            }
            $tii->endSession();
            turnitintool_redirect($CFG->wwwroot . '/mod/turnitintool/view.php' . '?id=' . $cm->id . '&do=intro');
            exit;
        } else {
            return $notice;
        }
    } else {
        turnitintool_print_error('permissiondeniederror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
    }
}
예제 #22
0
파일: lib.php 프로젝트: nuckey/moodle
/**
 * Make sure up-to-date events are created for all assignment instances
 *
 * This standard function will check all instances of this module
 * and make sure there are up-to-date events created for each of them.
 * If courseid = 0, then every assignment event in the site is checked, else
 * only assignment events belonging to the course specified are checked.
 * This function is used, in its new format, by restore_refresh_events()
 *
 * @param $courseid int optional If zero then all assignments for all courses are covered
 * @return boolean Always returns true
 */
function assignment_refresh_events($courseid = 0) {
    global $DB;

    if ($courseid == 0) {
        if (! $assignments = $DB->get_records("assignment")) {
            return true;
        }
    } else {
        if (! $assignments = $DB->get_records("assignment", array("course"=>$courseid))) {
            return true;
        }
    }
    $moduleid = $DB->get_field('modules', 'id', array('name'=>'assignment'));

    foreach ($assignments as $assignment) {
        $cm = get_coursemodule_from_id('assignment', $assignment->id);
        $event = new stdClass();
        $event->name        = $assignment->name;
        $event->description = format_module_intro('assignment', $assignment, $cm->id);
        $event->timestart   = $assignment->timedue;

        if ($event->id = $DB->get_field('event', 'id', array('modulename'=>'assignment', 'instance'=>$assignment->id))) {
            update_event($event);

        } else {
            $event->courseid    = $assignment->course;
            $event->groupid     = 0;
            $event->userid      = 0;
            $event->modulename  = 'assignment';
            $event->instance    = $assignment->id;
            $event->eventtype   = 'due';
            $event->timeduration = 0;
            $event->visible     = $DB->get_field('course_modules', 'visible', array('module'=>$moduleid, 'instance'=>$assignment->id));
            add_event($event);
        }

    }
    return true;
}
예제 #23
0
 /**
  * Update existing event and logs the action
  * @param int $eventid id in table personal_calendar
  * @param string $title event title
  * @param string $start event datetime
  * @param text $content event details
  */
 function update_recursive_event($eventid, $title, $start, $duration, $content, $recursion){
     global $langNotValidInput;
     $rec_eventid = Database::get()->querySingle('SELECT source_event_id FROM agenda WHERE id=?d',$eventid);
     if($rec_eventid){
         return update_event($rec_eventid, $title, $start, $duration, $content, $recursion, true);
     } else {
         return array('success'=>false, 'message'=>$langNotValidInput);
     }
 }
예제 #24
0
$app->get('/evento/novo', $authenticate($app), function () use($app) {
    $app->render('evento_novo.php', array('pageTitle' => _('Adicionar') . ' ' . get_setting('evento_singular')));
});
$app->post('/evento/novo', $authenticate($app), function () use($app) {
    $values = $app->request()->post('event');
    save_event($values);
    $app->redirect('/backoffice/eventos');
});
$app->get('/evento/editar/:id', $authenticate($app), function ($id) use($app) {
    $event = get_events_id($id);
    $app->render('evento_editar.php', array('event' => $event, 'pageTitle' => _('Editar') . ' ' . get_setting('evento_singular')));
});
// Guardar Evento Editar
$app->post('/evento/editar', $authenticate($app), function () use($app) {
    $event = $app->request()->post('event');
    update_event($event);
    $app->redirect('/backoffice/eventos');
});
//Deletes a event
$app->get('/evento/apagar/:id', $authenticate($app), function ($id) use($app) {
    delete_event($id);
    $app->redirect('/backoffice/eventos');
});
// Get the user page settings
$app->get('/defenicoes', $authenticate($app), function () use($app) {
    $app->render('defenicoes.php', array('pageTitle' => _('Definições')));
});
// Save defenicoes no website
$app->post('/defenicoes', $authenticate($app), function () use($app, $db) {
    $settings = $app->request()->post('settings');
    echo var_dump($settings);
예제 #25
0
 /**
  *
  * Updates a calendar event with new details
  * @param object $event a object containing details of an event tot be saved into a users calendar
  */
 function update_event($event)
 {
     global $CFG, $USER;
     if (stripos($CFG->release, "2.") !== false) {
         require_once $CFG->dirroot . '/calendar/lib.php';
         $calevent = calendar_event::load($event->id);
         return $calevent->update($event, false);
     } else {
         return update_event($event);
     }
 }
예제 #26
0
function list_events_action($uid)
{
    // needed to set the tab active
    $extras_active = true;
    $events_active = true;
    if (user_is_admin($uid)) {
        // dealing with event add form
        if (isset($_POST['description']) && isset($_POST['title'])) {
            $event_added = get_event_by_id($_POST['id']);
            // event exists
            if ($event_added) {
                update_event($_POST['id'], $_POST['title'], $_POST['description'], $_POST['date'], $_POST['max'], $_POST['registrationfee']);
            } else {
                add_event($_POST['title'], $_POST['description'], $_POST['date'], $_POST['max'], $_POST['registrationfee']);
            }
        }
        // get all the events
        $events = get_all_events();
        $uids = get_all_uids();
        require 'templates/events.php';
    } else {
        require 'templates/login.php';
    }
}
예제 #27
0
 /**
  * Updates a new assignment activity
  *
  * Given an object containing all the necessary data,
  * (defined by the form in mod.html) this function
  * will update the assignment instance and return the id number
  * The due date is updated in the calendar
  * This is common to all assignment types.
  *
  * @param $assignment object The data from the form on mod.html
  * @return int The assignment id
  */
 function update_instance($assignment)
 {
     global $COURSE;
     $assignment->timemodified = time();
     $assignment->id = $assignment->instance;
     $assignment->courseid = $assignment->course;
     if (!update_record('assignment', $assignment)) {
         return false;
     }
     if ($assignment->timedue) {
         $event = new object();
         if ($event->id = get_field('event', 'id', 'modulename', 'assignment', 'instance', $assignment->id)) {
             $event->name = $assignment->name;
             $event->description = $assignment->description;
             $event->timestart = $assignment->timedue;
             update_event($event);
         } else {
             $event = new object();
             $event->name = $assignment->name;
             $event->description = $assignment->description;
             $event->courseid = $assignment->course;
             $event->groupid = 0;
             $event->userid = 0;
             $event->modulename = 'assignment';
             $event->instance = $assignment->id;
             $event->eventtype = 'due';
             $event->timestart = $assignment->timedue;
             $event->timeduration = 0;
             add_event($event);
         }
     } else {
         delete_records('event', 'modulename', 'assignment', 'instance', $assignment->id);
     }
     // get existing grade item
     $assignment = stripslashes_recursive($assignment);
     assignment_grade_item_update($assignment);
     return true;
 }
/**
 * Make sure up-to-date events are created for all webquestscorm instances
 *
 * This standard function will check all instances of this module
 * and make sure there are up-to-date events created for each of them.
 * If courseid = 0, then every webquestscorm event in the site is checked, else
 * only webquestscorm events belonging to the course specified are checked.
 * This function is used, in its new format, by restore_refresh_events()
 *
 * @param $courseid int optional If zero then all webquestscorms for all courses are covered
 * @return boolean Always returns true
 */
function webquestscorm_refresh_events($courseid = 0)
{
    if ($courseid == 0) {
        if (!($webquestscorms = get_records("webquestscorm"))) {
            return true;
        }
    } else {
        if (!($webquestscorms = get_records("webquestscorm", "course", $courseid))) {
            return true;
        }
    }
    $moduleid = get_field('modules', 'id', 'name', 'webquestscorm');
    foreach ($webquestscorms as $webquestscorm) {
        $event = NULL;
        $event->name = addslashes($webquestscorm->name);
        $event->description = addslashes($webquestscorm->name);
        $event->timestart = $webquestscorm->timedue;
        if ($event->id = get_field('event', 'id', 'modulename', 'webquestscorm', 'instance', $webquestscorm->id)) {
            update_event($event);
        } else {
            $event->courseid = $webquestscorm->course;
            $event->groupid = 0;
            $event->userid = 0;
            $event->modulename = 'webquestscorm';
            $event->instance = $webquestscorm->id;
            $event->eventtype = 'due';
            $event->timeduration = 0;
            $event->visible = get_field('course_modules', 'visible', 'module', $moduleid, 'instance', $webquestscorm->id);
            add_event($event);
        }
    }
    return true;
}
예제 #29
0
파일: lib.php 프로젝트: ajv/Offline-Caching
/**
 * Updates chat records so that the next chat time is correct
 *
 * @global object
 * @param int $chatid
 * @return void
 */
function chat_update_chat_times($chatid = 0)
{
    /// Updates chat records so that the next chat time is correct
    global $DB;
    $timenow = time();
    $params = array('timenow' => $timenow, 'chatid' => $chatid);
    if ($chatid) {
        if (!($chats[] = $DB->get_record_select("chat", "id = :chatid AND chattime <= :timenow AND schedule > 0", $params))) {
            return;
        }
    } else {
        if (!($chats = $DB->get_records_select("chat", "chattime <= :timenow AND schedule > 0", $params))) {
            return;
        }
    }
    foreach ($chats as $chat) {
        switch ($chat->schedule) {
            case 1:
                // Single event - turn off schedule and disable
                $chat->chattime = 0;
                $chat->schedule = 0;
                break;
            case 2:
                // Repeat daily
                while ($chat->chattime <= $timenow) {
                    $chat->chattime += 24 * 3600;
                }
                break;
            case 3:
                // Repeat weekly
                while ($chat->chattime <= $timenow) {
                    $chat->chattime += 7 * 24 * 3600;
                }
                break;
        }
        $DB->update_record("chat", $chat);
        $event = new object();
        // Update calendar too
        $cond = "modulename='chat' AND instance = :chatid AND timestart <> :chattime";
        $params = array('chattime' => $chat->chattime, 'chatid' => $chatid);
        if ($event->id = $DB->get_field_select('event', 'id', $cond, $params)) {
            $event->timestart = $chat->chattime;
            update_event($event);
        }
    }
}
예제 #30
0
function url_action_calendar($tools, $get, $post)
{
    require_once $tools->include_path . 'cal_include.php';
    if (!$tools->logged_in()) {
        $tools->page_not_found();
    }
    /* get the current mailbox if any */
    $mailbox = $tools->get_mailbox();
    /* set the current mailbox */
    if ($mailbox) {
        $tools->set_mailbox($mailbox);
    }
    /* default values */
    $page_data = array();
    $week = false;
    $month = false;
    $today = date('m-d-Y');
    $year = false;
    $title = '';
    $detail = '';
    $repeat = 0;
    $duration = 0;
    $event_time = 0;
    $month_label = false;
    $day = false;
    $last_day = false;
    $events = array();
    $duration = '';
    $duration2 = '';
    $event_time = '';
    $event_time2 = '';
    $first_week_day = false;
    $all_events = array();
    $edit_id = 0;
    $dsp_page = 'calendar_month';
    $final_week = false;
    if (isset($post['calendar_add'])) {
        $req_flds = array('title', 'year', 'month', 'day');
        $opt_flds = array('repeat', 'detail', 'event_time', 'event_time2', 'duration', 'duration2');
        $cal_atts = normalize_input($req_flds, $opt_flds, $post);
        $cnt = count($req_flds) + count($opt_flds);
        if (count($cal_atts) == $cnt) {
            $edit_id = add_cal_event($cal_atts, $tools);
            if ($edit_id) {
                $tools->send_notice('Event Added');
                $dsp_page = 'edit';
            } else {
                $tools->send_notice('An error occured adding this event');
                $dsp_page = 'add';
            }
        } else {
            $dsp_page = 'add';
            foreach ($req_flds as $v) {
                if (isset($cal_atts[$v])) {
                    ${$v} = $cal_atts[$v];
                }
            }
            foreach ($opt_flds as $v) {
                if (isset($cal_atts[$v])) {
                    ${$v} = $cal_atts[$v];
                }
            }
        }
    } elseif (isset($post['calendar_update'])) {
        if (isset($post['event_id']) && ($event_id = $post['event_id'])) {
            $edit_id = $post['event_id'];
            $dsp_page = 'edit';
            $req_flds = array('title', 'year', 'month', 'day', 'event_id');
            $opt_flds = array('repeat', 'detail', 'event_time', 'event_time2', 'duration', 'duration2');
            $cal_atts = normalize_input($req_flds, $opt_flds, $post);
            $cnt = count($req_flds) + count($opt_flds);
            if (count($cal_atts) == $cnt) {
                $res = update_event($tools, $cal_atts);
                if ($res) {
                    $tools->send_notice('Event Updated');
                }
            }
        }
    } elseif (isset($post['calendar_delete'])) {
        if (isset($post['event_id']) && ($del_id = intval($post['event_id']))) {
            if (delete_event($tools, $del_id)) {
                calendar_init($tools);
                $tools->send_notice('Event Deleted');
                $dsp_page = 'calendar_month';
                $month = date('m');
                $year = date('Y');
                $month_label = strtolower(date('F'));
                $last_day = date('d', mktime(0, 0, 0, $month + 1, 0, $year));
                $first_week_day = date('w', mktime(0, 0, 0, $month, 1, $year));
                if ($first_week_day + $last_day > 36) {
                    $final_week = 6;
                } elseif ($first_week_day == 0 && $last_day == 28) {
                    $final_week = 4;
                } else {
                    $final_week = 5;
                }
            } else {
                $edit_id = $del_id;
                send_notice('Could not delete event');
            }
        }
    } elseif (isset($get['list_events'])) {
        $dsp_page = 'list_events';
        $all_events = get_calendar_events(false, false, false, 'all', $tools);
    } elseif (isset($get['add_event'])) {
        $dsp_page = 'add';
        foreach (array('year', 'month', 'day') as $v) {
            if (isset($get[$v])) {
                ${$v} = $get[$v];
            }
        }
    } elseif (isset($get['edit_event'])) {
        $dsp_page = 'edit';
        $edit_id = intval($get['edit_event']);
        foreach (array('year', 'month', 'day') as $v) {
            if (isset($get[$v])) {
                ${$v} = $get[$v];
            }
        }
    } elseif (isset($get['year']) && $get['year']) {
        if (preg_match("/^\\d{4}\$/", $get['year'])) {
            $year = $get['year'];
            $dsp_page = 'calendar_year';
            /* check for month in URL args */
            if (isset($get['month']) && $get['month']) {
                $month = strtotime($get['month']);
                if ($month && $month != -1) {
                    $month_label = $get['month'];
                    $month = date('m', $month);
                    $dsp_page = 'calendar_month';
                    $last_day = date('d', mktime(0, 0, 0, $month + 1, 0, $year));
                    $first_week_day = date('w', mktime(0, 0, 0, $month, 1, $year));
                    if ($first_week_day + $last_day > 36) {
                        $final_week = 6;
                    } elseif ($first_week_day == 0 && $last_day == 28) {
                        $final_week = 4;
                    } else {
                        $final_week = 5;
                    }
                    /* check for week in the URL args */
                    if (isset($get['week']) && $get['week']) {
                        if (preg_match("/^week([1-{$final_week}])\$/", $get['week'], $matches)) {
                            $dsp_page = 'calendar_week';
                            $week = $matches[1];
                            if ($week == 1) {
                                $last_month = strtolower(date('F', mktime(0, 0, 0, $month - 1, 1, $year)));
                                $last_int_month = strtolower(date('m', mktime(0, 0, 0, $month - 1, 1, $year)));
                                $last_year = date('Y', mktime(0, 0, 0, $month - 1, 1, $year));
                                $last_last_day = date('d', mktime(0, 0, 0, $last_int_month + 1, 0, $last_year));
                                $last_month_first_week_day = date('w', mktime(0, 0, 0, $last_int_month, 1, $last_year));
                                if ($last_month_first_week_day + $last_last_day > 36) {
                                    $last_final_week = 6;
                                } elseif ($first_week_day == 0 && $last_day == 28) {
                                    $last_final_week = 4;
                                } else {
                                    $last_final_week = 5;
                                }
                                $last_url = '?page=calendar&amp;year=' . $last_year . '&amp;month=' . $last_month . '&amp;week=week' . $last_final_week;
                                $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week2';
                            } elseif ($week == $final_week) {
                                $next_month = strtolower(date('F', mktime(0, 0, 0, $month + 1, 1, $year)));
                                $next_year = date('Y', mktime(0, 0, 0, $month + 1, 1, $year));
                                $next_url = '?page=calendar&amp;year=' . $next_year . '&amp;month=' . $next_month . '&amp;week=week1';
                                $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week' . ($week - 1);
                            } else {
                                $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week' . ($week + 1);
                                $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;week=week' . ($week - 1);
                            }
                            $page_data['last_url'] = $last_url;
                            $page_data['next_url'] = $next_url;
                        }
                    } elseif (isset($get['day']) && $get['day'] > 0 && $get['day'] <= $last_day) {
                        $dsp_page = 'calendar_day';
                        $day = $get['day'];
                        if ($day == $last_day) {
                            $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=' . ($day - 1);
                            if ($month == 12) {
                                $next_url = '?page=calendar&amp;year=' . ($year + 1) . '&amp;month=january&amp;day=1';
                            } else {
                                $next_month = strtolower(date("F", mktime(0, 0, 0, $month + 1, 1, $year)));
                                $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $next_month . '&amp;day=1';
                            }
                        } elseif ($day == 1) {
                            if ($month == 1) {
                                $last_url = '?page=calendar&amp;year=' . ($year - 1) . '&amp;month=december&amp;day=31';
                            } else {
                                $last_month = strtolower(date("F", mktime(0, 0, 0, $month - 1, 1, $year)));
                                $last_day = date("t", mktime(0, 0, 0, $month - 1, 1, $year));
                                $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $last_month . '&amp;day=' . $last_day;
                            }
                            $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=2';
                        } else {
                            $last_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=' . ($day - 1);
                            $next_url = '?page=calendar&amp;year=' . $year . '&amp;month=' . $month_label . '&amp;day=' . ($day + 1);
                        }
                        $page_data['last_url'] = $last_url;
                        $page_data['next_url'] = $next_url;
                    }
                }
            }
        }
    } else {
        $dsp_page = 'calendar_month';
        $month = date('m');
        $year = date('Y');
        $month_label = strtolower(date('F'));
        $last_day = date('d', mktime(0, 0, 0, $month + 1, 0, $year));
        $first_week_day = date('w', mktime(0, 0, 0, $month, 1, $year));
        if ($first_week_day + $last_day > 36) {
            $final_week = 6;
        } elseif ($first_week_day == 0 && $last_day == 28) {
            $final_week = 4;
        } else {
            $final_week = 5;
        }
    }
    if ($dsp_page != 'add' && $dsp_page != 'edit') {
        $events = get_calendar_events($month, $year, $day, $dsp_page, $tools);
    }
    if ($edit_id != 0 && $dsp_page == 'edit') {
        list($year, $month, $day, $event_time, $event_time2, $duration, $duration2, $title, $detail, $repeat) = get_cal_event($tools, $edit_id);
    }
    /* Build some more values for the display and stick everything into the $page_data array */
    $prev_month = strtolower(date('F', mktime(0, 0, 0, $month - 1, 1, $year)));
    $prev_month_url = '?page=calendar&amp;year=' . date('Y', mktime(0, 0, 0, $month - 1, 1, $year)) . '&amp;month=' . $prev_month;
    $next_month = strtolower(date('F', mktime(0, 0, 0, $month + 1, 1, $year)));
    $next_month_url = '?page=calendar&amp;year=' . date('Y', mktime(0, 0, 0, $month + 1, 1, $year)) . '&amp;month=' . $next_month;
    $page_data['cal_data'] = array('events' => $events, 'all_events' => $all_events, 'month' => $month, 'year' => $year, 'day' => $day, 'week' => $week, 'last_day' => $last_day, 'first_week_day' => $first_week_day, 'final_week' => $final_week, 'prev_month' => $prev_month, 'next_month' => $next_month, 'today' => $today, 'next_month_url' => $next_month_url, 'prev_month_url' => $prev_month_url, 'month_label' => $month_label);
    $page_data['dsp_page'] = $dsp_page;
    $page_data['title'] = $title;
    $page_data['detail'] = $detail;
    $page_data['event_time'] = $event_time;
    $page_data['duration'] = $duration;
    $page_data['repeat'] = $repeat;
    $page_data['duration'] = $duration;
    $page_data['duration2'] = $duration2;
    $page_data['event_time'] = $event_time;
    $page_data['event_time2'] = $event_time2;
    $page_data['edit_id'] = $edit_id;
    $tools->set_title($tools->str[1]);
    return $page_data;
}