From 6f6913284fa14128cee1bde2e548349829b5fd90 Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Thu, 24 Nov 2011 17:47:56 +0000 Subject: [PATCH] New feature: Token section workflow improvements by GCI participant Nano8Blazex Dev GCI participants: please update your CI sources git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11475 b72ed6b6-b9f8-46b5-92b4-906544132732 --- application/controllers/admin/tokens.php | 160 ++++++++++-------- application/views/admin/token/browse.php | 50 +++--- .../admin/token/tokendatabaseoptions.php | 20 +++ .../views/admin/token/tokensummary.php | 21 +-- 4 files changed, 140 insertions(+), 111 deletions(-) create mode 100644 application/views/admin/token/tokendatabaseoptions.php diff --git a/application/controllers/admin/tokens.php b/application/controllers/admin/tokens.php index b6e3e056e62..abd8bf0d4af 100644 --- a/application/controllers/admin/tokens.php +++ b/application/controllers/admin/tokens.php @@ -35,7 +35,7 @@ function __construct() /** * Show token index page, handle token database */ - function index($surveyid) + function index($surveyid,$limit=15,$start=0,$order=false,$searchstring=false) { $surveyid = sanitize_int($surveyid); @@ -47,6 +47,7 @@ function index($surveyid) self::_js_admin_includes(base_url()."scripts/admin/tokens.js"); + $this->load->model("tokens_dynamic_model"); $this->load->helper("surveytranslator"); $dateformatdetails=getDateFormatData($this->session->userdata('dateformat')); @@ -58,6 +59,8 @@ function index($surveyid) } $data['surveyprivate'] = $thissurvey['anonymized']; + + // CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY $tokenexists=tableExists('tokens_'.$surveyid); if (!$tokenexists) //If no tokens table exists @@ -70,13 +73,17 @@ function index($surveyid) $data['thissurvey']=$thissurvey; $data['imageurl'] = $this->config->item('imageurl'); $data['surveyid']=$surveyid; - - $this->load->model("tokens_dynamic_model"); $data['queries']=$this->tokens_dynamic_model->tokensSummary($surveyid); + $data['currentpath'] = 'index'; + + // set $data so the browse view can use it + self::_configureBrowsingData($surveyid,$limit,$start,$order,$searchstring, $data); self::_getAdminHeader(); $this->load->view("admin/token/tokenbar",$data); $this->load->view("admin/token/tokensummary",$data); + $this->load->view("admin/token/browse",$data); + $this->load->view("admin/token/tokendatabaseoptions",$data); self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); } } @@ -252,80 +259,24 @@ function bounceprocessing($surveyid) function browse($surveyid,$limit=50,$start=0,$order=false,$searchstring=false) { $surveyid = sanitize_int($surveyid); - $limit = (int) $limit; - $start = (int) $start; $clang=$this->limesurvey_lang; $this->load->model("tokens_dynamic_model"); - $tkcount=$this->tokens_dynamic_model->totalRecords($surveyid); - self::_js_admin_includes(base_url()."scripts/admin/tokens.js"); - //if (!isset($limit)) {$limit=(int)returnglobal('limit');} - //if ($limit==0) $limit=50; - //if (!isset($start)) {$start=(int)returnglobal('start');} - //if (!isset($limit)) {$limit = 100;} - //if (!isset($start)) {$start = 0;} if ($limit > $tkcount) {$limit=$tkcount;} - $next=$start+$limit; - $last=$start-$limit; - $end=$tkcount-$limit; - if ($end < 0) {$end=0;} - if ($last <0) {$last=0;} - if ($next >= $tkcount) {$next=$tkcount-$limit;} - if ($end < 0) {$end=0;} + $baselanguage = GetBaseLanguageFromSurveyID($surveyid); - $data['next']=$next; - $data['last']=$last; - $data['end']=$end; - if(!$order) $order=$this->input->post("order"); - $order=preg_replace('/[^_ a-z0-9-]/i', '',$order); - if ($order=="") {$order = "tid";} - if($this->input->post("limit")) $limit = $this->input->post("limit"); - if($this->input->post("start")) $start = $this->input->post("start"); - //if (!isset($order)) {$order=preg_replace('/[^_ a-z0-9-]/i', '', returnglobal('order'));} - //if (!isset($limit)) {$limit=(int)returnglobal('limit');} - - //ALLOW SELECTION OF NUMBER OF RECORDS SHOWN $thissurvey=getSurveyInfo($surveyid); - if(!$searchstring) $searchstring=$this->input->post("searchstring"); - /*$bquery = "SELECT * FROM ".db_table_name("tokens_$surveyid"); - if ($searchstring) - { - $sSearch=db_quote($searchstring); - $bquery .= " WHERE firstname LIKE '%{$sSearch}%' " - . "OR lastname LIKE '%{$sSearch}%' " - . "OR email LIKE '%{$sSearch}%' " - . "OR emailstatus LIKE '%{$sSearch}%' " - . "OR token LIKE '%{$sSearch}%'"; - } - if (!isset($order) || !$order) {$bquery .= " ORDER BY tid";} - else {$bquery .= " ORDER BY $order"; } - - $bresult = db_select_limit_assoc($bquery, $limit, $start) or safe_die ($clang->gT("Error").": $bquery
".$connect->ErrorMsg());*/ - if($searchstring) - { - $idata = array("firstname"=>$searchstring, - "lastname"=>$searchstring, - "email"=>$searchstring, - "emailstatus"=>$searchstring, - "token"=>$searchstring); - } - else - { - $idata = false; - } - - $data['bresult'] = $this->tokens_dynamic_model->getAllRecords($surveyid,false,$limit,$start,$order,$idata); $data['clang']=$clang; $data['thissurvey']=getSurveyInfo($surveyid); - $data['searchstring']=$searchstring; $data['imageurl'] = $this->config->item('imageurl'); $data['surveyid']=$surveyid; - $data['bgc']=""; - $data['limit']=$limit; - $data['start']=$start; - $data['order']=$order; $data['surveyprivate'] = $data['thissurvey']['anonymized']; + $data['currentpath'] = 'browse'; + + + // set $data so the browse view can use it + self::_configureBrowsingData($surveyid,$limit,$start,$order,$searchstring, $data); self::_getAdminHeader(); $this->load->view("admin/token/tokenbar",$data); @@ -406,7 +357,7 @@ function addnew($surveyid) $data['success']=false; } - $data['clang']=$clang; + /*$data['clang']=$clang; $thissurvey=getSurveyInfo($surveyid); $data['thissurvey']=$thissurvey; $data['imageurl'] = $this->config->item('imageurl'); @@ -415,8 +366,21 @@ function addnew($surveyid) self::_getAdminHeader(); $this->load->view("admin/token/tokenbar",$data); - $this->load->view("admin/token/addtokenpost",$data); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + //$this->load->view("admin/token/addtokenpost",$data); + self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));*/ + + // instead of going to success page, go back to new token page and have popup instead + if ($data['success']==true) { + $sTokenName = $data['firstname'] . " " . $data['lastname']; + if (($sTokenName == " ")||($sTokenName == "")) { + $sTokenName = $clang->gT("-------"); + } + $sFlashMessage = "" . $clang->gT("Success") . "
" . $clang->gT("New token was added.") . "
[" . $clang->gT("Name") . ": " . $sTokenName . "]"; + } else { + $sFlashMessage = $clang->gT("Failed") . $clang->gT("There is already an entry with that exact token in the table. The same token cannot be used in multiple entries."); + } + $this->session->set_userdata('flashmessage', $sFlashMessage); + self::_handletokenform($surveyid,"addnew"); } else { @@ -1736,4 +1700,64 @@ function _newtokentable($surveyid) return; } } + + /** + * Configure data for browsing + * to avoid repetitive code, Used in index() and browse() + */ + function _configureBrowsingData($surveyid,$limit,$start,$order,$searchstring, &$data) + { + $limit = (int) $limit; // for browsing + $start = (int) $start; // for browsing + + /* Browsing data*/ + $tkcount=$this->tokens_dynamic_model->totalRecords($surveyid); + + //if (!isset($limit)) {$limit=(int)returnglobal('limit');} + //if ($limit==0) $limit=50; + //if (!isset($start)) {$start=(int)returnglobal('start');} + //if (!isset($limit)) {$limit = 100;} + //if (!isset($start)) {$start = 0;} if ($limit > $tkcount) {$limit=$tkcount;} + $next=$start+$limit; + $last=$start-$limit; + $end=$tkcount-$limit; + if ($end < 0) {$end=0;} + if ($last <0) {$last=0;} + if ($next >= $tkcount) {$next=$tkcount-$limit;} + if ($end < 0) {$end=0;} + + $data['next']=$next; + $data['last']=$last; + $data['end']=$end; + + if(!$order) $order=$this->input->post("order"); + $order=preg_replace('/[^_ a-z0-9-]/i', '',$order); + if ($order=="") {$order = "tid";} + + if($this->input->post("limit")) $limit = $this->input->post("limit"); + if($this->input->post("start")) $start = $this->input->post("start"); + + //ALLOW SELECTION OF NUMBER OF RECORDS SHOWN + if(!$searchstring) $searchstring=$this->input->post("searchstring"); + if($searchstring) + { + $idata = array("firstname"=>$searchstring, + "lastname"=>$searchstring, + "email"=>$searchstring, + "emailstatus"=>$searchstring, + "token"=>$searchstring); +} + else + { + $idata = false; + } + + /*browsing*/ + $data['bresult'] = $this->tokens_dynamic_model->getAllRecords($surveyid,false,$limit,$start,$order,$idata); + $data['searchstring']=$searchstring; + $data['bgc']=""; + $data['limit']=$limit; + $data['start']=$start; + $data['order']=$order; + } } diff --git a/application/views/admin/token/browse.php b/application/views/admin/token/browse.php index 47be44bb026..975364896cc 100644 --- a/application/views/admin/token/browse.php +++ b/application/views/admin/token/browse.php @@ -1,3 +1,4 @@ + @@ -17,29 +18,31 @@ <?php $clang->eT("Bounce processing");?> - - + <?php $clang->eT("Show start...");?> - <?php $clang->eT("Show previous...");?> - <?php $clang->eT("Show next...");?> - <?php $clang->eT("Show last...");?> -
+ ' />
-
+   @@ -58,66 +61,66 @@ - + <?php $clang->eT("Sort by: ");?>IDID eT("Actions");?> - + <?php $clang->eT("Sort by: ").$clang->gT("First name");?> eT("First name");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Last name");?> eT("Last name");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Email address");?> eT("Email address");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Email status");?> eT("Email status");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Token");?> eT("Token");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Language");?> eT("Language");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Invitation sent?");?> eT("Invitation sent?");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Reminder sent?");?> eT("Reminder sent?");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Reminder count");?> eT("Reminder count");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Completed?");?> eT("Completed?");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Uses left");?> eT("Uses left");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Valid from");?> eT("Valid from");?> - + <?php $clang->eT("Sort by: ").$clang->gT("Valid until");?> eT("Valid until");?> @@ -125,7 +128,7 @@ foreach ($attrfieldnames as $attr_name=>$attr_translation) { echo "" - ."" + ."" ."".htmlspecialchars($attr_translation,ENT_QUOTES,'utf-8')."\n"; } ?> @@ -364,4 +367,5 @@ function sendPost(myaction,checkcode,arrayparam,arrayval)

- \ No newline at end of file + +
diff --git a/application/views/admin/token/tokendatabaseoptions.php b/application/views/admin/token/tokendatabaseoptions.php new file mode 100644 index 00000000000..d1a245c62a7 --- /dev/null +++ b/application/views/admin/token/tokendatabaseoptions.php @@ -0,0 +1,20 @@ + + +
gT("Token database administration options");?>
+
+ +
+ diff --git a/application/views/admin/token/tokensummary.php b/application/views/admin/token/tokensummary.php index e6aedd401df..c8eb2025e0c 100644 --- a/application/views/admin/token/tokensummary.php +++ b/application/views/admin/token/tokensummary.php @@ -45,23 +45,4 @@
- - -
gT("Token database administration options");?>
-
- -
- \ No newline at end of file +