new: [internal] Added convenience method to find the ID of an SG via it's UUID

pull/3345/head^2
iglocska 2018-06-17 23:35:38 +02:00
parent 2828b6f40a
commit cfba36dba5
1 changed files with 13 additions and 0 deletions

View File

@ -653,4 +653,17 @@ class SharingGroup extends AppModel {
if (empty($sg)) return false;
return $sg[0];
}
public function getSharingGroupIdByUuid($user, $data) {
$sg = $this->find('first', array(
'conditions' => array('SharingGroup.uuid' => $data['sharing_group_id']),
'recursive' => -1,
'fields' => array('SharingGroup.id')
));
if (!empty($sg) && $this->checkIfAuthorised($user, $sg['SharingGroup']['id'])) {
$data['sharing_group_id'] = $sg['SharingGroup']['id'];
return $data;
}
return false;
}
}