Ejemplo n.º 1
0
 public static function ClosestEvents()
 {
     $Events = Events::getEvents();
     $ClosestEvents = [];
     $CurrentDate = date('Y-m-d');
     // Soon
     foreach ($Events as $Event) {
         if (isset($Event['next_start'])) {
             $EventBeginDate = date('Y-m-d', strtotime($Event['next_start']));
             $LimitStartDate = Events::setTimeLimitStart('- 1 week', $CurrentDate);
             $LimitEndDate = Events::setTimeLimitEnd('+ 1 day', $CurrentDate);
             if ($LimitStartDate < $EventBeginDate && $EventBeginDate < $LimitEndDate && $CurrentDate < $Event['next_end']) {
                 $ClosestEvents['today'][] = $Event;
             }
         }
     }
     // This Week
     foreach ($Events as $Event) {
         if (isset($Event['next_start'])) {
             $EventBeginDate = date('Y-m-d', strtotime('+ 1 week', strtotime($Event['next_start'])));
             $LimitStartDate = Events::setTimeLimitStart('+ 2 day', $CurrentDate);
             $LimitEndDate = Events::setTimeLimitEnd('+ 3 week', $CurrentDate);
             if ($LimitStartDate < $EventBeginDate && $EventBeginDate < $LimitEndDate) {
                 $ClosestEvents['soon'][] = $Event;
             }
         }
     }
     return $ClosestEvents;
 }
Ejemplo n.º 2
0
function getEvents()
{
    $arr_submit = array(array('start'), array('end'));
    $frm_submitted = $arr_submit;
    if (!$error) {
        $arr_content = Events::getEvents($frm_submitted);
    } else {
        $arr_content = array();
    }
    echo json_encode($arr_content);
}
Ejemplo n.º 3
0
function getEvents()
{
    global $error;
    $arr_submit = array(array('cal_id', 'string', false, ''), array('start', 'int', true, ''), array('end', 'int', true, ''), array('sd', 'string', false, ''), array('ft', 'string', false, ''));
    $frm_submitted = validate_var($arr_submit);
    if (!$error) {
        if (isset($_SESSION['fast-easy-calender-sd'])) {
            $frm_submitted['sd'] = '';
            $frm_submitted['ft'] = '';
            unset($_SESSION['fast-easy-calender-sd']);
        } else {
            $_SESSION['fast-easy-calender-sd'] = true;
        }
        $arr_content = Events::getEvents($frm_submitted);
    } else {
        $arr_content = array();
    }
    echo json_encode($arr_content);
}
Ejemplo n.º 4
0
         header('Location: /game/profession');
     }
     $Profession = Professions::GetProfession($_REQUEST['lastcategory']);
     $Smarty->assign('Profession', $Profession);
     $Smarty->assign('Navigation', Professions::GetNavigation($Profession['id']));
     $Smarty->assign('Page', Page::Info('profession', array('bodycss' => 'profession-page profession-' . $_REQUEST['lastcategory'] . '', 'pagetitle' => $Profession['profession_translation'] . ' - ' . $Smarty->GetConfigVars('Menu_Game') . ' - ')));
     $Smarty->display('pages/game_profession');
 } elseif ($_REQUEST['subcategory'] == 'events') {
     Manager::LoadExtension('Events', $ClassConstructor);
     $Smarty->translate('Events');
     $EventName = $_REQUEST['lastcategory'];
     $EventData = Events::getEventData($EventName);
     if (!$EventData) {
         header('Location: /game/events');
     } else {
         $Events = Events::getEvents();
         $PageEventData = [];
         foreach ($Events as $Event) {
             if (isset($Event['description'])) {
                 $EventName = str_replace('\'', '', $Event['description']);
                 if (trim($EventData['name']) == trim($EventName)) {
                     $PageEventData = $Event;
                 }
             }
         }
         $Smarty->assign('DData', $PageEventData);
         $Smarty->assign('Event', $EventData);
         $Smarty->assign('Page', Page::Info('game', array('bodycss' => 'page view-page', 'pagetitle' => $EventData['name'] . ' - ')));
         $Smarty->display('pages/game_event_data');
     }
 }
