From 52d52e13f9dd509a01fbae8bd193e58f959ef5ad Mon Sep 17 00:00:00 2001 From: Gaurav Narula Date: Thu, 1 Dec 2011 17:58:41 +0000 Subject: [PATCH] Commit for GCI task #7122242 Port the Central Participant's Database panel core functionality into the yii framework (1/3) git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11552 b72ed6b6-b9f8-46b5-92b4-906544132732 --- application/controllers/AdminController.php | 1 + ...articipants.php => participantsaction.php} | 506 ++++---- .../models/ParticipantAttributeNames.php | 231 ++++ application/models/Participants.php | 1055 +++++++++++++++++ application/models/Survey.php | 7 +- .../models/Surveys_languagesettings.php | 4 +- application/models/User.php | 6 +- application/models/participants_model.php | 16 +- .../participants/attributeControl_view.php | 26 +- .../participants/displayParticipants_view.php | 87 +- .../participants/participantsPanel_view.php | 58 +- .../admin/participants/sharePanel_view.php | 6 +- .../admin/participants/userControl_view.php | 12 +- .../admin/participants/viewAttribute_view.php | 40 +- scripts/admin/displayParticipant.js | 8 +- 15 files changed, 1676 insertions(+), 387 deletions(-) rename application/controllers/admin/{participants.php => participantsaction.php} (74%) create mode 100644 application/models/ParticipantAttributeNames.php create mode 100644 application/models/Participants.php diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php index cebce09bb55..511316f6c5a 100644 --- a/application/controllers/AdminController.php +++ b/application/controllers/AdminController.php @@ -126,6 +126,7 @@ public function actions() 'statistics' => 'application.controllers.admin.statistics', 'labels' => 'application.controllers.admin.labels', 'templates' => 'application.controllers.admin.templates', + 'participants' => 'application.controllers.admin.participantsaction', ); } diff --git a/application/controllers/admin/participants.php b/application/controllers/admin/participantsaction.php similarity index 74% rename from application/controllers/admin/participants.php rename to application/controllers/admin/participantsaction.php index 58839e994a1..29d5e0da57b 100644 --- a/application/controllers/admin/participants.php +++ b/application/controllers/admin/participantsaction.php @@ -2,8 +2,31 @@ /* * This is the main controller for Participants Panel */ -class participants extends Admin_Controller +class participantsaction extends CAction { + +/** +* Routes the action into correct subaction +* +* @access protected +* @param string $sa +* @param array $get_vars +* @return void +*/ +protected function route($sa) +{ + return call_user_func_array(array($this, $sa),array()); +} + +function run($sa = '') { + if(!empty($sa)) { + $this->route($sa); + } + else { + CController::redirect(Yii::app()->createUrl('admin/participants/sa/index')); + } +} + /** * This function is responsible for loading the view 'participantsPanel' * @param null @@ -11,24 +34,24 @@ class participants extends Admin_Controller */ function index() { - $this->load->model('participants_model'); - $this->load->model('participant_attribute_model'); - $iUserID = $this->session->userdata('loginID'); - self::_getAdminHeader(); - if($this->session->userdata('USER_RIGHT_SUPERADMIN')) // if superadmin all the records in the cpdb will be displayed + //$this->load->model('participants_model'); + //$this->load->model('participant_attribute_model'); + $iUserID = Yii::app()->session['loginID']; + $this->getController()->_getAdminHeader(); + if(Yii::app()->session['USER_RIGHT_SUPERADMIN']) // if superadmin all the records in the cpdb will be displayed { - $iTotalRecords = $this->participants_model->getParticipantCount(); + $iTotalRecords = Participants::model()->count(); } else // if not only the participants on which he has right on (shared and owned) { - $iTotalRecords=$this->participants_model->getParticipantsOwnerCount($iUserID); + $iTotalRecords=Participants::getParticipantsOwnerCount($iUserID); } // gets the count of participants, their attributes and other such details - $iShared = $this->participants_model->getParticipantsSharedCount($iUserID); - $iOwned = $this->participants_model->getParticipantOwnedCount($iUserID); - $iBlacklisted = $this->participants_model->getBlacklistedCount($iUserID); - $iAttributeCount = $this->participant_attribute_model->getAttributeCount(); - $clang = $this->limesurvey_lang; + $iShared = Participants::getParticipantsSharedCount($iUserID); + $iOwned = Participants::model()->count('owner_uid = '.$iUserID); + $iBlacklisted = Participants::model()->count('owner_uid = '.$iUserID.' AND blacklisted = \'Y\''); + $iAttributeCount = ParticipantAttributeNames::model()->count(); + $clang = $this->getController()->lang; $aData = array('clang'=> $clang, 'totalrecords' => $iTotalRecords, 'owned' => $iOwned, @@ -37,9 +60,9 @@ function index() 'blacklisted' => $iBlacklisted ); // loads the participant panel and summary view - $this->load->view('admin/participants/participantsPanel_view',$aData); - $this->load->view('admin/participants/summary_view',$aData); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $this->getController()->render('/admin/participants/participantsPanel_view',$aData); + $this->getController()->render('/admin/participants/summary_view',$aData); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual")); } /** * This function is responsible for loading the view 'importCSV' @@ -62,32 +85,32 @@ function importCSV() */ function displayParticipants() { - self::_js_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/js/i18n/grid.locale-en.js"); - self::_js_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/js/jquery.jqGrid.min.js"); - $css_admin_includes[] = $this->config->item('generalscripts')."jquery/css/jquery.multiselect.css"; - $css_admin_includes[] = $this->config->item('generalscripts')."jquery/css/jquery.multiselect.filter.css"; - $css_admin_includes[] = $this->config->item('styleurl')."admin/default/displayParticipants.css"; - $css_admin_includes[] = $this->config->item('generalscripts')."jquery/jqGrid/css/ui.jqgrid.css"; - $css_admin_includes[] = $this->config->item('generalscripts')."jquery/jqGrid/css/jquery.ui.datepicker.css"; - $this->config->set_item("css_admin_includes", $css_admin_includes); - self::_getAdminHeader(); - $clang = $this->limesurvey_lang; - $this->load->model('users_model'); - $this->load->model('participant_attribute_model'); - $this->load->model('surveys_model'); - $this->load->model('participants_model'); - $getNames=$this->users_model->getSomeRecords(array('uid','full_name')); - $attributes = $this->participant_attribute_model->getVisibleAttributes(); - $allattributes = $this->participant_attribute_model->getAllAttributes(); - $attributeValues =$this->participant_attribute_model->getAllAttributesValues(); + $this->getController()->_js_admin_includes( Yii::app()->getConfig('generalscripts')."jquery/jqGrid/js/i18n/grid.locale-en.js"); + $this->getController()->_js_admin_includes( Yii::app()->getConfig('generalscripts')."jquery/jqGrid/js/jquery.jqGrid.min.js"); + $css_admin_includes[] = Yii::app()->getConfig('generalscripts')."jquery/css/jquery.multiselect.css"; + $css_admin_includes[] = Yii::app()->getConfig('generalscripts')."jquery/css/jquery.multiselect.filter.css"; + $css_admin_includes[] = Yii::app()->getConfig('styleurl')."admin/default/displayParticipants.css"; + $css_admin_includes[] = Yii::app()->getConfig('generalscripts')."jquery/jqGrid/css/ui.jqgrid.css"; + $css_admin_includes[] = Yii::app()->getConfig('generalscripts')."jquery/jqGrid/css/jquery.ui.datepicker.css"; + Yii::app()->setConfig("css_admin_includes", $css_admin_includes); + $this->getController()->_getAdminHeader(); + $clang = $this->getController()->lang; + //$this->load->model('users_model'); + //$this->load->model('participant_attribute_model'); + //$this->load->model('surveys_model'); + //$this->load->model('participants_model'); + $getNames= Yii::app()->db->createCommand()->select('uid,full_name')->from('{{users}}')->queryAll(); + $attributes = ParticipantAttributeNames::getVisibleAttributes(); + $allattributes = ParticipantAttributeNames::getAllAttributes(); + $attributeValues =ParticipantAttributeNames::getAllAttributesValues(); // loads the survey names to be shown in add to survey - if($this->session->userdata('USER_RIGHT_SUPERADMIN')) // if user is superadmin, all survey names + if(Yii::app()->session['USER_RIGHT_SUPERADMIN']) // if user is superadmin, all survey names { - $surveynames = $this->surveys_model->getAllSurveyNames(); + $surveynames = Survey::getAllSurveyNames(); } else // otherwise owned by him { - $surveynames = $this->surveys_model->getSurveyNames(); + $surveynames = Survey::getSurveyNames(); } // data to be passed to view $aData = array('names'=> $getNames, @@ -97,9 +120,9 @@ function displayParticipants() 'surveynames' =>$surveynames, 'clang'=> $clang ); // loads the participant panel view and display participant view - $this->load->view('admin/participants/participantsPanel_view',$aData); - $this->load->view('admin/participants/displayParticipants_view',$aData); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $this->getController()->render('/admin/participants/participantsPanel_view',$aData); + $this->getController()->render('/admin/participants/displayParticipants_view',$aData); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual")); } /** * This function is responsible for loading the view 'blacklistControl' @@ -108,11 +131,11 @@ function displayParticipants() */ function blacklistControl() { - self::_getAdminHeader(); - $clang = $this->limesurvey_lang; + $this->getController()->_getAdminHeader(); + $clang = $this->getController()->lang; $aData = array('clang'=> $clang); - $this->load->view('admin/participants/participantsPanel_view',$aData); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $this->getController()->render('/admin/participants/participantsPanel_view',$aData); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual")); } /** * This function is responsible for loading the view 'attributeControl' @@ -122,15 +145,14 @@ function blacklistControl() function attributeControl() { - $css_admin_includes[] = $this->config->item('styleurl')."admin/default/participants.css"; - $this->config->set_item("css_admin_includes", $css_admin_includes); - self::_getAdminHeader(); - $clang = $this->limesurvey_lang; - $this->load->model('participant_attribute_model'); - $aData = array('clang'=> $clang,'result'=>$this->participant_attribute_model->getAttributes()); - $this->load->view('admin/participants/participantsPanel_view',$aData); - $this->load->view('admin/participants/attributeControl_view',$aData); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $css_admin_includes[] = Yii::app()->getConfig('styleurl')."admin/default/participants.css"; + Yii::app()->setConfig("css_admin_includes", $css_admin_includes); + $this->getController()->_getAdminHeader(); + $clang = $this->getController()->lang; + $aData = array('clang'=> $clang,'result'=>ParticipantAttributeNames::getAttributes()); + $this->getController()->render('/admin/participants/participantsPanel_view',$aData); + $this->getController()->render('/admin/participants/attributeControl_view',$aData); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual")); } /** * This function is responsible for loading the view 'userControl' @@ -139,13 +161,13 @@ function attributeControl() */ function userControl() { - self::_getAdminHeader(); - $clang = $this->limesurvey_lang; + $this->getController()->_getAdminHeader(); + $clang = $this->getController()->lang; $aData = array('clang'=> $clang, - 'userideditable'=>$this->config->item("userideditable")); - $this->load->view('admin/participants/participantsPanel_view',$aData); - $this->load->view('admin/participants/userControl_view',$aData); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + 'userideditable'=>Yii::app()->getConfig("userideditable")); + $this->getController()->render('/admin/participants/participantsPanel_view',$aData); + $this->getController()->render('/admin/participants/userControl_view',$aData); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual")); } /** * This function is responsible for loading the view 'sharePanel' @@ -154,21 +176,21 @@ function userControl() */ function sharePanel() { - self::_js_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/js/i18n/grid.locale-en.js"); - self::_js_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/js/jquery.jqGrid.min.js"); - self::_js_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/plugins/jquery.searchFilter.js"); - self::_js_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/src/grid.celledit.js"); - self::_js_admin_includes($this->config->item('adminscripts')."sharePanel.js"); - self::_js_admin_includes($this->config->item('generalscripts')."jquery/jqGrid/js/i18n/grid.locale-en.js"); - $css_admin_includes[] = $this->config->item('generalscripts')."jquery/jqGrid/css/ui.jqgrid.css"; - $css_admin_includes[] = $this->config->item('generalscripts')."jquery/jqGrid/css/jquery.ui.datepicker.css"; - $this->config->set_item("css_admin_includes", $css_admin_includes); - self::_getAdminHeader(); - $clang = $this->limesurvey_lang; + $this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts')."jquery/jqGrid/js/i18n/grid.locale-en.js"); + $this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts')."jquery/jqGrid/js/jquery.jqGrid.min.js"); + $this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts')."jquery/jqGrid/plugins/jquery.searchFilter.js"); + $this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts')."jquery/jqGrid/src/grid.celledit.js"); + $this->getController()->_js_admin_includes(Yii::app()->getConfig('adminscripts')."sharePanel.js"); + $this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts')."jquery/jqGrid/js/i18n/grid.locale-en.js"); + $css_admin_includes[] = Yii::app()->getConfig('generalscripts')."jquery/jqGrid/css/ui.jqgrid.css"; + $css_admin_includes[] = Yii::app()->getConfig('generalscripts')."jquery/jqGrid/css/jquery.ui.datepicker.css"; + Yii::app()->setConfig("css_admin_includes", $css_admin_includes); + $this->getController()->_getAdminHeader(); + $clang = $this->getController()->lang; $aData = array('clang'=> $clang); - $this->load->view('admin/participants/participantsPanel_view',$aData); - $this->load->view('admin/participants/sharePanel_view',$aData); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $this->getController()->render('/admin/participants/participantsPanel_view',$aData); + $this->getController()->render('/admin/participants/sharePanel_view',$aData); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual")); } /** * This function sends the shared participant info to the share panel using JSON encoding @@ -245,23 +267,22 @@ function editShareInfo() */ function delParticipant() { - $this->load->model('participants_model'); - $selectoption = $this->input->post('selectedoption'); - $participant_id = $this->input->post('participant_id'); + $selectoption = CHttpRequest::getPost('selectedoption'); + $participant_id = CHttpRequest::getPost('participant_id'); // Deletes from participants only if($selectoption=="po") { - $this->participants_model->deleteParticipant($participant_id); + Participants::deleteParticipant($participant_id); } // Deletes from central and token table elseif($selectoption=="ptt") { - $this->participants_model->deleteParticipantToken($participant_id); + Participants::deleteParticipantToken($participant_id); } // Deletes from central , token and assosiated responses as well else { - $this->participants_model->deleteParticipantTokenAnswer($participant_id); + Participants::deleteParticipantTokenAnswer($participant_id); } } /** @@ -271,52 +292,50 @@ function delParticipant() */ function editParticipant() { - $operation = $_POST['oper']; - $this->load->model('participants_model'); - $this->load->model('users_model'); + $operation = CHttpRequest::getPost('oper'); //In case the uid is not editable, then user id is not posted and hence the current user is added in the uid - if($this->input->post('owner_uid')=='') + if(CHttpRequest::getPost('owner_uid')=='') { - $oid=$this->session->userdata('loginID'); + $oid=Yii::app()->session['loginID']; } //otherwise the one which is posted is added else { - $oid = $_POST['owner_uid']; + $oid = CHttpRequest::getPost('owner_uid'); } - if($this->input->post('language')=='') + if(CHttpRequest::getPost('language')=='') { - $lang=$this->session->userdata('adminlang'); + $lang=Yii::app()->session['adminlang']; } else { - $lang = $_POST['language']; + $lang = CHttpRequest::getPost('language'); } // if edit it will update the row if($operation == 'edit') { $aData = array( - 'participant_id' => $_POST['id'], - 'firstname' => $_POST['firstname'], - 'lastname' => $_POST['lastname'], - 'email' => $_POST['email'], - 'language' => $_POST['language'], - 'blacklisted' => $_POST['blacklisted'], + 'participant_id' => CHttpRequest::getPost('id'), + 'firstname' => CHttpRequest::getPost('firstname'), + 'lastname' => CHttpRequest::getPost('lastname'), + 'email' => CHttpRequest::getPost('email'), + 'language' => CHttpRequest::getPost('language'), + 'blacklisted' => CHttpRequest::getPost('blacklisted'), 'owner_uid' => $oid); - $this->participants_model->updateRow($aData); + Participants::updateRow($aData); } // if add it will insert a new row elseif($operation == 'add') { $uuid = $this->gen_uuid(); $aData = array('participant_id' => $uuid, - 'firstname' => $_POST['firstname'], - 'lastname' => $_POST['lastname'], - 'email' => $_POST['email'], - 'language' => $_POST['language'], - 'blacklisted' => $_POST['blacklisted'], + 'firstname' => CHttpRequest::getPost('firstname'), + 'lastname' => CHttpRequest::getPost('lastname'), + 'email' => CHttpRequest::getPost('email'), + 'language' => CHttpRequest::getPost('language'), + 'blacklisted' => CHttpRequest::getPost('blacklisted'), 'owner_uid' => $oid); - $this->participants_model->insertParticipant($aData); + Participants::insertParticipant($aData); } } /** @@ -339,18 +358,18 @@ function storeUserControlValues() */ function getSurveyInfo_json() { - $this->load->model('survey_links_model'); - $this->load->model('surveys_languagesettings_model'); - $participantid = $this->uri->segment(4); - $records = $this->survey_links_model->getLinkInfo($participantid); + //$this->load->model('survey_links_model'); + //$this->load->model('surveys_languagesettings_model'); + $participantid = CHttpRequest::getQuery('pid'); + $records = Yii::app()->db->createCommand()->select('token_id,survey_id,date_created')->from('{{survey_links}}')->where('participant_id = "'.$participantid.'"')->queryAll(); $aData->page = 1; - $aData->records = count ($this->survey_links_model->getLinkInfo($participantid)->result_array()); + $aData->records = count ($records); $aData->total = ceil ($aData->records /10 ); $i=0; - foreach($records->result() as $row) + foreach($records as $row) { - $surveyname = $this->surveys_languagesettings_model->getSurveyNames($row->survey_id); - $aData->rows[$i]['cell']=array($surveyname->row()->surveyls_title,"survey_id.">".$row->survey_id,$row->token_id,$row->date_created); + $surveyname = Surveys_languagesettings::getSurveyNames($row['survey_id']); + $aData->rows[$i]['cell']=array($surveyname[0]['surveyls_title'],"".$row['survey_id'],$row['token_id'],$row['date_created']); $i++; } echo ls_json_encode($aData); @@ -699,47 +718,44 @@ function exporttocsv() } function getParticipantsResults_json() { - $page = $this->input->post('page'); - $limit = $this->input->post('rows'); - $this->load->model('participants_model'); - $this->load->model('participant_attribute_model'); - $this->load->model('users_model'); - $attid = $this->participant_attribute_model->getAttributeVisibleID(); + $page = CHttpRequest::getPost('page'); + $limit = CHttpRequest::getPost('rows'); + $attid = ParticipantAttributeNames::getAttributeVisibleID(); $participantfields = array('participant_id','can_edit','firstname','lastname','email','blacklisted','surveys','language','owner_uid'); - if($this->session->userdata('USER_RIGHT_SUPERADMIN')) //If super admin all the participants will be visible + if(Yii::app()->session['USER_RIGHT_SUPERADMIN']) //If super admin all the participants will be visible { - $searchcondition = $this->uri->segment(4); + $searchcondition = CHttpRequest::getQuery('search'); $searchcondition = urldecode($searchcondition); $finalcondition = array(); $condition = explode("||",$searchcondition); if(count($condition)==3) { - $records = $this-> participants_model->getParticipantsSearch($condition,$page,$limit); + $records = Participants::getParticipantsSearch($condition,$page,$limit); $aData->page = $page; - $aData->records = count ($this->participants_model->getParticipantsSearch($condition,0,0)); + $aData->records = count (Participants::getParticipantsSearch($condition,0,0)); $aData->total = ceil ($aData->records /$limit ); } else { - $records = $this-> participants_model->getParticipantsSearchMultiple($condition,$page,$limit); + $records = Participants::getParticipantsSearchMultiple($condition,$page,$limit); $aData->page = $page; - $aData->records = count ($this->participants_model->getParticipantsSearchMultiple($condition,0,0)); + $aData->records = count (Participants::getParticipantsSearchMultiple($condition,0,0)); $aData->total = ceil ($aData->records /$limit ); } - $i=0; + $i=0; foreach($records as $row=>$value) { - $username = $this->users_model->getName($value['owner_uid']);//for conversion of uid to human readable names - $surveycount = $this->participants_model->getSurveyCount($value['participant_id']); - $sortablearray[$i]=array($value['participant_id'],"true",$value['firstname'],$value['lastname'],$value['email'],$value['blacklisted'],$surveycount,$value['language'],$username->full_name);// since it's the admin he has access to all editing on the participants inspite of what can_edit option is - $attributes = $this->participant_attribute_model->getParticipantVisibleAttribute($value['participant_id']); + $username = User::getName($value['owner_uid']);//for conversion of uid to human readable names + $surveycount = Participants::getSurveyCount($value['participant_id']); + $sortablearray[$i]=array($value['participant_id'],"true",$value['firstname'],$value['lastname'],$value['email'],$value['blacklisted'],$surveycount,$value['language'],$username[0]['full_name']);// since it's the admin he has access to all editing on the participants inspite of what can_edit option is + $attributes = ParticipantAttributeNames::getParticipantVisibleAttribute($value['participant_id']); foreach($attid as $attributeid) { - $answer=$this->participant_attribute_model->getAttributeValue($value['participant_id'],$attributeid['attribute_id']); - if(isset($answer->value)) + $answer=ParticipantAttributeNames::getAttributeValue($value['participant_id'],$attributeid['attribute_id']); + if(isset($answer['value'])) { - array_push($sortablearray[$i],$answer->value); + array_push($sortablearray[$i],$answer['value']); } else { @@ -768,53 +784,56 @@ function subval_sort($a,$subkey,$order) } return $c; } - $indexsort = array_search($this->input->post('sidx'), $participantfields); - $sortedarray = subval_sort($sortablearray,$indexsort,$this->input->post('sord')); - $i=0; - $count = count($sortedarray[0]); - foreach($sortedarray as $key=>$value) + if(!empty($sortablearray)) { - $aData->rows[$i]['id']=$value[0]; - $aData->rows[$i]['cell'] = array(); - for($j=0 ; $j < $count ; $j++) + $indexsort = array_search(CHttpRequest::getPost('sidx'), $participantfields); + $sortedarray = subval_sort($sortablearray,$indexsort,CHttpRequest::getPost('sord')); + $i=0; + $count = count($sortedarray[0]); + foreach($sortedarray as $key=>$value) { - array_push($aData->rows[$i]['cell'],$value[$j]); + $aData->rows[$i]['id']=$value[0]; + $aData->rows[$i]['cell'] = array(); + for($j=0 ; $j < $count ; $j++) + { + array_push($aData->rows[$i]['cell'],$value[$j]); + } + $i++; } - $i++; } echo ls_json_encode($aData); } else // Only the owned and shared participants will be visible { - $searchcondition = $this->uri->segment(4); + $searchcondition = CHttpRequest::getQuery('search'); $searchcondition = urldecode($searchcondition); $finalcondition = array(); $condition = explode("||",$searchcondition); if(count($condition)==3) { - $records = $this-> participants_model->getParticipantsSearch($condition,$page,$limit); + $records = Participants::getParticipantsSearch($condition,$page,$limit); $aData->page = $page; } else { - $records = $this-> participants_model->getParticipantsSearchMultiple($condition,$page,$limit); + $records = Participants::getParticipantsSearchMultiple($condition,$page,$limit); $aData->page = $page; } $i=0; foreach($records as $row=>$value) { - if($this->participants_model->is_owner($value['participant_id'])) + if(Participants::s_owner($value['participant_id'])) { - $username = $this->users_model->getName($value['owner_uid']);//for conversion of uid to human readable names - $surveycount = $this->participants_model->getSurveyCount($value['participant_id']); - $sortablearray[$i]=array($value['participant_id'],"true",$value['firstname'],$value['lastname'],$value['email'],$value['blacklisted'],$surveycount,$value['language'],$username->full_name);// since it's the admin he has access to all editing on the participants inspite of what can_edit option is - $attributes = $this->participant_attribute_model->getParticipantVisibleAttribute($value['participant_id']); + $username = User::getName($value['owner_uid']);//for conversion of uid to human readable names + $surveycount = Participants::getSurveyCount($value['participant_id']); + $sortablearray[$i]=array($value['participant_id'],"true",$value['firstname'],$value['lastname'],$value['email'],$value['blacklisted'],$surveycount,$value['language'],$username[0]['full_name']);// since it's the admin he has access to all editing on the participants inspite of what can_edit option is + $attributes = ParticipantAttributeNames::getParticipantVisibleAttribute($value['participant_id']); foreach($attid as $attributeid) { - $answer=$this->participant_attribute_model->getAttributeValue($value['participant_id'],$attributeid['attribute_id']); - if(isset($answer->value)) + $answer=ParticipantAttributeNames::getAttributeValue($value['participant_id'],$attributeid['attribute_id']); + if(isset($answer['value'])) { - array_push($sortablearray[$i],$answer->value); + array_push($sortablearray[$i],$answer['value']); } else { @@ -848,8 +867,8 @@ function subval_sort($a,$subkey,$order) { $aData->records = count($sortablearray); $aData->total = ceil (count($sortablearray) /$limit ); - $indexsort = array_search($this->input->post('sidx'), $participantfields); - $sortedarray = subval_sort($sortablearray,$indexsort,$this->input->post('sord')); + $indexsort = array_search(CHttpRequest::getPost('sidx'), $participantfields); + $sortedarray = subval_sort($sortablearray,$indexsort,CHttpRequest::getPost('sord')); $i=0; $count = count($sortedarray[0]); foreach($sortedarray as $key=>$value) @@ -874,36 +893,36 @@ function subval_sort($a,$subkey,$order) */ function getParticipants_json() { - $page = $this->input->post('page'); - $limit = $this->input->post('rows'); - $this->load->model('participants_model'); - $this->load->model('participant_attribute_model'); - $this->load->model('users_model'); - $attid = $this->participant_attribute_model->getAttributeVisibleID(); + $page = CHttpRequest::getPost('page'); + $limit = CHttpRequest::getPost('rows'); + //$this->load->model('participants_model'); + //$this->load->model('participant_attribute_model'); + //$this->load->model('users_model'); + $attid = ParticipantAttributeNames::getAttributeVisibleID(); $participantfields = array('participant_id','can_edit','firstname','lastname','email','blacklisted','surveys','language','owner_uid'); foreach($attid as $key=>$value) { array_push($participantfields,$value['attribute_name']); } - if($this->session->userdata('USER_RIGHT_SUPERADMIN')) //If super admin all the participants will be visible + if(Yii::app()->session['USER_RIGHT_SUPERADMIN']) //If super admin all the participants will be visible { - $records = $this-> participants_model->getParticipants($page,$limit); + $records = Participants::getParticipants($page,$limit); $aData->page = $page; - $aData->records = $this->participants_model->getParticipantsCount(); + $aData->records = Participants::model()->count(); $aData->total = ceil ( $aData->records / $limit ); $i=0; - foreach($records->result() as $row) + foreach($records as $key => $row) { - $username = $this->users_model->getName($row->owner_uid);//for conversion of uid to human readable names - $surveycount = $this->participants_model->getSurveyCount($row->participant_id); - $sortablearray[$i]=array($row->participant_id,"true",$row->firstname,$row->lastname,$row->email,$row->blacklisted,$surveycount,$row->language ,$username->full_name);// since it's the admin he has access to all editing on the participants inspite of what can_edit option is - $attributes = $this->participant_attribute_model->getParticipantVisibleAttribute($row->participant_id); + $username = User::getName($row['owner_uid']);//for conversion of uid to human readable names + $surveycount = Participants::getSurveyCount($row['participant_id']); + $sortablearray[$i]=array($row['participant_id'],"true",$row['firstname'],$row['lastname'],$row['email'],$row['blacklisted'],$surveycount,$row['language'] ,$username[0]['full_name']);// since it's the admin he has access to all editing on the participants inspite of what can_edit option is + $attributes = ParticipantAttributeNames::getParticipantVisibleAttribute($row['participant_id']); foreach($attid as $attributeid) { - $answer=$this->participant_attribute_model->getAttributeValue($row->participant_id,$attributeid['attribute_id']); - if(isset($answer->value)) + $answer=ParticipantAttributeNames::getAttributeValue($row['participant_id'],$attributeid['attribute_id']); + if(isset($answer[0]['value'])) { - array_push($sortablearray[$i],$answer->value); + array_push($sortablearray[$i],$answer[0]['value']); } else { @@ -932,8 +951,8 @@ function subval_sort($a,$subkey,$order) } return $c; } - $indexsort = array_search($this->input->post('sidx'), $participantfields); - $sortedarray = subval_sort($sortablearray,$indexsort,$this->input->post('sord')); + $indexsort = array_search(CHttpRequest::getPost('sidx'), $participantfields); + $sortedarray = subval_sort($sortablearray,$indexsort,CHttpRequest::getPost('sord')); $i=0; $count = count($sortedarray[0]); foreach($sortedarray as $key=>$value) @@ -951,25 +970,25 @@ function subval_sort($a,$subkey,$order) else // Only the owned and shared participants will be visible { - $iUserID = $this->session->userdata('loginID'); - $records = $this->participants_model->getParticipantsOwner($iUserID); + $iUserID = Yii::app()->session['loginID']; + $records = Participants::getParticipantsOwner($iUserID); $aData->page = $page; - $aData->records = count ($this->participants_model->getParticipantsOwner($iUserID)->result_array()); + $aData->records = count($records); $aData->total = ceil($aData->records/$limit); - $attid = $this->participant_attribute_model->getAttributeVisibleID(); + $attid = ParticipantAttributeNames::getAttributeVisibleID(); $i=0; - foreach($records->result() as $row) + foreach($records as $row) { - $surveycount = $this->participants_model->getSurveyCount($row->participant_id); - $ownername = $this->users_model->getName($row->owner_uid); //for conversion of uid to human readable names - $sortablearray[$i]=array($row->participant_id,$row->can_edit,$row->firstname,$row->lastname,$row->email,$row->blacklisted,$surveycount,$row->language,$ownername->full_name); - $attributes = $this->participant_attribute_model->getParticipantVisibleAttribute($row->participant_id); + $surveycount = Participants::getSurveyCount($row['participant_id']); + $ownername = Users::getName($row['owner_uid']); //for conversion of uid to human readable names + $sortablearray[$i]=array($row['participant_id'],$row['can_edit'],$row['firstname'],$row['lastname'],$row['email'],$row['blacklisted'],$surveycount,$row['language'],$ownername[0]['full_name']); + $attributes = ParticipantAttributeNames::getParticipantVisibleAttribute($row['participant_id']); foreach($attid as $attributeid) { - $answer=$this->participant_attribute_model->getAttributeValue($row->participant_id,$attributeid['attribute_id']); - if(isset($answer->value)) + $answer=ParticipantAttributeNames::getAttributeValue($row['participant_id'],$attributeid['attribute_id']); + if(isset($answer[0]['value'])) { - array_push($sortablearray[$i],$answer->value); + array_push($sortablearray[$i],$answer[0]['value']); } else { @@ -998,8 +1017,8 @@ function subval_sort($a,$subkey,$order) } return $c; } - $indexsort = array_search($this->input->post('sidx'), $participantfields); - $sortedarray = subval_sort($sortablearray,$indexsort,$this->input->post('sord')); + $indexsort = array_search(CHttpRequest::getPost('sidx'), $participantfields); + $sortedarray = subval_sort($sortablearray,$indexsort,CHttpRequest::getPost('sord')); $i=0; $count = count($sortedarray[0]); foreach($sortedarray as $key=>$value) @@ -1020,10 +1039,9 @@ function subval_sort($a,$subkey,$order) */ function getAttribute_json() { - $this->load->model('participant_attribute_model'); - $participant_id=$this->uri->segment(4); - $records = $this->participant_attribute_model->getParticipantVisibleAttribute($participant_id); - $getallattributes = $this->participant_attribute_model->getAttributes(); + $participant_id=CHttpRequest::getQuery('pid'); + $records = ParticipantAttributeNames::getParticipantVisibleAttribute($participant_id); + $getallattributes = ParticipantAttributeNames::getAttributes(); $aData->page = 1; $aData->records = count ($records); $aData->total = ceil ($aData->records /10 ); @@ -1037,7 +1055,7 @@ function getAttribute_json() $aData->rows[$i]['cell']=array("",$row['participant_id'],$row['attribute_type'],$row['attribute_name'],$row['value']); if($row['attribute_type']=="DD") { - $attvalues = $this->participant_attribute_model->getAttributesValues($row['attribute_id']); + $attvalues = ParticipantAttributeNames::getAttributesValues($row['attribute_id']); if(!empty($attvalues)) { $attval=""; @@ -1063,22 +1081,22 @@ function getAttribute_json() } if(count($doneattributes)==0) { - $attributenotdone = $this->participant_attribute_model->getAttributes(); + $attributenotdone = ParticipantAttributeNames::getAttributes(); } else { - $attributenotdone = $this->participant_attribute_model->getnotaddedAttributes($doneattributes); + $attributenotdone = ParticipantAttributeNames::getnotaddedAttributes($doneattributes); } if($attributenotdone>0) { foreach($attributenotdone as $row) { - $aData->rows[$i]['id']=$this->uri->segment(4)."_".$row['attribute_id']; - $aData->rows[$i]['cell']=array("",$this->uri->segment(4),$row['attribute_type'],$row['attribute_name'],""); + $aData->rows[$i]['id']=$participant_id."_".$row['attribute_id']; + $aData->rows[$i]['cell']=array("",$participant_id,$row['attribute_type'],$row['attribute_name'],""); if($row['attribute_type']=="DD") { - $attvalues = $this->participant_attribute_model->getAttributesValues($row['attribute_id']); + $attvalues = ParticipantAttributeNames::getAttributesValues($row['attribute_id']); if(!empty($attvalues)) { $attval=""; @@ -1112,37 +1130,36 @@ function getAttribute_json() function storeParticipants() { $aData = array('participant_id' => uniqid(), - 'firstname' => $this->input->post('firstname'), - 'lastname' => $this->input->post('lastname'), - 'email' => $this->input->post('email'), - 'language' => $this->input->post('language'), - 'blacklisted' => $this->input->post('blacklisted'), - 'owner_uid' => $this->input->post('owner_uid')); - $this->load->model('participants_model'); - $this->participants_model->insertParticipant($aData); + 'firstname' => CHttpRequest::getPost('firstname'), + 'lastname' => CHttpRequest::getPost('lastname'), + 'email' => CHttpRequest::getPost('email'), + 'language' => CHttpRequest::getPost('language'), + 'blacklisted' => CHttpRequest::getPost('blacklisted'), + 'owner_uid' => CHttpRequest::getPost('owner_uid')); + + Participants::insertParticipant($aData); } /* * This function is responsible for showing the additional attribute for central database */ function viewAttribute() { - $this->load->model('participant_attribute_model'); - $attribute_id = $this->uri->segment(4); - $attributes=$this->participant_attribute_model->getAttribute($attribute_id); - $attributenames = $this->participant_attribute_model->getAttributeNames($attribute_id); - $attributevalues=$this->participant_attribute_model->getAttributesValues($attribute_id); - $clang = $this->limesurvey_lang; + $attribute_id = CHttpRequest::getQuery('aid'); + $attributes=ParticipantAttributeNames::getAttribute($attribute_id); + $attributenames = ParticipantAttributeNames::getAttributeNames($attribute_id); + $attributevalues=ParticipantAttributeNames::getAttributesValues($attribute_id); + $clang = $this->getController()->lang; $aData = array('attributes' => $attributes, 'attributevalues' => $attributevalues, 'attributenames' => $attributenames, 'clang'=> $clang); - $css_admin_includes[] = $this->config->item('styleurl')."admin/default/participants.css"; - $css_admin_includes[] = $this->config->item('styleurl')."admin/default/viewAttribute.css"; - $this->config->set_item("css_admin_includes", $css_admin_includes); - self::_getAdminHeader(); - $this->load->view('admin/participants/participantsPanel_view',$aData); - $this->load->view('admin/participants/viewAttribute_view',$aData); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $css_admin_includes[] = Yii::app()->getConfig('styleurl')."admin/default/participants.css"; + $css_admin_includes[] = Yii::app()->getConfig('styleurl')."admin/default/viewAttribute.css"; + Yii::app()->setConfig("css_admin_includes", $css_admin_includes); + $this->getController()->_getAdminHeader(); + $this->getController()->render('/admin/participants/participantsPanel_view',$aData); + $this->getController()->render('/admin/participants/viewAttribute_view',$aData); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $this->getController()->lang->gT("LimeSurvey online manual")); } /* * This function is responsible for saving the additional attribute. It iterates through all the new attributes added dynamically @@ -1150,20 +1167,19 @@ function viewAttribute() */ function saveAttribute() { - $this->load->model('participant_attribute_model'); - $aData = array('attribute_id' => $this->uri->segment(4), - 'attribute_type' => $this->input->post('attribute_type'), - 'visible' => $this->input->post('visible')); - $this->participant_attribute_model->saveAttribute($aData); + $aData = array('attribute_id' => CHttpRequest::getQuery('aid'), + 'attribute_type' => CHttpRequest::getPost('attribute_type'), + 'visible' => CHttpRequest::getPost('visible')); + ParticipantAttributeNames::saveAttribute($aData); foreach($_POST as $key=>$value) { if(strlen($key) == 2) // check for language code in the post variables this is a hack as the only way to check for language data { - $langdata = array( 'attribute_id' => $this->uri->segment(4), + $langdata = array( 'attribute_id' => CHttpRequest::getQuery('aid'), 'attribute_name' => $value, 'lang' => $key ); - $this->participant_attribute_model->saveAttributeLanguages($langdata); + ParticipantAttributeNames::saveAttributeLanguages($langdata); } } if(isset($_POST['attribute_value_name_1'])) @@ -1174,12 +1190,12 @@ function saveAttribute() $attvaluename = 'attribute_value_name_'.$i; if(!empty($_POST[$attvaluename])) { - $aDatavalues[$i] = array('attribute_id' => $this->uri->segment(4), - 'value' => $this->input->post($attvaluename)); + $aDatavalues[$i] = array('attribute_id' => CHttpRequest::getQuery('aid'), + 'value' => CHttpRequest::getPost($attvaluename)); } $i++; }while(isset($_POST[$attvaluename])); - $this->participant_attribute_model->storeAttributeValues($aDatavalues); + ParticipantAttributeNames::storeAttributeValues($aDatavalues); } if(isset($_POST['editbox'])) @@ -1187,19 +1203,18 @@ function saveAttribute() $editattvalue = array('value_id'=> $_POST['value_id'], 'attribute_id'=> $this->uri->segment(4), 'value' => $_POST['editbox']); - $this->participant_attribute_model->saveAttributeValue($editattvalue); + ParticipantAttributeNames::saveAttributeValue($editattvalue); } - redirect('admin/participants/attributeControl'); + CController::redirect(Yii::app()->createUrl('admin/participants/sa/attributeControl')); } /* * This function is responsible for deleting the additional attribute. */ function delAttribute() { - $attribute_id = $this->uri->segment(4); - $this->load->model('participant_attribute_model'); - $this->participant_attribute_model->delAttribute($attribute_id); - redirect('admin/participants/attributeControl'); + $attribute_id = CHttpRequest::getQuery('aid'); + ParticipantAttributeNames::delAttribute($attribute_id); + CController::redirect(Yii::app()->createUrl('/admin/participants/sa/attributeControl')); } /* * This function is responsible for deleting the additional attribute values in case of drop down. @@ -1209,15 +1224,14 @@ function delAttributeValues() $attribute_id = $this->uri->segment(4); $value_id = $this->uri->segment(5); $this->load->model('participant_attribute_model'); - $this->participant_attribute_model->delAttributeValues($attribute_id,$value_id); - redirect('admin/participants/viewAttribute/'.$attribute_id); + ParticipantAttributeNames::delAttributeValues($attribute_id,$value_id); + redirect('admin/participants/sa/viewAttribute/'.$attribute_id); } /* * This function is responsible for deleting the storing the additional attributes */ function storeAttributes() { - $this->load->model('participant_attribute_model'); $i=1; do { @@ -1226,27 +1240,26 @@ function storeAttributes() $visible = 'visible_'.$i; if(!empty($_POST[$attname])) { - $aData = array('attribute_name' => $this->input->post($attname), - 'attribute_type' => $this->input->post($atttype), - 'visible' => $this->input->post($visible)); - $this->participant_attribute_model->storeAttribute($aData); + $aData = array('attribute_name' => CHttpRequest::getPost($attname), + 'attribute_type' => CHttpRequest::getPost($atttype), + 'visible' => CHttpRequest::getPost($visible)); + ParticipantAttributeNames::storeAttribute($aData); } $i++; }while(isset($_POST[$attname])); - redirect('admin/participants/attributeControl'); + CController::redirect('attributeControl'); } /* * This function is responsible for editing the additional attributes values */ function editAttributevalue() { - $this->load->model('participant_attribute_model'); - if($this->input->post('oper')=="edit") + if(CHttpRequest::getPost('oper')=="edit") { - $attributeid = explode("_",$this->input->post('id')); - $aData = array('participant_id' => $this->input->post('participant_id'),'attribute_id' => $attributeid[1],'value' => $this->input->post('attvalue')); - $this->participant_attribute_model->editParticipantAttributeValue($aData); + $attributeid = explode("_",CHttpRequest::getPost('id')); + $aData = array('participant_id' => CHttpRequest::getPost('participant_id'),'attribute_id' => $attributeid[1],'value' => CHttpRequest::getPost('attvalue')); + ParticipantAttributeNames::editParticipantAttributeValue($aData); } } function attributeMapCSV() @@ -1771,8 +1784,7 @@ function blacklistParticipant() } function saveVisible() { - $this->load->model('participant_attribute_model'); - $this->participant_attribute_model->saveAttributeVisible($this->input->post('attid'),$this->input->post('visiblevalue')); + ParticipantAttributeNames::saveAttributeVisible(CHttpRequest::getPost('attid'),CHttpRequest::getPost('visiblevalue')); } } ?> diff --git a/application/models/ParticipantAttributeNames.php b/application/models/ParticipantAttributeNames.php new file mode 100644 index 00000000000..bcbf7e0b2b6 --- /dev/null +++ b/application/models/ParticipantAttributeNames.php @@ -0,0 +1,231 @@ +4), + array('visible', 'length', 'max'=>5), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('attribute_id, attribute_type, visible', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'attribute_id' => 'Attribute', + 'attribute_type' => 'Attribute Type', + 'visible' => 'Visible', + ); + } + + /** + * Retrieves a list of models based on the current search/filter conditions. + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search() + { + // Warning: Please modify the following code to remove attributes that + // should not be searched. + + $criteria=new CDbCriteria; + + $criteria->compare('attribute_id',$this->attribute_id); + $criteria->compare('attribute_type',$this->attribute_type,true); + $criteria->compare('visible',$this->visible,true); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } + + function getVisibleAttributes() + { + return Yii::app()->db->createCommand()->select('{{participant_attribute_names}}.*,{{participant_attribute_names}}_lang.*')->from('{{participant_attribute_names}}')->order('{{participant_attribute_names}}.attribute_id', 'desc')->join('{{participant_attribute_names}}_lang', '{{participant_attribute_names}}_lang.attribute_id = {{participant_attribute_names}}.attribute_id')->where('{{participant_attribute_names}}.visible = "TRUE" AND {{participant_attribute_names}}_lang.lang = "'.Yii::app()->session['adminlang'].'"')->queryAll(); + } + + function getAllAttributes() + { + return Yii::app()->db->createCommand()->select('{{participant_attribute_names}}.*,{{participant_attribute_names}}_lang.*')->from('{{participant_attribute_names}}')->order('{{participant_attribute_names}}.attribute_id', 'desc')->join('{{participant_attribute_names}}_lang', '{{participant_attribute_names}}_lang.attribute_id = {{participant_attribute_names}}.attribute_id')->where('{{participant_attribute_names}}_lang.lang = "'.Yii::app()->session['adminlang'].'"')->queryAll(); + } + + function getAllAttributesValues() + { + return Yii::app()->db->createCommand()->select('*')->from('{{participant_attribute_values}}')->queryAll(); + } + + function getAttributeVisibleID() + { + return Yii::app()->db->createCommand()->select('{{participant_attribute_names}}.*,{{participant_attribute_names_lang}}.*')->from('{{participant_attribute_names}}')->order('{{participant_attribute_names}}.attribute_id', 'desc')->where('{{participant_attribute_names}}.visible = "TRUE"')->join('{{participant_attribute_names_lang}}', '{{participant_attribute_names_lang}}.attribute_id = {{participant_attribute_names}}.attribute_id')->where('{{participant_attribute_names_lang}}.lang = "'.Yii::app()->session['adminlang'].'"')->queryAll(); + } + + function getParticipantVisibleAttribute($participant_id) + { + return Yii::app()->db->createCommand()->select('{{participant_attribute}}.*,{{participant_attribute_names}}.*,{{participant_attribute_names_lang}}.*')->from('{{participant_attribute}}')->order('{{participant_attribute}}.attribute_id','desc')->where('participant_id = '.$participant_id)->join('{{participant_attribute_names_lang}}','{{participant_attribute}}.attribute_id = {{participant_attribute_names_lang}}.attribute_id')->join('{{participant_attribute_names}}', '{{participant_attribute}}.attribute_id = {{participant_attribute_names}}.attribute_id')->where('{{participant_attribute_names_lang}}.lang = "'.Yii::app()->session['adminlang'].'"')->where('lang = "'.Yii::app()->session['adminlang'].'"')->queryAll(); + } + + function getAttributeValue($participantid,$attributeid) + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participant_attribute}}')->where('participant_id = "'.$participantid.'" AND attribute_id = '.$attributeid)->queryAll(); + return $data; + } + + function getAttributes() + { + return Yii::app()->db->createCommand()->select('{{participant_attribute_names}}.*,{{participant_attribute_names_lang}}.*')->from('{{participant_attribute_names}}')->join('{{participant_attribute_names_lang}}', '{{participant_attribute_names}}.attribute_id = {{participant_attribute_names_lang}}.attribute_id')->where('lang = "'.Yii::app()->session['adminlang'].'"')->queryAll(); + } + + function getAttributesValues($attribute_id) + { + return Yii::app()->db->createCommand()->select('*')->from('{{participant_attribute_values}}')->where('attribute_id = '.$attribute_id)->queryAll(); + } + + // this is a very specific function used to get the attributes that are not present for the participant + function getnotaddedAttributes($attributeid) + { + $attrid = array('not in','{{participant_attribute_names}}.attribute_id'); + foreach($attributeid as $row) + { + $attrid[] = $row; + } + return Yii::app()->db->createCommand()->select('*')->from('{{participant_attribute_names}}')->join('{{participant_attribute_names_lang}}', '{{participant_attribute_names}}.attribute_id = {{participant_attribute_names_lang}}.attribute_id')->where($attrid)->queryAll(); + } + + function storeAttribute($data) + { + $insertnames = array('attribute_type' => $data['attribute_type'], + 'visible' => $data['visible']); + Yii::app()->db->createCommand()->insert('{{participant_attribute_names}}',$insertnames); + $insertnameslang = array('attribute_id' => Yii::app()->db->getLastInsertID(), + 'attribute_name'=>$data['attribute_name'], + 'lang' => Yii::app()->session['adminlang']); + Yii::app()->db->createCommand()->insert('{{participant_attribute_names_lang}}',$insertnameslang); + + } + + function editParticipantAttributeValue($data) + { + $query = Yii::app()->db->createCommand()->where('participant_id = "'.$data['participant_id'].'" AND attribute_id = '. $data['attribute_id'])->from('{{participant_attribute}}')->select('*')->queryAll(); + if(count($query) == 0) + { + Yii::app()->db->createCommand()->insert('{{participant_attribute}}',$data); + } + else + { + Yii::app()->db->createCommand()->update('{{participant_attribute}}',$data,'participant_id = "'.$data['participant_id'].'" AND attribute_id = '.$data['attribute_id']); + } + + } + + function delAttribute($attid) + { + Yii::app()->db->createCommand()->delete('{{participant_attribute_names_lang}}', 'attribute_id = '.$attid); + Yii::app()->db->createCommand()->delete('{{participant_attribute_names}}', 'attribute_id = '.$attid); + Yii::app()->db->createCommand()->delete('{{participant_attribute_values}}', 'attribute_id = '.$attid); + Yii::app()->db->createCommand()->delete('{{participant_attribute}}', 'attribute_id = '.$attid); + } + + function getAttributeNames($attributeid) + { + return Yii::app()->db->createCommand()->where('attribute_id = '.$attributeid)->where('lang = "'.Yii::app()->session['adminlang'].'"')->from('{{participant_attribute_names_lang}}')->select('*')->queryAll(); + } + function getAttribute($attribute_id) + { + $data = Yii::app()->db->createCommand()->from('{{participant_attribute_names}}')->where('{{participant_attribute_names}}.attribute_id = '.$attribute_id)->select('*')->queryRow(); + return $data; + } + + function saveAttribute($data) + { + Yii::app()->db->createCommand()->update('{{participant_attribute_names}}',$data,'attribute_id = '.$data['attribute_id']); + } + + function saveAttributeLanguages($data) + { + $query = Yii::app()->db->createCommand()->from('{{participant_attribute_names_lang}}')->where('attribute_id = '.$data['attribute_id'].' AND lang = "'.$data['lang'].'"')->select('*')->queryAll(); + if (count($query) == 0) + { + // A record does not exist, insert one. + $record = array('attribute_id'=>$data['attribute_id'],'attribute_name'=>$data['attribute_name'],'lang'=>$data['lang']); + $query = Yii::app()->db->createCommand()->insert('{{participant_attribute_names_lang}}', $data); + } + else + { + // A record does exist, update it. + $query = Yii::app()->db->createCommand()->update('{{participant_attribute_names_lang}}',array('attribute_id'=>$data['attribute_id'],'lang'=>$data['lang']),'attribute_name = "'.$data['attribute_name'].'"'); + } + } + + function storeAttributeValues($data) + { + foreach ($data as $record) { + Yii::app()->db->createCommand()->insert('{{participant_attribute_values}}',$record); + } + } + + //updates the attribute values in participant_attribute_values + function saveAttributeValue($data) + { + Yii::app()->db->createCommand()->update('{{participant_attribute_values}}', array('attribute_id' => $data['attribute_id'],'value_id'=>$data['value_id'])); + } + + function saveAttributeVisible($attid,$visiblecondition) + { + + $attribute_id = explode("_", $attid); + $data=array('visible'=>$visiblecondition); + if($visiblecondition == "") + { + $data=array('visible'=>'FALSE'); + } + Yii::app()->db->createCommand()->update('{{participant_attribute_names}}',$data,'attribute_id = '.$attribute_id[1]); + } +} diff --git a/application/models/Participants.php b/application/models/Participants.php new file mode 100644 index 00000000000..45726809d90 --- /dev/null +++ b/application/models/Participants.php @@ -0,0 +1,1055 @@ +true), + array('participant_id', 'length', 'max'=>50), + array('firstname, lastname, language', 'length', 'max'=>40), + array('email', 'length', 'max'=>80), + array('blacklisted', 'length', 'max'=>1), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('participant_id, firstname, lastname, email, language, blacklisted, owner_uid', 'safe', 'on'=>'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + ); + } + + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'participant_id' => 'Participant', + 'firstname' => 'Firstname', + 'lastname' => 'Lastname', + 'email' => 'Email', + 'language' => 'Language', + 'blacklisted' => 'Blacklisted', + 'owner_uid' => 'Owner Uid', + ); + } + + /** + * Retrieves a list of models based on the current search/filter conditions. + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search() + { + // Warning: Please modify the following code to remove attributes that + // should not be searched. + + $criteria=new CDbCriteria; + + $criteria->compare('participant_id',$this->participant_id,true); + $criteria->compare('firstname',$this->firstname,true); + $criteria->compare('lastname',$this->lastname,true); + $criteria->compare('email',$this->email,true); + $criteria->compare('language',$this->language,true); + $criteria->compare('blacklisted',$this->blacklisted,true); + $criteria->compare('owner_uid',$this->owner_uid); + + return new CActiveDataProvider($this, array( + 'criteria'=>$criteria, + )); + } + + /* + * funcion for generation of unique id + */ + function gen_uuid() + { + return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), + mt_rand( 0, 0xffff ), + mt_rand( 0, 0x0fff ) | 0x4000, + mt_rand( 0, 0x3fff ) | 0x8000, + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) + ); + } + + /* + * This function is responsible for adding the participant to the database + * Parameters : participant data + * Return Data : none + */ + function insertParticipant($data) + { + Yii::app()->db->createCommand()->insert('{{participants}}',$data)->query(); + } + + /* + * This function updates the data edited in the jqgrid + * Parameters : data that is edited + * Return Data : None + */ + function updateRow($data) + { + Yii::app()->db->createCommand()->update('{{participants}}',$data,'participant_id = "'.$data['participant_id'].'"'); + } + + function deleteParticipantTokenAnswer($rows) + { + $rowid=explode(",",$rows); + //$rowid = array('243148a0-bf56-4ee1-a6d2-a1f1cb5243d5'); + foreach($rowid as $row) + { + $tokens = Yii::app()->db->createCommand()->select('*')->from('{{survey_links}}')->where('participant_id = "'.$row.'"')->queryAll(); + foreach($tokens as $key => $value) + { + Yii::app()->db->createCommand()->delete('{{participants}}','participant_id = "'.$row.'"'); //Delete from participants + if(Yii::app()->db->schema->getTable('tokens_'.$value['survey_id'])) + { + $tokenid = Yii::app()->db->createCommand()->select('token')->from('{{tokens_'.$value['survey_id'].'}}')->where('participant_id = "'.$value['participant_id'].'"')->queryAll(); + $token = $tokenid[0]; + if((Yii::app()->db->schema->getTable('survey_'.$value['survey_id']))) + { + if(!empty($token['token'])) + { + $gettoken = Yii::app()->db->createCommand()->select('*')->from('{{survey_'.$value['survey_id'].'}}')->where('token = '.$token['token'])->queryAll(); + $gettoken = $gettoken[0]; + Yii::app()->db->createCommand()->delete('{{survey_'.$value['survey_id'].'}}','token = '. $gettoken['token']); + } + } + Yii::app()->db->createCommand()->delete('{{tokens_'.$value['survey_id'].'}}', 'participant_id = "'.$value['participant_id'].'"');// Deletes from token + } + } + } + } + + /* + * This function combines the shared participant and the central participant + * table and searches for any reference of owner id or shared owner id in the rows + */ + function getParticipantsOwner($userid) + { + return Yii::app()->db->createCommand()->select('{{participants}}.*,{{participant_shares}}.can_edit')->from('{{participants}}')->leftJoin('{{participant_shares}}',' {{participants}}.participant_id={{participant_shares}}.participant_id')->where('owner_uid = '.$userid.' OR share_uid = '.$userid)->group('{{participants}}.participant_id')->queryAll(); + } + + function getParticipantsOwnerCount($userid) + { + return Yii::app()->db->createCommand()->select('participants.*,participant_shares.can_edit')->from('{{participants}}')->leftJoin('{{participant_shares}}',' participants.participant_id=participant_shares.participant_id')->where('owner_uid = '.$userid.' OR share_uid = '.$userid)->group('participants.participant_id')->queryAll(); + } + + /* + * This function combines the shared participant and the central participant + * table and searches for any reference of owner id in the combined record + * of the two tables + */ + function getParticipantsSharedCount($userid) + { + return count(Yii::app()->db->createCommand()->select('{{participants}}.*, {{participant_shares}}.*')->from('{{participants}}')->join('{{participant_shares}}','{{participant_shares}}.participant_id = {{participants}}.participant_id')->where('owner_uid = '.$userid)->queryAll()); + } + + function getParticipants($page,$limit) + { + $start = $limit*$page - $limit; + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->limit($limit, $start)->queryAll(); + return $data; + } + + function getSurveyCount($participant_id) + { + $count = count(Yii::app()->db->createCommand()->select('*')->from('{{survey_links}}')->where('participant_id = "'.$participant_id.'"')->queryAll()); + return $count; + } + + /* + * This function deletes the row marked in the navigator + * Parameters : row id's + * Return Data : None + */ + function deleteParticipant($rows) + { + // Converting the comma seperated id's to an array to delete multiple rows + $rowid=explode(",",$rows); + foreach($rowid as $row) + { + Yii::app()->db->createCommand()->delete('{{participants}}','participant_id = "'.$row.'"'); + Yii::app()->db->createCommand()->delete('{{survey_links}}','participant_id = "'.$row.'"'); + Yii::app()->db->createCommand()->delete('{{participant_attribute}}','participant_id = "'.$row.'"'); + } + } + + function deleteParticipantToken($rows) + { + $rowid=explode(",",$rows); + foreach($rowid as $row) + { + $tokens = Yii::app()->db->createCommand()->select('*')->from('{{survey_links}}')->where('participant_id = "'.$row.'"')->queryAll(); + foreach($tokens as $key => $value) + { + if(Yii::app()->db->schema->getTable('tokens_'.$value['survey_id'])) + { + Yii::app()->db->createCommand()->delete('{{tokens_'.$value['survey_id'].'}}','participant_id = "'.$value['participant_id'].'"'); + } + } + Yii::app()->db->createCommand()->delete('{{participants}}','participant_id = "'.$row.'"'); + Yii::app()->db->createCommand()->delete('{{survey_links}}','participant_id = "'.$row.'"'); + Yii::app()->db->createCommand()->delete('{{participant_attribute}}','participant_id = "'.$row.'"'); + } + } + + function getParticipantsSearch($condition,$page,$limit) + { + $start = $limit*$page - $limit; + if($condition[1]=='equal') + { + if($condition[0]=='surveys') + { + $resultarray = array(); + if($page == 0 && $limit == 0) + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->queryAll(); + } + else + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->limit($limit,$start)->queryAll(); + } + foreach($data as $key=>$value) + { + $count = count(Yii::app()->db->createCommand()->where('participant_id = "'.$value['participant_id'].'"')->from('{{survey_links}}')->select('*')->queryAll()); + if($count == $condition[2]) + { + array_push($resultarray,$value); + } + } + return $resultarray; + } + else if($condition[0]=='owner_name') + { + $userid = Yii::app()->db->createCommand()->select('uid')->where('full_name = "'.$condition[2].'"')->from('{{users}}')->queryAll(); + $uid = $userid[0]; + $command = Yii::app()->db->createCommand(); + $command->where('owner_uid = '.$uid['uid']); + $command->select('*'); + if($page == 0 && $limit == 0) + { + $data= $command->from('{{participants}}')->queryAll(); + } + else + { + $data = $command->from('{{participants}}')->limit($limit,$start)->queryAll(); + } + return $data; + } + else if(is_numeric($condition[0])) + { + $command = Yii::app()->db->createCommand()->select('{{participant_attribute}}.*,{{participants}}.*')->from('{{participant_attribute}}')->join('{{participants}}', '{{participant_attribute}}.participant_id = {{participants}}.participant_id')->where('{{participant_attribute}}.attribute_id = '.$condition[0].' AND {{participant_attribute}}.value = "'.$condition[2].'"'); + if($page == 0 && $limit == 0) + { + $data = $command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else + { + $command = Yii::app()->db->createCommand()->where($condition[0].' = "'.$condition[2].'"'); + if($page == 0 && $limit == 0) + { + $data=$command->select('*')->from('{{participants}}')->queryAll(); + } + else + { + $data = $command->select('*')->from('{{participants}}')->limit($limit,$start)->queryAll(); + } + return $data; + } + } + else if($condition[1]=='contains') + { + $condition[2] = '%'.$condition[2].'%'; + if($condition[0]=='surveys') + { + $resultarray = array(); + if($page == 0 && $limit == 0) + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->queryAll(); + } + else + { + $data = Yii::app()->db->createCommand()->select('*')->limit($limit,$start)->from('{{participants}}')->queryAll(); + } + foreach($data as $key=>$value) + { + $count = count(Yii::app()->db->createCommand()->where('participant_id = "'.$value['participant_id'].'"')->from('{{survey_links}}')->queryAll()); + if($count == $condition[2]) + { + array_push($resultarray,$value); + } + } + return $resultarray; + } + + else if($condition[0]=='owner_name') + { + $userid = $command = Yii::app()->db->createCommand()->select('uid')->where(array('like','full_name',$condition[2]))->from('{{users}}')->queryAll(); + $uid = $userid[0]; + $command = Yii::app()->db->createCommand()->where('owner_uid = '.$uid['uid'])->order("lastname", "asc")->select('*')->from('{{participants}}'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else if(is_numeric($condition[0])) + { + $command = Yii::app()->db->createCommand()->select('{{participant_attribute}}.*,{{participants}}.*')->from('{{participant_attribute}}')->join('{{participants}}', '{{participant_attribute}}.participant_id = {{participants}}.participant_id')->where('{{participant_attribute}}.attribute_id = '.$condition[0])->where(array('like','{{participant_attribute}}.value',$condition[2])); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start); + } + return $data; + } + else + { + $command = Yii::app()->db->createCommand()->where(array('like',$condition[0],$condition[2]))->select('*')->from('{{participants}}'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + + } + else if($condition[1]=='notequal') + { + if($condition[0]=='surveys') + { + $resultarray = array(); + + if($page == 0 && $limit == 0) + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->queryAll(); + } + else + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->limit($limit,$start)->queryAll(); + } + foreach($data as $key=>$value) + { + $count = count(Yii::app()->db->createCommand()->select('*')->from('{{survey_links}}')->where('participant_id = "'.$value['participant_id'].'"')->queryAll()); + if($count != $condition[2]) + { + array_push($resultarray,$value); + } + } + return $resultarray; + } + else if($condition[0]=='owner_name') + { + + $userid = Yii::app()->db->createCommand()->select('uid')->where(array('not in','full_name',$condition[2]))->from('{{users}}')->queryAll(); + $uid = $userid[0]; + $command = Yii::app()->db->createCommand()->where('owner_uid = '.$uid['uid'])->from('{{participants}}')->select('*'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else if(is_numeric($condition[0])) + { + $command = Yii::app()->db->createCommand()->select('{{participant_attribute}}.*,{{participants}}.*')->from('{{participant_attribute}}')->join('{{participants}}', '{{participant_attribute}}.participant_id = {{participants}}.participant_id')->where('{{participant_attribute}}.attribute_id = '.$condition[0])->where(array('not in','{{participant_attribute}}.value',$condition[2])); + if($page == 0 && $limit == 0) + { + $data = $command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else + { + $command = Yii::app()->db->createCommand()->where(array('not in',$condition[0],$condition[2]))->from('{{participants}}')->select('*'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + } + else if($condition[1]=='notcontains') + { + $condition[2] = '%'.$condition[2].'%'; + if($condition[0]=='surveys') + { + $resultarray = array(); + $command = Yii::app()->db->createCommand()->order('lastname','asc')->from('{{participants}}')->select('*'); + if($page == 0 && $limit == 0) + { + $data = $command->queryAll(); + } + else + { + $data = $command->limit($limit,$start); + } + foreach($data as $key=>$value) + { + $count = count(Yii::app()->db->createCommand()->where('participant_id = "',$value['participant_id'].'"')->from('{{survey_links}}')->select('*')->queryAll()); + if($count != $condition[2]) + { + array_push($resultarray,$value); + } + } + return $resultarray; + } + else if($condition[0]=='owner_name') + { + $userid = Yii::app()->db->createCommand()->select('uid')->where(array('not like','full_name',$condition[2]))->from('{{users}}')->queryAll(); + $uid = $userid[0]; + $command = Yii::app()->db->createCommand()->where('owner_uid = '.$uid['uid'])->from('{{participants}}')->select('*'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else if(is_numeric($condition[0])) + { + $command = Yii::app()->db->createCommand()->select('{{participant_attribute}}.*,{{participants}}.*')->from('{{participant_attribute}}')->join('{{participants}}', '{{participant_attribute}}.participant_id = {{participants}}.participant_id')->where('{{participant_attribute}}.attribute_id = '.$condition[0])->where(array('not like','participant_attribute.value',$condition[2])); + if($page == 0 && $limit == 0) + { + $data = $command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else + { + $command = Yii::app()->db->createCommand()->where(array('not like',$condition[0],$condition[2]))->from('{{participants}}')->select('*'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + } + else if($condition[1]=='greaterthan') + { + if($condition[0]=='surveys') + { + $resultarray = array(); + if($page == 0 && $limit == 0) + { + $data = $this->db->get('participants'); + } + else + { + $data = $this->db->get('participants',$limit,$start); + } + foreach($data->result_array() as $key=>$value) + { + $this->db->where('participant_id',$value['participant_id']); + $this->db->from('survey_links'); + $count=$this->db->count_all_results(); + if($count > $condition[2]) + { + array_push($resultarray,$value); + } + } + return $resultarray; + } + else if($condition[0]=='owner_name') + { + $userid = Yii::app()->db->createCommand()->select('uid')->where('full_name = "'.$condition[2].'"')->from('{{users}}')->queryAll(); + $uid = $userid[0]; + $command = Yii::app()->db->createCommand()->where('owner_uid = '.$uid['uid'])->order("lastname", "asc")->select('*') ->from('{{participants}}'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else if(is_numeric($condition[0])) + { + $command = Yii::app()->db->createCommand()->select('{{participant_attribute}}.*,{{participants}}.*')->from('{{participant_attribute}}')->join('{{participants}}', '{{participant_attribute}}.participant_id = {{participants}}.participant_id')->where('{{participant_attribute}}.attribute_id = '.$condition[0].' AND participant_attribute.value > "'.$condition[2].'"'); + if($page == 0 && $limit == 0) + { + $data = $command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + else + { + $command = Yii::app()->db->createCommand()->where($condition[0].' > "'.$condition[2].'"')->order("lastname", "asc")->select('*')->from('{{participants}}'); + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + } + else if($condition[1]=='lessthan') + { + if($condition[0]=='surveys') + { + $resultarray = array(); + + if($page == 0 && $limit == 0) + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->queryAll(); + } + else + { + $data = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->limit($limit,$start)->queryAll(); + } + foreach($data as $key=>$value) + { + $count = count(Yii::app()->db->createCommand()->where('participant_id = "'.$value['participant_id'].'"')->from('{{survey_links}}')->select('*')->queryAll()); + if($count < $condition[2]) + { + array_push($resultarray,$value); + } + } + return $resultarray; + } + else if($condition[0]=='owner_name') + { + + $userid = Yii::app()->db->createCommand()->select('uid')->where('full_name = "'.$condition[2].'"')->from('{{users}}')->queryAll(); + $uid = $userid[0]; + $command = Yii::app()->db->createCommand()->where('owner_uid < '.$uid['uid'])->select('*')->from('{{participants}}'); + + if($page == 0 && $limit == 0) + { + $data=$command->queryAll(); + } + else + { + $data = $command->limit($limit,$start); + } + return $data; + } + else if(is_numeric($condition[0])) + { + $command = Yii::app()->db->createCommand()->select('{{participant_attribute}}.*,{{participants}}.*')->from('{{participant_attribute}}')->join('{{participants}}', '{{participant_attribute}}.participant_id = {{participants}}.participant_id')->where('{{participant_attribute}}.attribute_id = '.$condition[0])->where(array('not like','participant_attribute.value < "'.$condition[2].'"')); + if($page == 0 && $limit == 0) + { + $data = $command->queryAll(); + } + else + { + $this->db->limit($limit,$start); + $data = $command->limit($limit,$start); + } + return $data; + } + else + { + $command = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->where($condition[0].' < "'.$condition[2].'"'); + if($page == 0 && $limit == 0) + { + $data= $command->queryAll(); + } + else + { + $data = $command->limit($limit,$start)->queryAll(); + } + return $data; + } + + } + } + + function getParticipantsSearchMultiple($condition,$page,$limit) + { + $i=0; + $j=1; + $tobedonelater =array(); + $start = $limit*$page - $limit; + $command = new CDbCriteria; + $command->condition = ''; + $con= count($condition); + while($i < $con){ + if($i<3){ + $i+=3; + if($condition[1]=='equal') + { + if(is_numeric($condition[0])) + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[0].' AND {{participant_attribute}}.value = "'.$condition[2].'"')->queryAll(); + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $command->addCondition($condition[0].' = "'.$condition[2].'"'); + } + } + else if($condition[1]=='contains') + { + if(is_numeric($condition[0])) + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[0].' AND {{participant_attribute}}.value LIKE "%'.$condition[2].'%"')->queryAll(); + + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $command->addCondition($condition[0].' LIKE "%'.$condition[2].'%"'); + } + } + else if($condition[1]=='notequal') + { + if(is_numeric($condition[0])) + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[0].' AND {{participant_attribute}}.value NOT IN ("'.$condition[2].'")')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $command->addCondition($condition[0].' NOT IN ("'.$condition[2].'")'); + + } + } + else if($condition[1]=='notcontains') + { + if(is_numeric($condition[0])) + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[0].' AND {{participant_attribute}}.value NOT LIKE "%'.$condition[2].'%"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $command->addCondition($condition[0].' NOT LIKE "%'.$condition[2].'%"'); + + } + } + else if($condition[1]=='greaterthan') + { + if(is_numeric($condition[0])) + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[0].' AND {{participant_attribute}}.value > "'.$condition[2].'"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $command->addCondition($condition[0].' > "'.$condition[2].'"'); + + } + } + else if($condition[1]=='lessthan') + { + if(is_numeric($condition[0])) + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[0].' AND {{participant_attribute}}.value < "'.$condition[2].'"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $command->addCondition($condition[0].' < "'.$condition[2].'"'); + + } + } + } + + else if($condition[$i]!='') + { + if($condition[$i+2]=='equal') + { + if(is_numeric($condition[$i+1])) + { + if($condition[$i]=='and') + { + + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[$i+1].' AND {{participant_attribute}}.value = "'.$condition[$i+3].'"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $tobedonelater[$condition[$i+1]][0] = $condition[$i+2]; + $tobedonelater[$condition[$i+1]][1] = $condition[$i+3]; + } + } + else + { + if($condition[$i]=='and') + { + $command->addCondition($condition[$i+1].' = "'.$condition[$i+3].'"'); + } + else + { + $command->addCondition($condition[$i+1].' = "'.$condition[$i+3].'"','OR'); + } + } + } + else if($condition[$i+2]=='contains') + { + if(is_numeric($condition[$i+1])) + { + if($condition[$i]=='and') + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[$i+1].' AND {{participant_attribute}}.value LIKE "%'.$condition[$i+3].'%"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $tobedonelater[$condition[$i+1]][0] = $condition[$i+2]; + $tobedonelater[$condition[$i+1]][1] = $condition[$i+3]; + } + } + else + { + if($condition[$i]=='and') + { + + $command->addCondition($condition[$i+1].' LIKE "%'.$condition[$i+3].'%"'); + } + else + { + $command->addCondition($condition[$i+1].' LIKE "%'.$condition[$i+3].'%"','OR'); + } + } + } + else if($condition[$i+2]=='notequal') + { + if(is_numeric($condition[$i+1])) + { + if($condition[$i]=='and') + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[$i+1].' AND {{participant_attribute}}.value NOT IN ("'.$condition[$i+3].'")')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $tobedonelater[$condition[$i+1]][0] = $condition[$i+2]; + $tobedonelater[$condition[$i+1]][1] = $condition[$i+3]; + } + } + else + { + if($condition[$i]=='and') + { + $command->addCondition($condition[$i+1].' NOT IN ("'.$condition[$i+3].'")'); + } + else + { + $command->addCondition($condition[$i+1].' NOT IN ("'.$condition[$i+3].'")','OR'); + } + } + } + else if($condition[$i+2]=='notcontains') + { + if(is_numeric($condition[$i+1])) + { + if($condition[$i]=='and') + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[$i+1].' AND {{participant_attribute}}.value NOT LIKE "%'.$condition[$i+3].'%"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $tobedonelater[$condition[$i+1]][0] = $condition[$i+2]; + $tobedonelater[$condition[$i+1]][1] = $condition[$i+3]; + } + } + else + { + if($condition[$i]=='and') + { + $command->addCondition($condition[$i+1].' NOT LIKE "%'.$condition[$i+3].'%"'); + } + else + { + $command->addCondition($condition[$i+1].' NOT LIKE "%'.$condition[$i+3].'%"','OR'); + } + } + } + else if($condition[$i+2]=='greaterthan') + { + if(is_numeric($condition[$i+1])) + { + if($condition[$i]=='and') + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[$i+1].' AND {{participant_attribute}}.value > "'.$condition[$i+3].'"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $tobedonelater[$condition[$i+1]][0] = $condition[$i+2]; + $tobedonelater[$condition[$i+1]][1] = $condition[$i+3]; + } + } + else + { + if($condition[$i]=='and') + { + $command->addCondition($condition[$i+1].' > "'.$condition[$i+3].'"'); + } + else + { + $command->addCondition($condition[$i+1].' > "'.$condition[$i+3].'"','OR'); + } + } + } + else if($condition[$i+2]=='lessthan') + { + if(is_numeric($condition[$i+1])) + { + if($condition[$i]=='and') + { + $newsub = $j; + $arr = Yii::app()->db->createCommand('SELECT {{participant_attribute}}.participant_id FROM {{participant_attribute}} WHERE {{participant_attribute}}.attribute_id = '.$condition[$i+1].' AND {{participant_attribute}}.value < "'.$condition[$i+3].'"')->queryAll(); + + + $command->addInCondition('participant_id',$arr); + $j++; + } + else + { + $tobedonelater[$condition[$i+1]][0] = $condition[$i+2]; + $tobedonelater[$condition[$i+1]][1] = $condition[$i+3]; + } + } + else + { + if($condition[$i]=='and') + { + $command->addCondition($condition[$i+1].' < "'.$condition[$i+3].'"'); + } + else + { + $command->addCondition($condition[$i+1].' < "'.$condition[$i+3].'"','OR'); + } + } + } + $i=$i+4; + } + else{$i=$i+4;} + } + if($page == 0 && $limit == 0) + { + $arr = Participants::model()->findAll($command); + $data = array(); + foreach($arr as $t) + { + $data[$t->participant_id] = $t->attributes; + } + } + else + { + $command->limit = $limit; + $command->offset = $start; + $arr = Participants::model()->findAll($command); + $data = array(); + foreach($arr as $t) + { + $data[$t->participant_id] = $t->attributes; + } + } + + $otherdata = $data; + if(!empty($tobedonelater)) + { + $command = new CDBCriteria; + $command->select = 'participant_id'; + $command->distinct = TRUE; + $command->condition = ''; + foreach($tobedonelater as $key=>$value) + { + if($value[0] == 'equal') + { + $command->addCondition('attribute_id = '.$key,'OR'); + $command->addCondition('value = "'.$value[1].'"'); + } + if($value[0] == 'contains') + { + $command->addCondition('attribute_id = '.$key,'OR'); + $command->addCondition('value LIKE "%'.$value[1].'%"'); + } + if($value[0] == 'notequal') + { + $command->addCondition('attribute_id = '.$key,'OR'); + $command->addCondition('value != "'.$value[1].'"'); + } + if($value[0] == 'greaterthan') + { + $command->addCondition('attribute_id = '.$key,'OR'); + $command->addCondition('value > "'.$value[1].'"'); + } + if($value[0] == 'lessthan') + { + $command->addCondition('attribute_id = '.$key,'OR'); + $command->addCondition('value < "'.$value[1].'"'); + } + } + $participant_id = ParticipantAttributeNames::model()->findAll($command); + $command = new CDBCriteria; + $command->select = '*'; + $command->condition = ''; + foreach($participant_id as $key=>$value) + { + $command->addCondition('participant_id = "'.$value->participant_id.'"'); + } + if($page == 0 && $limit == 0) + { + $arr = Participants::model()->findAll($command); + $data = array(); + foreach($arr as $t) + { + $data[$t->participant_id] = $t->attributes; + } + } + else + { + $command->limit = $limit; + $command->offset = $start; + $arr = Participants::model()->findAll($command); + $data = array(); + foreach($arr as $t) + { + $data[$t->participant_id] = $t->attributes; + } + } + + + $orddata = $data; + $finalanswer = array_merge($otherdata,$orddata); + return $finalanswer; + } + else + { + return $otherdata; + } + + } +} diff --git a/application/models/Survey.php b/application/models/Survey.php index 8c8a1c53139..1c2caa59bc7 100644 --- a/application/models/Survey.php +++ b/application/models/Survey.php @@ -186,12 +186,7 @@ public function getSurveyNames() public function getAllSurveyNames() { - $this->db->select('surveyls_survey_id,surveyls_title'); - $this->db->from('surveys_languagesettings'); - $this->db->join('surveys','surveys_languagesettings.surveyls_survey_id = surveys.sid'); - //$this->db->where('usetokens','Y'); // Will be done later - $query=$this->db->get(); - return $query->result_array(); + return Yii::app()->db->createCommand()->select('surveyls_survey_id,surveyls_title')->from('{{surveys_languagesettings}}')->join('{{surveys}}','{{surveys_languagesettings}}.surveyls_survey_id = {{surveys}}.sid')->queryAll(); } public function deleteSurvey($iSurveyID, $recursive=true) diff --git a/application/models/Surveys_languagesettings.php b/application/models/Surveys_languagesettings.php index 994f8127143..ef4f82e6a50 100644 --- a/application/models/Surveys_languagesettings.php +++ b/application/models/Surveys_languagesettings.php @@ -114,9 +114,7 @@ function insertNewSurvey($data) } function getSurveyNames($surveyid) { - $this->db->select('surveyls_title')->from('surveys_languagesettings')->where('surveyls_language',$this->session->userdata('adminlang'))->where('surveyls_survey_id',$surveyid); - $query = $this->db->get(); - return $query; + return Yii::app()->db->createCommand()->select('surveyls_title')->from('{{surveys_languagesettings}}')->where('surveyls_language = "'.Yii::app()->session['adminlang'].'" AND surveyls_survey_id = '.$surveyid)->queryAll(); } function updateRecords($data,$condition=FALSE) diff --git a/application/models/User.php b/application/models/User.php index 6236559cf16..24fcad387b9 100644 --- a/application/models/User.php +++ b/application/models/User.php @@ -202,11 +202,7 @@ public function getShareSetting() */ public function getName($userid) { - $this->db->select('full_name'); - $this->db->from('users'); - $this->db->where(array("uid"=>$userid)); - $result = $this->db->get(); - return $result->row(); + return Yii::app()->db->createCommand()->select('full_name')->from('{{users}}')->where("uid = $userid")->queryAll(); } /** diff --git a/application/models/participants_model.php b/application/models/participants_model.php index 511f9201ae2..b666c9079a9 100644 --- a/application/models/participants_model.php +++ b/application/models/participants_model.php @@ -481,14 +481,14 @@ function getParticipantsSearchMultiple($condition,$page,$limit) else{$i=$i+4;} } if($page == 0 && $limit == 0) - { - $data= $this->db->get(); - } - else - { - $this->db->limit($limit,$start); - $data = $this->db->get(); - } + { + $data= $this->db->get(); + } + else + { + $this->db->limit($limit,$start); + $data = $this->db->get(); + } $otherdata = $data->result_array(); if(!empty($tobedonelater)) diff --git a/application/views/admin/participants/attributeControl_view.php b/application/views/admin/participants/attributeControl_view.php index c5dbd42ace1..1ec5169f05d 100644 --- a/application/views/admin/participants/attributeControl_view.php +++ b/application/views/admin/participants/attributeControl_view.php @@ -1,9 +1,9 @@ - - - + + +
@@ -12,7 +12,7 @@
'form44'); - echo form_open('/admin/participants/storeAttributes',$attribute); + echo CHtml::beginForm('storeAttributes','post',$attribute); ?>


