/** * bXpress Forums * A light weight and easy to use XOOPS module to create forums * * Copyright © 2014 Eduardo Cortés https://eduardocortes.mx * ----------------------------------------------------------------- * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ----------------------------------------------------------------- * @package bXpress * @author Eduardo Cortés <*****@*****.**> * @since 1.2 * @license GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html) * @link https://github.com/bitcero/bxpress */ function bxpress_block_users_show($options) { // Add css styles RMTemplate::get()->add_style('bxpress-blocks.min.css', 'bxpress'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbu = $db->prefix("users"); $tbp = $db->prefix("mod_bxpress_posts"); $tbl = $db->prefix("mod_bxpress_likes"); if ('active' == $options['type']) { $sql = "SELECT DISTINCT posts.uid, users.uid, users.uname, users.email, users.name,\n (SELECT COUNT(*) FROM {$tbp} WHERE uid = posts.uid) as total,\n (SELECT SUM(likes) FROM {$tbp} WHERE uid = posts.uid ) as likes\n FROM {$tbu} as users, {$tbp} as posts WHERE users.uid = posts.uid ORDER BY total DESC LIMIT 0, {$options['limit']}"; } $result = $db->query($sql); $users = array(); $user = new RMUser(); while ($row = $db->fetchArray($result)) { $user->assignVars($row); $users[] = array('id' => $user->id(), 'name' => '' != $user->name ? $user->name : $user->uname, 'uname' => $user->uname, 'avatar' => RMEvents::get()->run_event("rmcommon.get.avatar", $user->email, 0), 'posts' => $row['total'], 'likes' => $row['likes']); } $block['users'] = $users; return $block; }
function dt_block_items($options) { global $db, $xoopsModule; include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtsoftware.class.php'; include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php'; $tpl = RMTemplate::get(); $tpl->add_xoops_style('blocks.css', 'dtransport'); $dtfunc = new DTFunctions(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tbls = $db->prefix("dtrans_software"); $tblc = $db->prefix("dtrans_catsoft"); if ($options[1] > 0) { $sql = "SELECT s.* FROM {$tbls} as s, {$tblc} as c WHERE c.cat='" . $options[1] . "' AND s.id_soft=c.soft AND s.approved=1 AND s.`delete`=0"; } else { $sql = "SELECT s.* FROM {$tbls} as s WHERE s.`approved`=1 AND s.`delete`=0 "; } if (trim($options[10]) > 0) { $user = new RMUser(trim($options[10])); if ($user->isNew()) { return; } $sql .= " AND s.uid='" . $user->id() . "' "; } if ($options[11] > 0) { $sql .= "AND id_cat='{$options['11']}'"; } switch ($options[0]) { case 'all': $sql .= ' ORDER BY RAND() '; break; case 'recent': $sql .= " ORDER BY s.modified DESC, created DESC "; break; case 'popular': $sql .= " ORDER BY s.hits DESC "; break; case 'rated': $sql .= " ORDER BY s.`rating`/s.`votes` DESC "; break; case 'featured': $sql .= " AND featured=1 ORDER BY RAND() "; break; case 'daily': $sql = " AND daily=1 ORDER BY RAND() "; break; } $options[2] = $options[2] > 0 ? $options[2] : 5; $sql .= " LIMIT 0, {$options['2']}"; $result = $db->query($sql); $block = array(); while ($row = $db->fetchArray($result)) { $item = new DTSoftware(); $item->assignVars($row); $rtn = array(); $rtn['name'] = $item->getVar('name'); $rtn['version'] = $item->getVar('version'); if ($options[3]) { $img = new RMImage(); $img->load_from_params($item->getVar('image')); $rtn['image'] = $img->get_version($options[11]); } if ($options[4]) { $rtn['description'] = $item->getVar('shortdesc'); } if ($options[5]) { $rtn['hits'] = sprintf(__('Downloaded %s times.', 'dtransport'), '<strong>' . $item->getVar('hits') . '</strong>'); } if ($options[6]) { $rtn['urate'] = @number_format($item->getVar('rate') / $item->getVar('votes'), 1); } if ($options[7]) { $rtn['siterate'] = DTFunctions::ratingStars($item->getVar('siterate')); } $rtn['link'] = $item->permalink(); $rtn['metas'] = $dtfunc->get_metas('down', $item->id()); if ($options[9]) { $rtn['author'] = array('name' => $item->getVar('author_name'), 'url' => $item->getVar('author_url')); } $block['downs'][] = $rtn; } $block['showbutton'] = $options[8]; $block['downlang'] = __('Download', 'dtransport'); $block['lang_urate'] = __('User rating: %s', 'dtransport'); $block['lang_author'] = __('Author: %s', 'dtransport'); $block['langhits'] = _BK_DT_HITSTEXT; $block['langurate'] = _BK_DT_URATETEXT; $block['languser'] = _BK_DT_USERBY; return $block; }
/** * Save user data * * @param bool Indicates when is a edit */ function save_data($edit = false) { global $xoopsSecurity, $xoopsDB; $q = ''; // Query String foreach ($_POST as $k => $v) { ${$k} = $v; if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'sbt' || $k == 'action' || $k == 'password' || $k == 'passwordc') { continue; } $q .= $q == '' ? "{$k}=" . urlencode($v) : "&{$k}=" . urlencode($v); } if (!$xoopsSecurity->check()) { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('Sorry, you don\'t have permission to add users.', 'rmcommon'), 1); die; } if ($edit) { if ($uid <= 0) { redirectMsg('users.php', __('The specified user is not valid!', 'rmcommon'), 1); die; } $user = new RMUser($uid); if ($user->isNew()) { redirectMsg('users.php', __('The specified user does not exists!', 'rmcommon'), 1); die; } } else { $user = new RMUser(); } // Check uname, password and passwordc if ($uname == '' || $email == '' || !$edit && ($password == '' || $passwordc == '')) { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('Please fill all required fields and try again!', 'rmcommon'), 1); die; } // Check passwords if ($password != $passwordc) { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('Passwords doesn\'t match. Please chek them.', 'rmcommon'), 1); die; } // Check if user exists $sql = "SELECT COUNT(*) FROM " . $xoopsDB->prefix("users") . " WHERE (uname = '{$uname}' OR email = '{$email}')" . ($edit ? " AND uid != " . $user->uid : ''); list($exists) = $xoopsDB->fetchRow($xoopsDB->query($sql)); if ($exists > 0) { RMUris::redirect_with_message(__('Another user with same username or email already exists!', 'rmcommon'), 'users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, RMMSG_ERROR); } // Save user data $user->setVar('name', $name); $user->setVar('uname', $uname); $user->setVar('display_name', $display_name); $user->setVar('email', $email); if (!$edit) { $user->assignVar('user_regdate', time()); } if ($password != '') { $user->assignVar('pass', md5($password)); } $user->setVar('level', 1); $user->setVar('timezone_offset', $timezone); $user->setVar('url', $url); /** * If "All" has been selected then we need to get all * groups ID's */ if (in_array(0, $groups)) { $groups = array(); $result = $xoopsDB->query("SELECT groupid FROm " . $xoopsDB->prefix("groups")); while ($row = $xoopsDB->fetchArray($result)) { $groups[] = $row['groupid']; } unset($result); } /** * If no group has been selected, then we add user to * Anonymous group */ if (empty($groups)) { $groups = array(XOOPS_GROUP_ANONYMOUS); } $user->setGroups($groups); // Plugins and modules can save metadata. // Metadata are generated by other dynamical fields $user = RMEvents::get()->run_event('rmcommon.add.usermeta.4save', $user); if ($user->save()) { $user = RMEvents::get()->run_event($edit ? 'rmcommon.user.edited' : 'rmcommon.user.created', $user); redirectMsg('users.php', __('Database updated successfully!', 'rmcommon'), 0); } else { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('The users could not be saved. Please try again!', 'rmcommon') . '<br />' . $user->errors(), 1); } }
/** * Save user data * * @param bool Indicates when is a edit */ function save_data($edit = false) { global $xoopsSecurity; $q = ''; // Query String foreach ($_POST as $k => $v) { ${$k} = $v; if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'sbt' || $k == 'action' || $k == 'password' || $k == 'passwordc') { continue; } $q .= $q == '' ? "{$k}=" . urlencode($v) : "&{$k}=" . urlencode($v); } if (!$xoopsSecurity->check()) { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('Sorry, you don\'t have permission to add users.', 'rmcommon'), 1); die; } if ($edit) { if ($uid <= 0) { redirectMsg('users.php', __('The specified user is not valid!', 'rmcommon'), 1); die; } $user = new RMUser($uid); if ($user->isNew()) { redirectMsg('users.php', __('The specified user does not exists!', 'rmcommon'), 1); die; } } else { $user = new RMUser(); } // Check uname, password and passwordc if ($uname == '' || $email == '' || !$edit && ($password == '' || $passwordc == '')) { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('Please fill all required fields and try again!', 'rmcommon'), 1); die; } // Check passwords if ($password != $passwordc) { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('Passwords doesn\'t match. Please chek them.', 'rmcommon'), 1); die; } // Save user data $user->setVar('name', $name); $user->setVar('uname', $uname); $user->setVar('display_name', $display_name); $user->setVar('email', $email); if (!$edit) { $user->assignVar('user_regdate', time()); } if ($password != '') { $user->assignVar('pass', md5($password)); } $user->setVar('level', 1); $user->setVar('timezone_offset', $timezone); $user->setVar('url', $url); $user->setGroups($groups); // Plugins and modules can save metadata. // Metadata are generated by other dynamical fields $user = RMEvents::get()->run_event('rmcommon.add.usermeta.4save', $user); if ($user->save()) { $user = RMEvents::get()->run_event($edit ? 'rmcommon.user.edited' : 'rmcommon.user.created', $user); redirectMsg('users.php', __('Database updated successfully!', 'rmcommon'), 0); } else { redirectMsg('users.php?action=' . ($edit ? 'edit' : 'new') . '&' . $q, __('The users could not be saved. Please try again!', 'rmcommon') . '<br />' . $user->errors(), 1); } }
$post->assignVars($row); # Generamos los vínculos $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); $link = $post->permalink(); # Generamos el vínculo para el autor if ($post->getVar('author') > 0) { if (!isset($editors[$post->getVar('author')])) { $editors[$post->getVar('author')] = new MWEditor($post->getVar('author'), 'user'); } if ($editors[$post->getVar('author')]->isNew()) { if ($xoopsUser && $xoopsUser->uid() == $post->author) { $user = $xoopsUser; } else { $user = new RMUser($post->author); } $editors[$post->getVar('author')]->uid = $user->uid(); $editors[$post->getVar('author')]->name = $user->getVar('name'); $editors[$post->getVar('author')]->shortname = $user->getVar('uname'); $editors[$post->getVar('author')]->privileges = array('tags', 'tracks', 'comms'); $editors[$post->getVar('author')]->save(); } $editor = $editors[$post->getVar('author')]; $alink = $editor->permalink(); } else { $alink = ''; } # Información de Publicación $published = sprintf(__('%s by %s', 'mywords'), MWFunctions::format_time($post->getVar('pubdate'), 'string'), '<a href="' . $alink . '">' . (isset($editor) ? $editor->name : __('Anonymous', 'mywords')) . "</a>"); # Texto de continuar leyendo
if (count($post->get_categos()) <= 0) { $post->update(); } # Generamos los vínculos $day = date('d', $post->getVar('pubdate')); $month = date('m', $post->getVar('pubdate')); $year = date('Y', $post->getVar('pubdate')); // $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 0; # Cargamos los datos del autor $editor = new MWEditor($post->getVar('author'), 'user'); if ($editor->isNew()) { if ($xoopsUser && $xoopsUser->uid() == $post->author) { $user = $xoopsUser; } else { $user = new RMUser($post->author); } $editor->uid = $user->uid(); $editor->name = $user->getVar('name'); $editor->shortname = $user->getVar('uname'); $editor->privileges = array('tags', 'tracks', 'comms'); $editor->save(); } # Texto de continuar leyendo $xoopsTpl->assign('xoops_pagetitle', $post->getVar('customtitle') != '' ? $post->getVar('customtitle') : $post->getVar('title')); # Cargamos los comentarios del Artículo if ($page <= 0) { $path = explode("/", $request); $srh = array_search('page', $path); if (isset($path[$srh]) && $path[$srh] == 'page') { if (!isset($path[$srh])) {