/**
  * Checks if wiki is restricted for all users (*)
  *
  * @param $value string wgGroupPermissionsLocalId content
  * @return bool True if wiki is restricted
  */
 private static function isRestrictedWiki($value)
 {
     $permissions = WikiFactoryLoader::parsePermissionsSettings($value);
     if (isset($permissions['*']) && is_array($permissions['*']) && isset($permissions['*']['read']) && $permissions['*']['read'] === false) {
         return true;
     }
     return false;
 }
 /**
  * @brief Hook on WikiFactory change and update wikis's visibility if the wgGroupPermissionsLocal is changed
  *
  * @param String $cv_name
  * @param Integer $city_id
  * @param String $value
  *
  * @return Boolean
  *
  * @author Evgeniy (aquilax)
  */
 public static function onWikiFactoryChanged($cv_name, $city_id, $value)
 {
     global $wgExternalDatawareDB;
     if (empty($wgExternalDatawareDB)) {
         // Exit if there is no Dataware DB
         return true;
     }
     if ($cv_name === 'wgGroupPermissionsLocal') {
         $is_restricted = false;
         $permissions = WikiFactory::getVarValueByName('wgGroupPermissionsLocal', $city_id);
         if (!empty($value)) {
             $permissions = WikiFactoryLoader::parsePermissionsSettings($value);
         }
         if (isset($permissions['*']) && is_array($permissions['*']) && isset($permissions['*']['read']) && $permissions['*']['read'] === false) {
             $is_restricted = true;
         }
         UserProfilePageHelper::updateRestrictedWikis((int) $city_id, $is_restricted);
     }
     return true;
 }
Beispiel #3
0
 /**
  * Checks if a wiki is "restricted", or "private" (i.e. users need to log in to read,
  * e.g. communitycouncil.wikia.com)
  *
  * @param integer $wikiId The ID of the wiki to check
  *
  * @return boolean true if it's restricted, false otherwise
  */
 public static function isWikiPrivate($wikiId)
 {
     wfProfileIn(__METHOD__);
     //restricting a wiki is done by setting the "read" permission
     //to 0 (false) for the "*" group via a WF variable (source: Tor),
     //if the above will change in the future then this will stop working (duh),
     //we should probably introduce a WF flag to handle this case in a much more
     //clean and portable way
     $permissions = self::getVarValueByName('wgGroupPermissionsLocal', $wikiId);
     $ret = false;
     if (!empty($permissions)) {
         $permissions = WikiFactoryLoader::parsePermissionsSettings($permissions);
     }
     if (isset($permissions['*']) && is_array($permissions['*']) && isset($permissions['*']['read']) && $permissions['*']['read'] === false) {
         $ret = true;
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }