/** * Process labels form data depending on $action. * * @access public * @return void */ public function process() { $action = returnGlobal('action'); Yii::app()->loadHelper('admin/label'); $lid = returnGlobal('lid'); if ($action == "updateset" && Permission::model()->hasGlobalPermission('labelsets', 'update')) { updateset($lid); Yii::app()->setFlashMessage(gT("Label set properties sucessfully updated."), 'success'); } if ($action == "insertlabelset" && Permission::model()->hasGlobalPermission('labelsets', 'create')) { $lid = insertlabelset(); } if (($action == "modlabelsetanswers" || $action == "ajaxmodlabelsetanswers") && Permission::model()->hasGlobalPermission('labelsets', 'update')) { modlabelsetanswers($lid); } if ($action == "deletelabelset" && Permission::model()->hasGlobalPermission('labelsets', 'delete')) { if (deletelabelset($lid)) { Yii::app()->setFlashMessage(gT("Label set sucessfully deleted."), 'success'); $lid = 0; } } if ($lid) { $this->getController()->redirect(array("admin/labels/sa/view/lid/" . $lid)); } else { $this->getController()->redirect(array("admin/labels/sa/view")); } }
/** * Process labels form data depending on $action. * * @access public * @return void */ public function process() { if (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1 || Yii::app()->session['USER_RIGHT_MANAGE_LABEL'] == 1) { if (isset($_POST['method']) && get_magic_quotes_gpc()) { $_POST['method'] = stripslashes($_POST['method']); } $action = returnGlobal('action'); Yii::app()->loadHelper('admin/label'); $lid = returnGlobal('lid'); if ($action == "updateset") { updateset($lid); Yii::app()->session['flashmessage'] = Yii::app()->lang->gT("Label set properties sucessfully updated."); } if ($action == "insertlabelset") { $lid = insertlabelset(); } if ($action == "modlabelsetanswers" || $action == "ajaxmodlabelsetanswers") { modlabelsetanswers($lid); } if ($action == "deletelabelset") { if (deletelabelset($lid)) { Yii::app()->session['flashmessage'] = Yii::app()->lang->gT("Label set sucessfully deleted."); $lid = 0; } } if ($lid) { $this->getController()->redirect($this->getController()->createUrl("admin/labels/sa/view/lid/" . $lid)); } else { $this->getController()->redirect($this->getController()->createUrl("admin/labels/sa/view")); } } }
$_POST['method'] = stripslashes($_POST['method']); } $labelsoutput=''; if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $_SESSION['USER_RIGHT_MANAGE_LABEL'] == 1) { $js_admin_includes[]='scripts/labels.js'; if (isset($_POST['sortorder'])) {$postsortorder=sanitize_int($_POST['sortorder']);} if (!isset($action)) {$action=returnglobal('action');} if (!isset($lid)) {$lid=returnglobal('lid');} //DO DATABASE UPDATESTUFF if ($action == "updateset") {updateset($lid);} if ($action == "insertlabelset") {$lid=insertlabelset();} if ($action == "modlabelsetanswers") {modlabelsetanswers($lid);} if ($action == "deletelabelset") {if (deletelabelset($lid)) {$lid=0;}} if ($action == "importlabels") { include("importlabel.php"); } if ($action == "importlabelresources") { include("import_resources_zip.php"); if (isset($importlabelresourcesoutput)) {$labelsoutput.= $importlabelresourcesoutput;} return; } $labelsoutput= "<div class='menubar'>\n"
function modlabelsetanswers($lid) { //global $labelsoutput; $clang = Yii::app()->lang; $ajax = false; if (isset($_POST['ajax']) && $_POST['ajax'] == "1") { $ajax = true; } if (!isset($_POST['method'])) { $_POST['method'] = $clang->gT("Save"); } $sPostData = Yii::app()->getRequest()->getPost('dataToSend'); $sPostData = str_replace("\t", '', $sPostData); if (get_magic_quotes_gpc()) { $data = json_decode(stripslashes($sPostData)); } else { $data = json_decode($sPostData); } if ($ajax) { $lid = insertlabelset(); } $aErrors = array(); if (count(array_unique($data->{'codelist'})) == count($data->{'codelist'})) { $query = "DELETE FROM {{labels}} WHERE lid = '{$lid}'"; $result = Yii::app()->db->createCommand($query)->execute(); foreach ($data->{'codelist'} as $index => $codeid) { $codeObj = $data->{$codeid}; $actualcode = $codeObj->{'code'}; //$codeid = dbQuoteAll($codeid,true); $assessmentvalue = (int) $codeObj->{'assessmentvalue'}; foreach ($data->{'langs'} as $lang) { $strTemp = 'text_' . $lang; $title = $codeObj->{$strTemp}; $sortorder = $index; $oLabel = new Label(); $oLabel->lid = $lid; $oLabel->code = $actualcode; $oLabel->title = $title; $oLabel->sortorder = $sortorder; $oLabel->assessment_value = $assessmentvalue; $oLabel->language = $lang; if ($oLabel->validate()) { $result = $oLabel->save(); } else { $aErrors[] = $oLabel->getErrors(); } } } if (count($aErrors)) { Yii::app()->session['flashmessage'] = $clang->gT("Not all labels were updated successfully."); } else { Yii::app()->session['flashmessage'] = $clang->gT("Labels sucessfully updated"); } } else { Yii::app()->setFlashMessage($clang->gT("Can't update labels because you are using duplicated codes"), 'error'); } if ($ajax) { die; } }
function modlabelsetanswers($lid) { global $dbprefix, $connect, $clang, $labelsoutput, $databasetype, $filterxsshtml, $postsortorder; $ajax = false; if (isset($_POST['ajax']) && $_POST['ajax'] == "1") { $ajax = true; } if (!isset($_POST['method'])) { $_POST['method'] = $clang->gT("Save"); } $data = json_decode(html_entity_decode($_POST['dataToSend'], ENT_QUOTES, "UTF-8")); if ($ajax) { $lid = insertlabelset(); } if (count(array_unique($data->{'codelist'})) == count($data->{'codelist'})) { if ($filterxsshtml) { require_once "../classes/inputfilter/class.inputfilter_clean.php"; $myFilter = new InputFilter('', '', 1, 1, 1); } $query = "DELETE FROM " . db_table_name('labels') . " WHERE lid = {$lid}"; $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); foreach ($data->{'codelist'} as $index => $codeid) { $codeObj = $data->{$codeid}; $actualcode = db_quoteall($codeObj->{'code'}, true); $codeid = db_quoteall($codeid, true); $assessmentvalue = (int) $codeObj->{'assessmentvalue'}; foreach ($data->{'langs'} as $lang) { $strTemp = 'text_' . $lang; $title = $codeObj->{$strTemp}; if ($filterxsshtml) { $title = $myFilter->process($title); } else { $title = html_entity_decode($title, ENT_QUOTES, "UTF-8"); } // Fix bug with FCKEditor saving strange BR types $title = fix_FCKeditor_text($title); $title = db_quoteall($title, true); $sort_order = db_quoteall($index); $lang = db_quoteall($lang); $query = "INSERT INTO " . db_table_name('labels') . " (lid,code,title,sortorder, assessment_value, language)\n VALUES({$lid},{$actualcode},{$title},{$sort_order},{$assessmentvalue},{$lang})"; $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); } } $_SESSION['flashmessage'] = $clang->gT("Labels sucessfully updated"); } else { $labelsoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"" . $clang->gT("Can't update labels because you are using duplicated codes", "js") . "\")\n //-->\n</script>\n"; } if ($ajax) { die; } }
/** * Process labels form data depending on $action. * * @access public * @return void */ public function process() { if (Permission::model()->hasGlobalPermission('labelsets', 'update')) { if (isset($_POST['method']) && get_magic_quotes_gpc()) { $_POST['method'] = stripslashes($_POST['method']); } $action = returnGlobal('action'); Yii::app()->loadHelper('admin/label'); $lid = returnGlobal('lid'); if ($action == "updateset") { updateset($lid); Yii::app()->setFlashMessage(Yii::app()->lang->gT("Label set properties sucessfully updated."), 'success'); } if ($action == "insertlabelset") { $lid = insertlabelset(); } if ($action == "modlabelsetanswers" || $action == "ajaxmodlabelsetanswers") { modlabelsetanswers($lid); } if ($action == "deletelabelset") { if (deletelabelset($lid)) { Yii::app()->setFlashMessage(Yii::app()->lang->gT("Label set sucessfully deleted."), 'success'); $lid = 0; } } if ($lid) { $this->getController()->redirect(array("admin/labels/sa/view/lid/" . $lid)); } else { $this->getController()->redirect(array("admin/labels/sa/view")); } } }
$js_admin_includes[] = 'scripts/labels.js'; if (isset($_POST['sortorder'])) { $postsortorder = sanitize_int($_POST['sortorder']); } if (!isset($action)) { $action = returnglobal('action'); } if (!isset($lid)) { $lid = returnglobal('lid'); } //DO DATABASE UPDATESTUFF if ($action == "updateset") { updateset($lid); } if ($action == "insertlabelset") { $lid = insertlabelset(); } if ($action == "modlabelsetanswers") { modlabelsetanswers($lid); } if ($action == "deletelabelset") { if (deletelabelset($lid)) { $lid = 0; } } if ($action == "importlabels") { include "importlabel.php"; } if ($action == "importlabelresources") { include "import_resources_zip.php"; if (isset($importlabelresourcesoutput)) {
function modlabelsetanswers($lid) { //global $labelsoutput; $clang = Yii::app()->lang; $ajax = false; if (isset($_POST['ajax']) && $_POST['ajax'] == "1") { $ajax = true; } if (!isset($_POST['method'])) { $_POST['method'] = $clang->gT("Save"); } $sPostData = Yii::app()->getRequest()->getPost('dataToSend'); $sPostData = str_replace("\t", '', $sPostData); if (get_magic_quotes_gpc()) { $data = json_decode(stripslashes($sPostData)); } else { $data = json_decode($sPostData); } if ($ajax) { $lid = insertlabelset(); } if (count(array_unique($data->{'codelist'})) == count($data->{'codelist'})) { $query = "DELETE FROM {{labels}} WHERE lid = '{$lid}'"; $result = Yii::app()->db->createCommand($query)->execute(); foreach ($data->{'codelist'} as $index => $codeid) { $codeObj = $data->{$codeid}; $actualcode = $codeObj->{'code'}; //$codeid = dbQuoteAll($codeid,true); $assessmentvalue = (int) $codeObj->{'assessmentvalue'}; foreach ($data->{'langs'} as $lang) { $strTemp = 'text_' . $lang; $title = $codeObj->{$strTemp}; $p = new CHtmlPurifier(); if (Yii::app()->getConfig('filterxsshtml')) { $title = $p->purify($title); } else { $title = html_entity_decode($title, ENT_QUOTES, "UTF-8"); } // Fix bug with FCKEditor saving strange BR types $title = fixCKeditorText($title); $sort_order = $index; $insertdata = array('lid' => $lid, 'code' => $actualcode, 'title' => $title, 'sortorder' => $sort_order, 'assessment_value' => $assessmentvalue, 'language' => $lang); //$query = "INSERT INTO ".db_table_name('labels')." (`lid`,`code`,`title`,`sortorder`, `assessment_value`, `language`) // VALUES('$lid',$actualcode,$title,$sort_order,$assessmentvalue,$lang)"; $result = Yii::app()->db->createCommand()->insert('{{labels}}', $insertdata); } } Yii::app()->session['flashmessage'] = $clang->gT("Labels sucessfully updated"); } else { $labelsoutput = "<script type=\"text/javascript\">\n<!--\n alert(\"" . $clang->gT("Can't update labels because you are using duplicated codes", "js") . "\")\n //-->\n</script>\n"; } if ($ajax) { die; } if (isset($labelsoutput)) { echo $labelsoutput; exit; } }