ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDataCollectionRecordEditGUI Class Reference

Class ilDataCollectionRecordEditGUI. More...

+ Collaboration diagram for ilDataCollectionRecordEditGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $parent_obj)
 Constructor.
 executeCommand ()
 execute command
 create ()
 create Record
 edit ()
 edit Record
 confirmDelete ()
 confirmDelete
 cancelDelete ()
 cancelDelete
 delete ()
 initForm ()
 init Form
 getValues ()
 get Values
 cancelUpdate ()
 cancelSave ()
 save ()
 save Record
 searchObjects ()
 This function is only used by the ajax request if searching for ILIAS references.

Private Member Functions

 accessDenied ()
 sendFailure ()
 parseSearchResults ($a_res)
 Parse search results.

Private Attributes

 $record_id
 $table_id
 $table
 $parent_obj

Detailed Description

Constructor & Destructor Documentation

ilDataCollectionRecordEditGUI::__construct ( ilObjDataCollectionGUI  $parent_obj)

Constructor.

Definition at line 31 of file class.ilDataCollectionRecordEditGUI.php.

References $_GET, $_REQUEST, $parent_obj, and ilDataCollectionCache\getTableCache().

{
include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
$this->form = new ilPropertyFormGUI();
$this->parent_obj = $parent_obj;
$this->record_id = $_REQUEST['record_id'];
$this->table_id = $_GET['table_id'];
include_once("class.ilDataCollectionDatatype.php");
if ($_REQUEST['table_id']) {
$this->table_id = $_REQUEST['table_id'];
}
$this->table = ilDataCollectionCache::getTableCache($this->table_id);
}

+ Here is the call graph for this function:

Member Function Documentation

ilDataCollectionRecordEditGUI::accessDenied ( )
private

Definition at line 401 of file class.ilDataCollectionRecordEditGUI.php.

References $tpl.

Referenced by delete(), and save().

{
global $tpl;
$tpl->setContent("Access denied");
}

+ Here is the caller graph for this function:

ilDataCollectionRecordEditGUI::cancelDelete ( )

cancelDelete

Definition at line 116 of file class.ilDataCollectionRecordEditGUI.php.

References $ilCtrl.

{
global $ilCtrl;
$ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
}
ilDataCollectionRecordEditGUI::cancelSave ( )

Definition at line 289 of file class.ilDataCollectionRecordEditGUI.php.

References cancelUpdate().

{
$this->cancelUpdate();
}

+ Here is the call graph for this function:

ilDataCollectionRecordEditGUI::cancelUpdate ( )

Definition at line 280 of file class.ilDataCollectionRecordEditGUI.php.

References $ilCtrl.

Referenced by cancelSave().

{
global $ilCtrl;
$ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
}

+ Here is the caller graph for this function:

ilDataCollectionRecordEditGUI::confirmDelete ( )

confirmDelete

Definition at line 93 of file class.ilDataCollectionRecordEditGUI.php.

References $ilCtrl, $lng, $tpl, and ilDataCollectionCache\getRecordCache().

{
global $ilCtrl, $lng, $tpl;
include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
$conf = new ilConfirmationGUI();
$conf->setFormAction($ilCtrl->getFormAction($this));
$conf->setHeaderText($lng->txt('dcl_confirm_delete_record'));
$record = ilDataCollectionCache::getRecordCache($this->record_id);
$conf->addItem('record_id', $record->getId(), implode(", ", $record->getRecordFieldValues()));
$conf->addHiddenItem('table_id', $this->table_id);
$conf->setConfirm($lng->txt('delete'), 'delete');
$conf->setCancel($lng->txt('cancel'), 'cancelDelete');
$tpl->setContent($conf->getHTML());
}

+ Here is the call graph for this function:

ilDataCollectionRecordEditGUI::create ( )

create Record

Definition at line 68 of file class.ilDataCollectionRecordEditGUI.php.

References $ilCtrl, $tpl, and initForm().

