"> <img src='<?php echo $imageurl; ?> cpdb.png' alt='<?php $clang->eT("Central participant database/panel"); ?> ' /> </a> <img src='<?php echo $imageurl; ?> separator.gif' class='separator' alt='' /> <?php } if (hasSurveyPermission($surveyid, 'surveyactivation', 'update') || HasSurveyPermission($surveyid, 'tokens', 'delete')) { ?> <a href="<?php echo $this->createUrl("admin/tokens/sa/kill/surveyid/{$surveyid}"); ?> "> <img src='<?php echo $imageurl; ?> delete.png' alt='<?php $clang->eT("Delete tokens table"); ?> ' /> </a> <?php }
<?php } else { $clang->eT("You don't have the permission to activate tokens."); ?> <input type='submit' value='<?php $clang->eT("Back to main menu"); ?> ' onclick="window.open('<?php echo $this->createUrl("admin/survey/sa/view/surveyid/{$surveyid}"); ?> ', '_top')" /></div> <?php } // Do not offer old postgres token tables for restore since these are having an issue with missing index if ($tcount > 0 && (hasSurveyPermission($surveyid, 'surveysettings', 'update') || HasSurveyPermission($surveyid, 'tokens', 'create'))) { ?> <br /><div class='header ui-widget-header'><?php $clang->eT("Restore options"); ?> </div> <div class='messagebox ui-corner-all'> <?php echo CHtml::form(array("admin/tokens/sa/index/surveyid/{$surveyid}"), 'post'); ?> <?php $clang->eT("The following old token tables could be restored:"); ?> <br /><br /> <select size='4' name='oldtable' style='width:250px;'> <?php
/** * Show dialogs and create a new tokens table */ function _newtokentable($iSurveyId) { $clang = $this->getController()->lang; $aSurveyInfo = getSurveyInfo($iSurveyId); if (!hasSurveyPermission($iSurveyId, 'surveysettings', 'update') && !HasSurveyPermission($iSurveyId, 'tokens', 'create')) { Yii::app()->session['flashmessage'] = $clang->gT("Tokens have not been initialised for this survey."); $this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}")); } $bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}'); if ($bTokenExists) { Yii::app()->session['flashmessage'] = $clang->gT("Tokens already exist for this survey."); $this->getController()->redirect($this->getController()->createUrl("/admin/survey/sa/view/surveyid/{$iSurveyId}")); } // The user have rigth to create token, then don't test right after Yii::import('application.helpers.admin.token_helper', true); if (Yii::app()->request->getQuery('createtable') == "Y") { createTokenTable($iSurveyId); $this->_renderWrappedTemplate('token', array('message' => array('title' => $clang->gT("Token control"), 'message' => $clang->gT("A token table has been created for this survey.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_{$iSurveyId}\")<br /><br />\n" . "<input type='submit' value='" . $clang->gT("Continue") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n"))); } elseif (returnGlobal('restoretable') == "Y" && Yii::app()->request->getPost('oldtable')) { //Rebuild attributedescription value for the surveys table $table = Yii::app()->db->schema->getTable(Yii::app()->request->getPost('oldtable')); $fields = array_filter(array_keys($table->columns), 'filterForAttributes'); $fieldcontents = $aSurveyInfo['attributedescriptions']; if (!is_array($fieldcontents)) { $fieldcontents = array(); } foreach ($fields as $fieldname) { $name = $fieldname; if ($fieldname[10] == 'c') { //This belongs to a cpdb attribute $cpdbattid = substr($fieldname, 15); $data = ParticipantAttributeNames::model()->getAttributeName($cpdbattid, Yii::app()->session['adminlang']); $name = $data['attribute_name']; } if (!isset($fieldcontents[$fieldname])) { $fieldcontents[$fieldname] = array('description' => $name, 'mandatory' => 'N', 'show_register' => 'N'); } } Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => serialize($fieldcontents))); Yii::app()->db->createCommand()->renameTable(Yii::app()->request->getPost('oldtable'), Yii::app()->db->tablePrefix . "tokens_" . intval($iSurveyId)); //Check that the tokens table has the required fields Tokens_dynamic::model($iSurveyId)->checkColumns(); //Add any survey_links from the renamed table Survey_links::model()->rebuildLinksFromTokenTable($iSurveyId); $this->_renderWrappedTemplate('token', array('message' => array('title' => $clang->gT("Import old tokens"), 'message' => $clang->gT("A token table has been created for this survey and the old tokens were imported.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_{$iSurveyId}" . "\")<br /><br />\n" . "<input type='submit' value='" . $clang->gT("Continue") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n"))); LimeExpressionManager::SetDirtyFlag(); // so that knows that token tables have changed } else { $this->getController()->loadHelper('database'); $result = Yii::app()->db->createCommand(dbSelectTablesLike("{{old_tokens_" . intval($iSurveyId) . "_%}}"))->queryAll(); $tcount = count($result); if ($tcount > 0) { foreach ($result as $rows) { $oldlist[] = reset($rows); } $aData['oldlist'] = $oldlist; } $thissurvey = getSurveyInfo($iSurveyId); $aData['thissurvey'] = $thissurvey; $aData['surveyid'] = $iSurveyId; $aData['tcount'] = $tcount; $aData['databasetype'] = Yii::app()->db->getDriverName(); $this->_renderWrappedTemplate('token', 'tokenwarning', $aData); } }
<?php } else { $clang->eT("You don't have the permission to activate tokens."); ?> <input type='submit' value='<?php $clang->eT("Back to main menu"); ?> ' onclick="window.open('<?php echo $this->createUrl("admin/survey/sa/view/surveyid/{$surveyid}"); ?> ', '_top')" /></div> <?php } // Do not offer old postgres token tables for restore since these are having an issue with missing index if ($tcount > 0 && $databasetype != 'pgsql' && (hasSurveyPermission($surveyid, 'surveyactivation', 'update') || HasSurveyPermission($surveyid, 'tokens', 'delete'))) { ?> <br /><div class='header ui-widget-header'><?php $clang->eT("Restore options"); ?> </div> <div class='messagebox ui-corner-all'> <?php echo CHtml::form(array("admin/tokens/sa/index/surveyid/{$surveyid}"), 'post'); ?> <?php $clang->eT("The following old token tables could be restored:"); ?> <br /><br /> <select size='4' name='oldtable' style='width:250px;'> <?php
echo $imageurl; ?> cpdb.png' alt='<?php $clang->eT("Central participant database/panel"); ?> ' /> </a> <img src='<?php echo $imageurl; ?> separator.gif' class='separator' alt='' /> <?php } ?> <?php if (hasSurveyPermission($surveyid, 'surveysettings', 'update') || HasSurveyPermission($surveyid, 'tokens', 'delete')) { ?> <a href="<?php echo $this->createUrl("admin/tokens/sa/kill/surveyid/{$surveyid}"); ?> "> <img src='<?php echo $imageurl; ?> delete.png' alt='<?php $clang->eT("Delete tokens table"); ?> ' /> </a> <?php }