ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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

 __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 ()
 
 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...
 
- 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 ()
 viewObject container presentation for "administration -> repository, trash, permissions" More...
 
 deleteObject ($a_error=false)
 Display deletion confirmation screen. More...
 
 cloneAllObject ()
 Clone single (not container object) Method is overwritten in ilContainerGUI. More...
 
 redirectAfterCreation ()
 Redirect after creation, see https://docu.ilias.de/goto_docu_wiki_wpage_5035_1357.html. More...
 
 addToDeskObject ()
 
 removeFromDeskObject ()
 

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

const CMD_EDIT = "edit"
 
const CMD_VERSIONS = "versions"
 
 $object
 
 $lng
 
- 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 ($mode="create")
 
 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...
 
 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
 getObjectService ()
 Get object service. More...
 
 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...
 
 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
 
 $obj_service
 
- 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
 
 $rbacsystem
 
 $settings
 
 $rbacreview
 
 $toolbar
 
 $tmp_import_dir
 
 $tabs_gui = null
 
 $ctrl
 
 $object_service
 
 $favourites
 

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ilLoggerFactory\getLogger().

41  {
42  global $DIC;
43  $this->lng = $DIC->language();
44  $this->log = ilLoggerFactory::getLogger('file');
45  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
46  $this->obj_service = $DIC->object();
47  $this->lng->loadLanguageModule("file");
48  }
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
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 896 of file class.ilObjFileGUI.php.

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

897  {
898  global $DIC;
899  $ilErr = $DIC['ilErr'];
900  $lng = $DIC['lng'];
901  $ilAccess = $DIC['ilAccess'];
902 
903  if ($a_additional && substr($a_additional, -3) == "wsp") {
904  $_GET["baseClass"] = "ilsharedresourceGUI";
905  $_GET["wsp_id"] = $a_target;
906  include("ilias.php");
907  exit;
908  }
909 
910  // added support for direct download goto links
911  if ($a_additional && substr($a_additional, -8) == "download") {
912  ilObjectGUI::_gotoRepositoryNode($a_target, "sendfile");
913  }
914 
915  // static method, no workspace support yet
916 
917  if ($ilAccess->checkAccess("visible", "", $a_target)
918  || $ilAccess->checkAccess("read", "", $a_target)
919  ) {
920  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
921  } else {
922  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
923  ilUtil::sendFailure(sprintf(
924  $lng->txt("msg_no_perm_read_item"),
926  ), true);
928  }
929  }
930 
931  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
932  }
exit
Definition: login.php:29
$_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.
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ addLocatorItems()

ilObjFileGUI::addLocatorItems ( )

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

References $DIC, and ilObject2GUI\$node_id.

939  {
940  global $DIC;
941  $ilLocator = $DIC['ilLocator'];
942 
943  if (is_object($this->object)) {
944  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
945  }
946  }
$DIC
Definition: xapitoken.php:46

◆ edit()

ilObjFileGUI::edit ( )

edit object

public

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

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

537  {
538  global $DIC;
539  $ilTabs = $DIC['ilTabs'];
540  $ilErr = $DIC['ilErr'];
541 
542  if (!$this->checkPermissionBool("write")) {
543  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"));
544  }
545 
546  $ilTabs->activateTab("settings");
547 
548  $form = $this->initPropertiesForm(self::CMD_EDIT);
549 
550  $val = array();
551  $val['title'] = $this->object->getTitle();
552  $val['description'] = $this->object->getLongDescription();
553  $val['rating'] = $this->object->hasRating();
554  $form->setValuesByArray($val);
555 
556  // Edit ecs export settings
557  include_once 'Modules/File/classes/class.ilECSFileSettings.php';
558  $ecs = new ilECSFileSettings($this->object);
559  $ecs->addSettingsToForm($form, 'file');
560 
561  $this->tpl->setContent($form->getHTML());
562 
563  return true;
564  }
Class ilECSFileSettings.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
initPropertiesForm($mode="create")
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ executeCommand()

ilObjFileGUI::executeCommand ( )

Definition at line 57 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, ilObject2GUI\prepareOutput(), and ilFileInputGUI\setPersonalWorkspaceQuotaCheck().

58  {
59  global $DIC;
60  $ilNavigationHistory = $DIC['ilNavigationHistory'];
61  $ilCtrl = $DIC['ilCtrl'];
62  $ilUser = $DIC['ilUser'];
63  $ilTabs = $DIC['ilTabs'];
64  $ilAccess = $DIC['ilAccess'];
65  $ilErr = $DIC['ilErr'];
66 
67  $next_class = $this->ctrl->getNextClass($this);
68  $cmd = $this->ctrl->getCmd();
69 
70  if ($this->id_type == self::WORKSPACE_NODE_ID) {
72  }
73 
74  if (!$this->getCreationMode()) {
75  if ($this->id_type == self::REPOSITORY_NODE_ID
76  && $this->checkPermissionBool("read")
77  ) {
78  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->node_id);
79  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
80  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
81 
82  // add entry to navigation history
83  $ilNavigationHistory->addItem(
84  $this->node_id,
85  $link,
86  "file"
87  );
88  }
89  }
90 
91  $this->prepareOutput();
92 
93  switch ($next_class) {
94  case "ilinfoscreengui":
95  $this->infoScreenForward(); // forwards command
96  break;
97 
98  case 'ilobjectmetadatagui':
99  if (!$this->checkPermissionBool("write")) {
100  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
101  }
102 
103  $ilTabs->activateTab("id_meta");
104 
105  $md_gui = new ilObjectMetaDataGUI($this->object);
106 
107  // todo: make this work
108  // $md_gui->addMDObserver($this->object,'MDUpdateListener','Technical');
109 
110  $this->ctrl->forwardCommand($md_gui);
111  break;
112 
113  // repository permissions
114  case 'ilpermissiongui':
115  $ilTabs->activateTab("id_permissions");
116  $perm_gui = new ilPermissionGUI($this);
117  $ret = $this->ctrl->forwardCommand($perm_gui);
118  break;
119 
120  case "ilexportgui":
121  $ilTabs->activateTab("export");
122  $exp_gui = new ilExportGUI($this);
123  $exp_gui->addFormat("xml");
124  $ret = $this->ctrl->forwardCommand($exp_gui);
125  break;
126 
127  case 'ilobjectcopygui':
128  $cp = new ilObjectCopyGUI($this);
129  $cp->setType('file');
130  $this->ctrl->forwardCommand($cp);
131  break;
132 
133  // personal workspace permissions
134  case "ilworkspaceaccessgui":
135  $ilTabs->activateTab("id_permissions");
136  $wspacc = new ilWorkspaceAccessGUI($this->node_id, $this->getAccessHandler());
137  $this->ctrl->forwardCommand($wspacc);
138  break;
139 
140  case "ilcommonactiondispatchergui":
142  $this->ctrl->forwardCommand($gui);
143  break;
144 
145  case "illearningprogressgui":
146  $ilTabs->activateTab('learning_progress');
147  $new_gui = new ilLearningProgressGUI(
149  $this->object->getRefId(),
150  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId()
151  );
152  $this->ctrl->forwardCommand($new_gui);
153  $this->tabs_gui->setTabActive('learning_progress');
154  break;
155  case strtolower(ilFileVersionsGUI::class):
156  $this->tabs_gui->activateTab("id_versions");
157 
158  if (!$this->checkPermissionBool("write")) {
159  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
160  }
161  $this->ctrl->forwardCommand(new ilFileVersionsGUI($this->object));
162  break;
163  default:
164  // in personal workspace use object2gui
165  if ($this->id_type == self::WORKSPACE_NODE_ID) {
166  $this->addHeaderAction();
167 
168  // coming from goto we need default command
169  if (empty($cmd)) {
170  $ilCtrl->setCmd("infoScreen");
171  }
172  $ilTabs->clearTargets();
173 
174  return parent::executeCommand();
175  }
176 
177  if (empty($cmd)) {
178  $cmd = "infoScreen";
179  }
180 
181  $this->$cmd();
182  break;
183  }
184 
185  $this->addHeaderAction();
186  }
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.
$_GET["client_id"]
getAccessHandler()
Get access handler.
Class ilFileVersionsGUI.
global $ilCtrl
Definition: ilias.php:18
Export User Interface Class.
static setPersonalWorkspaceQuotaCheck($a_value)
$ilUser
Definition: imgupload.php:18
ACL access handler GUI.
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46
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 51 of file class.ilObjFileGUI.php.

52  {
53  return "file";
54  }

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

References infoScreenForward().

698  {
699  $this->ctrl->setCmd("showSummary");
700  $this->ctrl->setCmdClass("ilinfoscreengui");
701  $this->infoScreenForward();
702  }
infoScreenForward()
show information screen
+ Here is the call graph for this function:

◆ infoScreenForward()

ilObjFileGUI::infoScreenForward ( )

show information screen

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

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

Referenced by executeCommand(), and infoScreen().