- \ No newline at end of file + diff --git a/application/views/admin/participants/displayParticipants_view.php b/application/views/admin/participants/displayParticipants_view.php index 8bd582b797d..e4c4b536d2e 100644 --- a/application/views/admin/participants/displayParticipants_view.php +++ b/application/views/admin/participants/displayParticipants_view.php @@ -3,7 +3,7 @@ /* Build a different colModel for the userid column based on whether or not the user is editable */ /* This can probably be moved into the controller */ -if($this->config->item("userideditable") == 'Y') //Firstly, if the user has edit rights, make the columns editable +if(Yii::app()->getConfig("userideditable") == 'Y') //Firstly, if the user has edit rights, make the columns editable { $uid = '{ "name":"owner_uid", "index":"owner_uid", "width":150, "sorttype":"int", "sortable": true, "align":"center", "editable":true, "edittype":"select", "editoptions":{ "value":"'; $i=0; @@ -23,12 +23,12 @@ $j=1; $lang = '{ "name":"language", "index":"language", "sorttype":"string", "sortable": true, "align":"center", "editable":true, "edittype":"select", "editoptions":{ "value":"'; $getlangvalues = getLanguageData(); -if($this->session->userdata('adminlang')!='auto') +if(Yii::app()->session['adminlang']!='auto') { -$lname[0]=$this->session->userdata('adminlang').":".$getlangvalues[$this->session->userdata('adminlang')]['description']; +$lname[0]=Yii::app()->session['adminlang'].":".$getlangvalues[Yii::app()->session['adminlang']]['description']; } foreach ($getlangvalues as $keycode => $keydesc) { - if($this->session->userdata('adminlang')!=$keycode) + if(Yii::app()->session['adminlang']!=$keycode) { $cleanlangdesc = str_replace (";"," -",$keydesc['description']); $lname[$j]=$keycode.":".$cleanlangdesc; @@ -79,26 +79,26 @@ var deleteMsg = "
"+deletefrompanelmsg+"

  1. "+deletefrompanel+"
  2. "+deletefrompanelandtoken+"
  3. "+deletefrompaneltokenandresponse+"
