ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjFileGUI Class Reference

GUI class for file objects. More...

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

Public Member Functions

 __construct ($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
 Constructor. More...
 
 getType ()
 
 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 ()
 
 prepareOutput ($a_show_subobjects=true)
 
 isVisible ($a_ref_id, $a_type)
 
 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...
 
 putObjectInTree (ilObject $a_obj, $a_parent_node_id=null)
 Add object to tree at given position. More...
 
- Public Member Functions inherited from ilObjectGUI
 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...
 
 prepareOutput ($a_show_subobjects=true)
 prepare output More...
 
 getAdminTabs ()
 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 ()
 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...
 
 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...
 
 editObject ()
 edit object More...
 
 addExternalEditFormCustom (ilPropertyFormGUI $a_form)
 
 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...
 

Data Fields

 $object
 
- 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
 
 $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 Member Functions

 initCreationForms ($a_new_type)
 
 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...
 
 setTitleAndDescription ()
 
 showUpperIcon ()
 
 omitLocator ($a_omit=true)
 
 getTargetFrame ($a_cmd, $a_target_frame="")
 
 setTargetFrame ($a_cmd, $a_target_frame)
 
 getCenterColumnHTML ()
 
 getRightColumnHTML ()
 
 setColumnSettings (ilColumnGUI $column_gui)
 
 checkPermission ($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
 
 showPossibleSubObjects ()
 
 redirectToRefId ($a_ref_id, $a_cmd="")
 
 fillCloneTemplate ($a_tpl_varname, $a_type)
 
 fillCloneSearchTemplate ($a_tpl_varname, $a_type)
 
 searchCloneSource ()
 
 buildCloneSelect ($existing_objs)
 
 addAdminLocatorItems ($a_do_not_add_object=false)
 
 setTabs ()
 create tabs (repository/workspace switch) More...
 
 getReturnLocation ($a_cmd, $a_location="")
 Deprecated functions. More...
 
 setReturnLocation ($a_cmd, $a_location)
 
 showActions ()
 
 getTabs ()
 
 __showButton ($a_cmd, $a_text, $a_target='')
 
 hitsperpageObject ()
 
__initTableGUI ()
 
 __setTableGUIBasicData (&$tbl, &$result_set, $a_from="")
 
 addLocatorItems ()
 Functions to be overwritten. More...
 
 initCreationForms ($a_new_type)
 Init creation froms. 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 ()
 
 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...
 
 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, $a_catch_errors=true)
 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...
 
 getTabs ()
 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 (ilColumnGUI $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...
 

Protected Attributes

 $log = null
 
- Protected Attributes inherited from ilObject2GUI
 $object_id
 
 $node_id
 
 $creation_forms = array()
 
 $id_type = array()
 
 $parent_id
 
 $access_handler
 
- Protected Attributes inherited from ilObjectGUI
 $ilErr
 
 $locator
 
 $user
 
 $access
 
 $settings
 
 $rbacreview
 
 $toolbar
 
 $rbacsystem
 
 $tmp_import_dir
 
 $tabs_gui = null
 
 $ctrl
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjFileGUI::__construct (   $a_id = 0,
  $a_id_type = self::REPOSITORY_NODE_ID,
  $a_parent_node_id = 0 
)

Constructor.

Parameters
int$a_id
int$a_id_type
int$a_parent_node_id

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

References ilLoggerFactory\getLogger().

35  {
36  $this->log = ilLoggerFactory::getLogger('file');
37  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
38  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ _goto()

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

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

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

922  {
923  global $DIC;
924  $ilErr = $DIC['ilErr'];
925  $lng = $DIC['lng'];
926  $ilAccess = $DIC['ilAccess'];
927 
928  if ($a_additional && substr($a_additional, -3) == "wsp") {
929  $_GET["baseClass"] = "ilsharedresourceGUI";
930  $_GET["wsp_id"] = $a_target;
931  include("ilias.php");
932  exit;
933  }
934 
935  // added support for direct download goto links
936  if ($a_additional && substr($a_additional, -8) == "download") {
937  ilObjectGUI::_gotoRepositoryNode($a_target, "sendfile");
938  }
939 
940  // static method, no workspace support yet
941 
942  if ($ilAccess->checkAccess("visible", "", $a_target)
943  || $ilAccess->checkAccess("read", "", $a_target)
944  ) {
945  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
946  } else {
947  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
948  ilUtil::sendFailure(sprintf(
949  $lng->txt("msg_no_perm_read_item"),
951  ), true);
953  }
954  }
955 
956  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
957  }
global $DIC
Definition: saml.php:7
$_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 963 of file class.ilObjFileGUI.php.

References $DIC, ilObject2GUI\$node_id, and object.

964  {
965  global $DIC;
966  $ilLocator = $DIC['ilLocator'];
967 
968  if (is_object($this->object)) {
969  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
970  }
971  }
global $DIC
Definition: saml.php:7
Create new PHPExcel object
obj_idprivate

◆ cancelDeleteFile()

ilObjFileGUI::cancelDeleteFile ( )

Cancels the file deletion.

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

1365  {
1366  $this->ctrl->redirect($this, "versions");
1367  }

◆ cancelDeleteVersions()

ilObjFileGUI::cancelDeleteVersions ( )

Cancels the file version deletion.

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

1335  {
1336  $this->ctrl->redirect($this, "versions");
1337  }

◆ 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 1378 of file class.ilObjFileGUI.php.

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

◆ confirmDeleteFile()

ilObjFileGUI::confirmDeleteFile ( )

Deletes this file object.

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

References array, and ilObject2GUI\checkPermissionBool().

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

◆ confirmDeleteVersions()

ilObjFileGUI::confirmDeleteVersions ( )

Deletes the file versions that were confirmed by the user.

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

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

1311  {
1312  global $DIC;
1313  $ilTabs = $DIC['ilTabs'];
1314 
1315  // has the user the rights to delete versions?
1316  if (!$this->checkPermissionBool("write")) {
1317  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
1318  }
1319 
1320  // delete versions after confirmation
1321  if (count($_POST["hist_id"]) > 0) {
1322  $this->object->deleteVersions($_POST["hist_id"]);
1323  ilUtil::sendSuccess($this->lng->txt("file_versions_deleted"), true);
1324  }
1325 
1326  $this->ctrl->setParameter($this, "hist_id", "");
1327  $this->ctrl->redirect($this, "versions");
1328  }
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.
global $DIC
Definition: saml.php:7
$_POST["username"]
+ 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 1244 of file class.ilObjFileGUI.php.

References $DIC, $html, $table, ilObject\_getIcon(), array, object, ilUtil\sendFailure(), and ilUtil\sendQuestion().

1245  {
1246  global $DIC;
1247  $ilTabs = $DIC['ilTabs'];
1248  $ilLocator = $DIC['ilLocator'];
1249 
1250  // get ids either from GET (if single item was clicked) or
1251  // from POST (if multiple items were selected)
1252  $request = $DIC->http()->request();
1253 
1254  $version_ids = [];
1255  if (isset($request->getQueryParams()['hist_id'])) {
1256  $version_ids = [$request->getQueryParams()['hist_id']];
1257  } elseif (isset($request->getParsedBody()['hist_id'])) {
1258  $version_ids = (array) $request->getParsedBody()['hist_id'];
1259  }
1260 
1261  if (count($version_ids) < 1) {
1262  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
1263  $this->ctrl->redirect($this, "versions");
1264  } else {
1265  $ilTabs->activateTab("id_versions");
1266 
1267  // check if all versions are selected
1268  $versionsToKeep = array_udiff($this->object->getVersions(), $version_ids, array($this, "compareHistoryIds"));
1269  if (count($versionsToKeep) < 1) {
1270  // set our message
1271  ilUtil::sendQuestion($this->lng->txt("file_confirm_delete_all_versions"));
1272 
1273  // show confirmation gui
1274  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1275  $conf_gui = new ilConfirmationGUI();
1276  $conf_gui->setFormAction($this->ctrl->getFormAction($this, "versions"));
1277  $conf_gui->setCancel($this->lng->txt("cancel"), "cancelDeleteFile");
1278  $conf_gui->setConfirm($this->lng->txt("confirm"), "confirmDeleteFile");
1279 
1280  $conf_gui->addItem(
1281  "id[]",
1282  $this->ref_id,
1283  $this->object->getTitle(),
1284  ilObject::_getIcon($this->object->getId(), "small", $this->object->getType()),
1285  $this->lng->txt("icon") . " " . $this->lng->txt("obj_" . $this->object->getType())
1286  );
1287 
1288  $html = $conf_gui->getHTML();
1289  } else {
1290  include_once("./Modules/File/classes/class.ilFileVersionTableGUI.php");
1291 
1292  ilUtil::sendQuestion($this->lng->txt("file_confirm_delete_versions"));
1293  $versions = $this->object->getVersions($version_ids);
1294 
1295  $table = new ilFileVersionTableGUI($this, 'versions', true);
1296  $table->setMaxCount(sizeof($versions));
1297  $table->setData($versions);
1298 
1299  $html = $table->getHTML();
1300  }
1301 
1302  $this->tpl->setVariable('ADM_CONTENT', $html);
1303  }
1304  }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
global $DIC
Definition: saml.php:7
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Create new PHPExcel object
obj_idprivate
if(empty($password)) $table
Definition: pwgen.php:24
Class ilFileVersionTableGUI.
$html
Definition: example_001.php:87
Confirmation screen class.
+ Here is the call graph for this function:

◆ edit()

ilObjFileGUI::edit ( )

edit object

public

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

References $DIC, $form, ilObjectGUI\$ilErr, array, ilObject2GUI\checkPermissionBool(), and initPropertiesForm().

546  {
547  global $DIC;
548  $ilTabs = $DIC['ilTabs'];
549  $ilErr = $DIC['ilErr'];
550 
551  if (!$this->checkPermissionBool("write")) {
552  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"));
553  }
554 
555  $ilTabs->activateTab("settings");
556 
557  $form = $this->initPropertiesForm();
558 
559  $val = array();
560  $val['title'] = $this->object->getTitle();
561  $val['description'] = $this->object->getLongDescription();
562  $val['rating'] = $this->object->hasRating();
563  $form->setValuesByArray($val);
564 
565  // Edit ecs export settings
566  include_once 'Modules/File/classes/class.ilECSFileSettings.php';
567  $ecs = new ilECSFileSettings($this->object);
568  $ecs->addSettingsToForm($form, 'file');
569 
570  $this->tpl->setContent($form->getHTML());
571 
572  return true;
573  }
Class ilECSFileSettings.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
global $DIC
Definition: saml.php:7
if(isset($_POST['submit'])) $form
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ executeCommand()

ilObjFileGUI::executeCommand ( )

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

References $_GET, $DIC, $ilCtrl, ilObjectGUI\$ilErr, $ilUser, $ret, ilObjectGUI\addHeaderAction(), ilObject2GUI\checkPermissionBool(), ilObject2GUI\getAccessHandler(), ilObject2GUI\getCreationMode(), ilCommonActionDispatcherGUI\getInstanceFromAjaxCall(), infoScreenForward(), ilLearningProgressBaseGUI\LP_CONTEXT_REPOSITORY, object, ilObject2GUI\prepareOutput(), and ilFileInputGUI\setPersonalWorkspaceQuotaCheck().

48  {
49  global $DIC;
50  $ilNavigationHistory = $DIC['ilNavigationHistory'];
51  $ilCtrl = $DIC['ilCtrl'];
52  $ilUser = $DIC['ilUser'];
53  $ilTabs = $DIC['ilTabs'];
54  $ilAccess = $DIC['ilAccess'];
55  $ilErr = $DIC['ilErr'];
56 
57  $next_class = $this->ctrl->getNextClass($this);
58  $cmd = $this->ctrl->getCmd();
59 
60  if ($this->id_type == self::WORKSPACE_NODE_ID) {
62  }
63 
64  if (!$this->getCreationMode()) {
65  if ($this->id_type == self::REPOSITORY_NODE_ID
66  && $this->checkPermissionBool("read")
67  ) {
68  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->node_id);
69  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
70  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
71 
72  // add entry to navigation history
73  $ilNavigationHistory->addItem(
74  $this->node_id,
75  $link,
76  "file"
77  );
78  }
79  }
80 
81  $this->prepareOutput();
82 
83  switch ($next_class) {
84  case "ilinfoscreengui":
85  $this->infoScreenForward(); // forwards command
86  break;
87 
88  case 'ilobjectmetadatagui':
89  if (!$this->checkPermissionBool("write")) {
90  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
91  }
92 
93  $ilTabs->activateTab("id_meta");
94 
95  $md_gui = new ilObjectMetaDataGUI($this->object);
96 
97  // todo: make this work
98  // $md_gui->addMDObserver($this->object,'MDUpdateListener','Technical');
99 
100  $this->ctrl->forwardCommand($md_gui);
101  break;
102 
103  // repository permissions
104  case 'ilpermissiongui':
105  $ilTabs->activateTab("id_permissions");
106  $perm_gui = new ilPermissionGUI($this);
107  $ret = $this->ctrl->forwardCommand($perm_gui);
108  break;
109 
110  case "ilexportgui":
111  $ilTabs->activateTab("export");
112  $exp_gui = new ilExportGUI($this);
113  $exp_gui->addFormat("xml");
114  $ret = $this->ctrl->forwardCommand($exp_gui);
115  break;
116 
117  case 'ilobjectcopygui':
118  $cp = new ilObjectCopyGUI($this);
119  $cp->setType('file');
120  $this->ctrl->forwardCommand($cp);
121  break;
122 
123  // personal workspace permissions
124  case "ilworkspaceaccessgui":
125  $ilTabs->activateTab("id_permissions");
126  $wspacc = new ilWorkspaceAccessGUI($this->node_id, $this->getAccessHandler());
127  $this->ctrl->forwardCommand($wspacc);
128  break;
129 
130  case "ilcommonactiondispatchergui":
132  $this->ctrl->forwardCommand($gui);
133  break;
134 
135  case "illearningprogressgui":
136  $ilTabs->activateTab('learning_progress');
137  $new_gui = new ilLearningProgressGUI(
139  $this->object->getRefId(),
140  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId()
141  );
142  $this->ctrl->forwardCommand($new_gui);
143  $this->tabs_gui->setTabActive('learning_progress');
144  break;
145 
146  default:
147  // in personal workspace use object2gui
148  if ($this->id_type == self::WORKSPACE_NODE_ID) {
149  $this->addHeaderAction();
150 
151  // coming from goto we need default command
152  if (empty($cmd)) {
153  $ilCtrl->setCmd("infoScreen");
154  }
155  $ilTabs->clearTargets();
156 
157  return parent::executeCommand();
158  }
159 
160  if (empty($cmd)) {
161  $cmd = "infoScreen";
162  }
163 
164  $this->$cmd();
165  break;
166  }
167 
168  $this->addHeaderAction();
169  }
Class ilObjectMetaDataGUI.
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.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
getAccessHandler()
Get access handler.
global $ilCtrl
Definition: ilias.php:18
Export User Interface Class.
static setPersonalWorkspaceQuotaCheck($a_value)
$ilUser
Definition: imgupload.php:18
ACL access handler GUI.
Create new PHPExcel object
obj_idprivate
$ret
Definition: parser.php:6
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
addHeaderAction()
Add header action menu.
Class ilObjUserTrackingGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
+ Here is the call graph for this function:

◆ getType()

ilObjFileGUI::getType ( )

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

42  {
43  return "file";
44  }

◆ 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 1085 of file class.ilObjFileGUI.php.

References ilObject2GUI\$access_handler, $description, $DIC, $filename, $ilUser, $object, $response, $result, $size, $title, ilObject2GUI\$tree, $type, 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().

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

References infoScreenForward().

717  {
718  $this->ctrl->setCmd("showSummary");
719  $this->ctrl->setCmdClass("ilinfoscreengui");
720  $this->infoScreenForward();
721  }
infoScreenForward()
show information screen
+ Here is the call graph for this function:

◆ infoScreenForward()

ilObjFileGUI::infoScreenForward ( )

show information screen

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

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

Referenced by executeCommand(), and infoScreen().

728  {
729  global $DIC;
730  $ilTabs = $DIC['ilTabs'];
731  $ilErr = $DIC['ilErr'];
732  $ilToolbar = $DIC['ilToolbar'];
733 
734  $ilTabs->activateTab("id_info");
735 
736  if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool("read")) {
737  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
738  }
739 
740  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
741  $info = new ilInfoScreenGUI($this);
742 
743  if ($this->checkPermissionBool("read", "sendfile")) {
744  // #9876
745  $this->lng->loadLanguageModule("file");
746 
747  // #14378
748  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
749  $button = ilLinkButton::getInstance();
750  $button->setCaption("file_download");
751  $button->setPrimary(true);
752 
753  // get permanent download link for repository
754  if ($this->id_type == self::REPOSITORY_NODE_ID) {
755  $button->setUrl(ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
756  } else {
757  $button->setUrl($this->ctrl->getLinkTarget($this, "sendfile"));
758  }
759 
760  $ilToolbar->addButtonInstance($button);
761  }
762 
763  $info->enablePrivateNotes();
764 
765  if ($this->checkPermissionBool("read")) {
766  $info->enableNews();
767  }
768 
769  // no news editing for files, just notifications
770  $info->enableNewsEditing(false);
771  if ($this->checkPermissionBool("write")) {
772  $news_set = new ilSetting("news");
773  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
774 
775  if ($enable_internal_rss) {
776  $info->setBlockProperty("news", "settings", true);
777  $info->setBlockProperty("news", "public_notifications_option", true);
778  }
779  }
780 
781  // standard meta data
782  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
783 
784  // File Info
785  $info->addSection($this->lng->txt("file_info"));
786  $info->addProperty($this->lng->txt("filename"), $this->object->getFileName());
787  $info->addProperty($this->lng->txt("type"), $this->object->guessFileType());
788 
789  $info->addProperty($this->lng->txt("size"), ilUtil::formatSize(ilObjFile::_lookupFileSize($this->object->getId()), 'long'));
790  $info->addProperty($this->lng->txt("version"), $this->object->getVersion());
791 
792  if ($this->object->getPageCount() > 0) {
793  $info->addProperty($this->lng->txt("page_count"), $this->object->getPageCount());
794  }
795 
796  // using getVersions function instead of ilHistory direct
797  $uploader = $this->object->getVersions();
798  $uploader = array_shift($uploader);
799  $uploader = $uploader["user_id"];
800 
801  $this->lng->loadLanguageModule("file");
802  include_once "Services/User/classes/class.ilUserUtil.php";
803  $info->addProperty($this->lng->txt("file_uploaded_by"), ilUserUtil::getNamePresentation($uploader));
804 
805  // download link added in repository
806  if ($this->id_type == self::REPOSITORY_NODE_ID && $this->checkPermissionBool("read", "sendfile")) {
807  $tpl = new ilTemplate("tpl.download_link.html", true, true, "Modules/File");
808  $tpl->setVariable("LINK", ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
809  $info->addProperty($this->lng->txt("download_link"), $tpl->get());
810  }
811 
812  if ($this->id_type == self::WORKSPACE_NODE_ID) {
813  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
814  }
815 
816  // display previews
817  include_once("./Services/Preview/classes/class.ilPreview.php");
818  if (!$this->ctrl->isAsynch()
819  && ilPreview::hasPreview($this->object->getId(), $this->object->getType())
820  && $this->checkPermissionBool("read")
821  ) {
822  include_once("./Services/Preview/classes/class.ilPreviewGUI.php");
823 
824  // get context for access checks later on
825  $context;
826  switch ($this->id_type) {
827  case self::WORKSPACE_NODE_ID:
828  case self::WORKSPACE_OBJECT_ID:
830  break;
831 
832  default:
834  break;
835  }
836 
837  $preview = new ilPreviewGUI($this->node_id, $context, $this->object->getId(), $this->access_handler);
838  $info->addProperty($this->lng->txt("preview"), $preview->getInlineHTML());
839  }
840 
841  // forward the command
842  // $this->ctrl->setCmd("showSummary");
843  // $this->ctrl->setCmdClass("ilinfoscreengui");
844  $this->ctrl->forwardCommand($info);
845  }
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.
global $DIC
Definition: saml.php:7
$preview
getPermanentLinkWidget($a_append=null, $a_center=false)
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 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, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static _lookupFileSize($a_id)
Lookups the file size of the file in bytes.
Create new PHPExcel object
obj_idprivate
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
$info
Definition: index.php:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCreationForms()

ilObjFileGUI::initCreationForms (   $a_new_type)
protected
Parameters
string$a_new_type

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

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

176  {
177  $forms = array();
178 
179  if ($this->id_type == self::WORKSPACE_NODE_ID) {
181  $this->lng->loadLanguageModule("file");
182  ilUtil::sendFailure($this->lng->txt("personal_workspace_quota_exceeded_warning"), true);
183  $this->ctrl->redirect($this, "cancel");
184  }
185  }
186 
187  // use drag-and-drop upload if configured
189  $forms[] = $this->initMultiUploadForm();
190  } else {
191  $forms[] = $this->initSingleUploadForm();
192  $forms[] = $this->initZipUploadForm();
193  }
194 
195  // repository only
196  if ($this->id_type != self::WORKSPACE_NODE_ID) {
197  $forms[self::CFORM_IMPORT] = $this->initImportForm('file');
198  $forms[self::CFORM_CLONE] = $this->fillCloneTemplate(null, "file");
199  }
200 
201  return $forms;
202  }
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)
Create styles array
The data for the language used.
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 1431 of file class.ilObjFileGUI.php.

