]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Event.php
Rewrite Term class
[friendica.git] / src / Model / Event.php
index e7509c48e122c663293afb4620e3288546335aa1..d8657c1e9a61a2c706fde9c89131150ba8f0fa58 100644 (file)
@@ -48,8 +48,10 @@ class Event extends BaseObject
                }
 
                if ($simple) {
+                       $o = '';
+
                        if (!empty($event['summary'])) {
-                               $o = "<h3>" . BBCode::convert(Strings::escapeHtml($event['summary']), false, $simple) . "</h3>";
+                               $o .= "<h3>" . BBCode::convert(Strings::escapeHtml($event['summary']), false, $simple) . "</h3>";
                        }
 
                        if (!empty($event['desc'])) {
@@ -239,13 +241,12 @@ class Event extends BaseObject
         */
        public static function store($arr)
        {
-               $a = self::getApp();
-
                $event = [];
                $event['id']        = intval(defaults($arr, 'id'       , 0));
                $event['uid']       = intval(defaults($arr, 'uid'      , 0));
                $event['cid']       = intval(defaults($arr, 'cid'      , 0));
-               $event['uri']       =        defaults($arr, 'uri'      , Item::newURI($event['uid']));
+               $event['guid']      =        defaults($arr, 'guid'     , System::createUUID());
+               $event['uri']       =        defaults($arr, 'uri'      , Item::newURI($event['uid'], $event['guid']));
                $event['type']      =        defaults($arr, 'type'     , 'event');
                $event['summary']   =        defaults($arr, 'summary'  , '');
                $event['desc']      =        defaults($arr, 'desc'     , '');
@@ -316,8 +317,6 @@ class Event extends BaseObject
 
                        Hook::callAll('event_updated', $event['id']);
                } else {
-                       $event['guid']  = defaults($arr, 'guid', System::createUUID());
-
                        // New event. Store it.
                        DBA::insert('event', $event);
 
@@ -418,7 +417,6 @@ class Event extends BaseObject
                        "February"  => L10n::t("February"),
                        "March"     => L10n::t("March"),
                        "April"     => L10n::t("April"),
-                       "May"       => L10n::t("May"),
                        "June"      => L10n::t("June"),
                        "July"      => L10n::t("July"),
                        "August"    => L10n::t("August"),
@@ -471,6 +469,7 @@ class Event extends BaseObject
         * @param int    $event_id  The ID of the event in the event table
         * @param string $sql_extra
         * @return array Query result
+        * @throws \Exception
         */
        public static function getListById($owner_uid, $event_id, $sql_extra = '')
        {
@@ -499,17 +498,18 @@ class Event extends BaseObject
        /**
         * @brief Get all events in a specific time frame.
         *
-        * @param int $owner_uid The User ID of the owner of the events.
-        * @param array $event_params An associative array with
-        *      int 'ignore' =>
-        *      string 'start' => Start time of the timeframe.
-        *      string 'finish' => Finish time of the timeframe.
-        *      string 'adjust_start' =>
-        *      string 'adjust_finish' =>
+        * @param int    $owner_uid    The User ID of the owner of the events.
+        * @param array  $event_params An associative array with
+        *                             int 'ignore' =>
+        *                             string 'start' => Start time of the timeframe.
+        *                             string 'finish' => Finish time of the timeframe.
+        *                             string 'adjust_start' =>
+        *                             string 'adjust_finish' =>
         *
-        * @param string $sql_extra Additional sql conditions (e.g. permission request).
+        * @param string $sql_extra    Additional sql conditions (e.g. permission request).
         *
         * @return array Query results.
+        * @throws \Exception
         */
        public static function getListByDate($owner_uid, $event_params, $sql_extra = '')
        {
@@ -633,24 +633,27 @@ class Event extends BaseObject
        /**
         * @brief Format event to export format (ical/csv).
         *
-        * @param array  $events   Query result for events.
-        * @param string $format   The output format (ical/csv).
+        * @param array  $events Query result for events.
+        * @param string $format The output format (ical/csv).
         *
+        * @param        $timezone
         * @return string Content according to selected export format.
         *
-        * @todo Implement timezone support
+        * @todo  Implement timezone support
         */
-       private static function formatListForExport(array $events, $format, $timezone)
+       private static function formatListForExport(array $events, $format)
        {
+               $o = '';
+
                if (!count($events)) {
-                       return '';
+                       return $o;
                }
 
                switch ($format) {
                        // Format the exported data as a CSV file.
                        case "csv":
                                header("Content-type: text/csv");
-                               $o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
+                               $o .= '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
 
                                foreach ($events as $event) {
                                        /// @todo The time / date entries don't include any information about the
@@ -792,19 +795,14 @@ class Event extends BaseObject
        {
                $process = false;
 
-               $user = DBA::selectFirst('user', ['timezone'], ['uid' => $uid]);
-               if (DBA::isResult($user)) {
-                       $timezone = $user['timezone'];
-               }
-
                // Get all events which are owned by a uid (respects permissions).
                $events = self::getListByUserId($uid);
 
                // We have the events that are available for the requestor.
                // Now format the output according to the requested format.
-               $res = self::formatListForExport($events, $format, $timezone);
+               $res = self::formatListForExport($events, $format);
 
-               // If there are results the precess was successfull.
+               // If there are results the precess was successful.
                if (!empty($res)) {
                        $process = true;
                }
@@ -954,6 +952,7 @@ class Event extends BaseObject
         *  'name' => The name of the location,<br>
         * 'address' => The address of the location,<br>
         * 'coordinates' => Latitude‎ and longitude‎ (e.g. '48.864716,2.349014').<br>
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function locationToArray($s = '') {
                if ($s == '') {