The submodule "privatemsg_groups" supplies the permission "Write private messages to all organic groups". Users with this permission only can send public messages to all public groups. If the organic groups submodule "og_access" is enabled and there are some private groups, user with the permission "Write private messages to all organic groups" can not send to messages to this private groups.
I wrote a patch which adds a new permission: "Write private messages to all organic groups (public and private groups)"
if (module_exists('og_access')) {
$permissions['write privatemsg to all private organic groups'] = array(
'title' => t('Write private messages to all organic groups (public and private groups)'),
'description' => t('Allows to write messages to all users which belong to a public or a private organic group.'),
'warning' => t('This permission allows users to view the title and the members of all private groups.'),
);
In my patch I added two functions, which are a replacement of the organic group function og_get_all_group
. og_get_all_group
only returns the groups ids of users own groups and all public groups.
/**
* Return all organic groups.
*
* @return array
* A array of groups IDs ($gids).
*/
function privatemsg_groups_get_all_groups() {
$get_all_groups = 'og_get_all_group';
if (module_exists('og_access') && user_access('write privatemsg to all private organic groups')) {
$get_all_groups = '_privatemsg_groups_get_all_private_groups';
}
return $get_all_groups();
}
/**
* Return all existing private and public groups.
*
* @return array
* A array of groups IDs ($gids).
*/
function _privatemsg_groups_get_all_private_groups() {
if (!field_info_field(OG_GROUP_FIELD)) {
return array();
}
$query = db_select('field_data_' . OG_GROUP_FIELD, 'f')
->fields('f',array('entity_id'))
->condition('f.' . OG_GROUP_FIELD . '_value', 1);
$result = $query->execute()
->fetchAllAssoc('entity_id');
return !empty($result) ? array_keys($result) : array();
}
Is there a possibility to add this permission to the 2.x dev branch?
Comment | File | Size | Author |
---|---|---|---|
#2 | send-to-all-private-groups-2105031-2.patch | 3.53 KB | JosefFriedrich |
#1 | send-to-all-private-groups-2105031-1.patch | 3.04 KB | JosefFriedrich |
Comments
Comment #1
JosefFriedrich CreditAttribution: JosefFriedrich commentedThe patch as described above:
Comment #2
JosefFriedrich CreditAttribution: JosefFriedrich commentedBetter patch then #1 (Fix some erorrs)
Comment #3
ptmkenny CreditAttribution: ptmkenny commentedComment #3.0
ptmkenny CreditAttribution: ptmkenny commentedAdd some text
Comment #4
ivnish CreditAttribution: ivnish commented