本文整理匯總了PHP中UserStatus::setInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserStatus::setInfo方法的具體用法?PHP UserStatus::setInfo怎麽用?PHP UserStatus::setInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserStatus
的用法示例。
在下文中一共展示了UserStatus::setInfo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wfUpdateUserStatus
function wfUpdateUserStatus($username, $field, $value)
{
global $wgUser;
// Sanitizer::escapeHtmlAllowEntities($html);
$value = trim($value);
$field = trim($field);
$out = ResponseGenerator::getJson(ResponseGenerator::ERROR_UNKNOWN);
// This feature is only available for logged-in users.
if (!$wgUser->isLoggedIn()) {
$out = ResponseGenerator::getJson(ResponseGenerator::ERROR_NOT_LOGGED_IN);
return $out;
}
// No need to allow blocked users to access this page, they could abuse it, y'know.
if ($wgUser->isBlocked()) {
$out = ResponseGenerator::getJson(ResponseGenerator::ERROR_BLOCKED);
return $out;
}
// Database operations require write mode
if (wfReadOnly()) {
$out = ResponseGenerator::getJson(ResponseGenerator::ERROR_READ_ONLY);
return $out;
}
// Are we even allowed to do this?
if (!$wgUser->isAllowed('edit')) {
$out = ResponseGenerator::getJson(ResponseGenerator::ERROR_NOT_ALLOWED);
return $out;
}
if ($username === $wgUser->getName()) {
$us = new UserStatus($wgUser);
// if ($us->setAll($gender, $province, $city, $birthday, $status)){
// $out = ResponseGenerator::getJson(ResponseGenerator::SUCCESS);
// }
if ($us->setInfo($field, $value)) {
// $out = ResponseGenerator::getJson(ResponseGenerator::SUCCESS);
$ret = array('success' => true, 'result' => $us->setInfo($field, $value));
$out = json_encode($ret);
return $out;
}
}
return $out;
}