709  {
710  global $DIC;
711  $ilTabs = $DIC['ilTabs'];
712  $ilErr = $DIC['ilErr'];
713  $ilToolbar = $DIC['ilToolbar'];
714 
715  $ilTabs->activateTab("id_info");
716 
717  if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool("read")) {
718  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
719  }
720 
721  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
722  $info = new ilInfoScreenGUI($this);
723 
724  if ($this->checkPermissionBool("read", "sendfile")) {
725  // #14378
726  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
727  $button = ilLinkButton::getInstance();
728  $button->setCaption("file_download");
729  $button->setPrimary(true);
730 
731  // get permanent download link for repository
732  if ($this->id_type == self::REPOSITORY_NODE_ID) {
733  $button->setUrl(ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
734  } else {
735  $button->setUrl($this->ctrl->getLinkTarget($this, "sendfile"));
736  }
737 
738  $ilToolbar->addButtonInstance($button);
739  }
740 
741  $info->enablePrivateNotes();
742 
743  if ($this->checkPermissionBool("read")) {
744  $info->enableNews();
745  }
746 
747  // no news editing for files, just notifications
748  $info->enableNewsEditing(false);
749  if ($this->checkPermissionBool("write")) {
750  $news_set = new ilSetting("news");
751  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
752 
753  if ($enable_internal_rss) {
754  $info->setBlockProperty("news", "settings", true);
755  $info->setBlockProperty("news", "public_notifications_option", true);
756  }
757  }
758 
759  // standard meta data
760  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
761 
762  // File Info
763  $info->addSection($this->lng->txt("file_info"));
764  $info->addProperty($this->lng->txt("filename"), $this->secure($this->object->getFileName()));
765  $info->addProperty($this->lng->txt("type"), $this->object->guessFileType());
766 
767  $info->addProperty($this->lng->txt("size"), ilUtil::formatSize(ilObjFile::_lookupFileSize($this->object->getId()), 'long'));
768  $info->addProperty($this->lng->txt("version"), $this->object->getVersion());
769 
770  if ($this->object->getPageCount() > 0) {
771  $info->addProperty($this->lng->txt("page_count"), $this->object->getPageCount());
772  }
773 
774  // using getVersions function instead of ilHistory direct
775  $uploader = $this->object->getVersions();
776  $uploader = array_shift($uploader);
777  $uploader = $uploader["user_id"];
778 
779  include_once "Services/User/classes/class.ilUserUtil.php";
780  $info->addProperty($this->lng->txt("file_uploaded_by"), ilUserUtil::getNamePresentation($uploader));
781 
782  // download link added in repository
783  if ($this->id_type == self::REPOSITORY_NODE_ID && $this->checkPermissionBool("read", "sendfile")) {
784  $tpl = new ilTemplate("tpl.download_link.html", true, true, "Modules/File");
785  $tpl->setVariable("LINK", ilObjFileAccess::_getPermanentDownloadLink($this->node_id));
786  $info->addProperty($this->lng->txt("download_link"), $tpl->get());
787  }
788 
789  if ($this->id_type == self::WORKSPACE_NODE_ID) {
790  $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
791  }
792 
793  // display previews
794  include_once("./Services/Preview/classes/class.ilPreview.php");
795  if (!$this->ctrl->isAsynch()
796  && ilPreview::hasPreview($this->object->getId(), $this->object->getType())
797  && $this->checkPermissionBool("read")
798  ) {
799  include_once("./Services/Preview/classes/class.ilPreviewGUI.php");
800 
801  // get context for access checks later on
802  $context;
803  switch ($this->id_type) {
804  case self::WORKSPACE_NODE_ID:
805  case self::WORKSPACE_OBJECT_ID:
807  break;
808 
809  default:
811  break;
812  }
813 
814  $preview = new ilPreviewGUI($this->node_id, $context, $this->object->getId(), $this->access_handler);
815  $info->addProperty($this->lng->txt("preview"), $preview->getInlineHTML());
816  }
817 
818  // forward the command
819  // $this->ctrl->setCmd("showSummary");
820  // $this->ctrl->setCmdClass("ilinfoscreengui");
821  $this->ctrl->forwardCommand($info);
822  }
static _getPermanentDownloadLink($ref_id)
Gets the permanent download link for the file.
Class ilInfoScreenGUI.
$context
Definition: webdav.php:26
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
$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.
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.
$DIC
Definition: xapitoken.php:46
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
+ 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 192 of file class.ilObjFileGUI.php.

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

193  {
194  $forms = array();
195 
196  if ($this->id_type == self::WORKSPACE_NODE_ID) {
198  ilUtil::sendFailure($this->lng->txt("personal_resources_quota_exceeded_warning"), true);
199  $this->ctrl->redirect($this, "cancel");
200  }
201  }
202 
203  // use drag-and-drop upload if configured
205  $forms[] = $this->initMultiUploadForm();
206  } else {
207  $forms[] = $this->initSingleUploadForm();
208  $forms[] = $this->initZipUploadForm();
209  }
210 
211  // repository only
212  if ($this->id_type != self::WORKSPACE_NODE_ID) {
213  $forms[self::CFORM_IMPORT] = $this->initImportForm('file');
214  $forms[self::CFORM_CLONE] = $this->fillCloneTemplate(null, "file");
215  }
216 
217  return $forms;
218  }
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 1231 of file class.ilObjFileGUI.php.

