/** * Grab information about new messages and if they exist - add notification for specified wikis * * @param $user User */ function SiteWideMessagesUserNewTalks(&$user, &$talks) { global $wgExternalSharedDB, $wgMemc, $wgUser; if (F::app()->checkSkin('oasis') || $user->isAnon() || $wgUser->isAllowed('bot')) { //don't show information for anons and bots return true; } wfProfileIn(__METHOD__); $key = 'wikia:talk_messages:' . $user->getID() . ':' . str_replace(' ', '_', $user->getName()); $messages = $wgMemc->get($key); if (!is_array($messages) && $messages != 'deleted') { $messages = array(); // For Oasis we want to set the filter_seen argument to false since we want the messages // to stay visible until they actually dismiss them $messagesID = SiteWideMessages::getAllUserMessagesId($user); if (!empty($messagesID)) { //selected wikis $wikis = array_filter($messagesID['wiki']); if (count($wikis)) { $wikis = implode(',', $wikis); $DB = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB); $res = $DB->query("SELECT city_id, city_title, city_url FROM city_list WHERE city_id IN ({$wikis})", __METHOD__); while ($row = $DB->fetchObject($res)) { $link = $row->city_url . 'index.php?title=User_talk:' . urlencode($user->getTitleKey()); $wiki = $row->city_title; $messages[$row->city_id] = array('wiki' => $wiki, 'link' => $link); } } //all wikis $wikis = array_filter($messagesID['wiki'], create_function('$v', 'return empty($v);')); if (count($wikis)) { global $wgCityId, $wgUser, $wgSitename; $utp = $wgUser->getTalkPage(); $messages[$wgCityId] = array('wiki' => $wgSitename, 'link' => $utp->getFullURL()); } $wgMemc->set($key, $messages, 300); } } if (is_array($messages) && count($messages) > 0) { $talks += $messages; } wfProfileOut(__METHOD__); return true; }