Example #1
0
function calendar_print($data, $template)
{
    global $set, $db, $apx, $user;
    $tmpl = new tengine();
    $parse = $tmpl->used_vars($template, 'calendar');
    //Kategorie-Info
    $catids = get_ids($data, 'catid');
    $catdata = array();
    if (count($catids)) {
        $catdata = $db->fetch_index("SELECT * FROM " . PRE . "_calendar_cat WHERE id IN (" . implode(',', $catids) . ")", 'id');
    }
    //Termine auflisten
    if (count($data)) {
        foreach ($data as $res) {
            ++$i;
            $event = array();
            //Kategorie-Info
            $catinfo = $catdata[$res['catid']];
            //Link zum Termin
            $link = mklink('events.php?id=' . $res['id'], 'events,id' . $res['id'] . urlformat($res['title']) . '.html');
            //Aufmacher
            $picture = $picture_popup = '';
            if (in_template(array('EVENT.PICTURE', 'EVENT.PICTURE_POPUP', 'EVENT.PICTURE_POPUPPATH'), $parse)) {
                list($picture, $picture_popup, $picture_popuppath) = calendar_pic($res['picture']);
            }
            //Start berechnen
            $startday = $starttime = $endday = $endtime = 0;
            if (in_template(array('EVENT.STARTDAY', 'EVENT.STARTTIME'), $parse)) {
                $startday = calendar_stamp2time($res['startday']);
                if ($res['starttime'] != -1) {
                    $time_comp = calendar_explode_stamp($res['startday']);
                    $tmpstamp = sprintf('%04d', $res['starttime']);
                    $time_comp['hour'] = substr($tmpstamp, 0, 2);
                    $time_comp['minute'] = substr($tmpstamp, 2, 2);
                    $starttime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
                }
            }
            //Ende berechnen (falls nötig)
            if (in_template(array('EVENT.ENDDAY', 'EVENT.ENDTIME'), $parse)) {
                if ($res['endday'] != $res['startday'] || $res['endtime'] != -1) {
                    $endday = calendar_stamp2time($res['endday']);
                    if ($res['endtime'] != -1) {
                        $time_comp = calendar_explode_stamp($res['endday']);
                        $tmpstamp = sprintf('%04d', $res['endtime']);
                        $time_comp['hour'] = substr($tmpstamp, 0, 2);
                        $time_comp['minute'] = substr($tmpstamp, 2, 2);
                        $endtime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
                    }
                }
            }
            //Username + eMail
            if ($res['userid']) {
                $username = $res['username'];
                $email = iif(!$res['pub_hidemail'], $res['email']);
            } else {
                $username = $res['send_username'];
                $email = $res['send_email'];
            }
            //Text
            $eventtext = '';
            if (in_array('EVENT.TEXT', $parse)) {
                $eventtext = mediamanager_inline($res['text']);
                if ($apx->is_module('glossar')) {
                    $eventtext = glossar_highlight($eventtext);
                }
            }
            //Datehead
            if ($laststamp != $res['startday']) {
                $event['DATEHEAD'] = $startday;
            }
            //Tags
            if (in_array('EVENT.TAG', $parse) || in_array('EVENT.TAG_IDS', $parse) || in_array('EVENT.KEYWORDS', $parse)) {
                list($tagdata, $tagids, $keywords) = calendar_tags($res['id']);
            }
            $event['ID'] = $res['id'];
            $event['TITLE'] = $res['title'];
            $event['TEXT'] = $eventtext;
            $event['LINK'] = $link;
            $event['LOCATION'] = compatible_hsc($res['location']);
            $event['LOCATION_LINK'] = compatible_hsc($res['location_link']);
            $event['PRIORITY'] = $res['priority'];
            $event['RESTRICTED'] = $res['restricted'];
            $event['PRIVATE'] = $res['private'];
            $event['HITS'] = $res['hits'];
            $event['RELATED'] = calendar_links($res['links']);
            $event['PICTURE'] = $picture;
            $event['PICTURE_POPUP'] = $picture_popup;
            $event['PICTURE_POPUPPATH'] = $picture_popuppath;
            $event['STARTDAY'] = $startday;
            $event['STARTTIME'] = $starttime;
            $event['ENDDAY'] = $endday;
            $event['ENDTIME'] = $endtime;
            $event['USERID'] = $res['userid'];
            $event['USERNAME'] = replace($username);
            $event['EMAIL'] = replace($email);
            $event['EMAIL_ENCRYPTED'] = replace(cryptMail($email));
            $event['CATID'] = $res['catid'];
            $event['CATTITLE'] = $catinfo['title'];
            $event['CATICON'] = $catinfo['icon'];
            //Tags
            $event['TAG'] = $tagdata;
            $event['TAG_IDS'] = $tagids;
            $event['KEYWORDS'] = $keywords;
            //Galerie
            if ($apx->is_module('gallery') && $res['galid'] && !$res['private'] && in_template(array('EVENT.GALLERY_ID', 'EVENT.GALLERY_TITLE', 'EVENT.GALLERY_LINK'), $parse)) {
                $galinfo = gallery_info($res['galid']);
                $event['GALLERY_ID'] = $galinfo['id'];
                $event['GALLERY_TITLE'] = $galinfo['title'];
                $event['GALLERY_LINK'] = mklink('gallery.php?id=' . $galinfo['id'], 'gallery,list' . $galinfo['id'] . ',1' . urlformat($galinfo['title']) . '.html');
            }
            //Kommentare
            if ($apx->is_module('comments') && $set['calendar']['coms'] && $res['allowcoms']) {
                require_once BASEDIR . getmodulepath('comments') . 'class.comments.php';
                if (!isset($coms)) {
                    $coms = new comments('calendar', $res['id']);
                } else {
                    $coms->mid = $res['id'];
                }
                $link = mklink('events.php?id=' . $res['id'], 'events,id' . $res['id'] . urlformat($res['title']) . '.html');
                $event['COMMENT_COUNT'] = $coms->count();
                $event['COMMENT_LINK'] = $coms->link($link);
                $event['DISPLAY_COMMENTS'] = 1;
                if (in_template(array('EVENT.COMMENT_LAST_USERID', 'EVENT.COMMENT_LAST_NAME', 'EVENT.COMMENT_LAST_TIME'), $parse)) {
                    $event['COMMENT_LAST_USERID'] = $coms->last_userid();
                    $event['COMMENT_LAST_NAME'] = $coms->last_name();
                    $event['COMMENT_LAST_TIME'] = $coms->last_time();
                }
            }
            $eventdata[$i] = $event;
            $laststamp = $res['startday'];
        }
    }
    $tmpl->assign('EVENT', $eventdata);
    $tmpl->parse($template, 'calendar');
}
Example #2
0
function calendar_events_from_day($thisdaystamp, $parse, $parseprefix = 'DAY.')
{
    global $set, $apx, $db, $user;
    static $eventcache, $catdata;
    if (!isset($eventcache)) {
        $eventcache = array();
    }
    //Termin-Kategorien auslesen
    if (!isset($catdata)) {
        $catdata = array();
        if (in_template(array($parseprefix . 'EVENT.CATTITLE', $parseprefix . 'EVENT.CATICON'), $parse)) {
            $catdata = $db->fetch_index("SELECT * FROM " . PRE . "_calendar_cat", 'id');
        }
    }
    //Modefilter
    if ($_REQUEST['mode'] == 'private') {
        $modefilter = " AND a.private='1' AND a.userid='" . $user->info['userid'] . "' ";
    } else {
        $modefilter = " AND a.private='0' ";
    }
    //Sortby
    if ($set['calendar']['sortby'] == 2) {
        $sortby = " title ASC ";
    } else {
        $sortby = " startday DESC, starttime ASC ";
    }
    //Termine auslesen
    $edata = $db->fetch("SELECT a.*,b.username FROM " . PRE . "_calendar_events AS a LEFT JOIN " . PRE . "_user AS b USING(userid) WHERE '" . $thisdaystamp . "' BETWEEN startday AND endday AND a.active!=0 " . section_filter(true, 'a.secid') . " " . $modefilter . " ORDER BY " . $sortby);
    $eventdata = array();
    if (count($edata)) {
        foreach ($edata as $res) {
            ++$i;
            //Termin wurde schon verarbeitet => Übernehmen und fertig
            if (isset($eventcache[$res['id']])) {
                $eventdata[$i] = $eventcache[$res['id']];
                continue;
            }
            //Kategorie-Info
            $catinfo = $catdata[$res['catid']];
            //Link zum Termin
            $link = mklink('events.php?id=' . $res['id'], 'events,id' . $res['id'] . urlformat($res['title']) . '.html');
            //Aufmacher
            $picture = $picture_popup = $picture_popuppath = '';
            if (in_template(array($parseprefix . 'EVENT.PICTURE', $parseprefix . 'EVENT.PICTURE_POPUP', $parseprefix . 'EVENT.PICTURE_POPUPPATH'), $parse)) {
                list($picture, $picture_popup, $picture_popuppath) = calendar_pic($res['picture']);
            }
            //Start berechnen
            $startday = $starttime = $endday = $endtime = 0;
            if (in_template(array($parseprefix . 'EVENT.STARTDAY', $parseprefix . 'EVENT.STARTTIME'), $parse)) {
                $startday = calendar_stamp2time($res['startday']);
                if ($res['starttime'] != -1) {
                    $time_comp = calendar_explode_stamp($res['startday']);
                    $tmpstamp = sprintf('%04d', $res['starttime']);
                    $time_comp['hour'] = substr($tmpstamp, 0, 2);
                    $time_comp['minute'] = substr($tmpstamp, 2, 2);
                    $starttime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
                }
            }
            //Ende berechnen (falls nötig)
            if (in_template(array($parseprefix . 'EVENT.ENDDAY', $parseprefix . 'EVENT.ENDTIME'), $parse)) {
                if ($res['endday'] != $res['startday'] || $res['endtime'] != -1) {
                    $endday = calendar_stamp2time($res['endday']);
                    if ($res['endtime'] != -1) {
                        $time_comp = calendar_explode_stamp($res['endday']);
                        $tmpstamp = sprintf('%04d', $res['endtime']);
                        $time_comp['hour'] = substr($tmpstamp, 0, 2);
                        $time_comp['minute'] = substr($tmpstamp, 2, 2);
                        $endtime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
                    }
                }
            }
            //Username + eMail
            if ($res['userid']) {
                $username = $res['username'];
                $email = iif(!$res['pub_hidemail'], $res['email']);
            } else {
                $username = $res['send_username'];
                $email = $res['send_email'];
            }
            //Text
            $eventtext = '';
            if (in_array($parseprefix . 'EVENT.TEXT', $parse)) {
                $eventtext = mediamanager_inline($res['text']);
            }
            //Tags
            if (in_array($parseprefix . 'EVENT.TAG', $parse) || in_array($parseprefix . 'EVENT.TAG_IDS', $parse) || in_array($parseprefix . 'EVENT.KEYWORDS', $parse)) {
                list($tagdata, $tagids, $keywords) = calendar_tags($res['id']);
            }
            $event = array();
            $event['ID'] = $res['id'];
            $event['TITLE'] = $res['title'];
            $event['TEXT'] = $eventtext;
            $event['LINK'] = $link;
            $event['PRIORITY'] = $res['priority'];
            $event['RESTRICTED'] = $res['restricted'];
            $event['LOCATION'] = compatible_hsc($res['location']);
            $event['LOCATION_LINK'] = compatible_hsc($res['location_link']);
            $event['PRIVATE'] = $res['private'];
            $event['HITS'] = $res['hits'];
            $event['RELATED'] = calendar_links($res['links']);
            $event['PICTURE'] = $picture;
            $event['PICTURE_POPUP'] = $picture_popup;
            $event['PICTURE_POPUPPATH'] = $picture_popuppath;
            $event['STARTDAY'] = $startday;
            $event['STARTTIME'] = $starttime;
            $event['ENDDAY'] = $endday;
            $event['ENDTIME'] = $endtime;
            $event['USERID'] = $res['userid'];
            $event['USERNAME'] = replace($username);
            $event['EMAIL'] = replace($email);
            $event['EMAIL_ENCRYPTED'] = replace(cryptMail($email));
            $event['CATID'] = $res['catid'];
            $event['CATTITLE'] = $catinfo['title'];
            $event['CATICON'] = $catinfo['icon'];
            //Tags
            $event['TAG'] = $tagdata;
            $event['TAG_IDS'] = $tagids;
            $event['KEYWORDS'] = $keywords;
            $eventcache[$res['id']] = $event;
            $eventdata[$i] = $event;
        }
    }
    return $eventdata;
}
Example #3
0
function calendar_stamp2time($stamp)
{
    $info = calendar_explode_stamp($stamp);
    return mktime(0, 0, 0, $info['month'], $info['day'], $info['year']) + TIMEDIFF;
}
Example #4
0
function misc_eventsfeed()
{
    global $set, $db, $apx;
    $apx->tmpl->loaddesign('blank');
    header('Content-type: application/rss+xml');
    //Baum holen, wenn nur eine bestimmte Kategorie gezeigt werden soll
    $cattree = calendar_tree($_REQUEST['catid']);
    if ($catid) {
        $cattree = calendar_tree($catid);
        if (count($cattree)) {
            $catfilter = " AND a.catid IN (" . implode(',', $cattree) . ") ";
        }
    }
    $todaystamp = date('Ymd', time() - TIMEDIFF);
    $data = $db->fetch("SELECT a.*,b.username,b.email,b.pub_hidemail FROM " . PRE . "_calendar_events AS a LEFT JOIN " . PRE . "_user AS b USING(userid) WHERE a.active!=0 AND a.private='0' AND '" . $todaystamp . "'<=endday " . section_filter(true, 'a.secid') . " " . $catfilter . $modefilter . " ORDER BY startday ASC, starttime ASC, title ASC LIMIT 20");
    //Kategorie-Info
    $catids = get_ids($data, 'catid');
    $catdata = array();
    if (count($catids)) {
        $catdata = $db->fetch_index("SELECT * FROM " . PRE . "_calendar_cat WHERE id IN (" . implode(',', $catids) . ")", 'id');
    }
    if (count($data)) {
        foreach ($data as $res) {
            ++$i;
            $event = array();
            //Kategorie-Info
            $catinfo = $catdata[$res['catid']];
            //Link zum Termin
            $link = mklink('events.php?id=' . $res['id'], 'events,id' . $res['id'] . urlformat($res['title']) . '.html');
            //Start berechnen
            $startday = $starttime = $endday = $endtime = 0;
            $startday = calendar_stamp2time($res['startday']);
            if ($res['starttime'] != -1) {
                $time_comp = calendar_explode_stamp($res['startday']);
                $tmpstamp = sprintf('%04d', $res['starttime']);
                $time_comp['hour'] = substr($tmpstamp, 0, 2);
                $time_comp['minute'] = substr($tmpstamp, 2, 2);
                $starttime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
            }
            //Ende berechnen (falls nötig)
            if ($res['endday'] != $res['startday'] || $res['endtime'] != -1) {
                $endday = calendar_stamp2time($res['endday']);
                if ($res['endtime'] != -1) {
                    $time_comp = calendar_explode_stamp($res['endday']);
                    $tmpstamp = sprintf('%04d', $res['endtime']);
                    $time_comp['hour'] = substr($tmpstamp, 0, 2);
                    $time_comp['minute'] = substr($tmpstamp, 2, 2);
                    $endtime = mktime($time_comp['hour'], $time_comp['minute'], 0, $time_comp['month'], $time_comp['day'], $time_comp['year']) + TIMEDIFF;
                }
            }
            $event['ID'] = $res['id'];
            $event['TITLE'] = rss_replace($res['title']);
            $event['TEXT'] = rss_replace($res['text']);
            $event['LINK'] = HTTP_HOST . $link;
            $event['LOCATION'] = $res['location'];
            $event['LOCATION_LINK'] = $res['location_link'];
            $event['STARTDAY'] = $startday;
            $event['STARTTIME'] = $starttime;
            $event['ENDDAY'] = $endday;
            $event['ENDTIME'] = $endtime;
            $event['ADDTIME'] = $res['addtime'];
            $event['TIME'] = date('r', $res['addtime']);
            $event['CATID'] = $res['catid'];
            $event['CATTITLE'] = $catinfo['title'];
            $event['CATICON'] = $catinfo['icon'];
            $tabledata[] = $event;
        }
    }
    $apx->tmpl->assign('WEBSITENAME', $set['main']['websitename']);
    $apx->tmpl->assign('EVENT', $tabledata);
    $apx->tmpl->parse('rss', 'calendar');
}