1232  {
1233  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
1234  if (is_object($lg)) {
1235  if ($this->object->hasRating()) {
1236  $lg->enableRating(
1237  true,
1238  null,
1239  false,
1240  array("ilcommonactiondispatchergui", "ilratinggui")
1241  );
1242  }
1243  }
1244 
1245  return $lg;
1246  }

◆ initMultiUploadForm()

ilObjFileGUI::initMultiUploadForm ( )

Initializes the upload form for multiple files.

Returns
object The created property form.

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

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

Referenced by initCreationForms(), and uploadFiles().

955  {
956  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
957  $dnd_form_gui = new ilPropertyFormGUI();
958  $dnd_form_gui->setMultipart(true);
959  $dnd_form_gui->setHideLabels();
960 
961  // file input
962  include_once("Services/Form/classes/class.ilDragDropFileInputGUI.php");
963  $dnd_input = new ilDragDropFileInputGUI($this->lng->txt("files"), "upload_files");
964  $dnd_input->setArchiveSuffixes(array("zip"));
965  $dnd_input->setCommandButtonNames("uploadFiles", "cancel");
966  $dnd_form_gui->addItem($dnd_input);
967 
968  // add commands
969  $dnd_form_gui->addCommandButton("uploadFiles", $this->lng->txt("upload_files"));
970  $dnd_form_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
971 
972  $dnd_form_gui->setTableWidth("100%");
973  $dnd_form_gui->setTarget($this->getTargetFrame("save"));
974  $dnd_form_gui->setTitle($this->lng->txt("upload_files_title"));
975  $dnd_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.gif'), $this->lng->txt('obj_file'));
976 
977  $this->ctrl->setParameter($this, "new_type", "file");
978  $dnd_form_gui->setFormAction($this->ctrl->getFormAction($this, "uploadFiles"));
979 
980  return $dnd_form_gui;
981  }
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 (   $mode = "create")
protected
Parameters

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

References ilDiskQuotaHandler\isUploadPossible(), ilRadioOption\setInfo(), ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), ilTextAreaInputGUI\setRows(), and ilNonEditableValueGUI\setValue().

Referenced by edit(), and update().

574  {
575  $form = new ilPropertyFormGUI();
576  $form->setFormAction($this->ctrl->getFormAction($this, 'update'));
577 
578  $form->setTitle($this->lng->txt('file_edit'));
579  $form->addCommandButton('update', $this->lng->txt('save'));
580  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
581 
582  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
583  $title->setValue($this->object->getTitle());
584  $title->setInfo($this->lng->txt("if_no_title_then_filename"));
585  $form->addItem($title);
586 
587  if ($mode === 'create') {
588  $upload_possible = true;
589  if ($this->id_type == self::WORKSPACE_NODE_ID) {
590  $upload_possible = ilDiskQuotaHandler::isUploadPossible();
591  }
592 
593  if ($upload_possible) {
594  $file = new ilFileStandardDropzoneInputGUI(
595  'cancel',
596  $this->lng->txt('obj_file'),
597  'file'
598  );
599  $file->setRequired(false);
600  $form->addItem($file);
601 
602  $group = new ilRadioGroupInputGUI('', 'replace');
603  $group->setValue(0);
604 
605  $replace = new ilRadioOption($this->lng->txt('replace_file'), 1);
606  $replace->setInfo($this->lng->txt('replace_file_info'));
607  $group->addOption($replace);
608 
609  $keep = new ilRadioOption($this->lng->txt('file_new_version'), 0);
610  $keep->setInfo($this->lng->txt('file_new_version_info'));
611  $group->addOption($keep);
612 
613  $file->addSubItem($group);
614  } elseif ($mode == 'create') {
615  $file = new ilNonEditableValueGUI($this->lng->txt('obj_file'));
616  $file->setValue($this->lng->txt("personal_resources_quota_exceeded_warning"));
617  $form->addItem($file);
618  }
619  } else {
620  $o = new ilNonEditableValueGUI($this->lng->txt('upload_info'));
621  $o->setValue($this->lng->txt('upload_info_desc'));
622  $form->addItem($o);
623  }
624  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
625  $desc->setRows(3);
626  $form->addItem($desc);
627 
628  if ($this->id_type == self::REPOSITORY_NODE_ID) {
629  $this->lng->loadLanguageModule('rating');
630  $rate = new ilCheckboxInputGUI($this->lng->txt('rating_activate_rating'), 'rating');
631  $rate->setInfo($this->lng->txt('rating_activate_rating_info'));
632  $form->addItem($rate);
633  }
634 
635  $presentationHeader = new ilFormSectionHeaderGUI();
636  $presentationHeader->setTitle($this->lng->txt('settings_presentation_header'));
637  $form->addItem($presentationHeader);
638  $this->obj_service->commonSettings()->legacyForm($form, $this->object)->addTileImage();
639 
640  return $form;
641  }
This class represents an option in a radio group.
This class represents a property form user interface.
This class represents a section header 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.
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.
Class ilFileStandardDropzoneInputGUI.
setRequired($a_required)
Set Required.
+ 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 224 of file class.ilObjFileGUI.php.

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

