/** * Returns true if the specified Facebook user (default to current one) can * edit properties for the application. The user must be an administrator * or developer of the app and must also be an administrator of the wiki. */ function canEdit($fbUser = NULL) { global $facebook, $wgUser; if (!$fbUser instanceof FacebookUser) { $fbUser = new FacebookUser(); } // First, check MediaWiki permissions. Then check with Facebook if ($fbUser->getMWUser()->getId() == 0 || $fbUser->getMWUser()->getId() != $wgUser->getId()) { return false; } // If $wgFbUserRightsFromGroups is set, this should trigger a group check $groups = $fbUser->getMWUser()->getEffectiveGroups(); if (!in_array('sysop', $groups) && !in_array('fb-admin', $groups)) { return false; } // Check that the Facebook user has a development role with the application $roles = $this->getRoles(); if (!in_array($fbUser->getId(), $roles['administrators']) && !in_array($fbUser->getId(), $roles['developers'])) { return false; } return true; }
/** * Pushes an item to the Facebook user's Timeline when they add an article * to their watchlist. */ public static function WatchArticleComplete(&$user, &$article) { global $facebook; if (self::getAction('watch')) { $fbUser = new FacebookUser(); if ($fbUser->getMWUser()->getId() == $user->getId()) { $object = FacebookOpenGraph::newObjectFromTitle($article->getTitle()); if ($object) { try { // Publish the action $facebook->api('/' . $fbUser->getId() . '/' . self::getAction('watch'), 'POST', array($object->getType() => $object->getUrl())); } catch (FacebookApiException $e) { // echo $e->getType() . ": " . $e->getMessage() . "<br/>\n"; } } } } return true; }