{
global $ilCtrl, $tpl;
$this->initForm();
$tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

ilDataCollectionRecordEditGUI::delete ( )

Definition at line 126 of file class.ilDataCollectionRecordEditGUI.php.

References $ilCtrl, $lng, accessDenied(), ilDataCollectionCache\getRecordCache(), and ilUtil\sendSuccess().

{
global $ilCtrl, $lng;
$record = ilDataCollectionCache::getRecordCache($this->record_id);
if (! $this->table->hasPermissionToDeleteRecord($this->parent_obj->ref_id, $record)) {
$this->accessDenied();
return;
}
$record->doDelete();
ilUtil::sendSuccess($lng->txt("dcl_record_deleted"), true);
$ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
}

+ Here is the call graph for this function:

ilDataCollectionRecordEditGUI::edit ( )

edit Record

Definition at line 80 of file class.ilDataCollectionRecordEditGUI.php.

References $ilCtrl, $tpl, getValues(), and initForm().

{
global $tpl, $ilCtrl;
$this->initForm("edit");
$this->getValues();
$tpl->setContent($this->form->getHTML());
}

+ Here is the call graph for this function:

ilDataCollectionRecordEditGUI::executeCommand ( )

execute command

Definition at line 50 of file class.ilDataCollectionRecordEditGUI.php.

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$cmd = $ilCtrl->getCmd();
switch ($cmd) {
default:
$this->$cmd();
break;
}
return true;
}
ilDataCollectionRecordEditGUI::getValues ( )

get Values

Definition at line 251 of file class.ilDataCollectionRecordEditGUI.php.

References $img, ilObjMediaObject\_lookupItemPath(), ilDataCollectionCache\getRecordCache(), and ilDataCollectionDatatype\INPUTFORMAT_MOB.

Referenced by edit().

{
//Get Record-Values
$record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
//Get Table Field Definitions
$allFields = $this->table->getFields();
$values = array();
foreach ($allFields as $field) {
$value = $record_obj->getRecordFieldFormInput($field->getId());
$values['field_' . $field->getId()] = $value;
if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
if ($value) {
$this->form->getItemByPostVar('field_' . $field->getId())->setImage($img);
}
}
}
$this->form->setValuesByArray($values);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionRecordEditGUI::initForm ( )

init Form

Parameters
string$a_modevalues: create | edit

Definition at line 147 of file class.ilDataCollectionRecordEditGUI.php.

References $ilCtrl, $lng, $options, $tpl, ilObjDataCollection\_hasWriteAccess(), ilDataCollectionCache\getFieldCache(), ilDataCollectionDatatype\getInputField(), ilDataCollectionCache\getRecordCache(), ilDataCollectionCache\getTableCache(), ilObject2\getTitle(), ilDataCollectionDatatype\INPUTFORMAT_DATETIME, ilDataCollectionDatatype\INPUTFORMAT_FILE, ilDataCollectionDatatype\INPUTFORMAT_MOB, and ilDataCollectionDatatype\INPUTFORMAT_REFERENCE.

Referenced by create(), edit(), and save().

