protected function _deleteWikiGroups()
 {
     if (MediaWikiFarmer::getInstance()->sharingGroups()) {
         $db = $this->getDatabase();
         $query = 'DELETE FROM ' . $db->tableName('user_groups') . ' WHERE ug_group LIKE ';
         $query .= '\'[farmer][' . $this->_name . ']%\'';
         $db->query($query, __METHOD__);
     }
 }
Ejemplo n.º 2
0
 /**
  * Handles page to manage extensions
  */
 protected function _executeManageExtensions($wgFarmer)
 {
     global $wgOut, $wgUser, $wgRequest;
     if (!wfRunHooks('FarmerManageExtensions', array($wgFarmer))) {
         return;
     }
     // quick security check
     if (!MediaWikiFarmer::userIsFarmerAdmin($wgUser)) {
         $wgOut->wrapWikiMsg('== $1 ==', 'farmer-permissiondenied');
         $wgOut->addWikiMsg('farmer-extensions-extension-denied');
         return;
     }
     // look and see if a new extension was registered
     if ($wgRequest->wasPosted()) {
         $name = $wgRequest->getVal('name');
         $description = $wgRequest->getVal('description');
         $include = $wgRequest->getVal('include');
         $extension = new MediaWikiFarmer_Extension($name, $description, $include);
         if (!$extension->isValid()) {
             $wgOut->wrapWikiMsg('== $1 ==', 'farmer-extensions-invalid');
             $wgOut->addWikiMsg('farmer-extensions-invalid-text');
         } else {
             $wgFarmer->registerExtension($extension);
         }
     }
     $wgOut->wrapWikiMsg('== $1 ==', 'farmer-extensions-available');
     $extensions = $wgFarmer->getExtensions();
     if (count($extensions) === 0) {
         $wgOut->addWikiMsg('farmer-extensions-noavailable');
     } else {
         foreach ($wgFarmer->getExtensions() as $extension) {
             $wgOut->addWikiText('; ' . htmlspecialchars($extension->name) . ' : ' . htmlspecialchars($extension->description));
         }
     }
     $wgOut->wrapWikiMsg('== $1 ==', 'farmer-extensions-register');
     $wgOut->addWikiMsg('farmer-extensions-register-text1');
     $wgOut->addWikiMsg('farmer-extensions-register-text2');
     $wgOut->addWikiMsg('farmer-extensions-register-text3');
     $wgOut->addWikiMsg('farmer-extensions-register-text4');
     foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
         $wgOut->addWikiText('*' . $path);
     }
     $wgOut->addHTML("\n<form id=\"registerExtension\" method=\"post\">\n\t<table>\n\t\t<tr>\n\t\t\t<td align=\"right\">" . wfMsgHtml('farmer-extensions-register-name') . "</td>\n\t\t\t<td align=\"left\"><input type=\"text\" size=\"20\" name=\"name\" value=\"\" /></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align=\"right\">" . wfMsgHtml('farmer-description') . "</td>\n\t\t\t<td align=\"left\"><input type=\"text\" size=\"50\" name=\"description\" value=\"\" /></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align=\"right\">" . wfMsgHtml('farmer-extensions-register-includefile') . "</td>\n\t\t\t<td align=\"left\"><input type=\"text\" size=\"50\" name=\"include\" value=\"\" /></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>&#160;</td>\n\t\t\t<td align=\"right\"><input type=\"submit\" name=\"submit\" value=\"" . wfMsgHtml('farmer-button-submit') . "\" /></td>\n\t\t</tr>\n\t</table>\n</form>");
 }
 /**
  * Default callback function to get an database name and prefix for a wiki
  * in the farm
  *
  * @param $farmer MediaWikiFarmer
  * @param $wiki String
  * @return Array
  */
 protected static function _prefixTable(MediaWikiFarmer $farmer, $wiki)
 {
     if ($farmer->useWgConf()) {
         global $wgConf;
         return array($wgConf->get('wgDBname', $wiki), $wgConf->get('wgDBprefix', $wiki));
     } else {
         global $wgDBname;
         $prefix = $farmer->_dbTablePrefix . $wiki . $farmer->_dbTablePrefixSeparator;
         return array($wgDBname, $prefix);
     }
 }