Referenced by initCreationForms(), and save().

225  {
226  global $DIC;
227  $lng = $DIC['lng'];
228 
229  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
230  $single_form_gui = new ilPropertyFormGUI();
231  $single_form_gui->setMultipart(true);
232 
233  // File Title
234  $in_title = new ilTextInputGUI($lng->txt("title"), "title");
235  $in_title->setInfo($this->lng->txt("if_no_title_then_filename"));
236  $in_title->setSize(min(40, ilObject::TITLE_LENGTH));
237  $in_title->setMaxLength(ilObject::TITLE_LENGTH);
238  $single_form_gui->addItem($in_title);
239 
240  // File Description
241  $in_descr = new ilTextAreaInputGUI($lng->txt("description"), "description");
242  $single_form_gui->addItem($in_descr);
243 
244  // File
245  $in_file = new ilFileInputGUI($lng->txt("file"), "upload_file");
246  $in_file->setRequired(true);
247  $single_form_gui->addItem($in_file);
248 
249  $single_form_gui->addCommandButton("save", $this->lng->txt($this->type . "_add"));
250  $single_form_gui->addCommandButton("saveAndMeta", $this->lng->txt("file_add_and_metadata"));
251  $single_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
252 
253  $single_form_gui->setTableWidth("600px");
254  $single_form_gui->setTarget($this->getTargetFrame("save"));
255  $single_form_gui->setTitle($this->lng->txt($this->type . "_new"));
256  $single_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.svg'), $this->lng->txt('obj_file'));
257 
258  $this->ctrl->setParameter($this, "new_type", "file");
259 
260  $single_form_gui->setFormAction($this->ctrl->getFormAction($this, "save"));
261 
262  return $single_form_gui;
263  }
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.
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 text area property in a property form.
$DIC
Definition: xapitoken.php:46
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 358 of file class.ilObjFileGUI.php.

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

Referenced by initCreationForms(), and saveUnzip().

359  {
360  global $DIC;
361  $lng = $DIC['lng'];
362 
363  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
364  $zip_form_gui = new ilPropertyFormGUI();
365  $zip_form_gui->setMultipart(true);
366 
367  // File
368  $in_file = new ilFileInputGUI($lng->txt("file"), "zip_file");
369  $in_file->setRequired(true);
370  $in_file->setSuffixes(array("zip"));
371  $zip_form_gui->addItem($in_file);
372 
373  // Take over structure
374  $in_str = new ilCheckboxInputGUI($this->lng->txt("take_over_structure"), "adopt_structure");
375  $in_str->setInfo($this->lng->txt("take_over_structure_info"));
376  $zip_form_gui->addItem($in_str);
377 
378  $zip_form_gui->addCommandButton("saveUnzip", $this->lng->txt($this->type . "_add"));
379  $zip_form_gui->addCommandButton("cancel", $lng->txt("cancel"));
380 
381  $zip_form_gui->setTableWidth("600px");
382  $zip_form_gui->setTarget($this->getTargetFrame("save"));
383  $zip_form_gui->setTitle($this->lng->txt("header_zip"));
384  $zip_form_gui->setTitleIcon(ilUtil::getImagePath('icon_file.svg'), $this->lng->txt('obj_file'));
385 
386  $this->ctrl->setParameter($this, "new_type", "file");
387 
388  $zip_form_gui->setFormAction($this->ctrl->getFormAction($this, "saveUnzip"));
389 
390  return $zip_form_gui;
391  }
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="")
$DIC
Definition: xapitoken.php:46
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilObjFileGUI::save ( )

save object

public

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

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

Referenced by saveAndMeta().

