X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FSearchSub%2FSearchSub.php;h=7e9a94caa9ef8ad79979918183f4dd9e61b3d8ea;hb=59043dca7fb6f974b11797c4d0f20e5b78b0611d;hp=cbf64d39cc31ed52bedc096506176e4d48e25cc2;hpb=31c1177970124cee31823cab3a11542c23b4126d;p=quix0rs-gnu-social.git diff --git a/plugins/SearchSub/SearchSub.php b/plugins/SearchSub/SearchSub.php index cbf64d39cc..7e9a94caa9 100644 --- a/plugins/SearchSub/SearchSub.php +++ b/plugins/SearchSub/SearchSub.php @@ -120,6 +120,7 @@ class SearchSub extends Managed_DataObject $ts->profile_id = $profile->id; $ts->created = common_sql_now(); $ts->insert(); + self::blow('searchsub:by_profile:%d', $profile->id); return $ts; } @@ -135,6 +136,34 @@ class SearchSub extends Managed_DataObject 'profile_id' => $profile->id)); if ($ts) { $ts->delete(); + self::blow('searchsub:by_profile:%d', $profile->id); } } + + static function forProfile(Profile $profile) + { + $searches = array(); + + $keypart = sprintf('searchsub:by_profile:%d', $profile->id); + $searchstring = self::cacheGet($keypart); + + if ($searchstring !== false) { + if (!empty($searchstring)) { + $searches = explode(',', $searchstring); + } + } else { + $searchsub = new SearchSub(); + $searchsub->profile_id = $profile->id; + $searchsub->selectAdd(); + $searchsub->selectAdd('search'); + + if ($searchsub->find()) { + $searches = $searchsub->fetchAll('search'); + } + + self::cacheSet($keypart, implode(',', $searches)); + } + + return $searches; + } }