/** * If the page is in a Wikiplace namespace, search the owner and answer. * If the page is in a Wikiplace namespace but cannot be found, state only * * admins users are owner * @todo should not be a hook. Should be... * WpWikiPlaces->hasOwner($user) * and called by getUserPermissionError() * * @param Title $title * @param User $user * @param boolean */ public static function isOwner($title, $user, &$result) { $namespace = $title->getNamespace(); $db_key = $title->getDBkey(); if (WpPage::isPublic($namespace, $db_key) || !WpPage::isInWikiplaceNamespaces($namespace) || !$title->isKnown() || WpPage::isAdmin($namespace, $db_key)) { return true; // skip } $article_id = $title->getArticleID(); $user_id = $user->getId(); $result = WpPage::isOwner($article_id, $user); wfDebugLog('wikiplaces-debug', "{$user->getName()}({$user_id}) is" . ($result ? '' : ' not') . " owner of {$title->getPrefixedDBkey()}({$article_id})"); return false; // stop hook processing, because we have the answer }
/** * * @param int $namespace * @param string $db_key * @return boolean */ public static function isInWikiplace($namespace, $db_key) { if (!is_int($namespace)) { throw new MWException('Invalid namespace argument.'); } global $wgWikiplaceNamespaces; if (!in_array($namespace, $wgWikiplaceNamespaces)) { return false; } return !WpPage::isPublic($namespace, $db_key) && !WpPage::isAdmin($namespace, $db_key); }