ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilChatroomAdminSmileyGUI Class Reference

Class ilChatroomSmileyGUI Provides methods to show, add, edit and delete smilies consisting of icon and keywords. More...

+ Inheritance diagram for ilChatroomAdminSmileyGUI:
+ Collaboration diagram for ilChatroomAdminSmileyGUI:

Public Member Functions

 executeDefault ($requestedMethod)
 {
Parameters
string$requestedMethod
Returns
mixed
} More...
 
 view ()
 Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table of existing smilies. More...
 
 editSmiliesObject ()
 Shows existing smilies table Prepares existing smilies table and displays it. More...
 
 initSmiliesForm ()
 Initializes smilies form and returns it. More...
 
 showEditSmileyEntryFormObject ()
 Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it. More...
 
 initSmiliesEditForm ($form_data)
 Initializes SmiliesEditForm and returns it. More...
 
 deleteSmileyObject ()
 Deletes a smiley by $_REQUEST["chatroom_smiley_id"] @global ilRbacSystem $rbacsystem @global ilCtrl $ilCtrl. More...
 
 updateSmiliesObject ()
 Updates a smiley and/or its keywords Updates a smiley icon and/or its keywords by $_REQUEST["chatroom_smiley_id"] and gets keywords from $_REQUEST["chatroom_smiley_keywords"]. More...
 
 uploadSmileyObject ()
 Uploads and stores a new smiley with keywords from $_REQUEST["chatroom_smiley_keywords"] @global ilRbacSystem $rbacsystem @global ilCtrl2 $ilCtrl. More...
 
- Public Member Functions inherited from ilChatroomGUIHandler
 __construct (ilChatroomObjectGUI $gui)
 
 sendResponse ($response)
 Sends a json encoded response and exits the php process. More...
 
 hasPermission ($permission)
 Checks for access with ilRbacSystem. More...
 
 execute ($method)
 Executes given $method if existing, otherwise executes executeDefault() method. More...
 
 executeDefault ($requestedMethod)
 
 redirectIfNoPermission ($permission)
 Checks for requested permissions and redirects if the permission check failed. More...
 
 isSuccessful ($response)
 Checks for success param in an json decoded response. More...
 

Static Public Member Functions

static _checkSetup ()
 
static _getSmileyDir ()
 

Static Private Member Functions

static _setupFolder ()
 setup directory More...
 
static _insertDefaultValues ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilChatroomGUIHandler
 getRoomByObjectId ($objectId)
 
 exitIfNoRoomExists ($room)
 Checks if a ilChatroom exists. More...
 
 exitIfNoRoomPermission ($room, $subRoom, $chat_user)
 Check if user can moderate a chatroom. More...
 
 canModerate ($room, $subRoom, $user_id)
 Checks if the user has permission to moderate a ilChatroom. More...
 
 isMainRoom ($subRoomId)
 
- Protected Attributes inherited from ilChatroomGUIHandler
 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $rbacsystem
 

Detailed Description

Class ilChatroomSmileyGUI Provides methods to show, add, edit and delete smilies consisting of icon and keywords.

Author
Andreas Kordosz akord.nosp@m.osz@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilChatroomAdminSmileyGUI.php.

Member Function Documentation

◆ _checkSetup()

static ilChatroomAdminSmileyGUI::_checkSetup ( )
static

Definition at line 52 of file class.ilChatroomAdminSmileyGUI.php.

53 {
54 global $lng;
55
57
58 if(!is_dir($path))
59 {
60 ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_exists'));
62
63 if(!is_dir($path))
64 {
65 ilUtil::sendFailure($lng->txt('chat_smilies_dir_not_available'));
66 return false;
67 }
68 else
69 {
70 $smilies = array
71 (
72 "icon_smile.gif",
73 "icon_wink.gif",
74 "icon_laugh.gif",
75 "icon_sad.gif",
76 "icon_shocked.gif",
77 "icon_tongue.gif",
78 "icon_cool.gif",
79 "icon_eek.gif",
80 "icon_angry.gif",
81 "icon_flush.gif",
82 "icon_idea.gif",
83 "icon_thumbup.gif",
84 "icon_thumbdown.gif",
85 );
86
87 foreach($smilies as $smiley)
88 {
89 copy("templates/default/images/emoticons/$smiley", $path . "/$smiley");
90 }
91
93
94 ilUtil::sendSuccess($lng->txt('chat_smilies_initialized'));
95 }
96
97 }
98
99 if(!is_writable($path))
100 {
101 ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_writable'));
102 }
103
104 return true;
105 }
$path
Definition: aliased.php:25
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $lng
Definition: privfeed.php:17

