本文整理汇总了PHP中wcf\system\WCF::setLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP WCF::setLanguage方法的具体用法?PHP WCF::setLanguage怎么用?PHP WCF::setLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\system\WCF
的用法示例。
在下文中一共展示了WCF::setLanguage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* @see \wcf\data\AbstractDatabaseObjectAction::update()
*/
public function update()
{
if (isset($this->parameters['data'])) {
parent::update();
if (isset($this->parameters['data']['languageID'])) {
foreach ($this->objects as $object) {
if ($object->userID == WCF::getUser()->userID) {
if ($this->parameters['data']['languageID'] != WCF::getUser()->languageID) {
WCF::setLanguage($this->parameters['data']['languageID']);
}
break;
}
}
}
} else {
if (empty($this->objects)) {
$this->readObjects();
}
}
$groupIDs = isset($this->parameters['groups']) ? $this->parameters['groups'] : array();
$languageIDs = isset($this->parameters['languageIDs']) ? $this->parameters['languageIDs'] : array();
$removeGroups = isset($this->parameters['removeGroups']) ? $this->parameters['removeGroups'] : array();
$userOptions = isset($this->parameters['options']) ? $this->parameters['options'] : array();
if (!empty($groupIDs)) {
$action = new UserAction($this->objects, 'addToGroups', array('groups' => $groupIDs, 'addDefaultGroups' => false));
$action->executeAction();
}
if (!empty($removeGroups)) {
$action = new UserAction($this->objects, 'removeFromGroups', array('groups' => $removeGroups));
$action->executeAction();
}
foreach ($this->objects as $userEditor) {
if (!empty($userOptions)) {
$userEditor->updateUserOptions($userOptions);
}
if (!empty($languageIDs)) {
$userEditor->addToLanguages($languageIDs);
}
}
// handle user rename
if (count($this->objects) == 1 && !empty($this->parameters['data']['username'])) {
if ($this->objects[0]->username != $this->parameters['data']['username']) {
$userID = $this->objects[0]->userID;
$username = $this->parameters['data']['username'];
WCF::getDB()->beginTransaction();
// update comments
$sql = "UPDATE\twcf" . WCF_N . "_comment\n\t\t\t\t\tSET\tusername = ?\n\t\t\t\t\tWHERE\tuserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($username, $userID));
$sql = "UPDATE\twcf" . WCF_N . "_comment_response\n\t\t\t\t\tSET\tusername = ?\n\t\t\t\t\tWHERE\tuserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($username, $userID));
// modification log
$sql = "UPDATE\twcf" . WCF_N . "_modification_log\n\t\t\t\t\tSET\tusername = ?\n\t\t\t\t\tWHERE\tuserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($username, $userID));
WCF::getDB()->commitTransaction();
// fire event to handle other database tables
EventHandler::getInstance()->fireAction($this, 'rename');
}
}
}
示例2: update
/**
* @see wcf\data\AbstractDatabaseObjectAction::update()
*/
public function update()
{
if (isset($this->parameters['data'])) {
parent::update();
if (isset($this->parameters['data']['languageID'])) {
foreach ($this->objects as $object) {
if ($object->userID == WCF::getUser()->userID) {
if ($this->parameters['data']['languageID'] != WCF::getUser()->languageID) {
WCF::setLanguage($this->parameters['data']['languageID']);
}
break;
}
}
}
} else {
if (!count($this->objects)) {
$this->readObjects();
}
}
$groupIDs = isset($this->parameters['groups']) ? $this->parameters['groups'] : array();
$languageIDs = isset($this->parameters['languageIDs']) ? $this->parameters['languageIDs'] : array();
$removeGroups = isset($this->parameters['removeGroups']) ? $this->parameters['removeGroups'] : array();
$userOptions = isset($this->parameters['options']) ? $this->parameters['options'] : array();
foreach ($this->objects as $userEditor) {
if (!empty($groupIDs)) {
$userEditor->addToGroups($groupIDs);
}
if (!empty($removeGroups)) {
$userEditor->removeFromGroups($removeGroups);
}
if (!empty($userOptions)) {
$userEditor->updateUserOptions($userOptions);
}
if (!empty($languageIDs)) {
$userEditor->addToLanguages($languageIDs);
}
}
}