Ejemplo n.º 5
0
 public function testGetEvents()
 {
     TestingAuxLib::loadX2NonWebUser();
     TestingAuxLib::suLogin('admin');
     Yii::app()->settings->historyPrivacy = null;
     $lastEventId = 0;
     $lastTimestamp = 0;
     $events = Events::getEvents($lastEventId, $lastTimestamp, 4);
     $this->assertEquals(Yii::app()->db->createCommand("select id from x2_events order by timestamp desc, id desc limit 4")->queryColumn(), array_map(function ($event) {
         return $event->id;
     }, $events['events']));
 }
Ejemplo n.º 6
0
 public function actionGetEvents($lastEventId, $lastTimestamp, $myProfileId, $profileId)
 {
     // validate params
     if (!ctype_digit($lastEventId) || !ctype_digit($lastTimestamp) || !ctype_digit($myProfileId) || !ctype_digit($profileId)) {
         throw new CHttpException(400, Yii::t('app', 'Invalid parameter'));
     }
     $myProfile = Profile::model()->findByPk($myProfileId);
     $profile = Profile::model()->findByPk($profileId);
     if (!isset($myProfile) || !isset($profile)) {
         return false;
     }
     $result = Events::getEvents($lastEventId, $lastTimestamp, null, $profile, $myProfile->id === $profile->id);
     $events = $result['events'];
     $eventData = "";
     $newLastEventId = $lastEventId;
     $newLastTimestamp = $lastTimestamp;
     foreach ($events as $event) {
         if ($event instanceof Events) {
             if ($event->id > $newLastEventId) {
                 $newLastEventId = $event->id;
             }
             if ($event->timestamp > $newLastTimestamp) {
                 $newLastTimestamp = $event->timestamp;
             }
             $eventData .= $this->renderPartial('application.views.profile._viewEvent', array('data' => $event, 'noDateBreak' => true, 'profileId' => $profileId), true);
         }
     }
     $commentCriteria = new CDbCriteria();
     $sqlParams = array(':lastEventId' => $lastEventId);
     $condition = "associationType='Events' AND \n            timestamp <=" . time() . " AND id > :lastEventId";
     $parameters = array('order' => 'id ASC');
     $parameters['condition'] = $condition;
     $parameters['params'] = $sqlParams;
     $commentCriteria->scopes = array('findAll' => array($parameters));
     $comments = X2Model::model('Events')->findAll($commentCriteria);
     $commentCounts = array();
     $lastCommentId = $lastEventId;
     foreach ($comments as $comment) {
         $parentPost = X2Model::model('Events')->findByPk($comment->associationId);
         if (isset($parentPost) && !isset($commentCounts[$parentPost->id])) {
             $commentCounts[$parentPost->id] = count($parentPost->children);
         }
         $lastCommentId = $comment->id;
     }
     echo CJSON::encode(array($newLastEventId, $newLastEventId != $lastEventId ? $eventData : '', $commentCounts, $lastCommentId, $newLastTimestamp));
 }