272  {
273  global $DIC;
274  $ilUser = $DIC->user();
275 
276  if (!$this->checkPermissionBool("create", "", "file")) {
277  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
278  }
279 
280  $single_form_gui = $this->initSingleUploadForm();
281 
282  if ($single_form_gui->checkInput()) {
283  $title = $single_form_gui->getInput("title");
284  $description = $single_form_gui->getInput("description");
285  $upload_file = $single_form_gui->getInput("upload_file");
286 
287  if (trim($title) == "") {
288  $title = $upload_file["name"];
289  } else {
290  // BEGIN WebDAV: Ensure that object title ends with the filename extension
291  $fileExtension = ilObjFileAccess::_getFileExtension($upload_file["name"]);
292  $titleExtension = ilObjFileAccess::_getFileExtension($title);
293  if ($titleExtension != $fileExtension && strlen($fileExtension) > 0) {
294  $title .= '.' . $fileExtension;
295  }
296  // END WebDAV: Ensure that object title ends with the filename extension
297  }
298 
299  // create and insert file in grp_tree
300 
301  $fileObj = new ilObjFile();
302  $fileObj->setTitle($title);
303  $fileObj->setDescription($description);
304  $fileObj->setFileName($upload_file["name"]);
305 
306  $fileObj->setFileType(ilMimeTypeUtil::getMimeType(
307  "",
308  $upload_file["name"],
309  $upload_file["type"]
310  ));
311  $fileObj->setFileSize($upload_file["size"]);
312  $this->object_id = $fileObj->create();
313 
314  $this->putObjectInTree($fileObj, $this->parent_id);
315 
316  // upload file to filesystem
317  $fileObj->createDirectory();
318  if ($result = $fileObj->getUploadFile($upload_file["tmp_name"], $upload_file["name"])) {
319  $fileObj->setFileName($result->getName());
320  }
321 
322  $this->handleAutoRating($fileObj);
323 
324  // BEGIN ChangeEvent: Record write event.
325  ilChangeEvent::_recordWriteEvent($fileObj->getId(), $ilUser->getId(), 'create');
326  // END ChangeEvent: Record write event.
327 
328  ilUtil::sendSuccess($this->lng->txt("file_added"), true);
329 
330  if ($this->ctrl->getCmd() == "saveAndMeta") {
331  $this->ctrl->setParameter($this, "new_type", "");
332  $target = $this->ctrl->getLinkTargetByClass(array("ilobjectmetadatagui", "ilmdeditorgui"), "listSection", "", false, false);
333  ilUtil::redirect($target);
334  } else {
335  $this->ctrl->returnToParent($this);
336  }
337  } else {
338  $single_form_gui->setValuesByPost();
339  $this->tpl->setContent($single_form_gui->getHTML());
340  }
341  }
initSingleUploadForm()
FORM: Init single upload form.
$result
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 _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
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
$DIC
Definition: xapitoken.php:46
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 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 399 of file class.ilObjFileGUI.php.

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

400  {
401  $zip_form_gui = $this->initZipUploadForm();
402 
403  if ($this->checkPermissionBool("create", "", "file")) {
404  if ($zip_form_gui->checkInput()) {
405  $zip_file = $zip_form_gui->getInput("zip_file");
406  $adopt_structure = $zip_form_gui->getInput("adopt_structure");
407 
408  include_once("Services/Utilities/classes/class.ilFileUtils.php");
409 
410  // Create unzip-directory
411  $newDir = ilUtil::ilTempnam();
412  ilUtil::makeDir($newDir);
413 
414  // Check if permission is granted for creation of object, if necessary
415  if ($this->id_type != self::WORKSPACE_NODE_ID) {
416  $type = ilObject::_lookupType((int) $this->parent_id, true);
417  } else {
418  $type = ilObject::_lookupType($this->tree->lookupObjectId($this->parent_id), false);
419  }
420 
421  $tree = $access_handler = null;
422  switch ($type) {
423  // workspace structure
424  case 'wfld':
425  case 'wsrt':
426  $permission = $this->checkPermissionBool("create", "", "wfld");
427  $containerType = "WorkspaceFolder";
428  $tree = $this->tree;
430  break;
431 
432  // use categories as structure
433  case 'cat':
434  case 'root':
435  $permission = $this->checkPermissionBool("create", "", "cat");
436  $containerType = "Category";
437  break;
438 
439  // use folders as structure (in courses)
440  default:
441  $permission = $this->checkPermissionBool("create", "", "fold");
442  $containerType = "Folder";
443  break;
444  }
445  // processZipFile (
446  // Dir to unzip,
447  // Path to uploaded file,
448  // should a structure be created (+ permission check)?
449  // ref_id of parent
450  // object that contains files (folder or category)
451  // should sendInfo be persistent?)
452  try {
453  $processDone = ilFileUtils::processZipFile(
454  $newDir,
455  $zip_file["tmp_name"],
456  ($adopt_structure && $permission),
457  $this->parent_id,
458  $containerType,
459  $tree,
461  );
462  ilUtil::sendSuccess($this->lng->txt("file_added"), true);
463  } catch (ilFileUtilsException $e) {
464  ilUtil::sendFailure($e->getMessage(), true);
465  }
466 
467  ilUtil::delDir($newDir);
468  $this->ctrl->returnToParent($this);
469  } else {
470  $zip_form_gui->setValuesByPost();
471  $this->tpl->setContent($zip_form_gui->getHTML());
472  }
473  } else {
474  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
475  }
476  }
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)
Returns a unique and non existing Path for e temporary file or 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 644 of file class.ilObjFileGUI.php.

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

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

