示例#1
0
 /**
  * delete by userId and groupId
  *
  * @action delete
  * @param string $userId
  * @param string $groupId
  */
 function deleteAction($userId, $groupId)
 {
     $partnerId = $this->getPartnerId();
     //verify kuser exists
     $kuser = kuserPeer::getKuserByPartnerAndUid($partnerId, $userId);
     if (!$kuser) {
         throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID, $userId);
     }
     //verify group exists
     $kgroup = kuserPeer::getKuserByPartnerAndUid($partnerId, $groupId);
     if (!$kgroup) {
         //if the delete worker was triggered due to group deletion
         if (kCurrentContext::$master_partner_id != Partner::BATCH_PARTNER_ID) {
             throw new KalturaAPIException(KalturaErrors::GROUP_NOT_FOUND, $groupId);
         }
         kuserPeer::setUseCriteriaFilter(false);
         $kgroup = kuserPeer::getKuserByPartnerAndUid($partnerId, $groupId);
         kuserPeer::setUseCriteriaFilter(true);
         if (!$kgroup) {
             throw new KalturaAPIException(KalturaErrors::GROUP_NOT_FOUND, $groupId);
         }
     }
     $dbKuserKgroup = KuserKgroupPeer::retrieveByKuserIdAndKgroupId($kuser->getId(), $kgroup->getId());
     if (!$dbKuserKgroup) {
         throw new KalturaAPIException(KalturaErrors::GROUP_USER_DOES_NOT_EXIST, $userId, $groupId);
     }
     $dbKuserKgroup->setStatus(KuserKgroupStatus::DELETED);
     $dbKuserKgroup->save();
     $groupUser = new KalturaGroupUser();
     $groupUser->fromObject($dbKuserKgroup);
 }