当前位置: 首页>>代码示例>>PHP>>正文


PHP WCF::setLanguage方法代码示例

本文整理汇总了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');
         }
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:65,代码来源:UserAction.class.php

示例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);
         }
     }
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:41,代码来源:UserAction.class.php


注:本文中的wcf\system\WCF::setLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。