ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilChatroomSmileyTask Class Reference

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

+ Inheritance diagram for ilChatroomSmileyTask:
+ Collaboration diagram for ilChatroomSmileyTask:

Public Member Functions

 __construct (ilChatroomObjectGUI $gui)
 Constructor Sets $this->gui. More...
 
 executeDefault ($method)
 Default execute command. More...
 
 view ()
 Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table of existing smilies. More...
 
 showEditSmileyEntryFormObject ()
 Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it. More...
 
 deleteSmileyObject ()
 Deletes a smiley by $_REQUEST["chatroom_smiley_id"] @global ilRbacSystem $rbacsystem @global ilCtrl2 $ilCtrl. More...
 
 editSmiliesObject ()
 Shows existing smilies table Prepares existing smilies table and displays it. 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...
 
 initSmiliesForm ()
 Initializes smilies form and returns it. More...
 
 initSmiliesEditForm ($form_data)
 Initializes SmiliesEditForm and returns it. More...
 
 uploadSmileyObject ()
 Uploads and stores a new smiley with keywords from $_REQUEST["chatroom_smiley_keywords"] @global ilRbacSystem $rbacsystem @global ilCtrl2 $ilCtrl. More...
 
 __construct (ilChatroomObjectGUI $gui)
 
 executeDefault ($requestedMethod)
 

Static Public Member Functions

static _getSmileyDir ()
 
static _checkSetup ()
 

Static Private Member Functions

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

Private Attributes

 $gui
 

Detailed Description

Class ilChatroomSmileyTask 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.ilChatroomSmileyTask.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomSmileyTask::__construct ( ilChatroomObjectGUI  $gui)

Constructor Sets $this->gui.

Parameters
ilChatroomObjectGUI$gui

Reimplemented from ilChatroomTaskHandler.

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

23 {
24 $this->gui = $gui;
25 }

References $gui.

Member Function Documentation

◆ _checkSetup()

static ilChatroomSmileyTask::_checkSetup ( )
static

Definition at line 567 of file class.ilChatroomSmileyTask.php.

568 {
569 global $lng;
570
572
573 if(!is_dir($path))
574 {
575 ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_exists'));
577
578 if(!is_dir($path))
579 {
580 ilUtil::sendFailure($lng->txt('chat_smilies_dir_not_available'));
581 return false;
582 }
583 else
584 {
585 $smilies = array
586 (
587 "icon_smile.gif",
588 "icon_wink.gif",
589 "icon_laugh.gif",
590 "icon_sad.gif",
591 "icon_shocked.gif",
592 "icon_tongue.gif",
593 "icon_cool.gif",
594 "icon_eek.gif",
595 "icon_angry.gif",
596 "icon_flush.gif",
597 "icon_idea.gif",
598 "icon_thumbup.gif",
599 "icon_thumbdown.gif",
600 );
601
602 foreach($smilies as $smiley)
603 {
604 copy("templates/default/images/emoticons/$smiley", $path . "/$smiley");
605 }
606
608
609 ilUtil::sendSuccess($lng->txt('chat_smilies_initialized'));
610 }
611
612 }
613
614 if(!is_writable($path))
615 {
616 ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_writable'));
617 }
618
619 return true;
620 }
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:40
$path
Definition: index.php:22

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 ilChatroomSmileyTask::_getSmileyDir ( )
static
Returns
string path to smilies

Definition at line 562 of file class.ilChatroomSmileyTask.php.

563 {
564 return ilUtil::getWebspaceDir() . '/chatroom/smilies';
565 }
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 ilChatroomSmileyTask::_insertDefaultValues ( )
staticprivate

Definition at line 509 of file class.ilChatroomSmileyTask.php.

510 {
511 global $ilDB;
512
513 $values = array(
514 array("icon_smile.gif", ":)\n:-)\n:smile:"),
515 array("icon_wink.gif", ";)\n;-)\n:wink:"),
516 array("icon_laugh.gif", ":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
517 array("icon_sad.gif", ":(\n:-(\n:sad:"),
518 array("icon_shocked.gif", ":o\n:-o\n:shocked:"),
519 array("icon_tongue.gif", ":p\n:-p\n:tongue:"),
520 array("icon_cool.gif", ":cool:"),
521 array("icon_eek.gif", ":eek:"),
522 array("icon_angry.gif", ":||\n:-||\n:angry:"),
523 array("icon_flush.gif", ":flush:"),
524 array("icon_idea.gif", ":idea:"),
525 array("icon_thumbup.gif", ":thumbup:"),
526 array("icon_thumbdown.gif", ":thumbdown:"),
527 );
528
529 $stmt = $ilDB->prepare("
530 INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path)
531 VALUES (?, ?, ?)",
532 array("integer", "text", "text")
533 );
534
535 foreach($values as $val)
536 {
537 $row = array(
538 $ilDB->nextID("chat_smilies"),
539 $val[1],
540 $val[0]
541 );
542 $stmt->execute($row);
543 }
544 }
global $ilDB

References $ilDB, and $row.

Referenced by _checkSetup().

+ Here is the caller graph for this function:

◆ _setupFolder()

static ilChatroomSmileyTask::_setupFolder ( )
staticprivate

setup directory

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

550 {
552
553 if(!is_dir($path))
554 {
555 mkdir($path, 0755, true);
556 }
557 }

References $path, and _getSmileyDir().

+ Here is the call graph for this function:

◆ deleteSmileyObject()

ilChatroomSmileyTask::deleteSmileyObject ( )

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

Definition at line 139 of file class.ilChatroomSmileyTask.php.

140 {
141 global $rbacsystem, $ilCtrl, $lng;
142
143 if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
144 {
145 $this->ilias->raiseError(
146 $lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
147 );
148 }
149
150 include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
151
152 ilChatroomSmilies::_deleteSmiley($_REQUEST["chatroom_smiley_id"]);
153
154 $ilCtrl->redirect($this->gui, "smiley");
155 }
static _deleteSmiley($a_id)
Deletes smiliey by given id from database.
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, $ilCtrl, $lng, and ilChatroomSmilies\_deleteSmiley().

+ Here is the call graph for this function:

◆ editSmiliesObject()

ilChatroomSmileyTask::editSmiliesObject ( )

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

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

Definition at line 164 of file class.ilChatroomSmileyTask.php.

165 {
166 global $rbacsystem, $lng, $tpl;
167
168 if(!$rbacsystem->checkAccess('read', $this->gui->ref_id))
169 {
170 $this->ilias->raiseError(
171 $lng->txt('msg_no_perm_read'), $this->gui->ilias->error_obj->MESSAGE
172 );
173 }
174
175 include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
176
178
179 if(!$this->form_gui)
180 {
181 $form = $this->initSmiliesForm();
182 }
183 else
184 {
185 $form = $this->form_gui;
186 }
187
188 include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesGUI.php";
189
191
192 $tpl_smilies = new ilTemplate(
193 "tpl.chatroom_edit_smilies.html", true, true, "Modules/Chatroom"
194 );
195 $tpl_smilies->setVariable("SMILEY_TABLE", $table);
196 $tpl_smilies->setVariable("SMILEY_FORM", $form->getHtml());
197
198 $tpl->setContent($tpl_smilies->get());
199 }
global $tpl
Definition: ilias.php:8
initSmiliesForm()
Initializes smilies form and returns it.
static _getExistingSmiliesTable($a_ref)
Instantiates ilChatroomSmiliesTableGUI and returns its table's HTML.
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, $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()

ilChatroomSmileyTask::executeDefault (   $method)

Default execute command.

Calls view method.

Parameters
string$method

Reimplemented from ilChatroomTaskHandler.

Definition at line 32 of file class.ilChatroomSmileyTask.php.

33 {
34 //include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
35 //ilChatroomSmilies::_initial();
36 $this->view();
37 }
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()

ilChatroomSmileyTask::initSmiliesEditForm (   $form_data)

Initializes SmiliesEditForm and returns it.

@global ilCtrl2 $ilCtrl @global ilLanguage $lng

Returns
ilPropertyFormGUI

Definition at line 397 of file class.ilChatroomSmileyTask.php.

