/** * delete invite * * @param int $id * @param UserTable $user */ private function deleteInvite( $id, $user ) { global $_CB_framework; $row = new InviteTable(); $row->load( (int) $id ); $returnUrl = $_CB_framework->pluginClassUrl( $this->element, false, array( 'action' => 'groups', 'func' => 'show', 'id' => (int) $row->get( 'group' ) ) ); if ( $row->get( 'id' ) ) { if ( ! CBGroupJive::canAccessGroup( $row->group(), $user ) ) { cbRedirect( $returnUrl, CBTxt::T( 'Group does not exist.' ), 'error' ); } elseif ( $user->get( 'id' ) != $row->get( 'user_id' ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have sufficient permissions to delete this invite.' ), 'error' ); } elseif ( ! CBGroupJive::isModerator( $user->get( 'id' ) ) ) { if ( ( ! $this->params->get( 'groups_invites_display', 1 ) ) && ( $row->group()->get( 'type' ) != 3 ) ) { cbRedirect( $returnUrl, CBTxt::T( 'You do not have access to invites in this group.' ), 'error' ); } } } else { cbRedirect( $returnUrl, CBTxt::T( 'Invite does not exist.' ), 'error' ); } if ( ! $row->canDelete() ) { cbRedirect( $returnUrl, CBTxt::T( 'GROUP_INVITE_FAILED_TO_DELETE', 'Invite failed to delete. Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } if ( ! $row->delete() ) { cbRedirect( $returnUrl, CBTxt::T( 'GROUP_INVITE_FAILED_TO_DELETE', 'Invite failed to delete. Error: [error]', array( '[error]' => $row->getError() ) ), 'error' ); } cbRedirect( $returnUrl, CBTxt::T( 'Invite deleted successfully!' ) ); }