{
global $lng, $ilCtrl, $tpl;
//table_id
$hidden_prop = new ilHiddenInputGUI("table_id");
$hidden_prop->setValue($this->table_id);
$this->form->addItem($hidden_prop);
$ilCtrl->setParameter($this, "record_id", $this->record_id);
$this->form->setFormAction($ilCtrl->getFormAction($this));
$allFields = $this->table->getRecordFields();
$inline_css = '';
foreach ($allFields as $field) {
if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
$fieldref = $field->getFieldRef();
$reffield = ilDataCollectionCache::getFieldCache($fieldref);
$options = array();
if (! $field->isNRef()) {
$options[""] = $lng->txt('dcl_please_select');
}
$reftable = ilDataCollectionCache::getTableCache($reffield->getTableId());
foreach ($reftable->getRecords() as $record) {
switch($reffield->getDatatypeId()) {
$file_obj = new ilObjFile($record->getRecordFieldValue($fieldref), false);
$options[$record->getId()] = $file_obj->getFileName();
break;
$media_obj = new ilObjMediaObject($record->getRecordFieldValue($fieldref), false);
$options[$record->getId()] = $media_obj->getTitle();
break;
$options[$record->getId()] = $record->getRecordFieldSingleHTML($fieldref);
break;
default:
$options[$record->getId()] = $record->getRecordFieldValue($fieldref);
break;
}
}
asort($options);
$item->setOptions($options);
if($item instanceof ilMultiSelectInputGUI)
{
$item->setWidth(400);
$item->setHeight(100);
$inline_css .= 'div#'.$item->getFieldId().'{resize:both;} ';
}
}
$tpl->addInlineCss($inline_css);
if ($this->record_id) {
$record = ilDataCollectionCache::getRecordCache($this->record_id);
}
$item->setRequired($field->getRequired());
//WORKAROUND. If field is from type file: if it's required but already has a value it is no longer required as the old value is taken as default without the form knowing about it.
if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_FILE
|| $field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB
) {
if ($this->record_id && $record->getId()) {
$field_value = $record->getRecordFieldValue($field->getId());
if ($field_value) {
$item->setRequired(false);
}
}
}
if (! ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id) && $field->getLocked()) {
$item->setDisabled(true);
}
$this->form->addItem($item);
}
// Add possibility to change the owner in edit mode
if ($this->record_id) {
$ownerField = $this->table->getField('owner');
$inputfield = ilDataCollectionDatatype::getInputField($ownerField);
$this->form->addItem($inputfield);
}
// save and cancel commands
if (isset($this->record_id)) {
$this->form->setTitle($lng->txt("dcl_update_record"));
$this->form->addCommandButton("save", $lng->txt("dcl_update_record"));
$this->form->addCommandButton("cancelUpdate", $lng->txt("cancel"));
} else {
$this->form->setTitle($lng->txt("dcl_add_new_record"));
$this->form->addCommandButton("save", $lng->txt("save"));
$this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
}
$ilCtrl->setParameter($this, "table_id", $this->table_id);
$ilCtrl->setParameter($this, "record_id", $this->record_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionRecordEditGUI::parseSearchResults (   $a_res)
private

Parse search results.

Parameters
ilObject[]$a_res
Returns
array

Definition at line 474 of file class.ilDataCollectionRecordEditGUI.php.

References ilObject\_lookupDescription(), and ilObject\_lookupTitle().

Referenced by searchObjects().

{
foreach ($a_res as $obj_id => $references) {
$r['title'] = ilObject::_lookupTitle($obj_id);
$r['desc'] = ilObject::_lookupDescription($obj_id);
$r['obj_id'] = $obj_id;
$r['refs'] = $references;
$rows[] = $r;
}
return $rows ? $rows : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionRecordEditGUI::save ( )

save Record

Parameters
string$a_modevalues: create | edit

Definition at line 299 of file class.ilDataCollectionRecordEditGUI.php.

References $_POST, $ilCtrl, $ilUser, $lng, $tpl, ilObjDataCollection\_hasWriteAccess(), ilObjUser\_lookupId(), accessDenied(), ilDataCollectionCache\getRecordCache(), IL_CAL_DATETIME, IL_CAL_UNIX, initForm(), ilDataCollectionDatatype\INPUTFORMAT_MOB, sendFailure(), ilObjDataCollection\sendNotification(), and ilUtil\sendSuccess().

{
global $tpl, $ilUser, $lng, $ilCtrl;
$this->initForm();
if ($this->form->checkInput()) {
$record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
$date_obj = new ilDateTime(time(), IL_CAL_UNIX);
$record_obj->setTableId($this->table_id);
$record_obj->setLastUpdate($date_obj->get(IL_CAL_DATETIME));
$record_obj->setLastEditBy($ilUser->getId());
$create_mode = false;
if (ilObjDataCollection::_hasWriteAccess($this->parent_obj->ref_id)) {
$all_fields = $this->table->getRecordFields();
} else {
$all_fields = $this->table->getEditableFields();
}
$fail = "";
//Check if we can create this record.
foreach ($all_fields as $field) {
try {
$value = $this->form->getInput("field_" . $field->getId());
$field->checkValidity($value, $this->record_id);
$fail .= $field->getTitle() . ": " . $e . "<br>";
}
}
if ($fail) {
ilUtil::sendFailure($fail, true);
$this->sendFailure();
return;
}
if (! isset($this->record_id)) {
if (! ($this->table->hasPermissionToAddRecord($this->parent_obj->ref_id))) {
$this->accessDenied();
return;
}
$record_obj->setOwner($ilUser->getId());
$record_obj->setCreateDate($date_obj->get(IL_CAL_DATETIME));
$record_obj->setTableId($this->table_id);
$record_obj->doCreate();
$this->record_id = $record_obj->getId();
$create_mode = true;
} else {
if (! $record_obj->hasPermissionToEdit($this->parent_obj->ref_id)) {
$this->accessDenied();
return;
}
}
//edit values, they are valid we already checked them above
foreach ($all_fields as $field) {
$value = $this->form->getInput("field_" . $field->getId());
//deletion flag on MOB inputs.
if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_MOB
&& $this->form->getItemByPostVar("field_" . $field->getId())->getDeletionFlag()
) {
$value = - 1;
}
$record_obj->setRecordFieldValue($field->getId(), $value);
}
// Do we need to set a new owner for this record?
if (! $create_mode) {
$owner_id = ilObjUser::_lookupId($_POST['field_owner']);
if (! $owner_id) {
ilUtil::sendFailure($lng->txt('user_not_known'));
$this->sendFailure();
return;
}
$record_obj->setOwner($owner_id);
}
if ($create_mode) {
ilObjDataCollection::sendNotification("new_record", $this->table_id, $record_obj->getId());
}
$record_obj->doUpdate();
ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
$ilCtrl->setParameter($this, "table_id", $this->table_id);
$ilCtrl->setParameter($this, "record_id", $this->record_id);
$ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
} else {
global $tpl;
$this->form->setValuesByPost();
$tpl->setContent($this->form->getHTML());
}
}

+ Here is the call graph for this function:

ilDataCollectionRecordEditGUI::searchObjects ( )

This function is only used by the ajax request if searching for ILIAS references.

It builds the html for the search results.

Definition at line 420 of file class.ilDataCollectionRecordEditGUI.php.

References $_POST, $lng, $path, $res, $results, $tpl, exit, parseSearchResults(), and QP_COMBINATION_AND.

{
global $lng;
$search = $_POST['search_for'];
$dest = $_POST['dest'];
$html = "";
include_once './Services/Search/classes/class.ilQueryParser.php';
$query_parser = new ilQueryParser($search);
$query_parser->setMinWordLength(1, true);
$query_parser->setCombination(QP_COMBINATION_AND);
$query_parser->parse();
if (! $query_parser->validate()) {
$html .= $query_parser->getMessage() . "<br />";
}
// only like search since fulltext does not support search with less than 3 characters
include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
$object_search = new ilLikeObjectSearch($query_parser);
$res = $object_search->performSearch();
//$res->setRequiredPermission('copy');
$res->filter(ROOT_FOLDER_ID, true);
if (! count($results = $res->getResultsByObjId())) {
$html .= $lng->txt('dcl_no_search_results_found_for') . ' ' . $search . "<br />";
}
foreach ($results as $entry) {
$tpl = new ilTemplate("tpl.dcl_tree.html", true, true, "Modules/DataCollection");
foreach ((array)$entry['refs'] as $reference) {
include_once './Services/Tree/classes/class.ilPathGUI.php';
$path = new ilPathGUI();
$tpl->setCurrentBlock('result');
$tpl->setVariable('RESULT_PATH', $path->getPath(ROOT_FOLDER_ID, $reference) . " ยป " . $entry['title']);
$tpl->setVariable('RESULT_REF', $reference);
$tpl->setVariable('FIELD_ID', $dest);
$tpl->parseCurrentBlock();
}
$html .= $tpl->get();
}
echo $html;
}

+ Here is the call graph for this function:

ilDataCollectionRecordEditGUI::sendFailure ( )
private

Definition at line 410 of file class.ilDataCollectionRecordEditGUI.php.

References $tpl.

Referenced by save().

{
global $tpl;
$this->form->setValuesByPost();
$tpl->setContent($this->form->getHTML());
}

+ Here is the caller graph for this function:

Field Documentation

ilDataCollectionRecordEditGUI::$parent_obj
private

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

Referenced by __construct().

ilDataCollectionRecordEditGUI::$record_id
private

Definition at line 21 of file class.ilDataCollectionRecordEditGUI.php.

ilDataCollectionRecordEditGUI::$table
private

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

ilDataCollectionRecordEditGUI::$table_id
private

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


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