ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 {} 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"] ilRbacSystem $rbacsystem ilCtrl $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 ($withBaseDir=true)
 

Protected Member Functions

 getSmileyFormDataById ($smileyId)
 
- 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

 $form_gui
 
- Protected Attributes inherited from ilChatroomGUIHandler
 $gui
 
 $ilUser
 
 $ilCtrl
 
 $ilLng
 
 $webDirectory
 
 $upload
 

Static Private Member Functions

static _insertDefaultValues ()
 

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 44 of file class.ilChatroomAdminSmileyGUI.php.

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

45  {
46  global $lng;
47 
48  $path = self::_getSmileyDir();
49 
50  if (!is_dir($path)) {
51  ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_exists'));
53 
54  if (!is_dir($path)) {
55  ilUtil::sendFailure($lng->txt('chat_smilies_dir_not_available'));
56  return false;
57  } else {
58  $smilies = array(
59  "icon_smile.gif",
60  "icon_wink.gif",
61  "icon_laugh.gif",
62  "icon_sad.gif",
63  "icon_shocked.gif",
64  "icon_tongue.gif",
65  "icon_cool.gif",
66  "icon_eek.gif",
67  "icon_angry.gif",
68  "icon_flush.gif",
69  "icon_idea.gif",
70  "icon_thumbup.gif",
71  "icon_thumbdown.gif",
72  );
73 
74  foreach ($smilies as $smiley) {
75  copy("templates/default/images/emoticons/$smiley", $path . "/$smiley");
76  }
77 
78  self::_insertDefaultValues();
79 
80  ilUtil::sendSuccess($lng->txt('chat_smilies_initialized'));
81  }
82  }
83 
84  if (!is_writable($path)) {
85  ilUtil::sendInfo($lng->txt('chat_smilies_dir_not_writable'));
86  }
87 
88  return true;
89  }
static sendSuccess($a_info="", $a_keep=false)
Send Success 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.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ _getSmileyDir()

static ilChatroomAdminSmileyGUI::_getSmileyDir (   $withBaseDir = true)
static
Parameters
bool$withBaseDir
Returns
string

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

References $path, and ilUtil\getWebspaceDir().

96  {
97  $path = 'chatroom/smilies';
98 
99  if ($withBaseDir) {
100  $path = ilUtil::getWebspaceDir() . '/' . $path;
101  }
102 
103  return $path;
104  }
static getWebspaceDir($mode="filesystem")
get webspace directory
+ Here is the call graph for this function:

◆ _insertDefaultValues()

static ilChatroomAdminSmileyGUI::_insertDefaultValues ( )
staticprivate

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

References array.

107  {
108  $values = array(
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:"),
122  );
123 
124  require_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
125  foreach ($values as $val) {
126  ilChatroomSmilies::_storeSmiley($val[1], $val[0]);
127  }
128  }
Create styles array
The data for the language used.

◆ deleteSmileyObject()

ilChatroomAdminSmileyGUI::deleteSmileyObject ( )

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

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

References $_POST, $data, ilChatroomGUIHandler\$ilCtrl, $lng, $result, $s, $tpl, ilChatroomSmilies\_deleteMultipleSmilies(), ilChatroomSmilies\_prepareKeywords(), array, getSmileyFormDataById(), ilChatroomSmilies\getSmiliesBasePath(), ilUtil\img(), initSmiliesEditForm(), initSmiliesForm(), ILIAS\FileUpload\DTO\ProcessingStatus\OK, ilUtil\sendFailure(), ilUtil\sendInfo(), ilUtil\sendSuccess(), showEditSmileyEntryFormObject(), ilUtil\stripSlashes(), time, and view().

395  {
396  global $rbacsystem, $ilCtrl, $lng;
397 
398  if (!$rbacsystem->checkAccess('write', $this->gui->ref_id)) {
399  $this->ilias->raiseError(
400  $lng->txt('msg_no_perm_write'),
401  $this->ilias->error_obj->MESSAGE
402  );
403  }
404 
405  include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
406 
407  ilChatroomSmilies::_deleteSmiley($_REQUEST["chatroom_smiley_id"]);
408 
409  $ilCtrl->redirect($this->gui, "smiley");
410  }
redirection script todo: (a better solution should control the processing via a xml file) ...
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ editSmiliesObject()

ilChatroomAdminSmileyGUI::editSmiliesObject ( )

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

ilRbacSystem $rbacsystem ilLanguage $lng ilTemplate $tpl

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

References $form, $form_gui, $lng, $table, $tpl, ilChatroomSmilies\_checkSetup(), ilChatroomSmiliesGUI\_getExistingSmiliesTable(), and initSmiliesForm().

Referenced by view().