"; var searchBtn = "gT("Search") ?>"; var shareMsg = "gT("You can see and edit settings for shared participant in share panel.") ?>"; //PLEASE REVIEW -var jsonUrl = ""; -var jsonSearchUrl = ""; -var editUrl = ""; -var getSearchIDs = ""; -var getaddtosurveymsg = ""; -var minusbutton = ""; -var addbutton = ""; -var delparticipantUrl = ""; -var surveylinkUrl = ""; -var getAttribute_json = ""; -var exporttocsv = ""; -var exporttocsvcount = ""; -var getcpdbAttributes_json = ""; -var attMapUrl = ""; -var editAttributevalue = ""; -var shareUrl = ""; -var surveyUrl = ""; -var postUrl = ""; -var ajaxUrl = ""; -var redUrl = ""; +var jsonUrl = "createUrl("admin/participants/sa/getParticipants_json");?>"; +var jsonSearchUrl = "createUrl("admin/participants/sa/getParticipantsResults_json/search/");?>"; +var editUrl = "createUrl("admin/participants/sa/editParticipant"); ?>"; +var getSearchIDs = "createUrl("admin/participants/sa/getSearchIDs"); ?>"; +var getaddtosurveymsg = "createUrl("admin/participants/sa/getaddtosurveymsg"); ?>"; +var minusbutton = "getRequest()->getBaseUrl()."/images/deleteanswer.png" ?>"; +var addbutton = "getRequest()->getBaseUrl()."/images/plus.png" ?>"; +var delparticipantUrl = "createUrl("admin/participants/sa/delParticipant");?>"; +var surveylinkUrl = "createUrl("admin/participants/sa/getSurveyInfo_json/pid/"); ?>"; +var getAttribute_json = "createUrl("admin/participants/sa/getAttribute_json/pid/");?>"; +var exporttocsv = "createUrl("admin/participants/sa/exporttocsv");?>"; +var exporttocsvcount = "createUrl("admin/participants/sa/exporttocsvcount");?>"; +var getcpdbAttributes_json = "createUrl("admin/participants/sa/exporttocsvcount");?>"; +var attMapUrl = "createUrl("admin/participants/sa/attributeMap");?>"; +var editAttributevalue = "createUrl("admin/participants/sa/editAttributevalue");?>"; +var shareUrl = "createUrl("admin/participants/sa/shareParticipants"); ?>"; +var surveyUrl = "createUrl("admin/participants/sa/addToToken"); ?>"; +var postUrl = "createUrl("admin/participants/sa/setSession"); ?>"; +var ajaxUrl = "createUrl("images/ajax-loader.gif"); ?>"; +var redUrl = "createUrl("admin/participants/sa/displayParticipants");?>"; var colNames = '["participant_id","can_edit","gT("First Name") ?>","gT("Last Name") ?>","gT("E-Mail") ?>","gT("Blacklisted") ?>","gT("Surveys") ?>","gT("Language") ?>","gT("Owner Name") ?>"]'; var colModels = '[{ "name":"participant_id", "index":"participant_id", "width":100, "align":"center", "sorttype":"int", "sortable": true, "editable":false, "hidden":true},'; colModels += '{ "name":"can_edit", "index":"can_edit", "width":10, "align":"center", "sorttype":"int", "sortable": true, "editable":false, "hidden":true},'; @@ -114,7 +114,7 @@ echo $colModels; ?> - + 'images/home.png', + $home = array('src' => Yii::app()->getConfig('imageurl').'/home.png', 'alt' => 'Home Page', 'title' => 'Home Page', 'style' => 'margin-left:2px'); - $information = array('src' => 'images/summary.png', + $information = array('src' => Yii::app()->getConfig('imageurl').'/summary.png', 'alt' => 'Information', 'title' => 'Information', 'style' => 'margin-left:2px'); - $import = array('src' => 'images/importcsv.png', + $import = array('src' => Yii::app()->getConfig('imageurl').'/importcsv.png', 'alt' => 'Import from CSV', 'title' => 'Import from CSV', 'style' => 'margin-left:0px', 'style' => 'margin-right:1px'); - $export = array('src' => 'images/exportcsv.png', + $export = array('src' => Yii::app()->getConfig('imageurl').'/exportcsv.png', 'alt' => 'Export All', 'title' => 'Export All', 'name' => 'export', @@ -36,24 +36,24 @@ 'style' => 'margin-left:0px', 'style' => 'margin-right:1px'); - $display = array('src' => 'images/document.png', + $display = array('src' => Yii::app()->getConfig('imageurl').'/document.png', 'alt' => 'Display Participants', 'title' => 'Display Participants', 'style' => 'margin-left:5px'); - $blacklist = array('src' => 'images/trafficred.png', + $blacklist = array('src' => Yii::app()->getConfig('imageurl').'/trafficred.png', 'alt' => 'Blacklist Control', 'title' => 'BlackList Control', 'style' => 'margin-left:1px', 'style' => 'margin-right:1px'); - $globalsettings = array('src' => 'images/token_manage.png', + $globalsettings = array('src' => Yii::app()->getConfig('imageurl').'/token_manage.png', 'alt' => 'Global Participant Settings', 'title' => 'Global Participant Settings', 'style' => 'margin-left:5px', 'style' => 'margin-right:1px'); - $attributecontrol = array('src' => 'images/tag_green.png', + $attributecontrol = array('src' => Yii::app()->getConfig('imageurl').'/tag_green.png', 'alt' => 'Attribute Control', 'title' => 'Attribute Control', 'width' => 50, @@ -61,45 +61,45 @@ 'style' => 'margin-left:0px', 'style' => 'margin-right:1px'); - $sharepanel = array('src' => 'images/share.png', + $sharepanel = array('src' => Yii::app()->getConfig('imageurl').'/share.png', 'alt' => 'Share Panel', 'title' => 'Share Panel', 'height' => 35, 'width'=> 35, 'style' => 'margin-left:5px'); - $seperator = array('src' => 'images/seperator.gif', + $seperator = array('src' => Yii::app()->getConfig('imageurl').'/seperator.gif', 'alt' => '', 'title' => ''); - $ajaxloader = array('src' => 'images/ajax-loader.gif', + $ajaxloader = array('src' => Yii::app()->getConfig('imageurl').'/ajax-loader.gif', 'alt' => 'Ajax Loader', 'title' => 'Ajax Loader'); ?> @@ -90,13 +90,13 @@ gT('Attribute Visible:') ?> visible =="TRUE") + if($attributes['visible'] =="TRUE") { - echo form_checkbox('visible','TRUE',TRUE); + echo CHtml::checkbox('visible',TRUE,array('value'=>TRUE)); } else { - echo form_checkbox('visible','TRUE',FALSE); + echo CHtml::checkbox('visible',TRUE,array('value'=>FALSE)); } $hidden = array('visible' => 'FALSE'); ?> @@ -132,8 +132,8 @@ 'name' => $value['value_id'], 'height' => '15', 'title' => 'Edit Atribute'); - echo img($edit); - echo anchor('admin/participants/delAttributeValues/'.$attributes->attribute_id.'/'.$value['value_id'],img($del)); + echo CHtml::image($edit['src'],$edit['alt'],array_slice($edit,2)); + echo CHtml::link(img($del),'admin/participants/sa/delAttributeValues/'.$attributes['attribute_id'].'/'.$value['value_id']); ?> @@ -143,15 +143,15 @@

'Save')); + echo CHtml::endForm(); ?>

- \ No newline at end of file + diff --git a/scripts/admin/displayParticipant.js b/scripts/admin/displayParticipant.js index be5067496b4..952198f29c3 100644 --- a/scripts/admin/displayParticipant.js +++ b/scripts/admin/displayParticipant.js @@ -41,11 +41,15 @@ jQuery.download = function(url, data, method){ var id=1; $("#addbutton").click(function(){ id=2; +if(typeof optionstring === "undefined") +{ + optionstring = ""; +} html = "\n\ \n\ \n\ -\n\ -\n\ +\n\ +\n\ \n\ \n\ "+optionstring+"\n\\n\\n\\n\