Skip to content

Commit

Permalink
Exclude current user from UserPicker search
Browse files Browse the repository at this point in the history
  • Loading branch information
andystrobel committed Apr 25, 2014
1 parent 0c5d037 commit 49e1c53
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion protected/modules_core/user/resources/userpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $.fn.userpicker = function (options) {
currentValue: "",
renderType: "normal", // possible values are "normal", "partial"
focus: false,
userGuid: "",
placeholderText: 'Add an user'
}, options);

Expand Down Expand Up @@ -234,7 +235,7 @@ $.fn.userpicker = function (options) {
var _takenData = false;

// set options to link, that this entry is already taken or not available
if ($('#' + uniqueID + '_' + json[i].guid).length != 0 || json[i].isMember == true) {
if ($('#' + uniqueID + '_' + json[i].guid).length != 0 || json[i].isMember == true || json[i].guid == options.userGuid) {
_takenStyle = "opacity: 0.4;"
_takenData = true;
}
Expand Down
8 changes: 8 additions & 0 deletions protected/modules_core/user/widgets/UserPickerWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class UserPickerWidget extends HWidget {
*/
public $maxUsers = 50;

/**
* Set guid for the current user
*
* @var type string
*/
public $userGuid = "";

/**
* Set focus to input or not
*
Expand Down Expand Up @@ -108,6 +115,7 @@ public function run() {
'currentValue' => $currentValue,
'inputId' => $this->inputId,
'focus' => $this->focus,
'userGuid' => $this->userGuid,
'placeholderText' => $this->placeholderText,
));
}
Expand Down
3 changes: 2 additions & 1 deletion protected/modules_core/user/widgets/views/userPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
maxUsers: '<?php echo $maxUsers; ?>',
searchUrl: '<?php echo $userSearchUrl; ?>',
currentValue: '<?php echo $newValue; ?>',
focus:'<?php echo $focus ?>',
focus:'<?php echo $focus; ?>',
userGuid:'<?php echo $userGuid; ?>',
placeholderText:'<?php echo $placeholderText; ?>'
});
});
Expand Down
1 change: 1 addition & 0 deletions protected/modules_core/wall/widgets/views/contentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'inputId' => 'notifiyUserInput',
'userSearchUrl' => $this->createUrl($user_url, array('sguid' => $this->contentContainer->guid, 'keyword' => '-keywordPlaceholder-')),
'maxUsers' => 10,
'userGuid' => Yii::app()->user->guid,
'placeholderText' => Yii::t('WallModule.base', 'Add a member to notify'),
'focus' => true,
));
Expand Down

0 comments on commit 49e1c53

Please sign in to comment.