Skip to content

Commit

Permalink
Fixed issue #09461: share a participant without selecting a user
Browse files Browse the repository at this point in the history
Dev public participants in CPDB: allows sharing a participant with all the users
  • Loading branch information
gmambro committed Feb 16, 2016
1 parent a70ffe1 commit f7f014e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
27 changes: 23 additions & 4 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -315,10 +315,17 @@ function getShareInfo_json()

foreach ($records as $row)
{
$oShared = User::model()->getName($row['share_uid']); //for conversion of uid to human readable names
//for conversion of uid to human readable names
$iShareUserId = $row['share_uid'];
if ($iShareUserId != 0) {
$oShared = User::model()->getName($iShareUserId);
$sSharename = $oShared[0]['full_name'];
} else {
$sSharename = 'All users';
}
$owner = User::model()->getName($row['owner_uid']);
$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']);
$aData->rows[$i]['cell'] = array($row['firstname'], $row['lastname'], $row['email'], $sSharename, $row['share_uid'], $owner[0]['full_name'], $row['date_added'], $row['can_edit']);
$i++;
}

Expand All @@ -334,9 +341,15 @@ function getShareInfo_json()

foreach ($records as $row)
{
$sharename = User::model()->getName($row['share_uid']); //for conversion of uid to human readable names
$iShareUserId = $row['share_uid'];//for conversion of uid to human readable names
if ($iShareUserId != 0) {
$oShared = User::model()->getName($iShareUserId);
$sSharename = $oShared[0]['full_name'];
} else {
$sSharename = 'All users';
}
$aData->rows[$i]['id'] = $row['participant_id'];
$aData['rows'][$i]['cell'] = array($row['firstname'], $row['lastname'], $row['email'], $sharename['full_name'], $row['share_uid'], $row['date_added'], $row['can_edit']);
$aData['rows'][$i]['cell'] = array($row['firstname'], $row['lastname'], $row['email'], $sSharename, $row['share_uid'], $row['date_added'], $row['can_edit']);
$i++;
}

Expand Down Expand Up @@ -1458,6 +1471,12 @@ function shareParticipants()
$iParticipantId = Yii::app()->request->getPost('participantid');
$iShareUserId = Yii::app()->request->getPost('shareuser');
$bCanEdit = Yii::app()->request->getPost('can_edit');

// Some input validation needed
if ($iShareUserId == '') {
printf($clang->gT("Please select a user"));
return;
}

$i = 0;
if (Permission::model()->hasGlobalPermission('participantpanel','update') && $iShareUserId>0)
Expand Down
4 changes: 2 additions & 2 deletions application/models/Participant.php
Expand Up @@ -322,7 +322,7 @@ private function getParticipantsSelectCommand($count = false, $attid, $search =
// We are not superadmin so we need to limit to our own or shared with us
$selectValue[] = '{{participant_shares}}.can_edit';
$joinValue[] = 'LEFT JOIN {{participant_shares}} ON p.participant_id={{participant_shares}}.participant_id';
$aConditions[] = 'p.owner_uid = :userid1 OR {{participant_shares}}.share_uid = :userid2';
$aConditions[] = 'p.owner_uid = :userid1 OR {{participant_shares}}.share_uid = :userid2 OR {{participant_shares}}.share_uid = 0';
}

if ($count) {
Expand Down Expand Up @@ -914,7 +914,7 @@ function is_owner($participant_id)
->db
->createCommand()
->select('count(*)')
->where('participant_id = :participant_id AND share_uid = :userid')
->where('participant_id = :participant_id AND ( share_uid = :userid oOR share_uid = 0)')
->from('{{participant_shares}}')
->bindParam(":participant_id", $participant_id, PDO::PARAM_STR)
->bindParam(":userid", $userid, PDO::PARAM_INT)
Expand Down
Expand Up @@ -254,7 +254,10 @@
<?php eT("User with whom the participants are to be shared"); ?></p>
<p>
<?php

$options[''] = gT("Select...");
$options[0] = gT("All users");

foreach ($names as $row)
{
if (!(Yii::app()->session['loginID'] == $row['uid']))
Expand Down

0 comments on commit f7f014e

Please sign in to comment.