function remove() { $response = $this->get_response(); $volume_names = $response->html->request()->get($this->identifier_name); $form = $response->form; if ($volume_names !== '') { $submit = $form->get_elements('submit'); $submit->handler = 'onclick="wait();"'; $form->add($submit, 'submit'); $submit = $form->get_elements('cancel'); $submit->handler = 'onclick="cancel();"'; $form->add($submit, 'cancel'); $i = 0; foreach ($volume_names as $ex) { $d['param_f' . $i]['label'] = $ex; $d['param_f' . $i]['object']['type'] = 'htmlobject_input'; $d['param_f' . $i]['object']['attrib']['type'] = 'checkbox'; $d['param_f' . $i]['object']['attrib']['name'] = $this->identifier_name . '[' . $i . ']'; $d['param_f' . $i]['object']['attrib']['value'] = $ex; $d['param_f' . $i]['object']['attrib']['checked'] = true; $i++; } $form->add($d); if (!$form->get_errors() && $response->submit()) { $storage_id = $this->response->html->request()->get('storage_id'); $storage = new storage(); $resource = new resource(); $errors = array(); $message = array(); foreach ($volume_names as $key => $volume_name) { // check if an appliance is still using the volume as an image $image = new image(); $image->get_instance_by_name($volume_name); // check if it is still in use $appliance = new appliance(); $appliances_using_resource = $appliance->get_ids_per_image($image->id); if (count($appliances_using_resource) > 0) { $appliances_using_resource_str = implode(",", $appliances_using_resource[0]); $errors[] = sprintf($this->lang['msg_image_still_in_use'], $volume_name, $image->id, $appliances_using_resource_str); } else { // remove volume $linuxcoe_volume = new linuxcoe_volume(); $linuxcoe_volume->remove_by_name($volume_name); // remove the image of the volume $image->remove_by_name($volume_name); $form->remove($this->identifier_name . '[' . $key . ']'); $message[] = sprintf($this->lang['msg_removed'], $volume_name); } } if (count($errors) === 0) { $response->msg = join('<br>', $message); } else { $msg = array_merge($errors, $message); $response->error = join('<br>', $msg); } } } else { $response->msg = ''; } return $response; }