本文整理汇总了PHP中HtmlForm::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlForm::getUser方法的具体用法?PHP HtmlForm::getUser怎么用?PHP HtmlForm::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlForm
的用法示例。
在下文中一共展示了HtmlForm::getUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processInput
/**
* @param array $formData
* @param HtmlForm $form
*
* @return bool|string
* @throws DBUnexpectedError
* @throws Exception
* @throws MWException
*/
public static function processInput(array $formData, HtmlForm $form)
{
error_reporting(0);
global $wgCreateWikiSQLfiles, $IP;
$DBname = $formData['dbname'];
$founderName = $formData['founder'];
$dbw = wfGetDB(DB_MASTER);
$dbTest = $dbw->query('SHOW DATABASES LIKE ' . $dbw->addQuotes($DBname) . ';');
$rows = $dbTest->numRows();
$dbTest->free();
if ($rows !== 0) {
return wfMessage('createwiki-error-dbexists')->plain();
}
$farmerLogEntry = new ManualLogEntry('farmer', 'createandpromote');
$farmerLogEntry->setPerformer($form->getUser());
$farmerLogEntry->setTarget($form->getTitle());
$farmerLogEntry->setComment($formData['comment']);
$farmerLogEntry->setParameters(array('4::wiki' => $DBname, '5::founder' => $founderName));
$farmerLogID = $farmerLogEntry->insert();
$farmerLogEntry->publish($farmerLogID);
$dbw->query('SET storage_engine=InnoDB;');
$dbw->query('CREATE DATABASE ' . $dbw->addIdentifierQuotes($DBname) . ';');
$dbw->selectDB($DBname);
foreach ($wgCreateWikiSQLfiles as $file) {
$dbw->sourceFile($file);
}
$dbw->insert('site_stats', array('ss_row_id' => 1));
$dbw->close();
// Add DNS record to cloudflare
global $wgCreateWikiUseCloudFlare, $wgCloudFlareUser, $wgCloudFlareKey;
if ($wgCreateWikiUseCloudFlare) {
$domainPrefix = substr($DBname, 0, -4);
$cloudFlare = new cloudflare_api($wgCloudFlareUser, $wgCloudFlareKey);
$cloudFlareResult = $cloudFlare->rec_new('orain.org', 'CNAME', $domainPrefix, 'lb.orain.org');
if (!is_object($cloudFlareResult) || $cloudFlareResult->result !== 'success') {
wfDebugLog('CreateWiki', 'CloudFlare FAILED to add CNAME for ' . $domainPrefix . '.orain.org');
} else {
wfDebugLog('CreateWiki', 'CloudFlare CNAME added for ' . $domainPrefix . '.orain.org');
}
}
// Create local account for founder (hack)
$out = exec("php5 {$IP}/extensions/CentralAuth/maintenance/createLocalAccount.php " . escapeshellarg($founderName) . ' --wiki ' . escapeshellarg($DBname));
if (!strpos($out, 'created')) {
return wfMessage('createwiki-error-usernotcreated')->plain();
}
require_once "{$IP}/includes/UserRightsProxy.php";
// Grant founder sysop and bureaucrat rights
$founderUser = UserRightsProxy::newFromName($DBname, $founderName);
$newGroups = array('sysop', 'bureaucrat');
array_map(array($founderUser, 'addGroup'), $newGroups);
$founderUser->invalidateCache();
$form->getOutput()->addWikiMsg('createwiki-success', $DBname);
return true;
}
示例2: getUser
/**
* @return User
*/
function getUser()
{
static $user = null;
if ($user === null) {
$user = $this->mForm->getUser();
}
return $user;
}