]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User_group.php
Added type-hint for adaptNoticeListItem() method
[quix0rs-gnu-social.git] / classes / User_group.php
index b95ab228f6f5ecc00f51ffc21933aefa3a216f46..d89f3376f8028adc9a1b020da23eb0eaa027d88b 100644 (file)
@@ -92,9 +92,22 @@ class User_group extends Managed_DataObject
     {
         if (!isset($this->_profile[$this->profile_id])) {
             $profile = Profile::getKV('id', $this->profile_id);
+
             if (!$profile instanceof Profile) {
-                throw new GroupNoProfileException($this);
+
+                $profile = new Profile();
+                $profile->nickname   = $this->nickname;
+                $profile->fullname   = $this->fullname;
+                $profile->profileurl = $this->mainpage;
+                $profile->homepage   = $this->homepage;
+                $profile->bio        = $this->description;
+                $profile->location   = $this->location;
+                $profile->created    = common_sql_now();
+                $this->profile_id = $profile->insert();
+
+                //throw new GroupNoProfileException($this);
             }
+
             $this->_profile[$this->profile_id] = $profile;
         }
         return $this->_profile[$this->profile_id];
@@ -115,18 +128,7 @@ class User_group extends Managed_DataObject
 
     function homeUrl()
     {
-        $url = null;
-        if (Event::handle('StartUserGroupHomeUrl', array($this, &$url))) {
-            // normally stored in mainpage, but older ones may be null
-            if (!empty($this->mainpage)) {
-                $url = $this->mainpage;
-            } elseif ($this->isLocal()) {
-                $url = common_local_url('showgroup',
-                                        array('nickname' => $this->nickname));
-            }
-        }
-        Event::handle('EndUserGroupHomeUrl', array($this, &$url));
-        return $url;
+        return $this->getProfile()->getUrl();
     }
 
     function getUri()