15 private static function _insertDefaultValues()
20 $ilDB = $DIC->database();
23 array(
"icon_smile.gif",
":)\n:-)\n:smile:"),
24 array(
"icon_wink.gif",
";)\n;-)\n:wink:"),
25 array(
"icon_laugh.gif",
":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
26 array(
"icon_sad.gif",
":(\n:-(\n:sad:"),
27 array(
"icon_shocked.gif",
":o\n:-o\n:shocked:"),
28 array(
"icon_tongue.gif",
":p\n:-p\n:tongue:"),
29 array(
"icon_cool.gif",
":cool:"),
30 array(
"icon_eek.gif",
":eek:"),
31 array(
"icon_angry.gif",
":||\n:-||\n:angry:"),
32 array(
"icon_flush.gif",
":flush:"),
33 array(
"icon_idea.gif",
":idea:"),
34 array(
"icon_thumbup.gif",
":thumbup:"),
35 array(
"icon_thumbdown.gif",
":thumbdown:"),
40 INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path) 42 array(
"integer",
"text",
"text")
47 $ilDB->nextId(
"chatroom_smilies"),
61 public static function _checkSetup()
66 $lng = $DIC->language();
68 $path = self::_getSmileyDir();
94 foreach ($smilies as $smiley) {
95 copy(
"templates/default/images/emoticons/$smiley",
$path .
"/$smiley");
98 self::_insertDefaultValues();
99 ilUtil::sendSuccess(
$lng->txt(
'chatroom_smilies_initialized'));
103 if (!is_writable(
$path)) {
123 public static function _getSmilies()
128 $ilDB = $DIC->database();
130 $res =
$ilDB->query(
"SELECT smiley_id, smiley_keywords, smiley_path FROM chatroom_smilies");
135 "smiley_id" =>
$row[
'smiley_id'],
136 "smiley_keywords" =>
$row[
'smiley_keywords'],
137 "smiley_path" =>
$row[
'smiley_path'],
150 public static function _deleteMultipleSmilies($ids = array())
155 $ilDB = $DIC->database();
157 $smilies = self::_getSmiliesById($ids);
159 if (count($smilies) <= 0) {
163 $sql_parts = array();
165 foreach ($smilies as
$s) {
166 unlink($s[
"smiley_fullpath"]);
167 $sql_parts[] =
"smiley_id = " .
$ilDB->quote($s[
"smiley_id"],
'integer');
170 $ilDB->manipulate(
"DELETE FROM chatroom_smilies WHERE " . implode(
" OR ", $sql_parts));
178 public static function _getSmiliesById($ids = array())
183 $ilDB = $DIC->database();
189 $sql =
"SELECT smiley_id, smiley_keywords, smiley_path FROM chatroom_smilies WHERE ";
191 $sql_parts = array();
193 foreach ($ids as
$id) {
194 $sql_parts[] .=
"smiley_id = " .
$ilDB->quote($id,
"integer");
197 $sql .= join(
" OR ", $sql_parts);
203 "smiley_id" =>
$row[
'smiley_id'],
204 "smiley_keywords" =>
$row[
'smiley_keywords'],
205 "smiley_path" =>
$row[
'smiley_path'],
218 public static function _updateSmiley(
$data)
223 $ilDB = $DIC->database();
226 "UPDATE chatroom_smilies 227 SET smiley_keywords = %s 230 array(
'text',
'integer'),
231 array(
$data[
"smiley_keywords"],
$data[
"smiley_id"])
234 if (
$data[
"smiley_path"]) {
235 $sm = self::_getSmiley(
$data[
"smiley_id"]);
236 unlink($sm[
"smiley_fullpath"]);
238 "UPDATE chatroom_smilies 242 array(
'text',
'integer'),
243 array(
$data[
"smiley_path"],
$data[
"smiley_id"])
255 public static function _getSmiley($a_id)
260 $ilDB = $DIC->database();
264 SELECT smiley_id, smiley_keywords, smiley_path 265 FROM chatroom_smilies 266 WHERE smiley_id = %s ",
274 "smiley_id" =>
$row[
'smiley_id'],
275 "smiley_keywords" =>
$row[
'smiley_keywords'],
276 "smiley_path" =>
$row[
'smiley_path'],
282 throw new Exception(
'smiley with id $a_id not found');
291 return 'chatroom/smilies';
298 public static function _deleteSmiley($a_id)
303 $ilDB = $DIC->database();
306 $smiley = self::_getSmiley($a_id);
309 if (is_file(
$path)) {
314 "DELETE FROM chatroom_smilies 329 public static function _storeSmiley($keywords,
$path)
334 $ilDB = $DIC->database();
338 INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path) 341 "integer",
"text",
"text" 345 $ilDB->nextId(
"chatroom_smilies"),
359 $keywordscheck =
true;
362 $keywords_unchecked = explode(
"\n", $words);
363 if (count($keywords_unchecked) <= 0) {
364 $keywordscheck =
false;
367 if ($keywordscheck) {
370 foreach ($keywords_unchecked as $word) {
372 $keywords[] = trim($word);
377 if ($keywordscheck && count($keywords) <= 0) {
378 $keywordscheck =
false;
381 if ($keywordscheck) {
static makeDirParents($a_dir)
Create a new directory and all parent directories.
if(!array_key_exists('StateId', $_REQUEST)) $id
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
foreach($_POST as $key=> $value) $res
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _getSmileyDir()
Path to smilies.
static getSmiliesBasePath()
Returns smilies basepath.
static _prepareKeywords($words)
Trims given keywords and returns them in one array.
static getWebspaceDir($mode="filesystem")
get webspace directory