398 {
399 global $ilCtrl, $lng;
400
401 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
402
403 $this->form_gui = new ilPropertyFormGUI();
404
405 $this->form_gui->setValuesByArray($form_data);
406
407 $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
408
409 $ilCtrl->saveParameter($this->gui, 'smiley_id');
410
411 $this->form_gui->setFormAction(
412 $ilCtrl->getFormAction($this->gui, 'smiley-updateSmiliesObject') . $table_nav
413 );
414
415 $sec_l = new ilFormSectionHeaderGUI();
416
417 $sec_l->setTitle($lng->txt('chatroom_edit_smiley'));
418 $this->form_gui->addItem($sec_l);
419
420 include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesCurrentSmileyFormElement.php";
421
423 $lng->txt('chatroom_current_smiley_image_path'),
424 'chatroom_current_smiley_image_path'
425 );
426
427 $inp->setValue($form_data['chatroom_current_smiley_image_path']);
428 $this->form_gui->addItem($inp);
429
430 $inp = new ilImageFileInputGUI(
431 $lng->txt('chatroom_image_path'), 'chatroom_image_path'
432 );
433
434 $inp->setRequired(false);
435 $inp->setInfo($lng->txt('chatroom_smiley_image_only_if_changed'));
436 $this->form_gui->addItem($inp);
437
438 $inp = new ilTextAreaInputGUI(
439 $lng->txt('chatroom_smiley_keywords'), 'chatroom_smiley_keywords'
440 );
441
442 $inp->setValue($form_data['chatroom_smiley_keywords']);
443 $inp->setUseRte(false);
444 $inp->setRequired(true);
445 $inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
446 $this->form_gui->addItem($inp);
447
448 $inp = new ilHiddenInputGUI('chatroom_smiley_id');
449
450 $this->form_gui->addItem($inp);
451 $this->form_gui->addCommandButton(
452 'smiley-updateSmiliesObject', $lng->txt('submit')
453 );
454 $this->form_gui->addCommandButton('smiley', $lng->txt('cancel'));
455 return $this->form_gui;
456 }
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 $_REQUEST, $ilCtrl, and $lng.

Referenced by showEditSmileyEntryFormObject().

+ Here is the caller graph for this function:

◆ initSmiliesForm()

ilChatroomSmileyTask::initSmiliesForm ( )

Initializes smilies form and returns it.

@global ilCtrl2 $ilCtrl @global ilLanguage $lng

Returns
ilPropertyFormGUI

Definition at line 267 of file class.ilChatroomSmileyTask.php.

268 {
269 global $ilCtrl, $lng;
270
271 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
272
273 $this->form_gui = new ilPropertyFormGUI();
274
275 $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
276 $this->form_gui->setFormAction(
277 $ilCtrl->getFormAction($this->gui, 'smiley-uploadSmileyObject') . $table_nav
278 );
279
280 // chat server settings
281 $sec_l = new ilFormSectionHeaderGUI();
282
283 $sec_l->setTitle($lng->txt('chatroom_add_smiley'));
284 $this->form_gui->addItem($sec_l);
285
286 $inp = new ilImageFileInputGUI(
287 $lng->txt('chatroom_image_path'), 'chatroom_image_path'
288 );
289
290 $inp->setRequired(true);
291 $this->form_gui->addItem($inp);
292
293 $inp = new ilTextAreaInputGUI(
294 $lng->txt('chatroom_smiley_keywords'), 'chatroom_smiley_keywords'
295 );
296
297 $inp->setRequired(true);
298 $inp->setUseRte(false);
299 $inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
300 $this->form_gui->addItem($inp);
301 $this->form_gui->addCommandButton(
302 'smiley-uploadSmileyObject', $lng->txt('chatroom_upload_smiley')
303 );
304
305 return $this->form_gui;
306 }

References $_REQUEST, $ilCtrl, and $lng.

Referenced by editSmiliesObject(), and uploadSmileyObject().

+ Here is the caller graph for this function:

◆ showEditSmileyEntryFormObject()

ilChatroomSmileyTask::showEditSmileyEntryFormObject ( )

Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.

@global ilRbacSystem $rbacsystem @global ilTemplate $tpl

Definition at line 63 of file class.ilChatroomSmileyTask.php.

64 {
65 global $rbacsystem, $tpl, $lng;
66
67 $this->gui->switchToVisibleMode();
68
69 if(!$rbacsystem->checkAccess('read', $this->gui->ref_id))
70 {
71 $this->ilias->raiseError(
72 $lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE
73 );
74 }
75
76 include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
77
78 $smiley = ilChatroomSmilies::_getSmiley($_REQUEST["smiley_id"]);
79
80 $form_data = array(
81 "chatroom_smiley_id" => $smiley["smiley_id"],
82 "chatroom_smiley_keywords" => $smiley["smiley_keywords"],
83 "chatroom_current_smiley_image_path" => $smiley["smiley_fullpath"],
84 );
85
86 $form = $this->initSmiliesEditForm($form_data);
87
88 $tpl_form = new ilTemplate(
89 "tpl.chatroom_edit_smilies.html", true, true, "Modules/Chatroom"
90 );
91
92 $tpl_form->setVariable("SMILEY_FORM", $form->getHTML());
93
94 $tpl->setContent($tpl_form->get());
95 }
initSmiliesEditForm($form_data)
Initializes SmiliesEditForm and returns it.
static _getSmiley($a_id)
Looks up and returns smiley with id, throws exception if id is not found.

References $_REQUEST, $lng, $tpl, ilChatroomSmilies\_getSmiley(), and initSmiliesEditForm().

+ Here is the call graph for this function:

◆ updateSmiliesObject()

ilChatroomSmileyTask::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 208 of file class.ilChatroomSmileyTask.php.

209 {
210 global $rbacsystem, $ilCtrl, $tpl, $lng;
211
212 if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
213 {
214 $this->ilias->raiseError(
215 $lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
216 );
217 }
218
219 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
220 $this->form_gui = new ilPropertyFormGUI();
221
222 // $this->initSmiliesEditForm();
223
224 include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
225
227 ilUtil::stripSlashes($_REQUEST["chatroom_smiley_keywords"])
228 );
229
230 $keywordscheck = count($keywords) > 0;
231
232 if(!$this->form_gui->checkInput() || !$keywordscheck)
233 {
234 $tpl->setContent($this->form_gui->getHtml());
235 ilUtil::sendFailure('test', true);
236 return $this->view();
237 }
238 else
239 {
240 $data = array();
241 $data["smiley_keywords"] = join("\n", $keywords);
242 $data["smiley_id"] = $_REQUEST["smiley_id"];
243
244 if($_FILES["chatroom_image_path"])
245 {
246 move_uploaded_file(
247 $_FILES["chatroom_image_path"]["tmp_name"],
249 $_FILES["chatroom_image_path"]["name"]
250 );
251
252 $data["smiley_path"] = $_FILES["chatroom_image_path"]["name"];
253 }
254
256 }
257
258 $ilCtrl->redirect($this->gui, "smiley");
259 }
static _getSmiliesBasePath()
Returns smilies basepath.
static _prepareKeywords($words)
Trims given keywords and returns them in one array.
static _updateSmiley($data)
Updates smiley in DB by keyword and id from given array ($data["smiley_keywords"],...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_REQUEST, $data, $ilCtrl, $lng, $tpl, ilChatroomSmilies\_getSmiliesBasePath(), ilChatroomSmilies\_prepareKeywords(), ilChatroomSmilies\_updateSmiley(), ilUtil\sendFailure(), ilUtil\stripSlashes(), and view().

+ Here is the call graph for this function:

◆ uploadSmileyObject()

ilChatroomSmileyTask::uploadSmileyObject ( )

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

Definition at line 464 of file class.ilChatroomSmileyTask.php.

465 {
466 global $rbacsystem, $ilCtrl, $tpl, $lng;
467
468 if(!$rbacsystem->checkAccess('write', $this->gui->ref_id))
469 {
470 $this->ilias->raiseError(
471 $lng->txt('msg_no_perm_write'), $this->ilias->error_obj->MESSAGE
472 );
473 }
474
475 $this->initSmiliesForm();
476
477 include_once "Modules/Chatroom/classes/class.ilChatroomSmilies.php";
478 include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
479
480 //$this->form_gui = new ilPropertyFormGUI();
481
482 $this->form_gui->setValuesByPost();
483
485 ilUtil::stripSlashes($_REQUEST["chatroom_smiley_keywords"])
486 );
487
488 $keywordscheck = count($keywords) > 0;
489
490 if(!$this->form_gui->checkInput())
491 {
492 $tpl->setContent($this->form_gui->getHtml());
493 return $this->view();
494 }
495
496 $pathinfo = pathinfo($_FILES["chatroom_image_path"]["name"]);
497 $target_file = md5(time() + $pathinfo['basename']) . "." . $pathinfo['extension'];
498
499 move_uploaded_file(
500 $_FILES["chatroom_image_path"]["tmp_name"],
502 );
503
504 ilChatroomSmilies::_storeSmiley(join("\n", $keywords), $target_file);
505
506 $ilCtrl->redirect($this->gui, "smiley");
507 }
static _storeSmiley($keywords, $path)
Stores smiley with given keywords and path in database.

References $_REQUEST, $ilCtrl, $lng, $tpl, ilChatroomSmilies\_getSmiliesBasePath(), ilChatroomSmilies\_prepareKeywords(), ilChatroomSmilies\_storeSmiley(), initSmiliesForm(), ilUtil\stripSlashes(), and view().

+ Here is the call graph for this function:

◆ view()

ilChatroomSmileyTask::view ( )

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

Definition at line 44 of file class.ilChatroomSmileyTask.php.

45 {
46 include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
47
48 ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
49
50 $this->gui->switchToVisibleMode();
51
53
54 $this->editSmiliesObject();
55 }
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:

Field Documentation

◆ $gui

ilChatroomSmileyTask::$gui
private

Definition at line 15 of file class.ilChatroomSmileyTask.php.

Referenced by __construct().


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