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; }
static function OutputRoomsList($twocolumns = false, $id = "", $class = "", $fromAlbaNova = true, $fromKthCampus = false) { $stdout = $roomsmap = ""; // ---------------------- if (!class_exists("fromdb_rooms", FALSE)) { require_once PATH_CLASSES . "/fromdb/rooms.php"; } $dbRooms = new fromdb_rooms(FALSE); // ---------------------- $bookableRooms = $dbRooms->getRoomsByType($fromAlbaNova, $fromKthCampus); if (!count($bookableRooms)) { return BLURB_SORRY_NO_ROOMS; } // ---------------------- foreach ($bookableRooms as $campus => $items) { switch ($campus) { case "a": // AlbaNova campus $roomsmap = "<div id='map' class='col-content-center'>\r\n" . " <p class='bottommargin'>This is a list of <strong>bookable rooms in AlbaNova</strong>: auditoria, seminar rooms, lecture rooms and a selection of group rooms (note that the group rooms of the astronomy department on floor 6 in the AlbaNova main building are not in the list). <span class='only_online'>The map is clickable. There is a separate <strong><a href='" . preg_replace("|/[^/]*/index.php|", "/kth/index.php", $_SERVER["PHP_SELF"]) . "'>map of lecture rooms on the KTH Campus</a></strong>.</span></p>\r\n" . " <p class='only_online'><img src='img/_wiki/bookable_rooms.png' alt='' usemap='#roomsmap'></p>\r\n" . " <p class='only_print'><img src='img/_wiki/bookable_rooms_print.png' alt=''></p>\r\n" . " <map name='roomsmap' id='roomsmap'>\r\n" . " <area shape='poly' coords='533,140,539,117,554,117,567,94,597,106,583,138' href='" . $_SERVER["PHP_SELF"] . "#fr4' alt='Auditorium FR4 Oskar Klein' title='Auditorium FR4 Oskar Klein'>\r\n" . " <area shape='poly' coords='586,254,596,231,627,245,602,289' href='" . $_SERVER["PHP_SELF"] . "#fd5' alt='Auditorium FD5 The Svedberg' title='Auditorium FD5 The Svedberg'>\r\n" . " <area shape='poly' coords='188,254,199,207,224,211,211,258' href='" . $_SERVER["PHP_SELF"] . "#fa31' alt='Seminar Room FA31 Héctor Rubinstein' title='Seminar Room FA31 Héctor Rubinstein'>\r\n" . " <area shape='ploy' coords='211,259,227,211,249,218,235,265' href='" . $_SERVER["PHP_SELF"] . "#fa32' alt='Seminar Room FA32' title='Seminar Room FA32'>\r\n" . " <area shape='poly' coords='628,240,655,197,669,205,640,247' href='" . $_SERVER["PHP_SELF"] . "#fb51' alt='Lecture room FB51' title='Lecture room FB51'>\r\n" . " <area shape='poly' coords='640,248,670,205,686,214,656,258' href='" . $_SERVER["PHP_SELF"] . "#fb52' alt='Lecture room FB52' title='Lecture room FB52'>\r\n" . " <area shape='poly' coords='656,259,686,217,703,225,671,269' href='" . $_SERVER["PHP_SELF"] . "#fb53' alt='Lecture room FB53' title='Lecture room FB53'>\r\n" . " <area shape='poly' coords='671,270,703,230,716,239,681,277' href='" . $_SERVER["PHP_SELF"] . "#fb54' alt='Lecture room FB54' title='Lecture room FB54'>\r\n" . " <area shape='poly' coords='681,278,716,239,728,250,697,289' href='" . $_SERVER["PHP_SELF"] . "#fb55' alt='Lecture room FB55' title='Lecture room FB55'>\r\n" . " <area shape='poly' coords='627,84,624,39,671,47,640,92' href='" . $_SERVER["PHP_SELF"] . "#fb41' alt='Lecture room FB41' title='Lecture room FB41'>\r\n" . " <area shape='poly' coords='639,95,671,46,687,590,657,105' href='" . $_SERVER["PHP_SELF"] . "#fb42' alt='Lecture room FB42' title='Lecture room FB42'>\r\n" . " <area shape='poly' coords='595,137,620,91,642,104,615,145' href='" . $_SERVER["PHP_SELF"] . "#fd41' alt='Lecture room FD41' title='Lecture room FD41'>\r\n" . " <area shape='rect' coords='207,144,240,174' href='" . $_SERVER["PHP_SELF"] . "#fp41' alt='Lecture room FP41' title='Lecture room FP41'>\r\n" . " <area shape='rect' coords='60,7,92,35' href='" . $_SERVER["PHP_SELF"] . "#rb15' alt='Lecture room RB15' title='Lecture room RB15'>\r\n" . " <area shape='rect' coords='266,46,320,63' href='" . $_SERVER["PHP_SELF"] . "#132027' alt='Group Room 132:027 Nordita East Lunch Room' title='Group Room 132:027 Nordita Main Lunch Room'>\r\n" . " <area shape='rect' coords='236,64,315,86' href='" . $_SERVER["PHP_SELF"] . "#132028' alt='Group Room 132:028 Nordita East Seminar Room' title='Group Room 132:028 Nordita Main Seminar Room'>\r\n" . " <area shape='rect' coords='186,45,239,63' href='" . $_SERVER["PHP_SELF"] . "#122022' alt='Group Room 122:022 Nordita West Lunch Room' title='Group Room 122:022 Nordita West Lunch Room'>\r\n" . " <area shape='rect' coords='184,64,235,84' href='" . $_SERVER["PHP_SELF"] . "#122026' alt='Group Room 122:026 Nordita West Seminar Room' title='Group Room 122:026 Nordita West Seminar Room'>\r\n" . " <area shape='rect' coords='400,184,425,250' href='" . $_SERVER["PHP_SELF"] . "#a51003' alt='Group Room A5:1003' title='Group Room A5:1003'>\r\n" . " <area shape='rect' coords='488,187,506,254' href='" . $_SERVER["PHP_SELF"] . "#a51041' alt='Group Room A5:1041' title='Group Room A5:1041'>\r\n" . " <area shape='poly' coords='549,191,535,255,547,259,568,192' href='" . $_SERVER["PHP_SELF"] . "#a51069' alt='Group Room A5:0169' title='Group Room A5:0169'>\r\n" . " <area shape='rect' coords='400,29,432,93' href='" . $_SERVER["PHP_SELF"] . "#a41003' alt='Group Room A4:1003' title='Group Room A4:1003'>\r\n" . " <area shape='rect' coords='488,33,506,98' href='" . $_SERVER["PHP_SELF"] . "#a41041' alt='Group Room A4:1041' title='Group Room A4:1041'>\r\n" . " <area shape='rect' coords='46,227,73,290' href='" . $_SERVER["PHP_SELF"] . "#a31003' alt='Group Room A3:1003' title='Group Room A3:1003'>\r\n" . " </map>\r\n" . "</div>\r\n"; break; case "k": // KTH campus $roomsmap = "<p></p>\r\n"; break; } // end switch // ---------------------- $stdout .= $roomsmap; if ($twocolumns) { $stdout .= "<div class='col-content-left'>\r\n"; } foreach ($items as $typeid => $item) { $type = ""; switch ($typeid) { case "a": $type = "Auditorium"; $types = "Auditoria"; break; case "s": $type = "Seminar Room"; $types = "Seminar Rooms"; $stdout .= "<hr class='sep'>\r\n"; break; case "l": $type = "Lecture Room"; $types = "Lecture Rooms"; if ($twocolumns && $fromKthCampus) { $stdout .= "<hr class='sep only_print'>\r\n</div> <div class='col-content-right'>\r\n"; } else { $stdout .= "<hr class='sep'>\r\n"; } break; case "g": $type = "Group Room"; $types = "Group Rooms"; $stdout .= ""; if ($twocolumns && $fromAlbaNova) { $stdout .= "<hr class='sep only_print'>\r\n</div> <div class='col-content-right'>\r\n"; } else { $stdout .= "<hr class='sep'>\r\n"; } break; } if (!empty($type)) { $stdout .= "<h3>" . $types . "</h3>\r\n\r\n"; } foreach ($item as $it) { //$identifier = !empty($it["an_id"]) ? $it["an_id"] : $it["roomnumber"]; $identifier = $it["id"]; //$roomcode = empty($it["an_id"]) ? "<em>N/A</em>" : $it["an_id"]; $stdout .= " <p id='" . strtolower(str_replace(":", "", $identifier)) . "' class='roomname'>" . $type . " " . $identifier . (!empty($it["name"]) ? " "" . $it["name"] . """ : "") . "</p>\r\n"; $file = "img/_wiki/rooms_" . strtolower(str_replace(":", "", $identifier)) . ".png"; if (file_exists(INCLEVEL . $file)) { $stdout .= " <p><img src='" . $file . "' alt='' style='margin:0.5em 0 -1em 1.5em'></p>\r\n"; } $stdout .= " <dl>\r\n" . " <dd><em>Capacity</em>: <strong>" . (!empty($it["capacity"]) ? $it["capacity"] . " persons" : "[unknown]") . "</strong></dd>\r\n" . " <dd><em>Room number</em>: " . $it["roomnumber"] . "</dd>\r\n" . (empty($roomcode) || empty($it["an_id"]) ? "" : " <dd><em>Room code for bookings</em>: " . $roomcode . "</dd>\r\n") . ""; switch ($it["booktype_id"]) { case 1: // -- Book through Albanova reception (Albanova campus) $stdout .= " <dd><em>Book</em>: send e-mail to <strong>" . functions::obscurify_email("*****@*****.**") . "</strong></dd>\r\n" . " <dd><em>Check availability</em>: " . "<strong><a href='http://www.kth.se/schema/?" . "showweekend=false" . "&outputview=table" . "&location=" . strtolower($identifier) . "&start=" . date("Y-m-d") . "" . "&end=" . date("Y-m-d") . "'>www.kth.se/schema</a></strong></dd>\r\n"; break; case 2: // -- Book through rooms.albanova.se $stdout .= " <dd><em>Book and Check availability</em>: " . "<strong><a href='http://rooms.albanova.se/view_week.php?" . "area=" . $it["rbs_area"] . "&selectroom=" . $it["rbs_id"] . "'>" . "rooms.albanova.se</a></strong></dd>\r\n"; break; case 3: // -- Book on paper on door $stdout .= " <dd><em>Book</em>: on a paper on the door of the room</dd>\r\n"; break; case 4: // -- Book through KTH booking system (KTH Campus) /* OLD INTERFACE; keep for reference // minSeats=50&maxSeats=55 $stdout .= " <dd><em>Book</em>: via the <strong>AlbaNova reception</strong> " . "(extension 8444)</dd>\r\n" . " <dd><em>Check availability</em>: " . "<strong><a href='http://lokal2.timeedit.se/kth/roombookings.jsp?" . "element=week" . "&roomId=" . $it["kth_id"] . "&date=" . date("Y-m-d") . "'>" . "lokal2.timeedit.se/kth</a></strong></dd>\r\n"; */ $stdout .= " <dd><em>Book</em>: send e-mail to <strong>" . functions::obscurify_email("*****@*****.**") . "</strong></dd>\r\n" . " <dd><em>Check availability</em>: " . "<strong><a href='http://www.kth.se/schema/?" . "showweekend=false" . "&outputview=table" . "&location=" . strtolower($identifier) . "&start=" . date("Y-m-d") . "" . "&end=" . date("Y-m-d") . "'>www.kth.se/schema</a></strong></dd>\r\n"; break; } $stdout .= " </dl>\r\n" . "\r\n"; } } // end foreach if ($twocolumns) { $stdout .= "</div><div style='clear:both'><br></div>\r\n"; } } return $stdout; }
private static function drawSubscriptionsList($table = "subscriber", $dbData = array(), $numberOfSubscribers = 0, $enableEditing = true) { if (!in_array($table, array("subscriber", "invitee", "mailman"))) { return ""; } $stdout = ""; $news_url = isInPath("/" . PATH_NEWSEDITTEST . "/") ? PATH_NEWSTEST : PATH_NEWS; switch ($table) { case "subscriber": $stdout .= "<p style='font-size:1.2em'>A <strong>subscriber</strong> is someone who has " . "agreed to get newsletter announcement mails, either by " . "<a href='" . $news_url . "/about/subscribe/index.php'><strong>subscribing online</strong></a> " . "or by <strong>clicking on a subscription link in an</strong> " . "<a href='" . SUBSITE . "/subscriptions/invite_send/index.php'><strong>invitation letter</strong></a> " . "sent by Nordita.</p>\r\n" . "<p style='font-size:1.2em'>A subscriber can choose to " . "<a href='" . $news_url . "/about/unsubscribe/index.php'><strong>unsubscribe online</strong></a>, " . "or <strong>click an unsubscription link at the bottom of a newsletter announcement mail</strong>. " . "Below you can also <strong>manually remove a subscriber</strong> from the mailing list " . "<span class='nowrap'>(click on <img src='img/_icons/i-drop.png' alt='delete' " . "style='vertical-align:middle'> icon)</span>. You can undo manual unsubscriptions, but if a person " . "has chosen to unsubscribe, you are not allowed to override that decision.</span></p>\r\n" . PADDED_HR; if (empty($dbData)) { return $stdout .= functions::boxMessage("error", "There are currently <strong>no subscriptions</strong>."); } $stdout .= "<h3 class='bottommargin'>List of current " . "<strong> " . $numberOfSubscribers . "</strong> " . "active subscribers:</h3>\r\n" . "\r\n"; break; case "invitee": $stdout .= "<p style='font-size:1.2em'>Newsletter announcements should only be sent to people who " . "have agreed to receive them. In practice this means <strong>the announcement will only be " . "sent to subscribers</strong>.</p>" . "<p style='font-size:1.2em'><strong>You can send a one-time invitation mail</strong> to people on an " . "<em>invitation list</em>, which you put together below. In the invitaion mail are instructions " . "on how to <a href='" . $news_url . "/about/subscribe/index.php'><strong>subscribe</strong></a> " . "to the announcement mails. Only if the invitees choose to subscribe will they receive future " . "newsletter announcements.</p>\r\n" . PADDED_HR . "<div style='margin-bottom:2em'>\r\n" . " <form method='post' action='" . $_SERVER["PHP_SELF"] . "' style='display:inline;margin-right:3em'>\r\n" . " <input type='submit' value='Add New People to the Invitation List'>\r\n" . " <input type='hidden' name='add' value='1'>\r\n" . " </form>\r\n" . " <form method='post' action='" . $_SERVER["PHP_SELF"] . "' style='display:inline'>\r\n" . " <input type='submit' value='Add/Update Current Nordita Staff, Board and Committees'>\r\n" . " <input type='hidden' name='staff' value='1'>\r\n" . " </form>\r\n" . "</div>\r\n" . PADDED_HR; if (empty($dbData)) { return $stdout . functions::boxMessage("error", "There are currently <strong>no people</strong> on the invitation list."); } $stdout .= "<h3 class='bottommargin'>List of the " . "<strong> " . $numberOfSubscribers . "</strong> " . "people in the list that have not yet been invited:</h3>\r\n" . "\r\n"; break; case "mailman": if (!NEWS_DEBUG) { $stdout .= "<div style='margin-bottom:2em'>\r\n" . " <form method='post' action='" . $_SERVER["PHP_SELF"] . "' style='display:inline;margin-right:3em'>\r\n" . " <input type='submit' value='Add New People to the Mailing List'>\r\n" . " <input type='hidden' name='add' value='1'>\r\n" . " </form>\r\n" . "</div>\r\n" . PADDED_HR; } $stdout .= "<h3 class='bottommargin'>List of current " . "<strong> " . $numberOfSubscribers . "</strong> " . "active list members:</h3>\r\n" . "\r\n"; break; } // end switch // Rearrange $dbData as array $data // Assemble $_SESSION["plaintext"] $_SESSION["plaintext"] = ""; foreach ($dbData as $item) { $data[$item["email"][0]][] = $item; if (isset($item["status_id"]) && $item["status_id"] == NEWS_ACTIVE) { $_SESSION["plaintext"] .= $item["email"] . "\n"; } } $stdout .= "<div id='jtabs' class='notabs'>\r\n" . " <ul>\r\n"; $i = 0; foreach ($data as $initial => $items) { $allinitials[$initial] = $i++; $stdout .= " <li><a href='" . $_SERVER["PHP_SELF"] . "#jtabs-" . $initial . "'>" . strtoupper($initial) . "</a></li>\r\n"; } $stdout .= " </ul>\r\n"; if (in_array($table, array("subscriber", "mailman"))) { foreach ($data as $initial => $items) { $stdout .= " <div id='jtabs-" . $initial . "'>\r\n" . " <form id='edit' method='post' action='" . $_SERVER["PHP_SELF"] . "' style='margin-bottom:2em'>\r\n" . " <table style='width:100%'>\r\n" . " <tr>\r\n" . " <th></th>\r\n" . " <th class='b_zebra0' style='width:30%'>E-Mail</th>\r\n" . " <th class='b_zebra0' style='width:20%'>Name/Comment</th>\r\n" . " <th class='b_zebra0'>Date Joined</th>\r\n" . " <th class='b_zebra0'>Source</th>\r\n" . " <th class='b_zebra0'>Status</th>\r\n"; if ($enableEditing) { $stdout .= " <th style='width:1em'></th>\r\n" . " <th></th>\r\n" . " <th></th>\r\n"; } $stdout .= " </tr>\r\n"; $i = $k = 1; foreach ($items as $item) { $u = $item["status_id"] != NEWS_ACTIVE ? " deleted italic" : ""; $stdout .= " <tr>\r\n" . " <td>" . $k . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . functions::obscurify_email($item["email"]) . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $item["comment"] . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $item["date_created"] . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $item["source"] . "</td>\r\n" . " <td class='b_zebra" . $i . "'>" . $item["status"] . "</td>\r\n"; //" <td class='b_zebra".$i.$u."'>" . $item["source"]["subscribersource"] . "</td>\r\n" . //" <td class='b_zebra".$i."'>" . $item["status"]["subscriberstatus"] . "</td>\r\n"; if ($enableEditing) { $stdout .= " <td></td>\r\n" . " <td><button class='plain' type='submit' name='edit' " . "value='" . $item["email"] . "' title='Edit this record'>" . "<img src='img/_icons/i-edit-black.png' alt='Edit' title='Edit this record'>" . "</button></td>\r\n" . ($item["status_id"] == NEWS_ACTIVE || $table == "mailman" ? " <td><button class='plain' type='submit' name='delete' " . "value='" . $item["email"] . "' title='Remove this record'>" . "<img src='img/_icons/i-drop.png' alt='Delete' title='Remove this record'>" . "</button></td>\r\n" : ""); } $stdout .= " </tr>\r\n"; $i = 3 - $i; $k++; } $stdout .= " </table>\r\n" . " </form>\r\n" . " <form method='post' action='" . $_SERVER["PHP_SELF"] . "' " . "style='margin-top:-1em'>\r\n" . " [<input type='submit' value='Reload this page' " . "class='fakelink' style='font-size:1em'>]\r\n" . " <input type='hidden' name='initial' value='" . $item["email"][0] . "'>\r\n" . " <input type='hidden' name='reload' value='1'>\r\n" . " </form>\r\n" . " </div>\r\n"; } } elseif (in_array($table, array("invitee"))) { foreach ($data as $initial => $items) { $stdout .= " <div id='jtabs-" . $initial . "'>\r\n" . " <form id='edit' method='post' action='" . $_SERVER["PHP_SELF"] . "' style='margin-bottom:2em'>\r\n" . " <table style='width:100%'>\r\n" . " <tr>\r\n" . " <th class='b_zebra0 nowrap' style='width:25%'>E-Mail</th>\r\n" . " <th class='b_zebra0' style='width:20%'>Name</th>\r\n" . " <th class='b_zebra0' style='width:20%'>Comment</th>\r\n" . " <th class='b_zebra0'>Source</th>\r\n" . " <th class='b_zebra0'>Date Added</th>\r\n" . " <th class='b_zebra0 nowrap' style='width:20%'>Invitation Sent</th>\r\n"; if ($enableEditing) { $stdout .= " <th style='width:1em'></th>\r\n" . " <th></th>\r\n" . " <th></th>\r\n"; } $stdout .= " </tr>\r\n"; $i = 1; foreach ($items as $item) { if ($item["sent"]) { $u = " deleted italic"; $status = $item["date_invited"]; } elseif ($item["status_id"] != NEWS_ACTIVE) { $u = " deleted italic"; $status = "Not yet"; } else { $u = ""; $status = "Not yet"; } $stdout .= " <tr>\r\n" . " <td class='b_zebra" . $i . $u . " nowrap'>" . functions::obscurify_email($item["email"]) . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $item["firstname"] . " " . $item["lastname"] . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $item["comment"] . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $item["source"] . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $item["date_created"] . "</td>\r\n" . " <td class='b_zebra" . $i . $u . "'>" . $status . "</td>\r\n"; if ($enableEditing) { $stdout .= " <td></td>\r\n" . " <td><button class='plain' type='submit' name='edit' " . "value='" . $item["email"] . "' title='Edit this record'>" . "<img src='img/_icons/i-edit-black.png' alt='Edit' title='Edit this record'>" . "</button></td>\r\n" . (empty($u) ? " <td><button class='plain' type='submit' name='delete' " . "value='" . $item["email"] . "' title='Remove this record'>" . "<img src='img/_icons/i-drop.png' alt='Delete' title='Remove this record'>" . "</button></td>\r\n" : ""); } $stdout .= " </tr>\r\n"; $i = 3 - $i; } $stdout .= " </table>\r\n" . " </form>\r\n" . " <form method='post' action='" . $_SERVER["PHP_SELF"] . "' " . "style='margin-top:-1em'>\r\n" . " [<input type='submit' value='Reload this page' " . "class='fakelink' style='font-size:1em'>]\r\n" . " <input type='hidden' name='reload' value='1'>\r\n" . " <input type='hidden' name='initial' value='" . $item["email"][0] . "'>\r\n" . " </form>\r\n" . " </div>\r\n"; } } $stdout .= "</div>\r\n" . "<form method='post' action='" . SUBSITE . "/subscriptions/plaintext/index.php'>\r\n" . " [<input type='submit' value='Plaintext list of all active e-mail addresses' " . "class='fakelink' style='font-size:1em'>]\r\n" . "</form>\r\n" . "\r\n"; // Add jQuery script functions::gpc_declare_input("initial", "", false); if (strlen($GLOBALS["initial"]) == 1) { $in = isset($allinitials[$GLOBALS["initial"]]) ? $allinitials[$GLOBALS["initial"]] : key($allinitials); $GLOBALS[SUBSITE]["scripts"]["code"][] = " \$(function(){\$('#jtabs').tabs('option','active'," . $in . ");});\r\n"; } return $stdout; }
private static function outputPeopleLayoutBox($userarray = array()) { if (empty($userarray)) { return BLURB_SORRY_PEOPLE_SEARCH . "<!-- outputPeopleLayoutBox -->\r\n"; } $stdout = ""; // --------------------------------------------------------------------------- // SET WHICH COLUMNS TO DISPLAY // --------------------------------------------------------------------------- $fields = array("nw_fullname_reverse"); $defaultSortby = "nw_fullname_reverse_sortable"; // --------------------------------------------------------------------------- // REARRANGE DATA INTO CONVENIENT OUTPUT ARRAYS // Input: $userarray[username][fieldname] = array(record) // Output: $peopleEntries[][][] // --------------------------------------------------------------------------- if (!class_exists("search", FALSE)) { require_once PATH_CLASSES . "/lib/search.php"; } if (!isset($GLOBALS["QUERY"])) { search::analyzeQuery(); } $userarray = self::adaptForOutput($userarray, "", "", $fields); $userarrayMod = $userarray; foreach ($userarray as $usr => $entry) { // -- Trim CV field around matches if (isset($entry["nw_cv"]["plain"]) && !empty($entry["nw_cv"]["plain"]) && isset($GLOBALS["QUERY"]["_andor"])) { $userarrayMod[$usr]["nw_cv"]["plain"] = "... " . search::chopMatchText($GLOBALS["QUERY"]["_andor"], $entry["nw_cv"]["plain"]); //$userarrayMod[$usr]["nw_cv"]["plain"] = search::trimMatchText($entry["nw_cv"]["plain"]); } // -- Mark hits as bold foreach ($entry as $key => $val) { if ($key == "nw_email_plain" && !empty($val)) { list($u, $d) = explode("@", $val); $userarrayMod[$usr][$key] = search::auxOutputFormat(htmlspecialchars_decode(strip_tags($u)), $GLOBALS["QUERY"]["_andor"]) . "@" . $d; } elseif ($key == "nw_cv" && isset($val["plain"])) { $userarrayMod[$usr][$key]["plain"] = search::auxOutputFormat(htmlspecialchars_decode(strip_tags($val["plain"])), $GLOBALS["QUERY"]["_andor"]); } elseif (!in_array($key, array("nw_image_small", "nw_user"))) { $userarrayMod[$usr][$key] = search::auxOutputFormat(htmlspecialchars_decode(strip_tags($val)), $GLOBALS["QUERY"]["_andor"]); } } // -- Obscurify e-mail addresses $a = explode("@", $userarrayMod[$usr]["nw_email_plain"]); if (count($a) == 2) { $userarrayMod[$usr]["nw_email_plain"] = $a[0] . functions::obscurify_email("@" . $a[1]); } } // --------------------------------------------------------------------------- // OUTPUT TO SCREEN // --------------------------------------------------------------------------- $stdout .= " <div id='people-list'>\r\n" . "\r\n" . (!empty($doctitle) ? " <h2>" . $doctitle . "</h2>\r\n" : "") . "\r\n" . " <table class='box'>\r\n"; foreach ($userarrayMod as $usr => $entry) { $stdout .= " <tr>\r\n" . " <td class='img' style='width:60px!important'>\r\n" . " <a href='people/staff/index.php?" . "u=" . $entry["nw_user"] . "'>" . "<img src='" . $entry["nw_image_small"] . "' alt='' class='darkshadow'></a>\r\n" . " </td>\r\n" . " <td>\r\n" . " <p class='fullname'><a href='people/staff/index.php?" . "u=" . $entry["nw_user"] . "'>" . str_replace(" ", " ", $entry["nw_fullname"]) . "</a></p>\r\n" . (!empty($entry["nw_leaveofabsence"]) ? " <p>» <em>" . $entry["nw_leaveofabsence"] . "</em></p>\r\n" : "") . " <p>" . $entry["nw_employeeTitle"] . "</p>\r\n" . " <p>" . $entry["nw_groupShort"] . "</p>\r\n" . (!empty($entry["nw_email"]) ? " <p><em>E-mail</em>: " . $entry["nw_email_plain"] . "</p>\r\n" : "") . (!empty($entry["nw_office"]) ? " <p><em>Room</em>: " . $entry["nw_office"] . "</p>\r\n" : "") . (!empty($entry["nw_phone_linked"]) ? " <p><em>Phone</em>: " . $entry["nw_phone_linked"] . "</p>\r\n" : "") . (!empty($entry["nw_city"]) ? " <p><em>Nordita branch</em>: " . $entry["nw_city"] . "</p>\r\n" : " ") . (isset($entry["nw_cv"]["plain"]) && !empty($entry["nw_cv"]["plain"]) && strpos($entry["nw_cv"]["plain"], "<strong>") !== false ? " <dl><dt><em>CV and Research Interests</em>:</dt><dd>" . $entry["nw_cv"]["plain"] . "</dd></dl>\r\n" : " ") . " </td>\r\n" . " </tr>\r\n"; } // end foreach $stdout .= " </table>\r\n" . "\r\n" . " </div> <!-- people-list -->\r\n"; // ------------------------------------------------- return $stdout; }
function postParsingCleanup($decodedpage) { // Repeat comment removal to affect also included templates $decodedpage = preg_replace("/<!--.+-->/imsU", "", $decodedpage); while (preg_match("/([a-z,A-Z,0-9,\\.]*)\\@([a-z,A-Z,0-9,\\.]*)/iU", $decodedpage, $mailstring)) { $oldmail = $mailstring[0]; $newmail = functions::obscurify_email($mailstring[1] . "@" . $mailstring[2]); $decodedpage = str_replace($oldmail, $newmail, $decodedpage); } // end while // Bugfix for direct logins using http://user%3apassword%40host, eg. for retreiving scans from the Xerox $decodedpage = preg_replace("~%3[aA]~", ":", $decodedpage); $decodedpage = preg_replace("~%40~", "@", $decodedpage); $decodedpage = preg_replace("~(<p>)?<nowiki>~", "", $decodedpage); $decodedpage = preg_replace("~</nowiki>(</p>)?~", "", $decodedpage); $decodedpage = preg_replace("~<p><div style=([^>]*)><img([^>]*) alt=([^>]*)></div>~iU", "<p><img\\2 alt='' class='floatleft'>", $decodedpage); // TODO: The following three rules might have unwanted side-effects: $decodedpage = preg_replace("~<p><div style=([^>]*)><img([^>]*) alt=([^>]*)>~iU", "<p><img\\2 alt='' class='floatleft'>", $decodedpage); $decodedpage = preg_replace("~</p></div>([\r\n])+~", "</p>\\1", $decodedpage); $decodedpage = preg_replace("~</p>([\r\n])+<br([^>]*)>~U", "\\1<br\\2>", $decodedpage); $decodedpage = preg_replace("~width=\"([0-9]+)[px]*\"></div><br>~iU", "width=\"\\1\"><br>", $decodedpage); $decodedpage = preg_replace("~class='floatleft'></p><p class='imagecaption'>([^<]*)</p></div>~iU", "class='floatleft'> ", $decodedpage); $decodedpage = preg_replace("~class='floatleft'></p><p class='imagecaption'>([^<]*)</p></div>~iU", "class='floatleft'> ", $decodedpage); $decodedpage = preg_replace("~<p>\\+~mU", '', $decodedpage); // dirty trick for listings of newsletters $decodedpage = preg_replace("~<div><img (.*)></div>~U", '<img \\1>', $decodedpage); $decodedpage = preg_replace("~ alt=[\"'][^>]*\\..*[\"']~U", "", $decodedpage); $decodedpage = preg_replace("~ class=[\"'][\"']~", "", $decodedpage); $decodedpage = preg_replace("~<td></p>~", "<td>", $decodedpage); $decodedpage = preg_replace("~<p></td>~", "</td>", $decodedpage); $decodedpage = preg_replace("~<p><h3>~", "<h3>", $decodedpage); $decodedpage = preg_replace("~</ul></p>~", "</ul>", $decodedpage); $decodedpage = preg_replace("~</h2></p>~", "</h2>", $decodedpage); $decodedpage = preg_replace("~</p></p>~", "</p>", $decodedpage); $decodedpage = preg_replace("~<p><p ~", "<p ", $decodedpage); $decodedpage = preg_replace("~<p><p>~", "<p>", $decodedpage); $decodedpage = preg_replace("~<p><table~", "<table", $decodedpage); $decodedpage = preg_replace("~<p><h2~", "<h2", $decodedpage); $decodedpage = preg_replace("~</table></p>~", "</table>", $decodedpage); $decodedpage = preg_replace("~[\\ ]{2,}~", " ", $decodedpage); $decodedpage = preg_replace("~> <~", "><", $decodedpage); $decodedpage = preg_replace("~[\r\n]+~", "\r\n", $decodedpage); $decodedpage = preg_replace("~<p>( )*</p>~U", "", $decodedpage); $decodedpage = preg_replace("~</p>\\s*<p>\\s*</div>\\s*</p>~", "</div>", $decodedpage); $decodedpage = preg_replace("~</div></p>~", "</p>", $decodedpage); // not particularly safe $decodedpage = preg_replace("~width=(['\"])([0-9]*)px(['\"])~U", "width=\\1\\2\\3", $decodedpage); $decodedpage = preg_replace("~<p> ~", "<p class='free'>", $decodedpage); // not particularly safe $decodedpage = preg_replace("~<p class='free'><div>~", "<p class='free'>", $decodedpage); // not particularly safe $decodedpage = preg_replace("~<p><div>~", "<p>", $decodedpage); // not particularly safe $decodedpage = preg_replace("~<p><div class='([^']*)'></p>~imsU", "<div class='\\1'>", $decodedpage); $decodedpage = preg_replace("~<p><div class=~imsU", "<div class=", $decodedpage); $decodedpage = preg_replace("~([a-z]\")\"><~", "\\1><", $decodedpage); // images $decodedpage = str_replace("h", "h", $decodedpage); $decodedpage = str_replace("</sup><strong>", "</sup> <strong>", $decodedpage); $decodedpage = str_replace("<p></div>", "</div>", $decodedpage); $decodedpage = preg_replace("~ id=\"toc\\d*\"~", "", $decodedpage); // wiki jump points $decodedpage = preg_replace("~=\"([^\"]*)\"~", "='\\1'", $decodedpage); // wiki href and src $decodedpage = preg_replace("~ href=['\"]#([^'\"]*)['\"]~", " href='" . $_SERVER["PHP_SELF"] . "#\\1'", $decodedpage); // wiki local jump link $decodedpage = str_replace("\"", """, $decodedpage); // ATER wiki href and src return $decodedpage; }
function adaptRawUserArray($userarray = array(), $status = "active") { if (empty($userarray)) { return array(); } // ------------------------------------------ // MASSAGE DATA IN ARRAY $userarray // ------------------------------------------ //if (IS_TESTSERVER) debug::rr($userarray); foreach ($userarray as $usr => $udata) { // ----------------------------------- // -- Not every user has a value for these fields: // ----------------------------------- foreach (array("e_gid", "e_inst", "e_off", "e_org", "e_rate", "e_type") as $key) { if (!isset($udata[$key])) { $udata[$key] = ""; } } // ----------------------------------- // -- Rename field nw_firstname // -- Rename field nw_lastname // ----------------------------------- // nw_firstname in maildb: "name" // nw_lastname in maildb: "namefam" $udata["nw_firstname"] = isset($udata["av_firstname"]) ? $udata["av_firstname"] : ""; $udata["nw_lastname"] = isset($udata["av_lastname"]) ? $udata["av_lastname"] : ""; // ----------------------------------- // -- Create field nw_namevon = von // -- Create field nw_vonnamefam = von lastname // -- Create field nw_fullname = firstname von lastname // -- Create field nw_fullname_break = firstname<br>von lastname // -- Create field nw_fullname_reverse = lastname, firstname von // -- Create field nw_dotname = firstname.von.lastname // ----------------------------------- // nw_namevon in maildb: "von" $udata["nw_namevon"] = $udata["av_von"]; $udata["nw_vonnamefam"] = trim($udata["av_von"] . " " . $udata["nw_lastname"]); $udata["nw_fullname"] = str_replace(" ", " ", str_replace("-", "‑", $udata["nw_firstname"])) . " " . (!empty($udata["av_von"]) ? $udata["av_von"] . " " : "") . str_replace(" ", " ", str_replace("-", "‑", $udata["nw_lastname"])); $udata["nw_fullname_break"] = str_replace(" ", " ", str_replace("-", "‑", $udata["nw_firstname"])) . "<br>" . (!empty($udata["av_von"]) ? $udata["av_von"] . " " : "") . str_replace(" ", " ", str_replace("-", "‑", $udata["nw_lastname"])); $udata["nw_fullname_reverse"] = str_replace(" ", " ", preg_replace("/" . (!empty($udata["nw_namevon"]) ? $udata["nw_namevon"] . "\\s*" : "") . "/i", "", str_replace("-", "‑", $udata["nw_lastname"]))) . ", " . str_replace(" ", " ", str_replace("-", "‑", $udata["nw_firstname"])) . (!empty($udata["nw_namevon"]) ? " " . $udata["nw_namevon"] : ""); $udata["nw_fullname_reverse_sortable"] = strtolower(functions::strip_accents($udata["nw_fullname_reverse"])); $udata["nw_dotname"] = functions::dotName($udata["nw_fullname"]); if (functions::callMethod('people', 'lib/people', 'getSpecialDotname', $udata["nw_dotname"])) { $udata["nw_dotname"] = functions::callMethod('people', 'lib/people', 'getSpecialDotname', $udata["nw_dotname"]); } // ----------------------------------- // -- Rename field nw_user // ----------------------------------- // In maildb: "user" // NB. Can't use field 'av_identity' since it is a comma-separated list of // various usernames of unknown origin $udata["nw_user"] = $udata["nw_dotname"]; // ----------------------------------- // -- Rename field nw_id_ea // -- Rename field nw_id_maildb // ----------------------------------- // ID in maildb: "m_id" // ID in ea: "av_id" $udata["nw_id_ea"] = isset($udata["av_id"]) ? $udata["av_id"] : ""; $udata["nw_id_maildb"] = isset($udata["m_id"]) ? $udata["m_id"] : ""; // ----------------------------------- // -- Rename field nw_localinstitute // ----------------------------------- // In maildb: "institution" //TODO: 'av_institute' not reliable! $udata["nw_localinstitute"] = isset($udata["av_institute"]) ? strtolower($udata["av_institute"]) : ""; $ins = explode(",", $udata["nw_localinstitute"]); $insAll = array(); foreach ($ins as $item) { switch ($item) { case "nordita": $insAll[] = "NOR"; break; case "fysikum": $insAll[] = "FKM"; break; case "albanova": $insAll[] = "ALB"; break; case "vetenskapens hus": case "vetenskapenshus": $insAll[] = "VH"; break; } } $udata["nw_localinstitute"] = join(",", $insAll); // ----------------------------------- // -- Rename field nw_institute // ----------------------------------- // In maildb: ~"institution" $udata["nw_institute"] = isset($udata["av_institute"]) ? ucfirst($udata["av_institute"]) : ""; // ----------------------------------- // -- Rename field nw_ssn // ----------------------------------- // In maildb: "pers_number" $udata["nw_ssn"] = isset($udata["av_ssn"]) ? $udata["av_ssn"] : ""; // ----------------------------------- // -- Rename field nw_birthdate // -- Create field nw_birthday // ----------------------------------- // NB: 'av_birthdate' is a timestamp, 'nw_birthdate' is a date YYYY-MM-DD if (!empty($udata["av_birthdate"]) && abs($udata["av_birthdate"]) > date("Y")) { // must be a timestamp, not a year $udata["nw_birthdate"] = date("Y-m-d", $udata["av_birthdate"]); } elseif (!empty($udata["nw_ssn"]) && preg_match("/^(\\d\\d)(\\d\\d)(\\d\\d)/", $udata["nw_ssn"], $pn) && $pn[1] != "00") { $udata["nw_birthdate"] = ($pn[1] > date("y") + 10 ? "19" : "20") . $pn[1] . "-" . $pn[2] . "-" . $pn[3]; } else { $udata["nw_birthdate"] = ""; } // In maildb: N/A $udata["nw_birthday"] = !empty($udata["nw_birthdate"]) && ($t = strtotime($udata["nw_birthdate"])) ? date("m-d", $t) : ""; // ----------------------------------- // -- Rename field nw_office // ----------------------------------- // In maildb: "office" $udata["nw_office"] = isset($udata["e_off"]) ? $udata["e_off"] : ""; // ----------------------------------- // -- Create field nw_leaveofabsence, nw_notyetarrived // (call after nw_office) // ----------------------------------- if (!isset($udata["nw_leaveofabsence"])) { $udata["nw_leaveofabsence"] = ""; if (strpos(mb_strtolower($udata["nw_office"]), "leave of absence") !== false || strpos(mb_strtolower($udata["nw_office"]), "on leave") !== false) { $udata["nw_leaveofabsence"] = "On leave of absence"; } elseif (strpos($udata["nw_office"], "from") !== false || strpos($udata["nw_office"], "Arrives") !== false || strpos($udata["nw_office"], "arrives") !== false) { $udata["nw_leaveofabsence"] = $udata["nw_notyetarrived"] = $udata["nw_office"]; } } if (!empty($udata["nw_leaveofabsence"])) { $udata["nw_office"] = ""; } // ----------------------------------- // -- Create field nw_acc_kth // -- Create field nw_acc_su // -- Create field nw_acc_nbi // -- Create field nw_acc_maildb // ----------------------------------- $udata["nw_acc_kth"] = isset($udata["acc_kth"]) ? $udata["acc_kth"] : ""; // In maildb: "acc_kth" $udata["nw_acc_su"] = isset($udata["acc_su"]) ? $udata["acc_su"] : ""; // In maildb: "acc_su" $udata["nw_acc_nbi"] = !empty($udata["maildrop"]) && preg_match("/([^@]*)\\@(.*).dk/", $udata["maildrop"], $res) ? $res[1] : ""; // $udata["nw_acc_nbi"] = (isset($udata["acc_nbi"])) ? $udata["acc_nbi"] : ""; // $udata["nw_acc_nbi"] = (!empty($udata["av_email"]) // Use "av_email" and "av_email2", not "nw_email" // && preg_match("/^(.+)@nbi.dk$/i",$udata["av_email"],$nbi)) // ? $nbi[1] // : ""; // In maildb: "cmt" and "maildrop" $udata["nw_acc_maildb"] = isset($udata["user"]) ? $udata["user"] : ""; // $udata["nw_acc_maildb"] = (isset($udata["av_identity"])) ? $udata["av_identity"] : ""; // In maildb: "user" // ----------------------------------- // -- Rename field nw_phone // -- Create field nw_extension // -- Create field nw_phone_linked // (call after nw_notyetarrived) // ----------------------------------- $udata["nw_phone"] = isset($udata["av_phone"]) ? $udata["av_phone"] : ""; // In maildb: "phone" $udata["nw_extension"] = ""; if ($udata["nw_phone"] == "0000") { $udata["nw_phone"] = ""; } else { $udata["nw_phone"] = preg_replace("/ (..) (..)/", " \\1\\2", $udata["nw_phone"]); $udata["nw_phone"] = trim(str_replace(" ", " ", $udata["nw_phone"])); if (strlen($udata["nw_phone"]) == 4) { $udata["nw_extension"] = $udata["nw_phone"]; $udata["nw_phone"] = "+46 8 5537 <strong>" . $udata["nw_phone"] . "</strong>"; } elseif (preg_match("/46[\\D]*8[\\D]*5537[\\D]*(\\d\\d\\d\\d)/", $udata["nw_phone"], $res)) { $udata["nw_extension"] = $res[1]; $udata["nw_phone"] = "+46 8 5537 <strong>" . $res[1] . "</strong>"; } elseif (preg_match("/46[\\D]*8[\\D]*16[\\D]*(\\d\\d\\d\\d)/", $udata["nw_phone"], $res)) { $udata["nw_extension"] = $res[1]; $udata["nw_phone"] = "+46 8 16 <strong>" . $res[1] . "</strong>"; } elseif (preg_match("/46[\\D]*8[\\D]*674[\\D]*(\\d\\d\\d\\d)/", $udata["nw_phone"], $res)) { $udata["nw_extension"] = $res[1]; $udata["nw_phone"] = "+46 8 674 <strong>" . $res[1] . "</strong>"; } $udata["nw_phone"] = str_replace(" ", " ", $udata["nw_phone"]); } $phonestring = substr($udata["nw_phone"], 0, 1) == "+" ? str_replace(" ", "", str_replace(" ", "", str_replace("-", "", strip_tags($udata["nw_phone"])))) : ""; $udata["nw_phone_linked"] = !empty($phonestring) ? "<a href='tel:" . $phonestring . "'>" . $udata["nw_phone"] . "</a>" : $udata["nw_phone"]; if (!empty($udata["nw_notyetarrived"])) { $udata["nw_phone"] = ""; $udata["nw_extension"] = ""; $udata["nw_phone_linked"] = ""; } // ----------------------------------- // -- Create field nw_city // (after nw_phone) // ----------------------------------- $udata["nw_city"] = strpos($udata["nw_phone"], "+45") !== false ? "Copenhagen" : "Stockholm"; // Also in ea: "av_residentship" // ----------------------------------- // -- Create field nw_fax // (after nw_phone) // ----------------------------------- $udata["nw_fax"] = strpos($udata["nw_phone"], "+45") !== false ? FAX_COPENHAGEN_EXT : FAX_STOCKHOLM_EXT; // ----------------------------------- // -- Create field nw_building // (call after 'nw_city' and 'nw_leaveofabsence') // ----------------------------------- if ($udata["nw_city"] == "Copenhagen") { $udata["nw_building"] = "dk"; // "NBI (Copenhagen)" } elseif (preg_match("/^13/i", $udata["nw_office"], $res)) { $udata["nw_building"] = "13"; // "Nordita East Building" } elseif (preg_match("/^12/i", $udata["nw_office"], $res)) { $udata["nw_building"] = "12"; // "Nordita West Building" } elseif (preg_match("/^11/i", $udata["nw_office"], $res)) { $udata["nw_building"] = "11"; // "Nordita South Building" } elseif (preg_match("/^A5/i", $udata["nw_office"], $res)) { $udata["nw_building"] = "an"; // "AlbaNova Main Building" } else { $udata["nw_building"] = ""; } // ----------------------------------- // -- Create field nw_email // -- Create field nw_email_plain // (call after nw_notyetarrived) // ----------------------------------- // These fields exist but are not set for all users: // In ea: "av_email" // In maildb: "m_email" or "maildrop", see also "forward" // First check if people::$specialmail contains special instructions $smail = functions::callMethod('people', 'lib/people', 'getSpecialMail', $udata["nw_user"]); $udata["nw_email_plain"] = ""; if ($smail !== false) { $udata["nw_email_plain"] = $smail; } elseif (empty($udata["nw_notyetarrived"])) { $udata["nw_email_plain"] = $udata["nw_user"] . "@" . MAIL_DOMAIN; } $udata["nw_email"] = functions::obscurify_email($udata["nw_email_plain"]); // ----------------------------------- // -- Rename field nw_gid // -- Create field nw_group // -- Create field nw_groupShort // ----------------------------------- // in ea: "e_gid" // In maildb: "groupid" $udata["nw_group"] = $udata["nw_groupShort"] = $udata["nw_gid"] = ""; if (!empty($udata["e_gid"])) { $gridtmp = explode(",", $udata["e_gid"]); unset($grid); unset($gid); foreach ($gridtmp as $k => $v) { $v = trim($v); if ($v == "grund") { $v = "adm"; } if ($v == "admin") { $v = "adm"; } $gid[] = $v; if (isset($this->researchGroups[$v])) { $grid[] = $this->researchGroups[$v]; } } $udata["nw_group"] = isset($grid) && is_array($grid) ? implode("; ", $grid) : ""; $udata["nw_groupShort"] = str_replace("Statistical ", "Stat. ", str_replace("Condensed ", "Cond. ", $udata["nw_group"])); $udata["nw_gid"] = is_array($gid) ? implode(",", $gid) : ""; $udata["nw_gid"] = preg_replace("/^,/", "", preg_replace("/,\$/", "", str_replace(",,", ",", str_replace("kof", "", str_replace("BIO", "CM", str_replace("MA", "SA", str_replace("NP", "SA", str_replace("HP", "SA", $udata["nw_gid"])))))))); } // ----------------------------------- // -- Rename field nw_employmentStart // -- Rename field nw_employmentEnd // -- Create field nw_employmentPeriod // ----------------------------------- $udata["nw_employmentStart"] = isset($udata["lm_key"]) ? $udata["lm_key"] : ""; $udata["nw_employmentEnd"] = isset($udata["lm_status"]) ? $udata["lm_status"] : ""; // In maildb: "norPeriodOfStay" if ($udata["nw_employmentEnd"] > date("Y-m-d", mktime(0, 0, 0, 1, 1, date("Y") + 15))) { $udata["nw_employmentEnd"] = ""; } $udata["nw_employmentPeriod"] = functions::readableDateInterval($udata["nw_employmentStart"], $udata["nw_employmentEnd"], 1); // ----------------------------------- // -- Create field nw_status // ----------------------------------- // In maildb: "status" //TODO: $udata["nw_status"] = date("Y-m-d") <= $udata["nw_employmentEnd"] || empty($udata["nw_employmentEnd"]) ? "Active" : "Passive"; // ----------------------------------- // -- Rename field nw_employeeTitle // ----------------------------------- $udata["nw_employeeTitle"] = mb_strtolower($udata["lm_value"]); // In maildb: "employeeTitle" // Also in ea: "av_salutation" // 'lm_data' can be of the form "professor / professor emeritus", concatenating all // positions held by the user at Nordita over time. if (preg_match("#/\\S*([^/]*\\S*em[ei]rit[aus]*)\\S*/?#i", $udata["nw_employeeTitle"], $res)) { $udata["nw_employeeTitle"] = trim($res[1]); } $udata["nw_employeeTitle"] = preg_replace("#deputy director / professor#", "professor, deputy director", $udata["nw_employeeTitle"]); $udata["nw_employeeTitle"] = preg_replace("#visiting professor,professor#", "visiting professor", $udata["nw_employeeTitle"]); $udata["nw_employeeTitle"] = preg_replace("#phd student,associate phd student#", "associate phd student", $udata["nw_employeeTitle"]); if (strpos($udata["nw_employeeTitle"], "/") !== false) { $tmp = explode("/", $udata["nw_employeeTitle"]); $udata["nw_employeeTitle"] = trim(array_pop($tmp)); } // Cleanup of some exact string matches if ($udata["nw_employeeTitle"] == "fellow") { $udata["nw_employeeTitle"] = "nordita fellow"; } elseif (in_array($udata["nw_employeeTitle"], array("vice director", "deputy director"))) { $udata["nw_employeeTitle"] = "professor, deputy director"; } elseif ($udata["nw_employeeTitle"] == "director") { $udata["nw_employeeTitle"] = "professor, director"; } $etArray = explode(",", $udata["nw_employeeTitle"]); foreach ($etArray as $key => $title) { $title = trim($title); $etArray[$key] = ucfirst(str_ireplace("emiritus", "emeritus", str_ireplace("nordita", "Nordita", str_ireplace(" ", " ", str_ireplace("postdoctoral fellow", "postdoc", str_ireplace("postdoctoral researcher", "postdoc", str_ireplace("prof.", "professor", str_ireplace("phd", "PhD", str_ireplace("Visiting professor, Professor", "Visiting professor", str_ireplace("Hr officer", "HR officer", str_ireplace("Professor / ", "", str_ireplace("Ass.professor / ", "", $title)))))))))))); } $udata["nw_employeeTitle"] = join(", ", $etArray); // ----------------------------------- // -- Create field nw_employeeTitleShort // ----------------------------------- $udata["nw_employeeTitleShort"] = str_ireplace("Assistant", "Asst.", str_ireplace("Professor emeritus", "Prof. emer.", str_ireplace("Director emeritus", "Director. emer.", preg_replace("/ssociate[d]?/", "ssoc.", str_replace("orresponding", "orresp.", str_replace("ostdoctoral", "ostdoct.", str_replace("eputy", "ep.", str_replace("coordinator", "coord.", $udata["nw_employeeTitle"])))))))); // ----------------------------------- // -- Rename field nw_employeeType // ["faculty"|"fellows"|"visitors"|"postgrads"|"admin"] // After setting of "nw_employeeTitle" // ----------------------------------- $udata["nw_employeeType"] = functions::callMethod('people', 'lib/people', 'getEmploymentTypeFromTitle', $udata["nw_employeeTitle"]); if (empty($udata["nw_employeeType"])) { $udata["nw_employeeType"] = isset($udata["e_rate"]) ? $udata["e_rate"] : ""; // In maildb: "employeeType" // In ea: "lm_value" if ($udata["um_status"] == "v") { $udata["nw_employeeType"] = "visitors"; } } // ----------------------------------- // -- Create field nw_employeeTitleGrp // ----------------------------------- if (!class_exists("people", FALSE)) { require_once PATH_CLASSES . "/lib/people.php"; } $udata["nw_employeeTitleGrp"] = isset(people::$fieldnames[$udata["nw_employeeType"]]) ? people::$fieldnames[$udata["nw_employeeType"]] : ""; /* $grpArray = array(); foreach ($etArray as $key => $title) { switch (str_replace(" "," ",mb_strtolower($title))) { case "professor": case "professor emeritus": case "visiting professor": case "corresponding professor": case "associate professor": $grpArray["Professors"] = 1; if (empty($udata["nw_employeeType"])) $udata["nw_employeeType"] = "faculty"; break; case "assistant professor": case "visiting assistant professor": case "corresponding assistant professor": case "associate assistant professor": case "senior lecturer": case "visiting senior lecturer": case "corresponding senior lecturer": case "associate senior lecturer": $grpArray["Assistant Professors"] = 1; if (empty($udata["nw_employeeType"])) $udata["nw_employeeType"] = "faculty"; break; case "fellow": case "nordita fellow": case "postdoc": case "postdoctoral fellow": case "visiting fellow": case "visiting postdoc": case "visiting postdoctoral fellow": case "corresponding fellow": case "corresponding postdoc": case "associate fellow": case "associate postdoc": $grpArray["Postdocs"] = 1; if (empty($udata["nw_employeeType"])) $udata["nw_employeeType"] = "fellows"; break; case "phd student": case "phd fellow": case "visiting phd fellow": case "visiting phd student": case "corresponding phd student": case "corresponding phd fellow": case "associate phd student": case "associate phd fellow": $grpArray["PhD Students"] = 1; if (empty($udata["nw_employeeType"])) $udata["nw_employeeType"] = "postgrads"; break; case "masters student": case "visiting masters student": case "corresponding masters student": case "associate masters student": $grpArray["Masters Students"] = 1; if (empty($udata["nw_employeeType"])) $udata["nw_employeeType"] = "postgrads"; break; case "web and computing": case "economic officer": case "scientific program coordinator": case "student assistant": case "administrator": case "director": case "deputy director": case "hr officer": case "head of computing": case "head of administration": case "director emeritus": $grpArray["Administration"] = 1; if (empty($udata["nw_employeeType"])) $udata["nw_employeeType"] = "admin"; break; default: $grpArray[ucfirst($udata["nw_employeeTitle"])] = 1; break; } // end switch } // end foreach $udata["nw_employeeTitleGrp"] = join(", ",array_keys($grpArray)); */ // ----------------------------------- // -- Create field nw_image_small // -- Create field nw_image_medium // -- Create field nw_image_large // ----------------------------------- // In ea: "av_photo" // In maildb: "m_photo" $udata["nw_image_small"] = PATH_PEOPLE . "/48x48/" . "blank-48.png"; $pic_sans_ext = PATH_PEOPLE . "/48x48/" . $udata["nw_user"] . "-48"; foreach (array('.png', '.jpg', '.jpeg') as $ext) { if (file_exists(INCLEVEL . $pic_sans_ext . $ext)) { $udata["nw_image_small"] = $pic_sans_ext . $ext; break; } } $udata["nw_image_medium"] = PATH_PEOPLE . "/85x113/" . "blank-3x4.png"; $pic_sans_ext = PATH_PEOPLE . "/85x113/" . $udata["nw_user"] . "-3x4"; foreach (array('.png', '.jpg', '.jpeg') as $ext) { if (file_exists(INCLEVEL . $pic_sans_ext . $ext)) { $udata["nw_image_medium"] = $pic_sans_ext . $ext; break; } } $udata["nw_image_large"] = PATH_PEOPLE . "/188x250/" . "blank.png"; $pic_sans_ext = PATH_PEOPLE . "/188x250/" . $udata["nw_user"]; foreach (array('.png', '.jpg', '.jpeg') as $ext) { if (file_exists(INCLEVEL . $pic_sans_ext . $ext)) { $udata["nw_image_large"] = $pic_sans_ext . $ext; break; } } // ----------------------------------- // -- Create field nw_homepage // -- Create field nw_homepage_unlinked // ----------------------------------- // Also in ea: "av_http" $udata["nw_homepage_unlinked"] = ""; $udata["nw_homepage"] = ""; //TODO: fetch people::hasValidHomepage() from cache $slask = array($udata["nw_acc_kth"], $udata["nw_acc_su"], $udata["nw_acc_nbi"], $udata["nw_acc_maildb"], $udata["nw_user"]); if ($sweb = functions::callMethod('people', 'lib/people', 'getSpecialHomepage', $udata["nw_user"])) { $udata["nw_homepage_unlinked"] = $sweb; $udata["nw_homepage"] = "<a href='http://" . $sweb . "'" . ">" . $sweb . "</a>"; } elseif (functions::callMethod('people', 'lib/people', 'hasValidHomepage', $udata["nw_user"])) { $udata["nw_homepage_unlinked"] = "www.nordita.org/~" . $udata["nw_user"]; $udata["nw_homepage"] = "<a href='http://" . $udata["nw_homepage_unlinked"] . "/'" . ">" . $udata["nw_homepage_unlinked"] . "</a>"; } // ----------------------------------- // -- Rename field nw_home_address // -- Rename field nw_home_zip // -- Rename field nw_home_city // -- Create field nw_home_phone // -- Create field nw_phone_mobile // ----------------------------------- $udata["nw_home_address"] = isset($udata["av_address"]) ? $udata["av_address"] : ""; // In maildb: "address" $udata["nw_home_zip"] = isset($udata["av_zip"]) ? $udata["av_zip"] : ""; // In maildb: "postnummer" $udata["nw_home_city"] = isset($udata["av_city"]) ? $udata["av_city"] : ""; // In maildb: "ortnamn" //TODO: $udata["nw_home_phone"] = ""; // (isset($udata[""])) ? $udata[""] : ""; // In maildb: "phone_home" //TODO: $udata["nw_phone_mobile"] = ""; // (isset($udata[""])) ? $udata[""] : ""; // In maildb: "phone_mobile" // ----------------------------------- // -- Rename field nw_cv // ----------------------------------- $udata["nw_cv"] = isset($udata["cv"]) ? $udata["cv"] : ""; if ($udata["nw_cv"]["text"] == "") { if (!class_exists("fromdb_cv", FALSE)) { require_once PATH_CLASSES . "/fromdb/cv.php"; } $dbCvs = new fromdb_cv(); $cvitems = $dbCvs->getCvs(); // array("text","brief") $udata["nw_cv"] = isset($cvitems[$udata["nw_user"]]) ? $cvitems[$udata["nw_user"]] : array("text" => "", "brief" => ""); $udata["nw_cv"]["text"] = str_replace("<p></p>", "", $udata["nw_cv"]["text"]); $udata["nw_cv"]["plain"] = isset($udata["nw_cv"]["text"]) ? strip_tags($udata["nw_cv"]["text"]) : ""; } // ----------------------------------- // ERASE OBSOLETE FIELDS IN DB OUTPUT // ----------------------------------- foreach (array("acc_kth", "acc_su", "acc_nbi", "acc_maildb", "av_address", "av_birthcountry", "av_birthdate", "av_birthplace", "av_citizenship", "av_city", "av_ddate", "av_email", "av_email2", "av_firstname", "av_http", "av_id", "av_id2", "av_identity", "av_institute", "av_lastlogin", "av_lastname", "av_ms_country", "av_ms_institute", "av_ms_year", "av_phd_adviser_avid", "av_phd_country", "av_phd_institute", "av_phd_year", "av_phone", "av_photo", "av_position", "av_pwd", "av_pwd2", "av_residentship", "av_salutation", "av_sex", "av_ssn", "av_timestamp", "av_zip", "av_timestamp", "av_von", "e_cc", "e_gid", "e_inst", "e_off", "e_org", "e_rate", "e_type", "lm_value", "lm_key", "lm_status", "lm_option", "um_status", "altname", "altacct", "maildrop", "user", "cv") as $field) { if (isset($udata[$field])) { unset($udata[$field]); } } // ----------------------------------- // COLLECT DATA FROM OTHER SOURCES, IF NEEDED // ----------------------------------- include PATH_DATA . "/adhoc_people_data.php"; // ----------------------------------- // SAVE BACK CHANGES INTO ARRAY $userarray // NB. An empty $status papameter should be interpreted as "any status" // ------------------------------------------------------------------------- if (empty($status) || strtolower($udata["nw_status"]) == $status || $status == "alumni") { $userarray[$usr] = $udata; } } // end foreach // ------------------------------------------ return $userarray; }