References $lg, array, and object.

1432  {
1433  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
1434  if (is_object($lg)) {
1435  if ($this->object->hasRating()) {
1436  $lg->enableRating(
1437  true,
1438  null,
1439  false,
1440  array("ilcommonactiondispatchergui", "ilratinggui")
1441  );
1442  }
1443  }
1444 
1445  return $lg;
1446  }
$lg
Definition: example_018.php:62
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate

◆ 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 array, 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="")
Create styles array
The data for the language used.
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 582 of file class.ilObjFileGUI.php.

References $file, $form, $title, ilDiskQuotaHandler\isUploadPossible(), object, ilRadioOption\setInfo(), ilFormPropertyGUI\setInfo(), and ilTextAreaInputGUI\setRows().

Referenced by edit(), and update().

583  {
584  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
585 
586  $this->lng->loadLanguageModule('file');
587 
588  $form = new ilPropertyFormGUI();
589  $form->setFormAction($this->ctrl->getFormAction($this), 'update');
590  $form->setTitle($this->lng->txt('file_edit'));
591  $form->addCommandButton('update', $this->lng->txt('save'));
592  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
593 
594  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
595  $title->setValue($this->object->getTitle());
596  $title->setInfo($this->lng->txt("if_no_title_then_filename"));
597  $form->addItem($title);
598 
599  $upload_possible = true;
600  if ($this->id_type == self::WORKSPACE_NODE_ID) {
601  $upload_possible = ilDiskQuotaHandler::isUploadPossible();
602  }
603 
604  if ($upload_possible) {
605  $file = new ilFileStandardDropzoneInputGUI($this->lng->txt('obj_file'), 'file');
606  $file->setRequired(false);
607  $form->addItem($file);
608 
609  $group = new ilRadioGroupInputGUI('', 'replace');
610  $group->setValue(0);
611 
612  $replace = new ilRadioOption($this->lng->txt('replace_file'), 1);
613  $replace->setInfo($this->lng->txt('replace_file_info'));
614  $group->addOption($replace);
615 
616  $keep = new ilRadioOption($this->lng->txt('file_new_version'), 0);
617  $keep->setInfo($this->lng->txt('file_new_version_info'));
618  $group->addOption($keep);
619 
620  $file->addSubItem($group);
621  } else {
622  $file = new ilNonEditableValueGUI($this->lng->txt('obj_file'));
623  $file->setValue($this->lng->txt("personal_workspace_quota_exceeded_warning"));
624  $form->addItem($file);
625  }
626 
627  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
628  $desc->setRows(3);
629  #$desc->setCols(40);
630  $form->addItem($desc);
631 
632  if ($this->id_type == self::REPOSITORY_NODE_ID) {
633  $this->lng->loadLanguageModule('rating');
634  $rate = new ilCheckboxInputGUI($this->lng->txt('rating_activate_rating'), 'rating');
635  $rate->setInfo($this->lng->txt('rating_activate_rating_info'));
636  $form->addItem($rate);
637  }
638 
639  return $form;
640  }
This class represents an option in a radio group.
This class represents a property form user interface.
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.
if(isset($_POST['submit'])) $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.
Create new PHPExcel object
obj_idprivate
This class represents a text area property in a property form.
Class ilFileStandardDropzoneInputGUI.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 208 of file class.ilObjFileGUI.php.

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

