/** * @desc Realiza una búsqueda en el módulo desde EXM */ function pwSearch($queryarray, $andor, $limit, $offset, $userid) { global $myts; include_once XOOPS_ROOT_PATH . "/modules/works/class/pwwork.class.php"; $mc = RMUtilities::module_config('works'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT a.* FROM " . $db->prefix('pw_works') . " a INNER JOIN " . $db->prefix('pw_clients') . " b ON (a.public=1 AND a.client=b.id_client AND ("; $sql1 = ''; if (is_array($queryarray)) { foreach ($queryarray as $k) { $sql1 .= ($sql1 == '' ? "" : "{$andor}") . " (a.title LIKE '%{$k}%' OR a.short LIKE '%{$k}%' OR b.name LIKE '%{$k}%' OR b.business_name LIKE '%{$k}%') "; } } $sql1 .= "))"; $sql1 .= " GROUP BY a.id_work ORDER BY a.created DESC LIMIT {$offset}, {$limit}"; $result = $db->queryF($sql . $sql1); $ret = array(); while ($row = $db->fetchArray($result)) { $work = new PWWork(); $work->assignVars($row); $rtn = array(); $rtn['image'] = 'images/works.png'; $rtn['title'] = $work->title(); $rtn['time'] = $work->created(); $rtn['uid'] = ''; $rtn['desc'] = $work->descShort(); $rtn['link'] = $work->link(); $ret[] = $rtn; } return $ret; }
function pw_comments_show($options) { global $xoopsModule, $xoopsModuleConfig; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwwork.class.php'; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php'; $db = XoopsDatabaseFactory::getDatabaseConnection(); if (isset($xoopsModule) && $xoopsModule->dirname() == 'works') { $mc =& $xoopsModuleConfig; } else { $mc =& RMUtilities::module_config('works'); } $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE comment<>'' ORDER BY " . ($options[1] ? " created DESC " : " RAND() "); $sql .= " LIMIT 0," . $options[0]; $result = $db->query($sql); $clients = array(); while ($row = $db->fetchArray($result)) { $work = new PWWork(); $work->assignVars($row); if (!isset($clients[$work->client()])) { $clients[$work->client()] = new PWClient($work->client(), 1); } $client =& $clients[$work->client()]; $rtn = array(); $rtn['client'] = $client->businessName(); $rtn['link'] = $work->link(); $rtn['comment'] = $work->comment(); $block['works'][] = $rtn; } return $block; }
/** * @desc Función para incrementar el número de comentarios */ function dt_com_update($item, $total) { include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtsoftware.class.php'; $db =& XoopsDatabaseFactory::getDatabaseConnection(); $sql = "UPDATE " . $db->prefix("dtrans_software") . " SET comments='{$total}' WHERE id_soft='{$item}'"; $db->queryF($sql); }
public function __construct($id = null, $col = 0) { $this->db = XoopsDatabaseFactory::getDatabaseConnection(); $this->_dbtable = $this->db->prefix("gs_users"); $this->setNew(); $this->initVarsFromTable(); if ($col) { $this->primary = 'uid'; } if (!isset($id)) { return; } if (is_numeric($id)) { if (!$this->loadValues($id)) { return; } $this->unsetNew(); } else { $this->primary = 'uname'; if ($this->loadValues($id)) { $this->unsetNew(); } $this->primary = 'id_user'; } $this->eUser = new XoopsUser($this->getVar('uid')); $this->primary = 'id_user'; }
/** * Retrieves the settings for a given plugin * * @param string $dir Plugin's directory * @param bool $values * @return array */ static function plugin_settings($dir, $values = false) { if ($dir == '') { return null; } if (!isset(self::$plugin_settings[$dir])) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mod_rmcommon_settings") . " WHERE element='{$dir}'"; $result = $db->query($sql); if ($db->getRowsNum($result) <= 0) { return null; } $configs = array(); while ($row = $db->fetchArray($result)) { $configs[$row['name']] = $row; } $configs = self::option_value_output($configs); self::$plugin_settings[$dir] = $configs; } if (!$values) { return (object) self::$plugin_settings[$dir]; } $ret = array(); foreach (self::$plugin_settings[$dir] as $name => $conf) { $ret[$name] = $conf['value']; } return (object) $ret; }
function xoops_module_update_rmcommon($mod, $prev) { $db = XoopsDatabaseFactory::getDatabaseConnection(); // Add tables to database $sql = "ALTER TABLE `" . $db->prefix("rmc_blocks") . "` ADD `content` TEXT NOT NULL AFTER `content_type`"; return $db->queryF($sql); }
function &gs_rssshow($limit) { global $util, $mc; $db = XoopsDatabaseFactory::getDatabaseConnection(); include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php'; foreach ($_GET as $k => $v) { ${$k} = $v; } $feed = array(); // Información General $items = array(); $mc =& $util->moduleConfig('galleries'); if ($show == 'imgs') { $feed['title'] = htmlspecialchars(_MI_GS_RSSNAME); $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/photos/' : 'explore.php?by=explore/photos')); $feed['description'] = htmlspecialchars(_MI_GS_RSSIMGS_DESC); $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE public='2' ORDER BY created DESC LIMIT 0,15"; $result = $db->query($sql); $users = array(); while ($row = $db->fetchArray($result)) { $pic = new GSImage(); $pic->assignVars($row); if (!isset($users[$pic->owner()])) { $users[$pic->owner()] = new GSUser($pic->owner(), 1); } $user =& $users[$pic->owner()]; $rtn = array(); $rtn['title'] = htmlspecialchars($pic->title()); $rtn['link'] = $user->userURL() . 'img/' . $pic->id() . '/'; $rtn['description'] = htmlspecialchars('<img src="' . $user->filesURL() . '/ths/' . $pic->image() . '" alt="" /><br />' . sprintf(_MI_GS_RSSIMGDESC, $pic->desc(), formatTimestamp($pic->created(), 'string'), $user->uname(), $pic->views())); $rtn['date'] = formatTimestamp($pic->created()); $items[] = $rtn; } } elseif ($show == 'sets') { $feed['title'] = htmlspecialchars(_MI_GS_RSSSETS); $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/sets/' : 'explore.php?by=explore/sets')); $feed['description'] = htmlspecialchars(_MI_GS_RSSSETS_DESC); $sql = "SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT 0,15"; $result = $db->query($sql); $users = array(); while ($row = $db->fetchArray($result)) { $set = new GSSet(); $set->assignVars($row); if (!isset($users[$set->owner()])) { $users[$set->owner()] = new GSUser($set->owner(), 1); } $user =& $users[$set->owner()]; $rtn = array(); $rtn['title'] = htmlspecialchars($set->title()); $rtn['link'] = $user->userURL() . 'set/' . $set->id() . '/'; $rtn['description'] = htmlspecialchars(sprintf(_MI_GS_RSSSETDESC, $user->uname(), formatTimestamp($set->date(), 'string'), $set->pics())); $rtn['date'] = formatTimestamp($set->date()); $items[] = $rtn; } } $ret = array('feed' => $feed, 'items' => $items); return $ret; }
/** * Función para realizar búsquedas */ function qpages_search($qa, $andor, $limit, $offset, $userid) { global $xoopsUser, $mc; include_once XOOPS_ROOT_PATH . '/modules/qpages/class/qppage.class.php'; $mc = RMUtilities::module_config('qpages'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("qpages_pages"); $adds = ''; if (is_array($qa) && ($count = count($qa))) { $adds = ''; for ($i = 0; $i < $count; $i++) { $adds .= $adds == '' ? "(titulo LIKE '%{$qa[$i]}%' OR titulo_amigo LIKE '%{$qa[$i]}%')" : " {$andor} (titulo LIKE '%{$qa[$i]}%' OR titulo_amigo LIKE '%{$qa[$i]}%')"; } } $sql .= $adds != '' ? " WHERE {$adds}" : ''; if ($userid > 0) { $sql .= ($adds != '' ? " AND " : " WHERE ") . "uid='{$userid}'"; } $sql .= " ORDER BY modificado DESC"; $i = 0; $result = $db->query($sql); $ret = array(); while ($row = $db->fetchArray($result)) { $page = new QPPage(); $page->assignVars($row); $ret[$i]['image'] = "images/page.png"; $ret[$i]['link'] = $mc['links'] == 0 ? 'page.php?page=' . $page->getFriendTitle() : $page->getFriendTitle() . '/'; $ret[$i]['title'] = $page->getTitle(); $ret[$i]['time'] = $page->getDate(); $ret[$i]['uid'] = $page->uid(); $ret[$i]['desc'] = $page->getDescription(); $i++; } return $ret; }
/** * Mostramos las página existentes */ function qpagesBlockPages($options) { global $xoopsConfig; include_once XOOPS_ROOT_PATH . '/modules/qpages/class/qppage.class.php'; $db =& XoopsDatabaseFactory::getDatabaseConnection(); $mc =& RMUtilities::module_config('qpages'); if (!defined('QP_URL')) { define('QP_URL', XOOPS_URL . ($mc['links'] ? $mc['basepath'] : '/modules/qpages')); } $sql = "SELECT * FROM " . $db->prefix("qpages_pages"); if ($options[0] > 0) { $sql .= " WHERE cat='{$options['0']}'"; } $sql .= " ORDER BY fecha DESC LIMIT 0,{$options['1']}"; $block = array(); $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $page = new QPPage(); $page->assignVars($row); $rtn = array(); $rtn['id'] = $page->getID(); $rtn['titulo'] = $page->getTitle(); $rtn['link'] = $page->getPermaLink(); $block['pages'][] = $rtn; } return $block; }
/** * Constructor * */ public function __construct() { Language::load('xmf'); $this->db = \XoopsDatabaseFactory::getDatabaseConnection(); $this->databaseName = XOOPS_DB_NAME; $this->resetQueue(); }
function __construct($id = null) { $this->db = XoopsDatabaseFactory::getDatabaseConnection(); $this->_dbtable = $this->db->prefix("gs_postcards"); $this->setNew(); $this->initVarsFromTable(); if ($id == null) { return; } /* if (!$this->loadValues(intval($id))) return; $this->unsetNew(); }*/ if (is_numeric($id)) { if (!$this->loadValues($id)) { return; } } else { $this->primary = 'code'; if ($this->loadValues($id)) { $this->unsetNew(); } $this->primary = 'id_post'; return; } $this->unsetNew(); }
function __construct($id = null, $res = 0) { $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); $this->_dbtable = $this->db->prefix("rd_sections"); $this->setNew(); $this->initVarsFromTable(); if ($id == null) { return; } if (is_numeric($id)) { if (!$this->loadValues($id)) { return; } $this->unsetNew(); } else { $sql = "SELECT * FROM " . $this->_dbtable . " WHERE nameid='{$id}' AND id_res='{$res}'"; $result = $this->db->query($sql); if ($this->db->getRowsNum($result) <= 0) { return; } $row = $this->db->fetchArray($result); $this->assignVars($row); $this->unsetNew(); } }
/** * Este archivo permite controlar el bloque o los bloques * Bloques Existentes: * * 1. Publicaciones Recientes * 2. Publicaciones Populares (Mas Leídas) * 3. Publicaciones Mejor Votadas */ function rd_block_resources($options) { global $xoopsModule; include_once XOOPS_ROOT_PATH . '/modules/docs/class/rdresource.class.php'; $db = XoopsDatabaseFactory::getDatabaseConnection(); $mc = RMUtilities::module_config('docs'); $sql = "SELECT * FROM " . $db->prefix("rd_resources") . ' WHERE public=1 AND approved=1'; switch ($options[0]) { case 'recents': $sql .= " ORDER BY created DESC"; break; case 'popular': $sql .= " ORDER BY `reads` DESC"; break; } $sql .= " LIMIT 0, " . ($options[1] > 0 ? $options[1] : 5); $result = $db->query($sql); $block = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $ret = array(); $ret['id'] = $res->id(); $ret['title'] = $res->getVar('title'); if ($options[2]) { $ret['desc'] = $options[3] == 0 ? $res->getVar('description') : TextCleaner::truncate($res->getVar('description'), $options[3]); } $ret['link'] = $res->permalink(); $ret['author'] = sprintf(__('Created by %s', 'docs'), '<strong>' . $res->getVar('owname') . '</strong>'); $ret['reads'] = sprintf(__('Viewed %s times', 'docs'), '<strong>' . $res->getVar('reads') . '</strong>'); $block['resources'][] = $ret; } RMTemplate::get()->add_style('blocks.css', 'docs'); return $block; }
public function __construct($id = null) { $this->db = XoopsDatabaseFactory::getDatabaseConnection(); $this->_dbtable = $this->db->prefix("bxpress_posts"); $this->setNew(); $this->initVarsFromTable(); $this->initVar('post_text', XOBJ_DTYPE_TXTAREA); $this->initVar('post_edit', XOBJ_DTYPE_TXTAREA); if (!isset($id)) { return; } if (!$this->loadValues($id)) { return; } $this->unsetNew(); // Cargamos el texto $sql = "SELECT * FROM " . $this->db->prefix("bxpress_posts_text") . " WHERE post_id='" . $this->id() . "'"; $result = $this->db->queryF($sql); if ($this->db->getRowsNum($result) <= 0) { return; } $this->havetext = true; $row = $this->db->fetchArray($result); $this->setVar('post_text', $row['post_text']); $this->setVar('post_edit', $row['post_edit']); }
/** * @param $ctable * @param null|array $id */ public function __construct($ctable, $id = null) { $this->ctable = $ctable; $this->db = XoopsDatabaseFactory::getDatabaseConnection(); parent::__construct(); $this->initVar('comment_id', XOBJ_DTYPE_INT, null, false); $this->initVar('item_id', XOBJ_DTYPE_INT, null, false); $this->initVar('order', XOBJ_DTYPE_INT, null, false); $this->initVar('mode', XOBJ_DTYPE_OTHER, null, false); $this->initVar('subject', XOBJ_DTYPE_TXTBOX, null, false, 255); $this->initVar('comment', XOBJ_DTYPE_TXTAREA, null, false, null); $this->initVar('ip', XOBJ_DTYPE_OTHER, null, false); $this->initVar('pid', XOBJ_DTYPE_INT, 0, false); $this->initVar('date', XOBJ_DTYPE_INT, null, false); $this->initVar('nohtml', XOBJ_DTYPE_INT, 1, false); $this->initVar('nosmiley', XOBJ_DTYPE_INT, 0, false); $this->initVar('noxcode', XOBJ_DTYPE_INT, 0, false); $this->initVar('user_id', XOBJ_DTYPE_INT, null, false); $this->initVar('icon', XOBJ_DTYPE_OTHER, null, false); $this->initVar('prefix', XOBJ_DTYPE_OTHER, null, false); if (!empty($id)) { if (is_array($id)) { $this->assignVars($id); } else { $this->load((int) $id); } } }
function __construct($id = null) { $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); $this->_dbtable = $this->db->prefix("dtrans_software_edited"); $this->setNew(); $this->initVarsFromTable(false); $this->setVarType('groups', XOBJ_DTYPE_ARRAY); $this->setVarType('fields', XOBJ_DTYPE_ARRAY); if ($id == null) { return; } if (is_numeric($id)) { $this->primary = "soft"; if ($this->loadValues($id)) { $this->unsetNew(); } $this->primary = "id_soft"; } else { $this->primary = "nameid"; if ($this->loadValues($id)) { $this->unsetNew(); } $this->primary = "id_soft"; } }
public function __construct($mydirname, $opt = array()) { global $xoopsUser, $xoopsModule; $this->xoopsUser = $xoopsUser; $this->xoopsModule = $xoopsModule; $this->isAdmin = is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid')); $this->mydirname = $mydirname; $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); $this->defaultVolumeOptions = array_merge($this->defaultVolumeOptions, $opt); $this->mygids = is_object($this->xoopsUser) ? $this->xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); if (!isset($_SESSION[_MD_XELFINDER_NETVOLUME_SESSION_KEY]) && is_object($this->xoopsUser)) { if ($uid = $this->xoopsUser->getVar('uid')) { $uid = intval($uid); $table = $this->db->prefix($this->mydirname . '_userdat'); $sql = 'SELECT `data` FROM `' . $table . '` WHERE `key`=\'netVolumes\' AND `uid`=' . $uid . ' LIMIT 1'; if ($res = $this->db->query($sql)) { if ($this->db->getRowsNum($res) > 0) { list($data) = $this->db->fetchRow($res); if ($data = @unserialize($data)) { $_SESSION[_MD_XELFINDER_NETVOLUME_SESSION_KEY] = $data; } } } } } }
/** * To prevent errors when upload images with closed site */ public function eventCoreIncludeCommonLanguage() { global $xoopsConfig; if ($xoopsConfig['cpanel'] != 'redmexico') { $db = XoopsDatabaseFactory::getDatabaseConnection(); $db->queryF("UPDATE " . $db->prefix("config") . " SET conf_value='redmexico' WHERE conf_modid=0 AND conf_catid=1 AND conf_name='cpanel'"); } /** * Check before to a rmcommon native module be installed */ $fct = RMHttpRequest::get('fct', 'string', ''); $op = RMHttpRequest::get('op', 'string', ''); if ('modulesadmin' == $fct && 'install' == $op) { $dirname = RMHttpRequest::get('module', 'string', ''); if ('' != $dirname) { $module = new XoopsModule(); $module->loadInfoAsVar($dirname); if ($module->getInfo('rmnative')) { RMUris::redirect_with_message(__('Please install %s using the modules manager from Common Utilities to prevent errors during install.', 'rmcommon'), RMCURL . '/modules.php?action=install&dir=' . $dirname, RMMSG_WARN); } } } if (RMUris::current_url() == RMCURL . '/include/upload.php' && $xoopsConfig['closesite']) { $security = rmc_server_var($_POST, 'rmsecurity', 0); $data = TextCleaner::getInstance()->decrypt($security, true); $data = explode("|", $data); // [0] = referer, [1] = session_id(), [2] = user, [3] = token $xoopsUser = new XoopsUser($data[0]); if ($xoopsUser->isAdmin()) { $xoopsConfig['closesite'] = 0; } } RMEvents::get()->run_event('rmcommon.include.common.language'); }
function __construct($id = null) { $this->db = XoopsDatabaseFactory::getDatabaseConnection(); $this->_dbtable = $this->db->prefix("mod_bxpress_topics"); $this->setNew(); $this->initVarsFromTable(); if (!isset($id)) { return; } /** * Cargamos los datos del foro */ if (is_numeric($id)) { if (!$this->loadValues($id)) { return; } $this->unsetNew(); } else { $this->primary = 'friendname'; if ($this->loadValues($id)) { $this->unsetNew(); } $this->primary = 'id_topic'; } }
function pw_categories_show($options) { global $xoopsModule, $xoopsModuleConfig; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwwork.class.php'; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php'; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php'; $db = XoopsDatabaseFactory::getDatabaseConnection(); if (isset($xoopsModule) && $xoopsModule->dirname() == 'works') { $mc =& $xoopsModuleConfig; } else { $mc =& RMUtilities::module_config('works'); } $db = XoopsDatabaseFactory::getDatabaseConnection(); $result = $db->query("SELECT * FROM " . $db->prefix("pw_categos") . " ORDER BY name"); $block = array(); while ($row = $db->fetchArray($result)) { $cat = new PWCategory(); $cat->assignVars($row); $ret = array(); $ret['name'] = $row['name']; $ret['link'] = $cat->link(); $block['categos'][] = $ret; } return $block; }
function search_resources() { global $xoopsConfig, $xoopsUser, $page, $xoopsTpl; $keyword = rmc_server_var($_GET, 'keyword', ''); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1"; list($num) = $db->fetchRow($db->query($sql)); $page = rmc_server_var($_GET, 'page', 1); $limit = 15; $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $start = $num <= 0 ? 0 : ($page - 1) * $limit; $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url(RDFunctions::make_link('search') . '?keyword=' . $keyword . '&page={PAGE_NUM}'); $sql = "SELECT * FROM " . $db->prefix("rd_resources") . " WHERE (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%') AND public=1 AND approved=1 LIMIT {$start}, {$limit}"; $result = $db->query($sql); $resources = array(); while ($row = $db->fetchArray($result)) { $res = new RDResource(); $res->assignVars($row); $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'desc' => TextCleaner::truncate($res->getVar('description'), 100), 'link' => $res->permalink(), 'created' => $res->getVar('created'), 'owner' => $res->getVar('owner'), 'uname' => $res->getVar('owname'), 'reads' => $res->getVar('reads')); } RDFunctions::breadcrumb(); RMBreadCrumb::get()->add_crumb(__('Browsing recent Documents', 'docs')); RMTemplate::get()->add_style('docs.css', 'docs'); include 'header.php'; $xoopsTpl->assign('xoops_pagetitle', sprintf(__('Search results for "%s"', 'docs'), $keyword)); include RMEvents::get()->run_event('docs.template.search', RMTemplate::get()->get_template('rd_search.php', 'module', 'docs')); include 'footer.php'; }
public function __construct() { $db = XoopsDatabaseFactory::getDatabaseConnection(); $result = $db->query("SELECT dirname FROM " . $db->prefix("modules") . " WHERE isactive='1'"); $i = 0; while (list($module) = $db->fetchRow($result)) { if (is_dir($dir = XOOPS_ROOT_PATH . "/modules/{$module}/events/")) { $file_list = XoopsLists::getFileListAsArray($dir); foreach ($file_list as $file) { if (preg_match('/(\\.php)$/i', $file)) { $file = substr($file, 0, -4); $this->_preloads[$i]['module'] = $module; $this->_preloads[$i]['file'] = $file; $i++; } } } } // Set Events foreach ($this->_preloads as $preload) { include_once XOOPS_ROOT_PATH . '/modules/' . $preload['module'] . '/events/' . $preload['file'] . '.php'; $class_name = ucfirst($preload['module']) . ucfirst($preload['file']) . 'Preload'; if (!class_exists($class_name)) { continue; } $class_methods = get_class_methods($class_name); foreach ($class_methods as $method) { if (strpos($method, 'event') === 0) { $event_name = strtolower(str_replace('event', '', $method)); $event = array('class_name' => $class_name, 'method' => $method); $this->_events[$event_name][] = $event; } } } }
public function __construct($id = '', $use_email = false, $pass = '') { $this->db = XoopsDatabaseFactory::getDatabaseConnection(); $this->_dbtable = $this->db->prefix("users"); $this->setNew(); $this->initVarsFromTable(); /** * Find user using the email */ if ($use_email) { if ('' == $id) { return null; } $this->primary = 'email'; if ($this->loadValues($id)) { $this->unsetNew(); } $this->primary = 'uid'; return true; } if ($id != '' && is_numeric($id) && $this->loadValues(intval($id))) { $this->unsetNew(); } elseif ($id != '') { $this->primary = 'uname'; if ($this->loadValues($id)) { $this->unsetNew(); } $this->primary = 'uid'; } }
/** * @desc Genera el código HTML para el campo */ public function render() { $rtn = "<script type='text/javascript' src='" . XOOPS_URL . "/modules/galleries/include/fieldusers.js'></script>"; $rtn .= "<div id='rmformUsers_" . $this->getName() . "'" . ($this->getExtra() != '' ? " " . $this->getExtra() : '') . ">\n\t\t\t\t<ul id='rmformUsersList_" . $this->getName() . "' style='list-style: none; margin: 0; padding: 0; overflow: hidden;'>"; $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($this->showall && in_array(0, $this->selected)) { $rtn .= "<li>\n\n\t\t\t\t\t\t<label><input type='" . ($this->multi ? 'checkbox' : 'radio') . "' name='" . ($this->multi ? $this->getName() . '[]' : $this->getName()) . "' id='" . ($this->multi ? $this->getName() . '[]' : $this->getName()) . "'\n\t\t\t\t \t\tvalue='0' checked='checked' /> " . _RMS_CF_ALLUSERS . "</label></li>"; } if (is_array($this->selected) && !empty($this->selected) && !(count($this->selected) == 1 && $this->selected[0] == 0)) { $sql = "SELECT uid,uname FROM " . $db->prefix("gs_users") . " WHERE "; $sql1 = ''; if ($this->multi) { foreach ($this->selected as $id) { if ($id != 0) { $sql1 .= $sql1 == '' ? "uid='{$id}'" : " OR uid='{$id}'"; } } } else { if ($this->selected[0] != 0) { $sql1 = "uid='" . $this->selected[0] . "'"; } } $result = $db->query($sql . $sql1); while ($row = $db->fetchArray($result)) { $rtn .= "<li>\n\n\t\t\t\t\t\t<label><input type='" . ($this->multi ? 'checkbox' : 'radio') . "' name='" . ($this->multi ? $this->getName() . '[]' : $this->getName()) . "' id='" . ($this->multi ? $this->getName() . '[]' : $this->getName()) . "'\n\t\t\t\t \t\tvalue='{$row['uid']}' checked='checked' /> {$row['uname']}</label></li>"; } } $rtn .= "</ul></div><br />\n\t\t\t\t<a href='javascript:;' onclick=\"selectGSUsers('" . $this->getForm() . "', '" . $this->getName() . ($this->multi ? "[]" : "") . "'," . $this->limit . ", '" . XOOPS_URL . "'," . $this->width . "," . $this->height . "," . ($this->multi ? 1 : 0) . "," . ($this->showall ? 1 : 0) . ",'{$this->_onchange}');\" style='background: url(" . XOOPS_URL . "/rmcommon/images/" . ($this->multi ? 'users.png' : 'user.png') . ") no-repeat left; padding: 3px 1px 3px 18px;'>" . ($this->multi ? _RMS_CF_SELUSERS : _RMS_CF_SELUSER) . "</a>"; return $rtn; }
/** * Save feature */ function dt_save_log($edit) { global $item, $log, $tpl, $xoopsTpl, $mc, $dtfunc; $query = ''; foreach ($_POST as $k => $v) { ${$k} = $v; } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { //Verificamos que la característica exista $lg = new DTLog($log); if ($lg->isNew()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Specified log does not exists!', 'dtransport')); } } else { $lg = new DTLog(); } $tc = TextCleaner::getInstance(); //Comprueba que el título de la característica no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_logs') . " WHERE title='{$title}' AND id_log!=" . $lg->id() . " AND id_soft=" . $item->id(); list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/edit/' . $lg->id() : '/?p=cpanel&action=logs&id=' . $item->id() . '/&op=edit&log=' . $lg->id()), 1, __('Another log with same title already exists!', 'dtransport')); } $lg->setSoftware($item->id()); $lg->setTitle($title); $lg->setLog($content); $lg->setDate(time()); if (!$lg->save()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Log could not be saved! Please try again.', 'dtransport')); } redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Log saved successfully!', 'dtransport')); }
/** * Assign vars to Smarty var, then this var can be used as index of the resource * @param int Id of the section parent * @param int Jumps (level) * @param object Resource (owner) * @param string Smarty var to append * @param string Index number to add (eg. 1.1) * @param bool Indicates if the array will be assigned to Smarty var or not * @param array Reference to an array for fill. * @return empty */ function assignSectionTree($parent = 0, $jumps = 0, AHResource $res, $var = 'index', $number = '', $assign = true, &$array = null) { global $tpl; $db = XoopsDatabaseFactory::getDatabaseConnection(); if (get_class($res) != 'AHResource') { return; } $sql = "SELECT * FROM " . $db->prefix("pa_sections") . " WHERE " . ($res->id() > 0 ? "id_res='" . $res->id() . "' AND" : '') . "\n\t\t\tparent='{$parent}' ORDER BY `order`"; $result = $db->query($sql); $sec = new AHSection(); $i = 1; // Counter $num = 1; while ($row = $db->fetchArray($result)) { $sec->assignVars($row); $link = ah_make_link($res->nameId() . '/' . $sec->nameId()); if ($assign) { $tpl->append($var, array('title' => $sec->title(), 'nameid' => $sec->nameId(), 'jump' => $jumps, 'link' => $link, 'number' => $jumps == 0 ? $num : ($number != '' ? $number . '.' : '') . $i)); } else { $array[] = array('title' => $sec->title(), 'nameid' => $sec->nameId(), 'jump' => $jumps, 'link' => $link, 'number' => $jumps == 0 ? $num : ($number != '' ? $number . '.' : '') . $i); } assignSectionTree($sec->id(), $jumps + 1, $res, $var, ($number != '' ? $number . '.' : '') . $i, $assign, $array); $i++; if ($jumps == 0) { $num++; } } return true; }
/** * @desc Elimina los temas especificados **/ function deleteTopics() { global $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsSecurity->check()) { redirectMsg('prune.php', __('Session token expired!', 'bxpress'), 0); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT id_topic FROM " . $db->prefix('bxpress_topics') . " WHERE "; $sql .= $forums == 0 ? '' : "id_forum='{$forums}' "; //Determinamos de que foro se va a limpiar temas $sql .= $forums ? " AND date<" . (time() - $days * 86400) : " date<" . (time() - $days * 86400); //Determinamos los temas con los dias de antigüedad especificados $sql .= $option == 2 ? " AND replies=0" : ''; //Determinamos los temas a eliminar $sql .= $fixed ? " AND sticky=1 " : ' AND sticky=0'; //Temas fijos $result = $db->queryF($sql); $num = $db->getRowsNum($result); while ($rows = $db->fetchArray($result)) { $topic = new BBTopic(); $topic->assignVars($rows); $topic->delete(); } redirectMsg('prune.php', sprintf(__('Prune done! %u topics deleted', 'bxpress'), $num), 0); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { global $xoopsDB; if (empty($xoopsDB)) { $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(true); } $this->object = new Tables(); }
/** * @param $table_name * @param $id_name * @param $pid_name */ function XoopsTree($table_name, $id_name, $pid_name) { $GLOBALS['xoopsLogger']->addDeprecated("Class '" . __CLASS__ . "' is deprecated, check 'XoopsObjectTree' in tree.php"); $this->db =& XoopsDatabaseFactory::getDatabaseConnection(); $this->table = $table_name; $this->id = $id_name; $this->pid = $pid_name; }
/** * Construct a string related to the system to make name less predictable * * @return string */ protected function systemSecret() { $db = \XoopsDatabaseFactory::getDatabaseConnection(); $prefix = $db->prefix(); $secret = md5($prefix); $secret = substr($secret, 8, 8); return $secret; }