Exemple #1
0
 public static function getSelectedCategories($timespan = "today", $agenda_fid = array(), $nolimit = false, $skipexcluded = true)
 {
     if (empty($agenda_fid)) {
         return array();
     }
     $agenda_records = array();
     //if (IS_TESTSERVER) {echo "<br><br>AGENDA FIDS in getSelectedCategories()=";debug::rr($agenda_fid);}
     //  $checkconnection = 1;
     //  //$checkconnection = @fsockopen("agenda.albanova.se", 80, $errno, $errstr, 5);
     //
     //  if (!$checkconnection) {
     //
     //    // --------------------------------------------
     //    // agenda web server does not reply
     //    // print "Error";
     //    // --------------------------------------------
     //
     //  } else {
     // --------------------------------------------
     // 1. Assemble parameters for getAgendaRecords() method
     // --------------------------------------------
     //TODO// add period selection to getAgendaRecords() method (parameter: $agenda_numdays)
     // ------------------
     // -- create $date_start, $date_end, $timestamp_start, $timestamp_end
     list($date_start, $date_end, $timestamp_start, $timestamp_end) = self::getDateTimeFromPeriod($timespan);
     // --------------------------------------------
     // 2. Extract data from agenda database
     // --------------------------------------------
     // --------------------------------------
     // -- create $agenda_records[$day][$startindex]
     $evid = array();
     foreach ($agenda_fid as $categoryId => $categoryname) {
         // --------------------------------------
         // -- obtain all events for this $categoryId from getAgendaRecords() into $replyThiscat
         // --------------------------------------
         $replyThiscat = self::getAgendaRecords("", $categoryId, 1, 0, 0, 0, 0, $date_start, $date_end);
         // include contributions
         // --------------------------------------
         // -- extract contributions
         // --------------------------------------
         if (isset($replyThiscat)) {
             foreach ($replyThiscat as $day => $dayevents) {
                 foreach ($dayevents as $start => $dayevent) {
                     // keep only contributions if their event is not classified as "nodisplay":
                     $subpath = event::getEventByAgendaid($dayevent["id"], "subpath");
                     if (is_null($GLOBALS["documentClass"]->getEventConfig($subpath, "nodisplay")) || !$GLOBALS["documentClass"]->getEventConfig($subpath, "nodisplay")) {
                         if (isset($dayevent["contribution"])) {
                             foreach ($dayevent["contribution"] as $ctrib) {
                                 if ($ctrib["start"] != "None" && isset($ctrib["starttime"])) {
                                     $ctrib["title"] = trim($ctrib["title"]);
                                     // -- Give all events a unique starttime by adding inessential seconds:
                                     if (!empty($ctrib["title"])) {
                                         $startindex = $ctrib["starttime"] . ":" . time();
                                         if (isset($replyThiscat[$ctrib["startdate"]][$startindex])) {
                                             $ttl = isset($replyThiscat[$ctrib["startdate"]][$startindex]["title_plain"]) ? strtolower($replyThiscat[$ctrib["startdate"]][$startindex]["title_plain"]) : strtolower($replyThiscat[$ctrib["startdate"]][$startindex]["title"]);
                                             if (strtolower($ttl) != strtolower($ctrib["title_plain"])) {
                                                 do {
                                                     $startindex = date("H:i", strtotime($startindex) + 60);
                                                 } while (isset($replyThiscat[$ctrib["startdate"]][$startindex]));
                                             }
                                         }
                                         // Keep only contributions within requested time interval:
                                         if ($ctrib["from"] >= $timestamp_start && $ctrib["from"] <= $timestamp_end) {
                                             $replyThiscat[$ctrib["startdate"]][$startindex] = $ctrib;
                                         }
                                     }
                                     // end if (!empty($ctrib["title"]))
                                     // -- Throw away contributions which are obviously not interesting, like breaks:
                                     if (in_array(strtolower($ctrib["title_plain"]), event::$breaks)) {
                                         unset($replyThiscat[$ctrib["startdate"]][$startindex]);
                                     }
                                 }
                                 // end if
                             }
                         }
                         // end foreach ($dayevent["contribution"])
                         // -- Throw away record for ongoing programs (keeping only their contributions)
                         if (in_array($dayevent["eventtype"], array_keys(event::$eventTypeId))) {
                             if (!$nolimit && $dayevent["from"] <= $timestamp_start) {
                                 unset($replyThiscat[$day][$start]);
                             } else {
                                 unset($replyThiscat[$day][$start]["contribution"]);
                             }
                         }
                     }
                     // end if
                 }
                 // end foreach ($dayevents)
             }
         }
         // end if-foreach ($replyThiscat)
         // --------------------------------------
         // -- put only events within $agenda_numdays days from today into $agenda_records
         // --------------------------------------
         foreach ($replyThiscat as $day => $dayevents) {
             foreach ($dayevents as $start => $dayevent) {
                 $keep = false;
                 if (!empty($dayevent["eventtype"]) && $timespan != "next24h") {
                     $keep = $dayevent["startdate"] <= $date_start && $date_start <= $dayevent["enddate"] || $dayevent["startdate"] <= $date_end && $date_end <= $dayevent["enddate"] || $date_start <= $dayevent["startdate"] && $dayevent["enddate"] <= $date_end ? 1 : 0;
                     // timestamps
                 } else {
                     $keep = $timestamp_start <= $dayevent["from"] && $dayevent["from"] <= $timestamp_end ? 1 : 0;
                     // timestamps
                 }
                 // We don't want events listed in event::$confidNotForDisplay, or undated events parked on 1 January
                 if (isset($dayevent["parent_id"]) && in_array($dayevent["parent_id"], event::$confidNotForDisplay) || date("m-d", $dayevent["from"]) == "01-01") {
                     $keep = false;
                 }
                 $s = $dayevent["id"] . (isset($dayevent["parent_id"]) ? "-" . $dayevent["parent_id"] : "");
                 if ($keep && !isset($evid[$s])) {
                     $dayevent["categoryid"] = $categoryId;
                     $startindex = $dayevent["starttime"];
                     if (isset($agenda_records[$day][$startindex])) {
                         do {
                             // this may be obsolete
                             $startindex = date("H:i", strtotime($startindex) + 120);
                         } while (isset($agenda_records[$day][$startindex]));
                     }
                     $agenda_records[$day][$startindex] = $dayevent;
                 }
                 // end if ($keep)
                 $evid[$s] = 1;
             }
             // end foreach
         }
         // end if-foreach only $agenda_numdays
         // --------------------------------------
     }
     // end foreach $agenda_fid
     // --------------------------------------
     // -- sort $agenda_records
     // --------------------------------------
     ksort($agenda_records);
     foreach ($agenda_records as $dat => $evnt) {
         ksort($agenda_records[$dat]);
         if (empty($evnt)) {
             unset($agenda_records[$dat]);
         }
     }
     // --------------------------------------------
     // 3. We don't want more than self::maxEventsListed items in this list
     // --------------------------------------------
     if (!$nolimit) {
         $maxnumber = $timespan == "next" ? 1 : self::maxEventsListed;
         $count = 0;
         $ids = array();
         foreach ($agenda_records as $day => $dayevents) {
             if ($count == 0) {
                 $firstday = $day;
             }
             foreach ($dayevents as $categoryId => $dayevent) {
                 // remove cross-posted events (keep only the first)
                 if (in_array($dayevent["id"], $ids)) {
                     unset($agenda_records[$day][$categoryId]);
                 } else {
                     $ids[] = $dayevent["id"];
                     // save id for accepted (non-cross-posted) events
                     $count++;
                     if ($count > $maxnumber) {
                         unset($agenda_records[$day][$categoryId]);
                     }
                 }
             }
             if (!count($agenda_records[$day])) {
                 unset($agenda_records[$day]);
             }
         }
     }
     // end if
     // --------------------------------------------
     return $agenda_records;
 }