138  {
139  global $rbacsystem, $lng, $tpl;
140 
141  if (!$rbacsystem->checkAccess('read', $this->gui->ref_id)) {
142  $this->ilias->raiseError(
143  $lng->txt('msg_no_perm_read'),
144  $this->gui->ilias->error_obj->MESSAGE
145  );
146  }
147 
148  include_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
149 
151 
152  if (!$this->form_gui) {
153  $form = $this->initSmiliesForm();
154  } else {
156  }
157 
158  include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesGUI.php";
159 
161 
162  $tpl_smilies = new ilTemplate(
163  "tpl.chatroom_edit_smilies.html",
164  true,
165  true,
166  "Modules/Chatroom"
167  );
168  $tpl_smilies->setVariable("SMILEY_TABLE", $table);
169  $tpl_smilies->setVariable("SMILEY_FORM", $form->getHtml());
170 
171  $tpl->setContent($tpl_smilies->get());
172  }
static _getExistingSmiliesTable($a_ref)
Constructor public.
$tpl
Definition: ilias.php:10
initSmiliesForm()
Initializes smilies form and returns it.
if(isset($_POST['submit'])) $form
special template class to simplify handling of ITX/PEAR
redirection script todo: (a better solution should control the processing via a xml file) ...
static _checkSetup()
Checks if smiley folder is available; if not it will try to create folder and performs actions for an...
global $lng
Definition: privfeed.php:17
if(empty($password)) $table
Definition: pwgen.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeDefault()

ilChatroomAdminSmileyGUI::executeDefault (   $requestedMethod)

{}

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

References view().

23  {
24  $this->view();
25  }
view()
Switches GUI to visible mode and calls editSmiliesObject method which prepares and displays the table...
+ Here is the call graph for this function:

◆ getSmileyFormDataById()

ilChatroomAdminSmileyGUI::getSmileyFormDataById (   $smileyId)
protected
Parameters
$smileyId
Returns
array
Exceptions

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

References array.

Referenced by deleteSmileyObject(), and showEditSmileyEntryFormObject().

268  {
269  require_once 'Modules/Chatroom/classes/class.ilChatroomSmilies.php';
270  $smiley = ilChatroomSmilies::_getSmiley($smileyId);
271 
272  $form_data = array(
273  'chatroom_smiley_id' => $smiley['smiley_id'],
274  'chatroom_smiley_keywords' => $smiley['smiley_keywords'],
275  'chatroom_current_smiley_image_path' => $smiley['smiley_fullpath'],
276  );
277 
278  return $form_data;
279  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ initSmiliesEditForm()

ilChatroomAdminSmileyGUI::initSmiliesEditForm (   $form_data)

Initializes SmiliesEditForm and returns it.

ilCtrl2 $ilCtrl ilLanguage $lng

Returns
ilPropertyFormGUI

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

References $form_gui, ilChatroomGUIHandler\$ilCtrl, $lng, $tpl, array, ilUtil\img(), ilFileInputGUI\setSuffixes(), ilChatroomSmiliesCurrentSmileyFormElement\setValue(), and ilTextAreaInputGUI\setValue().

Referenced by deleteSmileyObject(), and showEditSmileyEntryFormObject().

288  {
289  global $ilCtrl, $lng;
290 
291  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
292 
293  $this->form_gui = new ilPropertyFormGUI();
294 
295  $this->form_gui->setValuesByArray($form_data);
296 
297  $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
298 
299  $ilCtrl->saveParameter($this->gui, 'smiley_id');
300 
301  $this->form_gui->setFormAction(
302  $ilCtrl->getFormAction($this->gui, 'smiley-updateSmiliesObject') . $table_nav
303  );
304 
305  $sec_l = new ilFormSectionHeaderGUI();
306 
307  $sec_l->setTitle($lng->txt('chatroom_edit_smiley'));
308  $this->form_gui->addItem($sec_l);
309 
310  include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesCurrentSmileyFormElement.php";
311 
313  $lng->txt('chatroom_current_smiley_image_path'),
314  'chatroom_current_smiley_image_path'
315  );
316 
317  $inp->setValue($form_data['chatroom_current_smiley_image_path']);
318  $this->form_gui->addItem($inp);
319 
320  $inp = new ilImageFileInputGUI(
321  $lng->txt('chatroom_image_path'),
322  'chatroom_image_path'
323  );
324  $inp->setSuffixes(array("jpg", "jpeg", "png", "gif", "svg"));
325 
326  $inp->setRequired(false);
327  $inp->setInfo($lng->txt('chatroom_smiley_image_only_if_changed'));
328  $this->form_gui->addItem($inp);
329 
330  $inp = new ilTextAreaInputGUI(
331  $lng->txt('chatroom_smiley_keywords'),
332  'chatroom_smiley_keywords'
333  );
334 
335  $inp->setValue($form_data['chatroom_smiley_keywords']);
336  $inp->setUseRte(false);
337  $inp->setRequired(true);
338  $inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
339  $this->form_gui->addItem($inp);
340 
341  $inp = new ilHiddenInputGUI('chatroom_smiley_id');
342 
343  $this->form_gui->addItem($inp);
344  $this->form_gui->addCommandButton(
345  'smiley-updateSmiliesObject',
346  $lng->txt('submit')
347  );
348  $this->form_gui->addCommandButton('smiley', $lng->txt('cancel'));
349  return $this->form_gui;
350  }
This class represents a property form user interface.
This class represents a section header in a property form.
setValue($a_value)
Set Value.
setValue($a_value)
Sets given value as $this->value in ilChatroomSmiliesCurrentSmileyFormElement.
This class represents a hidden form property in a property form.
Class ilChatroomSmiliesCurrentSmileyFormElement Class ilchatroomSmiliesCurrentSmileyFormElement simpl...
Create styles array
The data for the language used.
This class represents an image file property in a property form.
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSmiliesForm()

