/** * @param array $row * @param array $calendar * @param string $base_path * @return array */ private function jqcal2wdcal($row, $calendar, $base_path) { $not = q("SELECT COUNT(*) num FROM %s%snotifications WHERE `calendar_id` = %d AND `calendarobject_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($row["calendar_id"]), IntVal($row["calendarobject_id"])); $editable = $this->getPermissionsItem($calendar["namespace_id"], $row["calendarobject_id"], $row); $end = wdcal_mySql2PhpTime($row["EndTime"]); if ($row["IsAllDayEvent"]) { $end -= 1; } return array("jq_id" => $row["id"], "ev_id" => $row["calendarobject_id"], "summary" => escape_tags($row["Summary"]), "start" => wdcal_mySql2PhpTime($row["StartTime"]), "end" => $end, "is_allday" => $row["IsAllDayEvent"], "is_moredays" => 0, "is_recurring" => $row["IsRecurring"], "color" => is_null($row["Color"]) || $row["Color"] == "" ? $calendar["calendarcolor"] : $row["Color"], "is_editable" => $editable ? 1 : 0, "is_editable_quick" => $editable && !$row["IsRecurring"] ? 1 : 0, "location" => "Loc.", "attendees" => '', "has_notification" => $not[0]["num"] > 0 ? 1 : 0, "url_detail" => $base_path . $row["calendarobject_id"] . "/", "url_edit" => $base_path . $row["calendarobject_id"] . "/edit/", "special_type" => ""); }
/** * @param array $row * @return array */ private function virtualData2wdcal($row) { $end = wdcal_mySql2PhpTime($row["data_end"]); if ($row["data_allday"]) { $end--; } $start = wdcal_mySql2PhpTime($row["data_start"]); $a = get_app(); $arr = array("uri" => $row["data_uri"], "subject" => escape_tags($row["data_subject"]), "start" => $start, "end" => $end, "is_allday" => $row["data_allday"] == 1, "is_moredays" => date("Ymd", $start) != date("Ymd", $end), "is_recurring" => $row["data_type"] == "birthday", "color" => "#ff0000", "is_editable" => false, "is_editable_quick" => false, "location" => $row["data_location"], "attendees" => '', "has_notification" => false, "url_detail" => $a->get_baseurl() . "/dav/wdcal/" . $row["data_uri"] . "/", "url_edit" => "", "special_type" => $row["data_type"] == "birthday" ? "birthday" : ""); return $arr; }
private function jqcal2wdcal($row, $usr_id, $base_path) { $evo = new DBClass_friendica_jqcalendar($row); $not = q("SELECT COUNT(*) num FROM %s%snotifications WHERE `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($row["ical_uri"]), $row["ical_recurr_uri"]); $editable = $this->getPermissionsItem($usr_id, $row["ical_uri"], $row["ical_recurr_uri"], $row); $recurring = is_null($evo->RecurringRule) || $evo->RecurringRule == "" || $evo->RecurringRule == "NULL" ? 0 : 1; $end = wdcal_mySql2PhpTime($evo->EndTime); if ($evo->IsAllDayEvent) { $end -= 1; } $arr = array("uri" => $evo->ical_uri, "subject" => escape_tags($evo->Subject), "start" => wdcal_mySql2PhpTime($evo->StartTime), "end" => $end, "is_allday" => $evo->IsAllDayEvent, "is_moredays" => 0, "is_recurring" => $recurring, "color" => is_null($evo->Color) || $evo->Color == "" ? $this->calendarDb->calendarcolor : $evo->Color, "is_editable" => $editable ? 1 : 0, "is_editable_quick" => $editable && !$recurring ? 1 : 0, "location" => $evo->Location, "attendees" => '', "has_notification" => $not[0]["num"] > 0 ? 1 : 0, "url_detail" => $base_path . $evo->ical_uri . "/", "url_edit" => $base_path . $evo->ical_uri . "/edit/", "special_type" => ""); return $arr; }
/** * @param array $contact * @return array */ private function dav_contactarr2vcardsource($contact) { $name = explode(" ", $contact["name"]); $first_name = $last_name = ""; $middle_name = array(); $num = count($name); for ($i = 0; $i < $num && $first_name == ""; $i++) { if ($name[$i] != "") { $first_name = $name[$i]; unset($name[$i]); } } for ($i = $num - 1; $i >= 0 && $last_name == ""; $i--) { if (isset($name[$i]) && $name[$i] != "") { $last_name = $name[$i]; unset($name[$i]); } } foreach ($name as $n) { if ($n != "") { $middle_name[] = $n; } } $vcarddata = new vcard_source_data($first_name, implode(" ", $middle_name), $last_name); $vcarddata->homepages[] = new vcard_source_data_homepage("pref", $contact["url"]); $vcarddata->last_update = $contact["last-update"] > 0 ? $contact["last-update"] : $contact["created"]; $photo = q("SELECT * FROM photo WHERE `contact-id` = %d ORDER BY scale DESC", $contact["id"]); //prefer size 80x80 if ($photo && count($photo) > 0) { $photodata = new vcard_source_data_photo(); $photodata->width = $photo[0]["width"]; $photodata->height = $photo[0]["height"]; $photodata->type = "JPEG"; $photodata->binarydata = $photo[0]["data"]; $vcarddata->photo = $photodata; } switch ($contact["network"]) { case "face": $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("facebook", $contact["notify"], "http://www.facebook.com/" . $contact["notify"]); break; case "dfrn": $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("dfrn", $contact["nick"], $contact["url"]); break; case "twitter": $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("twitter", $contact["nick"], "http://twitter.com/" . $contact["nick"]); // @TODO Stimmt das? break; } $vcard = vcard_source_compile($vcarddata); return array("id" => $contact["id"], "carddata" => $vcard, "uri" => $contact["id"] . ".vcf", "lastmodified" => wdcal_mySql2PhpTime($vcarddata->last_update), "etag" => md5($vcard), "size" => strlen($vcard)); }
/** * @param string $uri * @param string $recurr_uri * @return string */ function wdcal_getEditPage($uri, $recurr_uri) { $a = get_app(); $localization = wdcal_local::getInstanceByUser($a->user["uid"]); if ($uri != "" && $uri != "new") { $o = q("SELECT * FROM %s%sjqcalendar WHERE `uid` = %d AND `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $a->user["uid"], dbesc($uri), dbesc($recurr_uri)); if (count($o) != 1) { return t('Not found'); } $event = $o[0]; $calendarSource = wdcal_calendar_factory($a->user["uid"], $event["namespace"], $event["namespace_id"]); $permissions = $calendarSource->getPermissionsItem($a->user["uid"], $uri, $recurr_uri, $event); if (!$permissions["write"]) { return t('No access'); } $n = q("SELECT * FROM %s%snotifications WHERE `uid` = %d AND `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $a->user["uid"], dbesc($uri), dbesc($recurr_uri)); if (count($n) > 0) { $notification_type = $n[0]["rel_type"]; $notification_value = -1 * $n[0]["rel_value"]; $notification = true; } else { if ($event["IsAllDayEvent"]) { $notification_type = "hour"; $notification_value = 24; } else { $notification_type = "minute"; $notification_value = 60; } $notification = false; } } elseif (isset($_REQUEST["start"]) && $_REQUEST["start"] > 0) { $event = array("id" => 0, "Subject" => $_REQUEST["title"], "Location" => "", "Description" => "", "StartTime" => $_REQUEST["start"], "EndTime" => $_REQUEST["end"], "IsAllDayEvent" => $_REQUEST["isallday"], "Color" => null, "RecurringRule" => null); if ($_REQUEST["isallday"]) { $notification_type = "hour"; $notification_value = 24; } else { $notification_type = "hour"; $notification_value = 1; } $notification = true; } else { $event = array("id" => 0, "Subject" => "", "Location" => "", "Description" => "", "StartTime" => "", "EndTime" => "", "IsAllDayEvent" => "", "Color" => null, "RecurringRule" => null); $notification_type = "hour"; $notification_value = 1; $notification = true; } $out = "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>"; $out .= "<form method='POST' action='" . $a->get_baseurl() . "/dav/wdcal/{$uri}/edit/'><input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n"; $out .= "<label for='cal_subject'>Subject:</label>\n\t\t<input name='color' id='cal_color' value='" . (strlen($event["Color"]) != 7 ? "#5858ff" : escape_tags($event["Color"])) . "'>\n\t\t<input name='subject' id='cal_subject' value='" . escape_tags($event["Subject"]) . "'><br>\n"; $out .= "<label for='cal_allday'>Is All-Day event:</label><input type='checkbox' name='allday' id='cal_allday' " . ($event["IsAllDayEvent"] ? "checked" : "") . "><br>\n"; $out .= "<label for='cal_startdate'>Starts:</label>"; $out .= "<input name='start_date' value='" . $localization->dateformat_datepicker_php(wdcal_mySql2PhpTime($event["StartTime"])) . "' id='cal_start_date'>"; $out .= "<input name='start_time' value='" . substr($event["StartTime"], 11, 5) . "' id='cal_start_time'>"; $out .= "<br>\n"; $out .= "<label for='cal_enddate'>Ends:</label>"; $out .= "<input name='end_date' value='" . $localization->dateformat_datepicker_php(wdcal_mySql2PhpTime($event["EndTime"])) . "' id='cal_end_date'>"; $out .= "<input name='end_time' value='" . substr($event["EndTime"], 11, 5) . "' id='cal_end_time'>"; $out .= "<br>\n"; $out .= "<label for='cal_location'>Location:</label><input name='location' id='cal_location' value='" . escape_tags($event["Location"]) . "'><br>\n"; $out .= "<label for='event-desc-textarea'>" . t("Description") . ":</label> <textarea id='event-desc-textarea' name='wdcal_desc' style='vertical-align: top; width: 400px; height: 100px;'>" . escape_tags($event["Description"]) . "</textarea>"; $out .= "<br style='clear: both;'>"; $out .= "<label for='notification'>" . t('Notification') . ":</label>"; $out .= '<input type="checkbox" name="notification" id="notification" '; if ($notification) { $out .= "checked"; } $out .= '> '; $out .= '<span id="notification_detail" style="display: none;"> <input name="notification_value" value="' . $notification_value . '" size="3"> <select name="notification_type" size="1"> <option value="minute" '; if ($notification_type == "minute") { $out .= "selected"; } $out .= '> ' . t('Minutes') . '</option> <option value="hour" '; if ($notification_type == "hour") { $out .= "selected"; } $out .= '> ' . t('Hours') . '</option> <option value="day" '; if ($notification_type == "day") { echo "selected"; } $out .= '> ' . t('Days') . '</option> </select> ' . t('before') . ' </span><br><br>'; $out .= "<script>\$(function() {\n\t\twdcal_edit_init('" . $localization->dateformat_datepicker_js() . "');\n\t});</script>"; $out .= "<input type='submit' name='save' value='Save'></form>"; return $out; }
/** * @param array $row * @param array $calendar * @param string $base_path * @return array */ private function jqcal2wdcal($row, $calendar, $base_path) { if ($row["adjust"]) { $start = datetime_convert('UTC', date_default_timezone_get(), $row["start"]); $finish = datetime_convert('UTC', date_default_timezone_get(), $row["finish"]); } else { $start = $row["start"]; $finish = $row["finish"]; } $allday = strpos($start, "00:00:00") !== false && strpos($finish, "00:00:00") !== false; $summary = $row["summary"] ? $row["summary"] : substr(preg_replace("/\\[[^\\]]*\\]/", "", $row["desc"]), 0, 100); return array("jq_id" => $row["id"], "ev_id" => $row["id"], "summary" => escape_tags($summary), "start" => wdcal_mySql2PhpTime($start), "end" => wdcal_mySql2PhpTime($finish), "is_allday" => $allday ? 1 : 0, "is_moredays" => substr($start, 0, 10) != substr($finish, 0, 10), "is_recurring" => $row["type"] == "birthday", "color" => "7878ff", "is_editable" => 0, "is_editable_quick" => 0, "location" => $row["location"], "attendees" => '', "has_notification" => 0, "url_detail" => $base_path . "/events/event/" . $row["id"], "url_edit" => "", "special_type" => $row["type"] == "birthday" ? "birthday" : ""); }