ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjFileGUI Class Reference

GUI class for file objects. More...

+ Inheritance diagram for ilObjFileGUI:
+ Collaboration diagram for ilObjFileGUI:

Public Member Functions

 getType ()
 
 _forwards ()
 
 executeCommand ()
 
 initSingleUploadForm ()
 FORM: Init single upload form. More...
 
 save ()
 save object More...
 
 saveAndMeta ()
 save object More...
 
 initZipUploadForm ($a_mode="create")
 FORM: Init zip upload form. More...
 
 saveUnzip ()
 saveUnzip object More...
 
 update ()
 updates object entry in object_data More...
 
 edit ()
 edit object More...
 
 sendFile ()
 
 versions ()
 file versions/history More...
 
 infoScreen ()
 this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually, if everything works through ilCtrl in the future this may be changed More...
 
 infoScreenForward ()
 show information screen More...
 
 setTabs ()
 
 addLocatorItems ()
 
 initMultiUploadForm ()
 Initializes the upload form for multiple files. More...
 
 uploadFiles ()
 Called after a file was uploaded. More...
 
 deleteVersions ()
 Displays a confirmation screen with selected file versions that should be deleted. More...
 
 confirmDeleteVersions ()
 Deletes the file versions that were confirmed by the user. More...
 
 cancelDeleteVersions ()
 Cancels the file version deletion. More...
 
 confirmDeleteFile ()
 Deletes this file object. More...
 
 cancelDeleteFile ()
 Cancels the file deletion. More...
 
 compareHistoryIds ($v1, $v2)
 Compares two versions either by passing a history entry or an id. More...
 
 rollbackVersion ()
 Performs a rollback with the selected file version. More...
 