Ejemplo n.º 7
0
function getEvents()
{
    global $error;
    $arr_submit = array(array('start', 'int', true, ''), array('end', 'int', true, ''));
    $frm_submitted = validate_var($arr_submit);
    if (!$error) {
        $arr_content = Events::getEvents($frm_submitted);
    } else {
        $arr_content = array();
    }
    echo json_encode($arr_content);
}
Ejemplo n.º 8
0
function getEvents($inputs)
{
    include "Events.php";
    $event = new Events();
    $event->getEvents($inputs[0]);
}
Ejemplo n.º 9
0
define("FILE_OUTPUT", "/index.html");
define("TEN_WORD_USER", "workingwithme");
define("TWITTER_USERNAME", "NeilCrosby");
date_default_timezone_set('UTC');
function __autoload($class_name)
{
    require_once 'classes/' . $class_name . '.php';
}
$eventsObj = new Events(INPUT_EVENTS);
$flickr = getHtmlForStream('flickr', INPUT_RSS_FLICKR, 7);
$considered = getHtmlForStream('considered', INPUT_RSS_CONSIDERED, 5);
$stream = '';
//getHtmlForStream('consciousness', INPUT_RSS_CONSCIOUSNESS,    20);
$others = '';
//getHtmlForStream('otherssaid',    INPUT_RSS_OTHERS_SAID,      30);
$events = $eventsObj->getEvents();
if (!$flickr || !$considered) {
    error_log("some data didn't return");
    return;
}
mb_internal_encoding("UTF-8");
$template = getTemplate();
$template = str_replace(array('##flickr##', '##consideredthoughts##', '##streamofconsciousness##', '##otherssaid##', '###events###'), array($flickr, $considered, $stream, $others, $events), $template);
saveOutput($template);
$server = 80 == $_SERVER['SERVER_PORT'] ? $_SERVER['SERVER_NAME'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'];
if (!isset($_GET['no_redirect'])) {
    header("Location: http://{$server}/");
}
exit;
function getTemplate()
{
Ejemplo n.º 10
0
 /**
  * Obtain all current notifications/events for the current web user.
  */
 public function actionGet()
 {
     if (Yii::app()->user->isGuest) {
         header('Content-type: application/json');
         echo CJSON::encode(array('sessionError' => Yii::t('app', 'Your X2Engine session has expired. You may select "cancel" to ignore this message and recover unsaved data from the current page. Otherwise, you will be redirected to the login page.')));
         Yii::app()->end();
     }
     if (!isset($_GET['lastNotifId'])) {
         // if the client doesn't specify the last
         $_GET['lastNotifId'] = 0;
     }
     // message ID received, send everything
     $notifications = $this->getNotifications($_GET['lastNotifId']);
     $notifCount = 0;
     if (count($notifications)) {
         $notifCount = X2Model::model('Notification')->countByAttributes(array('user' => Yii::app()->user->name), 'createDate < ' . time());
     }
     $chatMessages = array();
     $lastEventId = 0;
     $lastTimestamp = 0;
     // if the client specifies the last message ID received,
     if (isset($_GET['lastEventId']) && is_numeric($_GET['lastEventId'])) {
         // only send newer messages
         $lastEventId = $_GET['lastEventId'];
     }
     if (isset($_GET['lastTimestamp']) && is_numeric($_GET['lastTimestamp'])) {
         $lastTimestamp = $_GET['lastTimestamp'];
     }
     if ($lastEventId == 0) {
         // get page of newest events
         $retVal = Events::getFilteredEventsDataProvider(null, true, null, isset($_SESSSION['filters']));
         $dataProvider = $retVal['dataProvider'];
         $events = $dataProvider->getData();
     } else {
         // get new events
         $limit = null;
         $result = Events::getEvents($lastEventId, $lastTimestamp, $limit);
         $events = $result['events'];
     }
     $i = count($events) - 1;
     for ($i; $i > -1; --$i) {
         if (isset($events[$i])) {
             $userLink = '<span class="widget-event">' . $events[$i]->user . '</span>';
             $chatMessages[] = array((int) $events[$i]->id, (int) $events[$i]->timestamp, $userLink, $events[$i]->getText(array('truncated' => true)), Formatter::formatFeedTimestamp($events[$i]->timestamp));
         }
     }
     if (!empty($notifications) || !empty($chatMessages)) {
         header('Content-type: application/json');
         echo CJSON::encode(array('notifCount' => $notifCount, 'notifData' => $notifications, 'chatData' => $chatMessages));
     }
 }
Ejemplo n.º 11
0
<?php

require "Events.php";
// Look for a valid action
if (isset($_GET['method'])) {
    switch ($_GET['method']) {
        case "eventList":
            $events = new Events();
            $data = $events->getEvents();
            break;
        case "event":
            $event_id = (int) $_GET['event_id'];
            $events = new Events();
            $data = $events->getEventById($event_id);
            break;
        default:
            http_response_code(400);
            $data = array("error" => "bad request");
            break;
    }
} else {
    http_response_code(400);
    $data = array("error" => "bad request");
}
// let's send the data back
header("Content-Type: application/json");
echo json_encode($data);
Ejemplo n.º 12
0
<?php

//require_once 'core/DB.php';
require_once 'config.php';
require_once 'core/EventModel.php';
class Events extends EventModel
{
    public function __construct()
    {
        parent::__construct();
    }
    public function getEvents()
    {
        $u = $this->db->select('events', '*');
        print $u[0]['text'];
    }
}
$obj = new Events();
$obj->getEvents();