Exemple #1
0
/**
* @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> &raquo; " . ($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();
}
Exemple #2
0
    foreach ($likes_ids as $like) {
        if (!isset($users[$like])) {
            $users[$like] = new XoopsUser($like);
        }
        $like_user = $users[$like];
        $likes[] = array('uid' => $like, 'uname' => $like_user->getVar('uname'), 'name' => $like_user->getVar('name') != '' ? $like_user->getVar('name') : $like_user->getVar('uname'), 'avatar' => RMEvents::get()->run_event("rmcommon.get.avatar", $like_user->getVar('email'), 40));
    }
    $posts[$post->id()] = array('id' => $post->id(), 'text' => $post->text(), 'edit' => $post->editText(), 'approved' => $post->approved(), 'date' => $tf->ago($post->date()), 'canedit' => $canedit, 'candelete' => $candelete, 'canshow' => $canshow, 'canreport' => $report, 'poster' => $userData, 'attachs' => $attachs, 'attachscount' => count($attachs), 'parent' => $post->parent, 'replies' => $row['replies'], 'likes_count' => $row['likes'], 'likes' => $likes);
    $posts_ids[] = $post->id();
}
$tpl->assign('posts', $posts);
unset($userData, $bbUser, $users);
// Common Utilities Notifications
$notifications = RMNotifications::get();
$events = Bxpress_Notifications::get();
$permissions = $forum->permissions();
// New topics notifications
$event = $events->event('reply')->parameters($topic->id())->permissions(array('groups' => in_array(0, $permissions['view']) ? array() : $permissions['view']));
$notifications->add_item($event);
unset($event, $permissions);
$tpl->assign('notifications', $notifications->render());
$tpl->assign('lang_edit', __('Edit', 'bxpress'));
$tpl->assign('lang_delete', __('Delete', 'bxpress'));
$tpl->assign('lang_report', __('Report', 'bxpress'));
$tpl->assign('lang_quote', __('Quote', 'bxpress'));
$tpl->assign('lang_online', __('Online!', 'bxpress'));
$tpl->assign('lang_offline', __('Disconnected', 'bxpress'));
$tpl->assign('lang_attachments', __('Attachments', 'bxpress'));
$tpl->assign('xoops_pagetitle', $topic->title() . " &raquo; " . $xoopsModuleConfig['forum_title']);
$tpl->assign('token', $xoopsSecurity->createToken());
$tpl->assign('lang_edittext', __('Edit Text', 'bxpress'));
Exemple #3
0
/**
* @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> &raquo; " . ($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();
}