本文整理汇总了PHP中ManualLogEntry::setPerformer方法的典型用法代码示例。如果您正苦于以下问题:PHP ManualLogEntry::setPerformer方法的具体用法?PHP ManualLogEntry::setPerformer怎么用?PHP ManualLogEntry::setPerformer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ManualLogEntry
的用法示例。
在下文中一共展示了ManualLogEntry::setPerformer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: logTagAdded
protected function logTagAdded($tags, $revId, $user, $reason)
{
// log it
$logEntry = new ManualLogEntry('tag', 'update');
$logEntry->setPerformer($user);
$logEntry->setComment($reason);
// find the appropriate target page
if ($revId) {
$rev = Revision::newFromId($revId);
if ($rev) {
$logEntry->setTarget($rev->getTitle());
}
}
if (!$logEntry->getTarget()) {
// target is required, so we have to set something
$logEntry->setTarget(SpecialPage::getTitleFor('Tags'));
}
$logParams = array('4::revid' => $revId, '6:list:tagsAdded' => $tags, '7:number:tagsAddedCount' => count($tags));
$logEntry->setParameters($logParams);
$logEntry->setRelations(array('Tag' => $tags));
$dbw = wfGetDB(DB_MASTER);
$logId = $logEntry->insert($dbw);
// Only send this to UDP, not RC, similar to patrol events
$logEntry->publish($logId, 'udp');
//$logEntry->publish( $logId );
}
示例4: 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);
}
示例5: 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;
}
示例6: 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');
}
}
}
示例7: newLogEntry
public function newLogEntry($action, $params)
{
$logEntry = new ManualLogEntry('phpunit', $action);
$logEntry->setPerformer($this->user);
$logEntry->setTarget($this->title);
$logEntry->setComment('A very good reason');
$logEntry->setParameters($params);
return $logEntry;
}
示例8: 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);
}
示例9: processUpload
private function processUpload()
{
$request = $this->getRequest();
$dataurl = $request->getVal('avatar');
if (!$dataurl || parse_url($dataurl, PHP_URL_SCHEME) !== 'data') {
$this->displayMessage($this->msg('avatar-notuploaded'));
return false;
}
$img = Thumbnail::open($dataurl);
global $wgMaxAvatarResolution;
switch ($img->type) {
case IMAGETYPE_GIF:
case IMAGETYPE_PNG:
case IMAGETYPE_JPEG:
break;
default:
$this->displayMessage($this->msg('avatar-invalid'));
return false;
}
// Must be square
if ($img->width !== $img->height) {
$this->displayMessage($this->msg('avatar-notsquare'));
return false;
}
// Check if image is too small
if ($img->width < 32 || $img->height < 32) {
$this->displayMessage($this->msg('avatar-toosmall'));
return false;
}
// Check if image is too big
if ($img->width > $wgMaxAvatarResolution || $img->height > $wgMaxAvatarResolution) {
$this->displayMessage($this->msg('avatar-toolarge'));
return false;
}
// Avatar directories
global $wgUploadDirectory;
$uploadDir = $wgUploadDirectory . '/avatars/' . $this->getUser()->getId() . '/';
@mkdir($uploadDir, 0777, true);
// We do this to convert format to png
$img->createThumbnail($wgMaxAvatarResolution, $uploadDir . 'original.png');
// We only create thumbnail with default resolution here. Others are generated on demand
global $wgDefaultAvatarRes;
$img->createThumbnail($wgDefaultAvatarRes, $uploadDir . $wgDefaultAvatarRes . '.png');
$img->cleanup();
$this->displayMessage($this->msg('avatar-saved'));
$logEntry = new \ManualLogEntry('avatar', 'upload');
$logEntry->setPerformer($this->getUser());
$logEntry->setTarget($this->getUser()->getUserPage());
$logId = $logEntry->insert();
$logEntry->publish($logId, 'rcandudp');
return true;
}
示例10: 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);
}
示例11: addLogEntry
/**
* adds a log entry to the database.
*
* @param $type string: type of the log entry
* @param $subtype string: subtype of the log entry
* @param $user User: user that performs the logged operation
* @param $ns int: number of the namespace for the entry's target's title
* @param $title string: title of the entry's target
* @param $comment string: comment of the log entry
* @param $parameters Array: (optional) accompanying data that is attached
* to the entry
*
* @return int id of the added log entry
*/
private function addLogEntry($type, $subtype, User $user, $ns, $title, $comment = null, $parameters = null)
{
$logEntry = new ManualLogEntry($type, $subtype);
$logEntry->setPerformer($user);
$logEntry->setTarget(Title::newFromText($title, $ns));
if ($comment !== null) {
$logEntry->setComment($comment);
}
if ($parameters !== null) {
$logEntry->setParameters($parameters);
}
return $logEntry->insert();
}
示例12: run
function run()
{
// Unfortunately the global is needed until bug is fixed:
// https://phabricator.wikimedia.org/T51086
// Once MW >= 1.24 is supported, can use MovePage class.
global $wgUser;
// Initialization
$title = $this->title;
// Other stuff
$user = $this->getUser();
$summary = $this->getSummary();
$target = $this->getTarget();
$base = $this->params['base-source'];
$doer = User::newFromName($this->getPerformer());
PageTranslationHooks::$allowTargetEdit = true;
PageTranslationHooks::$jobQueueRunning = true;
$oldUser = $wgUser;
$wgUser = $user;
self::forceRedirects(false);
// Don't check perms, don't leave a redirect
$ok = $title->moveTo($target, false, $summary, false);
if (!$ok) {
$params = array('target' => $target->getPrefixedText(), 'error' => $ok);
$entry = new ManualLogEntry('pagetranslation', 'movenok');
$entry->setPerformer($doer);
$entry->setTarget($title);
$entry->setParameters($params);
$logid = $entry->insert();
$entry->publish($logid);
}
self::forceRedirects(true);
PageTranslationHooks::$allowTargetEdit = false;
$this->unlock();
$cache = wfGetCache(CACHE_ANYTHING);
$key = wfMemcKey('translate-pt-move', $base);
$count = $cache->decr($key);
$last = strval($count) === '0';
if ($last) {
$cache->delete($key);
$params = array('target' => $this->params['base-target']);
$entry = new ManualLogEntry('pagetranslation', 'moveok');
$entry->setPerformer($doer);
$entry->setParameters($params);
$entry->setTarget(Title::newFromText($base));
$logid = $entry->insert();
$entry->publish($logid);
PageTranslationHooks::$jobQueueRunning = false;
}
$wgUser = $oldUser;
return true;
}
示例13: newLogEntry
/**
* Create new Log entry
*
* @param string $action Action name as defined above
* @param integer $mapId Map id
* @param string $comment Comment
* @param array $params Additional params
* @return ManualLogEntry
*/
public static function newLogEntry($action, $user, $mapId, $comment, $params = [])
{
$logEntry = new ManualLogEntry(self::LOG_TYPE_NAME, $action);
$logEntry->setPerformer($user);
$logEntry->setTarget(SpecialPage::getTitleFor(WikiaMapsSpecialController::PAGE_NAME, $mapId));
$logEntry->setComment($comment);
if (!empty($params)) {
// we can't allow to pass those elements
// more info: https://www.mediawiki.org/wiki/Manual:Logging_to_Special:Log#1.19_and_later
unset($params[1], $params[2], $params[3]);
$logEntry->setParameters($params);
}
return $logEntry;
}
示例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'];
$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);
}
示例15: onArticleInsertComplete
/**
* Called just after a new Article is created.
*
* @since 0.1
*/
public static function onArticleInsertComplete(&$article, User &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, Revision $revision)
{
global $articleProtectionNS;
if (!in_array($article->getTitle()->getNamespace(), $articleProtectionNS)) {
return true;
}
$dbw = wfGetDB(DB_MASTER);
$dbw->insert('article_protection', array('article_id' => $article->getID(), 'user_name' => $user->getName(), 'owner' => 1, 'original_owner' => 1, 'edit_permission' => 0));
$logEntry = new ManualLogEntry('ArticleProtection', 'owner-created-permissions');
$logEntry->setPerformer($user);
// User object, the user who performed this action
$logEntry->setTarget(Title::newFromID($article->getID()));
// The page that this log entry affects, a Title object
$logid = $logEntry->insert();
return true;
}