ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomSmilies Class Reference

Class ilChatroomSmilies. More...

+ Collaboration diagram for ilChatroomSmilies:

Static Public Member Functions

static _getSmileyDir ()
 Path to smilies.
static _initial ()
 Performs initial setup (db, dirs, default data)
static _checkSetup ()
 Checks if smiley folder is available; if not it will try to create folder and performs actions for an initial smiley set.
static _getSmilies ()
 Fetches smilies from database.
static _getSmiley ($a_id)
 Looks up and returns smiley with id, throws exception if id is not found.
static _getSmiliesById ($ids=array())
 Fetches smilies from database by id.
static _deleteMultipleSmilies ($ids=array())
 Deletes multiple smilies by given id array.
static _updateSmiley ($data)
 Updates smiley in DB by keyword and id from given array ($data["smiley_keywords"], $data["smiley_id"])
static _getSmiliesBasePath ()
 Returns smilies basepath.
static _deleteSmiley ($a_id)
 Deletes smiliey by given id from database.
static _storeSmiley ($keywords, $path)
 Stores smiley with given keywords and path in database.
static _prepareKeywords ($words)
 Trims given keywords and returns them in one array.

Static Private Member Functions

static _setupDatabase ()
 Creates table and sequence.
static _insertDefaultValues ()
 Inserts default smiley set.
static _setupFolder ()
 Setup directory.

Detailed Description

Class ilChatroomSmilies.

Author
Jan Posselt jposs.nosp@m.elt@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilChatroomSmilies.php.

Member Function Documentation

static ilChatroomSmilies::_checkSetup ( )
static

Checks if smiley folder is available; if not it will try to create folder and performs actions for an initial smiley set.

ilLanguage $lng

Returns
boolean

Definition at line 131 of file class.ilChatroomSmilies.php.

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

{
global $lng;
if( !is_dir( $path ) )
{
ilUtil::sendInfo( $lng->txt( 'chatroom_smilies_dir_not_exists' ) );
if( !is_dir( $path ) )
{
ilUtil::sendFailure( $lng->txt( 'chatroom_smilies_dir_not_available' ) );
return false;
}
else
{
$smilies = array(
"icon_smile.gif",
"icon_wink.gif",
"icon_laugh.gif",
"icon_sad.gif",
"icon_shocked.gif",
"icon_tongue.gif",
"icon_cool.gif",
"icon_eek.gif",
"icon_angry.gif",
"icon_flush.gif",
"icon_idea.gif",
"icon_thumbup.gif",
"icon_thumbdown.gif",
);
foreach( $smilies as $smiley )
{
copy( "templates/default/images/emoticons/$smiley", $path . "/$smiley" );
}
ilUtil::sendSuccess( $lng->txt( 'chatroom_smilies_initialized' ) );
}
}
if( !is_writable( $path ) )
{
ilUtil::sendInfo( $lng->txt( 'chatroom_smilies_dir_not_writable' ) );
}
return true;
}

+ Here is the call graph for this function:

static ilChatroomSmilies::_deleteMultipleSmilies (   $ids = array())
static

Deletes multiple smilies by given id array.

ilDBMySQL $ilDB

Parameters
array$ids

Definition at line 290 of file class.ilChatroomSmilies.php.

References _getSmiliesById().

Referenced by ilChatroomSmileyTask\confirmedDeleteMultipleObject().

