From 658ecb4a73b1308c09a13a1eee3ae5583bbb0712 Mon Sep 17 00:00:00 2001 From: louis Date: Thu, 24 Sep 2015 12:49:35 +0200 Subject: [PATCH] Dev: tokens display --- application/controllers/admin/tokens.php | 46 ++- application/core/Survey_Common_Action.php | 1 - application/views/admin/assessments_view.php | 203 ++++++----- application/views/admin/super/messagebox.php | 22 +- .../views/admin/survey/surveybar_view.php | 324 +++++++++--------- .../views/admin/token/addtokenpost.php | 54 ++- application/views/admin/token/bounce.php | 10 +- application/views/admin/token/csvpost.php | 179 ++++++---- application/views/admin/token/csvupload.php | 147 +++++--- .../views/admin/token/dummytokenform.php | 160 +++++---- .../views/admin/token/exportdialog.php | 26 +- application/views/admin/token/import.php | 26 +- application/views/admin/token/invite.php | 172 +++++----- application/views/admin/token/ldapform.php | 135 +++++--- application/views/admin/token/ldappost.php | 85 +++-- .../admin/token/managetokenattributes.php | 261 +++++++------- application/views/admin/token/remind.php | 187 +++++----- application/views/admin/token/token_bar.php | 30 +- application/views/admin/token/tokenform.php | 4 - 19 files changed, 1193 insertions(+), 879 deletions(-) diff --git a/application/controllers/admin/tokens.php b/application/controllers/admin/tokens.php index f18972f03bb..9f8bec4fac1 100644 --- a/application/controllers/admin/tokens.php +++ b/application/controllers/admin/tokens.php @@ -635,7 +635,6 @@ function editToken($iSurveyId) */ function addnew($iSurveyId) { - // CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY $iSurveyId = sanitize_int($iSurveyId); if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'create')) @@ -643,6 +642,7 @@ function addnew($iSurveyId) Yii::app()->session['flashmessage'] = gT("You do not have sufficient rights to access this page."); $this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}")); } + $bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}'); if (!$bTokenExists) //If no tokens table exists { @@ -729,6 +729,8 @@ function addnew($iSurveyId) $aData['thissurvey'] = getSurveyInfo($iSurveyId); $aData['surveyid'] = $iSurveyId; + + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'addtokenpost'), $aData); } @@ -819,19 +821,21 @@ function edit($iSurveyId, $iTokenId) foreach ($aTokenData as $k => $v) $token->$k = $v; $token->save(); - + + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => gT("Success"), 'message' => gT("The token entry was successfully updated.") . "

\n" - . "\t\tgetController()->createUrl("admin/tokens/sa/browse/surveyid/$iSurveyId/") . "', '_top')\" />\n" + . "\t\tgetController()->createUrl("admin/tokens/sa/browse/surveyid/$iSurveyId/") . "', '_top')\" />\n" )), $aData); } else { + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => gT("Failed"), 'message' => gT("There is already an entry with that exact token in the table. The same token cannot be used in multiple entries.") . "

\n" - . "\t\tgetController()->createUrl("admin/tokens/sa/edit/surveyid/$iSurveyId/tokenid/$iTokenId") . "', '_top')\" />\n" + . "\t\tgetController()->createUrl("admin/tokens/sa/edit/surveyid/$iSurveyId/tokenid/$iTokenId") . "', '_top')\" />\n" ))); } } @@ -1161,14 +1165,15 @@ function deletetokenattributes($iSurveyId) } elseif ($confirm!='confirm' && $sAttributeToDelete) { + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => sprintf(gT("Delete token attribute %s"),$sAttributeToDelete), 'message' => "

".gT("If you remove this attribute, you will lose all information.") . "

\n" . CHtml::form(array("admin/tokens/sa/deletetokenattributes/surveyid/{$iSurveyId}"), 'post',array('id'=>'attributenumber')) . CHtml::hiddenField('deleteattribute',$sAttributeToDelete) . CHtml::hiddenField('sid',$iSurveyId) - . CHtml::htmlButton(gT('Delete attribute'),array('type'=>'submit','value'=>'confirm','name'=>'confirm')) - . CHtml::htmlButton(gT('Cancel'),array('type'=>'submit','value'=>'cancel','name'=>'cancel')) + . CHtml::htmlButton(gT('Delete attribute'),array('type'=>'submit','value'=>'confirm','name'=>'confirm', 'class'=>'btn btn-default btn-lg')) + . CHtml::htmlButton(gT('Cancel'),array('type'=>'submit','value'=>'cancel','name'=>'cancel', 'class'=>'btn btn-default btn-lg')) . CHtml::endForm() )), $aData); } @@ -1237,9 +1242,10 @@ function updatetokenattributedescriptions($iSurveyId) } $aData['thissurvey'] = getSurveyInfo($iSurveyId); $aData['surveyid'] = $iSurveyId; + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => gT('Token attribute descriptions were successfully updated.'), - 'message' => "
getController()->createUrl("/admin/tokens/sa/managetokenattributes/surveyid/$iSurveyId") . "', '_top')\" />" + 'message' => "
getController()->createUrl("/admin/tokens/sa/managetokenattributes/surveyid/$iSurveyId") . "', '_top')\" />" )), $aData); } @@ -1589,6 +1595,7 @@ function email($iSurveyId, $tokenids = null) } else { + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => gT("Warning"), 'message' => gT("There were no eligible emails to send. This will be because none satisfied the criteria of:") @@ -1603,9 +1610,15 @@ function email($iSurveyId, $tokenids = null) /** * Export Dialog + * */ function exportdialog($iSurveyId) { + $aData["surveyinfo"] = $surveyinfo; + $aData['title_bar']['title'] = $surveyinfo['surveyls_title']."(".gT("ID").":".$iSurveyId.")"; + $aData['sidebar']["token_menu"]=TRUE; + $aData['token_bar']['closebutton']['url'] = 'admin/tokens/sa/index/surveyid/'.$iSurveyId; + // CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY $iSurveyId = sanitize_int($iSurveyId); if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'export'))//EXPORT FEATURE SUBMITTED BY PIETERJAN HEYSE @@ -2314,12 +2327,13 @@ function tokenify($iSurveyId) if (!Yii::app()->request->getParam('ok')) { + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => gT("Create tokens"), 'message' => gT("Clicking 'Yes' will generate tokens for all those in this token list that have not been issued one. Continue?") . "

\n" - . "getController()->createUrl("admin/tokens/sa/tokenify/surveyid/$iSurveyId", array('ok'=>'Y'))) . "\" />\n" - . "getController()->createUrl("admin/tokens/sa/index/surveyid/$iSurveyId") . "', '_top')\" />\n" . "
\n" )), $aData); @@ -2376,13 +2390,14 @@ function kill($iSurveyId) $newtableDisplay = Yii::app()->db->tablePrefix . $newtable; if (!Yii::app()->request->getQuery('ok')) { + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => gT("Delete Tokens Table"), 'message' => gT("If you delete this table tokens will no longer be required to access this survey.") . "
" . gT("A backup of this table will be made if you proceed. Your system administrator will be able to access this table.") . "
\n" . sprintf('("%s")

', $newtableDisplay) - . "getController()->createUrl("admin/tokens/sa/kill/surveyid/{$iSurveyId}/ok/Y") . "', '_top')\" />\n" - . "getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n" )), $aData); } @@ -2394,11 +2409,12 @@ function kill($iSurveyId) //Remove any survey_links to the CPDB SurveyLink::model()->deleteLinksBySurvey($iSurveyId); + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array( 'message' => array( 'title' => gT("Delete Tokens Table"), 'message' => '
' . gT("The tokens table has now been removed and tokens are no longer required to access this survey.") . "
" . gT("A backup of this table has been made and can be accessed by your system administrator.") . "
\n" . sprintf('("%s")

