Пример #1
0
 public static function OutputQrcode()
 {
     $stdout = "";
     $showform = 1;
     $founderror = $error = $warning = array();
     // gpc_declare_input ($vname, $default, $bool, $allowed, $set_session, $strip_tags)
     functions::gpc_declare_input_experimental("doit", false, true);
     functions::gpc_declare_input_experimental("qr-ext", "", false);
     functions::gpc_declare_input_experimental("qr-text", "", false);
     functions::gpc_declare_input_experimental("qr-zoom", QRCODE_DEFAULT_PIXELSIZE, false);
     functions::gpc_declare_input_experimental("qr-level", QRCODE_DEFAULT_LEVEL, false);
     functions::gpc_declare_input_experimental("qr-width", QRCODE_DEFAULT_IMAGEWIDTH, false);
     // ---------------------------------------
     if (in_array($GLOBALS["qr-ext"], self::$filetypes)) {
         return self::outputQrcodeCreate($GLOBALS["qr-text"], $GLOBALS["qr-zoom"], $GLOBALS["qr-level"], $GLOBALS["qr-width"], $GLOBALS["qr-ext"]);
     }
     // end if ($GLOBALS["display"])
     // ---------------------------------------
     if ($GLOBALS["doit"]) {
         if (empty($GLOBALS["qr-text"])) {
             $founderror["qr-text"] = 1;
             $error[] = "Please type an URL or text to be embedded in the QR code";
         }
         if (!is_numeric($GLOBALS["qr-width"])) {
             $founderror["qr-width"] = 1;
             $error[] = "Please select a size of the QR code image in pixels";
         }
         if ($GLOBALS["qr-width"] < 100 || $GLOBALS["qr-width"] > 2000) {
             $founderror["qr-width"] = 1;
             $error[] = "Please select a QR code image size between 100 px and 2000 px";
         }
         if (!is_numeric($GLOBALS["qr-zoom"]) || !is_int($GLOBALS["qr-zoom"] + 0) || $GLOBALS["qr-zoom"] < 1) {
             $founderror["qr-zoom"] = 1;
             $error[] = "The zoom factor must be a positive integer";
         }
         if (!isset(self::$errorlevels[$GLOBALS["qr-level"]])) {
             $founderror["qr-level"] = 1;
             $error[] = "Please select a valid QR code error correction level";
         }
         // -------------------------------------
         if (empty($founderror)) {
             $stdout .= "<div class='col-content-left'>\r\n" . self::outputQrcodeCreate($GLOBALS["qr-text"], $GLOBALS["qr-zoom"], $GLOBALS["qr-level"]) . "</div>\r\n";
         }
     }
     // end if ($GLOBALS["doit"])
     // ---------------------------------------
     // form
     if ($showform) {
         $stdout .= "<div class='col-content-right divider'>\r\n" . self::outputQrcodeForm($founderror, $error, $warning) . "</div>\r\n";
     }
     // ---------------------------------------
     $stdout .= "<div style='clear:both'>\r\n";
     return $stdout;
 }
