本文整理汇总了PHP中ManualLogEntry::publish方法的典型用法代码示例。如果您正苦于以下问题:PHP ManualLogEntry::publish方法的具体用法?PHP ManualLogEntry::publish怎么用?PHP ManualLogEntry::publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualLogEntry
的用法示例。
在下文中一共展示了ManualLogEntry::publish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeRejectAll
public function executeRejectAll()
{
$out = $this->mSpecial->getOutput();
$userpage = $this->mSpecial->getUserpageByModId($this->id);
if (!$userpage) {
throw new ModerationError('moderation-edit-not-found');
}
$dbw = wfGetDB(DB_MASTER);
# Need latest data without lag
$res = $dbw->select('moderation', array('mod_id AS id'), array('mod_user_text' => $userpage->getText(), 'mod_rejected' => 0, 'mod_merged_revid' => 0), __METHOD__, array('USE INDEX' => 'moderation_rejectall'));
if (!$res || $res->numRows() == 0) {
throw new ModerationError('moderation-nothing-to-rejectall');
}
$ids = array();
foreach ($res as $row) {
$ids[] = $row->id;
}
$dbw->update('moderation', array('mod_rejected' => 1, 'mod_rejected_by_user' => $this->moderator->getId(), 'mod_rejected_by_user_text' => $this->moderator->getName(), 'mod_rejected_batch' => 1, 'mod_preloadable' => 0), array('mod_id' => $ids), __METHOD__);
$nrows = $dbw->affectedRows();
if ($nrows) {
$logEntry = new ManualLogEntry('moderation', 'rejectall');
$logEntry->setPerformer($this->moderator);
$logEntry->setTarget($userpage);
$logEntry->setParameters(array('4::count' => $nrows));
$logid = $logEntry->insert();
$logEntry->publish($logid);
}
$out->addWikiMsg('moderation-rejected-ok', $nrows);
}
示例2: onSubmit
public function onSubmit(array $formData)
{
global $IP, $wgCreateWikiSQLfiles;
$DBname = $formData['dbname'];
$founderName = $formData['founder'];
$siteName = $formData['sitename'];
$language = $formData['language'];
$private = $formData['private'];
$reason = $formData['reason'];
$dbw = wfGetDB(DB_MASTER);
$farmerLogEntry = new ManualLogEntry('farmer', 'createwiki');
$farmerLogEntry->setPerformer($this->getUser());
$farmerLogEntry->setTarget($this->getTitle());
$farmerLogEntry->setComment($reason);
$farmerLogEntry->setParameters(array('4::wiki' => $DBname));
$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 $sqlfile) {
$dbw->sourceFile($sqlfile);
}
$this->writeToDBlist($DBname, $siteName, $language, $private);
$this->createMainPage($language);
$shcreateaccount = exec("/usr/bin/php " . "{$IP}/extensions/CentralAuth/maintenance/createLocalAccount.php " . wfEscapeShellArg($founderName) . " --wiki " . wfEscapeShellArg($DBname));
if (!strpos($shcreateaccount, 'created')) {
wfDebugLog('CreateWiki', 'Failed to create local account for founder. - error: ' . $shcreateaccount);
return wfMessage('createwiki-error-usernotcreated')->escaped();
}
$shpromoteaccount = exec("/usr/bin/php " . "{$IP}/maintenance/createAndPromote.php " . wfEscapeShellArg($founderName) . " --bureaucrat --sysop --force --wiki " . wfEscapeShellArg($DBname));
$this->getOutput()->addHTML('<div class="successbox">' . wfMessage('createwiki-success')->escaped() . '</div>');
return true;
}
示例3: execute
public function execute()
{
$out = $this->mSpecial->getOutput();
$dbw = wfGetDB(DB_MASTER);
$row = $dbw->selectRow('moderation', array('mod_user AS user', 'mod_user_text AS user_text'), array('mod_id' => $this->id), __METHOD__);
if (!$row) {
throw new ModerationError('moderation-edit-not-found');
}
$dbw = wfGetDB(DB_MASTER);
if ($this->actionName == 'block') {
$dbw->replace('moderation_block', array('mb_address'), array('mb_address' => $row->user_text, 'mb_user' => $row->user, 'mb_by' => $this->moderator->getId(), 'mb_by_text' => $this->moderator->getName(), 'mb_timestamp' => $dbw->timestamp(wfTimestampNow())), __METHOD__);
$logEntry = new ManualLogEntry('moderation', 'block');
} else {
$dbw->delete('moderation_block', array('mb_address' => $row->user_text), __METHOD__);
$logEntry = new ManualLogEntry('moderation', 'unblock');
}
$nrows = $dbw->affectedRows();
if ($nrows > 0) {
$logEntry->setPerformer($this->moderator);
$logEntry->setTarget(Title::makeTitle(NS_USER, $row->user_text));
$logid = $logEntry->insert();
$logEntry->publish($logid);
}
$out->addWikiMsg('moderation-' . ($this->actionName == 'unblock' ? 'un' : '') . 'block-' . ($nrows ? 'ok' : 'fail'), $row->user_text);
}
示例4: record
/**
* Record a log event for a change being patrolled
*
* @param mixed $rc Change identifier or RecentChange object
* @param bool $auto Was this patrol event automatic?
* @param User $user User performing the action or null to use $wgUser
*
* @return bool
*/
public static function record($rc, $auto = false, User $user = null)
{
global $wgLogAutopatrol;
// do not log autopatrolled edits if setting disables it
if ($auto && !$wgLogAutopatrol) {
return false;
}
if (!$rc instanceof RecentChange) {
$rc = RecentChange::newFromId($rc);
if (!is_object($rc)) {
return false;
}
}
if (!$user) {
global $wgUser;
$user = $wgUser;
}
$entry = new ManualLogEntry('patrol', 'patrol');
$entry->setTarget($rc->getTitle());
$entry->setParameters(self::buildParams($rc, $auto));
$entry->setPerformer($user);
$logid = $entry->insert();
if (!$auto) {
$entry->publish($logid, 'udp');
}
return true;
}
示例5: execute
public function execute($par)
{
// Shortcut by using $par
if ($par) {
$this->getOutput()->redirect($this->getTitle()->getLinkURL(array('user' => $par)));
return;
}
$this->setHeaders();
$this->outputHeader();
// Parse options
$opt = new \FormOptions();
$opt->add('user', '');
$opt->add('delete', '');
$opt->add('reason', '');
$opt->fetchValuesFromRequest($this->getRequest());
// Parse user
$user = $opt->getValue('user');
$userObj = \User::newFromName($user);
$userExists = $userObj && $userObj->getId() !== 0;
// If current task is delete and user is not allowed
$canDoAdmin = $this->getUser()->isAllowed('avataradmin');
if ($opt->getValue('delete')) {
if (!$canDoAdmin) {
throw new \PermissionsError('avataradmin');
}
// Delete avatar if the user exists
if ($userExists) {
if (Avatars::deleteAvatar($userObj)) {
global $wgAvatarLogInRC;
$logEntry = new \ManualLogEntry('avatar', 'delete');
$logEntry->setPerformer($this->getUser());
$logEntry->setTarget($userObj->getUserPage());
$logEntry->setComment($opt->getValue('reason'));
$logId = $logEntry->insert();
$logEntry->publish($logId, $wgAvatarLogInRC ? 'rcandudp' : 'udp');
}
}
}
$this->getOutput()->addModules(array('mediawiki.userSuggest'));
$this->showForm($user);
if ($userExists) {
$haveAvatar = Avatars::hasAvatar($userObj);
if ($haveAvatar) {
$html = \Xml::tags('img', array('src' => Avatars::getLinkFor($user, 'original') . '&nocache&ver=' . dechex(time()), 'height' => 400), '');
$html = \Xml::tags('p', array(), $html);
$this->getOutput()->addHTML($html);
// Add a delete button
if ($canDoAdmin) {
$this->showDeleteForm($user);
}
} else {
$this->getOutput()->addWikiMsg('viewavatar-noavatar');
}
} else {
if ($user) {
$this->getOutput()->addWikiMsg('viewavatar-nouser');
}
}
}
示例6: logPromotion
/**
* Log the promotion of a local unattached to a global
*
* @param string $oldName
* @param string $wiki
* @param string $newName
* @param string $reason
*/
public function logPromotion($oldName, $wiki, $newName, $reason)
{
$logEntry = new ManualLogEntry('gblrename', 'promote');
$logEntry->setPerformer($this->performingUser);
$logEntry->setTarget(Title::makeTitleSafe(NS_SPECIAL, 'CentralAuth/' . $newName));
$logEntry->setComment($reason);
$logEntry->setParameters(array('4::olduser' => $oldName, '5::newuser' => $newName, '6::oldwiki' => $wiki));
$logEntry->setRelations(array('oldname' => $oldName));
$logid = $logEntry->insert();
$logEntry->publish($logid);
}
示例7: log
/**
* @param CentralAuthUser[] $oldNames
* @param string $newName
* @param string $reason
*/
public function log(array $oldNames, $newName, $reason)
{
$logEntry = new ManualLogEntry('gblrename', 'merge');
$logEntry->setPerformer($this->performingUser);
$logEntry->setTarget(Title::makeTitleSafe(NS_SPECIAL, 'CentralAuth/' . $newName));
$imploded = implode('|', array_map(function (CentralAuthUser $user) {
return $user->getName();
}, $oldNames));
$logEntry->setComment($reason);
$logEntry->setParameters(array('4::olduser' => $imploded, '5::newuser' => $newName));
$logid = $logEntry->insert();
$logEntry->publish($logid);
}
示例8: log
/**
* Create a log entry using the provided info.
* Takes care about the logging interface changes in MediaWiki 1.19.
*
* @since 0.1
*
* @param array $info
*/
public static function log(array $info)
{
$user = array_key_exists('user', $info) ? $info['user'] : $GLOBALS['wgUser'];
$logEntry = new ManualLogEntry($info['type'], $info['subtype']);
$logEntry->setPerformer($user);
$logEntry->setTarget($info['title']);
if (array_key_exists('comment', $info)) {
$logEntry->setComment($info['comment']);
}
if (array_key_exists('parameters', $info)) {
$logEntry->setParameters($info['parameters']);
}
$logid = $logEntry->insert();
$logEntry->publish($logid);
}
示例9: run
function run()
{
// Initialization
$title = $this->title;
// Other stuff
$user = $this->getUser();
$summary = $this->getSummary();
$base = $this->getBase();
$doer = User::newFromName($this->getPerformer());
PageTranslationHooks::$allowTargetEdit = true;
$error = '';
$wikipage = new WikiPage($title);
$ok = $wikipage->doDeleteArticle($summary, false, 0, true, $error, $user);
if (!$ok) {
$params = array('target' => $base, 'error' => $ok);
$type = $this->getFull() ? 'deletefnok' : 'deletelnok';
$entry = new ManualLogEntry('pagetranslation', $type);
$entry->setPerformer($doer);
$entry->setTarget($title);
$entry->setParameters($params);
$logid = $entry->insert();
$entry->publish($logid);
}
PageTranslationHooks::$allowTargetEdit = false;
$cache = wfGetCache(CACHE_DB);
$pages = (array) $cache->get(wfMemcKey('pt-base', $base));
$lastitem = array_pop($pages);
if ($title->getPrefixedText() === $lastitem) {
$cache->delete(wfMemcKey('pt-base', $base));
$type = $this->getFull() ? 'deletefok' : 'deletelok';
$entry = new ManualLogEntry('pagetranslation', $type);
$entry->setPerformer($doer);
$entry->setTarget(Title::newFromText($base));
$logid = $entry->insert();
$entry->publish($logid);
$tpage = TranslatablePage::newFromTitle($title);
$tpage->getTranslationPercentages(true);
foreach ($tpage->getTranslationPages() as $page) {
$page->invalidateCache();
}
$title->invalidateCache();
}
return true;
}
示例10: onSubmitInput
function onSubmitInput(array $params)
{
if (!$this->getUser()->isAllowed('managewiki')) {
throw new MWException("User '{$this->getUser()->getName()}' without managewiki right tried to change wiki settings!");
}
$values = array('wiki_sitename' => $params['sitename'], 'wiki_language' => $params['language'], 'wiki_closed' => $params['closed'] == true ? 1 : 0);
if ($this->getUser()->isAllowed('managewiki-restricted')) {
$values['wiki_private'] = $params['private'] == true ? 1 : 0;
}
$dbw = wfGetDB(DB_MASTER);
$dbw->update('cw_wikis', $values, array('wiki_dbname' => $params['dbname']), __METHOD__);
$farmerLogEntry = new ManualLogEntry('farmer', 'managewiki');
$farmerLogEntry->setPerformer($this->getUser());
$farmerLogEntry->setTarget($this->getTitle());
$farmerLogEntry->setComment($params['reason']);
$farmerLogEntry->setParameters(array('4::wiki' => $params['dbname']));
$farmerLogID = $farmerLogEntry->insert();
$farmerLogEntry->publish($farmerLogID);
$this->getOutput()->addHTML('<div class="successbox">' . wfMessage('managewiki-success')->escaped() . '</div>');
return true;
}
示例11: doImport
private function doImport(array $json)
{
global $wgTriggerFlowThreadHooks;
$wgTriggerFlowThreadHooks = false;
$output = $this->getOutput();
foreach ($json as $articles) {
$title = \Title::newFromText($articles->title);
$count = count($articles->posts);
$skipped = 0;
// Skip non-existent title
if ($title === null || !$title->exists()) {
$output->addWikiMsg('flowthreadimport-failed', $articles->title, $count);
continue;
}
$titleId = $title->getArticleID();
foreach ($articles->posts as $postJson) {
$data = array('id' => UUID::fromHex($postJson->id), 'pageid' => $titleId, 'userid' => $postJson->userid, 'username' => $postJson->username, 'text' => $postJson->text, 'parentid' => $postJson->parentid ? UUID::fromHex($postJson->parentid) : null, 'status' => $postJson->status, 'like' => 0, 'report' => 0);
$postObject = new Post($data);
try {
$postObject->post();
} catch (\Exception $ex) {
$count--;
$skipped++;
}
}
if ($count) {
$logEntry = new \ManualLogEntry('comments', 'import');
$logEntry->setPerformer($this->getUser());
$logEntry->setTarget($title);
$logEntry->setParameters(array('4::count' => $count));
$logId = $logEntry->insert();
$logEntry->publish($logId, 'udp');
$output->addWikiMsg('flowthreadimport-success', $articles->title, $count);
}
if ($skipped) {
$output->addWikiMsg('flowthreadimport-skipped', $articles->title, $skipped);
}
}
}
示例12: changeState
public static function changeState(MessageGroup $group, $code, $newState, User $user)
{
$currentState = self::getState($group, $code);
if ($currentState === $newState) {
return false;
}
$table = 'translate_groupreviews';
$index = array('tgr_group', 'tgr_language');
$row = array('tgr_group' => $group->getId(), 'tgr_lang' => $code, 'tgr_state' => $newState);
$dbw = wfGetDB(DB_MASTER);
$dbw->replace($table, array($index), $row, __METHOD__);
$entry = new ManualLogEntry('translationreview', 'group');
$entry->setPerformer($user);
$entry->setTarget(SpecialPage::getTitleFor('Translate', $group->getId()));
// @todo
// $entry->setComment( $comment );
$entry->setParameters(array('4::language' => $code, '5::group-label' => $group->getLabel(), '6::old-state' => $currentState, '7::new-state' => $newState));
$logid = $entry->insert();
$entry->publish($logid);
Hooks::run('TranslateEventMessageGroupStateChange', array($group, $code, $currentState, $newState));
return true;
}
示例13: record
/**
* Record a log event for a change being patrolled
*
* @param $rc Mixed: change identifier or RecentChange object
* @param $auto Boolean: was this patrol event automatic?
*
* @return bool
*/
public static function record($rc, $auto = false)
{
if (!$rc instanceof RecentChange) {
$rc = RecentChange::newFromId($rc);
if (!is_object($rc)) {
return false;
}
}
$title = Title::makeTitleSafe($rc->getAttribute('rc_namespace'), $rc->getAttribute('rc_title'));
if ($title) {
$entry = new ManualLogEntry('patrol', 'patrol');
$entry->setTarget($title);
$entry->setParameters(self::buildParams($rc, $auto));
$entry->setPerformer(User::newFromName($rc->getAttribute('rc_user_text'), false));
$logid = $entry->insert();
if (!$auto) {
$entry->publish($logid, 'udp');
}
return true;
}
return false;
}
示例14: log
/**
* Create a log entry using the provided info.
* Takes care about the logging interface changes in MediaWiki 1.19.
*
* @since 0.1
*
* @param array $info
*/
public static function log(array $info)
{
$user = array_key_exists('user', $info) ? $info['user'] : $GLOBALS['wgUser'];
if ($info !== false) {
if (class_exists('ManualLogEntry')) {
$logEntry = new ManualLogEntry($info['type'], $info['subtype']);
$logEntry->setPerformer($user);
$logEntry->setTarget($info['title']);
if (array_key_exists('comment', $info)) {
$logEntry->setComment($info['comment']);
}
if (array_key_exists('parameters', $info)) {
$logEntry->setParameters($info['parameters']);
}
$logid = $logEntry->insert();
$logEntry->publish($logid);
} else {
// Compatibility with MediaWiki 1.18.
$log = new LogPage($info['type']);
$log->addEntry($info['subtype'], $info['title'], array_key_exists('comment', $info) ? $info['comment'] : '', array_key_exists('parameters', $info) ? $info['parameters'] : array(), $user);
}
}
}
示例15: logTagManagementAction
/**
* Writes a tag action into the tag management log.
*
* @param string $action
* @param string $tag
* @param string $reason
* @param User $user Who to attribute the action to
* @param int $tagCount For deletion only, how many usages the tag had before
* it was deleted.
* @return int ID of the inserted log entry
* @since 1.25
*/
protected static function logTagManagementAction($action, $tag, $reason, User $user, $tagCount = null)
{
$dbw = wfGetDB(DB_MASTER);
$logEntry = new ManualLogEntry('managetags', $action);
$logEntry->setPerformer($user);
// target page is not relevant, but it has to be set, so we just put in
// the title of Special:Tags
$logEntry->setTarget(Title::newFromText('Special:Tags'));
$logEntry->setComment($reason);
$params = array('4::tag' => $tag);
if (!is_null($tagCount)) {
$params['5:number:count'] = $tagCount;
}
$logEntry->setParameters($params);
$logEntry->setRelations(array('Tag' => $tag));
$logId = $logEntry->insert($dbw);
$logEntry->publish($logId);
return $logId;
}