* distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
session_start();
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/../lib/AAB/AABService.php';
require_once __DIR__ . '/../lib/AAB/PaginationParameters.php';
use Att\Api\AAB\AABService;
use Att\Api\AAB\PaginationParameters;
$arr = null;
try {
    envinit();
    $aabService = new AABService(getFqdn(), getSessionToken());
    $gid = $_POST['removeContactsGroupId'];
    if ($gid === '') {
        throw new Exception('Group Id must not be empty');
    }
    $cids = $_POST['removeContactIds'];
    if ($cids === '') {
        throw new Exception('Contact Ids must not be empty');
    }
    $cids = explode(",", $cids);
    $aabService->removeContactsFromGroup($gid, $cids);
    $arr = array('success' => true, 'text' => 'Successfully removed contacts from group.');
} catch (Exception $e) {
    $arr = array('success' => false, 'text' => $e->getMessage());
}
echo json_encode($arr);
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 private function _handleRemoveContactsFromGroup()
 {
     $vnames = array('removeContactsFromGroup', 'groupId', 'contactIds');
     $this->copyToSession($vnames);
     if (!isset($_SESSION['removeContactsFromGroup'])) {
         return;
     }
     $gid = $_SESSION['groupId'];
     $cids = $_SESSION['contactIds'];
     $cids = explode(",", $cids);
     try {
         $aabSrvc = new AABService($this->apiFQDN, $this->getSessionToken());
         $aabSrvc->removeContactsFromGroup($gid, $cids);
         $this->results[C_REMOVE_CONTACTS_FROM_GROUP] = true;
         $this->clearSession($vnames);
     } catch (Exception $e) {
         $this->errors[C_MANAGE_GROUPS_ERROR] = $e->getMessage();
         $this->clearSession($vnames);
     }
 }