33 include_once
'Modules/Chatroom/classes/class.ilChatroom.php';
37 $this->gui->switchToVisibleMode();
48 $path = self::_getSmileyDir();
74 foreach ($smilies as $smiley) {
75 copy(
"templates/default/images/emoticons/$smiley", $path .
"/$smiley");
78 self::_insertDefaultValues();
80 ilUtil::sendSuccess($DIC->language()->txt(
'chat_smilies_initialized'));
84 if (!is_writable($path)) {
97 $path =
'chatroom/smilies';
109 array(
"icon_smile.gif",
":)\n:-)\n:smile:"),
110 array(
"icon_wink.gif",
";)\n;-)\n:wink:"),
111 array(
"icon_laugh.gif",
":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
112 array(
"icon_sad.gif",
":(\n:-(\n:sad:"),
113 array(
"icon_shocked.gif",
":o\n:-o\n:shocked:"),
114 array(
"icon_tongue.gif",
":p\n:-p\n:tongue:"),
115 array(
"icon_cool.gif",
":cool:"),
116 array(
"icon_eek.gif",
":eek:"),
117 array(
"icon_angry.gif",
":||\n:-||\n:angry:"),
118 array(
"icon_flush.gif",
":flush:"),
119 array(
"icon_idea.gif",
":idea:"),
120 array(
"icon_thumbup.gif",
":thumbup:"),
121 array(
"icon_thumbdown.gif",
":thumbdown:"),
124 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
125 foreach ($values as $val) {
126 ilChatroomSmilies::_storeSmiley($val[1], $val[0]);
136 if (!$this->rbacsystem->checkAccess(
'read', $this->gui->ref_id)) {
137 $this->
ilias->raiseError(
138 $this->ilLng->txt(
'msg_no_perm_read'),
139 $this->gui->ilias->error_obj->MESSAGE
143 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
145 ilChatroomSmilies::_checkSetup();
147 if (!$this->form_gui) {
153 include_once
"Modules/Chatroom/classes/class.ilChatroomSmiliesGUI.php";
158 "tpl.chatroom_edit_smilies.html",
163 $tpl_smilies->setVariable(
"SMILEY_TABLE", $table);
164 $tpl_smilies->setVariable(
"SMILEY_FORM", $form->getHtml());
166 $this->mainTpl->setContent($tpl_smilies->get());
179 $table_nav = $_REQUEST[
"_table_nav"] ?
"&_table_nav=" . $_REQUEST[
"_table_nav"] :
"";
180 $this->form_gui->setFormAction(
187 $sec_l->setTitle($this->ilLng->txt(
'chatroom_add_smiley'));
188 $this->form_gui->addItem($sec_l);
191 $this->ilLng->txt(
'chatroom_image_path'),
192 'chatroom_image_path' 194 $inp->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif",
"svg"));
196 $inp->setRequired(
true);
197 $this->form_gui->addItem($inp);
200 $this->ilLng->txt(
'chatroom_smiley_keywords'),
201 'chatroom_smiley_keywords' 205 $inp->setUseRte(
false);
206 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_keywords_one_per_line_note'));
207 $this->form_gui->addItem($inp);
210 if ($this->rbacsystem->checkAccess(
"write", $this->gui->ref_id)) {
211 $this->form_gui->addCommandButton(
'smiley-uploadSmileyObject', $DIC->language()->txt(
'chatroom_upload_smiley'));
222 $this->gui->switchToVisibleMode();
224 if (!$this->rbacsystem->checkAccess(
'read', $this->gui->ref_id)) {
225 $this->
ilias->raiseError(
226 $this->ilLng->txt(
'msg_no_perm_read'),
227 $this->
ilias->error_obj->MESSAGE
231 if (!$this->form_gui) {
238 "tpl.chatroom_edit_smilies.html",
244 $tpl_form->setVariable(
"SMILEY_FORM", $form->getHTML());
246 $this->mainTpl->setContent($tpl_form->get());
256 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
257 $smiley = ilChatroomSmilies::_getSmiley($smileyId);
260 'chatroom_smiley_id' => $smiley[
'smiley_id'],
261 'chatroom_smiley_keywords' => $smiley[
'smiley_keywords'],
262 'chatroom_current_smiley_image_path' => $smiley[
'smiley_fullpath'],
274 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
278 $this->form_gui->setValuesByArray($form_data);
280 $table_nav = $_REQUEST[
"_table_nav"] ?
"&_table_nav=" . $_REQUEST[
"_table_nav"] :
"";
284 $this->form_gui->setFormAction(
290 $sec_l->setTitle($this->ilLng->txt(
'chatroom_edit_smiley'));
291 $this->form_gui->addItem($sec_l);
293 include_once
"Modules/Chatroom/classes/class.ilChatroomSmiliesCurrentSmileyFormElement.php";
296 $this->ilLng->txt(
'chatroom_current_smiley_image_path'),
297 'chatroom_current_smiley_image_path' 300 $inp->
setValue($form_data[
'chatroom_current_smiley_image_path']);
301 $this->form_gui->addItem($inp);
304 $this->ilLng->txt(
'chatroom_image_path'),
305 'chatroom_image_path' 307 $inp->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif",
"svg"));
309 $inp->setRequired(
false);
310 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_image_only_if_changed'));
311 $this->form_gui->addItem($inp);
314 $this->ilLng->txt(
'chatroom_smiley_keywords'),
315 'chatroom_smiley_keywords' 318 $inp->
setValue($form_data[
'chatroom_smiley_keywords']);
319 $inp->setUseRte(
false);
320 $inp->setRequired(
true);
321 $inp->setInfo($this->ilLng->txt(
'chatroom_smiley_keywords_one_per_line_note'));
322 $this->form_gui->addItem($inp);
326 $this->form_gui->addItem($inp);
327 $this->form_gui->addCommandButton(
328 'smiley-updateSmiliesObject',
329 $this->ilLng->txt(
'submit')
331 $this->form_gui->addCommandButton(
'smiley', $this->ilLng->txt(
'cancel'));
341 $this->gui->switchToVisibleMode();
343 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
344 $this->
ilias->raiseError(
345 $this->ilLng->txt(
'msg_no_perm_write'),
346 $this->
ilias->error_obj->MESSAGE
350 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
351 $smiley = ilChatroomSmilies::_getSmiley((
int) $_REQUEST[
'smiley_id']);
353 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
356 $confirmation->setHeaderText($this->ilLng->txt(
'chatroom_confirm_delete_smiley'));
357 $confirmation->addButton($this->ilLng->txt(
'confirm'),
'smiley-deleteSmileyObject');
358 $confirmation->addButton($this->ilLng->txt(
'cancel'),
'smiley');
359 $confirmation->addItem(
'chatroom_smiley_id', $smiley[
'smiley_id'],
ilUtil::img($smiley[
'smiley_fullpath'], $smiley[
'smiley_keywords']) .
' ' . $smiley[
'smiley_keywords']);
361 $this->mainTpl->setContent($confirmation->getHTML());
369 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
370 $this->
ilias->raiseError(
371 $this->ilLng->txt(
'msg_no_perm_write'),
372 $this->
ilias->error_obj->MESSAGE
376 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
378 ilChatroomSmilies::_deleteSmiley($_REQUEST[
"chatroom_smiley_id"]);
388 public function updateSmiliesObject()
390 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
391 $this->
ilias->raiseError(
392 $this->ilLng->txt(
'msg_no_perm_write'),
393 $this->
ilias->error_obj->MESSAGE
399 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
404 $atLeastOneKeywordGiven = count($keywords) > 0;
406 if (!($isFormValid = $this->form_gui->checkInput()) || !$atLeastOneKeywordGiven) {
411 $this->form_gui->setValuesByPost();
418 $data[
"smiley_keywords"] = join(
"\n", $keywords);
419 $data[
"smiley_id"] = (int) $_REQUEST[
'smiley_id'];
421 if ($this->upload->hasUploads() && !$this->upload->hasBeenProcessed()) {
422 $this->upload->process();
425 $result = array_values($this->upload->getResults())[0];
427 $this->upload->moveOneFileTo(
430 \
ILIAS\FileUpload\Location::WEB,
439 \ilChatroomSmilies::_updateSmiley(
$data);
441 \ilUtil::sendSuccess($this->ilLng->txt(
'saved_successfully'),
true);
451 $this->gui->switchToVisibleMode();
453 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
454 $this->
ilias->raiseError(
455 $this->ilLng->txt(
'msg_no_perm_write'),
456 $this->
ilias->error_obj->MESSAGE
460 $items = (array) $_REQUEST[
'smiley_id'];
461 if (count($items) == 0) {
466 include_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
467 $smilies = ilChatroomSmilies::_getSmiliesById($items);
468 if (count($smilies) == 0) {
473 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
476 $confirmation->setHeaderText($this->ilLng->txt(
'chatroom_confirm_delete_smiley'));
477 $confirmation->addButton($this->ilLng->txt(
'confirm'),
'smiley-confirmedDeleteMultipleObject');
478 $confirmation->addButton($this->ilLng->txt(
'cancel'),
'smiley');
480 foreach ($smilies as $s) {
481 $confirmation->addItem(
'sel_ids[]', $s[
'smiley_id'],
ilUtil::img($s[
'smiley_fullpath'], $s[
'smiley_keywords']) .
' ' . $s[
'smiley_keywords']);
484 $this->mainTpl->setContent($confirmation->getHTML());
492 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
493 $this->
ilias->raiseError(
494 $this->ilLng->txt(
'msg_no_perm_write'),
495 $this->
ilias->error_obj->MESSAGE
499 $parts =
$_POST[
"sel_ids"];
500 if (count($parts) == 0) {
504 include_once
"Modules/Chatroom/classes/class.ilChatroomSmilies.php";
505 ilChatroomSmilies::_deleteMultipleSmilies($parts);
514 public function uploadSmileyObject()
516 if (!$this->rbacsystem->checkAccess(
'write', $this->gui->ref_id)) {
517 $this->
ilias->raiseError(
518 $this->ilLng->txt(
'msg_no_perm_write'),
519 $this->
ilias->error_obj->MESSAGE
525 require_once
'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
530 $atLeastOneKeywordGiven = count($keywords) > 0;
532 if (!($isFormValid = $this->form_gui->checkInput()) || !$atLeastOneKeywordGiven) {
537 $this->form_gui->setValuesByPost();
543 $pathinfo = pathinfo($_FILES[
"chatroom_image_path"][
"name"]);
544 $target_file = md5(time() + $pathinfo[
'basename']) .
"." . $pathinfo[
'extension'];
546 if ($this->upload->hasUploads() && !$this->upload->hasBeenProcessed()) {
547 $this->upload->process();
550 $result = array_values($this->upload->getResults())[0];
552 $this->upload->moveOneFileTo(
555 \
ILIAS\FileUpload\Location::WEB,
560 ilChatroomSmilies::_storeSmiley(join(
"\n", $keywords), $target_file);
564 \ilUtil::sendSuccess($this->ilLng->txt(
'saved_successfully'),
true);
deleteSmileyObject()
Deletes a smiley by $_REQUEST["chatroom_smiley_id"].
static makeDirParents($a_dir)
Create a new directory and all parent directories.
This class provides processing control methods.
static _getExistingSmiliesTable($a_ref)
Constructor public.
static _getSmileyDir($withBaseDir=true)
Class ChatMainBarProvider .
view()
Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table...
setValue($a_value)
Set Value.
initSmiliesForm()
Initializes smilies form and returns it.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
initSmiliesEditForm($form_data)
Initializes SmiliesEditForm and returns it.
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get form action url for gui class object.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
Class ilChatroomGUIHandler.
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getSmileyFormDataById($smileyId)
saveParameter($a_obj, $a_parameter)
Set parameters that should be passed in every form and link of a gui class.
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a text area property in a property form.
static getSmiliesBasePath()
Returns smilies basepath.
static _insertDefaultValues()
static _prepareKeywords($words)
Trims given keywords and returns them in one array.
Class ilChatroomSmileyGUI Provides methods to show, add, edit and delete smilies consisting of icon a...
showEditSmileyEntryFormObject()
Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.
editSmiliesObject()
Shows existing smilies table Prepares existing smilies table and displays it.
executeDefault($requestedMethod)
{}
deleteMultipleObject()
Shows confirmation view for deleting multiple smilies Prepares confirmation view for deleting multipl...
showDeleteSmileyFormObject()
Shows DeleteSmileyForm Prepares DeleteSmileyForm and displays it.
static getWebspaceDir($mode="filesystem")
get webspace directory
confirmedDeleteMultipleObject()
Deletes multiple smilies by $_REQUEST["sel_ids"].
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
Confirmation screen class.