30 'smiley_keywords' => array(
34 'smiley_path' => array(
43 $ilDB->createTable(
'chatroom_smilies', $fields );
44 $ilDB->addPrimaryKey(
'chatroom_smilies', array(
'smiley_id') );
45 $ilDB->createSequence(
'chatroom_smilies' );
58 array(
"icon_smile.gif",
":)\n:-)\n:smile:"),
59 array(
"icon_wink.gif",
";)\n;-)\n:wink:"),
60 array(
"icon_laugh.gif",
":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
61 array(
"icon_sad.gif",
":(\n:-(\n:sad:"),
62 array(
"icon_shocked.gif",
":o\n:-o\n:shocked:"),
63 array(
"icon_tongue.gif",
":p\n:-p\n:tongue:"),
64 array(
"icon_cool.gif",
":cool:"),
65 array(
"icon_eek.gif",
":eek:"),
66 array(
"icon_angry.gif",
":||\n:-||\n:angry:"),
67 array(
"icon_flush.gif",
":flush:"),
68 array(
"icon_idea.gif",
":idea:"),
69 array(
"icon_thumbup.gif",
":thumbup:"),
70 array(
"icon_thumbdown.gif",
":thumbdown:"),
73 $stmt = $ilDB->prepare(
" 74 INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path) 76 array(
"integer",
"text",
"text" )
79 foreach( $values as $val )
82 $ilDB->nextID(
"chatroom_smilies" ),
86 $stmt->execute(
$row );
97 if( !is_dir(
$path ) )
99 mkdir(
$path, 0755,
true );
118 self::_setupDatabase();
119 self::_insertDefaultValues();
120 self::_setupFolder();
135 $path = self::_getSmileyDir();
137 if( !is_dir(
$path ) )
142 if( !is_dir(
$path ) )
162 "icon_thumbdown.gif",
165 foreach( $smilies as $smiley )
167 copy(
"templates/default/images/emoticons/$smiley",
$path .
"/$smiley" );
170 self::_insertDefaultValues();
175 if( !is_writable(
$path ) )
193 "SELECT smiley_id, smiley_keywords, smiley_path 194 FROM chatroom_smilies" 198 for( $i = 0; $i <
$res->numRows(); $i++ )
200 $tmp =
$res->fetchRow();
202 "smiley_id" => $tmp[0],
203 "smiley_keywords" => $tmp[1],
204 "smiley_path" => $tmp[2],
223 $res = $ilDB->queryF(
" 224 SELECT smiley_id, smiley_keywords, smiley_path 225 FROM chatroom_smilies 226 WHERE smiley_id = %s ",
227 array(
'integer'), array($a_id)
230 if(
$res->numRows() )
232 $tmp =
$res->fetchRow();
234 "smiley_id" => $tmp[0],
235 "smiley_keywords" => $tmp[1],
236 "smiley_path" => $tmp[2],
241 throw new Exception(
'smiley with id $a_id not found' );
258 $sql =
"SELECT smiley_id, smiley_keywords, smiley_path FROM chatroom_smilies WHERE ";
260 $sql_parts = array();
262 foreach( $ids as $id )
264 $sql_parts[] .=
"smiley_id = " . $ilDB->quote( $id,
"integer" );
267 $sql .= join(
" OR ", $sql_parts );
268 $res = $ilDB->query( $sql );
271 for( $i = 0; $i <
$res->numRows(); $i++ )
273 $tmp =
$res->fetchRow();
275 "smiley_id" => $tmp[0],
276 "smiley_keywords" => $tmp[1],
277 "smiley_path" => $tmp[2],
294 $smilies = self::_getSmiliesById( $ids );
296 if( count( $smilies ) <= 0 )
299 $sql_parts = array();
301 foreach( $smilies as $s )
303 unlink( $s[
"smiley_fullpath"] );
304 $sql_parts[] =
"smiley_id = " . $ilDB->quote( $s[
"smiley_id"],
'integer' );
307 $ilDB->manipulate(
"DELETE FROM chatroom_smilies WHERE " . join(
" OR ", $sql_parts ) );
322 "UPDATE chatroom_smilies 323 SET smiley_keywords = %s 326 array(
'text',
'integer'),
327 array(
$data[
"smiley_keywords"],
$data[
"smiley_id"])
330 if(
$data[
"smiley_path"] )
332 $sm = self::_getSmiley(
$data[
"smiley_id"] );
333 unlink( $sm[
"smiley_fullpath"] );
335 "UPDATE chatroom_smilies 339 array(
'text',
'integer'),
340 array(
$data[
"smiley_path"],
$data[
"smiley_id"])
367 $smiley = self::_getSmiley( $a_id );
370 if( is_file(
$path ) )
374 "DELETE FROM chatroom_smilies 398 $stmt = $ilDB->prepare(
" 399 INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path) 402 "integer",
"text",
"text" 406 $ilDB->nextID(
"chatroom_smilies" ),
410 $stmt->execute(
$row );
421 $keywordscheck =
true;
424 $keywords_unchecked = explode(
"\n", $words );
425 if( count( $keywords_unchecked ) <= 0 )
426 $keywordscheck =
false;
432 foreach( $keywords_unchecked as $word )
435 $keywords[] = trim( $word );
439 if( $keywordscheck && count( $keywords ) <= 0 )
440 $keywordscheck =
false;
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 _getSmilies()
Fetches smilies from database.
static _deleteSmiley($a_id)
Deletes smiliey by given id from database.
static _setupFolder()
Setup directory.
static _insertDefaultValues()
Inserts default smiley set.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static _updateSmiley($data)
Updates smiley in DB by keyword and id from given array ($data["smiley_keywords"], $data["smiley_id"])
static _storeSmiley($keywords, $path)
Stores smiley with given keywords and path in database.
static _getSmiliesBasePath()
Returns smilies basepath.
static _getSmiliesById($ids=array())
Fetches smilies from database by id.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _checkSetup()
Checks if smiley folder is available; if not it will try to create folder and performs actions for an...
static _getSmileyDir()
Path to smilies.
static _initial()
Performs initial setup (db, dirs, default data)
static _getSmiley($a_id)
Looks up and returns smiley with id, throws exception if id is not found.
static _prepareKeywords($words)
Trims given keywords and returns them in one array.
static _setupDatabase()
Creates table and sequence.
static getWebspaceDir($mode="filesystem")
get webspace directory
static _deleteMultipleSmilies($ids=array())
Deletes multiple smilies by given id array.