$lastpost['time'] = $last->date(); $lastpost['id'] = $last->id(); $lastpost['poster'] = array('uid' => $last->uid, 'uname' => $last->poster_name, 'name' => $last_poster->name != '' ? $last_poster->name : $last_poster->uname, 'email' => $last_poster->email, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $last_poster->getVar('email'), 50), 'link' => XOOPS_URL . '/userinfo.php?uid=' . $last_poster->uid); if ($xoopsUser) { $lastpost['new'] = $last->date() > $xoopsUser->getVar('last_login') && time() - $last->date() < $xoopsModuleConfig['time_new']; } else { $lastpost['new'] = time() - $last->date() <= $xoopsModuleConfig['time_new']; } } $tpages = ceil($topic->replies() / $xoopsModuleConfig['perpage']); if ($tpages > 1) { $pages = bXFunctions::paginateIndex($tpages); } else { $pages = null; } $tpl->append('topics', array('id' => $topic->id(), 'title' => $topic->title(), 'replies' => $topic->replies(), 'views' => $topic->views(), 'by' => sprintf(__('By: %s', 'bxpress'), $topic->posterName()), 'last' => $lastpost, 'popular' => $topic->replies() >= $forum->hotThreshold(), 'sticky' => $topic->sticky(), 'pages' => $pages, 'tpages' => $tpages, 'closed' => $topic->status(), 'poster' => array('uid' => $topic->poster, 'uname' => $poster->uname, 'name' => $poster->name, 'email' => $poster->email, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $poster->getVar('email'), 100), 'type' => $poster->isAdmin() ? 'admin' : ($forum->isModerator($topic->poster) ? 'moderator' : 'user')))); } // Datos del Foro $tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name(), 'moderator' => $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : false)); // Notificaciones de Common Utilities $notifications = RMNotifications::get(); $events = Bxpress_Notifications::get(); // New topics notifications $event = $events->event('newtopic')->parameters($forum->id())->permissions(array('users' => $forum->moderators(), 'groups' => array(XOOPS_GROUP_ADMIN))); $notifications->add_item($event); // New posts notification $event = $events->event('forum-newpost')->parameters($forum->id())->permissions(array('users' => $forum->moderators(), 'groups' => array(XOOPS_GROUP_ADMIN))); $notifications->add_item($event); // Assign output to a Smarty variable $tpl->assign('notifications', $notifications->render()); $tpl->assign('lang_pages', __('Pages:', 'bxpress'));
$lastpost['date'] = formatTimeStamp($last->date(), 'c'); $lastpost['by'] = sprintf(__('By: %s', 'bxpress'), $last->uname()); $lastpost['id'] = $last->id(); if ($xoopsUser) { $lastpost['new'] = $last->date() > $xoopsUser->getVar('last_login') && time() - $last->date() < $xoopsModuleConfig['time_new']; } else { $lastpost['new'] = time() - $last->date() <= $xoopsModuleConfig['time_new']; } } $tpages = ceil($topic->replies() / $xoopsModuleConfig['perpage']); if ($tpages > 1) { $pages = bXFunctions::paginateIndex($tpages); } else { $pages = null; } $tpl->append('topics', array('id' => $topic->id(), 'title' => $topic->title(), 'replies' => $topic->replies(), 'views' => $topic->views(), 'by' => sprintf(__('By: %s', 'bxpress'), $topic->posterName()), 'last' => $lastpost, 'popular' => $topic->replies() >= $forum->hotThreshold(), 'sticky' => $topic->sticky(), 'pages' => $pages, 'tpages' => $tpages, 'closed' => $topic->status())); } // Datos del Foro $tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name(), 'moderator' => $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : false)); $tpl->assign('lang_pages', __('Pages:', 'bxpress')); $tpl->assign('lang_topic', __('Topics', 'bxpress')); $tpl->assign('lang_replies', __('Replies', 'bxpress')); $tpl->assign('lang_views', __('Views', 'bxpress')); $tpl->assign('lang_lastpost', __('Last Post', 'bxpress')); $tpl->assign('lang_nonew', __('No new posts', 'bxpress')); $tpl->assign('lang_withnew', __('New posts', 'bxpress')); $tpl->assign('lang_hotnonew', __('No hot topics', 'bxpress')); $tpl->assign('lang_hotnew', __('New hot topics', 'bxpress')); $tpl->assign('lang_sticky', __('Sticky', 'bxpress')); $tpl->assign('lang_closed', __('Closed Topic', 'bxpress')); if ($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'topic')) {
/** * @desc Muestra el formulario para creación de Foros * @param int $edit Determina si se esta editando un foro existente */ function bx_show_form($edit = 0) { global $xoopsModule, $xoopsConfig; if (!RMfunctions::plugin_installed('advform')) { RMUris::redirect_with_message(sprintf(__('<a href="%s">AdvancedForms</a> must be installed before to create any forum. Please download and install it.', 'bxpress'), 'https://github.com/bitcero/advform'), 'forums.php', RMMSG_ERROR); } if ($edit) { $id = RMHttpRequest::request('id', 'integer', 0); if ($id <= 0) { RMUris::redirect_with_message(__('Provided ID is not valid!', 'bxpress'), 'forums.php', RMMSG_WARN); die; } $forum = new bXForum($id); if ($forum->isNew()) { RMUris::redirect_with_message(__('Specified forum does not exists!', 'bxpress'), 'forums.php', RMMSG_ERROR); die; } } RMTemplate::get()->add_style('admin.css', 'bxpress'); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'))); xoops_cp_header(); $bcHand = new bXCategoryHandler(); $bfHand = new bXForumHandler(); $form = new RMForm($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'), 'frmForum', 'forums.php'); // Categorias $ele = new RMFormSelect(__('Category', 'bxpress'), 'cat', 0, $edit ? array($forum->category()) : null); $ele->addOption(0, __('Select category...', 'bxpress'), $edit ? 0 : 1); $ele->addOptionsArray($bcHand->getForSelect()); $form->addElement($ele, true, 'noselect:0'); // NOmbre $form->addElement(new RMFormText(__('Forum name', 'bxpress'), 'name', 50, 150, $edit ? $forum->name() : ''), true); // Descripcion $form->addElement(new RMFormEditor(__('Forum description', 'bxpress'), 'desc', '90%', '300px', $edit ? $forum->getVar('desc', 'e') : '')); $form->addElement(new RMFormImageUrl(__('Forum image', 'bxpress'), 'image', $edit ? $forum->image : '')); // Activo $form->addElement(new RMFormYesNo(__('Activate forum', 'bxpress'), 'active', $edit ? $forum->active() : 1)); // Firmas $form->addElement(new RMFormYesNo(__('Allow signatures in the posts', 'bxpress'), 'sig', $edit ? $forum->signature() : 1)); // Temas Populares $form->addElement(new RMFormText(__('Answers to match a topic as popular', 'bxpress'), 'hot_threshold', 10, 5, $edit ? $forum->hotThreshold() : 10), true, 'bigger:1'); // Orden en la lista $form->addElement(new RMFormText(__('Order in the list', 'bxpress'), 'order', 10, 5, $edit ? $forum->order() : 0), false, 'bigger:-1'); // Adjuntos $form->addElement(new RMFormYesNo(__('Allow attachments', 'bxpress'), 'attachments', $edit ? $forum->attachments() : 1)); $ele = new RMFormText(__('Maximum attachments file size', 'bxpress'), 'attach_maxkb', 10, 20, $edit ? $forum->maxSize() : 50); $ele->setDescription(__('Specify this value in Kilobytes', 'bxpress')); $form->addElement($ele, false, 'bigger:0'); $ele = new RMFormText(__('Allowed file types', 'bxpress'), 'attach_ext', 50, 0, $edit ? implode("|", $forum->extensions()) : 'zip|tar|jpg|gif|png|gz'); $ele->setDescription(__('Specified the extensions of allowed file types separating each one with "|" and without the dot.', 'bxpress')); $form->addElement($ele); // Grupos con permiso if ($edit) { $grupos = $forum->permissions(); } $form->addElement(new RMFormGroups(__('Can view the forum', 'bxpress'), 'perm_view', 1, 1, 5, $edit ? $grupos['view'] : array(0))); $form->addElement(new RMFormGroups(__('Can start new topics', 'bxpress'), 'perm_topic', 1, 1, 5, $edit ? $grupos['topic'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can answer', 'bxpress'), 'perm_reply', 1, 1, 5, $edit ? $grupos['reply'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can edit their posts', 'bxpress'), 'perm_edit', 1, 1, 5, $edit ? $grupos['edit'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can delete', 'bxpress'), 'perm_delete', 1, 1, 5, $edit ? $grupos['delete'] : array(1))); $form->addElement(new RMFormGroups(__('Can vote', 'bxpress'), 'perm_vote', 1, 1, 5, $edit ? $grupos['vote'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can attach', 'bxpress'), 'perm_attach', 1, 1, 5, $edit ? $grupos['attach'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can send without approval', 'bxpress'), 'perm_approve', 1, 1, 5, $edit ? $grupos['approve'] : array(1, 2))); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'bxpress') : __('Create Forum', 'bxpress'), 'submit', '', 1); $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location=\'forums.php\';"'); $form->addElement($ele); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $forum->id())); } $form->display(); xoops_cp_footer(); }
/** * @desc Muestra el formulario para creación de Foros * @param int $edit Determina si se esta editando un foro existente */ function bx_show_form($edit = 0) { global $xoopsModule, $xoopsConfig; if ($edit) { $id = rmc_server_var($_REQUEST, 'id', 0); if ($id <= 0) { redirectMsg('forums.php', __('Provided ID is not valid!', 'bxpress'), 1); die; } $forum = new bXForum($id); if ($forum->isNew()) { redirectMsg('forums.php', __('Specified forum does not exists!', 'bxpress'), 1); die; } } bXFunctions::menu_bar(); RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/foros/standalone/1/#crear-foro'); RMTemplate::get()->add_style('admin.css', 'bxpress'); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'))); xoops_cp_header(); $bcHand = new bXCategoryHandler(); $bfHand = new bXForumHandler(); $form = new RMForm($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'), 'frmForum', 'forums.php'); // Categorias $ele = new RMFormSelect(__('Category', 'bxpress'), 'cat', 0, $edit ? array($forum->category()) : null); $ele->addOption(0, __('Select category...', 'bxpress'), $edit ? 0 : 1); $ele->addOptionsArray($bcHand->getForSelect()); $form->addElement($ele, true, 'noselect:0'); // NOmbre $form->addElement(new RMFormText(__('Forum name', 'bxpress'), 'name', 50, 150, $edit ? $forum->name() : ''), true); // Descripcion $form->addElement(new RMFormEditor(__('Forum description', 'bxpress'), 'desc', '90%', '300px', $edit ? $forum->description() : '')); // Activo $form->addElement(new RMFormYesNo(__('Activate forum', 'bxpress'), 'active', $edit ? $forum->active() : 1)); // Firmas $form->addElement(new RMFormYesNo(__('Allow signatures in the posts', 'bxpress'), 'sig', $edit ? $forum->signature() : 1)); // Temas Populares $form->addElement(new RMFormText(__('Answers to match a topic as popular', 'bxpress'), 'hot_threshold', 10, 5, $edit ? $forum->hotThreshold() : 10), true, 'bigger:1'); // Orden en la lista $form->addElement(new RMFormText(__('Order in the list', 'bxpress'), 'order', 10, 5, $edit ? $forum->order() : 0), false, 'bigger:-1'); // Adjuntos $form->addElement(new RMFormYesNo(__('Allow attachments', 'bxpress'), 'attachments', $edit ? $forum->attachments() : 1)); $ele = new RMFormText(__('Maximum attachments file size', 'bxpress'), 'attach_maxkb', 10, 20, $edit ? $forum->maxSize() : 50); $ele->setDescription(__('Specify this value in Kilobytes', 'bxpress')); $form->addElement($ele, false, 'bigger:0'); $ele = new RMFormText(__('Allowed file types', 'bxpress'), 'attach_ext', 50, 0, $edit ? implode("|", $forum->extensions()) : 'zip|tar|jpg|gif|png|gz'); $ele->setDescription(__('Specified the extensions of allowed file types separating each one with "|" and without the dot.', 'bxpress')); $form->addElement($ele); // Grupos con permiso if ($edit) { $grupos = $forum->permissions(); } $form->addElement(new RMFormGroups(__('Can view the forum', 'bxpress'), 'perm_view', 1, 1, 5, $edit ? $grupos['view'] : array(0))); $form->addElement(new RMFormGroups(__('Can start new topics', 'bxpress'), 'perm_topic', 1, 1, 5, $edit ? $grupos['topic'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can answer', 'bxpress'), 'perm_reply', 1, 1, 5, $edit ? $grupos['reply'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can edit their posts', 'bxpress'), 'perm_edit', 1, 1, 5, $edit ? $grupos['edit'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can delete', 'bxpress'), 'perm_delete', 1, 1, 5, $edit ? $grupos['delete'] : array(1))); $form->addElement(new RMFormGroups(__('Can vote', 'bxpress'), 'perm_vote', 1, 1, 5, $edit ? $grupos['vote'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can attach', 'bxpress'), 'perm_attach', 1, 1, 5, $edit ? $grupos['attach'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can send without approval', 'bxpress'), 'perm_approve', 1, 1, 5, $edit ? $grupos['approve'] : array(1, 2))); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'bxpress') : __('Create Forum', 'bxpress'), 'submit', '', 1); $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location=\'forums.php\';"'); $form->addElement($ele); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $forum->id())); } $form->display(); xoops_cp_footer(); }