本文整理汇总了PHP中WikiFactory::setFlags方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::setFlags方法的具体用法?PHP WikiFactory::setFlags怎么用?PHP WikiFactory::setFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::setFlags方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: markWikiAsClosed
/**
* Mark given wiki as queued for removal
*
* @param $wikiId integer city ID
* @return bool
*/
private function markWikiAsClosed($wikiId)
{
WikiFactory::setFlags($wikiId, WikiFactory::FLAG_FREE_WIKI_URL | WikiFactory::FLAG_DELETE_DB_IMAGES);
$res = WikiFactory::setPublicStatus(WikiFactory::CLOSE_ACTION, $wikiId, self::REASON);
WikiFactory::clearCache($wikiId);
return $res !== false;
}
示例2: sendMail
function sendMail($commandLineOptions, $jobOptions, $wikiId, $wikiData)
{
global $wgSitename;
$wiki = WikiFactory::getWikiByID($wikiId);
$magicwords = array('#WIKINAME' => $wiki->city_title);
$flags = WikiFactory::getFlags($wikiId);
$flag = $jobOptions['mailType'] == 'first' ? WikiFactory::FLAG_ADOPT_MAIL_FIRST : WikiFactory::FLAG_ADOPT_MAIL_SECOND;
//this kind of e-mail already sent for this wiki
if ($flags & $flag) {
return;
}
$globalTitleUserRights = GlobalTitle::newFromText('UserRights', -1, $wikiId);
$specialUserRightsUrl = $globalTitleUserRights->getFullURL();
$globalTitlePreferences = GlobalTitle::newFromText('Preferences', -1, $wikiId);
$specialPreferencesUrl = $globalTitlePreferences->getFullURL();
//at least one admin has not edited during xx days
foreach ($wikiData['admins'] as $adminId) {
//print info
if (!isset($commandLineOptions['quiet'])) {
echo "Trying to send the e-mail to the user (id:{$adminId}) on wiki (id:{$wikiId}).\n";
}
$adminUser = User::newFromId($adminId);
$defaultOption = null;
if ($wikiId > 194785) {
$defaultOption = 1;
}
$acceptMails = $adminUser->getOption("adoptionmails-{$wikiId}", $defaultOption);
if ($acceptMails && $adminUser->isEmailConfirmed()) {
$adminName = $adminUser->getName();
if (!isset($commandLineOptions['quiet'])) {
echo "Sending the e-mail to the user (id:{$adminId}, name:{$adminName}) on wiki (id:{$wikiId}).\n";
}
if (!isset($commandLineOptions['dryrun'])) {
echo "Really Sending the e-mail to the user (id:{$adminId}, name:{$adminName}) on wiki (id:{$wikiId}).\n";
$adminUser->sendMail(strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-subject"), $magicwords), strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-content", $adminName, $specialUserRightsUrl, $specialPreferencesUrl), $magicwords), null, null, 'AutomaticWikiAdoption', strtr(wfMsgForContent("wikiadoption-mail-{$jobOptions['mailType']}-content-HTML", $adminName, $specialUserRightsUrl, $specialPreferencesUrl), $magicwords));
}
}
}
if (!isset($commandLineOptions['dryrun'])) {
WikiFactory::setFlags($wikiId, $flag);
}
}
示例3: doUpdateDomains
/**
* doUpdateDomains
*
* Store changes connected with domains
*
* @access private
* @author eloy@wikia
*
* @return mixed info when change, null when not changed
*/
private function doUpdateDomains(&$request)
{
$action = $request->getText("wpAction", null);
$reason = $request->getText("wpReason", wfMsg('wikifactory-public-status-change-default-reason'));
$message = "";
switch ($action) {
case "status":
$status = $request->getVal("wpWikiStatus", 0);
WikiFactory::setPublicStatus($status, $this->mWiki->city_id, $reason);
$this->mWiki->city_public = $status;
WikiFactory::clearCache($this->mWiki->city_id);
$message = "Status of this wiki was changed to " . $this->mStatuses[$status];
case "protect":
$protect = $request->getCheck("wpProtected", false);
if ($protect) {
$message = "Wiki protected";
WikiFactory::setFlags($this->mWiki->city_id, WikiFactory::FLAG_PROTECTED, false, $reason);
} else {
$message = "Wiki un-protected";
WikiFactory::resetFlags($this->mWiki->city_id, WikiFactory::FLAG_PROTECTED, false, $reason);
}
break;
}
return Wikia::successmsg($message);
}
示例4: doDisableWiki
protected function doDisableWiki($wikiId, $flags, $reason = '')
{
// TOOD: copied from WikiFactory::disableWiki since it's not released yet
WikiFactory::setFlags($wikiId, $flags);
$res = WikiFactory::setPublicStatus(WikiFactory::CLOSE_ACTION, $wikiId, $reason);
if ($this->debug) {
var_dump("setPublicStatus", $wikiId, $res);
}
WikiFactory::clearCache($wikiId);
return $res !== false;
}
示例5: processWikis
protected function processWikis()
{
$flags = $this->getFlags();
$status = $flags & WikiFactory::FLAG_HIDE_DB_IMAGES ? WikiFactory::HIDE_ACTION : WikiFactory::CLOSE_ACTION;
$reason = $this->reason;
foreach ($this->wikiIds as $wikiId) {
// skip wikis with id lesser than "start"
if ($this->start && $this->start > $wikiId) {
continue;
}
// echo "status: memory = ".memory_get_usage(true)."\n";
// check memory usage
if (!$this->checkMemoryLimit(1)) {
echo "error: memory limit exceeded (1G), please restart the script\n";
return;
}
$city = WikiFactory::getWikiByID($wikiId);
if (!$city) {
echo "{$wikiId}: error: city could not be found\n";
continue;
}
$city_name = $city->city_dbname;
if (!$city->city_public) {
echo "{$wikiId}: error: ({$city_name}) city is already non-public\n";
continue;
}
$evaluator = new DeadWikiEvaluator($wikiId);
if (!$evaluator->getStatus()) {
echo "{$wikiId}: error: ({$city_name}) city does not meet requirements to be closed: " . $evaluator->getMessage() . "\n";
continue;
}
echo "{$wikiId}: ({$city_name}) marking as closed... ";
if (!$this->dryRun) {
WikiFactory::setFlags($wikiId, $flags);
$res = WikiFactory::setPublicStatus($status, $wikiId, $reason);
WikiFactory::clearCache($wikiId);
echo "OK\n";
} else {
echo "OK (dry run)\n";
}
}
}
示例6: doClose
/**
* close Wiki(s)
* @access private
*/
private function doClose($newWiki = "")
{
global $wgRequest, $wgOut;
wfProfileIn(__METHOD__);
$WFTitle = Title::makeTitle(NS_SPECIAL, 'WikiFactory');
#---
$output = "";
if (!empty($this->mWikis)) {
$output = Xml::openElement('ul', null);
foreach ($this->mWikis as $wiki) {
Wikia::log(__METHOD__, "Closing: {$wiki->city_title} (url: {$wiki->city_url}) (id: {$wiki->city_id}) (dbname: {$wiki->city_dbname}) ");
#-- move to archive
$message = wfMsgExt('closewiki-wiki-closed', array('parse'), $wiki->city_title, $wiki->city_url);
if (!empty($newWiki)) {
Wikia::log(__METHOD__, " ... and redirecting to: {$this->mRedirect} (id: {$newWiki})");
$this->moveOldDomains($wiki->city_id, $newWiki);
#-- add "old" prefix to main domain and set is as primary
$prefixedDomain = $this->prefixMainDomain($wiki->city_id);
Wikia::log(__METHOD__, " ... primary domain set to: {$prefixedDomain}");
#-- set new city ID in city_domains (except for just created "old" domain)
$isMoved = WikiFactory::redirectDomains($wiki->city_id, $newWiki, !empty($prefixedDomain) ? array($prefixedDomain) : array());
#---
$message = wfMsgExt('closewiki-wiki-closed_redirect', array('parse'), $wiki->city_title, $wiki->city_url, sprintf("%s%s", "http://", $this->mRedirect));
}
#-- set public to 0
$status = isset($this->mFlags[WikiFactory::FLAG_HIDE_DB_IMAGES]) ? WikiFactory::HIDE_ACTION : WikiFactory::CLOSE_ACTION;
#-- set flags as a number
if (!empty($this->mFlags)) {
$city_flags = 0;
foreach ($this->mFlags as $flag) {
$city_flags |= $flag;
}
WikiFactory::setFlags($wiki->city_id, $city_flags);
}
// Let's request the XML dump if needed
if (isset($this->mFlags[WikiFactory::FLAG_CREATE_DB_DUMP])) {
DumpsOnDemand::queueDump($wiki->city_id, isset($this->mFlags[WikiFactory::FLAG_HIDE_DB_IMAGES]), true);
}
if (empty($this->mReason)) {
$this->mReason = "-";
}
$res = WikiFactory::setPublicStatus($status, $wiki->city_id, $this->mReason);
if ($res === $status) {
$output .= Xml::tags('li', array('style' => 'padding:4px;'), $message);
WikiFactory::clearCache($wiki->city_id);
if (!empty($newWiki)) {
WikiFactory::clearCache($newWiki);
}
}
}
$output .= Xml::closeElement('ul');
}
$output .= Xml::element('input', array('name' => 'wiki-return', 'type' => 'button', 'value' => wfMsg('closewiki-return', wfMsg('wikifactory')), 'onclick' => "window.location='{$WFTitle->getFullURL()}'"));
$wgOut->addHtml($output);
$aHookParams = ['city_id' => $wiki->city_id];
wfRunHooks('WikiFactoryWikiClosed', array($aHookParams));
wfProfileOut(__METHOD__);
}