public function get_menu_content() { //Create file template $tpl = new FileTemplate('shoutbox/ShoutboxModuleMiniMenu.tpl'); //Assign the lang file to the tpl $tpl->add_lang(LangLoader::get('common', 'shoutbox')); $config = ShoutboxConfig::load(); $forbidden_tags = array_flip($config->get_forbidden_formatting_tags()); if ($config->is_shout_bbcode_enabled()) { $smileys_cache = SmileysCache::load(); $smileys_per_line = 5; //Smileys par ligne. $smileys_displayed_number = 0; foreach ($smileys_cache->get_smileys() as $code_smile => $infos) { $smileys_displayed_number++; $tpl->assign_block_vars('smileys', array('C_END_LINE' => $smileys_displayed_number % $smileys_per_line == 0, 'URL' => TPL_PATH_TO_ROOT . '/images/smileys/' . $infos['url_smiley'], 'CODE' => addslashes($code_smile))); } } $tpl->put_all(array('C_MEMBER' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'C_DISPLAY_FORM' => ShoutboxAuthorizationsService::check_authorizations()->write() && !AppContext::get_current_user()->is_readonly(), 'C_VALIDATE_ONKEYPRESS_ENTER' => $config->is_validation_onkeypress_enter_enabled(), 'C_DISPLAY_SHOUT_BBCODE' => ModulesManager::is_module_installed('BBCode') && $config->is_shout_bbcode_enabled(), 'C_BOLD_DISABLED' => isset($forbidden_tags['b']), 'C_ITALIC_DISABLED' => isset($forbidden_tags['i']), 'C_UNDERLINE_DISABLED' => isset($forbidden_tags['u']), 'C_STRIKE_DISABLED' => isset($forbidden_tags['s']), 'C_AUTOMATIC_REFRESH_ENABLED' => $config->is_automatic_refresh_enabled(), 'SHOUTBOX_PSEUDO' => AppContext::get_current_user()->get_display_name(), 'SHOUT_REFRESH_DELAY' => $config->get_refresh_delay(), 'L_ALERT_LINK_FLOOD' => sprintf(LangLoader::get_message('e_l_flood', 'errors'), $config->get_max_links_number_per_message()), 'SHOUTBOX_MESSAGES' => ShoutboxAjaxRefreshMessagesController::get_view())); return $tpl->render(); }
private function check_authorizations() { if (!ShoutboxAuthorizationsService::check_authorizations()->read()) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } }
private function check_authorizations() { return ShoutboxAuthorizationsService::check_authorizations()->write() && !AppContext::get_current_user()->is_readonly(); }
private function check_authorizations() { $message = $this->get_message(); if ($message->get_id() === null) { if (!ShoutboxAuthorizationsService::check_authorizations()->write()) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } } else { if (!$message->is_authorized_to_edit()) { $error_controller = PHPBoostErrors::user_not_authorized(); DispatchManager::redirect($error_controller); } } if (AppContext::get_current_user()->is_readonly()) { $controller = PHPBoostErrors::user_in_read_only(); DispatchManager::redirect($controller); } }
public function is_authorized_to_delete() { return ShoutboxAuthorizationsService::check_authorizations()->moderation() || ShoutboxAuthorizationsService::check_authorizations()->write() && $this->get_author_user()->get_id() == AppContext::get_current_user()->get_id() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL); }