◆ setTabs()

ilObjFileGUI::setTabs ( )

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

References $DIC, $lng, ilLearningProgressAccess\checkAccess(), ilObject2GUI\checkPermissionBool(), and ilFileVersionsGUI\CMD_DEFAULT.

827  {
828  global $DIC;
829  $ilTabs = $DIC['ilTabs'];
830  $lng = $DIC['lng'];
831  $ilHelp = $DIC['ilHelp'];
832 
833  $ilHelp->setScreenIdComponent("file");
834 
835  $this->ctrl->setParameter($this, "ref_id", $this->node_id);
836 
837  if ($this->checkPermissionBool("write")) {
838  $ilTabs->addTab(
839  "id_versions",
840  $lng->txt(self::CMD_VERSIONS),
841  $this->ctrl->getLinkTargetByClass(ilFileVersionsGUI::class, ilFileVersionsGUI::CMD_DEFAULT)
842  );
843  }
844 
845  if ($this->checkPermissionBool("visible") || $this->checkPermissionBool("read")) {
846  $ilTabs->addTab(
847  "id_info",
848  $lng->txt("info_short"),
849  $this->ctrl->getLinkTargetByClass(array("ilobjfilegui", "ilinfoscreengui"), "showSummary")
850  );
851  }
852 
853  if ($this->checkPermissionBool("write")) {
854  $ilTabs->addTab(
855  "settings",
856  $lng->txt("settings"),
857  $this->ctrl->getLinkTarget($this, self::CMD_EDIT)
858  );
859  }
860 
861  if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
862  $ilTabs->addTab(
863  'learning_progress',
864  $lng->txt('learning_progress'),
865  $this->ctrl->getLinkTargetByClass(array(__CLASS__, 'illearningprogressgui'), '')
866  );
867  }
868 
869  // meta data
870  if ($this->checkPermissionBool("write")) {
871  $mdgui = new ilObjectMetaDataGUI($this->object);
872  $mdtab = $mdgui->getTab();
873  if ($mdtab) {
874  $ilTabs->addTab(
875  "id_meta",
876  $lng->txt("meta_data"),
877  $mdtab
878  );
879  }
880  }
881 
882  // export
883  if ($this->checkPermissionBool("write")) {
884  $ilTabs->addTab(
885  "export",
886  $lng->txt("export"),
887  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
888  );
889  }
890 
891  // will add permission tab if needed
892  parent::setTabs();
893  }
Class ilObjectMetaDataGUI.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ update()

ilObjFileGUI::update ( )

updates object entry in object_data

public

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

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

485  {
486  global $DIC;
487  $ilTabs = $DIC['ilTabs'];
488 
489  $form = $this->initPropertiesForm();
490  if (!$form->checkInput()) {
491  $ilTabs->activateTab("settings");
492  $form->setValuesByPost();
493  $this->tpl->setContent($form->getHTML());
494 
495  return false;
496  }
497 
498  $title = $form->getInput('title');
499  // bugfix mantis 26045:
500  $filename = empty($data["name"]) ? $this->object->getFileName() : $data["name"];
501  if (strlen(trim($title)) == 0) {
502  $title = $filename;
503  } else {
504  $title = $this->object->checkFileExtension($filename, $title);
505  }
506  $this->object->setTitle($title);
507  $this->object->setDescription($form->getInput('description'));
508  $this->object->setRating($form->getInput('rating'));
509 
510  $this->update = $this->object->update();
511  $this->obj_service->commonSettings()->legacyForm($form, $this->object)->saveTileImage();
512 
513  // BEGIN ChangeEvent: Record update event.
514  if (!empty($data["name"])) {
515  global $DIC;
516  $ilUser = $DIC['ilUser'];
517  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
518  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
519  }
520  // END ChangeEvent: Record update event.
521 
522  // Update ecs export settings
523  $ecs = new ilECSFileSettings($this->object);
524  $ecs->handleSettingsUpdate();
525 
526  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
527  ilUtil::redirect($this->ctrl->getLinkTarget($this, self::CMD_EDIT, '', false, false));
528  }
Class ilECSFileSettings.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
initPropertiesForm($mode="create")
static _catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
$ilUser
Definition: imgupload.php:18
$filename
Definition: buildRTE.php:89
$DIC
Definition: xapitoken.php:46
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 987 of file class.ilObjFileGUI.php.

