mode == "room" ) { $this->krihvel->out("head", ''); } } public function addCSS() { $this->krihvel->out("head", ''); } /** * @Secured('roles' = {'manager', 'schooladm', 'member'}, 'valid' = {}) * */ public function actionCreate() { global $kdb; $sql = "INSERT INTO chatrooms (title, topic) VALUES ('".$_POST['ctit']."', '".$_POST['ctop']."')"; $kdb->query($sql); return array('pid' => 'Chat'); } /** * @Secured('roles' = {'authenticated'}, 'valid' = {}) * */ public function actionCancel(){ return array('pid' => 'Chat'); } /** * @Secured('roles' = {'manager', 'schooladm'}, 'valid' = {}) * */ public function actionDelete() { if ( isset($_POST['chatroomid']) && is_numeric($_POST['chatroomid']) ) { global $kdb; $sql = "DELETE FROM chatrooms WHERE ChatroomID=".$_POST['chatroomid']; $kdb->query($sql); } return array('pid' => 'Chat'); } public function getChatrooms() { global $kdb; $sql = "SELECT * FROM chatrooms"; $ret = $kdb->query($sql); $res = array(); while ( ($row = mysql_fetch_array($ret) ) ) { $res[] = $row; } return $res; } public function getRoomID() { return isset($_GET['chatroom']) ? $_GET['chatroom'] : "0"; } public function getRoomName() { if ( isset($_GET['chatroom']) && is_numeric($_GET['chatroom']) ) { global $kdb; $sql = "SELECT title FROM chatrooms WHERE ChatroomID = ".$_GET['chatroom']; $ret = $kdb->query($sql); $topic = mysql_fetch_array($ret); return $topic[0]; } return "..."; } public function getRoomTopic() { if ( isset($_GET['chatroom']) && is_numeric($_GET['chatroom']) ) { global $kdb; $sql = "SELECT topic FROM chatrooms WHERE ChatroomID = ".$_GET['chatroom']; $ret = $kdb->query($sql); $title = mysql_fetch_array($ret); return $title[0]; } return "..."; } public function getNumberOfUsers($chid) { global $kdb; $sql = "SELECT COUNT(uid) FROM chatusers where logout='000-00-00 00:00:00' AND roomid=".$chid; $ret = $kdb->query($sql); $sum = mysql_fetch_array($ret); return $sum[0]; } } ?>