diff --git a/application/controllers/admin/participantsaction.php b/application/controllers/admin/participantsaction.php index 26a0d3dd258..33aefce349a 100644 --- a/application/controllers/admin/participantsaction.php +++ b/application/controllers/admin/participantsaction.php @@ -207,7 +207,7 @@ function getShareInfo_json() { $oShared = User::getName($row['share_uid']); //for conversion of uid to human readable names $owner = User::getName($row['owner_uid']); - $aData->rows[$i]['id'] = $row['participant_id']; + $aData->rows[$i]['id'] = $row['participant_id']."--".$row['share_uid']; //This is the unique combination per record $aData->rows[$i]['cell'] = array($row['firstname'], $row['lastname'], $row['email'], $oShared[0]['full_name'], $row['share_uid'], $owner[0]['full_name'], $row['date_added'], $row['can_edit']); $i++; } @@ -241,9 +241,10 @@ function getShareInfo_json() function editShareInfo() { $operation = Yii::app()->request->getPost('oper'); + $shareIds = Yii::app()->request->getPost('id'); if ($operation == 'del') // If operation is delete , it will delete, otherwise edit it { - ParticipantShares::deleteRow($_POST); + ParticipantShares::deleteRow($shareIds); } else { diff --git a/application/models/ParticipantShares.php b/application/models/ParticipantShares.php index bfd66880869..75e032d166e 100644 --- a/application/models/ParticipantShares.php +++ b/application/models/ParticipantShares.php @@ -118,19 +118,24 @@ public function storeParticipantShare($data) function updateShare($data) { - $criteria = new CDbCriteria; - $criteria->addCondition('participant_id = :participant_id')->bindParam(":participant_id", $data['participant_id'], PDO::PARAM_STR); - $criteria->addCondition('share_uid = :shareuid')->bindParam(":shareuid", $data['shareuid'], PDO::PARAM_INT); - ParticipantShares::model()->updateAll($data,$criteria); + list($participantId, $shareuid)=explode("--", $data['participant_id']); + $updatedata=array("participant_id"=>$participantId, "share_uid"=>$data['share_uid'], "can_edit"=>$data['can_edit']); + $criteria = new CDbCriteria; + $criteria->addCondition("participant_id = '$participantId'"); + $criteria->addCondition("share_uid = '$shareuid' "); + ParticipantShares::model()->updateAll($updatedata,$criteria); } function deleteRow($rows) { // Converting the comma seperated id's to an array to delete multiple rows - $rowid=explode(",",$rows['id']); - foreach($rowid as $row) + $rowid=explode(",",$rows); + foreach($rowid as $row) { - Yii::app()->db->createCommand()->delete('{{participant_shares}}','participant_id = :participant_id')->bindParam(":participant_id", $row, PDO::PARAM_STR); + list($participantId, $uId)=explode("--", $row); + Yii::app()->db + ->createCommand() + ->delete('{{participant_shares}}',"participant_id = '$participantId' AND share_uid = $uId"); } } } diff --git a/application/views/admin/participants/sharePanel_view.php b/application/views/admin/participants/sharePanel_view.php index 7a945bb0101..4e21f0287ab 100644 --- a/application/views/admin/participants/sharePanel_view.php +++ b/application/views/admin/participants/sharePanel_view.php @@ -1,7 +1,19 @@
eT("Share panel"); ?>

diff --git a/scripts/admin/attributeControl.js b/scripts/admin/attributeControl.js index 14bc77e42b3..a1eea44a192 100644 --- a/scripts/admin/attributeControl.js +++ b/scripts/admin/attributeControl.js @@ -41,8 +41,19 @@ $(document).ready(function() { } }); - jQuery('#attributeControl').jqGrid('navGrid','#pager', {add:true, del:true, edit:true}, {width:400}, {width:400, reloadAfterSubmit: false, - afterSubmit: function (response) { return [true, '', response.responseText]; }}, {}, {multipleSearch:true, width:600}); + jQuery('#attributeControl').jqGrid('navGrid', + '#pager', + {add:true, del:true, edit:true}, + {width:400}, + { width:400, + reloadAfterSubmit: false, + afterSubmit: function (response) { + return [true, '', response.responseText]; + } + }, + {}, + {multipleSearch:true, width:600} + ); }); diff --git a/scripts/admin/sharePanel.js b/scripts/admin/sharePanel.js index 76de3f88909..fcb165c3a73 100644 --- a/scripts/admin/sharePanel.js +++ b/scripts/admin/sharePanel.js @@ -4,75 +4,85 @@ Please Note: we are not using the normal jqgrid cell edit here. */ function ajaxSave(rowid,shareduid) { var state; +var cbId="#check_"+rowid+"_"+shareduid; -if($('#check_'+rowid+'_'+shareduid).is(':checked')) +if($(cbId).is(':checked')) { - state = "true"; + state="true"; } -else +else { state ="false"; } $.post(editurlshare, { participant_id: rowid, can_edit: state, shared_uid: shareduid } ); } $(document).ready(function() { -//script for jqGrid +//script for jqGrid if(isadmin == 1) { - var colNames = '["First Name","Last Name","E-Mail","Shared With","shared_uid","Owner","Date Added","Can Edit"]'; - var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false}, - {name:'lastname',index:'lastname', width:60,align:"center",editable:false}, - {name:'email',index:'email', width:130,align:"center",editable:false}, - {name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40}, + var colNames = '["'+firstNameText+'", "'+lastNameText+'", "'+emailText+'", "'+sharedWithText+'", "'+sharedUidText+'", "'+ownerText+'", "'+dateAddedText+'", "'+canEditText+'"]'; + var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false}, + {name:'lastname',index:'lastname', width:60,align:"center",editable:false}, + {name:'email',index:'email', width:130,align:"center",editable:false}, + {name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40}, {name:'shareduid',index:'shareduid',hidden: true,editable:false}, - {name:'Owner',index:'Owner', width:130,align:"center",editable:false,width:40}, - {name:'dateadded',index:'dateadded', width:80,align:"center",editable:false}, + {name:'Owner',index:'Owner', width:130,align:"center",editable:false,width:40}, + {name:'dateadded',index:'dateadded', width:80,align:"center",editable:false}, {name: 'canedit', width: 40, align: 'center', editable: true, formatter: checkboxFormatter, edittype: 'checkbox'}]; } else { - var colNames = '["First Name","Last Name","E-Mail","Shared With","shared_uid","Date Added","Can Edit"]'; - var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false}, - {name:'lastname',index:'lastname', width:60,align:"center",editable:false}, - {name:'email',index:'email', width:130,align:"center",editable:false}, - {name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40}, + var colNames = '["'+firstNameText+'", "'+lastNameText+'", "'+emailText+'", "'+sharedWithText+'", "'+sharedUidText+'", "'+dateAddedText+'", "'+canEditText+'"]'; + var CM = [ {name:'firstname',index:'firstname', width:60,align:"center",editable:false}, + {name:'lastname',index:'lastname', width:60,align:"center",editable:false}, + {name:'email',index:'email', width:130,align:"center",editable:false}, + {name:'sharedwith',index:'sharedwith', width:130,align:"center",editable:false,width:40}, {name:'shareduid',index:'shareduid',hidden: true,editable:false}, - {name:'dateadded',index:'dateadded', width:80,align:"center",editable:false}, + {name:'dateadded',index:'dateadded', width:80,align:"center",editable:false}, {name: 'canedit', width: 40, align: 'center', editable: true, formatter: checkboxFormatter, edittype: 'checkbox'}]; } var lastSel; jQuery("#sharePanel").jqGrid({ -align:"center", -url: shareinfoUrl, -editurl : editurlshare, -datatype: "json", -mtype: "post", -editable : true, -colNames: jQuery.parseJSON(colNames), -colModel: CM, -height: "100%", -width: "100%", -rowNum: 25, -scrollOffset:0, -autowidth: true, -sortname : "firstname", -rowList: [25,50,100,250,500,1000,5000,10000], -multiselect: true, -loadonce: true, -pager: "#pager" + align:"center", + url: shareinfoUrl, + editurl : editurlshare, + datatype: "json", + mtype: "post", + editable : true, + colNames: jQuery.parseJSON(colNames), + colModel: CM, + height: "100%", + width: "100%", + rowNum: 25, + scrollOffset:0, + autowidth: true, + sortname : "firstname", + rowList: [25,50,100,250,500,1000,2000,5000], + multiselect: true, + loadonce: true, + pager: "#pager" }); function checkboxFormatter(cellvalue, options, rowObject) { -cellvalue = cellvalue + ""; -cellvalue = cellvalue.toLowerCase(); -var bchk = cellvalue.search(/(false|0|no|off|n)/i) < 0 ? " checked=\"checked\"" : ""; -/* Adding a name and the shared user id to the checkbox here with the format check_rowId_shared_uid so that in the ajax save function we get the currect selected value instead of the one -provided by custom formatter so that the user can toggle on a single checkbox and still the values are stored at the database. The only thing that can be unique accross the share panel is the row id and share user id*/ - -return "" -} -jQuery('#sharePanel').jqGrid('navGrid','#pager',{add:false,del:true,edit:false}); + cellvalue = cellvalue + ""; + cellvalue = cellvalue.toLowerCase(); + var bchk = cellvalue.search(/(false|0|no|off|n)/i) < 0 ? " checked=\"checked\"" : ""; + /* Adding a name and the shared user id to the checkbox here with the format check_rowId_shared_uid + * so that in the ajax save function we get the currect selected value instead of the one + * provided by custom formatter so that the user can toggle on a single checkbox and still + * the values are stored at the database. The only thing that can be unique accross the + * share panel is the row id and share user id + * */ + return "" +} +jQuery('#sharePanel').jqGrid('navGrid', + '#pager', + {add:false,del:true,edit:false}, + {closeAfterDel: true, + reloadAfterSubmit: true + } + ); $.extend(jQuery.jgrid.edit,{closeAfterAdd: true,reloadAfterSubmit: true,closeOnEspace:true});