* @package Wombat */ WBClass::load('WBDatasource' ); /** * Webinar * * @version 0.2.0 * @package Wombat */ class WBWebinar extends WBStdClass { /** * Config parameter * * Loaded from database and key value pairs, usually * @var array */ protected $config = array(); /** * table * @var WBDatasource_Table */ private $table; /** * Current Session Data, If Any * @var array */ private $session = array(); /** * Configuration * @var WBConfig */ private $conf; /** * Constructor * * @param array default parameter */ final public function __construct($parameter = array()) { if (empty($parameter['table'])) { $parameter['table'] = WBClass::create('WBDatasource_Table'); } $this->table = $parameter['table']; $this->conf = WBClass::create('WBConfig'); $this->conf->load('webinar/connector'); } public function isAvailable() { } /** * Initialize Object by Id * * Load session from database * * @see getByName() * @param string id * @return WBWebinar */ public function getById($id) { if ($this->getId() == $id) { return $this; } $data = array(); if (!empty($id)) { $data = $this->table->get(WBDatasource::TABLE_WEBINARMEETING, $id); } if (empty($data)) { return $this; } $data = $data[0]; $this->session = $data; /** @var WBWebinar */ $obj = $this->getByName($data['webinarconfig']); $obj->session['id'] = $id; $obj->setMeetingId($data['meetingidentifier']); $obj->setMeetingMeta($data['meetingmeta']); return $obj; } /** * Initialize Object by Name * * See if config exists, load config, instantiate object, configure and return it * * @param string config name * @return WBWebinar */ final public function getByName($name = '__default') { if ('__default' == $name) { $name = $this->conf->get('connector/default', ''); if (empty($name)) { return $this; } } $config = $this->conf->get('connector/available/' . $name, array()); if (empty($config)) { return $this; } if (empty($config['name'])) { return $this; } $clazz = __CLASS__ . '_' . $config['name']; $param = array( 'table' => $this->table ); /** @var WBWebinar */ $obj = WBClass::create($clazz, $param); $obj->session['id'] = ''; $obj->configure($name, $config); return $obj; } /** * Get Primary Column Name * * @return string */ final public function getIdentifier() { return $this->table->getIdentifier(WBDatasource::TABLE_WEBINARMEETING, true); } /** * Get Current Session's Id * * @return string */ final public function getId() { if (empty($this->session) || empty($this->session['id'])) { return ''; } return $this->session['id']; } /** * Set Meeting Identifier * * @param string id */ final protected function setMeetingId($mid) { $this->session['meetingidentifier'] = trim($mid); } /** * Get Meeting Identifier * * @return string id */ final public function getMeetingId() { return $this->session['meetingidentifier']; } /** * Set Meeting Meta Data * * @param string */ final protected function setMeetingMeta($meta) { $this->session['meetingmeta'] = array(); if (empty($meta)) { return; } // meta is supposed to be a string if (is_string($meta)) { $meta = unserialize($meta); } $this->session['meetingmeta'] = $meta; } /** * Get Meeting Meta Data * * @return array */ final protected function getMeetingMeta() { return $this->session['meetingmeta']; } final public function save() { $save = array( 'webinarconfig' => $this->session['webinarconfig'], 'meetingidentifier' => $this->session['meetingidentifier'], 'meetingmeta' => serialize($this->session['meetingmeta']) ); $id = $this->session['id']; if (empty($id)) { $id = '__new'; } $this->session['id'] = $this->table->save(WBDatasource::TABLE_WEBINARMEETING, $id, $save); } /** * Configure Payment Type * * Set config values, call init() when done * @see init() * @param string config name * @param array config data, usually from database */ final public function configure($name, $config = array()) { $this->session = array(); $this->session['id'] = ''; $this->session['webinarconfig'] = $name; $this->session['meetingidentifier'] = ''; $this->session['meetingmeta'] = ''; $this->config = array_merge($this->config, $config); $this->init(); } /** * Initialize * * Called after configuration */ protected function init() { } /** * Add Or Load Meeting * * @param array */ final public function add($data) { $mid = $this->getMeetingId(); if (!empty($mid)) { $this->loadMeeting(); $mid = $this->getMeetingId(); } if (empty($mid)) { $this->addMeeting($data); $this->save(); } } /** * Get URL to Join the Meeting * * @param string person's name * @param bool is moderator * @return string */ final public function getJoinURL($name = '', $moderator = false) { $mid = $this->getMeetingId(); if (empty($mid)) { return ''; } return $this->getMeetingJoinUrl($name, $moderator); } /** * End Current Meeting * */ final public function end() { $id = $this->getId(); if (empty($id)) { return; } $this->endMeeting(); $this->setMeetingId(''); $this->save(); } /** * Get Recordings of Meeting * * @return array list */ final public function getRecordings() { $id = $this->getId(); if (empty($id)) { return array(); } return $this->getMeetingRecorings(); } /** * Create Meeting * * @param array */ protected function addMeeting($data) { } /** * Load Meeting * */ protected function loadMeeting() { } /** * Get Meeting's Join URL for Moderator or Attendee * * @param string person's name * @param bool is moderator */ protected function getMeetingJoinUrl($name = '', $moderator = false) { } /** * End Meeting * */ protected function endMeeting() { } /** * Get Recordings of Meeting - Implementation * * @return array list */ protected function getMeetingRecorings() { return array(); } }