Referenced by initCreationForms(), and save().

209  {
210  global $DIC;
211  $lng = $DIC['lng'];
212 
213  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
214  $single_form_gui = new ilPropertyFormGUI();
215  $single_form_gui->setMultipart(true);
216 
217  // File Title
218  $in_title = new ilTextInputGUI($lng->txt("title"), "title");
219  $in_title->setInfo($this->lng->txt("if_no_title_then_filename"));
220  $in_title->setSize(min(40, ilObject::TITLE_LENGTH));
221  $in_title->setMaxLength(ilObject::TITLE_LENGTH);
222  $single_form_gui->addItem($in_title);
223 
224  // File Description
225  $in_descr = new ilTextAreaInputGUI($lng->txt("description"), "description");
226  $single_form_gui->addItem($in_descr);
227 
228  // File
229  $in_file = new ilFileInputGUI($lng->txt("file"), "upload_file");
230  $in_file->setRequired(true);
231  $single_form_gui->addItem($in_file);
232 
233  $single_form_gui->addCommandButton("save", $this->lng->txt($this->type . "_add"));
234  $single_form_gui->addCommandButton("saveAndMeta", $this->lng->txt("file_add_and_metadata"));
235  $single_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
236 
237  $single_form_gui->setTableWidth("600px");
238  $single_form_gui->setTarget($this->getTargetFrame("save"));
239  $single_form_gui->setTitle($this->lng->txt($this->type . "_new"));
240  $single_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.svg'), $this->lng->txt('obj_file'));
241 
242  $this->ctrl->setParameter($this, "new_type", "file");
243 
244  $single_form_gui->setFormAction($this->ctrl->getFormAction($this, "save"));
245 
246  return $single_form_gui;
247  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
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 342 of file class.ilObjFileGUI.php.

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

Referenced by initCreationForms(), and saveUnzip().

343  {
344  global $DIC;
345  $lng = $DIC['lng'];
346 
347  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
348  $zip_form_gui = new ilPropertyFormGUI();
349  $zip_form_gui->setMultipart(true);
350 
351  // File
352  $in_file = new ilFileInputGUI($lng->txt("file"), "zip_file");
353  $in_file->setRequired(true);
354  $in_file->setSuffixes(array("zip"));
355  $zip_form_gui->addItem($in_file);
356 
357  // Take over structure
358  $in_str = new ilCheckboxInputGUI($this->lng->txt("take_over_structure"), "adopt_structure");
359  $in_str->setInfo($this->lng->txt("take_over_structure_info"));
360  $zip_form_gui->addItem($in_str);
361 
362  $zip_form_gui->addCommandButton("saveUnzip", $this->lng->txt($this->type . "_add"));
363  $zip_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
364 
365  $zip_form_gui->setTableWidth("600px");
366  $zip_form_gui->setTarget($this->getTargetFrame("save"));
367  $zip_form_gui->setTitle($this->lng->txt("header_zip"));
368  $zip_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.svg'), $this->lng->txt('obj_file'));
369 
370  $this->ctrl->setParameter($this, "new_type", "file");
371 
372  $zip_form_gui->setFormAction($this->ctrl->getFormAction($this, "saveUnzip"));
373 
374  return $zip_form_gui;
375  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
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="")
Create styles array
The data for the language used.
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 1403 of file class.ilObjFileGUI.php.

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

1404  {
1405  global $DIC;
1406  $ilTabs = $DIC['ilTabs'];
1407 
1408  // has the user the rights to delete the file?
1409  if (!$this->checkPermissionBool("write")) {
1410  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
1411  }
1412 
1413  // get ids either from GET (if single item was clicked) or
1414  // from POST (if multiple items were selected)
1415  $version_ids = isset($_GET["hist_id"]) ? array($_GET["hist_id"]) : $_POST["hist_id"];
1416 
1417  // more than one entry selected?
1418  if (count($version_ids) != 1) {
1419  ilUtil::sendInfo($this->lng->txt("file_rollback_select_exact_one"), true);
1420  $this->ctrl->redirect($this, "versions");
1421  }
1422 
1423  // rollback the version
1424  $new_version = $this->object->rollback($version_ids[0]);
1425 
1426  ilUtil::sendSuccess(sprintf($this->lng->txt("file_rollback_done"), $new_version["rollback_version"]), true);
1427  $this->ctrl->redirect($this, "versions");
1428  }
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.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Create styles array
The data for the language used.
$_POST["username"]
+ Here is the call graph for this function:

◆ save()

ilObjFileGUI::save ( )

save object

public

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

References $description, $DIC, $ilUser, $result, $target, $title, ilObjFileAccess\_getFileExtension(), ilChangeEvent\_recordWriteEvent(), array, ilObject2GUI\checkPermissionBool(), ilMimeTypeUtil\getMimeType(), ilObject2GUI\handleAutoRating(), initSingleUploadForm(), ilObject2GUI\putObjectInTree(), ilUtil\redirect(), and ilUtil\sendSuccess().

Referenced by saveAndMeta().

256  {
257  global $DIC;
258  $ilUser = $DIC->user();
259 
260  if (!$this->checkPermissionBool("create", "", "file")) {
261  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
262  }
263 
264  $single_form_gui = $this->initSingleUploadForm();
265 
266  if ($single_form_gui->checkInput()) {
267  $title = $single_form_gui->getInput("title");
268  $description = $single_form_gui->getInput("description");
269  $upload_file = $single_form_gui->getInput("upload_file");
270 
271  if (trim($title) == "") {
272  $title = $upload_file["name"];
273  } else {
274  // BEGIN WebDAV: Ensure that object title ends with the filename extension
275  $fileExtension = ilObjFileAccess::_getFileExtension($upload_file["name"]);
276  $titleExtension = ilObjFileAccess::_getFileExtension($title);
277  if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
278  $title .= '.' . $fileExtension;
279  }
280  // END WebDAV: Ensure that object title ends with the filename extension
281  }
282 
283  // create and insert file in grp_tree
284 
285  $fileObj = new ilObjFile();
286  $fileObj->setTitle($title);
287  $fileObj->setDescription($description);
288  $fileObj->setFileName($upload_file["name"]);
289 
290  $fileObj->setFileType(ilMimeTypeUtil::getMimeType(
291  "",
292  $upload_file["name"],
293  $upload_file["type"]
294  ));
295  $fileObj->setFileSize($upload_file["size"]);
296  $this->object_id = $fileObj->create();
297 
298  $this->putObjectInTree($fileObj, $this->parent_id);
299 
300  // upload file to filesystem
301  $fileObj->createDirectory();
302  if ($result = $fileObj->getUploadFile($upload_file["tmp_name"], $upload_file["name"])) {
303  $fileObj->setFileName($result->getName());
304  }
305 
306  $this->handleAutoRating($fileObj);
307 
308  // BEGIN ChangeEvent: Record write event.
309  ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
310  // END ChangeEvent: Record write event.
311 
312  ilUtil::sendSuccess($this->lng->txt("file_added"), true);
313 
314  if ($this->ctrl->getCmd() == "saveAndMeta") {
315  $this->ctrl->setParameter($this, "new_type", "");
316  $target = $this->ctrl->getLinkTargetByClass(array("ilobjectmetadatagui", "ilmdeditorgui"), "listSection", "", false, false);
318  } else {
319  $this->ctrl->returnToParent($this);
320  }
321  } else {
322  $single_form_gui->setValuesByPost();
323  $this->tpl->setContent($single_form_gui->getHTML());
324  }
325  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
initSingleUploadForm()
FORM: Init single upload form.
$result
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
global $DIC
Definition: saml.php:7
static _getFileExtension($a_file_name)
Gets the file extension of the specified file name.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
static getMimeType($a_file='', $a_filename='', $a_mime='')
handleAutoRating(ilObject $a_new_obj)
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
static redirect($a_script)
+ 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 333 of file class.ilObjFileGUI.php.

References save().

334  {
335  $this->save();
336  }
save()
save object
+ Here is the call graph for this function:

◆ saveUnzip()

ilObjFileGUI::saveUnzip ( )

saveUnzip object

public

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

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

384  {
385  $zip_form_gui = $this->initZipUploadForm();
386 
387  if ($this->checkPermissionBool("create", "", "file")) {
388  if ($zip_form_gui->checkInput()) {
389  $zip_file = $zip_form_gui->getInput("zip_file");
390  $adopt_structure = $zip_form_gui->getInput("adopt_structure");
391 
392  include_once("Services/Utilities/classes/class.ilFileUtils.php");
393 
394  // Create unzip-directory
395  $newDir = ilUtil::ilTempnam();
396  ilUtil::makeDir($newDir);
397 
398  // Check if permission is granted for creation of object, if necessary
399  if ($this->id_type != self::WORKSPACE_NODE_ID) {
400  $type = ilObject::_lookupType((int) $this->parent_id, true);
401  } else {
402  $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false);
403  }
404 
405  $tree = $access_handler = null;
406  switch ($type) {
407  // workspace structure
408  case 'wfld':
409  case 'wsrt':
410  $permission = $this->checkPermissionBool("create", "", "wfld");
411  $containerType = "WorkspaceFolder";
412  $tree = $this->tree;
414  break;
415 
416  // use categories as structure
417  case 'cat':
418  case 'root':
419  $permission = $this->checkPermissionBool("create", "", "cat");
420  $containerType = "Category";
421  break;
422 
423  // use folders as structure (in courses)
424  default:
425  $permission = $this->checkPermissionBool("create", "", "fold");
426  $containerType = "Folder";
427  break;
428  }
429  // processZipFile (
430  // Dir to unzip,
431  // Path to uploaded file,
432  // should a structure be created (+ permission check)?
433  // ref_id of parent
434  // object that contains files (folder or category)
435  // should sendInfo be persistent?)
436  try {
437  $processDone = ilFileUtils::processZipFile(
438  $newDir,
439  $zip_file["tmp_name"],
440  ($adopt_structure && $permission),
441  $this->parent_id,
442  $containerType,
443  $tree,
445  );
446  ilUtil::sendSuccess($this->lng->txt("file_added"), true);
447  } catch (ilFileUtilsException $e) {
448  ilUtil::sendFailure($e->getMessage(), true);
449  }
450 
451  ilUtil::delDir($newDir);
452  $this->ctrl->returnToParent($this);
453  } else {
454  $zip_form_gui->setValuesByPost();
455  $this->tpl->setContent($zip_form_gui->getHTML());
456  }
457  } else {
458  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
459  }
460  }
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.
$type
getAccessHandler()
Get access handler.
initZipUploadForm($a_mode="create")
FORM: Init zip upload form.
static 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
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($a_temp_path=null)
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
Class to report exception.
+ Here is the call graph for this function:

◆ sendFile()

ilObjFileGUI::sendFile ( )

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

References $_GET, $DIC, ilChangeEvent\_recordReadEvent(), ilLPStatusWrapper\_updateStatus(), ilObject2GUI\checkPermissionBool(), and object.

644  {
645  global $DIC;
646 
647  try {
648  if (ANONYMOUS_USER_ID == $DIC->user()->getId() && isset($_GET['transaction'])) {
649  $a_hist_entry_id = isset($_GET["hist_id"]) ? $_GET["hist_id"] : null;
650  $this->object->sendFile($a_hist_entry_id);
651  }
652 
653  if ($this->checkPermissionBool("read")) {
654  // BEGIN ChangeEvent: Record read event.
655  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
656 
657  // Record read event and catchup with write events
659  $this->object->getType(),
660  $this->object->getRefId(),
661  $this->object->getId(),
662  $DIC->user()->getId()
663  );
664  // END ChangeEvent: Record read event.
665 
666  require_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
667  ilLPStatusWrapper::_updateStatus($this->object->getId(), $DIC->user()->getId());
668 
669  $a_hist_entry_id = isset($_GET["hist_id"]) ? $_GET["hist_id"] : null;
670  $this->object->sendFile($a_hist_entry_id);
671  } else {
672  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
673  }
674  } catch (\ILIAS\Filesystem\Exception\FileNotFoundException $e) {
675  $this->ilErr->raiseError($e->getMessage(), $this->ilErr->MESSAGE);
676  }
677 
678  return true;
679  }
static _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.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
Class BaseForm.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
Create new PHPExcel object
obj_idprivate
Class FlySystemFileAccessTest.
+ Here is the call graph for this function:

◆ setTabs()

ilObjFileGUI::setTabs ( )

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

References $DIC, ilObjectGUI\$lng, array, ilLearningProgressAccess\checkAccess(), ilObject2GUI\checkPermissionBool(), and object.

850  {
851  global $DIC;
852  $ilTabs = $DIC['ilTabs'];
853  $lng = $DIC['lng'];
854  $ilHelp = $DIC['ilHelp'];
855 
856  $ilHelp->setScreenIdComponent("file");
857 
858  $this->ctrl->setParameter($this, "ref_id", $this->node_id);
859 
860  if ($this->checkPermissionBool("visible") || $this->checkPermissionBool("read")) {
861  $ilTabs->addTab(
862  "id_info",
863  $lng->txt("info_short"),
864  $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilinfoscreengui"), "showSummary")
865  );
866  }
867 
868  if ($this->checkPermissionBool("write")) {
869  $ilTabs->addTab(
870  "settings",
871  $lng->txt("edit"),
872  $this->ctrl->getLinkTarget($this, "edit")
873  );
874  }
875 
876  if ($this->checkPermissionBool("write")) {
877  $ilTabs->addTab(
878  "id_versions",
879  $lng->txt("versions"),
880  $this->ctrl->getLinkTarget($this, "versions")
881  );
882  }
883 
884  require_once 'Services/Tracking/classes/class.ilLearningProgressAccess.php';
885  if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
886  $ilTabs->addTab(
887  'learning_progress',
888  $lng->txt('learning_progress'),
889  $this->ctrl->getLinkTargetByClass(array(__CLASS__, 'illearningprogressgui'), '')
890  );
891  }
892 
893  // meta data
894  if ($this->checkPermissionBool("write")) {
895  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
896  $mdgui = new ilObjectMetaDataGUI($this->object);
897  $mdtab = $mdgui->getTab();
898  if ($mdtab) {
899  $ilTabs->addTab(
900  "id_meta",
901  $lng->txt("meta_data"),
902  $mdtab
903  );
904  }
905  }
906 
907  // export
908  if ($this->checkPermissionBool("write")) {
909  $ilTabs->addTab(
910  "export",
911  $lng->txt("export"),
912  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
913  );
914  }
915 
916  // will add permission tab if needed
917  parent::setTabs();
918  }
Class ilObjectMetaDataGUI.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
global $DIC
Definition: saml.php:7
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:

◆ update()

ilObjFileGUI::update ( )

updates object entry in object_data

public

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

References ilObjectGUI\$data, $DIC, $filename, $form, $ilUser, $result, $title, ilChangeEvent\_catchupWriteEvents(), ilChangeEvent\_recordWriteEvent(), initPropertiesForm(), object, ilUtil\redirect(), and ilUtil\sendSuccess().

469  {
470  global $DIC;
471  $ilTabs = $DIC['ilTabs'];
472 
473  $form = $this->initPropertiesForm();
474  if (!$form->checkInput()) {
475  $ilTabs->activateTab("settings");
476  $form->setValuesByPost();
477  $this->tpl->setContent($form->getHTML());
478 
479  return false;
480  }
481 
482  $data = $form->getInput('file');
483 
484  // delete trailing '/' in filename
485  $data["name"] = rtrim($data["name"], '/');
486 
487  $filename = empty($data["name"]) ? $this->object->getFileName() : $data["name"];
488  $title = $form->getInput('title');
489  if (strlen(trim($title)) == 0) {
490  $title = $filename;
491  } else {
492  $title = $this->object->checkFileExtension($filename, $title);
493  }
494  $this->object->setTitle($title);
495 
496  if (!empty($data["name"])) {
497  $result = null;
498  switch ($form->getInput('replace')) {
499  case 1:
500  $this->object->deleteVersions();
501  $this->object->clearDataDirectory();
502  $result = $this->object->replaceFile($data['tmp_name'], $data['name']);
503  break;
504  case 0:
505  $result = $this->object->addFileVersion($data['tmp_name'], $data['name']);
506  break;
507  }
508  if ($result) {
509  $this->object->setFileType($result->getMimeType());
510  $this->object->setFileSize($result->getSize());
511  $this->object->setFilename($result->getName());
512  }
513  }
514 
515  $this->object->setDescription($form->getInput('description'));
516  $this->object->setRating($form->getInput('rating'));
517 
518  $this->update = $this->object->update();
519 
520  // BEGIN ChangeEvent: Record update event.
521  if (!empty($data["name"])) {
522  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
523  global $DIC;
524  $ilUser = $DIC['ilUser'];
525  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
526  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
527  }
528  // END ChangeEvent: Record update event.
529 
530  // Update ecs export settings
531  include_once 'Modules/File/classes/class.ilECSFileSettings.php';
532  $ecs = new ilECSFileSettings($this->object);
533  $ecs->handleSettingsUpdate();
534 
535  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
536  ilUtil::redirect($this->ctrl->getLinkTarget($this, 'versions', '', false, false));
537  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilECSFileSettings.
$result
global $DIC
Definition: saml.php:7
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
static _catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
if(isset($_POST['submit'])) $form
$ilUser
Definition: imgupload.php:18
Create new PHPExcel object
obj_idprivate
static redirect($a_script)
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 1012 of file class.ilObjFileGUI.php.

References $_POST, $DIC, $files, $response, $result, array, ilObject2GUI\checkPermissionBool(), exit, ilObject2GUI\handleAfterSaveCallback(), handleFileUpload(), ilFileUtils\hasValidExtension(), header, initMultiUploadForm(), object, and ilUtil\sendInfo().

1013  {
1014  global $DIC;
1015 
1016  $response = new stdClass();
1017  $response->error = null;
1018  $response->debug = null;
1019 
1020  $files = $_FILES;
1021 
1022  // #14249 - race conditions because of concurrent uploads
1023  $after_creation_callback = (int) $_REQUEST["crtcb"];
1024  if ($after_creation_callback) {
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  try {
1033  if (!$this->checkPermissionBool("create", "", "file")) {
1034  $response->error = $this->lng->txt("permission_denied");
1035  } else {
1036  // handle the file
1037  $inp = $dnd_form_gui->getInput("upload_files");
1038  $this->log->debug("ilObjFileGUI::uploadFiles " . print_r($_POST, true));
1039  $this->log->debug("ilObjFileGUI::uploadFiles " . print_r($_FILES, true));
1040  $fileresult = $this->handleFileUpload($inp);
1041  if ($fileresult) {
1042  $response = (object) array_merge((array) $response, (array) $fileresult);
1043  }
1044  }
1045  } catch (Exception $ex) {
1046  $response->error = $ex->getMessage();
1047  }
1048  } else {
1049  $dnd_input = $dnd_form_gui->getItemByPostVar("upload_files");
1050  $response->error = $dnd_input->getAlert();
1051  }
1052 
1053  if ($after_creation_callback
1054  && sizeof($this->after_creation_callback_objects)
1055  ) {
1056  foreach ($this->after_creation_callback_objects as $new_file_obj) {
1057  ilObject2GUI::handleAfterSaveCallback($new_file_obj, $after_creation_callback);
1058  }
1059  unset($this->after_creation_callback_objects);
1060  }
1061 
1062  // send response object (don't use 'application/json' as IE wants to download it!)
1063  header('Vary: Accept');
1064  header('Content-type: text/plain');
1065 
1066  foreach ($DIC->upload()->getResults() as $result) {
1067  if (!ilFileUtils::hasValidExtension($result->getName())) {
1068  $this->lng->loadLanguageModule('file');
1069  ilUtil::sendInfo($this->lng->txt('file_upload_info_file_with_critical_unknown_extension_later_renamed_when_downloading'), true);
1070  }
1071  }
1072  echo json_encode($response);
1073  // no further processing!
1074  exit;
1075  }
$files
Definition: add-vimline.php:18
handleFileUpload($file_upload)
Handles the upload of a single file and adds it to the parent object.
$result
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
global $DIC
Definition: saml.php:7
static hasValidExtension($a_filename)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static handleAfterSaveCallback(ilObject $a_obj, $a_callback_ref_id)
After creation callback.
Add a drawing to the header
Definition: 04printing.php:69
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
initMultiUploadForm()
Initializes the upload form for multiple files.
$response
$_POST["username"]
+ Here is the call graph for this function:

◆ versions()

ilObjFileGUI::versions ( )

file versions/history

public

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

References $DIC, $table, and ilObject2GUI\checkPermissionBool().

688  {
689  global $DIC;
690  $ilTabs = $DIC['ilTabs'];
691 
692  $ilTabs->activateTab("id_versions");
693 
694  if (!$this->checkPermissionBool("write")) {
695  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
696  }
697 
698  // get versions
699  $versions = $this->object->getVersions();
700 
701  // build versions table
702  require_once("Modules/File/classes/class.ilFileVersionTableGUI.php");
703  $table = new ilFileVersionTableGUI($this, "versions");
704  $table->setMaxCount(sizeof($versions));
705  $table->setData($versions);
706 
707  $this->tpl->setVariable("ADM_CONTENT", $table->getHTML());
708  }
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
global $DIC
Definition: saml.php:7
if(empty($password)) $table
Definition: pwgen.php:24
Class ilFileVersionTableGUI.
+ Here is the call graph for this function:

Field Documentation

◆ $log

ilObjFileGUI::$log = null
protected

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

◆ $object

ilObjFileGUI::$object

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

Referenced by handleFileUpload().


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