Exemple #2
0
 static function getEventPlaylistArray()
 {
     if (!class_exists("event", FALSE)) {
         require_once PATH_CLASSES . "/lib/event.php";
     }
     // --------------------------------
     // -- Fetch data => $eventArray
     // --------------------------------
     if (!function_exists("menu_events")) {
         require_once PATH_MENU . "/m_events.php";
     }
     // --------------------------------
     // -- Extend data => $playlistArray
     // --------------------------------
     $playlistArray = $sort = array();
     $allevents = event::getEventByAgendaid();
     foreach ($allevents as $thisevent) {
         if (!empty($thisevent["videos"])) {
             $thisevent["confid"] = preg_match("#confId=(.*)\$#iU", $thisevent["url"], $resArr) ? $resArr[1] : "0";
             $thisevent["title"] = str_replace("; School on Data Assimilation", "", $thisevent["title"]);
             // fix
             $thisevent["startdate"] = event::getEventByAgendaid($thisevent["confid"], "startdate");
             $thisevent["subpath"] = event::getEventByAgendaid($thisevent["confid"], "subpath");
             $thisevent["period"] = event::getEventByAgendaid($thisevent["confid"], "period");
             $thisevent["image"] = event::getEventByAgendaid($thisevent["confid"], "image");
             $thisevent["id"] = $thisevent["subpath"];
             $thisevent["host"] = "youtube";
             $thisevent["remote"]["playlist_id"] = $thisevent["youtubeid"];
             $thisevent["remote"]["playlist_url"] = "http://www.youtube.com/playlist?" . "list=" . $thisevent["remote"]["playlist_id"] . "&feature=view_all";
             $remote = self::getPlaylist($thisevent["remote"]["playlist_id"]);
             if (!empty($remote)) {
                 $thisevent = array_merge($thisevent, $remote);
                 $playlistArray[$thisevent["subpath"]] = $thisevent;
                 $sort[$thisevent["subpath"]] = $thisevent["startdate"];
             }
         }
         // end if
     }
     // end foreach
     if (empty($playlistArray) || empty($sort)) {
         return array();
     }
     array_multisort($sort, SORT_DESC, $playlistArray);
     return $playlistArray;
 }
Exemple #3
0
 public function getEventCalendarData($selectAll = FALSE)
 {
     functions::gpc_declare_input("vert", 0, true);
     $allConfids = $this->getAgendaConferenceIdsForNorditaEvents();
     if (!is_array($allConfids) || empty($allConfids)) {
         return array();
     }
     $calendar = array();
     $proglist = array();
     $eventIdToTitle = array();
     $eventIdToPath = array();
     $grid = array();
     foreach ($allConfids as $confId) {
         $oneprogram = event::getEventByAgendaid($confId);
         if (!empty($oneprogram)) {
             $yr = date("Y", $oneprogram["from"]);
             if (substr($oneprogram["startdate"], -5) != "01-01" && ($selectAll || date("Y") <= $yr)) {
                 $calendar[$yr][date("z", $oneprogram["from"])][] = $oneprogram["id"];
                 $calendar[$yr][date("z", $oneprogram["to"])][] = -$oneprogram["id"];
                 $eventIdToTitle[$oneprogram["id"]] = $oneprogram["title"];
                 $eventIdToPath[$oneprogram["id"]] = $oneprogram["subpath"];
                 unset($coord);
                 if (isset($oneprogram["chairs"]) && is_array($oneprogram["chairs"])) {
                     foreach ($oneprogram["chairs"] as $ch) {
                         $coord[] = $ch["av_firstname"] . " " . $ch["av_lastname"];
                     }
                 }
                 $proglist[$oneprogram["startdate"]] = array("title" => $oneprogram["title"], "id" => $oneprogram["id"], "subpath" => $oneprogram["subpath"], "startdate" => $oneprogram["startdate"], "chairlist" => isset($coord) ? implode(", ", $coord) : "", "enddate" => $oneprogram["enddate"], "blurb" => "", "eventtype" => $oneprogram["eventtype"], "period" => $oneprogram["period"]);
             }
         }
     }
     // end foreach
     ksort($calendar);
     foreach ($calendar as $yr => $cal) {
         ksort($cal);
         $calendar[$yr] = $cal;
     }
     ksort($proglist);
     foreach ($calendar as $yr => $cal) {
         $firsttime = mktime(0, 0, 0, 1, 1, $yr);
         $lastday = date("z", mktime(0, 0, 0, 12, 31, $yr));
         $idx = array();
         for ($day = 0; $day <= $lastday; $day++) {
             $thistime = mktime(0, 0, 0, 1, $day + 1, $yr);
             $thisdate = date("j", $thistime);
             $thismonth = date("n", $thistime);
             if (isset($calendar[$yr][$day])) {
                 foreach ($calendar[$yr][$day] as $v) {
                     if ($v < 0) {
                         unset($idx[abs($v)]);
                     } else {
                         $idx[$v] = $v;
                     }
                 }
             }
             if ($GLOBALS["vert"]) {
                 $grid[$yr][$thisdate][$thismonth] = join(" ", $idx);
                 for ($i = $thisdate + 1; $i <= 31; $i++) {
                     // fill to end of month
                     $grid[$yr][$i][$thismonth] = NULL;
                 }
             } else {
                 $grid[$yr][$thismonth][$thisdate] = join(" ", $idx);
                 for ($i = $thisdate + 1; $i <= 31; $i++) {
                     // fill to end of month
                     $grid[$yr][$thismonth][$i] = NULL;
                 }
             }
             // end if
         }
         // end foreach
     }
     return array("proglist" => $proglist, "eventIdToTitle" => $eventIdToTitle, "eventIdToPath" => $eventIdToPath, "grid" => $grid);
 }
Exemple #4
0
 function getArrivingVisitors($period = "week", $delta = 0)
 {
     $delta = $delta ? 0 : 7;
     $saturday1 = date("Y-m-d", time() - 3600 + ($delta - 1 - date("w", time() - 3600)) * 86400);
     $sunday = date("Y-m-d", time() - 3600 + ($delta - date("w", time() - 3600)) * 86400);
     $saturday2 = date("Y-m-d", time() - 3600 + ($delta + 6 - date("w", time() - 3600)) * 86400);
     $where = "";
     switch ($period) {
         // %w = day of the week, Sun=0
         case "month":
             $where = "FROM_UNIXTIME(V.v_start,'%Y-%m-%d') BETWEEN " . "DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -DATE_FORMAT(NOW(),'%w')+1 DAY),'%Y-%m-%d') " . "AND " . "DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -DATE_FORMAT(NOW(),'%w')+31 DAY),'%Y-%m-%d') ";
             break;
             // %w = day of the week, Sun=0
         // %w = day of the week, Sun=0
         case "week":
             $where = "FROM_UNIXTIME(V.v_start,'%Y-%m-%d') BETWEEN " . "DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -DATE_FORMAT(NOW(),'%w')+1 DAY),'%Y-%m-%d') " . "AND " . "DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -DATE_FORMAT(NOW(),'%w')+7 DAY),'%Y-%m-%d') ";
             break;
             // %w = day of the week, Sun=0
         // %w = day of the week, Sun=0
         case "extweek":
             $where = "FROM_UNIXTIME(V.v_start,'%Y-%m-%d') BETWEEN '" . $saturday1 . "' AND '" . $saturday2 . "'";
             break;
             // If today=Monday, also list arrivals from weekend
         // If today=Monday, also list arrivals from weekend
         case "today":
             $where = date("l") == "Monday" ? "FROM_UNIXTIME(V.v_start,'%Y-%m-%d') BETWEEN " . "DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -2 DAY),'%Y-%m-%d') " . "AND " . "DATE_FORMAT(NOW(),'%Y-%m-%d') " : "FROM_UNIXTIME(V.v_start,'%Y-%m-%d') BETWEEN " . "DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 DAY),'%Y-%m-%d') " . "AND " . "DATE_FORMAT(NOW(),'%Y-%m-%d') ";
             //"FROM_UNIXTIME(V.v_start,'%Y-%m-%d')=CURDATE() ";
             break;
     }
     // end switch
     // ------------------------------------------------------
     // Query database
     // ------------------------------------------------------
     $sql = "\n      SELECT\n        IF(E.e_code>0,E.e_name,'Visitors') AS 'event',\n        CONCAT(A.av_firstname,' ',A.av_lastname) AS 'personname',\n        CONCAT(IFNULL(NULLIF(CONCAT(A.av_salutation,' '),' '),''),A.av_firstname,' ',A.av_lastname) AS 'personnametitle',\n        CONCAT(A.av_institute,IFNULL(NULLIF(CONCAT(', ',A.av_citizenship),', '),'')) AS 'affiliation',\n        V.v_start,\n        E.e_code AS 'eventid',\n        FROM_UNIXTIME(V.v_start,'%Y-%m-%d') AS 'startdate',\n        FROM_UNIXTIME(V.v_end,'%Y-%m-%d') AS 'enddate',\n        A.av_email\n      FROM\n        abs_visits AS V\n        LEFT JOIN zzz_avatars AS A ON A.av_id=V.v_avid\n        LEFT JOIN abs_events AS E ON E.e_code=SUBSTRING(V.v_code,1,4)\n      WHERE " . $where . " AND (V.v_status <> 'STATUS_NO') " . "      ORDER BY\n        E.e_code ASC,\n        V.v_start,\n        A.av_lastname,\n        A.av_firstname";
     $res = $this->query($sql, IS_TESTSERVER);
     // includes a call to connect
     // ------------------------------------------------------
     // Assemble $visit[] from resultset
     // ------------------------------------------------------
     $visit = array();
     if ($this->num_rows($res)) {
         while ($cell = $this->next_record_assoc($res)) {
             // keep only visitors if their event is not classified as "nodisplay":
             $subpath = event::getEventByAgendaid($cell["eventid"], "subpath");
             if (is_null($GLOBALS["documentClass"]->getEventConfig($subpath, "nodisplay")) || !$GLOBALS["documentClass"]->getEventConfig($subpath, "nodisplay")) {
                 $affiliation = !empty($cell["affiliation"]) ? $cell["affiliation"] : (!empty($cell["r_home"]) ? $cell["r_home"] : "");
                 $a = strtolower($affiliation);
                 if (strpos($a, "kth") === false && strpos($a, "royal institute of technology") === false && strpos($a, "stockholm u") === false && $a != "nordita" && strpos($a, "fysikum") === false && strpos($a, "okc") === false && strpos($a, "oskar klein center for cosmoparticle physics") === false && strpos($a, "dept. of astronomy") === false) {
                     $visit[strtotime($cell["startdate"])][$cell["event"]][] = array("name" => str_replace("  ", " ", $cell["personname"]), "affiliation" => $affiliation, "dates" => functions::readableDateInterval($cell["startdate"], $cell["enddate"]), "email" => functions::obscurify_email($cell["av_email"]));
                 }
             }
             // end if
         }
         // end while
     }
     ksort($visit);
     return $visit;
 }
Exemple #5
0
 public static function OutputEventVisitdates()
 {
     $stdout = "";
     $eventShortname = $eventTitle = $dates = $oneEventParticipants = $eventParticipants = array();
     $daterowInterval = 10;
     $colorScheme = "green";
     // ["red"|"green"]
     //    $visit = functions::callMethod('fromdb_vm','fromdb/vm','getArrivingVisitors');
     if (!isset($dbVm) || !is_object($dbVm)) {
         require_once PATH_CLASSES . "/fromdb/vm.php";
         $dbVm = new fromdb_vm();
     }
     // ------------------------------------------------------------------------
     // Output drop-down list
     // ------------------------------------------------------------------------
     $stdout .= event::outputEventDropdown(array(), "participant visiting dates");
     // ------------------------------------------------------------------------
     if (!isset($_REQUEST["confid"]) || empty($_REQUEST["confid"])) {
         return $stdout;
     }
     // ------------------------------------------------------------------------
     // GPC
     // ------------------------------------------------------------------------
     // Must be after call to event::outputEventDropdown() where $GLOBALS["confid"] is set.
     if (!isset($GLOBALS["confid"])) {
         functions::gpc_declare_input("confid", array(), false);
     }
     if (!empty($GLOBALS["confid"])) {
         $confidArray = is_array($GLOBALS["confid"]) ? $GLOBALS["confid"] : array($GLOBALS["confid"]);
     }
     functions::gpc_declare_input("sortdate", "", false);
     // ------------------------------------------------------------------------
     // Obtain data
     // ------------------------------------------------------------------------
     $pagePath = $GLOBALS["documentClass"]->getPagePath();
     $i = 0;
     $keys = array();
     foreach ($confidArray as $confid) {
         $q[] = "confid[" . $i . "]=" . $confid;
         $i++;
         $eventShortname[$confid] = $GLOBALS["documentClass"]->getPathFromAgendaId($confid);
         $eventTitle[$confid] = event::getEventByAgendaid($confid, "title");
         $dates[$confid] = $dbVm->getDateInterval($confid);
         $title[$confid] = !empty($eventTitle[$confid]) ? "<h2>" . $eventTitle[$confid] . "</h2>\r\n" : "";
         $title[$confid] .= "<h3>Participants during " . $dates[$confid][0] . "</h3>\r\n";
         if ($dates[$confid][1] <= $dates[$confid][2]) {
             $d = $dates[$confid][1];
             do {
                 $keys[$d] = 0;
                 $d = date("Y-m-d", strtotime($d . " +1 day"));
             } while ($d <= $dates[$confid][2]);
         }
     }
     if (isset($GLOBALS["mode"])) {
         $q[] = "mode=" . $GLOBALS["mode"];
     }
     ksort($keys);
     $qstring = implode("&amp;", $q);
     // Obtain participants for each requested event
     foreach ($confidArray as $confid) {
         $oneEventParticipants[$confid] = $dbVm->getEventsParticipantPresence($confid, $keys, 1);
     }
     // Merge all participants to one array
     foreach ($oneEventParticipants as $confid => $parts) {
         foreach ($parts as $key => $data) {
             $eventParticipants[strtolower($key)] = $data;
         }
     }
     ksort($eventParticipants);
     // Possibly sort participants by presence on a particular day
     if (!empty($GLOBALS["sortdate"])) {
         $eventParticipants = $dbVm->getEventsParticipantPresenceDay($eventParticipants, $GLOBALS["sortdate"]);
     }
     // ------------------------------------------------------------------------
     // Output data
     // ------------------------------------------------------------------------
     if (empty($eventParticipants)) {
         return $stdout . implode("", $title) . BLURB_SORRY_NO_PARTICIPANTS;
     }
     // ------------------------------------------------------------------------
     $daterow = "  <tr>\r\n" . "    <td>" . "<a href='" . $pagePath . "/index.php?" . $qstring . "'><strong>Name</strong></a>" . "</td>\r\n";
     foreach ($keys as $d => $slask) {
         $daterow .= "    <td class='" . (date("N", strtotime($d)) < 6 ? "wday" : "wend") . "'>" . "<a href='" . $pagePath . "/index.php?" . $qstring . "&amp;sortdate=" . $d . "'>" . date("D", strtotime($d)) . "<br>" . date("d", strtotime($d)) . "<br>" . date("M", strtotime($d)) . "</a>" . "</td>\r\n";
     }
     $daterow .= "  </tr>\r\n";
     // -------------------------
     $stdout .= implode("", $title) . "<p class='only_online'>Click on a date in the table to <strong>highlight " . "participants present that day</strong>; click on the " . "&quot;<a href='" . $pagePath . "/index.php?" . $qstring . "'>" . "<strong>Name</strong></a>&quot; link to " . "<strong>sort alphabetically</strong>.</p>\r\n" . "\r\n" . "<table class='dategrid zebra" . $colorScheme . "'>\r\n" . $daterow;
     $row1 = 0;
     foreach ($eventParticipants as $name => $data) {
         $stdout .= "  <tr>\r\n" . "    <td class='name'>" . $data["name"] . "</td>\r\n";
         $row2 = 1;
         foreach ($data["here"] as $date => $d) {
             $active = $date == $GLOBALS["sortdate"] && $data["here"][$date] ? "highlighted" : "active" . ($row1 % 2 ? "1" : "2");
             $weekday = date("N", strtotime($date)) > 5 ? "wend" : "";
             $stdout .= "    <td class='" . ($d ? $active : $weekday) . "'></td>\r\n";
             $row2++;
         }
         $stdout .= "  </tr>\r\n";
         $row1++;
         if ($row1 % $daterowInterval == 0) {
             $stdout .= $daterow;
         }
     }
     // end foreach
     $stdout .= ($row1 % $daterowInterval == 0 ? "" : $daterow) . "</table>\r\n";
     // -------------------------
     return $stdout;
 }