]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Event/classes/Happening.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Event / classes / Happening.php
index 3d2a1738b5e21e8427d8d0f7f848f6e74faf2ff9..fd8c3c8a2aaf6ff841b6461ce48b4295bd30d924 100644 (file)
@@ -27,9 +27,7 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Data class for happenings
@@ -53,13 +51,13 @@ class Happening extends Managed_DataObject
 
     public $__table = 'happening'; // table name
     public $id;                    // varchar(36) UUID
-    public $uri;                   // varchar(255)
+    public $uri;                   // varchar(191)   not 255 because utf8mb4 takes more space
     public $profile_id;            // int
     public $start_time;            // datetime
     public $end_time;              // datetime
-    public $title;                 // varchar(255)
-    public $location;              // varchar(255)
-    public $url;                   // varchar(255)
+    public $title;                 // varchar(191)   not 255 because utf8mb4 takes more space
+    public $location;              // varchar(191)   not 255 because utf8mb4 takes more space
+    public $url;                   // varchar(191)   not 255 because utf8mb4 takes more space
     public $description;           // text
     public $created;               // datetime
 
@@ -76,18 +74,18 @@ class Happening extends Managed_DataObject
                               'not null' => true,
                               'description' => 'UUID'),
                 'uri' => array('type' => 'varchar',
-                               'length' => 255,
+                               'length' => 191,
                                'not null' => true),
                 'profile_id' => array('type' => 'int', 'not null' => true),
                 'start_time' => array('type' => 'datetime', 'not null' => true),
                 'end_time' => array('type' => 'datetime', 'not null' => true),
                 'title' => array('type' => 'varchar',
-                                 'length' => 255,
+                                 'length' => 191,
                                  'not null' => true),
                 'location' => array('type' => 'varchar',
-                                    'length' => 255),
+                                    'length' => 191),
                 'url' => array('type' => 'varchar',
-                               'length' => 255),
+                               'length' => 191),
                 'description' => array('type' => 'text'),
                 'created' => array('type' => 'datetime',
                                    'not null' => true),
@@ -116,8 +114,8 @@ class Happening extends Managed_DataObject
 
         $ev->id          = UUID::gen();
         $ev->profile_id  = $profile->id;
-        $ev->start_time  = common_sql_date($start_time);
-        $ev->end_time    = common_sql_date($end_time);
+        $ev->start_time  = $start_time;
+        $ev->end_time    = $end_time;
         $ev->title       = $title;
         $ev->location    = $location;
         $ev->description = $description;
@@ -172,14 +170,14 @@ class Happening extends Managed_DataObject
                                $options);
 
         if (!array_key_exists('uri', $options)) {
-            $options['uri'] = $ev->uri;
+            $options['uri'] = $ev->getUri();
         }
 
         if (!empty($url)) {
             $options['urls'] = array($url);
         }
 
-        $saved = Notice::saveNew($profile->id,
+        $saved = Notice::saveNew($profile->getID(),
                                  $content,
                                  array_key_exists('source', $options) ?
                                  $options['source'] : 'web',
@@ -202,14 +200,19 @@ class Happening extends Managed_DataObject
         return $this->url;
     }
 
+    public function getUri()
+    {
+        return $this->uri;
+    }
+
     function getNotice()
     {
-        return Notice::getKV('uri', $this->uri);
+        return Notice::getKV('uri', $this->getUri());
     }
 
     static function fromNotice(Notice $notice)
     {
-        return Happening::getKV('uri', $notice->uri);
+        return Happening::getKV('uri', $notice->getUri());
     }
 
     function getRSVPs()
@@ -219,7 +222,7 @@ class Happening extends Managed_DataObject
 
     function getRSVP($profile)
     {
-        return RSVP::pkeyGet(array('profile_id' => $profile->id,
-                                   'event_id' => $this->id));
+        return RSVP::pkeyGet(array('profile_id' => $profile->getID(),
+                                   'event_uri' => $this->getUri()));
     }
 }