- Public Member Functions inherited from ilObject2GUI
 __construct ($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
 Constructor. More...
 
executeCommand ()
 execute command More...
 
 delete ()
 Display delete confirmation form (repository/workspace switch) More...
 
 confirmedDelete ()
 Delete objects (repository/workspace switch) More...
 
 getHTML ()
 
 withReferences ()
 Final/Private declaration of unchanged parent methods. More...
 
 setCreationMode ($a_mode=true)
 
 getCreationMode ()
 
 isVisible ()
 
 trash ()
 
 undelete ()
 
 cancelDelete ()
 
 removeFromSystem ()
 
 cloneAll ()
 
 view ()
 view object content (repository/workspace switch) More...
 
 getType ()
 Functions that must be overwritten. More...
 
 create ()
 Deleted in ilObject. More...
 
 save ()
 
 edit ()
 
 update ()
 
 cancel ()
 
 importFile ()
 Import. More...
 
- Public Member Functions inherited from ilObjectGUI
 ilObjectGUI ($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
 Constructor public. More...
 
executeCommand ()
 execute command More...
 
 withReferences ()
 determines wether objects are referenced or not (got ref ids or not) More...
 
 setCreationMode ($a_mode=true)
 if true, a creation screen is displayed the current $_GET[ref_id] don't belong to the current class! the mode is determined in ilrepositorygui More...
 
 getCreationMode ()
 get creation mode More...
 
 getAdminTabs (&$tabs_gui)
 administration tabs show only permissions and trash folder More...
 
 getHTML ()
 
 confirmedDeleteObject ()
 confirmed deletion of object -> objects are moved to trash or deleted immediately, if trash is disabled More...
 
 cancelDeleteObject ()
 cancel deletion of object More...
 
 cancelObject ($in_rep=false)
 cancel action and go back to previous page public More...
 
 createObject ()
 create new object form More...
 
 cancelCreation ()
 cancel create action and go back to repository parent More...
 
 saveObject ()
 save object More...
 
 editObject ()
 edit object More...
 
 updateObject ()
 updates object entry in object_data More...
 
 getFormAction ($a_cmd, $a_formaction="")
 get form action for command (command is method name without "Object", e.g. More...
 
 isVisible ($a_ref_id, $a_type)
 
 viewObject ()
 list childs of current object More...
 
 deleteObject ($a_error=false)
 Display deletion confirmation screen. More...
 
 cloneAllObject ()
 Clone single (not container object) Method is overwritten in ilContainerGUI. More...
 

Static Public Member Functions

static _goto ($a_target, $a_additional=null)
 
- Static Public Member Functions inherited from ilObject2GUI
static handleAfterSaveCallback (ilObject $a_obj, $a_callback_ref_id)
 After creation callback. More...
 
- Static Public Member Functions inherited from ilObjectGUI
static _gotoRepositoryRoot ($a_raise_error=false)
 Goto repository root. More...
 
static _gotoRepositoryNode ($a_ref_id, $a_cmd="frameset")
 Goto repository root. More...
 

Protected Member Functions

 initCreationForms ()
 
 initPropertiesForm ()
 
 handleFileUpload ($file_upload)
 Handles the upload of a single file and adds it to the parent object. More...
 
 initHeaderAction ($a_sub_type=null, $a_sub_id=null)
 
- Protected Member Functions inherited from ilObject2GUI
 afterConstructor ()
 Do anything that should be done after constructor in here. More...
 
 assignObject ()
 create object instance as internal property (repository/workspace switch) More...
 
 getAccessHandler ()
 Get access handler. More...
 
 setLocator ()
 set Locator More...
 
 deleteConfirmation ()
 Display delete confirmation form (workspace specific) More...
 
 deleteConfirmedObjects ()
 Delete objects (workspace specific) More...
 
 prepareOutput ()
 
 setTitleAndDescription ()
 
 showUpperIcon ()
 
 omitLocator ($a_omit=true)
 
 getTargetFrame ($a_cmd, $a_target_frame="")
 
 setTargetFrame ($a_cmd, $a_target_frame)
 
 getCenterColumnHTML ()
 
 getRightColumnHTML ()
 
 setColumnSettings ($column_gui)
 
 checkPermission ($a_perm, $a_cmd="")
 
 showPossibleSubObjects ()
 
 redirectToRefId ()
 
 fillCloneTemplate ($a_tpl_varname, $a_type)
 
 fillCloneSearchTemplate ($a_tpl_varname, $a_type)
 
 searchCloneSource ()
 
 buildCloneSelect ($existing_objs)
 
 addAdminLocatorItems ()
 
 setTabs ()
 create tabs (repository/workspace switch) More...
 
 getReturnLocation ()
 Deprecated functions. More...
 
 setReturnLocation ()
 
 showActions ()
 
 getTitlesByRefId ()
 
 getTabs ()
 
 __showButton ()
 
 hitsperpageObject ()
 
 __initTableGUI ()
 
 __setTableGUIBasicData ()
 
 addLocatorItems ()
 Functions to be overwritten. More...
 
 initCreationForms ($a_new_type)
 Init creation froms. More...
 
 putObjectInTree (ilObject $a_obj, $a_parent_node_id=null)
 Add object to tree at given position. More...
 
 checkPermissionBool ($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
 Check permission. More...
 
 initHeaderAction ($a_sub_type=null, $a_sub_id=null)
 Add header action menu. More...
 
 redrawHeaderAction ()
 Updating icons after ajax call. More...
 
 getPermanentLinkWidget ($a_append=null, $a_center=false)
 
 handleAutoRating (ilObject $a_new_obj)
 
- Protected Member Functions inherited from ilObjectGUI
 assignObject ()
 
 prepareOutput ()
 prepare output More...
 
 setTitleAndDescription ()
 called by prepare output More...
 
 initHeaderAction ($a_sub_type=null, $a_sub_id=null)
 Add header action menu. More...
 
 insertHeaderAction ($a_list_gui)
 Insert header action into main template. More...
 
 addHeaderAction ()
 Add header action menu. More...
 
 redrawHeaderActionObject ()
 Ajax call: redraw action header only. More...
 
 showMountWebfolderIcon ()
 
 setTabs ()
 set admin tabs public More...
 
 setAdminTabs ()
 set admin tabs public More...
 
 setLocator ()
 set Locator More...
 
 addLocatorItems ()
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 omitLocator ($a_omit=true)
 
 addAdminLocatorItems ($a_do_not_add_object=false)
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 initCreationForms ($a_new_type)
 Init creation froms. More...
 
 getCreationFormsHTML (array $a_forms)
 Get HTML for creation forms (accordion) More...
 
 initCreateForm ($a_new_type)
 Init object creation form. More...
 
 initDidacticTemplate (ilPropertyFormGUI $form)
 Show didactic template types. More...
 
 addDidacticTemplateOptions (array &$a_options)
 Add custom templates. More...
 
 getDidacticTemplateVar ($a_type)
 Get didactic template setting from creation screen. More...
 
 putObjectInTree (ilObject $a_obj, $a_parent_node_id=null)
 Add object to tree at given position. More...
 
 afterSave (ilObject $a_new_object)
 Post (successful) object creation hook. More...
 
 initEditForm ()
 Init object edit form. More...
 
 initEditCustomForm (ilPropertyFormGUI $a_form)
 Add custom fields to update form. More...
 
 getEditFormValues ()
 Get values for edit form. More...
 
 getEditFormCustomValues (array &$a_values)
 Add values to custom edit fields. More...
 
 validateCustom (ilPropertyFormGUI $a_form)
 Validate custom values (if not possible with checkInput()) More...
 
 updateCustom (ilPropertyFormGUI $a_form)
 Insert custom update form values into object. More...
 
 afterUpdate ()
 Post (successful) object update hook. More...
 
 initImportForm ($a_new_type)
 Init object import form. More...
 
 importFileObject ($parent_id=null)
 Import. More...
 
 afterImport (ilObject $a_new_object)
 Post (successful) object import hook. More...
 
 setFormAction ($a_cmd, $a_formaction)
 set specific form action for command More...
 
 getReturnLocation ($a_cmd, $a_location="")
 get return location for command (command is method name without "Object", e.g. More...
 
 setReturnLocation ($a_cmd, $a_location)
 set specific return location for command More...
 
 getTargetFrame ($a_cmd, $a_target_frame="")
 get target frame for command (command is method name without "Object", e.g. More...
 
 setTargetFrame ($a_cmd, $a_target_frame)
 set specific target frame for command More...
 
 showPossibleSubObjects ()
 show possible subobjects (pulldown menu) More...
 
 getTemplateFile ($a_cmd, $a_type="")
 get a template blockfile format: tpl. More...
 
 getTitlesByRefId ($a_ref_ids)
 get Titles of objects this method is used for error messages in methods cut/copy/paste More...
 
 getTabs (&$tabs_gui)
 get tabs abstract method. More...
 
 __showButton ($a_cmd, $a_text, $a_target='')
 
 hitsperpageObject ()
 
__initTableGUI ()
 
 __setTableGUIBasicData (&$tbl, &$result_set, $a_from="")
 standard implementation for tables use 'from' variable use different initial setting of table More...
 
 redirectToRefId ($a_ref_id, $a_cmd="")
 redirects to (repository) view per ref id usually to a container and usually used at the end of a save/import method where the object gui type (of the new object) doesn't match with the type of the current $_GET["ref_id"] value More...
 
 fillCloneTemplate ($a_tpl_varname, $a_type)
 Fill object clone template This method can be called from any object GUI class that wants to offer object cloning. More...
 
 getCenterColumnHTML ()
 Get center column. More...
 
 getRightColumnHTML ()
 Display right column. More...
 
 setColumnSettings ($column_gui)
 May be overwritten in subclasses. More...
 
 checkPermission ($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
 Check permission and redirect on error. More...
 
 checkPermissionBool ($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
 Check permission. More...
 
 enableDragDropFileUpload ()
 Enables the file upload into this object by dropping files. More...
 
 handleAutoRating (ilObject $a_new_obj)
 Activate rating automatically if parent container setting. More...
 

Additional Inherited Members

- Data Fields inherited from ilObject2GUI
 $tree
 
const OBJECT_ID = 0
 
const REPOSITORY_NODE_ID = 1
 
const WORKSPACE_NODE_ID = 2
 
const REPOSITORY_OBJECT_ID = 3
 
const WORKSPACE_OBJECT_ID = 4
 
const PORTFOLIO_OBJECT_ID = 5
 
- Data Fields inherited from ilObjectGUI
const COPY_WIZARD_NEEDS_PAGE = 1
 
 $ilias
 
 $objDefinition
 
 $tpl
 
 $tree
 
 $lng
 
 $data
 
 $object
 
 $ref_id
 
 $obj_id
 
 $maxcount
 
 $formaction
 
 $return_location
 
 $target_frame
 
 $tab_target_script
 
 $actions
 
 $sub_objects
 
 $omit_locator = false
 
const CFORM_NEW = 1
 
const CFORM_IMPORT = 2
 
const CFORM_CLONE = 3
 
- Protected Attributes inherited from ilObject2GUI
 $object_id
 
 $node_id
 
 $creation_forms = array()
 
 $id_type = array()
 
 $parent_id
 
 $access_handler
 

Detailed Description

Member Function Documentation

◆ _forwards()

ilObjFileGUI::_forwards ( )

Definition at line 28 of file class.ilObjFileGUI.php.

29  {
30  return array();
31  }

◆ _goto()

static ilObjFileGUI::_goto (   $a_target,
  $a_additional = null 
)
static

Definition at line 927 of file class.ilObjFileGUI.php.

References $_GET, $ilErr, ilObjectGUI\$lng, ilObjectGUI\_gotoRepositoryNode(), ilObjectGUI\_gotoRepositoryRoot(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), exit, and ilUtil\sendFailure().

928  {
929  global $ilErr, $lng, $ilAccess;
930 
931  if($a_additional && substr($a_additional, -3) == "wsp")
932  {
933  $_GET["baseClass"] = "ilsharedresourceGUI";
934  $_GET["wsp_id"] = $a_target;
935  include("ilias.php");
936  exit;
937  }
938 
939  // added support for direct download goto links
940  if($a_additional && substr($a_additional, -8) == "download")
941  {
942  ilObjectGUI::_gotoRepositoryNode($a_target, "sendfile");
943  }
944 
945  // static method, no workspace support yet
946 
947  if ($ilAccess->checkAccess("visible", "", $a_target))
948  {
949  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
950  }
951  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
952  {
953  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
956  }
957 
958  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
959  }
exit
Definition: login.php:54
$_GET["client_id"]
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static _lookupTitle($a_id)
lookup object title
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static _lookupObjId($a_id)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ addLocatorItems()

ilObjFileGUI::addLocatorItems ( )

Definition at line 964 of file class.ilObjFileGUI.php.

References ilObject2GUI\$node_id.

965  {
966  global $ilLocator;
967 
968  if (is_object($this->object))
969  {
970  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
971  }
972  }

◆ cancelDeleteFile()

ilObjFileGUI::cancelDeleteFile ( )

Cancels the file deletion.

Definition at line 1369 of file class.ilObjFileGUI.php.

1370  {
1371  $this->ctrl->redirect($this, "versions");
1372  }

◆ cancelDeleteVersions()

ilObjFileGUI::cancelDeleteVersions ( )

Cancels the file version deletion.

Definition at line 1340 of file class.ilObjFileGUI.php.

1341  {
1342  $this->ctrl->redirect($this, "versions");
1343  }

◆ compareHistoryIds()

ilObjFileGUI::compareHistoryIds (   $v1,
  $v2 
)

Compares two versions either by passing a history entry or an id.

Parameters
$v1The first version to compare.
$v2The second version to compare.
Returns

Definition at line 1381 of file class.ilObjFileGUI.php.

1382  {
1383  if (is_array($v1))
1384  $v1 = (int)$v1["hist_entry_id"];
1385  else if (!is_int($v1))
1386  $v1 = (int)$v1;
1387 
1388  if (is_array($v2))
1389  $v2 = (int)$v2["hist_entry_id"];
1390  else if (!is_int($v2))
1391  $v2 = (int)$v2;
1392 
1393  return $v1 - $v2;
1394  }

◆ confirmDeleteFile()

ilObjFileGUI::confirmDeleteFile ( )

Deletes this file object.

Definition at line 1348 of file class.ilObjFileGUI.php.

References ilObject2GUI\checkPermissionBool().

1349  {
1350  // has the user the rights to delete the file?
1351  if (!$this->checkPermissionBool("write"))
1352  {
1353  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
1354  }
1355 
1356  // delete this file object
1357  include_once("./Services/Repository/classes/class.ilRepUtilGUI.php");
1358  $ru = new ilRepUtilGUI($this);
1359  $ru->deleteObjects($this->parent_id, array($this->ref_id));
1360 
1361  // redirect to parent object
1362  $this->ctrl->setParameterByClass("ilrepositorygui", "ref_id", $this->parent_id);
1363  $this->ctrl->redirectByClass("ilrepositorygui");
1364  }
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
Repository GUI Utilities.
+ Here is the call graph for this function:

◆ confirmDeleteVersions()

ilObjFileGUI::confirmDeleteVersions ( )

Deletes the file versions that were confirmed by the user.

Definition at line 1316 of file class.ilObjFileGUI.php.

References $_POST, ilObject2GUI\checkPermissionBool(), and ilUtil\sendSuccess().

1317  {
1318  global $ilTabs;
1319 
1320  // has the user the rights to delete versions?
1321  if (!$this->checkPermissionBool("write"))
1322  {
1323  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
1324  }
1325 
1326  // delete versions after confirmation
1327  if (count($_POST["hist_id"]) > 0)
1328  {
1329  $this->object->deleteVersions($_POST["hist_id"]);
1330  ilUtil::sendSuccess($this->lng->txt("file_versions_deleted"), true);
1331  }
1332 
1333  $this->ctrl->setParameter($this, "hist_id", "");
1334  $this->ctrl->redirect($this, "versions");
1335  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
+ Here is the call graph for this function:

◆ deleteVersions()

ilObjFileGUI::deleteVersions ( )

Displays a confirmation screen with selected file versions that should be deleted.

Definition at line 1258 of file class.ilObjFileGUI.php.

References $_GET, $_POST, ilObject\_getIcon(), ilUtil\sendFailure(), and ilUtil\sendQuestion().

1259  {
1260  global $ilTabs, $ilLocator;
1261 
1262  // get ids either from GET (if single item was clicked) or
1263  // from POST (if multiple items were selected)
1264  $version_ids = isset($_GET["hist_id"]) ? array($_GET["hist_id"]) : $_POST["hist_id"];
1265 
1266  if (count($version_ids) < 1)
1267  {
1268  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1269  $this->ctrl->redirect($this, "versions");
1270  }
1271  else
1272  {
1273  $ilTabs->activateTab("id_versions");
1274 
1275  // check if all versions are selected
1276  $versionsToKeep = array_udiff($this->object->getVersions(), $version_ids, array($this, "compareHistoryIds"));
1277  if (count($versionsToKeep) < 1)
1278  {
1279  // set our message
1280  ilUtil::sendQuestion($this->lng->txt("file_confirm_delete_all_versions"));
1281 
1282  // show confirmation gui
1283  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1284  $conf_gui = new ilConfirmationGUI();
1285  $conf_gui->setFormAction($this->ctrl->getFormAction($this, "versions"));
1286  $conf_gui->setCancel($this->lng->txt("cancel"), "cancelDeleteFile");
1287  $conf_gui->setConfirm($this->lng->txt("confirm"), "confirmDeleteFile");
1288 
1289  $conf_gui->addItem("id[]", $this->ref_id, $this->object->getTitle(),
1290  ilObject::_getIcon($this->object->getId(), "small", $this->object->getType()),
1291  $this->lng->txt("icon")." ".$this->lng->txt("obj_".$this->object->getType()));
1292 
1293  $html = $conf_gui->getHTML();
1294  }
1295  else
1296  {
1297  include_once("./Modules/File/classes/class.ilFileVersionTableGUI.php");
1298 
1299  ilUtil::sendQuestion($this->lng->txt("file_confirm_delete_versions"));
1300  $versions = $this->object->getVersions($version_ids);
1301 
1302  $table = new ilFileVersionTableGUI($this, 'versions', true);
1303  $table->setMaxCount(sizeof($versions));
1304  $table->setData($versions);
1305 
1306  $html = $table->getHTML();
1307  }
1308 
1309  $this->tpl->setVariable('ADM_CONTENT', $html);
1310  }
1311  }
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilFileVersionTableGUI.
Confirmation screen class.
+ Here is the call graph for this function:

◆ edit()

ilObjFileGUI::edit ( )

edit object

public

Definition at line 574 of file class.ilObjFileGUI.php.

References $ilErr, ilObject2GUI\checkPermissionBool(), and initPropertiesForm().

575  {
576  global $ilTabs, $ilErr;
577 
578  if (!$this->checkPermissionBool("write"))
579  {
580  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"));
581  }
582 
583  $ilTabs->activateTab("settings");
584 
585  $form = $this->initPropertiesForm();
586 
587  $val = array();
588  $val['title'] = $this->object->getTitle();
589  $val['description'] = $this->object->getLongDescription();
590  $val['rating'] = $this->object->hasRating();
591  $form->setValuesByArray($val);
592 
593  // Edit ecs export settings
594  include_once 'Modules/File/classes/class.ilECSFileSettings.php';
595  $ecs = new ilECSFileSettings($this->object);
596  $ecs->addSettingsToForm($form, 'file');
597 
598  $this->tpl->setContent($form->getHTML());
599  return true;
600  }
Class ilECSFileSettings.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
+ Here is the call graph for this function:

◆ executeCommand()

ilObjFileGUI::executeCommand ( )

Definition at line 33 of file class.ilObjFileGUI.php.

References $_GET, $cmd, $ilCtrl, $ilErr, $ilUser, $ret, ilPaymentBookings\_readBookingByTransaction(), ilPaymentObject\_requiresPurchaseToAccess(), ilObjectGUI\addHeaderAction(), ilMDEditorGUI\addObserver(), ilObject2GUI\checkPermissionBool(), ilObject2GUI\getAccessHandler(), ilObject2GUI\getCreationMode(), ilCommonActionDispatcherGUI\getInstanceFromAjaxCall(), infoScreenForward(), ilObject2GUI\prepareOutput(), ilObject2GUI\setLocator(), and ilFileInputGUI\setPersonalWorkspaceQuotaCheck().

34  {
35  global $ilNavigationHistory, $ilCtrl, $ilUser, $ilTabs, $ilAccess, $ilErr;
36 
37  $next_class = $this->ctrl->getNextClass($this);
38  $cmd = $this->ctrl->getCmd();
39 
40  if($this->id_type == self::WORKSPACE_NODE_ID)
41  {
42  include_once "Services/Form/classes/class.ilFileInputGUI.php";
44  }
45 
46  if(!$this->getCreationMode())
47  {
48  // do not move this payment block!!
49  if(IS_PAYMENT_ENABLED)
50  {
51  include_once './Services/Payment/classes/class.ilPaymentObject.php';
52  if(ANONYMOUS_USER_ID == $ilUser->getId() && isset($_GET['transaction']))
53  {
54  $transaction = $_GET['transaction'];
55  include_once './Services/Payment/classes/class.ilPaymentBookings.php';
56  $valid_transaction = ilPaymentBookings::_readBookingByTransaction($transaction);
57  }
58 
59  if(ilPaymentObject::_requiresPurchaseToAccess($this->node_id, $type = (isset($_GET['purchasetype'])
60  ? $_GET['purchasetype'] : NULL) ))
61  {
62  $this->setLocator();
63  $this->tpl->getStandardTemplate();
64 
65  include_once './Services/Payment/classes/class.ilShopPurchaseGUI.php';
66  $pp = new ilShopPurchaseGUI((int)$this->node_id);
67  $ret = $this->ctrl->forwardCommand($pp);
68  return true;
69  }
70  }
71  else if($this->id_type == self::REPOSITORY_NODE_ID
72  && $this->checkPermissionBool("read"))
73  {
74  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->node_id);
75  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
76  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
77 
78  // add entry to navigation history
79  $ilNavigationHistory->addItem($this->node_id,
80  $link, "file");
81  }
82  }
83 
84  $this->prepareOutput();
85 
86  switch ($next_class)
87  {
88  case "ilinfoscreengui":
89  $this->infoScreenForward(); // forwards command
90  break;
91 
92  case 'ilmdeditorgui':
93  if(!$this->checkPermissionBool("write"))
94  {
95  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
96  }
97 
98  $ilTabs->activateTab("id_meta");
99 
100  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
101 
102  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
103  $md_gui->addObserver($this->object,'MDUpdateListener','General');
104 
105  // todo: make this work
106  $md_gui->addObserver($this->object,'MDUpdateListener','Technical');
107 
108  $this->ctrl->forwardCommand($md_gui);
109  break;
110 
111  // repository permissions
112  case 'ilpermissiongui':
113  $ilTabs->activateTab("id_permissions");
114  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
115  $perm_gui =& new ilPermissionGUI($this);
116  $ret =& $this->ctrl->forwardCommand($perm_gui);
117  break;
118 
119  case "ilexportgui":
120  if(!$this->checkPermissionBool("write"))
121  {
122  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
123  }
124  $ilTabs->activateTab("export");
125  include_once("./Services/Export/classes/class.ilExportGUI.php");
126  $exp_gui = new ilExportGUI($this);
127  $exp_gui->addFormat("xml");
128  $ret = $this->ctrl->forwardCommand($exp_gui);
129  break;
130 
131  case 'ilobjectcopygui':
132  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
133  $cp = new ilObjectCopyGUI($this);
134  $cp->setType('file');
135  $this->ctrl->forwardCommand($cp);
136  break;
137 
138  // personal workspace permissions
139  case "ilworkspaceaccessgui";
140  $ilTabs->activateTab("id_permissions");
141  include_once('./Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php');
142  $wspacc = new ilWorkspaceAccessGUI($this->node_id, $this->getAccessHandler());
143  $this->ctrl->forwardCommand($wspacc);
144  break;
145 
146  case "ilcommonactiondispatchergui":
147  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
149  $this->ctrl->forwardCommand($gui);
150  break;
151 
152  default:
153  // in personal workspace use object2gui
154  if($this->id_type == self::WORKSPACE_NODE_ID)
155  {
156  $this->addHeaderAction();
157 
158  // coming from goto we need default command
159  if (empty($cmd))
160  {
161  $ilCtrl->setCmd("infoScreen");
162  }
163  $ilTabs->clearTargets();
164  return parent::executeCommand();
165  }
166 
167  if (empty($cmd))
168  {
169  $cmd = "infoScreen";
170  }
171 
172  $this->$cmd();
173  break;
174  }
175 
176  $this->addHeaderAction();
177  }
setLocator()
set Locator
infoScreenForward()
show information screen
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
GUI class for the workflow of copying objects.
$_GET["client_id"]
getAccessHandler()
Get access handler.
Class ilShopPurchaseGUI.
$cmd
Definition: sahs_server.php:35
static _requiresPurchaseToAccess($a_ref_id, $a_purchasetype='')
this function should be used by all buyable repository objects !!
addObserver(&$a_class, $a_method, $a_element)
global $ilCtrl
Definition: ilias.php:18
Export User Interface Class.
ACL access handler GUI.
global $ilUser
Definition: imgupload.php:15
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
setPersonalWorkspaceQuotaCheck($a_value)
addHeaderAction()
Add header action menu.
static _readBookingByTransaction($a_transaction)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
+ Here is the call graph for this function:

◆ getType()

ilObjFileGUI::getType ( )

Definition at line 22 of file class.ilObjFileGUI.php.

23  {
24  return "file";
25  }

◆ handleFileUpload()

ilObjFileGUI::handleFileUpload (   $file_upload)
protected

Handles the upload of a single file and adds it to the parent object.

Parameters
array$file_uploadAn array containing the file upload parameters.
Returns
object The response object.

Definition at line 1083 of file class.ilObjFileGUI.php.

References ilObject2GUI\$access_handler, $filename, $ilUser, ilObjectGUI\$object, $size, ilObject2GUI\$tree, ilObjFileAccess\_getFileExtension(), ilObject\_lookupType(), ilChangeEvent\_recordWriteEvent(), ilObject2GUI\checkPermissionBool(), ilUtil\delDir(), ilObject2GUI\getAccessHandler(), ilMimeTypeUtil\getMimeType(), ilFileUtils\getNewObjects(), ilObject2GUI\handleAutoRating(), ilUtil\ilTempnam(), ilUtil\makeDir(), ilFileUtils\processZipFile(), ilObject2GUI\putObjectInTree(), and ilUtil\stripSlashes().

Referenced by uploadFiles().

1084  {
1085  global $ilUser;
1086 
1087  // file upload params
1088  $filename = ilUtil::stripSlashes($file_upload["name"]);
1089  $type = ilUtil::stripSlashes($file_upload["type"]);
1090  $size = ilUtil::stripSlashes($file_upload["size"]);
1091  $temp_name = $file_upload["tmp_name"];
1092 
1093  // additional params
1094  $title = ilUtil::stripSlashes($file_upload["title"]);
1095  $description = ilUtil::stripSlashes($file_upload["description"]);
1096  $extract = ilUtil::stripSlashes($file_upload["extract"]);
1097  $keep_structure = ilUtil::stripSlashes($file_upload["keep_structure"]);
1098 
1099  // create answer object
1100  $response = new stdClass();
1101  $response->fileName = $filename;
1102  $response->fileSize = intval($size);
1103  $response->fileType = $type;
1104  $response->fileUnzipped = $extract;
1105  $response->error = null;
1106 
1107  // extract archive?
1108  if ($extract)
1109  {
1110  $zip_file = $filename;
1111  $adopt_structure = $keep_structure;
1112 
1113  include_once ("Services/Utilities/classes/class.ilFileUtils.php");
1114 
1115  // Create unzip-directory
1116  $newDir = ilUtil::ilTempnam();
1117  ilUtil::makeDir($newDir);
1118 
1119  // Check if permission is granted for creation of object, if necessary
1120  if($this->id_type != self::WORKSPACE_NODE_ID)
1121  {
1122  $type = ilObject::_lookupType((int)$this->parent_id, true);
1123  }
1124  else
1125  {
1126  $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false);
1127  }
1128 
1129  $tree = $access_handler = null;
1130  switch($type)
1131  {
1132  // workspace structure
1133  case 'wfld':
1134  case 'wsrt':
1135  $permission = $this->checkPermissionBool("create", "", "wfld");
1136  $containerType = "WorkspaceFolder";
1137  $tree = $this->tree;
1138  $access_handler = $this->getAccessHandler();
1139  break;
1140 
1141  // use categories as structure
1142  case 'cat':
1143  case 'root':
1144  $permission = $this->checkPermissionBool("create", "", "cat");
1145  $containerType = "Category";
1146  break;
1147 
1148  // use folders as structure (in courses)
1149  default:
1150  $permission = $this->checkPermissionBool("create", "", "fold");
1151  $containerType = "Folder";
1152  break;
1153  }
1154 
1155  try
1156  {
1157  // processZipFile (
1158  // Dir to unzip,
1159  // Path to uploaded file,
1160  // should a structure be created (+ permission check)?
1161  // ref_id of parent
1162  // object that contains files (folder or category)
1163  // should sendInfo be persistent?)
1165  $newDir,
1166  $temp_name,
1167  ($adopt_structure && $permission),
1168  $this->parent_id,
1169  $containerType,
1170  $tree,
1171  $access_handler);
1172  }
1173  catch (ilFileUtilsException $e)
1174  {
1175  $response->error = $e->getMessage();
1176  }
1177  catch (Exception $ex)
1178  {
1179  $response->error = $ex->getMessage();
1180  }
1181 
1182  ilUtil::delDir($newDir);
1183 
1184  // #15404
1185  if($this->id_type != self::WORKSPACE_NODE_ID)
1186  {
1187  foreach(ilFileUtils::getNewObjects() as $parent_ref_id => $objects)
1188  {
1189  if($parent_ref_id != $this->parent_id)
1190  {
1191  continue;
1192  }
1193 
1194  foreach($objects as $object)
1195  {
1196  $this->after_creation_callback_objects[] = $object;
1197  }
1198  }
1199  }
1200  }
1201  else
1202  {
1203  if (trim($title) == "")
1204  {
1205  $title = $filename;
1206  }
1207  else
1208  {
1209  // BEGIN WebDAV: Ensure that object title ends with the filename extension
1211  $titleExtension = ilObjFileAccess::_getFileExtension($title);
1212  if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
1213  {
1214  $title .= '.'.$fileExtension;
1215  }
1216  // END WebDAV: Ensure that object title ends with the filename extension
1217  }
1218 
1219  // create and insert file in grp_tree
1220  include_once("./Modules/File/classes/class.ilObjFile.php");
1221  $fileObj = new ilObjFile();
1222  $fileObj->setTitle($title);
1223  $fileObj->setDescription($description);
1224  $fileObj->setFileName($filename);
1225 
1226  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1227  $fileObj->setFileType(ilMimeTypeUtil::getMimeType("", $filename, $type));
1228  $fileObj->setFileSize($size);
1229  $this->object_id = $fileObj->create();
1230 
1231  $this->putObjectInTree($fileObj, $this->parent_id);
1232 
1233  // see uploadFiles()
1234  if(is_array($this->after_creation_callback_objects))
1235  {
1236  $this->after_creation_callback_objects[] = $fileObj;
1237  }
1238 
1239  // upload file to filesystem
1240  $fileObj->createDirectory();
1241  $fileObj->raiseUploadError(false);
1242  $fileObj->getUploadFile($temp_name, $filename);
1243 
1244  $this->handleAutoRating($fileObj);
1245 
1246  // BEGIN ChangeEvent: Record write event.
1247  require_once('./Services/Tracking/classes/class.ilChangeEvent.php');
1248  ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
1249  // END ChangeEvent: Record write event.
1250  }
1251 
1252  return $response;
1253  }
$size
Definition: RandomTest.php:79
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
getAccessHandler()
Get access handler.
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
Class ilObjFile.
handleAutoRating(ilObject $a_new_obj)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static _lookupType($a_id, $a_reference=false)
lookup object type
$filename
Definition: buildRTE.php:89
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
global $ilUser
Definition: imgupload.php:15
static getNewObjects()
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
processZipFile($a_directory, $a_file, $structure, $ref_id=null, $containerType=null, $tree=null, $access_handler=null)
unzips in given directory and processes uploaded zip for use as single files
_recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
Class to report exception.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infoScreen()

ilObjFileGUI::infoScreen ( )

this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually, if everything works through ilCtrl in the future this may be changed

Definition at line 737 of file class.ilObjFileGUI.php.

References infoScreenForward().

738  {
739  $this->ctrl->setCmd("showSummary");
740  $this->ctrl->setCmdClass("ilinfoscreengui");
741  $this->infoScreenForward();
742  }
infoScreenForward()
show information screen
+ Here is the call graph for this function:

◆ infoScreenForward()

ilObjFileGUI::infoScreenForward ( )

show information screen

Definition at line 747 of file class.ilObjFileGUI.php.

References ilObject2GUI\$access_handler, $ilErr, $preview, ilObjectGUI\$tpl, ilObjFileAccess\_getPermanentDownloadLink(), ilObjFile\_lookupFileSize(), ilObject2GUI\checkPermissionBool(), ilPreviewGUI\CONTEXT_REPOSITORY, ilPreviewGUI\CONTEXT_WORKSPACE, ilFormat\formatSize(), ilLinkButton\getInstance(), ilUserUtil\getNamePresentation(), ilObject2GUI\getPermanentLinkWidget(), and ilPreview\hasPreview().

Referenced by executeCommand(), and infoScreen().

748  {
749  global $ilTabs, $ilErr, $ilToolbar;
750 
751  $ilTabs->activateTab("id_info");
752 
753  if (!$this->checkPermissionBool("visible"))
754  {
755  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
756  }
757 
758  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
759  $info = new ilInfoScreenGUI($this);
760 
761  if ($this->checkPermissionBool("read", "sendfile"))
762  {
763  // #9876
764  $this->lng->loadLanguageModule("file");
765 
766  // #14378
767  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
768  $button = ilLinkButton::getInstance();
769  $button->setCaption("file_download");
770  $button->setPrimary(true);
771 
772  // get permanent download link for repository
773  if ($this->id_type == self::REPOSITORY_NODE_ID)
774  {
775  $button->setUrl(ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
776  }
777  else
778  {
779  $button->setUrl($this->ctrl->getLinkTarget($this, "sendfile"));
780  }
781 
782  $ilToolbar->addButtonInstance($button);
783  }
784 
785  $info->enablePrivateNotes();
786 
787  if ($this->checkPermissionBool("read"))
788  {
789  $info->enableNews();
790  }
791 
792  // no news editing for files, just notifications
793  $info->enableNewsEditing(false);
794  if ($this->checkPermissionBool("write"))
795  {
796  $news_set = new ilSetting("news");
797  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
798 
799  if ($enable_internal_rss)
800  {
801  $info->setBlockProperty("news", "settings", true);
802  $info->setBlockProperty("news", "public_notifications_option", true);
803  }
804  }
805 
806 
807  // standard meta data
808  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
809 
810  $info->addSection($this->lng->txt("file_info"));
811  $info->addProperty($this->lng->txt("filename"),
812  $this->object->getFileName());
813  // BEGIN WebDAV Guess file type.
814  $info->addProperty($this->lng->txt("type"),
815  $this->object->guessFileType());
816  // END WebDAV Guess file type.
817  $info->addProperty($this->lng->txt("size"),
818  ilFormat::formatSize(ilObjFile::_lookupFileSize($this->object->getId()),'long'));
819  $info->addProperty($this->lng->txt("version"),
820  $this->object->getVersion());
821 
822  // using getVersions function instead of ilHistory direct
823  $uploader = $this->object->getVersions();
824  $uploader = array_shift($uploader);
825  $uploader = $uploader["user_id"];
826 
827  $this->lng->loadLanguageModule("file");
828  include_once "Services/User/classes/class.ilUserUtil.php";
829  $info->addProperty($this->lng->txt("file_uploaded_by"), ilUserUtil::getNamePresentation($uploader));
830 
831  // download link added in repository
832  if ($this->id_type == self::REPOSITORY_NODE_ID && $this->checkPermissionBool("read", "sendfile"))
833  {
834  $tpl = new ilTemplate("tpl.download_link.html", true, true, "Modules/File");
835  $tpl->setVariable("LINK", ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
836  $info->addProperty($this->lng->txt("download_link"), $tpl->get());
837  }
838 
839  if($this->id_type == self::WORKSPACE_NODE_ID)
840  {
841  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
842  }
843 
844  // display previews
845  include_once("./Services/Preview/classes/class.ilPreview.php");
846  if (!$this->ctrl->isAsynch() &&
847  ilPreview::hasPreview($this->object->getId(), $this->object->getType()) &&
848  $this->checkPermissionBool("read"))
849  {
850  include_once("./Services/Preview/classes/class.ilPreviewGUI.php");
851 
852  // get context for access checks later on
853  $context;
854  switch ($this->id_type)
855  {
856  case self::WORKSPACE_NODE_ID:
857  case self::WORKSPACE_OBJECT_ID:
859  break;
860 
861  default:
863  break;
864  }
865 
866  $preview = new ilPreviewGUI($this->node_id, $context, $this->object->getId(), $this->access_handler);
867  $info->addProperty($this->lng->txt("preview"), $preview->getInlineHTML());
868  }
869 
870  // forward the command
871  // $this->ctrl->setCmd("showSummary");
872  // $this->ctrl->setCmdClass("ilinfoscreengui");
873  $this->ctrl->forwardCommand($info);
874  }
ILIAS Setting Class.
static _getPermanentDownloadLink($ref_id)
Gets the permanent download link for the file.
Class ilInfoScreenGUI.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
$preview
getPermanentLinkWidget($a_append=null, $a_center=false)
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
static hasPreview($a_obj_id, $a_type="")
Determines whether the object with the specified reference id has a preview.
special template class to simplify handling of ITX/PEAR
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
_lookupFileSize($a_id)
Lookups the file size of the file in bytes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCreationForms()

ilObjFileGUI::initCreationForms ( )
protected

Definition at line 179 of file class.ilObjFileGUI.php.

References ilObject2GUI\fillCloneTemplate(), ilObjectGUI\initImportForm(), initMultiUploadForm(), initSingleUploadForm(), initZipUploadForm(), ilFileUploadSettings\isDragAndDropUploadEnabled(), ilDiskQuotaHandler\isUploadPossible(), and ilUtil\sendFailure().

180  {
181  $forms = array();
182 
183  if($this->id_type == self::WORKSPACE_NODE_ID)
184  {
185  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
187  {
188  $this->lng->loadLanguageModule("file");
189  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
190  $this->ctrl->redirect($this, "cancel");
191  }
192  }
193 
194  // use drag-and-drop upload if configured
195  require_once("Services/FileUpload/classes/class.ilFileUploadSettings.php");
197  {
198  $forms[] = $this->initMultiUploadForm();
199  }
200  else
201  {
202  $forms[] = $this->initSingleUploadForm();
203  $forms[] = $this->initZipUploadForm();
204  }
205 
206  // repository only
207  if($this->id_type != self::WORKSPACE_NODE_ID)
208  {
209  $forms[self::CFORM_IMPORT] = $this->initImportForm('file');
210  $forms[self::CFORM_CLONE] = $this->fillCloneTemplate(null, "file");
211  }
212 
213  return $forms;
214  }
initSingleUploadForm()
FORM: Init single upload form.
initZipUploadForm($a_mode="create")
FORM: Init zip upload form.
fillCloneTemplate($a_tpl_varname, $a_type)
initImportForm($a_new_type)
Init object import form.
static isUploadPossible($a_additional_size=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
initMultiUploadForm()
Initializes the upload form for multiple files.
static isDragAndDropUploadEnabled()
Gets whether drag and drop file upload is enabled.
+ Here is the call graph for this function:

◆ initHeaderAction()

ilObjFileGUI::initHeaderAction (   $a_sub_type = null,
  $a_sub_id = null 
)
protected

Definition at line 1427 of file class.ilObjFileGUI.php.

1428  {
1429  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
1430  if(is_object($lg))
1431  {
1432  if($this->object->hasRating())
1433  {
1434  $lg->enableRating(true, null, false,
1435  array("ilcommonactiondispatchergui", "ilratinggui"));
1436  }
1437  }
1438  return $lg;
1439  }

◆ initMultiUploadForm()

ilObjFileGUI::initMultiUploadForm ( )

Initializes the upload form for multiple files.

Returns
object The created property form.

Definition at line 979 of file class.ilObjFileGUI.php.

References ilUtil\getImagePath(), ilObject2GUI\getTargetFrame(), and ilDragDropFileInputGUI\setArchiveSuffixes().

Referenced by initCreationForms(), and uploadFiles().

980  {
981  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
982  $dnd_form_gui = new ilPropertyFormGUI();
983  $dnd_form_gui->setMultipart(true);
984  $dnd_form_gui->setHideLabels();
985 
986  // file input
987  include_once("Services/Form/classes/class.ilDragDropFileInputGUI.php");
988  $dnd_input = new ilDragDropFileInputGUI($this->lng->txt("files"), "upload_files");
989  $dnd_input->setArchiveSuffixes(array("zip"));
990  $dnd_input->setCommandButtonNames("uploadFiles", "cancel");
991  $dnd_form_gui->addItem($dnd_input);
992 
993  // add commands
994  $dnd_form_gui->addCommandButton("uploadFiles", $this->lng->txt("upload_files"));
995  $dnd_form_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
996 
997  $dnd_form_gui->setTableWidth("100%");
998  $dnd_form_gui->setTarget($this->getTargetFrame("save"));
999  $dnd_form_gui->setTitle($this->lng->txt("upload_files_title"));
1000  $dnd_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.gif'), $this->lng->txt('obj_file'));
1001 
1002  $this->ctrl->setParameter($this, "new_type", "file");
1003  $dnd_form_gui->setFormAction($this->ctrl->getFormAction($this, "uploadFiles"));
1004 
1005  return $dnd_form_gui;
1006  }
This class represents a property form user interface.
setArchiveSuffixes($a_suffixes)
Set accepted archive suffixes.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getTargetFrame($a_cmd, $a_target_frame="")
This class represents a file input property where multiple files can be dopped in a property form...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPropertiesForm()

ilObjFileGUI::initPropertiesForm ( )
protected
Parameters

Definition at line 607 of file class.ilObjFileGUI.php.

References $file, ilDiskQuotaHandler\isUploadPossible(), ilRadioOption\setInfo(), ilFormPropertyGUI\setInfo(), ilTextAreaInputGUI\setRows(), and ilTextInputGUI\setValue().

Referenced by edit(), and update().

608  {
609  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
610 
611  $this->lng->loadLanguageModule('file');
612 
613  $form = new ilPropertyFormGUI();
614  $form->setFormAction($this->ctrl->getFormAction($this),'update');
615  $form->setTitle($this->lng->txt('file_edit'));
616  $form->addCommandButton('update',$this->lng->txt('save'));
617  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
618 
619  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
620  $title->setValue($this->object->getTitle());
621  $title->setInfo($this->lng->txt("if_no_title_then_filename"));
622  $form->addItem($title);
623 
624  $upload_possible = true;
625  if($this->id_type == self::WORKSPACE_NODE_ID)
626  {
627  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
628  $upload_possible = ilDiskQuotaHandler::isUploadPossible();
629  }
630 
631  if($upload_possible)
632  {
633  $file = new ilFileInputGUI($this->lng->txt('obj_file'),'file');
634  $file->setRequired(false);
635  // $file->enableFileNameSelection('title');
636  $form->addItem($file);
637 
638  $group = new ilRadioGroupInputGUI('','replace');
639  $group->setValue(0);
640 
641  $replace = new ilRadioOption($this->lng->txt('replace_file'),1);
642  $replace->setInfo($this->lng->txt('replace_file_info'));
643  $group->addOption($replace);
644 
645 
646  $keep = new ilRadioOption($this->lng->txt('file_new_version'),0);
647  $keep->setInfo($this->lng->txt('file_new_version_info'));
648  $group->addOption($keep);
649 
650  $file->addSubItem($group);
651  }
652  else
653  {
654  $file = new ilNonEditableValueGUI($this->lng->txt('obj_file'));
655  $file->setValue($this->lng->txt("personal_workspace_quota_exceeded_warning"));
656  $form->addItem($file);
657  }
658 
659  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
660  $desc->setRows(3);
661  #$desc->setCols(40);
662  $form->addItem($desc);
663 
664  if($this->id_type == self::REPOSITORY_NODE_ID)
665  {
666  $this->lng->loadLanguageModule('rating');
667  $rate = new ilCheckboxInputGUI($this->lng->txt('rating_activate_rating'), 'rating');
668  $rate->setInfo($this->lng->txt('rating_activate_rating_info'));
669  $form->addItem($rate);
670  }
671 
672  return $form;
673  }
This class represents an option in a radio group.
print $file
This class represents a property form user interface.
This class represents a file property in a property form.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Info.
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
This class represents a text property in a property form.
static isUploadPossible($a_additional_size=null)
This class represents a non editable value in a property form.
This class represents a text area property in a property form.
setValue($a_value)
Set Value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSingleUploadForm()

ilObjFileGUI::initSingleUploadForm ( )

FORM: Init single upload form.

Definition at line 219 of file class.ilObjFileGUI.php.

References ilObjectGUI\$lng, ilUtil\getImagePath(), ilObject2GUI\getTargetFrame(), ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), and ilObject\TITLE_LENGTH.

Referenced by initCreationForms(), and save().

220  {
221  global $lng;
222 
223  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
224  $single_form_gui = new ilPropertyFormGUI();
225  $single_form_gui->setMultipart(true);
226 
227  // File Title
228  $in_title = new ilTextInputGUI($lng->txt("title"), "title");
229  $in_title->setInfo($this->lng->txt("if_no_title_then_filename"));
230  $in_title->setSize(min(40, ilObject::TITLE_LENGTH));
231  $in_title->setMaxLength(ilObject::TITLE_LENGTH);
232  $single_form_gui->addItem($in_title);
233 
234  // File Description
235  $in_descr = new ilTextAreaInputGUI($lng->txt("description"), "description");
236  $single_form_gui->addItem($in_descr);
237 
238  // File
239  $in_file = new ilFileInputGUI($lng->txt("file"), "upload_file");
240  $in_file->setRequired(true);
241  $single_form_gui->addItem($in_file);
242 
243  $single_form_gui->addCommandButton("save", $this->lng->txt($this->type."_add"));
244  $single_form_gui->addCommandButton("saveAndMeta", $this->lng->txt("file_add_and_metadata"));
245  $single_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
246 
247  $single_form_gui->setTableWidth("600px");
248  $single_form_gui->setTarget($this->getTargetFrame("save"));
249  $single_form_gui->setTitle($this->lng->txt($this->type."_new"));
250  $single_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.svg'), $this->lng->txt('obj_file'));
251 
252  $this->ctrl->setParameter($this, "new_type", "file");
253 
254  $single_form_gui->setFormAction($this->ctrl->getFormAction($this, "save"));
255 
256  return $single_form_gui;
257  }
This class represents a property form user interface.
const TITLE_LENGTH
max length of object title
This class represents a file property in a property form.
setInfo($a_info)
Set Information Text.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a text property in a property form.
getTargetFrame($a_cmd, $a_target_frame="")
This class represents a text area property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initZipUploadForm()

ilObjFileGUI::initZipUploadForm (   $a_mode = "create")

FORM: Init zip upload form.

Definition at line 357 of file class.ilObjFileGUI.php.

References ilObjectGUI\$lng, ilUtil\getImagePath(), ilObject2GUI\getTargetFrame(), ilFormPropertyGUI\setInfo(), and ilFormPropertyGUI\setRequired().

Referenced by initCreationForms(), and saveUnzip().

358  {
359  global $lng;
360 
361  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
362  $zip_form_gui = new ilPropertyFormGUI();
363  $zip_form_gui->setMultipart(true);
364 
365  // File
366  $in_file = new ilFileInputGUI($lng->txt("file"), "zip_file");
367  $in_file->setRequired(true);
368  $in_file->setSuffixes(array("zip"));
369  $zip_form_gui->addItem($in_file);
370 
371  // Take over structure
372  $in_str = new ilCheckboxInputGUI($this->lng->txt("take_over_structure"), "adopt_structure");
373  $in_str->setInfo($this->lng->txt("take_over_structure_info"));
374  $zip_form_gui->addItem($in_str);
375 
376  $zip_form_gui->addCommandButton("saveUnzip", $this->lng->txt($this->type."_add"));
377  $zip_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
378 
379  $zip_form_gui->setTableWidth("600px");
380  $zip_form_gui->setTarget($this->getTargetFrame("save"));
381  $zip_form_gui->setTitle($this->lng->txt("header_zip"));
382  $zip_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.svg'), $this->lng->txt('obj_file'));
383 
384  $this->ctrl->setParameter($this, "new_type", "file");
385 
386  $zip_form_gui->setFormAction($this->ctrl->getFormAction($this, "saveUnzip"));
387 
388  return $zip_form_gui;
389  }
This class represents a property form user interface.
This class represents a file property in a property form.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getTargetFrame($a_cmd, $a_target_frame="")
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rollbackVersion()

ilObjFileGUI::rollbackVersion ( )

Performs a rollback with the selected file version.

Definition at line 1399 of file class.ilObjFileGUI.php.

References $_GET, $_POST, ilObject2GUI\checkPermissionBool(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

1400  {
1401  global $ilTabs;
1402 
1403  // has the user the rights to delete the file?
1404  if (!$this->checkPermissionBool("write"))
1405  {
1406  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
1407  }
1408 
1409  // get ids either from GET (if single item was clicked) or
1410  // from POST (if multiple items were selected)
1411  $version_ids = isset($_GET["hist_id"]) ? array($_GET["hist_id"]) : $_POST["hist_id"];
1412 
1413  // more than one entry selected?
1414  if (count($version_ids) != 1)
1415  {
1416  ilUtil::sendInfo($this->lng->txt("file_rollback_select_exact_one"), true);
1417  $this->ctrl->redirect($this, "versions");
1418  }
1419 
1420  // rollback the version
1421  $new_version = $this->object->rollback($version_ids[0]);
1422 
1423  ilUtil::sendSuccess(sprintf($this->lng->txt("file_rollback_done"), $new_version["rollback_version"]), true);
1424  $this->ctrl->redirect($this, "versions");
1425  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

◆ save()

ilObjFileGUI::save ( )

save object

public

Definition at line 264 of file class.ilObjFileGUI.php.

References $ilUser, ilObjectGUI\$objDefinition, ilObjFileAccess\_getFileExtension(), ilChangeEvent\_recordWriteEvent(), ilObject2GUI\checkPermissionBool(), ilMimeTypeUtil\getMimeType(), ilObject2GUI\handleAutoRating(), initSingleUploadForm(), ilObject2GUI\putObjectInTree(), ilUtil\redirect(), and ilUtil\sendSuccess().

Referenced by saveAndMeta().

265  {
266  global $objDefinition, $ilUser;
267 
268  if (!$this->checkPermissionBool("create", "", "file"))
269  {
270  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
271  }
272 
273  $single_form_gui = $this->initSingleUploadForm();
274 
275  if ($single_form_gui->checkInput())
276  {
277  $title = $single_form_gui->getInput("title");
278  $description = $single_form_gui->getInput("description");
279  $upload_file = $single_form_gui->getInput("upload_file");
280 
281  if (trim($title) == "")
282  {
283  $title = $upload_file["name"];
284  }
285  else
286  {
287  // BEGIN WebDAV: Ensure that object title ends with the filename extension
288  $fileExtension = ilObjFileAccess::_getFileExtension($upload_file["name"]);
289  $titleExtension = ilObjFileAccess::_getFileExtension($title);
290  if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
291  {
292  $title .= '.'.$fileExtension;
293  }
294  // END WebDAV: Ensure that object title ends with the filename extension
295  }
296 
297  // create and insert file in grp_tree
298  include_once("./Modules/File/classes/class.ilObjFile.php");
299  $fileObj = new ilObjFile();
300  $fileObj->setTitle($title);
301  $fileObj->setDescription($description);
302  $fileObj->setFileName($upload_file["name"]);
303  //$fileObj->setFileType($upload_file["type"]);
304  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
305  $fileObj->setFileType(ilMimeTypeUtil::getMimeType(
306  "", $upload_file["name"], $upload_file["type"]));
307  $fileObj->setFileSize($upload_file["size"]);
308  $this->object_id = $fileObj->create();
309 
310  $this->putObjectInTree($fileObj, $this->parent_id);
311 
312  // upload file to filesystem
313  $fileObj->createDirectory();
314  $fileObj->getUploadFile($upload_file["tmp_name"],
315  $upload_file["name"]);
316 
317  $this->handleAutoRating($fileObj);
318 
319  // BEGIN ChangeEvent: Record write event.
320  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
321  ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
322  // END ChangeEvent: Record write event.
323 
324  ilUtil::sendSuccess($this->lng->txt("file_added"),true);
325 
326  if ($this->ctrl->getCmd() == "saveAndMeta")
327  {
328  $this->ctrl->setParameter($this, "new_type", "");
329  $target = $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilmdeditorgui"), "listSection", "", false, false);
330  ilUtil::redirect($target);
331  }
332  else
333  {
334  $this->ctrl->returnToParent($this);
335  }
336  }
337  else
338  {
339  $single_form_gui->setValuesByPost();
340  $this->tpl->setContent($single_form_gui->getHTML());
341  }
342  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
initSingleUploadForm()
FORM: Init single upload form.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
Class ilObjFile.
handleAutoRating(ilObject $a_new_obj)
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
global $ilUser
Definition: imgupload.php:15
static redirect($a_script)
http redirect to other script
_recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAndMeta()

ilObjFileGUI::saveAndMeta ( )

save object

public

Definition at line 349 of file class.ilObjFileGUI.php.

References save().

350  {
351  $this->save();
352  }
save()
save object
+ Here is the call graph for this function:

◆ saveUnzip()

ilObjFileGUI::saveUnzip ( )

saveUnzip object

public

Definition at line 396 of file class.ilObjFileGUI.php.

References ilObject2GUI\$access_handler, ilObject2GUI\$tree, ilObject\_lookupType(), ilObject2GUI\checkPermissionBool(), ilUtil\delDir(), ilObject2GUI\getAccessHandler(), ilUtil\ilTempnam(), initZipUploadForm(), ilUtil\makeDir(), ilFileUtils\processZipFile(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

397  {
398  $zip_form_gui = $this->initZipUploadForm();
399 
400  if ($this->checkPermissionBool("create", "", "file"))
401  {
402  if ($zip_form_gui->checkInput())
403  {
404  $zip_file = $zip_form_gui->getInput("zip_file");
405  $adopt_structure = $zip_form_gui->getInput("adopt_structure");
406 
407  include_once ("Services/Utilities/classes/class.ilFileUtils.php");
408 
409  // Create unzip-directory
410  $newDir = ilUtil::ilTempnam();
411  ilUtil::makeDir($newDir);
412 
413  // Check if permission is granted for creation of object, if necessary
414  if($this->id_type != self::WORKSPACE_NODE_ID)
415  {
416 
417  $type = ilObject::_lookupType((int)$this->parent_id, true);
418  }
419  else
420  {
421  $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false);
422  }
423 
424  $tree = $access_handler = null;
425  switch($type)
426  {
427  // workspace structure
428  case 'wfld':
429  case 'wsrt':
430  $permission = $this->checkPermissionBool("create", "", "wfld");
431  $containerType = "WorkspaceFolder";
432  $tree = $this->tree;
433  $access_handler = $this->getAccessHandler();
434  break;
435 
436  // use categories as structure
437  case 'cat':
438  case 'root':
439  $permission = $this->checkPermissionBool("create", "", "cat");
440  $containerType = "Category";
441  break;
442 
443  // use folders as structure (in courses)
444  default:
445  $permission = $this->checkPermissionBool("create", "", "fold");
446  $containerType = "Folder";
447  break;
448  }
449  // processZipFile (
450  // Dir to unzip,
451  // Path to uploaded file,
452  // should a structure be created (+ permission check)?
453  // ref_id of parent
454  // object that contains files (folder or category)
455  // should sendInfo be persistent?)
456  try
457  {
458  $processDone = ilFileUtils::processZipFile( $newDir,
459  $zip_file["tmp_name"],
460  ($adopt_structure && $permission),
461  $this->parent_id,
462  $containerType,
463  $tree,
465  ilUtil::sendSuccess($this->lng->txt("file_added"),true);
466  }
467  catch (ilFileUtilsException $e)
468  {
469  ilUtil::sendFailure($e->getMessage(), true);
470  }
471 
472  ilUtil::delDir($newDir);
473  $this->ctrl->returnToParent($this);
474  }
475  else
476  {
477  $zip_form_gui->setValuesByPost();
478  $this->tpl->setContent($zip_form_gui->getHTML());
479  }
480  }
481  else
482  {
483  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
484  }
485  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
getAccessHandler()
Get access handler.
initZipUploadForm($a_mode="create")
FORM: Init zip upload form.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
processZipFile($a_directory, $a_file, $structure, $ref_id=null, $containerType=null, $tree=null, $access_handler=null)
unzips in given directory and processes uploaded zip for use as single files
Class to report exception.
+ Here is the call graph for this function:

◆ sendFile()

ilObjFileGUI::sendFile ( )

Definition at line 675 of file class.ilObjFileGUI.php.

References $_GET, $ilCtrl, $ilUser, ilChangeEvent\_recordReadEvent(), and ilObject2GUI\checkPermissionBool().

676  {
677  global $ilUser, $ilCtrl;
678 
679  if(ANONYMOUS_USER_ID == $ilUser->getId() && isset($_GET['transaction']) )
680  {
681  $this->object->sendFile($_GET["hist_id"]);
682  }
683 
684  if ($this->checkPermissionBool("read"))
685  {
686  // BEGIN ChangeEvent: Record read event.
687  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
688  global $ilUser;
689  // Record read event and catchup with write events
690  ilChangeEvent::_recordReadEvent($this->object->getType(), $this->object->getRefId(),
691  $this->object->getId(), $ilUser->getId());
692  // END ChangeEvent: Record read event.
693 
694  $this->object->sendFile($_GET["hist_id"]);
695  }
696  else
697  {
698  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
699  }
700  return true;
701  }
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
_recordReadEvent($a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ setTabs()

ilObjFileGUI::setTabs ( )

Definition at line 878 of file class.ilObjFileGUI.php.

References ilObjectGUI\$lng, and ilObject2GUI\checkPermissionBool().

879  {
880  global $ilTabs, $lng, $ilHelp;
881 
882  $ilHelp->setScreenIdComponent("file");
883 
884  $this->ctrl->setParameter($this,"ref_id",$this->node_id);
885 
886  if ($this->checkPermissionBool("visible"))
887  {
888  $ilTabs->addTab("id_info",
889  $lng->txt("info_short"),
890  $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilinfoscreengui"), "showSummary"));
891  }
892 
893  if ($this->checkPermissionBool("write"))
894  {
895  $ilTabs->addTab("settings",
896  $lng->txt("edit"),
897  $this->ctrl->getLinkTarget($this, "edit"));
898  }
899 
900  if ($this->checkPermissionBool("write"))
901  {
902  $ilTabs->addTab("id_versions",
903  $lng->txt("versions"),
904  $this->ctrl->getLinkTarget($this, "versions"));
905  }
906 
907  // meta data
908  if ($this->checkPermissionBool("write"))
909  {
910  $ilTabs->addTab("id_meta",
911  $lng->txt("meta_data"),
912  $this->ctrl->getLinkTargetByClass(array('ilobjfilegui','ilmdeditorgui'),'listSection'));
913  }
914 
915  // export
916  if ($this->checkPermissionBool("write"))
917  {
918  $ilTabs->addTab("export",
919  $lng->txt("export"),
920  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
921  }
922 
923  // will add permission tab if needed
924  parent::setTabs();
925  }
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
+ Here is the call graph for this function:

◆ update()

ilObjFileGUI::update ( )

updates object entry in object_data

public

Definition at line 492 of file class.ilObjFileGUI.php.

References ilObjectGUI\$data, $filename, $ilUser, ilChangeEvent\_catchupWriteEvents(), ilChangeEvent\_recordWriteEvent(), ilMimeTypeUtil\getMimeType(), initPropertiesForm(), ilUtil\redirect(), and ilUtil\sendSuccess().

493  {
494  global $ilTabs;
495 
496  $form = $this->initPropertiesForm();
497  if(!$form->checkInput())
498  {
499  $ilTabs->activateTab("settings");
500  $form->setValuesByPost();
501  $this->tpl->setContent($form->getHTML());
502  return false;
503  }
504 
505  $data = $form->getInput('file');
506 
507  // delete trailing '/' in filename
508  while (substr($data["name"],-1) == '/')
509  {
510  $data["name"] = substr($data["name"],0,-1);
511  }
512 
513  $filename = empty($data["name"]) ? $this->object->getFileName() : $data["name"];
514  $title = $form->getInput('title');
515  if(strlen(trim($title)) == 0)
516  {
517  $title = $filename;
518  }
519  else
520  {
521  $title = $this->object->checkFileExtension($filename,$title);
522  }
523  $this->object->setTitle($title);
524 
525  if (!empty($data["name"]))
526  {
527  switch($form->getInput('replace'))
528  {
529  case 1:
530  $this->object->deleteVersions();
531  $this->object->clearDataDirectory();
532  $this->object->replaceFile($data['tmp_name'],$data['name']);
533  break;
534  case 0:
535  $this->object->addFileVersion($data['tmp_name'],$data['name']);
536  break;
537  }
538  $this->object->setFileName($data['name']);
539  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
540  $this->object->setFileType(ilMimeTypeUtil::getMimeType(
541  "", $data["name"], $data["type"]));
542  $this->object->setFileSize($data['size']);
543  }
544 
545  $this->object->setDescription($form->getInput('description'));
546  $this->object->setRating($form->getInput('rating'));
547 
548  $this->update = $this->object->update();
549 
550  // BEGIN ChangeEvent: Record update event.
551  if (!empty($data["name"]))
552  {
553  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
554  global $ilUser;
555  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
556  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
557  }
558  // END ChangeEvent: Record update event.
559 
560  // Update ecs export settings
561  include_once 'Modules/File/classes/class.ilECSFileSettings.php';
562  $ecs = new ilECSFileSettings($this->object);
563  $ecs->handleSettingsUpdate();
564 
565  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
566  ilUtil::redirect($this->ctrl->getLinkTarget($this,'edit','',false,false));
567  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilECSFileSettings.
static getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
$filename
Definition: buildRTE.php:89
global $ilUser
Definition: imgupload.php:15
_catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
static redirect($a_script)
http redirect to other script
_recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
update()
updates object entry in object_data
+ Here is the call graph for this function:

◆ uploadFiles()

ilObjFileGUI::uploadFiles ( )

Called after a file was uploaded.

Definition at line 1011 of file class.ilObjFileGUI.php.

References $_REQUEST, ilObject2GUI\checkPermissionBool(), ilJsonUtil\encode(), exit, ilObject2GUI\handleAfterSaveCallback(), handleFileUpload(), and initMultiUploadForm().

1012  {
1013  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
1014 
1015  $response = new stdClass();
1016  $response->error = null;
1017  $response->debug = null;
1018 
1019  $files = $_FILES;
1020 
1021  // #14249 - race conditions because of concurrent uploads
1022  $after_creation_callback = (int)$_REQUEST["crtcb"];
1023  if($after_creation_callback)
1024  {
1025  $this->after_creation_callback_objects = array();
1026  unset($_REQUEST["crtcb"]);
1027  }
1028 
1029  // load form
1030  $dnd_form_gui = $this->initMultiUploadForm();
1031  if ($dnd_form_gui->checkInput())
1032  {
1033  try
1034  {
1035  if (!$this->checkPermissionBool("create", "", "file"))
1036  {
1037  $response->error = $this->lng->txt("permission_denied");
1038  }
1039  else
1040  {
1041  // handle the file
1042  $fileresult = $this->handleFileUpload($dnd_form_gui->getInput("upload_files"));
1043  if ($fileresult)
1044  $response = (object)array_merge((array)$response, (array)$fileresult);
1045  }
1046  }
1047  catch (Exception $ex)
1048  {
1049  $response->error = $ex->getMessage() . " ## " . $ex->getTraceAsString();
1050  }
1051  }
1052  else
1053  {
1054  $dnd_input = $dnd_form_gui->getItemByPostVar("upload_files");
1055  $response->error = $dnd_input->getAlert();
1056  }
1057 
1058  if($after_creation_callback &&
1059  sizeof($this->after_creation_callback_objects))
1060  {
1061  foreach($this->after_creation_callback_objects as $new_file_obj)
1062  {
1063  ilObject2GUI::handleAfterSaveCallback($new_file_obj, $after_creation_callback);
1064  }
1065  unset($this->after_creation_callback_objects);
1066  }
1067 
1068  // send response object (don't use 'application/json' as IE wants to download it!)
1069  header('Vary: Accept');
1070  header('Content-type: text/plain');
1071  echo ilJsonUtil::encode($response);
1072 
1073  // no further processing!
1074  exit;
1075  }
exit
Definition: login.php:54
handleFileUpload($file_upload)
Handles the upload of a single file and adds it to the parent object.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
static encode($mixed, $suppress_native=false)
static handleAfterSaveCallback(ilObject $a_obj, $a_callback_ref_id)
After creation callback.
initMultiUploadForm()
Initializes the upload form for multiple files.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ Here is the call graph for this function:

◆ versions()

ilObjFileGUI::versions ( )

file versions/history

public

Definition at line 709 of file class.ilObjFileGUI.php.

References ilObject2GUI\checkPermissionBool().

710  {
711  global $ilTabs;
712 
713  $ilTabs->activateTab("id_versions");
714 
715  if (!$this->checkPermissionBool("write"))
716  {
717  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
718  }
719 
720  // get versions
721  $versions = $this->object->getVersions();
722 
723  // build versions table
724  require_once("Modules/File/classes/class.ilFileVersionTableGUI.php");
725  $table = new ilFileVersionTableGUI($this, "versions");
726  $table->setMaxCount(sizeof($versions));
727  $table->setData($versions);
728 
729  $this->tpl->setVariable("ADM_CONTENT", $table->getHTML());
730  }
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
Class ilFileVersionTableGUI.
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: