예제 #1
0
 public function eventRmcommonLoadRightWidgets($widgets)
 {
     global $xoopsModule;
     if (!isset($xoopsModule) || $xoopsModule->getVar('dirname') != 'system' && $xoopsModule->getVar('dirname') != 'mywords') {
         return $widgets;
     }
     // Check edition
     $id = RMHttpRequest::request('id', 'integer', 0);
     $op = RMHttpRequest::request('op', 'string', '');
     $edit = $op == 'edit' ? 1 : 0;
     $post = null;
     if ($edit) {
         //Verificamos que el software sea válido
         if ($id <= 0) {
             $params = '';
         }
         $post = new MWPost($id);
     }
     if (defined("RMCSUBLOCATION") && RMCSUBLOCATION == 'new_post') {
         include_once '../widgets/widget-publish.php';
         $widgets[] = mywords_widget_publish($post);
         include_once '../widgets/widget-post-type.php';
         $widgets[] = mywords_widget_post_type($post);
         include_once '../widgets/widget-image.php';
         $widgets[] = mywords_widget_image($post);
         include_once '../widgets/widget-categories.php';
         $widgets[] = mywords_widget_categories($post);
         include_once '../widgets/widget-tags.php';
         $widgets[] = mywords_widget_addtags($post);
     }
     return $widgets;
 }
예제 #2
0
/**
 * Provides a widget to specify the default image for posts
 */
function mywords_widget_image($post = null)
{
    global $xoopsSecurity, $xoopsModuleConfig, $xoopsUser, $rm_config;
    $type = RMHttpRequest::request('type', 'string', '');
    $widget = array();
    $widget['title'] = __('Default Image', 'mywords');
    $util = new RMUtilities();
    if (isset($post) && is_a($post, 'MWPost')) {
        if ($post->isNew()) {
            $params = '';
        } else {
            $params = $post->getVar('image', 'e');
        }
    } else {
        $params = '';
    }
    $widget['content'] = '<form name="frmDefimage" id="frm-defimage" method="post">';
    $widget['content'] .= $util->image_manager('image', 'image', $params, array('accept' => 'thumbnail', 'multiple' => 'no'));
    $widget['content'] .= '</form>';
    return $widget;
}
예제 #3
0
/**
* @desc Activa o desactiva una categoría
**/
function activeCatego($act = 0)
{
    global $xoopsSecurity;
    $cats = RMHttpRequest::request('ids', 'array', array());
    //Verificamos si se ha proporcionado una categoría
    if (empty($cats)) {
        RMUris::redirect_with_message(__('You must select at least one category', 'bxpress'), './categories.php', RMMSG_WARN);
        die;
    }
    if (!$xoopsSecurity->check()) {
        RMUris::redirect_with_message(__('Session token expired!', 'bxpress'), 'categories.php', RMMSG_ERROR);
        die;
    }
    $errors = '';
    foreach ($cats as $k) {
        //Verificamos que la categoría sea válida
        if ($k <= 0) {
            $errors .= sprintf(__('Category ID %s is not valid!', 'bxpress'), '<strong>' . $k . '</strong>') . '<br />';
            continue;
        }
        //Verificamos que categoría exista
        $cat = new bXCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(_AS_BB_ERRCATNOEXIST, $k);
            continue;
        }
        $cat->setStatus($act);
        if (!$cat->save()) {
            $errors .= sprintf(_AS_BB_ERRCATNOSAVE, $k);
        }
    }
    if ($errors != '') {
        RMUris::redirect_with_message(__('Errors ocurred while trying to change status', 'bxpress') . $errors, './categories.php', RMMSG_ERROR);
        die;
    } else {
        RMUris::redirect_with_message(__('Database updated successfully!', 'bxpress'), './categories.php', RMMSG_SUCCESS);
        die;
    }
}
예제 #4
0
    if (!$xoopsDB->queryF($sql)) {
        $errors .= '<br>' . $xoopsDB->error();
    }
    // Eliminar datos del grupo
    $sql = "DELETE FROM " . $xoopsDB->prefix("groups") . " WHERE `groupid` IN (" . implode(",", $ids) . ")";
    if (!$xoopsDB->queryF($sql)) {
        $errors .= '<br>' . $xoopsDB->error();
    }
    if ('' == $errors) {
        showMessage(__('Selected groups has been deleted.', 'rmcommon'), RMMSG_SUCCESS, 'fa fa-remove-circle');
        $ajax->ajax_response('', 0, 1, array('reload' => true));
    } else {
        $ajax->ajax_response(__('Errors ocurred while trying to delete selected groups.', 'rmcommon') . "\n" . $errors, 1, 1);
    }
}
// get the action
$action = RMHttpRequest::request('action', 'string', '');
switch ($action) {
    case 'new-group':
        show_group_form();
        break;
    case 'save-group':
        save_group_data();
        break;
    case 'delete-group':
        delete_group_data();
        break;
    default:
        show_groups_list();
        break;
}
예제 #5
0
 protected function limit_statement($start = null)
 {
     if ($this->results_x_page <= 0) {
         return null;
     }
     if ($start == null) {
         $start = RMHttpRequest::request('start', 'integer', 0);
     }
     $sql = " LIMIT {$start}, " . $this->results_x_page;
     return $sql;
 }
예제 #6
0
/**
* @desc Almacena los datos de un foro
*/
function bx_save_forum($edit = 0)
{
    global $xoopsSecurity, $xoopsModuleConfig, $xoopsConfig;
    $q = $edit ? 'action=edit' : 'action=new';
    $prefix = 1;
    foreach ($_POST as $k => $v) {
        if (substr($k, 0, 5) == 'perm_') {
            $permissions[substr($k, 5)] = $v;
        } else {
            ${$k} = $v;
        }
        if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'action') {
            continue;
        }
        $q .= '&' . $k . '=' . $v;
    }
    if (!$xoopsSecurity->check()) {
        RMUris::redirect_with_message(__('Session token expired', 'bxpress'), 'forums.php?' . $q, RMMSG_ERROR);
    }
    if ($edit) {
        $id = RMHttpRequest::request('id', 'integer', 0);
        if ($id <= 0) {
            RMUris::redirect_with_message(__('Specified id is not valid!', 'bxpress'), 'forums.php', RMMSG_ERROR);
        }
        $forum = new bXForum($id);
        if ($forum->isNew()) {
            RMUris::redirect_with_message(__('Specified forum does not exists!', 'bxpress'), 'forums.php', RMMSG_ERROR);
        }
    } else {
        $forum = new bXForum();
    }
    $forum->setVar('name', $name);
    $forum->setVar('desc', $desc);
    $forum->setVar('image', $image);
    if (!$edit) {
        $forum->setVar('topics', 0);
        $forum->setVar('posts', 0);
        $forum->setVar('last_post_id', 0);
        $forum->setVar('subforums', 0);
    }
    $forum->setVar('cat', $cat);
    $forum->setActive($active);
    $forum->setSignature($sig);
    $forum->setPrefix($prefix);
    $forum->setHotThreshold($hot_threshold);
    $forum->setOrder($order);
    $forum->setAttachments($attachments);
    $forum->setMaxSize($attach_maxkb);
    $forum->setExtensions(explode('|', $attach_ext));
    $forum->setPermissions($permissions);
    // Check if forum exists
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("mod_bxpress_forums") . " WHERE name='{$name}' AND cat={$cat}";
    if ($edit) {
        $sql .= " AND id_forum != " . $forum->id();
    }
    list($exists) = $db->fetchRow($db->query($sql));
    if ($exists) {
        RMUris::redirect_with_message(sprintf(__('Another forum with name "%s" already exists in this category.', 'bxpress'), $name), 'forums.php?' . $q, RMMSG_ERROR);
    }
    if ($forum->save()) {
        if ($parent > 0) {
            $pf = new bXForum($parent);
            if (!$pf->isNew()) {
                $pf->setSubforums($pf->subforums() + 1);
                $pf->save();
            }
        }
        if (!$edit) {
            //Redireccionamos a ventana de selección de moderadores
            redirectMsg('forums.php?action=moderators&id=' . $forum->id(), __('Forum saved successfully! Redirecting to moderators assignment...', 'bxpress'), 0);
        } else {
            redirectMsg('forums.php', __('Changes saved successfully!', 'bxpress'), 0);
        }
    } else {
        redirectMsg('forums.php?' . $q, __('Forum could not be saved!', 'bxpress') . $forum->errors(), 1);
    }
}
예제 #7
0
    }
    $image = new RMImage($id);
    if ($image->isNew()) {
        images_send_json(array('message' => __('Specified image does not exists', 'rmcommon'), 'error' => 1, 'token' => $xoopsSecurity->createToken()));
    }
    $author = new RMUser($image->uid);
    $original = pathinfo($image->get_files_path() . '/' . $image->file);
    $dimensions = getimagesize($image->get_files_path() . '/' . $image->file);
    $mimes = (include XOOPS_ROOT_PATH . '/include/mimetypes.inc.php');
    $category_sizes = $cat->getVar('sizes');
    $sizes = array();
    foreach ($category_sizes as $i => $size) {
        if ($size['width'] <= 0) {
            continue;
        }
        $tfile = $image->get_files_path() . '/sizes/' . $original['filename'] . '-' . $size['name'] . '.' . $original['extension'];
        if (!is_file($tfile)) {
            continue;
        }
        $t_dim = getimagesize($tfile);
        $sizes[] = array('width' => $t_dim[0], 'height' => $t_dim[1], 'url' => $image->get_files_url() . '/sizes/' . $original['filename'] . '-' . $size['name'] . '.' . $original['extension'], 'name' => $size['name']);
    }
    $sizes[] = array('width' => $dimensions[0], 'height' => $dimensions[1], 'url' => $image->getOriginal(), 'name' => __('Original', 'rmcommon'));
    $links = array('none' => array('caption' => __('None', 'rmcommon'), 'value' => ''), 'file' => array('caption' => __('File URL', 'rmcommon'), 'value' => XOOPS_UPLOAD_URL . '/' . date('Y', $image->getVar('date')) . '/' . date('m', $image->getVar('date')) . '/' . $image->getVar('file')));
    $links = RMEvents::get()->run_event('rmcommon.image.insert.links', $links, $image, RMHttpRequest::post('url', 'string', ''));
    // Image data
    $data = array('id' => $image->id(), 'title' => $image->title, 'date' => formatTimestamp($image->date, 'l'), 'description' => $image->getVar('desc', 'n'), 'author' => array('uname' => $author->uname, 'uid' => $author->uid, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $author->email, 40), 'url' => XOOPS_URL . '/userinfo.php?uid=' . $author->email), 'medium' => $image->get_by_size(300), 'url' => $image->get_files_url(), 'original' => array('file' => $original['basename'], 'url' => $image->getOriginal(), 'size' => RMFormat::bytes_format(filesize($image->get_files_path() . '/' . $image->file)), 'width' => $dimensions[0], 'height' => $dimensions[1]), 'mime' => isset($mimes[$original['extension']]) ? $mimes[$original['extension']] : 'application/octet-stream', 'sizes' => $sizes, 'links' => $links);
    $data = RMEvents::get()->run_event('rmcommon.loading.image.details', $data, $image, RMHttpRequest::request('url', 'string', ''));
    $data['token'] = $xoopsSecurity->createToken();
    images_send_json($data);
}
예제 #8
0
파일: edit.php 프로젝트: petitours/bxpress
<?php

// $Id: edit.php 1034 2012-09-06 02:30:13Z i.bitcero $
// --------------------------------------------------------------
// bXpress Forums
// An simple forums module for XOOPS and Common Utilities
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
define('BB_LOCATION', 'posts');
include '../../mainfile.php';
$op = RMHttpRequest::request('op', 'string', '');
$id = RMHttpRequest::request('id', 'integer', 0);
if ($id <= 0) {
    redirect_header('./', 2, __('No post has been specified!', 'bxpress'));
    die;
}
$post = new bXPost($id);
if ($post->isNew()) {
    redirect_header('./', 2, __('Specified post does not exists!', 'bxpress'));
    die;
}
$topic = new bXTopic($post->topic());
$forum = new bXForum($topic->forum());
// Verificamos si el usuario tiene permisos de edición en el foro
if (!$xoopsUser || !$forum->isAllowed($xoopsUser->getGroups(), 'edit')) {
    redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('You don\'t have permission to edit this post!', 'bxpress'));
    die;
}
// Verificamos si el usuario tiene permiso de edición para el post
예제 #9
0
 protected function getParameter($name, $type = 'string', $default = '')
 {
     if (isset($this->parameters[$name])) {
         return RMHttpRequest::array_value($name, $this->parameters, $type, $default);
     } else {
         return RMHttpRequest::request($name, $type, $default);
     }
 }