{
global $ilDB;
$smilies = self::_getSmiliesById( $ids );
if( count( $smilies ) <= 0 )
return;
$sql_parts = array();
foreach( $smilies as $s )
{
unlink( $s["smiley_fullpath"] );
$sql_parts[] = "smiley_id = " . $ilDB->quote( $s["smiley_id"], 'integer' );
}
$ilDB->manipulate( "DELETE FROM chatroom_smilies WHERE " . join( " OR ", $sql_parts ) );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_deleteSmiley (   $a_id)
static

Deletes smiliey by given id from database.

ilDBMySQL $ilDB

Parameters
integer$a_id

Definition at line 361 of file class.ilChatroomSmilies.php.

References $path, _getSmiley(), and ilUtil\getWebspaceDir().

Referenced by ilChatroomSmileyTask\deleteSmileyObject().

{
global $ilDB;
try
{
$smiley = self::_getSmiley( $a_id );
$path = ilUtil::getWebspaceDir() . '/chatroom/smilies/' . $smiley["smiley_path"];
if( is_file( $path ) )
unlink( $path );
$ilDB->manipulateF(
"DELETE FROM chatroom_smilies
WHERE
smiley_id = %s",
array('integer'),
array($a_id)
);
}
catch(Exception $e)
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_getSmiley (   $a_id)
static

Looks up and returns smiley with id, throws exception if id is not found.

ilDBMySQL $ilDB

Parameters
integer$a_id
Returns
string

Definition at line 219 of file class.ilChatroomSmilies.php.

References $res, $result, and ilUtil\getWebspaceDir().

Referenced by _deleteSmiley(), _updateSmiley(), ilChatroomSmileyTask\showDeleteSmileyFormObject(), and ilChatroomSmileyTask\showEditSmileyEntryFormObject().

{
global $ilDB;
$res = $ilDB->queryF( "
SELECT smiley_id, smiley_keywords, smiley_path
FROM chatroom_smilies
WHERE smiley_id = %s ",
array('integer'), array($a_id)
);
if( $res->numRows() )
{
$tmp = $res->fetchRow();
$result = array(
"smiley_id" => $tmp[0],
"smiley_keywords" => $tmp[1],
"smiley_path" => $tmp[2],
"smiley_fullpath" => ilUtil::getWebspaceDir() . '/chatroom/smilies/' . $tmp[2]
);
return $result;
}
throw new Exception( 'smiley with id $a_id not found' );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_getSmileyDir ( )
static

Path to smilies.

Returns
string

Definition at line 108 of file class.ilChatroomSmilies.php.

References ilUtil\getWebspaceDir().

Referenced by _checkSetup().

{
return ilUtil::getWebspaceDir() . '/chatroom/smilies';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_getSmilies ( )
static

Fetches smilies from database.

Returns
array

Definition at line 188 of file class.ilChatroomSmilies.php.

References $res, $result, and ilUtil\getWebspaceDir().

Referenced by ilChatroomSmiliesGUI\_getExistingSmiliesTable(), and ilChatroomInitialTask\executeDefault().

{
global $ilDB;
$res = $ilDB->query(
"SELECT smiley_id, smiley_keywords, smiley_path
FROM chatroom_smilies"
);
$result = array();
for( $i = 0; $i < $res->numRows(); $i++ )
{
$tmp = $res->fetchRow();
$result[] = array(
"smiley_id" => $tmp[0],
"smiley_keywords" => $tmp[1],
"smiley_path" => $tmp[2],
"smiley_fullpath" => ilUtil::getWebspaceDir() . '/chatroom/smilies/' . $tmp[2]
);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_getSmiliesBasePath ( )
static

Returns smilies basepath.

Returns
string

Definition at line 350 of file class.ilChatroomSmilies.php.

References ilUtil\getWebspaceDir().

Referenced by ilChatroomSmileyTask\updateSmiliesObject(), and ilChatroomSmileyTask\uploadSmileyObject().

{
return ilUtil::getWebspaceDir() . '/chatroom/smilies/';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_getSmiliesById (   $ids = array())
static

Fetches smilies from database by id.

ilDBMySQL $ilDB

Parameters
array$ids
Returns
array

Definition at line 251 of file class.ilChatroomSmilies.php.

References $res, $result, and ilUtil\getWebspaceDir().

Referenced by _deleteMultipleSmilies(), and ilChatroomSmileyTask\deleteMultipleObject().

{
global $ilDB;
if( !count( $ids ) )
return;
$sql = "SELECT smiley_id, smiley_keywords, smiley_path FROM chatroom_smilies WHERE ";
$sql_parts = array();
foreach( $ids as $id )
{
$sql_parts[] .= "smiley_id = " . $ilDB->quote( $id, "integer" );
}
$sql .= join( " OR ", $sql_parts );
$res = $ilDB->query( $sql );
$result = array();
for( $i = 0; $i < $res->numRows(); $i++ )
{
$tmp = $res->fetchRow();
$result[] = array(
"smiley_id" => $tmp[0],
"smiley_keywords" => $tmp[1],
"smiley_path" => $tmp[2],
"smiley_fullpath" => ilUtil::getWebspaceDir() . '/chatroom/smilies/' . $tmp[2]
);
}
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_initial ( )
static

Performs initial setup (db, dirs, default data)

Definition at line 116 of file class.ilChatroomSmilies.php.

References _insertDefaultValues(), _setupDatabase(), and _setupFolder().

+ Here is the call graph for this function:

static ilChatroomSmilies::_insertDefaultValues ( )
staticprivate

Inserts default smiley set.

ilDBMySQL $ilDB

Definition at line 53 of file class.ilChatroomSmilies.php.

References $row.

Referenced by _checkSetup(), and _initial().

{
global $ilDB;
$values = array(
array("icon_smile.gif", ":)\n:-)\n:smile:"),
array("icon_wink.gif", ";)\n;-)\n:wink:"),
array("icon_laugh.gif", ":D\n:-D\n:laugh:\n:grin:\n:biggrin:"),
array("icon_sad.gif", ":(\n:-(\n:sad:"),
array("icon_shocked.gif", ":o\n:-o\n:shocked:"),
array("icon_tongue.gif", ":p\n:-p\n:tongue:"),
array("icon_cool.gif", ":cool:"),
array("icon_eek.gif", ":eek:"),
array("icon_angry.gif", ":||\n:-||\n:angry:"),
array("icon_flush.gif", ":flush:"),
array("icon_idea.gif", ":idea:"),
array("icon_thumbup.gif", ":thumbup:"),
array("icon_thumbdown.gif", ":thumbdown:"),
);
$stmt = $ilDB->prepare("
INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path)
VALUES (?, ?, ?)",
array( "integer", "text", "text" )
);
foreach( $values as $val )
{
$row = array(
$ilDB->nextID( "chatroom_smilies" ),
$val[1],
$val[0]
);
$stmt->execute( $row );
}
}

+ Here is the caller graph for this function:

static ilChatroomSmilies::_prepareKeywords (   $words)
static

Trims given keywords and returns them in one array.

Parameters
string$words
Returns
array

Definition at line 419 of file class.ilChatroomSmilies.php.

Referenced by ilChatroomSmileyTask\updateSmiliesObject(), and ilChatroomSmileyTask\uploadSmileyObject().

{
$keywordscheck = true;
// check keywords
$keywords_unchecked = explode( "\n", $words );
if( count( $keywords_unchecked ) <= 0 )
$keywordscheck = false;
if( $keywordscheck )
{
$keywords = array();
foreach( $keywords_unchecked as $word )
{
if( trim( $word ) )
$keywords[] = trim( $word );
}
}
if( $keywordscheck && count( $keywords ) <= 0 )
$keywordscheck = false;
if( $keywordscheck )
return $keywords;
else
return array();
}

+ Here is the caller graph for this function:

static ilChatroomSmilies::_setupDatabase ( )
staticprivate

Creates table and sequence.

ilDBMySQL $ilDB

Definition at line 21 of file class.ilChatroomSmilies.php.

Referenced by _initial().

{
global $ilDB;
$fields = array(
'smiley_id' => array(
'type' => 'integer',
'length' => 4,
),
'smiley_keywords' => array(
'type' => 'text',
'length' => 100,
),
'smiley_path' => array(
'type' => 'text',
'length' => 200,
)
);
//$ilDB->dropTable( "chatroom_smilies" );
//$ilDB->dropTable( "chatroom_smilies_seq" );
$ilDB->createTable( 'chatroom_smilies', $fields );
$ilDB->addPrimaryKey( 'chatroom_smilies', array('smiley_id') );
$ilDB->createSequence( 'chatroom_smilies' );
}

+ Here is the caller graph for this function:

static ilChatroomSmilies::_setupFolder ( )
staticprivate

Setup directory.

Definition at line 93 of file class.ilChatroomSmilies.php.

References $path, and ilUtil\getWebspaceDir().

Referenced by _initial().

{
$path = ilUtil::getWebspaceDir() . '/chatroom/smilies';
if( !is_dir( $path ) )
{
mkdir( $path, 0755, true );
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilChatroomSmilies::_storeSmiley (   $keywords,
  $path 
)
static

Stores smiley with given keywords and path in database.

ilDBMySQL $ilDB

Parameters
array$keywords
string$path

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

References $path, and $row.

Referenced by ilChatroomSmileyTask\uploadSmileyObject().

{
global $ilDB;
$stmt = $ilDB->prepare( "
INSERT INTO chatroom_smilies (smiley_id, smiley_keywords, smiley_path)
VALUES (?, ?, ?)",
array(
"integer", "text", "text"
)
);
$row = array(
$ilDB->nextID( "chatroom_smilies" ),
$keywords,
);
$stmt->execute( $row );
}

+ Here is the caller graph for this function:

static ilChatroomSmilies::_updateSmiley (   $data)
static

Updates smiley in DB by keyword and id from given array ($data["smiley_keywords"], $data["smiley_id"])

ilDBMySQL $ilDB

Parameters
array$data

Definition at line 317 of file class.ilChatroomSmilies.php.

References _getSmiley().

Referenced by ilChatroomSmileyTask\updateSmiliesObject().

{
global $ilDB;
$ilDB->manipulateF(
"UPDATE chatroom_smilies
SET smiley_keywords = %s
WHERE
smiley_id = %s",
array('text', 'integer'),
array($data["smiley_keywords"], $data["smiley_id"])
);
if( $data["smiley_path"] )
{
$sm = self::_getSmiley( $data["smiley_id"] );
unlink( $sm["smiley_fullpath"] );
$ilDB->manipulateF(
"UPDATE chatroom_smilies
SET smiley_path = %s
WHERE
smiley_id = %s",
array('text', 'integer'),
array($data["smiley_path"], $data["smiley_id"])
);
}
}

+ 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: