/** * Deletes a flexiskin defined by id via request parameter * @return String encoded result JSON string */ public function deleteFlexiskin() { $sId = $this->getMain()->getVal('id', ''); if ($sId == "") { return FormatJson::encode(array('success' => false, 'msg' => wfMessage('bs-flexiskin-api-error-missing-param', 'id')->plain())); } $oStatus = BsFileSystemHelper::deleteFolder("flexiskin" . DS . $iId); if (BsConfig::get("MW::Flexiskin::Active") == $iId) { BsConfig::set("MW::Flexiskin::Active", ""); BsConfig::saveSettings(); } if (!$oStatus->isGood()) { return FormatJson::encode(array('success' => false, 'msg' => wfMessage('bs-flexiskin-error-delete-skin', $this->getErrorMessage($oStatus))->plain())); } else { return FormatJson::encode(array('success' => true)); } }
public static function uploadFile() { if (wfReadOnly()) { global $wgReadOnly; $oAjaxResponse = new AjaxResponse(FormatJson::encode(array('success' => false, 'msg' => wfMessage('bs-readonly', $wgReadOnly)->escaped()))); $oAjaxResponse->setContentType('text/html'); return $oAjaxResponse; } global $wgRequest, $wgUser; self::unsetUserImage($wgUser); $oAvatars = BsExtensionManager::getExtension('Avatars'); $sAvatarFileName = self::$sAvatarFilePrefix . $wgUser->getId() . ".png"; $oStatus = BsFileSystemHelper::uploadAndConvertImage($wgRequest->getVal('name'), $oAvatars->mInfo[EXTINFO::NAME], $sAvatarFileName); if (!$oStatus->isGood()) { $aErrors = $oStatus->getErrorsArray(); $aResult = json_encode(array('success' => false, 'msg' => $aErrors[0][0])); } else { $aResult = json_encode(array('success' => true, 'msg' => wfMessage('bs-avatars-upload-complete')->plain(), 'name' => $oStatus->getValue())); # found no way to regenerate thumbs. just delete thumb folder if it exists $oStatus = BsFileSystemHelper::deleteFolder('Avatars' . DS . 'thumb' . DS . $sAvatarFileName, true); if (!$oStatus->isGood()) { throw new MWException('FATAL: Avatar thumbs could no be deleted!'); } } $oAjaxResponse = new AjaxResponse($aResult); $oAjaxResponse->setContentType('text/html'); return $oAjaxResponse; }