/** * get the layout for comments * * This function adapts the layout of comments to the internal state of the overlay. * * @see articles/view_as_chat.php */ function get_comments_layout_value($default_value) { global $context; switch ($this->attributes['status']) { case 'created': case 'open': case 'lobby': return 'yabb'; case 'started': // no specific rule for enrolment if (!isset($this->attributes['enrolment'])) { return 'chat'; } // chat is opened to any visitor --confirm participation of surfer if ($this->attributes['enrolment'] == 'none') { if (!$this->has_joined()) { $this->join_meeting(); } return 'chat'; } // surfer has not applied if (!($enrolment = enrolments::get_record($this->anchor->get_reference()))) { return 'excluded'; } // registration has not been approved if (!isset($enrolment['approved']) || $enrolment['approved'] != 'Y') { return 'excluded'; } // surfer is allowed to participate to restricted chat if (!$this->has_joined()) { $this->join_meeting(); } return 'chat'; case 'stopped': return 'excerpt'; default: return $default_value; } }
/** * remember that surfer is enrolled in a meeting * * @param string reference of the target page */ public static function confirm($reference) { global $context; // sanity check if (!$reference) { return; } // ensure that the joiner has been enrolled... if (!($item = enrolments::get_record($reference))) { if (Surfer::get_id()) { // fields to save $query = array(); $query[] = "anchor = '" . $reference . "'"; $query[] = "approved = 'Y'"; $query[] = "edit_date = '" . SQL::escape(gmstrftime('%Y-%m-%d %H:%M:%S')) . "'"; $query[] = "user_id = " . SQL::escape(Surfer::get_id()); $query[] = "user_email = '" . SQL::escape(Surfer::get_email_address()) . "'"; // insert a new record $query = "INSERT INTO " . SQL::table_name('enrolments') . " SET " . implode(', ', $query); SQL::query($query); } // each joiner takes one seat } else { $query = "UPDATE " . SQL::table_name('enrolments') . " SET approved = 'Y' WHERE id = " . SQL::escape($item['id']); SQL::query($query); } }
/** * manage potential transition to state 'stopped' * * This function updates $this->feed_back to report to the end-user */ function transition_to_stopped() { global $context; // no enrolment at all if (!$this->with_enrolment()) { return; } // no enrolment if (isset($this->attributes['enrolment']) && $this->attributes['enrolment'] == 'none') { $this->feed_back['status'][] = i18n::s('Any page visitor can participate'); } // manual enrolment if (isset($this->attributes['enrolment']) && $this->attributes['enrolment'] == 'manual') { $this->feed_back['status'][] = i18n::s('Registration is managed by page owner'); } // spread the word if (isset($this->anchor) && $this->anchor->is_owned()) { $label = i18n::s('Invite participants'); $this->feed_back['menu'][] = Skin::build_link($this->anchor->get_url('invite'), $label, 'span'); } // manage enrolment if (isset($this->anchor) && $this->anchor->is_owned()) { $label = i18n::s('Manage enrolment'); if ($count = enrolments::count_enrolled($this->anchor->get_reference())) { $label .= ' (' . $count . ')'; } $this->feed_back['menu'][] = Skin::build_link($this->get_url('enroll'), $label, 'span'); } // surfer has applied if ($enrolment = enrolments::get_record($this->anchor->get_reference())) { // registration has been approved if (isset($enrolment['approved']) && $enrolment['approved'] == 'Y') { $this->feed_back['status'][] = i18n::s('You have been enrolled'); } elseif ($this->attributes['status'] != 'started') { $this->feed_back['status'][] = i18n::s('You have asked for an invitation'); } else { $this->feed_back['status'][] = '<img alt="*" src="' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/ajax/ajax_spinner.gif" style="vertical-align:-3px" /> ' . i18n::s('You have asked for an invitation'); Page::insert_script('function reload_until_enrolment() {' . "\n" . ' window.location.reload(true);' . "\n" . '}' . "\n" . 'window.setInterval("reload_until_enrolment()",20000);' . "\n"); } // surfer should express his participation } elseif (isset($this->attributes['enrolment']) && $this->attributes['enrolment'] == 'none') { // until meeting has started if (Surfer::get_id() && in_array($this->attributes['status'], array('created', 'open', 'lobby'))) { $this->feed_back['menu'][] = Skin::build_link($this->get_url('apply'), i18n::s('Confirm my participation'), 'button'); } // surfer should ask for an invitation } elseif (isset($this->attributes['enrolment']) && $this->attributes['enrolment'] == 'validate') { // until meeting has stopped if (Surfer::get_id() && in_array($this->attributes['status'], array('open', 'lobby', 'started'))) { $this->feed_back['menu'][] = Skin::build_link($this->get_url('apply'), i18n::s('Ask for an invitation'), 'button'); } } // display event status to page owner, if any if (isset($this->anchor) && $this->anchor->is_owned()) { if (is_callable(array($this, 'get_event_status')) && ($status = $this->get_event_status())) { $this->feed_back['status'][] = $status; } } // start is mandatory before stop if ($this->attributes['status'] == 'started') { // meeting has been stopped externally if (!$this->is_running()) { // move to the 'stopped' status and refresh the page $fields = array('status' => 'stopped'); if ($this->set_values($fields)) { $this->feed_back['reload_this_page'] = TRUE; } // automatic stop } elseif ($this->minutes_since_stop > 0 && $this->with_automatic_stop()) { // move to the 'stopped' status and refresh the page $fields = array('status' => 'stopped'); if ($this->set_values($fields)) { $this->feed_back['reload_this_page'] = TRUE; } // event owner } elseif (isset($this->anchor) && $this->anchor->is_owned()) { // join the meeting if ($this->with_join_button()) { $this->feed_back['commands'][] = Skin::build_link($this->get_url('join'), i18n::s('Join the meeting'), $this->with_new_window() ? 'tee' : 'button', i18n::s('Meeting has started!')); } // display the button to stop the meeting if ($this->with_stop_button()) { $this->feed_back['commands'][] = Skin::build_link($this->get_url('stop'), i18n::s('Stop the meeting'), $this->with_join_button() ? 'span' : 'button'); } // enrolment is not required } elseif (isset($this->attributes['enrolment']) && $this->attributes['enrolment'] == 'none') { // join the meeting if ($this->with_join_button()) { $this->feed_back['commands'][] = Skin::build_link($this->get_url('join'), i18n::s('Join the meeting'), $this->with_new_window() ? 'tee' : 'button', i18n::s('Meeting has started!')); } // surfer has been fully enrolled } elseif (($enrolment = enrolments::get_record($this->anchor->get_reference())) && $enrolment['approved'] == 'Y') { // join the meeting if ($this->with_join_button()) { $this->feed_back['commands'][] = Skin::build_link($this->get_url('join'), i18n::s('Join the meeting'), $this->with_new_window() ? 'tee' : 'button', i18n::s('Meeting has started!')); } } } }