References $lng, $path, _getSmileyDir(), _insertDefaultValues(), ilUtil\makeDirParents(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSmileyDir()

static ilChatroomAdminSmileyGUI::_getSmileyDir ( )
static
Returns
string path to smilies

Definition at line 110 of file class.ilChatroomAdminSmileyGUI.php.

111 {
112 return ilUtil::getWebspaceDir() . '/chatroom/smilies';
113 }
static getWebspaceDir($mode="filesystem")
get webspace directory

References ilUtil\getWebspaceDir().

Referenced by _checkSetup(), and _setupFolder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _insertDefaultValues()

static ilChatroomAdminSmileyGUI::_insertDefaultValues ( )
staticprivate

Definition at line 115 of file class.ilChatroomAdminSmileyGUI.php.

116 {
117 $values = array(
118 array("icon_smile.gif", ":)\n:-)\n:smile:"),
119 array("icon_wink.gif", ";)\n;-)\n:wink:"),
120 array("icon_laugh.gif", ":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
121 array("icon_sad.gif", ":(\n:-(\n:sad:"),
122 array("icon_shocked.gif", ":o\n:-o\n:shocked:"),
123 array("icon_tongue.gif", ":p\n:-p\n:tongue:"),
124 array("icon_cool.gif", ":cool:"),
125 array("icon_eek.gif", ":eek:"),
126 array("icon_angry.gif", ":||\n:-||\n:angry:"),
127 array("icon_flush.gif", ":flush:"),
128 array("icon_idea.gif", ":idea:"),
129 array("icon_thumbup.gif", ":thumbup:"),
130 array("icon_thumbdown.gif", ":thumbdown:"),
131 );
132
133 require_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
134 foreach($values as $val)
135 {
136 ilChatroomSmilies::_storeSmiley($val[1], $val[0]);
137 }
138 }

Referenced by _checkSetup().

+ Here is the caller graph for this function:

◆ _setupFolder()

static ilChatroomAdminSmileyGUI::_setupFolder ( )
staticprivate

setup directory

Definition at line 17 of file class.ilChatroomAdminSmileyGUI.php.

18 {
20
21 if(!is_dir($path))
22 {
23 mkdir($path, 0755, true);
24 }
25 }

References $path, and _getSmileyDir().

+ Here is the call graph for this function:

◆ deleteSmileyObject()

ilChatroomAdminSmileyGUI::deleteSmileyObject ( )

Deletes a smiley by $_REQUEST["chatroom_smiley_id"] @global ilRbacSystem $rbacsystem @global ilCtrl $ilCtrl.

Definition at line 382 of file class.ilChatroomAdminSmileyGUI.php.

383 {
384 global $rbacsystem, $ilCtrl, $lng;
385
386 if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
387 {
388 $this->ilias->raiseError(
389 $lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
390 );
391 }
392
393 include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
394
395 ilChatroomSmilies::_deleteSmiley($_REQUEST["chatroom_smiley_id"]);
396
397 $ilCtrl->redirect($this->gui, "smiley");
398 }
redirection script todo: (a better solution should control the processing via a xml file)

References ilChatroomGUIHandler\$ilCtrl, $lng, and ilChatroomGUIHandler\$rbacsystem.

◆ editSmiliesObject()

ilChatroomAdminSmileyGUI::editSmiliesObject ( )

Shows existing smilies table Prepares existing smilies table and displays it.

@global ilRbacSystem $rbacsystem @global ilLanguage $lng @global ilTemplate $tpl

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

148 {
149 global $rbacsystem, $lng, $tpl;
150
151 if(!$rbacsystem->checkAccess('read', $this->gui->ref_id))
152 {
153 $this->ilias->raiseError(
154 $lng->txt('msg_no_perm_read'), $this->gui->ilias->error_obj->MESSAGE
155 );
156 }
157
158 include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
159
161
162 if(!$this->form_gui)
163 {
164 $form = $this->initSmiliesForm();
165 }
166 else
167 {
168 $form = $this->form_gui;
169 }
170
171 include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesGUI.php";
172
174
175 $tpl_smilies = new ilTemplate(
176 "tpl.chatroom_edit_smilies.html", true, true, "Modules/Chatroom"
177 );
178 $tpl_smilies->setVariable("SMILEY_TABLE", $table);
179 $tpl_smilies->setVariable("SMILEY_FORM", $form->getHtml());
180
181 $tpl->setContent($tpl_smilies->get());
182 }
global $tpl
Definition: ilias.php:8
initSmiliesForm()
Initializes smilies form and returns it.
static _getExistingSmiliesTable($a_ref)
Constructor @access public.
static _checkSetup()
Checks if smiley folder is available; if not it will try to create folder and performs actions for an...
special template class to simplify handling of ITX/PEAR

References $lng, ilChatroomGUIHandler\$rbacsystem, $tpl, ilChatroomSmilies\_checkSetup(), ilChatroomSmiliesGUI\_getExistingSmiliesTable(), and initSmiliesForm().

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeDefault()

ilChatroomAdminSmileyGUI::executeDefault (   $requestedMethod)

{

Parameters
string$requestedMethod
Returns
mixed
}

Reimplemented from ilChatroomGUIHandler.

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

31 {
32 $this->view();
33 }
view()
Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table...

References view().

+ Here is the call graph for this function:

◆ initSmiliesEditForm()

ilChatroomAdminSmileyGUI::initSmiliesEditForm (   $form_data)

Initializes SmiliesEditForm and returns it.

@global ilCtrl2 $ilCtrl @global ilLanguage $lng

Returns
ilPropertyFormGUI

Definition at line 278 of file class.ilChatroomAdminSmileyGUI.php.

279 {
280 global $ilCtrl, $lng;
281
282 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
283
284 $this->form_gui = new ilPropertyFormGUI();
285
286 $this->form_gui->setValuesByArray($form_data);
287
288 $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
289
290 $ilCtrl->saveParameter($this->gui, 'smiley_id');
291
292 $this->form_gui->setFormAction(
293 $ilCtrl->getFormAction($this->gui, 'smiley-updateSmiliesObject') . $table_nav
294 );
295
296 $sec_l = new ilFormSectionHeaderGUI();
297
298 $sec_l->setTitle($lng->txt('chatroom_edit_smiley'));
299 $this->form_gui->addItem($sec_l);
300
301 include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesCurrentSmileyFormElement.php";
302
304 $lng->txt('chatroom_current_smiley_image_path'),
305 'chatroom_current_smiley_image_path'
306 );
307
308 $inp->setValue($form_data['chatroom_current_smiley_image_path']);
309 $this->form_gui->addItem($inp);
310
311 $inp = new ilImageFileInputGUI(
312 $lng->txt('chatroom_image_path'), 'chatroom_image_path'
313 );
314 $inp->setSuffixes(array("jpg", "jpeg", "png", "gif", "svg"));
315
316 $inp->setRequired(false);
317 $inp->setInfo($lng->txt('chatroom_smiley_image_only_if_changed'));
318 $this->form_gui->addItem($inp);
319
320 $inp = new ilTextAreaInputGUI(
321 $lng->txt('chatroom_smiley_keywords'), 'chatroom_smiley_keywords'
322 );
323
324 $inp->setValue($form_data['chatroom_smiley_keywords']);
325 $inp->setUseRte(false);
326 $inp->setRequired(true);
327 $inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
328 $this->form_gui->addItem($inp);
329
330 $inp = new ilHiddenInputGUI('chatroom_smiley_id');
331
332 $this->form_gui->addItem($inp);
333 $this->form_gui->addCommandButton(
334 'smiley-updateSmiliesObject', $lng->txt('submit')
335 );
336 $this->form_gui->addCommandButton('smiley', $lng->txt('cancel'));
337 return $this->form_gui;
338 }
Class ilChatroomSmiliesCurrentSmileyFormElement Class ilchatroomSmiliesCurrentSmileyFormElement simpl...
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
This class represents an image file property in a property form.
This class represents a property form user interface.
This class represents a text area property in a property form.

References ilChatroomGUIHandler\$ilCtrl, and $lng.

Referenced by showEditSmileyEntryFormObject().

+ Here is the caller graph for this function:

◆ initSmiliesForm()

ilChatroomAdminSmileyGUI::initSmiliesForm ( )

Initializes smilies form and returns it.

@global ilCtrl2 $ilCtrl @global ilLanguage $lng

Returns
ilPropertyFormGUI

Definition at line 190 of file class.ilChatroomAdminSmileyGUI.php.

191 {
192 global $ilCtrl, $lng;
193
194 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
195
196 $this->form_gui = new ilPropertyFormGUI();
197
198 $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
199 $this->form_gui->setFormAction(
200 $ilCtrl->getFormAction($this->gui, 'smiley-uploadSmileyObject') . $table_nav
201 );
202
203 // chat server settings
204 $sec_l = new ilFormSectionHeaderGUI();
205
206 $sec_l->setTitle($lng->txt('chatroom_add_smiley'));
207 $this->form_gui->addItem($sec_l);
208
209 $inp = new ilImageFileInputGUI(
210 $lng->txt('chatroom_image_path'), 'chatroom_image_path'
211 );
212 $inp->setSuffixes(array("jpg", "jpeg", "png", "gif", "svg"));
213
214 $inp->setRequired(true);
215 $this->form_gui->addItem($inp);
216
217 $inp = new ilTextAreaInputGUI(
218 $lng->txt('chatroom_smiley_keywords'), 'chatroom_smiley_keywords'
219 );
220
221 $inp->setRequired(true);
222 $inp->setUseRte(false);
223 $inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
224 $this->form_gui->addItem($inp);
225 $this->form_gui->addCommandButton(
226 'smiley-uploadSmileyObject', $lng->txt('chatroom_upload_smiley')
227 );
228
229 return $this->form_gui;
230 }

References ilChatroomGUIHandler\$ilCtrl, and $lng.

Referenced by editSmiliesObject(), and uploadSmileyObject().

+ Here is the caller graph for this function:

◆ showEditSmileyEntryFormObject()

ilChatroomAdminSmileyGUI::showEditSmileyEntryFormObject ( )

Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.

@global ilRbacSystem $rbacsystem @global ilTemplate $tpl

Definition at line 238 of file class.ilChatroomAdminSmileyGUI.php.

239 {
240 global $rbacsystem, $tpl, $lng;
241
242 $this->gui->switchToVisibleMode();
243
244 if(!$rbacsystem->checkAccess('read', $this->gui->ref_id))
245 {
246 $this->ilias->raiseError(
247 $lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE
248 );
249 }
250
251 include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
252
253 $smiley = ilChatroomSmilies::_getSmiley($_REQUEST["smiley_id"]);
254
255 $form_data = array(
256 "chatroom_smiley_id" => $smiley["smiley_id"],
257 "chatroom_smiley_keywords" => $smiley["smiley_keywords"],
258 "chatroom_current_smiley_image_path" => $smiley["smiley_fullpath"],
259 );
260
261 $form = $this->initSmiliesEditForm($form_data);
262
263 $tpl_form = new ilTemplate(
264 "tpl.chatroom_edit_smilies.html", true, true, "Modules/Chatroom"
265 );
266
267 $tpl_form->setVariable("SMILEY_FORM", $form->getHTML());
268
269 $tpl->setContent($tpl_form->get());
270 }
initSmiliesEditForm($form_data)
Initializes SmiliesEditForm and returns it.

References $lng, ilChatroomGUIHandler\$rbacsystem, $tpl, and initSmiliesEditForm().

+ Here is the call graph for this function:

◆ updateSmiliesObject()

ilChatroomAdminSmileyGUI::updateSmiliesObject ( )

Updates a smiley and/or its keywords Updates a smiley icon and/or its keywords by $_REQUEST["chatroom_smiley_id"] and gets keywords from $_REQUEST["chatroom_smiley_keywords"].

@global ilRbacSystem $rbacsystem @global ilCtrl2 $ilCtrl

Definition at line 407 of file class.ilChatroomAdminSmileyGUI.php.

408 {
409 global $rbacsystem, $ilCtrl, $tpl, $lng;
410
411 if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
412 {
413 $this->ilias->raiseError(
414 $lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
415 );
416 }
417
418 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
419 $this->form_gui = new ilPropertyFormGUI();
420
421 // $this->initSmiliesEditForm();
422
423 include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
424
426 ilUtil::stripSlashes($_REQUEST["chatroom_smiley_keywords"])
427 );
428
429 $keywordscheck = count($keywords) > 0;
430
431 if(!$this->form_gui->checkInput() || !$keywordscheck)
432 {
433 $tpl->setContent($this->form_gui->getHtml());
434 ilUtil::sendFailure('test', true);
435 return $this->view();
436 }
437 else
438 {
439 $data = array();
440 $data["smiley_keywords"] = join("\n", $keywords);
441 $data["smiley_id"] = $_REQUEST["smiley_id"];
442
443 if($_FILES["chatroom_image_path"])
444 {
446 $_FILES["chatroom_image_path"]["tmp_name"],
447 $_FILES["chatroom_image_path"]["name"],
448 ilChatroomSmilies::_getSmiliesBasePath() . $_FILES["chatroom_image_path"]["name"]
449 );
450
451 $data["smiley_path"] = $_FILES["chatroom_image_path"]["name"];
452 }
453
454 ilChatroomSmilies::_updateSmiley($data);
455 }
456
457 $ilCtrl->redirect($this->gui, "smiley");
458 }
static _getSmiliesBasePath()
Returns smilies basepath.
static _prepareKeywords($words)
Trims given keywords and returns them in one array.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $data, ilChatroomGUIHandler\$ilCtrl, $lng, ilChatroomGUIHandler\$rbacsystem, $tpl, ilChatroomSmilies\_getSmiliesBasePath(), ilChatroomSmilies\_prepareKeywords(), ilUtil\moveUploadedFile(), ilUtil\sendFailure(), ilUtil\stripSlashes(), and view().

