function showTranslateGroup($gid, $message = "")
 {
     $survey = new Survey($_SESSION['SUID']);
     $group = $survey->getGroup($gid);
     $returnStr = $this->showGroupHeader($survey, $group, Language::headerTranslateGroup(), $message);
     if ($_SESSION['VRFILTERMODE_GROUP'] == 2) {
         $returnStr .= $this->showTranslateGroupLayout($group);
     } elseif ($_SESSION['VRFILTERMODE_GROUP'] == 3) {
         $returnStr .= $this->showTranslateGroupAssistance($group);
     } else {
         $returnStr .= $this->showTranslateGroupLayout($group);
     }
     //$returnStr .= '<div style="min-height: 50px;"></div>';
     $returnStr .= $this->showGroupFooter($survey);
     return $returnStr;
 }
 function showToolsBatchEditorGroups($variablecookievalue, $sectioncookievalue, $groupcookievalue, $typecookievalue)
 {
     $returnStr = $this->getToolsBatchEditorTopTab(2, $variablecookievalue != "", $sectioncookievalue != "", $groupcookievalue != "", $typecookievalue != "");
     $returnStr .= "<form method='post' id='reload' name='reload'>";
     $returnStr .= setSessionParamsPost(array('page' => 'sysadmin.tools.batcheditor'));
     $returnStr .= "</form>";
     $returnStr .= '<form id=actionform name=actionform method="post">';
     $returnStr .= setSessionParamsPost(array('page' => 'sysadmin.tools.batcheditorres'));
     $returnStr .= "<input type=hidden name=batchaction id=batchaction />";
     $returnStr .= "<input type=hidden name=vrfiltermode_batch id=vrfiltermode_batch value=2 />";
     $returnStr .= '<div class="well">';
     $groups = explode("-", $groupcookievalue);
     $returnStr1 = '';
     foreach ($groups as $group) {
         $varsplit = explode("~", $group);
         $survey = new Survey($varsplit[0]);
         $v = $survey->getGroup($varsplit[1]);
         if ($v->getName() != "") {
             $returnStr1 .= '<tr>';
             $returnStr1 .= '<td>';
             $returnStr1 .= "<input class='selectedgroupbox' name=selected[] type='checkbox' value='" . $group . "'>";
             $returnStr1 .= '</td>';
             $returnStr1 .= '<td>' . $v->getName() . '</td>';
             $returnStr1 .= '<tr>';
         }
     }
     if ($returnStr1 == "") {
         $returnStr .= $this->displayInfo(Language::messageToolsBatchEditorNoGroupsFound());
     } else {
         $returnStr .= $this->displayComboBox();
         $returnStr .= '<div class="row row-offcanvas row-offcanvas-right">
                      <div class="col-xs-6 col-md-3">';
         $returnStr .= '<span class="label label-default">' . Language::labelToolsBatchEditorGroups() . '</span>';
         $returnStr .= '<div style="background-color: white;" class="well">';
         $returnStr .= '<table class="table table-bordered table-striped">';
         $returnStr .= '<tr>';
         $returnStr .= "<th><nobr/></th>";
         $returnStr .= "<th>" . Language::labelTypeEditGeneralName() . "</th>";
         $returnStr .= '</tr>';
         $returnStr .= $returnStr1;
         $returnStr .= '</table>';
         $returnStr .= $this->displayCookieScripts();
         // TODO: ADD PAGE RELOAD HERE
         $returnStr .= "<script type=text/javascript>\n                           function selectAllGroup() {\n                            \$('.selectedgroupbox').prop('checked', true);\n                           };\n                           function unselectAllGroup() {\n                            \$('.selectedgroupbox').prop('checked', false);\n                           };\n                           </script>";
         $returnStr .= "<input class='btn btn-default' type=button onclick='selectAllGroup();' value='Select all'/>";
         $returnStr .= "<input class='btn btn-default' type=button onclick='unselectAllGroup();' value='Unselect all'/>";
         $returnStr .= "<input class='btn btn-default' type=button onclick='clearCookie(\"uscicgroupcookie\"); \$(\"#reload\").submit();' value='" . Language::buttonClear() . "'/>";
         $returnStr .= "</div>";
         $returnStr .= '</div>';
         // actions
         $returnStr .= '<div class="col-xs-12 col-md-9">';
         $returnStr .= '<span class="label label-default">' . Language::labelToolsBatchEditorActions() . '</span>';
         $returnStr .= '<div style="background-color: white;" class="well">';
         $returnStr .= '<span class="label label-default">' . Language::labelEdit() . '</span>';
         $returnStr .= '<div class="well">';
         $returnStr .= '<ul class="nav nav-pills nav-justified" role="tablist">';
         $returnStr .= '<li class="active"><a href="#general" role="tab" data-toggle="tab">' . Language::labelGeneral() . '</a></li>';
         $returnStr .= '<li><a href="#access" role="tab" data-toggle="tab">' . Language::labelAccess() . '</a></li>';
         $returnStr .= '<li><a href="#verification" role="tab" data-toggle="tab">' . Language::labelVerification() . '</a></li>';
         $returnStr .= '<li><a href="#display" role="tab" data-toggle="tab">' . Language::labelLayout() . '</a></li>';
         $returnStr .= '<li><a href="#assistance" role="tab" data-toggle="tab">' . Language::labelAssistance() . '</a></li>';
         $returnStr .= '<li><a href="#navigation" role="tab" data-toggle="tab">' . Language::labelNavigation() . '</a></li>';
         $returnStr .= '</ul>';
         $returnStr .= $this->showToolsBatchEditorGroupTabs(1);
         $returnStr .= '</div>';
         $returnStr .= '<span class="label label-default">' . Language::labelCopy() . '</span>';
         $returnStr .= '<div class="well">';
         $returnStr .= '<table width=100%>';
         $surveys = new Surveys();
         $suid = loadvar("suid");
         if ($suid == "") {
             $suid = $_SESSION['SUID'];
             if ($suid == "") {
                 $suid = $surveys->getFirstSurvey(false);
             }
         }
         if ($surveys->getNumberOfSurveys() > 1) {
             $returnStr .= '<tr><td>' . Language::labelTypeCopySurvey() . '</td><td>' . $this->displaySurveys("suid", "suid", $suid) . '</tr>';
         }
         $returnStr .= '</table>';
         $returnStr .= '<input onclick="$(\'#batchaction\').val(\'copy\'); $(\'#actionform\').submit(); " type="button" class="btn btn-default" value="' . Language::buttonCopy() . '"/>';
         $returnStr .= '</div>';
         if ($surveys->getNumberOfSurveys() > 1) {
             $returnStr .= '<span class="label label-default">' . Language::labelMove() . '</span>';
             $returnStr .= '<div class="well">';
             $returnStr .= '<table width=100%>';
             $returnStr .= '<tr><td>' . Language::labelTypeMoveSurvey() . '</td><td>' . $this->displaySurveys("suid", "suid", $_SESSION['SUID']) . '</tr>';
             $returnStr .= '</table>';
             $returnStr .= '<input onclick="$(\'#batchaction\').val(\'move\'); $(\'#actionform\').submit(); " type="button" class="btn btn-default" value="' . Language::buttonMove() . '"/>';
             $returnStr .= '</div>';
         }
         $returnStr .= '<span class="label label-default">' . Language::labelRemove() . '</span>';
         $returnStr .= '<div class="well">';
         $returnStr .= '<input onclick="$(\'#batchaction\').val(\'remove\'); $(\'#actionform\').submit(); " type="button" class="btn btn-default" value="' . Language::buttonRemove() . '"/>';
         $returnStr .= '</div>';
         $returnStr .= '</div>';
         // close
         $returnStr .= '</div>';
         $returnStr .= '</div>';
     }
     $returnStr .= '</div>';
     $returnStr .= '</form>';
     return $returnStr;
 }