', $newtableDisplay) - . "getController()->createUrl("admin/survey/sa/view/surveyid/".$iSurveyId) . "', '_top')\" />" )), $aData); @@ -2534,11 +2550,12 @@ function _newtokentable($iSurveyId) if (Yii::app()->request->getQuery('createtable') == "Y") { Token::createTable($iSurveyId); + $aData['sidebar']['state'] = "close"; LimeExpressionManager::SetDirtyFlag(); // LimeExpressionManager needs to know about the new token table $this->_renderWrappedTemplate('token', array('message' =>array( 'title' => gT("Token control"), 'message' => gT("A token table has been created for this survey.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_$iSurveyId\")

\n" - . "getController()->createUrl("admin/tokens/sa/index/surveyid/$iSurveyId") . "', '_top')\" />\n" ))); } @@ -2576,10 +2593,11 @@ function _newtokentable($iSurveyId) //Add any survey_links from the renamed table SurveyLink::model()->rebuildLinksFromTokenTable($iSurveyId); + $aData['sidebar']['state'] = "close"; $this->_renderWrappedTemplate('token', array('message' => array( 'title' => gT("Import old tokens"), 'message' => gT("A token table has been created for this survey and the old tokens were imported.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_$iSurveyId" . "\")

\n" - . "getController()->createUrl("admin/tokens/sa/index/surveyid/$iSurveyId") . "', '_top')\" />\n" ))); diff --git a/application/core/Survey_Common_Action.php b/application/core/Survey_Common_Action.php index d034b582898..7edf52427ba 100644 --- a/application/core/Survey_Common_Action.php +++ b/application/core/Survey_Common_Action.php @@ -27,7 +27,6 @@ class Survey_Common_Action extends CAction public function __construct($controller, $id) { parent::__construct($controller, $id); - // Make sure viewHelper can be autoloaded Yii::import('application.helpers.viewHelper'); } diff --git a/application/views/admin/assessments_view.php b/application/views/admin/assessments_view.php index c4c33f4d8a4..1f0cfc01434 100644 --- a/application/views/admin/assessments_view.php +++ b/application/views/admin/assessments_view.php @@ -1,3 +1,9 @@ +