ilChatroomAdminSmileyGUI::initSmiliesForm ( )

Initializes smilies form and returns it.

ilCtrl2 $ilCtrl ilLanguage $lng

Returns
ilPropertyFormGUI

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

References $form_gui, ilChatroomGUIHandler\$ilCtrl, $lng, array, ilFormPropertyGUI\setRequired(), and ilFileInputGUI\setSuffixes().

Referenced by deleteSmileyObject(), and editSmiliesObject().

181  {
182  global $ilCtrl, $lng;
183 
184  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
185 
186  $this->form_gui = new ilPropertyFormGUI();
187 
188  $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
189  $this->form_gui->setFormAction(
190  $ilCtrl->getFormAction($this->gui, 'smiley-uploadSmileyObject') . $table_nav
191  );
192 
193  // chat server settings
194  $sec_l = new ilFormSectionHeaderGUI();
195 
196  $sec_l->setTitle($lng->txt('chatroom_add_smiley'));
197  $this->form_gui->addItem($sec_l);
198 
199  $inp = new ilImageFileInputGUI(
200  $lng->txt('chatroom_image_path'),
201  'chatroom_image_path'
202  );
203  $inp->setSuffixes(array("jpg", "jpeg", "png", "gif", "svg"));
204 
205  $inp->setRequired(true);
206  $this->form_gui->addItem($inp);
207 
208  $inp = new ilTextAreaInputGUI(
209  $lng->txt('chatroom_smiley_keywords'),
210  'chatroom_smiley_keywords'
211  );
212 
213  $inp->setRequired(true);
214  $inp->setUseRte(false);
215  $inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
216  $this->form_gui->addItem($inp);
217  $this->form_gui->addCommandButton(
218  'smiley-uploadSmileyObject',
219  $lng->txt('chatroom_upload_smiley')
220  );
221 
222  return $this->form_gui;
223  }
This class represents a property form user interface.
This class represents a section header in a property form.
Create styles array
The data for the language used.
This class represents an image file property in a property form.
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showEditSmileyEntryFormObject()

ilChatroomAdminSmileyGUI::showEditSmileyEntryFormObject ( )

Shows EditSmileyEntryForm Prepares EditSmileyEntryForm and displays it.

ilRbacSystem $rbacsystem ilTemplate $tpl

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

References $form, $form_gui, $lng, $tpl, getSmileyFormDataById(), and initSmiliesEditForm().

Referenced by deleteSmileyObject().

232  {
233  global $rbacsystem, $tpl, $lng;
234 
235  $this->gui->switchToVisibleMode();
236 
237  if (!$rbacsystem->checkAccess('read', $this->gui->ref_id)) {
238  $this->ilias->raiseError(
239  $lng->txt('msg_no_perm_read'),
240  $this->ilias->error_obj->MESSAGE
241  );
242  }
243 
244  if (!$this->form_gui) {
245  $form = $this->initSmiliesEditForm($this->getSmileyFormDataById((int) $_REQUEST['smiley_id']));
246  } else {
248  }
249 
250  $tpl_form = new ilTemplate(
251  "tpl.chatroom_edit_smilies.html",
252  true,
253  true,
254  "Modules/Chatroom"
255  );
256 
257  $tpl_form->setVariable("SMILEY_FORM", $form->getHTML());
258 
259  $tpl->setContent($tpl_form->get());
260  }
$tpl
Definition: ilias.php:10
initSmiliesEditForm($form_data)
Initializes SmiliesEditForm and returns it.
if(isset($_POST['submit'])) $form
special template class to simplify handling of ITX/PEAR
redirection script todo: (a better solution should control the processing via a xml file) ...
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller 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 31 of file class.ilChatroomAdminSmileyGUI.php.

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

Referenced by deleteSmileyObject(), and executeDefault().

32  {
33  include_once 'Modules/Chatroom/classes/class.ilChatroom.php';
34 
35  ilChatroom::checkUserPermissions('read', $this->gui->ref_id);
36 
37  $this->gui->switchToVisibleMode();
38 
39  self::_checkSetup();
40 
41  $this->editSmiliesObject();
42  }
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
editSmiliesObject()
Shows existing smilies table Prepares existing smilies table and displays it.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $form_gui

ilChatroomAdminSmileyGUI::$form_gui
protected

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