예제 #1
0
 /**
  * Handle any upload/deletion requests.
  */
 public function handle_form_action()
 {
     // First, we shall handle the items already attached
     $attachments = $this->get_filtered_request_data();
     $attached_ids = array_keys($attachments);
     // Query the ones we must
     $to_query = array_diff($attached_ids, $this->operator->get_all_ids());
     if (!empty($to_query)) {
         $this->operator->load($to_query, true);
     }
     $uploader_key = $this->request->header('X-PLUPLOAD_KEY', '');
     $uploader_key = $uploader_key ?: $this->request->variable('uploader_key', '');
     // Do not perform any actions without a valid key.
     if (!check_link_hash($uploader_key, 'uploader_key')) {
         return;
     }
     // Next, delete those requested
     $delete_indices = $this->request->variable('delete_file', array(0 => 0));
     if ($delete_indices) {
         $this->handle_delete($delete_indices);
     }
     // set requested attachment as preview
     $preview = $this->request->variable('set_preview_file' . $this->object_type, 0);
     if ($preview) {
         $this->operator->set_preview($preview);
     }
     if ($this->request->is_set($this->form_name, request_interface::FILES)) {
         $this->handle_upload();
     }
 }