本文整理汇总了PHP中UserProfile::clearCache方法的典型用法代码示例。如果您正苦于以下问题:PHP UserProfile::clearCache方法的具体用法?PHP UserProfile::clearCache怎么用?PHP UserProfile::clearCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserProfile
的用法示例。
在下文中一共展示了UserProfile::clearCache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Show the special page
*
* @param $section Mixed: parameter passed to the page or null
*/
public function execute( $par ) {
global $wgUser, $wgOut, $wgRequest, $wgUserProfileScripts, $wgScriptPath, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle;
$wgSupressPageTitle = true;
$wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'edit-profiles-title' ) ) );
// This feature is only available for logged-in users.
if ( !$wgUser->isLoggedIn() ) {
$wgOut->setPageTitle( wfMsg( 'user-profile-update-notloggedin-title' ) );
$wgOut->addWikiMsg( 'user-profile-update-notloggedin-text' );
return;
}
// No need to allow blocked users to access this page, they could abuse it, y'know.
if ( $wgUser->isBlocked() ) {
$wgOut->blockedPage( false );
return false;
}
// Database operations require write mode
if ( wfReadOnly() ) {
$wgOut->readOnlyPage();
return;
}
// Are we even allowed to do this?
if ( !$wgUser->isAllowed( 'editothersprofiles' ) ) {
$wgOut->permissionRequired( 'editothersprofiles' );
return;
}
// Add CSS & JS
$wgOut->addExtensionStyle( $wgUserProfileScripts . '/UserProfile.css' );
if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
$wgOut->addModuleScripts( 'ext.userProfile.updateProfile' );
} else {
$wgOut->addScriptFile( $wgUserProfileScripts . '/UpdateProfile.js' );
}
// Get the user's name from the wpUser URL parameter
$userFromRequest = $wgRequest->getText( 'wpUser' );
// If the wpUser parameter isn't set but a parameter was passed to the
// special page, use the given parameter instead
if ( !$userFromRequest && $par ) {
$userFromRequest = $par;
}
// Still not set? Just give up and show the "search for a user" form...
if ( !$userFromRequest ) {
$wgOut->addHTML( $this->createUserInputForm() );
return;
}
$target = User::newFromName( $userFromRequest );
if ( !$target || $target->getID() == 0 ) {
$wgOut->addHTML( wfMsg( 'nosuchusershort', htmlspecialchars( $userFromRequest ) ) );
$wgOut->addHTML( $this->createUserInputForm() );
return;
}
if ( $wgRequest->wasPosted() ) {
$this->saveProfileBasic( $target );
$this->saveSettings_basic( $target );
$this->saveProfilePersonal( $target );
$this->saveProfileCustom( $target );
UserProfile::clearCache( $target->getID() );
$log = new LogPage( 'profile' );
if ( !$wgUpdateProfileInRecentChanges ) {
$log->updateRecentChanges = false;
}
$log->addEntry(
'profile',
$target->getUserPage(),
wfMsgForContent( 'user-profile-edit-profile',
array( '[[User:' . $target->getName() . ']]' ) )
);
$wgOut->addHTML(
'<span class="profile-on">' .
wfMsg( 'user-profile-edit-profile-update-saved' ) .
'</span><br /><br />'
);
// create the user page if it doesn't exist yet
$title = Title::makeTitle( NS_USER, $target->getName() );
$article = new Article( $title );
if ( !$article->exists() ) {
$article->doEdit( '', 'create user page', EDIT_SUPPRESS_RC );
}
}
$wgOut->addHTML( $this->displayBasicForm( $target ) );
//.........这里部分代码省略.........
示例2: execute
/**
* Show the special page
*
* @param $section Mixed: parameter passed to the page or null
*/
public function execute($section)
{
global $wgUser, $wgOut, $wgRequest, $wgUserProfileScripts, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle;
$wgSupressPageTitle = true;
$wgOut->setHTMLTitle(wfMsg('pagetitle', wfMsg('edit-profile-title')));
// This feature is only available for logged-in users.
if (!$wgUser->isLoggedIn()) {
$wgOut->setPageTitle(wfMsgForContent('user-profile-update-notloggedin-title'));
$wgOut->addHTML(wfMsgForContent('user-profile-update-notloggedin-text', SpecialPage::getTitleFor('Userlogin')->escapeFullURL(), SpecialPage::getTitleFor('Userlogin', 'signup')->escapeFullURL()));
return;
}
// No need to allow blocked users to access this page, they could abuse it, y'know.
if ($wgUser->isBlocked()) {
$wgOut->blockedPage(false);
return false;
}
// Database operations require write mode
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return;
}
// Add CSS & JS
$wgOut->addExtensionStyle($wgUserProfileScripts . '/UserProfile.css');
$wgOut->addScriptFile($wgUserProfileScripts . '/UpdateProfile.js');
if ($wgRequest->wasPosted()) {
if (!$section) {
$section = 'basic';
}
switch ($section) {
case 'basic':
$this->saveProfileBasic();
$this->saveSettings_basic();
break;
case 'personal':
$this->saveProfilePersonal();
break;
case 'custom':
$this->saveProfileCustom();
break;
case 'preferences':
$this->saveSettings_pref();
break;
}
UserProfile::clearCache($wgUser->getID());
$log = new LogPage(wfMsgForContent('user-profile-update-profile'));
if (!$wgUpdateProfileInRecentChanges) {
$log->updateRecentChanges = false;
}
$log->addEntry(wfMsgForContent('user-profile-update-profile'), $wgUser->getUserPage(), wfMsgForContent('user-profile-update-log-section') . " '{$section}'");
$wgOut->addHTML('<span class="profile-on">' . wfMsg('user-profile-update-saved') . '</span><br /><br />');
// create user page if not exists
$title = Title::makeTitle(NS_USER, $wgUser->getName());
$article = new Article($title);
if (!$article->exists()) {
$article->doEdit('', 'create user page', EDIT_SUPPRESS_RC);
}
}
if (!$section) {
$section = 'basic';
}
switch ($section) {
case 'basic':
$wgOut->addHTML($this->displayBasicForm());
break;
case 'personal':
$wgOut->addHTML($this->displayPersonalForm());
break;
case 'custom':
$wgOut->addHTML($this->displayCustomForm());
break;
case 'preferences':
$wgOut->addHTML($this->displayPreferencesForm());
break;
}
}
示例3: execute
//.........这里部分代码省略.........
// Why, oh why did I want to be so fucking smart with these
// field names?! This str_replace() voodoo all over the place is
// outright painful.
$correctField = str_replace('-', '_', $field);
if ($stats_data[$correctField] < $threshold) {
$can_create = false;
$thresholdReasons[$threshold] = $field;
}
}
$hasEqualEditThreshold = isset($wgUserProfileThresholds['edit']) && $wgUserProfileThresholds['edit'] == $wgAutoConfirmCount ? true : false;
$can_create = $user->isAllowed('createpage') && $hasEqualEditThreshold ? true : $can_create;
// Boo, go away!
if ($can_create == false) {
global $wgSupressPageTitle;
$wgSupressPageTitle = false;
$out->setPageTitle($this->msg('user-profile-create-threshold-title')->text());
$thresholdMessages = array();
foreach ($thresholdReasons as $requiredAmount => $reason) {
// Replace underscores with hyphens for consistency in i18n
// message names.
$reason = str_replace('_', '-', $reason);
/**
* For grep:
* user-profile-create-threshold-edits
* user-profile-create-threshold-votes
* user-profile-create-threshold-comments
* user-profile-create-threshold-comment-score-plus
* user-profile-create-threshold-comment-score-minus
* user-profile-create-threshold-recruits
* user-profile-create-threshold-friend-count
* user-profile-create-threshold-foe-count
* user-profile-create-threshold-weekly-wins
* user-profile-create-threshold-monthly-wins
* user-profile-create-threshold-poll-votes
* user-profile-create-threshold-picture-game-votes
* user-profile-create-threshold-quiz-created
* user-profile-create-threshold-quiz-answered
* user-profile-create-threshold-quiz-correct
* user-profile-create-threshold-quiz-points
*/
$thresholdMessages[] = $this->msg('user-profile-create-threshold-' . $reason)->numParams($requiredAmount)->parse();
}
$out->addHTML($this->msg('user-profile-create-threshold-reason', $this->getLanguage()->commaList($thresholdMessages))->parse());
return '';
}
}
// Add CSS & JS
$out->addModuleStyles('ext.socialprofile.userprofile.css');
$out->addModules('ext.userProfile.updateProfile');
if ($request->wasPosted()) {
if (!$section) {
$section = 'basic';
}
switch ($section) {
case 'basic':
$this->saveProfileBasic($user);
$this->saveSettings_basic($user);
break;
case 'personal':
$this->saveProfilePersonal($user);
break;
case 'custom':
$this->saveProfileCustom($user);
break;
case 'preferences':
$this->saveSettings_pref();
break;
}
UserProfile::clearCache($user->getID());
$log = new LogPage('profile');
if (!$wgUpdateProfileInRecentChanges) {
$log->updateRecentChanges = false;
}
$log->addEntry('profile', $user->getUserPage(), $this->msg('user-profile-update-log-section')->inContentLanguage()->text() . " '{$section}'");
$out->addHTML('<span class="profile-on">' . $this->msg('user-profile-update-saved')->plain() . '</span><br /><br />');
// create the user page if it doesn't exist yet
$title = Title::makeTitle(NS_USER, $user->getName());
$article = new Article($title);
if (!$article->exists()) {
$article->doEdit('', 'create user page', EDIT_SUPPRESS_RC);
}
}
if (!$section) {
$section = 'basic';
}
switch ($section) {
case 'basic':
$out->addHTML($this->displayBasicForm($user));
break;
case 'personal':
$out->addHTML($this->displayPersonalForm($user));
break;
case 'custom':
$out->addHTML($this->displayCustomForm($user));
break;
case 'preferences':
$out->addHTML($this->displayPreferencesForm());
break;
}
}