Пример #2
0
 public static function OutputEventPartMail()
 {
     //    $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();
     }
     $stdout = "";
     $mailaddresses = $mailaddressesEvent = $mailbyexpenses = array();
     if (!defined("EXPENSES_LABEL_DO")) {
         define("EXPENSES_LABEL_DO", "grouping e-mail addresses by participant expenses");
     }
     if (!defined("EXPENSES_LABEL_DONT")) {
         define("EXPENSES_LABEL_DONT", "sorting e-mail addresses alphabetically");
     }
     if (!defined("WEEK_DO")) {
         define("WEEK_DO", "grouping e-mail addresses by week within the event");
     }
     if (!defined("WEEK_DONT")) {
         define("WEEK_DONT", "listing e-mail addresses for the entire event");
     }
     if (!defined("REJECTED_DO")) {
         define("REJECTED_DO", "display accepted, pending and rejected applicants");
     }
     if (!defined("REJECTED_DONT")) {
         define("REJECTED_DONT", "display only accepted applicants");
     }
     // ------------------------------------------------------------------------
     // Output drop-down list
     // ------------------------------------------------------------------------
     $stdout .= event::outputEventDropdown(array("semicolon", "byexpenses"), "participant e-mail addresses");
     // ------------------------------------------------------------------------
     if (!isset($_REQUEST["confid"]) || empty($_REQUEST["confid"])) {
         return $stdout;
     }
     // ------------------------------------------------------------------------
     // GPC
     // ------------------------------------------------------------------------
     // gpc_declare_input ($vname, $default, $bool, $allowed, $set_session, $strip_tags)
     // 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"]);
     }
     //TODO: have 4 views instead of 4 toggles
     functions::gpc_declare_input_experimental("with_semicolon", "comma", false, array(), true);
     functions::gpc_declare_input_experimental("by_expenses", EXPENSES_LABEL_DONT, false, array(), true);
     functions::gpc_declare_input_experimental("by_week", WEEK_DONT, false, array(), false);
     functions::gpc_declare_input_experimental("by_acceptance", REJECTED_DONT, false, array(), false);
     // ------------------------------------------------------------------------
     // Obtain data
     // ------------------------------------------------------------------------
     // Obtain mailaddresses for each requested event
     foreach ($confidArray as $confid) {
         $eventShortname[$confid] = $GLOBALS["documentClass"]->getPathFromAgendaId($confid);
         $eventTitle[$confid] = event::getEventByAgendaid($confid, "title");
         $dates[$confid] = $dbVm->getDateInterval($confid);
         $year[$confid] = isset($dates[$confid][1]) ? date("Y", strtotime($dates[$confid][1])) : "";
         if ($GLOBALS["by_week"] == WEEK_DO) {
             // $mailaddressesEvent[$confid] = array(weekNumber=>array(idx=>emailAddress))
             $mailaddressesEvent[$confid] = $dbVm->getEventsParticipantMailsByWeek($confid);
         } elseif ($GLOBALS["by_expenses"] == EXPENSES_LABEL_DO) {
             // $mailaddressesEvent[$confid] = array("with accommodation expenses"|"no accommodation expenses"=>array("with travel expenses"|"no travel expenses"=>array(idx=>emailAddress))
             $mailaddressesEvent[$confid] = $dbVm->getEventsParticipantMailsByExpenses($confid);
         } elseif ($GLOBALS["by_acceptance"] == REJECTED_DO) {
             // $mailaddressesEvent[$confid] = array("accepted"|"pending"|"rejected"=>array(idx=>emailAddress))
             $mailaddressesEvent[$confid] = $dbVm->getEventsParticipantMailsByAcceptance($confid, 0, 1);
         } else {
             // $mailaddressesEvent[$confid] = essentially commaseparated string of email addresses
             $mailaddressesEvent[$confid] = $dbVm->getEventsParticipantMails($confid, 1);
             // Remove dummy "@nordita.org" addresses (used sometimes for people coming for two
             // disjoint periods). Note that this regexp also might kill genuine Nordita participants!
             $mailaddressesEvent[$confid] = preg_replace("/([^\\ ]*-[^\\ ]*\\@nordita.org,?)/i", "", $mailaddressesEvent[$confid]);
         }
     }
     $temp = array();
     // Merge all mailaddresses to one string
     foreach ($mailaddressesEvent as $confid => $data) {
         if ($GLOBALS["by_week"] == WEEK_DO) {
             foreach ($data as $week => $data2) {
                 foreach ($data2 as $email => $slask) {
                     if (!isset($temp[$week][$email])) {
                         $temp[$week][$email] = 1;
                     }
                 }
             }
             $mailaddresses = empty($temp) ? array() : $temp;
         } elseif ($GLOBALS["by_expenses"] == EXPENSES_LABEL_DO) {
             foreach ($data as $living => $data2) {
                 foreach ($data2 as $travel => $data3) {
                     foreach ($data3 as $email) {
                         if (!isset($temp[$living][$travel][$email])) {
                             $temp[$living][$travel][] = $email;
                         }
                     }
                 }
             }
             $mailaddresses = empty($temp) ? array() : $temp;
         } elseif ($GLOBALS["by_acceptance"] == REJECTED_DO) {
             foreach ($data as $status => $data2) {
                 foreach ($data2 as $email) {
                     if (!in_array($email, $temp[$status])) {
                         $temp[$status][] = $email;
                     }
                 }
             }
             $mailaddresses = empty($temp) ? array() : $temp;
         } else {
             if (!empty($data)) {
                 $data = preg_replace("/^\\d*#/", "", $data);
                 foreach (explode(", ", $data) as $email) {
                     $temp[strtolower($email)] = 1;
                 }
             }
             ksort($temp);
             $mailaddresses = empty($temp) ? "" : count($temp) . "#" . implode(", ", array_keys($temp));
         }
     }
     // ------------------------------------------------------------------------
     // Output data
     // ------------------------------------------------------------------------
     // ----------------------------------------
     // -- Extra form with buttons to toggle output state
     // ----------------------------------------
     $extraFieldsForm = array();
     if (isset($GLOBALS["with_semicolon"])) {
         $extraFieldsForm[] = ($GLOBALS["with_semicolon"] == "semicolon" ? "            Now using <strong>semicolon</strong> to separate e-mail addresses. " . "Switch to using \r\n" . "            <input type='submit' name='with_semicolon' " . "value='comma'>\r\n" : "            Now using <strong>comma</strong> to separate e-mail addresses. " . "Switch to using \r\n" . "            <input type='submit' name='with_semicolon' " . "value='semicolon'>\r\n") . "            as separator.\r\n";
     }
     if (isset($GLOBALS["by_expenses"])) {
         $extraFieldsForm[] = $GLOBALS["by_expenses"] == EXPENSES_LABEL_DO ? "            Now e-mail addresses are <strong>grouped by participant expenses</strong>. " . "Switch to \r\n" . "            <input type='submit' name='by_expenses' " . "value='" . EXPENSES_LABEL_DONT . "'>\r\n" : "            Now e-mail addresses are <strong>sorted alphabetically</strong>. " . "Switch to \r\n" . "            <input type='submit' name='by_expenses' " . "value='" . EXPENSES_LABEL_DO . "'>\r\n";
     }
     if (isset($GLOBALS["by_week"])) {
         $extraFieldsForm[] = $GLOBALS["by_week"] == WEEK_DO ? "            Now e-mail addresses are <strong>grouped by week within the event</strong>. " . "Switch to \r\n" . "            <input type='submit' name='by_week' " . "value='" . WEEK_DONT . "'>\r\n" : "            Now e-mail addresses are <strong>shown for the entire duration of the event</strong>. " . "Switch to \r\n" . "            <input type='submit' name='by_week' " . "value='" . WEEK_DO . "'>\r\n";
     }
     if (isset($GLOBALS["by_acceptance"])) {
         $extraFieldsForm[] = $GLOBALS["by_acceptance"] == REJECTED_DONT ? "            Now displaying <strong>only e-mail addresses for accepted applicants</strong>. " . "Switch to \r\n" . "            <input type='submit' name='by_acceptance' " . "value='" . REJECTED_DO . "'>\r\n" : "            Now displaying <strong>e-mail address for all applicants (accepted, pending and rejected)</strong>. " . "Switch to \r\n" . "            <input type='submit' name='by_acceptance' " . "value='" . REJECTED_DONT . "'>\r\n";
     }
     if (!empty($extraFieldsForm)) {
         $stdout .= "        <div class='box warning background padding only_online' style='padding-bottom:0'>\r\n" . "          <form " . "action='" . $_SERVER["PHP_SELF"] . "' " . "method='POST' " . "enctype='multipart/form-data' " . "style='margin-bottom:1em'>\r\n" . implode("            <br>\r\n", $extraFieldsForm);
         foreach ($confidArray as $i => $confid) {
             $stdout .= "            <input type='hidden' name='confid[" . $i . "]' value='" . $confid . "'>\r\n";
         }
         if (isset($GLOBALS["mode"])) {
             $stdout .= "            <input type='hidden' name='mode' value='" . $GLOBALS["mode"] . "'>\r\n";
         }
         $stdout .= "          </form>\r\n" . "        </div>\r\n" . "\r\n";
     }
     // ----------------------------------------
     // -- List of e-mail addresses
     // ----------------------------------------
     $stdout .= "        <hr class='only_online'>\r\n" . "\r\n";
     foreach ($confidArray as $confid) {
         $stdout .= "          <div class='eventheading bottommargin clear'>\r\n" . "            <p><img src='" . PATH_EVENTLOGOS . "/" . $eventShortname[$confid] . ".png' alt='' " . "style='float:left;margin:0px 20px 2em 0px;'></p>\r\n" . "            <h2>" . $eventTitle[$confid] . "</h2>\r\n" . (!empty($dates[$confid][0]) ? "            <p>" . $dates[$confid][0] . "</p>\r\n" : "<br>") . "\r\n";
     }
     if (empty($mailaddresses)) {
         return $stdout . BLURB_SORRY_NO_PARTICIPANTS;
     }
     if ($GLOBALS["with_semicolon"] == "semicolon") {
         $separator = "; ";
         $chunksize = 15;
         // 999
     } else {
         $separator = ", ";
         $chunksize = 15;
     }
     if ($GLOBALS["by_expenses"] == EXPENSES_LABEL_DO) {
         $chunksize = 999;
     }
     if ($GLOBALS["by_week"] == WEEK_DO && is_array($mailaddresses)) {
         $stdout .= "          </div>\r\n";
         foreach ($mailaddresses as $week => $items) {
             //TODO: $confid odefinierat
             $per = functions::daysInWeek($week, $year[$confid], 1);
             if (isset($per[0]) && isset($per[1])) {
                 $stdout .= "          <h4 style='clear:both'>Participants present " . functions::readableDateInterval($per[0], $per[1]) . "</h4>\r\n" . "          <p>" . implode($separator, array_keys($items)) . "</p>\r\n";
             }
         }
     } elseif ($GLOBALS["by_expenses"] == EXPENSES_LABEL_DO && is_array($mailaddresses)) {
         $stdout .= "          </div>\r\n";
         foreach ($mailaddresses as $living_label => $arr) {
             foreach ($arr as $travel_label => $addresses) {
                 sort($addresses);
                 $addressarray = array_chunk($addresses, $chunksize);
                 $stdout .= "          <h4 style='clear:both'>" . ucfirst($living_label) . " &#8212; " . ucfirst($travel_label) . "</h4>\r\n";
                 foreach ($addressarray as $chunk) {
                     $stdout .= "          <p>" . implode($separator, $chunk) . "</p>\r\n";
                 }
             }
         }
     } elseif ($GLOBALS["by_acceptance"] == REJECTED_DO && is_array($mailaddresses)) {
         $stdout .= "          </div>\r\n";
         foreach ($mailaddresses as $heading => $chunk) {
             sort($chunk);
             $stdout .= "          <h3 style='clear:both'>Mail addresses of the " . count($chunk) . " <em class='green'>" . $heading . "</em> applicants</h3>\r\n" . "          <p>" . implode($separator, $chunk) . "</p>\r\n";
         }
     } else {
         $addresstring = explode("#", $mailaddresses);
         $addresses = array_flip(array_flip(preg_split("/,\\s?/", $addresstring[1])));
         sort($addresses);
         $rem = count($addresses) % $chunksize;
         if ($rem < $chunksize / 2) {
             $chunksize = $chunksize + $rem;
         }
         $addressarray = array_chunk($addresses, $chunksize);
         $stdout .= "            <h3 style='clear:both'>MAIL ADDRESSES OF THE " . count($addresses) . " ACCEPTED PARTICIPANTS</h3>\r\n" . "          </div> <!-- eventheading -->\r\n" . (count($addressarray) <= 1 ? "" : "          <p style='margin-left:2em'>[<em>Note that most mail systems will " . "<strong>reject as spam</strong> any mail sent to more than 15-20 recipients " . "(the limit differs between systems). Rather than sending one mail to all " . "recipients listed below, <strong>you should send the same mail " . count($addressarray) . " times</strong>, each time only to the mail " . "addresses in each of the " . count($addressarray) . " groups of addresses " . "below.</em>]</p>") . "\r\n";
         foreach ($addressarray as $chunk) {
             $stdout .= "          <p>" . implode($separator, $chunk) . "</p>\r\n";
         }
     }
     // end if
     // ---------------------------
     return $stdout;
 }