]> git.mxchange.org Git - friendica.git/blobdiff - include/event.php
Code standards in api_get_user
[friendica.git] / include / event.php
index b9988badfa1aaddbc110b03bfc8c43770ad5c9b8..bc9467dc80217a1c352277ebaf94ef91c4fe6c3d 100644 (file)
@@ -5,11 +5,15 @@
  */
 
 use Friendica\App;
+use Friendica\Content\Feature;
+use Friendica\Core\PConfig;
 use Friendica\Core\System;
+use Friendica\Database\DBM;
+use Friendica\Util\Map;
 
 require_once 'include/bbcode.php';
-require_once 'include/map.php';
 require_once 'include/datetime.php';
+require_once "include/conversation.php";
 
 function format_event_html($ev, $simple = false) {
        if (! ((is_array($ev)) && count($ev))) {
@@ -71,7 +75,7 @@ function format_event_html($ev, $simple = false) {
 
                // Include a map of the location if the [map] BBCode is used.
                if (strpos($ev['location'], "[map") !== false) {
-                       $map = generate_named_map($ev['location']);
+                       $map = Map::byLocation($ev['location']);
                        if ($map !== $ev['location']) {
                                $o.= $map;
                        }
@@ -214,7 +218,7 @@ function event_delete($event_id) {
                return;
        }
 
-       q("DELETE FROM `event` WHERE `id` = %d", intval($event_id));
+       dba::delete('event', array('id' => $event_id));
        logger("Deleted event ".$event_id, LOGGER_DEBUG);
 }
 
@@ -253,7 +257,7 @@ function event_store($arr) {
                );
        }
 
-       if (dbm::is_result($c)) {
+       if (DBM::is_result($c)) {
                $contact = $c[0];
        }
 
@@ -268,7 +272,7 @@ function event_store($arr) {
                        intval($arr['id']),
                        intval($arr['uid'])
                );
-               if ((! dbm::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
+               if ((! DBM::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
 
                        // Nothing has changed. Grab the item id to return.
 
@@ -276,7 +280,7 @@ function event_store($arr) {
                                intval($arr['id']),
                                intval($arr['uid'])
                        );
-                       return ((dbm::is_result($r)) ? $r[0]['id'] : 0);
+                       return ((DBM::is_result($r)) ? $r[0]['id'] : 0);
                }
 
                // The event changed. Update it.
@@ -309,7 +313,7 @@ function event_store($arr) {
                        intval($arr['id']),
                        intval($arr['uid'])
                );
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
                        $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
                        $object .= '</object>' . "\n";
@@ -360,7 +364,7 @@ function event_store($arr) {
                        dbesc($arr['uri']),
                        intval($arr['uid'])
                );
-               if (dbm::is_result($r)) {
+               if (DBM::is_result($r)) {
                        $event = $r[0];
                }
 
@@ -403,7 +407,7 @@ function event_store($arr) {
                $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                        intval($arr['uid'])
                );
-               //if (dbm::is_result($r))
+               //if (DBM::is_result($r))
                //      $plink = System::baseUrl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
 
 
@@ -435,10 +439,7 @@ function event_store($arr) {
 function get_event_strings() {
 
        // First day of the week (0 = Sunday).
-       $firstDay = get_pconfig(local_user(), 'system', 'first_day_of_week');
-       if ($firstDay === false) {
-               $firstDay = 0;
-       }
+       $firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0);
 
        $i18n = array(
                        "firstDay" => $firstDay,
@@ -546,7 +547,7 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
                intval($event_params["event_id"])
        );
 
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                return event_remove_duplicates($r);
        }
 }
@@ -590,7 +591,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
                        dbesc($event_params["adjust_finish"])
        );
 
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                return event_remove_duplicates($r);
        }
 }
@@ -804,7 +805,7 @@ function events_by_uid($uid = 0, $sql_extra = '') {
                );
        }
 
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                return $r;
        }
 }
@@ -828,7 +829,7 @@ function event_export($uid, $format = 'ical') {
        // We are allowed to show events.
        // Get the timezone the user is in.
        $r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
-       if (dbm::is_result($r)) {
+       if (DBM::is_result($r)) {
                $timezone = $r[0]['timezone'];
        }
 
@@ -899,7 +900,7 @@ function widget_events() {
         * for exporting the cal is enabled (otherwise the widget would appear for logged in users
         * on foreigen profile pages even if the widget is disabled).
         */
-       if (intval($owner_uid) && local_user() !== $owner_uid && ! feature_enabled($owner_uid, "export_calendar")) {
+       if (intval($owner_uid) && local_user() !== $owner_uid && ! Feature::isEnabled($owner_uid, "export_calendar")) {
                return;
        }
 
@@ -907,7 +908,7 @@ function widget_events() {
         * If it's a kind of profile page (intval($owner_uid)) return if the user not logged in and
         * export feature isn't enabled.
         */
-       if (intval($owner_uid) && ! local_user() && ! feature_enabled($owner_uid, "export_calendar")) {
+       if (intval($owner_uid) && ! local_user() && ! Feature::isEnabled($owner_uid, "export_calendar")) {
                return;
        }
 
@@ -966,9 +967,9 @@ function format_event_item($item) {
        }
        // Construct the map HTML.
        if (isset($evloc['address'])) {
-               $location['map'] = '<div class="map">' . generate_named_map($evloc['address']) . '</div>';
+               $location['map'] = '<div class="map">' . Map::byLocation($evloc['address']) . '</div>';
        } elseif (isset($evloc['coordinates'])) {
-               $location['map'] = '<div class="map">' . generate_map(str_replace('/', ' ', $evloc['coordinates'])) . '</div>';
+               $location['map'] = '<div class="map">' . Map::byCoordinates(str_replace('/', ' ', $evloc['coordinates'])) . '</div>';
        }
 
        // Construct the profile link (magic-auth).