/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Quota(); if (isset($_POST['Quota'])) { $model->attributes = $_POST['Quota']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->idQuota)); } } $this->render('create', array('model' => $model)); }
function insertquota($iSurveyId) { $iSurveyId = sanitize_int($iSurveyId); $this->_checkPermissions($iSurveyId, 'create'); $aData = $this->_getData($iSurveyId); $aLangs = $aData['aLangs']; $oQuota = new Quota(); $oQuota->sid = $iSurveyId; $oQuota->name = Yii::app()->request->getPost('quota_name'); $oQuota->qlimit = Yii::app()->request->getPost('quota_limit'); $oQuota->action = Yii::app()->request->getPost('quota_action'); $oQuota->autoload_url = Yii::app()->request->getPost('autoload_url'); $oQuota->save(); $iQuotaId = $oQuota->id; //Iterate through each language, and make sure there is a quota message for it $sError = ''; foreach ($aLangs as $sLang) { if (!$_POST['quotals_message_' . $sLang]) { $sError .= getLanguageNameFromCode($sLang, false) . "\\n"; } } if ($sError != '') { $aData['sShowError'] = $sError; } else { foreach ($aLangs as $sLang) { //Clean XSS - Automatically provided by CI input class $_POST['quotals_message_' . $sLang] = html_entity_decode($_POST['quotals_message_' . $sLang], ENT_QUOTES, "UTF-8"); // Fix bug with FCKEditor saving strange BR types $_POST['quotals_message_' . $sLang] = fixCKeditorText($_POST['quotals_message_' . $sLang]); $oQuotaLanguageSettings = new QuotaLanguageSetting(); $oQuotaLanguageSettings->quotals_quota_id = $iQuotaId; $oQuotaLanguageSettings->quotals_language = $sLang; $oQuotaLanguageSettings->quotals_name = Yii::app()->request->getPost('quota_name'); $oQuotaLanguageSettings->quotals_message = $_POST['quotals_message_' . $sLang]; $oQuotaLanguageSettings->quotals_url = $_POST['quotals_url_' . $sLang]; $oQuotaLanguageSettings->quotals_urldescrip = $_POST['quotals_urldescrip_' . $sLang]; $oQuotaLanguageSettings->save(); } } self::_redirectToIndex($iSurveyId); }