Пример #1
0
/**
* @copyright	Copyright (C) 2015-2015 GWE Systems Ltd. All rights reserved.
 * @license		By negoriation with author via http://www.gwesystems.com
*/
function ProcessJsonRequest(&$requestObject, $returnData)
{
    //$file4 = JPATH_SITE . '/components/com_jevents/libraries/checkconflict.php';
    //if (JFile::exists($file4)) JFile::delete($file4);
    $returnData->allclear = 1;
    ini_set("display_errors", 0);
    $lang = JFactory::getLanguage();
    $lang->load("com_jevents", JPATH_SITE);
    $lang->load("com_jevents", JPATH_ADMINISTRATOR);
    include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php";
    $params = JComponentHelper::getParams("com_jevents");
    if (!$params->get("checkconflicts", 0)) {
        return $returnData;
    }
    // Do we ignore overlaps
    if (JEVHelper::isEventDeletor(true) && isset($requestObject->formdata->overlapoverride) && $requestObject->formdata->overlapoverride == 1) {
        return $returnData;
    }
    // Enforce referrer
    if (!$params->get("skipreferrer", 0)) {
        if (!array_key_exists("HTTP_REFERER", $_SERVER)) {
            PlgSystemGwejson::throwerror("There was an error - no referrer info available");
        }
        $live_site = $_SERVER['HTTP_HOST'];
        $ref_parts = parse_url($_SERVER["HTTP_REFERER"]);
        if (!isset($ref_parts["host"]) || $ref_parts["host"] . (isset($ref_parts["port"]) ? ':' . $ref_parts["port"] : '') != $live_site) {
            PlgSystemGwejson::throwerror("There was an error - missing host in referrer");
        }
    }
    if ($params->get("icaltimezonelive", "") != "" && is_callable("date_default_timezone_set") && $params->get("icaltimezonelive", "") != "") {
        $timezone = date_default_timezone_get();
        $tz = $params->get("icaltimezonelive", "");
        date_default_timezone_set($tz);
        $registry = JRegistry::getInstance("jevents");
        $registry->set("jevents.timezone", $timezone);
    }
    $token = JSession::getFormToken();
    if (!isset($requestObject->token) || strcmp($requestObject->token, $token) !== 0) {
        PlgSystemGwejson::throwerror("There was an error - bad token.  Please refresh the page and try again.");
    }
    $user = JFactory::getUser();
    if (!JEVHelper::isEventCreator()) {
        PlgSystemGwejson::throwerror("There was an error - not an event creator");
    }
    if (intval($requestObject->formdata->evid) > 0) {
        $db = JFactory::getDBO();
        $dataModel = new JEventsDataModel("JEventsAdminDBModel");
        $queryModel = new JEventsDBModel($dataModel);
        $event = $queryModel->getEventById(intval($requestObject->formdata->evid), 1, "icaldb");
        //$db->setQuery("SELECT * FROM #__jevents_vevent where ev_id=".intval($requestObject->formdata->evid));
        //	$event = $db->loadObject();
        if (!$event || !JEVHelper::canEditEvent($event)) {
            PlgSystemGwejson::throwerror("There was an error - cannot edit this event");
        }
    }
    $returnData->overlaps = array();
    if ($requestObject->pressbutton == "icalrepeat.apply" || $requestObject->pressbutton == "icalrepeat.save") {
        $testrepeat = simulateSaveRepeat($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkRepeatOverlaps($testrepeat, $returnData, intval($requestObject->formdata->evid), $requestObject);
    } else {
        $testevent = simulateSaveEvent($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkEventOverlaps($testevent, $returnData, intval($requestObject->formdata->evid), $requestObject);
    }
    if (count($overlaps) > 0) {
        $returnData->allclear = 0;
        foreach ($overlaps as $olp) {
            $overlap = new stdClass();
            $overlap->event_id = $olp->eventid;
            $overlap->eventdetail_id = $olp->eventdetail_id;
            $overlap->summary = $olp->summary;
            $overlap->rp_id = $olp->rp_id;
            $overlap->startrepeat = $olp->startrepeat;
            $overlap->endrepeat = $olp->endrepeat;
            list($y, $m, $d, $h, $m, $d) = sscanf($olp->startrepeat, "%d-%d-%d %d:%d:%d");
            $tstring = JText::_("JEV_OVERLAP_MESSAGE");
            $overlap->conflictMessage = sprintf($tstring, $olp->summary, JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->startrepeat)), JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->endrepeat)), $olp->conflictCause);
            $overlap->conflictMessage = addslashes($overlap->conflictMessage);
            $overlap->url = JURI::root() . "index.php?option=com_jevents&task=icalrepeat.detail&evid=" . $olp->rp_id . "&year={$y}&month={$m}&day={$d}";
            $overlap->url = str_replace("components/com_jevents/libraries/", "", $overlap->url);
            $returnData->overlaps[] = $overlap;
        }
    }
    if ($requestObject->error) {
        $returnData->allclear = 0;
        return "Error";
    }
    return $returnData;
}
function ProcessRequest(&$requestObject, $returnData)
{
    define("REQUESTOBJECT", serialize($requestObject));
    define("RETURNDATA", serialize($returnData));
    require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php';
    require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php';
    $requestObject = unserialize(REQUESTOBJECT);
    $returnData = unserialize(RETURNDATA);
    $returnData->allclear = 1;
    ini_set("display_errors", 0);
    global $option;
    $client = "site";
    if (isset($requestObject->client) && in_array($requestObject->client, array("site", "administrator"))) {
        $client = $requestObject->client;
    }
    $mainframe = JFactory::getApplication($client);
    JFactory::getApplication()->initialise();
    $option = "com_jevents";
    // Not sure why this is needed but it is if (use use $mainframe =& JFactory::getApplication($client); )!!!
    // needed for Joomla 1.5 plugins
    $GLOBALS['mainframe'] = $mainframe;
    $lang =& JFactory::getLanguage();
    $lang->load("com_jevents", JPATH_SITE);
    $lang->load("com_jevents", JPATH_ADMINISTRATOR);
    include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php";
    $params =& JComponentHelper::getParams("com_jevents");
    if (!$params->get("checkclashes", 0) && !$params->get("noclashes", 0)) {
        return $returnData;
    }
    // Enforce referrer
    if (!$params->get("skipreferrer", 0)) {
        if (!array_key_exists("HTTP_REFERER", $_SERVER)) {
            throwerror("There was an error");
        }
        $live_site = $_SERVER['HTTP_HOST'];
        $ref_parts = parse_url($_SERVER["HTTP_REFERER"]);
        if (!isset($ref_parts["host"]) || $ref_parts["host"] . (isset($ref_parts["port"]) ? ':' . $ref_parts["port"] : '') != $live_site) {
            throwerror("There was an error - missing host in referrer");
        }
    }
    if ($params->get("icaltimezonelive", "") != "" && is_callable("date_default_timezone_set") && $params->get("icaltimezonelive", "") != "") {
        $timezone = date_default_timezone_get();
        $tz = $params->get("icaltimezonelive", "");
        date_default_timezone_set($tz);
        $registry =& JRegistry::getInstance("jevents");
        $registry->setValue("jevents.timezone", $timezone);
    }
    $token = JUtility::getToken();
    if (!isset($requestObject->token) || $requestObject->token != $token) {
        throwerror("There was an error - bad token.  Please refresh the page and try again.");
    }
    $user = JFactory::getUser();
    if (!JEVHelper::isEventCreator()) {
        throwerror("There was an error");
    }
    if (intval($requestObject->formdata->evid) > 0) {
        $db = JFactory::getDBO();
        $dataModel = new JEventsDataModel("JEventsAdminDBModel");
        $queryModel = new JEventsDBModel($dataModel);
        $event = $queryModel->getEventById(intval($requestObject->formdata->evid), 1, "icaldb");
        //$db->setQuery("SELECT * FROM #__jevents_vevent where ev_id=".intval($requestObject->formdata->evid));
        //	$event = $db->loadObject();
        if (!$event || !JEVHelper::canEditEvent($event)) {
            throwerror("There was an error");
        }
    }
    $returnData->overlaps = array();
    if ($requestObject->pressbutton == "icalrepeat.apply" || $requestObject->pressbutton == "icalrepeat.save") {
        $testrepeat = simulateSaveRepeat($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkRepeatOverlaps($testrepeat, $returnData, intval($requestObject->formdata->evid), $requestObject);
    } else {
        $testevent = simulateSaveEvent($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkEventOverlaps($testevent, $returnData, intval($requestObject->formdata->evid), $requestObject);
    }
    if (count($overlaps) > 0) {
        $returnData->allclear = 0;
        foreach ($overlaps as $olp) {
            $overlap = new stdClass();
            $overlap->event_id = $olp->eventid;
            $overlap->eventdetail_id = $olp->eventdetail_id;
            $overlap->summary = $olp->summary;
            $overlap->rp_id = $olp->rp_id;
            $overlap->startrepeat = $olp->startrepeat;
            $overlap->endrepeat = $olp->endrepeat;
            list($y, $m, $d, $h, $m, $d) = sscanf($olp->startrepeat, "%d-%d-%d %d:%d:%d");
            $tstring = JText::_("JEV_OVERLAP_MESSAGE");
            $overlap->conflictMessage = sprintf($tstring, $olp->summary, JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->startrepeat)), JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->endrepeat)), $olp->conflictCause);
            $overlap->conflictMessage = addslashes($overlap->conflictMessage);
            $overlap->url = JURI::root() . "index.php?option=com_jevents&task=icalrepeat.detail&evid=" . $olp->rp_id . "&year={$y}&month={$m}&day={$d}";
            $overlap->url = str_replace("components/com_jevents/libraries/", "", $overlap->url);
            $returnData->overlaps[] = $overlap;
        }
    }
    if ($requestObject->error) {
        $returnData->allclear = 0;
        return "Error";
    }
    return $returnData;
}
Пример #3
0
function ProcessRequest(&$requestObject, $returnData)
{
    define("REQUESTOBJECT", serialize($requestObject));
    define("RETURNDATA", serialize($returnData));
    require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php';
    require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php';
    $requestObject = unserialize(REQUESTOBJECT);
    $returnData = unserialize(RETURNDATA);
    $returnData->allclear = 1;
    ini_set("display_errors", 0);
    global $option;
    $client = "site";
    if (isset($requestObject->client) && in_array($requestObject->client, array("site", "administrator"))) {
        $client = $requestObject->client;
    }
    $mainframe = JFactory::getApplication($client);
    JFactory::getApplication()->initialise();
    $option = "com_jevents";
    // Not sure why this is needed but it is if (use use $mainframe =& JFactory::getApplication($client); )!!!
    //$GLOBALS['mainframe']=$mainframe;
    $params =& JComponentHelper::getParams("com_jevents");
    if (!$params->get("checkclashes", 0) && !$params->get("noclashes", 0)) {
        return $returnData;
    }
    if ($params->get("icaltimezonelive", "") != "" && is_callable("date_default_timezone_set")) {
        $timezone = date_default_timezone_get();
        date_default_timezone_set($params->get("icaltimezonelive", ""));
    }
    $token = JUtility::getToken();
    if (!isset($requestObject->token) || $requestObject->token != $token) {
        throwerror("There was an error - bad token.  Please refresh the page and try again.");
    }
    $user = JFactory::getUser();
    if ($user->id == 0) {
        throwerror("There was an error");
    }
    if (intval($requestObject->formdata->evid) > 0) {
        $db = JFactory::getDBO();
        $db->setQuery("SELECT * FROM #__jevents_vevent where ev_id=" . intval($requestObject->formdata->evid));
        $event = $db->loadObject();
        if (!$event || $event->created_by != $user->id && $user->usertype != "Super Administrator") {
            throwerror("There was an error");
        }
    }
    $returnData->overlaps = array();
    if ($requestObject->pressbutton == "icalrepeat.apply" || $requestObject->pressbutton == "icalrepeat.save") {
        $testrepeat = simulateSaveRepeat($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkRepeatOverlaps($testrepeat, $returnData, intval($requestObject->formdata->evid));
    } else {
        $testevent = simulateSaveEvent($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkEventOverlaps($testevent, $returnData, intval($requestObject->formdata->evid));
    }
    if (count($overlaps) > 0) {
        $returnData->allclear = 0;
        foreach ($overlaps as $olp) {
            $overlap = new stdClass();
            $overlap->event_id = $olp->eventid;
            $overlap->eventdetail_id = $olp->eventdetail_id;
            $overlap->summary = $olp->summary;
            $overlap->rp_id = $olp->rp_id;
            $overlap->startrepeat = $olp->startrepeat;
            $overlap->endrepeat = $olp->endrepeat;
            list($y, $m, $d, $h, $m, $d) = sscanf($olp->startrepeat, "%d-%d-%d %d:%d:%d");
            $overlap->url = JURI::root() . "index.php?option=com_jevents&task=icalrepeat.detail&evid=" . $olp->rp_id . "&year={$y}&month={$m}&day={$d}";
            $overlap->url = str_replace("components/com_jevents/libraries/", "", $overlap->url);
            $returnData->overlaps[] = $overlap;
        }
    }
    if ($requestObject->error) {
        return "Error";
        $returnData->allclear = 0;
    }
    return $returnData;
}