/**
  * Add a website into help desk setting
  *
  * <b>Request Type: </b>PUT<br/>
  * <b>Request Endpoint: </b>http://{server-domain}/api/helpdesk/setting/add-website<br/>
  * <b>Content-type: </b>Application/json<br/>
  * <b>Summary: </b>This api is for adding a website into help desk setting.<br/>
  *
  * <b>Request Example: </b>
  * <pre>
  *     {
  *          "settingId": '52d791327ae252f9149547cb',
  *          "Website"  : {
  *              "name" : '爱不宅',
  *              "url"  : 'www.ibuzhai.com'
  *          }
  *     }
  * </pre>
  */
 public function actionAddWebsite()
 {
     $checkUrl = "((http|ftp|https)://)(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-]*)?";
     $website = $this->getParams('website');
     $settingId = $this->getParams('settingId');
     $accountId = $this->getAccountId();
     if (!ereg($checkUrl, $website['url'])) {
         throw new InvalidParameterException(['url' => Yii::t('helpDesk', 'url_format_wrong')]);
     }
     if (!empty($website['name']) && !empty($website['url'])) {
         $settingId = new \MongoId($settingId);
         $website = ['id' => StringUtil::uuid(), 'name' => $website['name'], 'url' => $website['url'], 'code' => HelpDeskSetting::getCode($website['url'], $accountId)];
         // Add a website into help desk setting
         $result = HelpDeskSetting::updateAll(['$push' => ['websites' => $website]], ['_id' => $settingId]);
         if ($result) {
             return $website;
         }
         throw new ServerErrorHttpException('add website fail');
     }
     throw new BadRequestHttpException('parameters missing');
 }