References $_POST, ilObject2GUI\$access_handler, $DIC, Vendor\Package\$e, $filename, $ilUser, $object, $response, $result, $size, ilObject2GUI\$tree, $type, ilObject\_lookupType(), ilChangeEvent\_recordWriteEvent(), ilObject2GUI\checkPermissionBool(), ilUtil\delDir(), exit, ilObject2GUI\getAccessHandler(), ilFileUtils\getNewObjects(), ilObject2GUI\handleAfterSaveCallback(), ilObject2GUI\handleAutoRating(), ilFileUtils\hasValidExtension(), ilUtil\ilTempnam(), initMultiUploadForm(), ilUtil\makeDir(), ilFileUtils\processZipFile(), ilObject2GUI\putObjectInTree(), ilUtil\sendInfo(), and ilUtil\stripSlashes().

988  {
989  global $DIC;
990 
991  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
992 
993  $response = new stdClass();
994  $response->error = null;
995  $response->debug = null;
996 
997  $files = $_FILES;
998 
999  // #14249 - race conditions because of concurrent uploads
1000  $after_creation_callback = (int) $_REQUEST["crtcb"];
1001  if ($after_creation_callback) {
1002  $this->after_creation_callback_objects = array();
1003  unset($_REQUEST["crtcb"]);
1004  }
1005 
1006  // load form
1007  $dnd_form_gui = $this->initMultiUploadForm();
1008  if ($dnd_form_gui->checkInput()) {
1009  try {
1010  if (!$this->checkPermissionBool("create", "", "file")) {
1011  $response->error = $this->lng->txt("permission_denied");
1012  } else {
1013  // handle the file
1014  $inp = $dnd_form_gui->getInput("upload_files");
1015  $this->log->debug("ilObjFileGUI::uploadFiles " . print_r($_POST, true));
1016  $this->log->debug("ilObjFileGUI::uploadFiles " . print_r($_FILES, true));
1017  $fileresult = $this->handleFileUpload($inp);
1018  if ($fileresult) {
1019  $response = (object) array_merge((array) $response, (array) $fileresult);
1020  }
1021  }
1022  } catch (Exception $ex) {
1023  $response->error = $this->lng->txt('general_upload_error_occured');
1024  }
1025  } else {
1026  $dnd_input = $dnd_form_gui->getItemByPostVar("upload_files");
1027  $response->error = $dnd_input->getAlert();
1028  }
1029 
1030  if ($after_creation_callback
1031  && sizeof($this->after_creation_callback_objects)
1032  ) {
1033  foreach ($this->after_creation_callback_objects as $new_file_obj) {
1034  ilObject2GUI::handleAfterSaveCallback($new_file_obj, $after_creation_callback);
1035  }
1036  unset($this->after_creation_callback_objects);
1037  }
1038 
1039  // send response object (don't use 'application/json' as IE wants to download it!)
1040  header('Vary: Accept');
1041  header('Content-type: text/plain');
1042 
1043  if ($DIC->upload()->hasBeenProcessed()) {
1044  foreach ($DIC->upload()->getResults() as $result) {
1045  if (!ilFileUtils::hasValidExtension($result->getName()) && $result->getStatus()->getCode() == ProcessingStatus::OK) {
1047  $this->lng->txt('file_upload_info_file_with_critical_extension'),
1048  true
1049  );
1050  }
1051  }
1052  }
1053  echo json_encode($response);
1054  // no further processing!
1055  exit;
1056  }
exit
Definition: login.php:29
$result
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
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.
$DIC
Definition: xapitoken.php:46
initMultiUploadForm()
Initializes the upload form for multiple files.
$response
$_POST["username"]
+ Here is the call graph for this function:

◆ versions()

ilObjFileGUI::versions ( )
Deprecated:

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

687  {
688  $this->ctrl->redirectByClass(ilFileVersionsGUI::class);
689  }

Field Documentation

◆ $lng

ilObjFileGUI::$lng

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

Referenced by _goto(), initSingleUploadForm(), initZipUploadForm(), and setTabs().

◆ $log

ilObjFileGUI::$log = null
protected

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

◆ $obj_service

ilObjFileGUI::$obj_service
protected

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

◆ $object

ilObjFileGUI::$object

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

Referenced by uploadFiles().

◆ CMD_EDIT

const ilObjFileGUI::CMD_EDIT = "edit"

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

◆ CMD_VERSIONS

const ilObjFileGUI::CMD_VERSIONS = "versions"

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


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