Beispiel #3
0
 function handleGroupAction($selected, $action, &$groupcookievalue)
 {
     $surveys = array();
     $displaySysAdmin = new DisplaySysAdmin();
     switch ($action) {
         case 'edit':
             $settings = $this->getBatchEditorGroupProperties();
             $tosave = array();
             $tocompile = array();
             $changed = array();
             foreach ($settings as $set) {
                 if (loadvar($set . "_checkbox") == 1) {
                     $val = loadvarAllowHTML($set);
                     if ($val != "") {
                         foreach ($selected as $sel) {
                             $s = explode("~", $sel);
                             if (isset($surveys[$s[0]])) {
                                 $survey = $surveys[$s[0]];
                             } else {
                                 $survey = new Survey($s[0]);
                                 $surveys[$s[0]] = $survey;
                                 $tocompile[] = $s[0];
                             }
                             if (isset($tosave[$sel])) {
                                 $group = $tosave[$sel];
                             } else {
                                 $group = $survey->getGroup($s[1]);
                                 $tosave[$sel] = $group;
                             }
                             if (isset($changed[$s[0]])) {
                                 $arr = $changed[$s[0]];
                                 if (isset($arr[$sel]) == false) {
                                     $arr[$sel] = $group;
                                     $changed[$s[0]] = $arr;
                                 }
                             } else {
                                 $arr = array();
                                 $arr[$sel] = $group;
                                 $changed[$s[0]] = $arr;
                             }
                             $group->setSettingValue($set, $val);
                             if ($set == SETTING_GROUP_TEMPLATE && $val == TABLE_TEMPLATE_CUSTOM) {
                                 $group->setSettingValue(SETTING_GROUP_CUSTOM_TEMPLATE, loadvarAllowHTML(SETTING_GROUP_CUSTOM_TEMPLATE));
                             }
                         }
                     }
                 }
             }
             /* save */
             foreach ($tosave as $to) {
                 $to->save();
             }
             /* compile */
             foreach ($tocompile as $comp) {
                 if (isset($surveys[$comp])) {
                     $survey = $surveys[$comp];
                 } else {
                     $survey = new Survey($comp);
                     $surveys[$comp] = $survey;
                 }
                 $compiler = new Compiler($comp, getSurveyVersion($surveys[$comp]));
                 $mess = $compiler->generateGroups($changed[$comp]);
                 $mess = $compiler->generateGetFillsGroups($changed[$comp]);
                 $mess = $compiler->generateInlineFieldsGroups($changed[$comp]);
             }
             if ($changed) {
                 $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorEdited(Language::labelGroupsLower()));
             } else {
                 $content = $displaySysAdmin->displayWarning(Language::messageToolsBatchEditorNotEdited());
             }
             break;
             break;
         case 'copy':
             // determine survey
             $suid = loadvar('suid');
             foreach ($selected as $sel) {
                 $s = explode("~", $sel);
                 if (isset($surveys[$s[0]])) {
                     $survey = $surveys[$s[0]];
                 } else {
                     $survey = new Survey($s[0]);
                     $surveys[$s[0]] = $survey;
                 }
                 $group = $survey->getGroup($s[1]);
                 $oldgroup = $group;
                 $group->copy($suid);
                 $newgroups[] = $group;
             }
             /* compile new */
             $compiler = new Compiler($suid, getSurveyVersion($survey));
             $mess = $compiler->generateGroups($newgroups);
             $mess = $compiler->generateGetFillsGroups($newgroups);
             $mess = $compiler->generateInlineFieldsGroups($newgroups);
             $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorCopied(Language::labelGroupsLower()));
             break;
         case 'move':
             $tocompile = array();
             $moved = array();
             $newgroups = array();
             // determine survey
             $suid = loadvar('suid');
             $cookiearr = explode("-", $groupcookievalue);
             foreach ($selected as $sel) {
                 $s = explode("~", $sel);
                 if (isset($surveys[$s[0]])) {
                     $survey = $surveys[$s[0]];
                 } else {
                     $survey = new Survey($s[0]);
                     $surveys[$s[0]] = $survey;
                     $tocompile[] = $s[0];
                 }
                 $group = $survey->getGroup($s[1]);
                 $oldgroup = $group;
                 $group->move($suid);
                 if (isset($moved[$s[0]])) {
                     $arr = $moved[$s[0]];
                 } else {
                     $arr = array();
                 }
                 $arr[] = $oldgroup;
                 $moved[$s[0]] = $arr;
                 $newgroups[] = $group;
                 /* update cookie */
                 $ind = array_search($sel, $cookiearr);
                 $cookiearr[$ind] = $group->getSuid() . '~' . $group->getGid();
             }
             /* update cookie */
             setcookie('uscicgroupcookie', implode("-", $cookiearr));
             //implode("-", $arr));
             $groupcookievalue = implode("-", $cookiearr);
             /* compile old */
             foreach ($tocompile as $comp) {
                 if (isset($surveys[$comp])) {
                     $survey = $surveys[$comp];
                 } else {
                     $survey = new Survey($comp);
                     $surveys[$comp] = $survey;
                 }
                 /* we moved across survey for one or more groups in this survey */
                 if ($suid != $comp) {
                     $compiler = new Compiler($comp, getSurveyVersion($surveys[$comp]));
                     $mess = $compiler->generateGroups($moved[$comp], true);
                 }
             }
             /* compile new */
             $compiler = new Compiler($suid, getSurveyVersion($survey));
             $mess = $compiler->generateGroups($newgroups);
             $mess = $compiler->generateGetFillsGroups($newgroups);
             $mess = $compiler->generateInlineFieldsGroups($newgroups);
             $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorMoved(Language::labelGroupsLower()));
             break;
         case 'remove':
             $removed = array();
             $cookiearr = explode("-", $groupcookievalue);
             foreach ($selected as $sel) {
                 $s = explode("~", $sel);
                 if (isset($surveys[$s[0]])) {
                     $survey = $surveys[$s[0]];
                 } else {
                     $survey = new Survey($s[0]);
                     $surveys[$s[0]] = $survey;
                 }
                 $group = $survey->getGroup($s[1]);
                 $group->remove();
                 $removed[] = $group;
                 /* update cookie */
                 $ind = array_search($sel, $cookiearr);
                 unset($cookiearr[$ind]);
             }
             /* update cookie */
             setcookie('uscicgroupcookie', implode("-", $cookiearr));
             //implode("-", $arr));
             $groupcookievalue = implode("-", $cookiearr);
             /* compile */
             foreach ($surveys as $survey) {
                 $compiler = new Compiler($survey->getSuid(), getSurveyVersion($survey));
                 $mess = $compiler->generateGroups($removed, true);
             }
             $content = $displaySysAdmin->displaySuccess(Language::messageToolsBatchEditorRemoved(Language::labelGroupsLower()));
             break;
         default:
             $content = $displaySysAdmin->displayWarning(Language::messageToolsBatchEditorUnrecognizedAction());
             break;
     }
     return $content;
 }
Beispiel #4
0
 function showTranslateGroupAssistanceRes()
 {
     $displayTranslator = new DisplayTranslator();
     $survey = new Survey($_SESSION['SUID']);
     $gid = getFromSessionParams('gid');
     $group = $survey->getGroup($gid);
     $_SESSION['GID'] = $gid;
     $group->setEmptyMessage(loadvarAllowHTML(SETTING_EMPTY_MESSAGE));
     $group->setErrorMessageExactRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_EXACT_REQUIRED));
     $group->setErrorMessageMinimumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MINIMUM_REQUIRED));
     $group->setErrorMessageMaximumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MAXIMUM_REQUIRED));
     $group->setErrorMessageExclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_EXCLUSIVE));
     $group->setErrorMessageInclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INCLUSIVE));
     $group->SetErrorMessageUniqueRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_UNIQUE_REQUIRED));
     $content = $displayTranslator->displaySuccess(Language::messageGroupChanged($group->getName()));
     $group->save();
     /* compile */
     $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey));
     $mess = $compiler->generateGroups(array($group));
     $mess = $compiler->generateGetFillsGroups(array($group));
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     /* return result */
     return $displayTranslator->showTranslateGroup($_SESSION['GID'], $content);
 }