+ Here is the call graph for this function:

◆ uploadSmileyObject()

ilChatroomAdminSmileyGUI::uploadSmileyObject ( )

Uploads and stores a new smiley with keywords from $_REQUEST["chatroom_smiley_keywords"] @global ilRbacSystem $rbacsystem @global ilCtrl2 $ilCtrl.

Definition at line 549 of file class.ilChatroomAdminSmileyGUI.php.

550 {
551 global $rbacsystem, $ilCtrl, $tpl, $lng;
552
553 if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
554 {
555 $this->ilias->raiseError(
556 $lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
557 );
558 }
559
560 $this->initSmiliesForm();
561
562 include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
563 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
564
565 //$this->form_gui = new ilPropertyFormGUI();
566
567 $this->form_gui->setValuesByPost();
568
570 ilUtil::stripSlashes($_REQUEST["chatroom_smiley_keywords"])
571 );
572
573 $keywordscheck = count($keywords) > 0;
574
575 if(!$this->form_gui->checkInput())
576 {
577 $tpl->setContent($this->form_gui->getHtml());
578 return $this->view();
579 }
580
581 $pathinfo = pathinfo($_FILES["chatroom_image_path"]["name"]);
582 $target_file = md5(time() + $pathinfo['basename']) . "." . $pathinfo['extension'];
583
585 $_FILES["chatroom_image_path"]["tmp_name"],
586 $target_file,
588 );
589
590 ilChatroomSmilies::_storeSmiley(join("\n", $keywords), $target_file);
591
592 $ilCtrl->redirect($this->gui, "smiley");
593 }

References ilChatroomGUIHandler\$ilCtrl, $lng, ilChatroomGUIHandler\$rbacsystem, $tpl, ilChatroomSmilies\_getSmiliesBasePath(), ilChatroomSmilies\_prepareKeywords(), initSmiliesForm(), ilUtil\moveUploadedFile(), ilUtil\stripSlashes(), and view().

+ Here is the call graph for this function:

◆ view()

ilChatroomAdminSmileyGUI::view ( )

Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table of existing smilies.

Definition at line 39 of file class.ilChatroomAdminSmileyGUI.php.

40 {
41 include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
42
43 ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
44
45 $this->gui->switchToVisibleMode();
46
48
49 $this->editSmiliesObject();
50 }
editSmiliesObject()
Shows existing smilies table Prepares existing smilies table and displays it.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.

References _checkSetup(), ilChatroom\checkUserPermissions(), and editSmiliesObject().

Referenced by executeDefault(), updateSmiliesObject(), and uploadSmileyObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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