ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPropertyFormGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Form/classes/class.ilFormGUI.php");
5 
6 // please do not add any more includes here if things are not really
7 // highly re-used
8 include_once("./Services/Form/classes/class.ilFormPropertyGUI.php");
9 include_once("./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
10 include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
11 include_once("./Services/Form/classes/class.ilCustomInputGUI.php");
12 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
13 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
14 include_once("./Services/Form/classes/class.ilImageFileInputGUI.php");
15 include_once('./Services/Form/classes/class.ilFlashFileInputGUI.php');
16 include_once("./Services/Form/classes/class.ilLocationInputGUI.php");
17 include_once("./Services/Form/classes/class.ilRadioGroupInputGUI.php");
18 include_once("./Services/Form/classes/class.ilCheckboxGroupInputGUI.php");
19 include_once("./Services/Form/classes/class.ilFormSectionHeaderGUI.php");
20 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
21 include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php");
22 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
23 include_once("./Services/Form/classes/class.ilDurationInputGUI.php");
24 include_once("./Services/Form/classes/class.ilFeedUrlInputGUI.php");
25 include_once("./Services/Form/classes/class.ilNonEditableValueGUI.php");
26 include_once("./Services/Form/classes/class.ilRegExpInputGUI.php");
27 include_once('./Services/Form/classes/class.ilColorPickerInputGUI.php');
28 include_once('./Services/Form/classes/class.ilPasswordInputGUI.php');
29 include_once('./Services/Form/classes/class.ilUserLoginInputGUI.php');
30 include_once('./Services/Form/classes/class.ilEMailInputGUI.php');
31 include_once('./Services/Form/classes/class.ilHiddenInputGUI.php');
32 include_once('./Services/Form/classes/class.ilNumberInputGUI.php');
33 include_once('./Services/Form/classes/class.ilCSSRectInputGUI.php');
34 include_once('./Services/Form/classes/class.ilRadioMatrixInputGUI.php');
35 include_once('./Services/Form/classes/class.ilTextWizardInputGUI.php');
36 include_once './Services/Form/classes/class.ilFileWizardInputGUI.php';
37 include_once './Services/Form/classes/class.ilFormulaInputGUI.php';
38 include_once './Services/Form/classes/class.ilBirthdayInputGUI.php';
39 
49 {
50  private $buttons = array();
51  private $items = array();
52  protected $mode = "std";
53  protected $check_input_called = false;
54  protected $disable_standard_message = false;
55  protected $top_anchor = "il_form_top";
56  protected $titleicon = false;
57  protected $description = "";
58  protected $tbl_width = false;
59  protected $show_top_buttons = true;
60  protected $reloaded_files;
61 
67  function ilPropertyFormGUI()
68  {
69  global $lng;
70 
71  $lng->loadLanguageModule("form");
73 
74  // do it as early as possible
75  $this->rebuildUploadedFiles();
76  }
77 
81  function &executeCommand()
82  {
83  global $ilCtrl;
84 
85  $next_class = $ilCtrl->getNextClass($this);
86  $cmd = $ilCtrl->getCmd();
87 
88  switch($next_class)
89  {
90  case 'ilformpropertydispatchgui':
91  $ilCtrl->saveParameter($this, 'postvar');
92  include_once './Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
93  $form_prop_dispatch = new ilFormPropertyDispatchGUI();
94  $item = $this->getItemByPostVar($_REQUEST["postvar"]);
95  $form_prop_dispatch->setItem($item);
96  return $ilCtrl->forwardCommand($form_prop_dispatch);
97  break;
98 
99  }
100  return false;
101  }
102 
110  final public function setTableWidth($a_width)
111  {
112  $this->tbl_width = $a_width;
113  }
114 
121  final public function getTableWidth()
122  {
123  return $this->tbl_width;
124  }
125 
131  function setMode($a_mode)
132  {
133  $this->mode = $a_mode;
134  }
135 
141  function getMode()
142  {
143  return $this->mode;
144  }
145 
151  function setTitle($a_title)
152  {
153  $this->title = $a_title;
154  }
155 
161  function getTitle()
162  {
163  return $this->title;
164  }
165 
171  function setTitleIcon($a_titleicon)
172  {
173  $this->titleicon = $a_titleicon;
174  }
175 
181  function getTitleIcon()
182  {
183  return $this->titleicon;
184  }
185 
191  function setDescription($a_val)
192  {
193  $this->description = $a_val;
194  }
195 
201  function getDescription()
202  {
203  return $this->description;
204  }
205 
211  function setTopAnchor($a_val)
212  {
213  $this->top_anchor = $a_val;
214  }
215 
221  function getTopAnchor()
222  {
223  return $this->top_anchor;
224  }
225 
229  public function setShowTopButtons($a_val)
230  {
231  $this->show_top_buttons = $a_val;
232  }
233 
237  public function getShowTopButtons()
238  {
240  }
241 
247  function addItem($a_item)
248  {
249  $a_item->setParentForm($this);
250  return $this->items[] = $a_item;
251  }
252 
258  function removeItemByPostVar($a_post_var)
259  {
260  foreach ($this->items as $key => $item)
261  {
262  if (method_exists($item, "getPostVar") && $item->getPostVar() == $a_post_var)
263  {
264  unset($this->items[$key]);
265  }
266  }
267  }
268 
274  function getItemByPostVar($a_post_var)
275  {
276  foreach ($this->items as $key => $item)
277  {
278  if ($item->getType() != "section_header")
279  {
280  //if ($item->getPostVar() == $a_post_var)
281  $ret = $item->getItemByPostVar($a_post_var);
282  if (is_object($ret))
283  {
284  return $ret;
285  }
286  }
287  }
288 
289  return false;
290  }
291 
297  function setItems($a_items)
298  {
299  $this->items = $a_items;
300  }
301 
307  function getItems()
308  {
309  return $this->items;
310  }
311 
317  function setDisableStandardMessage($a_val)
318  {
319  $this->disable_standard_message = $a_val;
320  }
321 
328  {
330  }
331 
337  function setValuesByArray($a_values)
338  {
339  foreach($this->items as $item)
340  {
341  $item->setValueByArray($a_values);
342  }
343  }
344 
349  function setValuesByPost()
350  {
351  foreach($this->items as $item)
352  {
353  $item->setValueByArray($_POST);
354  }
355  }
356 
363  function checkInput()
364  {
365  global $lng;
366 
367  if ($this->check_input_called)
368  {
369  die ("Error: ilPropertyFormGUI->checkInput() called twice.");
370  }
371 
372  $ok = true;
373  foreach($this->items as $item)
374  {
375  $item_ok = $item->checkInput();
376  if(!$item_ok)
377  {
378  $ok = false;
379  }
380  }
381 
382  // check if POST is missint completely (if post_max_size exceeded)
383  if (count($this->items) > 0 && !is_array($_POST))
384  {
385  $ok = false;
386  }
387 
388  $this->check_input_called = true;
389 
390 
391 
392  // try to keep uploads for another try
393  if(!$ok && $_POST["ilfilehash"] && sizeof($_FILES))
394  {
395  $hash = $_POST["ilfilehash"];
396 
397  foreach($_FILES as $field => $data)
398  {
399  // we support up to 2 nesting levels (see test/assesment)
400  if(is_array($data["tmp_name"]))
401  {
402  foreach($data["tmp_name"] as $idx => $upload)
403  {
404  if(is_array($upload))
405  {
406  foreach($upload as $idx2 => $file)
407  {
408  if($file && is_uploaded_file($file))
409  {
410  $file_name = $data["name"][$idx][$idx2];
411  $file_type = $data["type"][$idx][$idx2];
412  $this->keepFileUpload($hash, $field, $file, $file_name, $file_type, $idx, $idx2);
413  }
414  }
415  }
416  else if($upload && is_uploaded_file($upload))
417  {
418  $file_name = $data["name"][$idx];
419  $file_type = $data["type"][$idx];
420  $this->keepFileUpload($hash, $field, $upload, $file_name, $file_type, $idx);
421  }
422  }
423  }
424  else
425  {
426  $this->keepFileUpload($hash, $field, $data["tmp_name"], $data["name"], $data["type"]);
427  }
428  }
429  }
430 
431 
432  if (!$ok && !$this->getDisableStandardMessage())
433  {
434  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
435  }
436  return $ok;
437  }
438 
449  public function getInput($a_post_var, $ensureValidation = true)
450  {
451  // this check ensures, that checkInput has been called (incl. stripSlashes())
452  if (!$this->check_input_called && $ensureValidation)
453  {
454  die ("Error: ilPropertyFormGUI->getInput() called without calling checkInput() first.");
455  }
456 
457  return $_POST[$a_post_var];
458  }
459 
469  function addCustomProperty($a_title, $a_html, $a_info = "",
470  $a_alert = "", $a_required = false)
471  {
472  $this->properties[] = array ("type" => "custom",
473  "title" => $a_title,
474  "html" => $a_html,
475  "info" => $a_info);
476  }
477 
484  function addCommandButton($a_cmd, $a_text)
485  {
486  $this->buttons[] = array("cmd" => $a_cmd, "text" => $a_text);
487  }
488 
493  {
494  $this->buttons = array();
495  }
496 
500  function getContent()
501  {
502  global $lng, $tpl, $ilUser;
503 
504  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
508 
509  $tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
510  $tpl->addJavaScript("Services/Form/js/Form.js");
511 
512  $this->tpl = new ilTemplate("tpl.property_form.html", true, true, "Services/Form");
513 
514  // check if form has not title and first item is a section header
515  // -> use section header for title and remove section header
516  // -> command buttons are presented on top
517  $fi = $this->items[0];
518  if ($this->getMode() == "std" &&
519  $this->getTitle() == "" &&
520  is_object($fi) && $fi->getType() == "section_header"
521  )
522  {
523  $this->setTitle($fi->getTitle());
524  unset($this->items[0]);
525  }
526 
527 
528  // title icon
529  if ($this->getTitleIcon() != "" && @is_file($this->getTitleIcon()))
530  {
531  $this->tpl->setCurrentBlock("title_icon");
532  $this->tpl->setVariable("IMG_ICON", $this->getTitleIcon());
533  $this->tpl->parseCurrentBlock();
534  }
535 
536  // title
537  if ($this->getTitle() != "")
538  {
539  // commands on top
540  if (count($this->buttons) > 0 && $this->getShowTopButtons())
541  {
542  // command buttons
543  foreach($this->buttons as $button)
544  {
545  $this->tpl->setCurrentBlock("cmd2");
546  $this->tpl->setVariable("CMD", $button["cmd"]);
547  $this->tpl->setVariable("CMD_TXT", $button["text"]);
548  $this->tpl->parseCurrentBlock();
549  }
550  $this->tpl->setCurrentBlock("commands2");
551  $this->tpl->parseCurrentBlock();
552  }
553 
554  $this->tpl->setCurrentBlock("header");
555  $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
556  $this->tpl->setVariable("LABEL", $this->getTopAnchor());
557  $this->tpl->setVariable("TXT_DESCRIPTION", $this->getDescription());
558  $this->tpl->parseCurrentBlock();
559  }
560  $this->tpl->touchBlock("item");
561 
562  // properties
563  $this->required_text = false;
564  foreach($this->items as $item)
565  {
566  if ($item->getType() != "hidden")
567  {
568  $this->insertItem($item);
569  }
570  }
571 
572  // required
573  if ($this->required_text && $this->getMode() == "std")
574  {
575  $this->tpl->setCurrentBlock("required_text");
576  $this->tpl->setVariable("TXT_REQUIRED", $lng->txt("required_field"));
577  $this->tpl->parseCurrentBlock();
578  }
579 
580  // command buttons
581  foreach($this->buttons as $button)
582  {
583  $this->tpl->setCurrentBlock("cmd");
584  $this->tpl->setVariable("CMD", $button["cmd"]);
585  $this->tpl->setVariable("CMD_TXT", $button["text"]);
586  $this->tpl->parseCurrentBlock();
587  }
588 
589  // try to keep uploads even if checking input fails
590  if($this->getMultipart())
591  {
592  $hash = $_POST["ilfilehash"];
593  if(!$hash)
594  {
595  $hash = md5(uniqid(mt_rand(), true));
596  }
597  $fhash = new ilHiddenInputGUI("ilfilehash");
598  $fhash->setValue($hash);
599  $this->addItem($fhash);
600  }
601 
602  // hidden properties
603  $hidden_fields = false;
604  foreach($this->items as $item)
605  {
606  if ($item->getType() == "hidden")
607  {
608  $item->insert($this->tpl);
609  $hidden_fields = true;
610  }
611  }
612 
613  if ($this->required_text || count($this->buttons) > 0 || $hidden_fields)
614  {
615  $this->tpl->setCurrentBlock("commands");
616  $this->tpl->parseCurrentBlock();
617  }
618 
619 
620  if ($this->getMode() == "subform")
621  {
622  $this->tpl->touchBlock("sub_table");
623  }
624  else
625  {
626  $this->tpl->touchBlock("std_table");
627  $this->tpl->setVariable('STD_TABLE_WIDTH',$this->getTableWidth());
628  }
629 
630  return $this->tpl->get();
631  }
632 
633  function insertItem($item, $a_sub_item = false)
634  {
635  global $tpl, $lng;
636 
637  if(method_exists($item, "getMulti") && $item->getMulti())
638  {
639  $tpl->addJavascript("./Services/Form/js/ServiceFormMulti.js");
640 
641  $this->tpl->setCurrentBlock("multi_in");
642  $this->tpl->setVariable("ID", $item->getFieldId());
643  $this->tpl->parseCurrentBlock();
644 
645  $this->tpl->touchBlock("multi_out");
646 
647 
648  // add hidden item to enable preset multi items
649  $multi_values = $item->getMultiValues();
650  if(is_array($multi_values) && sizeof($multi_values) > 1)
651  {
652  $multi_value = new ilHiddenInputGUI("ilMultiValues~".$item->getPostVar());
653  $multi_value->setValue(implode("~", $multi_values));
654  $this->addItem($multi_value);
655  }
656  }
657 
658  $item->insert($this->tpl);
659 
660  if ($item->getType() == "file" || $item->getType() == "image_file")
661  {
662  $this->setMultipart(true);
663  }
664 
665  if ($item->getType() != "section_header")
666  {
667  // info text
668  if ($item->getInfo() != "")
669  {
670  $this->tpl->setCurrentBlock("description");
671  $this->tpl->setVariable("PROPERTY_DESCRIPTION",
672  $item->getInfo());
673  $this->tpl->parseCurrentBlock();
674  }
675 
676  if ($this->getMode() == "subform")
677  {
678  // required
679  if ($item->getType() != "non_editable_value")
680  {
681  if ($item->getRequired())
682  {
683  $this->tpl->touchBlock("sub_required");
684  $this->required_text = true;
685  }
686  }
687 
688  // hidden title (for accessibility, e.g. file upload)
689  if ($item->getHiddenTitle() != "")
690  {
691  $this->tpl->setCurrentBlock("sub_hid_title");
692  $this->tpl->setVariable("SPHID_TITLE",
693  $item->getHiddenTitle());
694  $this->tpl->parseCurrentBlock();
695  }
696 
697  $this->tpl->setCurrentBlock("sub_prop_start");
698  $this->tpl->setVariable("PROPERTY_TITLE", $item->getTitle());
699  if ($item->getType() != "non_editable_value")
700  {
701  $this->tpl->setVariable("LAB_ID", $item->getFieldId());
702  }
703  $this->tpl->parseCurrentBlock();
704  }
705  else
706  {
707  // required
708  if ($item->getType() != "non_editable_value")
709  {
710  if ($item->getRequired())
711  {
712  $this->tpl->touchBlock("required");
713  $this->required_text = true;
714  }
715  }
716 
717  // hidden title (for accessibility, e.g. file upload)
718  if ($item->getHiddenTitle() != "")
719  {
720  $this->tpl->setCurrentBlock("std_hid_title");
721  $this->tpl->setVariable("PHID_TITLE",
722  $item->getHiddenTitle());
723  $this->tpl->parseCurrentBlock();
724  }
725 
726  $this->tpl->setCurrentBlock("std_prop_start");
727  $this->tpl->setVariable("PROPERTY_TITLE", $item->getTitle());
728  if ($item->getType() != "non_editable_value")
729  {
730  $this->tpl->setVariable("LAB_ID", $item->getFieldId());
731  }
732  $this->tpl->parseCurrentBlock();
733  }
734 
735  // alert
736  if ($item->getType() != "non_editable_value" && $item->getAlert() != "")
737  {
738  $this->tpl->setCurrentBlock("alert");
739  $this->tpl->setVariable("IMG_ALERT",
740  ilUtil::getImagePath("icon_alert_s.png"));
741  $this->tpl->setVariable("ALT_ALERT",
742  $lng->txt("alert"));
743  $this->tpl->setVariable("TXT_ALERT",
744  $item->getAlert());
745  $this->tpl->parseCurrentBlock();
746  }
747 
748  // subitems
749  $sf = null;
750  if ($item->getType() != "non_editable_value" or 1)
751  {
752  $sf = $item->getSubForm();
753  if ($item->hideSubForm() && is_object($sf))
754  {
755  $this->tpl->setCurrentBlock("sub_form_hide");
756  $this->tpl->setVariable("DSFID", $item->getFieldId());
757  $this->tpl->parseCurrentBlock();
758  }
759  }
760 
761 
762  $sf_content = "";
763  if (is_object($sf))
764  {
765  $sf_content = $sf->getContent();
766  if ($sf->getMultipart())
767  {
768  $this->setMultipart(true);
769  }
770  $this->tpl->setCurrentBlock("sub_form");
771  $this->tpl->setVariable("PROP_SUB_FORM", $sf_content);
772  $this->tpl->setVariable("SFID", $item->getFieldId());
773  $this->tpl->parseCurrentBlock();
774  }
775 
776  $this->tpl->setCurrentBlock("prop");
777 
778  $this->tpl->parseCurrentBlock();
779  }
780 
781  $this->tpl->touchBlock("item");
782  }
783 
784 
785  //
786  // UPLOAD HANDLING
787  //
788 
801  protected function keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index = null, $a_sub_index = null)
802  {
803  global $ilUser;
804 
805  $user_id = $ilUser->getId();
806  if(!$user_id || $user_id == ANONYMOUS_USER_ID)
807  {
808  return;
809  }
810 
811  $a_name = ilUtil::getAsciiFileName($a_name);
812 
813  $tmp_file_name = implode("~~", array($user_id,
814  $a_hash,
815  $a_field,
816  $a_index,
817  $a_sub_index,
818  str_replace("/", "~~", $a_type),
819  str_replace("~~", "_", $a_name)));
820 
821  // make sure temp directory exists
822  $temp_path = ilUtil::getDataDir() . "/temp";
823  if (!is_dir($temp_path))
824  {
825  ilUtil::createDirectory($temp_path);
826  }
827 
828  move_uploaded_file($a_tmp_name, $temp_path."/".$tmp_file_name);
829  }
830 
839  function getFileUpload($a_field, $a_index = null, $a_sub_index = null)
840  {
841  $res = array();
842  if($a_index)
843  {
844  if($_FILES[$a_field]["tmp_name"][$a_index][$a_sub_index])
845  {
846  $res = array(
847  "tmp_name" => $_FILES[$a_field]["tmp_name"][$a_index][$a_sub_index],
848  "name" => $_FILES[$a_field]["name"][$a_index][$a_sub_index],
849  "type" => $_FILES[$a_field]["type"][$a_index][$a_sub_index],
850  "error" => $_FILES[$a_field]["error"][$a_index][$a_sub_index],
851  "size" => $_FILES[$a_field]["size"][$a_index][$a_sub_index],
852  "is_upload" => true
853  );
854  }
855  else if($this->reloaded_files[$a_field]["tmp_name"][$a_index][$a_sub_index])
856  {
857  $res = array(
858  "tmp_name" => $this->reloaded_files["tmp_name"][$a_index][$a_sub_index],
859  "name" => $this->reloaded_files["name"][$a_index][$a_sub_index],
860  "type" => $this->reloaded_files["type"][$a_index][$a_sub_index],
861  "error" => $this->reloaded_files["error"][$a_index][$a_sub_index],
862  "size" => $this->reloaded_files["size"][$a_index][$a_sub_index],
863  "is_upload" => false
864  );
865  }
866  }
867  else if($a_sub_index)
868  {
869  if($_FILES[$a_field]["tmp_name"][$a_index])
870  {
871  $res = array(
872  "tmp_name" => $_FILES[$a_field]["tmp_name"][$a_index],
873  "name" => $_FILES[$a_field]["name"][$a_index],
874  "type" => $_FILES[$a_field]["type"][$a_index],
875  "error" => $_FILES[$a_field]["error"][$a_index],
876  "size" => $_FILES[$a_field]["size"][$a_index],
877  "is_upload" => true
878  );
879  }
880  else if($this->reloaded_files[$a_field]["tmp_name"][$a_index])
881  {
882  $res = array(
883  "tmp_name" => $this->reloaded_files[$a_field]["tmp_name"][$a_index],
884  "name" => $this->reloaded_files[$a_field]["name"][$a_index],
885  "type" => $this->reloaded_files[$a_field]["type"][$a_index],
886  "error" => $this->reloaded_files[$a_field]["error"][$a_index],
887  "size" => $this->reloaded_files[$a_field]["size"][$a_index],
888  "is_upload" => false
889  );
890  }
891  }
892  else
893  {
894  if($_FILES[$a_field]["tmp_name"])
895  {
896  $res = array(
897  "tmp_name" => $_FILES[$a_field]["tmp_name"],
898  "name" => $_FILES[$a_field]["name"],
899  "type" => $_FILES[$a_field]["type"],
900  "error" => $_FILES[$a_field]["error"],
901  "size" => $_FILES[$a_field]["size"],
902  "is_upload" => true
903  );
904  }
905  else if($this->reloaded_files[$a_field]["tmp_name"])
906  {
907  $res = array(
908  "tmp_name" => $this->reloaded_files[$a_field]["tmp_name"],
909  "name" => $this->reloaded_files[$a_field]["name"],
910  "type" => $this->reloaded_files[$a_field]["type"],
911  "error" => $this->reloaded_files[$a_field]["error"],
912  "size" => $this->reloaded_files[$a_field]["size"],
913  "is_upload" => false
914  );
915  }
916  }
917  return $res;
918  }
919 
928  function hasFileUpload($a_field, $a_index = null, $a_sub_index = null)
929  {
930  $data = $this->getFileUpload($a_field, $a_index, $a_sub_index);
931  return (bool)$data["tmp_name"];
932  }
933 
944  function moveFileUpload($a_target_directory, $a_field, $a_target_name = null, $a_index = null, $a_sub_index = null)
945  {
946  if(!is_dir($a_target_directory))
947  {
948  return;
949  }
950 
951  $data = $this->getFileUpload($a_field, $a_index, $a_sub_index);
952  if($data["tmp_name"] && file_exists($data["tmp_name"]))
953  {
954  if($a_target_name)
955  {
956  $data["name"] = $a_target_name;
957  }
958 
959  $target_file = $a_target_directory."/".$data["name"];
960  $target_file = str_replace("//", "/", $target_file);
961 
962  if($data["is_upload"])
963  {
964  if (!move_uploaded_file($data["tmp_name"], $target_file))
965  {
966  return;
967  }
968  }
969  else
970  {
971  if (!rename($data["tmp_name"], $target_file))
972  {
973  return;
974  }
975  }
976 
977  return $target_file;
978  }
979  }
980 
984  protected function rebuildUploadedFiles()
985  {
986  global $ilUser;
987 
988  if($_POST["ilfilehash"])
989  {
990  $user_id = $ilUser->getId();
991  $temp_path = ilUtil::getDataDir() . "/temp";
992  if(is_dir($temp_path) && $user_id && $user_id != ANONYMOUS_USER_ID)
993  {
994  $reload = array();
995 
996  $temp_files = glob($temp_path."/".$ilUser->getId()."~~".$_POST["ilfilehash"]."~~*");
997  if(is_array($temp_files))
998  {
999  foreach($temp_files as $full_file)
1000  {
1001  $file = explode("~~", basename($full_file));
1002  $field = $file[2];
1003  $idx = $file[3];
1004  $idx2 = $file[4];
1005  $type = $file[5]."/".$file[6];
1006  $name = $file[7];
1007 
1008  if($idx2 != "")
1009  {
1010  if(!$_FILES[$field]["tmp_name"][$idx][$idx2])
1011  {
1012  $reload[$field]["tmp_name"][$idx][$idx2] = $full_file;
1013  $reload[$field]["name"][$idx][$idx2] = $name;
1014  $reload[$field]["type"][$idx][$idx2] = $type;
1015  $reload[$field]["error"][$idx][$idx2] = 0;
1016  $reload[$field]["size"][$idx][$idx2] = filesize($full_file);
1017  }
1018  }
1019  else if($idx != "")
1020  {
1021  if(!$_FILES[$field]["tmp_name"][$idx])
1022  {
1023  $reload[$field]["tmp_name"][$idx] = $full_file;
1024  $reload[$field]["name"][$idx] = $name;
1025  $reload[$field]["type"][$idx] = $type;
1026  $reload[$field]["error"][$idx] = 0;
1027  $reload[$field]["size"][$idx] = filesize($full_file);
1028  }
1029  }
1030  else
1031  {
1032  if(!$_FILES[$field]["tmp_name"])
1033  {
1034  $reload[$field]["tmp_name"] = $full_file;
1035  $reload[$field]["name"] = $name;
1036  $reload[$field]["type"] = $type;
1037  $reload[$field]["error"] = 0;
1038  $reload[$field]["size"] = filesize($full_file);
1039  }
1040  }
1041  }
1042  }
1043 
1044  $this->reloaded_files = $reload;
1045  }
1046  }
1047  }
1048 }
1049 
1050 ?>