add search submenu to default local nav

This commit is contained in:
Evan Prodromou
2011-04-05 18:45:37 -04:00
parent 11bbc5adcd
commit cffbda8183
3 changed files with 123 additions and 0 deletions

View File

@@ -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 && !empty($searchstring)) {
$searches = explode(',', $searchstring);
} else {
$searchsub = new SearchSub();
$searchsub->profile_id = $profile->id;
if ($searchsub->find()) {
while ($searchsub->fetch()) {
if (!empty($searchsub->search)) {
$searches[] = $searchsub->search;
}
}
}
self::cacheSet($keypart, implode(',', $searches));
}
return $searches;
}
}