Skip to content

Commit

Permalink
Fixed issue: #08206: Add answers to the set of labels is not possible…
Browse files Browse the repository at this point in the history
… in language code for "-" eg: pt-BR.

Dev: remove xss filter uneeded
Dev: use sanitize_languagecodeS for language and rules for label name
  • Loading branch information
Shnoulle committed Oct 4, 2013
1 parent 8e2ffd6 commit 2f4458c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions application/controllers/admin/labels.php
Expand Up @@ -392,8 +392,8 @@ public function ajaxSets()
if ($lid == 0)
{
$lset = new Labelsets;
$lset->label_name = sanitize_xss_string(Yii::app()->getRequest()->getPost('laname'));
$lset->languages = sanitize_xss_string($language);
$lset->label_name = Yii::app()->getRequest()->getPost('laname');
$lset->languages = sanitize_languagecodeS($language);
$lset->save();

$lid = getLastInsertID($lset->tableName());
Expand Down
16 changes: 3 additions & 13 deletions application/helpers/admin/label_helper.php
Expand Up @@ -97,19 +97,9 @@ function insertlabelset()
// $labelsoutput.= $_POST['languageids']; For debug purposes
$clang = Yii::app()->lang;

$postlanguageids=sanitize_languagecodeS(Yii::app()->getRequest()->getPost('languageids'));
$postlabel_name=Yii::app()->getRequest()->getPost('label_name');

if (!empty($_POST['languageids']))
{
$postlanguageids=sanitize_languagecodeS($_POST['languageids']);
}

if (!empty($_POST['label_name']))
{
$postlabel_name=sanitize_labelname($_POST['label_name']);
}

//postlabel_name = dbQuoteAll($postlabel_name,true);
//$postlanguageids = dbQuoteAll($postlanguageids,true);
$data = array(
'label_name' => $postlabel_name,
'languages' => $postlanguageids
Expand All @@ -119,7 +109,7 @@ function insertlabelset()
$result=Labelsets::model()->insertRecords($data);
if (!$result)
{
safeDie("Inserting the label set failed:<br />".$query."<br />");
Yii::app()->session['flashmessage'] = $clang->gT("Inserting the label set failed.");
}
else
{
Expand Down
13 changes: 12 additions & 1 deletion application/models/Labelsets.php
Expand Up @@ -64,7 +64,18 @@ function getAllRecords($condition=FALSE)

return $data;
}

/**
* Returns this model's validation rules
*
*/
public function rules()
{
return array(
array('label_name','required'),
array('label_name','length', 'min' => 1, 'max'=>100),
array('label_name','LSYii_Validators'),
);
}
function getLID()
{
return Yii::app()->db->createCommand()->select('lid')->order('lid asc')->from('{{labelsets}}')->query()->readAll();
Expand Down

0 comments on commit 2f4458c

Please sign in to comment.