function xoonips_change_uid($su_uid) { $u = new XoopsUser($su_uid); $groupids = $u->getGroups(); $_SESSION['xoopsUserId'] = $su_uid; $_SESSION["xoopsUserGroups"] = $groupids; }
/** * @desc Envía correo de aprobación de publicación * @param Object $res Publicación **/ function mail_approved(RDResource &$res) { global $xoopsModuleConfig, $xoopsConfig; $config_handler =& xoops_gethandler('config'); $mconfig = $config_handler->getConfigsByCat(XOOPS_CONF_MAILER); $errors = ''; $user = new XoopsUser($res->getVar('owner')); $member_handler =& xoops_gethandler('member'); $method = $user->getVar('notify_method'); $mailer = new RMMailer('text/plain'); $mailer->add_xoops_users($user); $mailer->set_subject(sprintf(__('Publication <%s> approved!', 'docs'), $res->getVar('title'))); $mailer->assign('dear_user', $user->getVar('name') != '' ? $user->getVar('name') : $user->getVar('uname')); $mailer->assign('link_to_resource', $res->permalink()); $mailer->assign('site_name', $xoopsConfig['sitename']); $mailer->assign('resource_name', $res->getVar('title')); $mailer->template(RMTemplate::get()->get_template('mail/resource_approved.php', 'module', 'docs')); switch ($method) { case '1': $mailer->set_from_xuser($mconfig['fromuid']); $ret = $mailer->send_pm(); break; case '2': $ret = $mailer->send(); break; } $page = rmc_server_var($_POST, 'page', 1); return $ret; }
/** * Shows all messages sent by users and stored in database */ function cm_show_messages() { global $xoopsDB, $xoopsModuleConfig, $xoopsSecurity; // Styles RMTemplate::get()->add_style('admin.css', 'contact'); // Pagination $page = rmc_server_var($_GET, 'page', 1); $page = $page <= 0 ? 1 : $page; $result = $xoopsDB->query("SELECT COUNT(*) FROM " . $xoopsDB->prefix("contactme")); list($num) = $xoopsDB->fetchRow($result); $limit = $xoopsModuleConfig['limit']; $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('index.php?page={PAGE_NUM}'); // Get messages $messages = array(); $result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("contactme") . " ORDER BY id_msg DESC LIMIT {$start},{$limit}"); $time = new RMTimeFormatter(0, __('%M% %d%, %Y%', 'contact')); while ($row = $xoopsDB->fetchArray($result)) { $msg = new CTMessage(); $msg->assignVars($row); if ($msg->getVar('xuid')) { $user = new XoopsUser($msg->getVar('xuid')); } $messages[] = array('id' => $msg->id(), 'subject' => $msg->getVar('subject'), 'ip' => $msg->getVar('ip'), 'email' => $msg->getVar('email'), 'name' => $msg->getVar('name'), 'company' => $msg->getVar('org'), 'body' => $msg->getVar('body'), 'phone' => $msg->getVar('phone'), 'register' => $msg->getVar('register'), 'xuid' => $msg->getVar('xuid'), 'uname' => $msg->getVar('xuid') > 0 ? $user->uname() : '', 'date' => $time->format($msg->getVar('date'))); } RMTemplate::get()->add_local_script('admin.js', 'contact'); RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon'); xoops_cp_header(); include RMTemplate::get()->get_template('admin/ct_dashboard.php', 'module', 'contact'); xoops_cp_footer(); }
/** * 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 b_weblog_links_show($options) { global $xoopsDB, $xoopsUser; $mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0]; $link_module = $options[1]; $link_num = $options[2]; $only_post = $options[3]; $showdsc = $options[4]; if ($only_post == "1") { if (!preg_match("|weblog\\d*/post\\.php\$|", $_SERVER['SCRIPT_NAME'])) { return false; } } $currentuid = !empty($xoopsUser) ? $xoopsUser->getVar('uid', 'E') : 0; $user_id = !empty($_GET['user_id']) ? intval($_GET['user_id']) : 0; $submitter = empty($user_id) ? $currentuid : $user_id; $block = array(); if (preg_match("/^mylinks\\d*\$/", $options[0])) { // in case of mylinks module $sql = sprintf('SELECT c.title as category, l.title as title, url, description as dsc FROM %s as c, %s as l, %s as d WHERE c.cid=l.cid and d.lid=l.lid and status=1 ', $xoopsDB->prefix($options[0] . '_cat'), $xoopsDB->prefix($options[0] . '_links'), $xoopsDB->prefix($options[0] . '_text')); if ($submitter) { $sql = sprintf('%s and submitter=%d', $sql, $submitter); } $sql .= " order by l.cid,l.date "; } elseif (preg_match("/^weblinks\\d*\$/", $options[0])) { // in case of weblink module $sql = sprintf('select link.title as title, link.url as url, link.description as dsc, cat.title as category from %s as cat, %s as link, %s as clink where link.lid=clink.lid and clink.cid=cat.cid ', $xoopsDB->prefix($options[0] . '_category'), $xoopsDB->prefix($options[0] . '_link'), $xoopsDB->prefix($options[0] . '_catlink')); if ($submitter) { $sql = sprintf('%s and link.uid=%d', $sql, $submitter); } $sql .= " order by clink.cid,clink.lid "; } if (!isset($sql)) { return array(); } $result = $xoopsDB->query($sql, $link_num, 0); while ($myrow = $xoopsDB->fetchArray($result)) { $category = $myrow['category']; if (!isset($block['links'][$category])) { $block['links'][$category] = array(); } $block['links'][$category][] = array("title" => $myrow['title'], "url" => $myrow['url'], "dsc" => $myrow['dsc']); } if ($submitter) { $blogOwner = new XoopsUser($submitter); $block['lang_whose'] = sprintf(_MB_WEBLOG_LANG_LINKS_FOR, $blogOwner->getVar('uname', 'E')); } else { $block['lang_whose'] = _MB_WEBLOG_LANG_LINKS_FOR_EVERYONE; } if ($showdsc) { $block['showdsc'] = 1; } return $block; }
/** * Check if given user is allowed * @param object XoopsUser object * @return bool */ public function user_allowed_toupload(XoopsUser $user) { $groups = $user->getGroups(); $allowed = $this->getVar('groups'); foreach ($groups as $id) { if (in_array($id, $allowed['write'])) { return true; } } return false; }
/** * @desc Obtiene el último usuario registrado * @return objeto {@link XoopsUser} */ function getLastUser() { $db = XoopsDatabaseFactory::getDatabaseConnection(); $result = $db->query("SELECT * FROM " . $db->prefix("users") . " WHERE level>'0' ORDER BY uid DESC LIMIT 0,1"); if ($db->getRowsNum($result) > 0) { $row = $db->fetchArray($result); $user = new XoopsUser(); $user->assignVars($row); return $user; } return false; }
/** * To prevent errors when upload images with closed site */ public function eventCoreIncludeCommonLanguage() { global $xoopsConfig; if (RMFunctions::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; } } }
function yogurt_iteminfo($category, $item_id) { $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname('yogurt'); if ($category == 'global') { $item['name'] = ''; $item['url'] = ''; return $item; } global $xoopsDB; if ($category == 'picture') { $sql = 'SELECT title,uid_owner,url FROM ' . $xoopsDB->prefix('yogurt_images') . ' WHERE uid_owner = ' . $item_id . ' LIMIT 1'; $result = $xoopsDB->query($sql); $result_array = $xoopsDB->fetchArray($result); /** * Let's get the user name of the owner of the album */ $owner = new XoopsUser(); $identifier = $owner->getUnameFromId($result_array['uid_owner']); $item['name'] = $identifier . "'s Album"; $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/album.php?uid=' . $result_array['uid_owner']; return $item; } if ($category == 'video') { $sql = 'SELECT video_id,uid_owner,video_desc,youtube_code, mainvideo FROM ' . $xoopsDB->prefix('yogurt_images') . ' WHERE uid_owner = ' . $item_id . ' LIMIT 1'; $result = $xoopsDB->query($sql); $result_array = $xoopsDB->fetchArray($result); /** * Let's get the user name of the owner of the album */ $owner = new XoopsUser(); $identifier = $owner->getUnameFromId($result_array['uid_owner']); $item['name'] = $identifier . "'s Videos"; $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/seutubo.php?uid=' . $result_array['uid_owner']; return $item; } if ($category == 'scrap') { $sql = 'SELECT scrap_id, scrap_from, scrap_to, scrap_text FROM ' . $xoopsDB->prefix('yogurt_scraps') . ' WHERE scrap_from = ' . $item_id . ' LIMIT 1'; $result = $xoopsDB->query($sql); $result_array = $xoopsDB->fetchArray($result); /** * Let's get the user name of the owner of the album */ $owner = new XoopsUser(); $identifier = $owner->getUnameFromId($result_array['scrap_from']); $item['name'] = $identifier . "'s Scraps"; $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/scrapbook.php?uid=' . $result_array['scrap_from']; return $item; } }
function b_marquee_xfsection($limit, $dateformat, $itemssize) { $block = array(); global $xoopsDB; if (!function_exists('xfblock_checkAccess')) { include_once XOOPS_ROOT_PATH . "/modules/xfsection/include/xfblock_groupaccess.php"; } $myts =& MyTextSanitizer::getInstance(); $sql = "SELECT articleid, title, published, expired, counter, groupid, uid FROM " . $xoopsDB->prefix("xfs_article") . " WHERE published < " . time() . " AND published > 0 AND (expired = 0 OR expired > " . time() . ") AND noshowart = 0 AND offline = 0 ORDER BY published DESC"; $result = $xoopsDB->query($sql, $limit, 0); while ($myrow = $xoopsDB->fetchArray($result)) { if (xfblock_checkAccess($myrow["groupid"])) { $wfs = array(); $title = $myts->htmlSpecialChars($myrow["title"]); if (!XOOPS_USE_MULTIBYTES) { if ($itemssize > 0) { $title = $myts->htmlSpecialChars(substr($myrow['title'], 0, $itemssize - 1)); } else { $title = $myts->htmlSpecialChars($myrow['title']); } } $block[] = array('date' => formatTimestamp($myrow['published'], $dateformat), 'category' => '', 'author' => XoopsUser::getUnameFromId($myrow['uid']), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/xfsection/article.php?articleid=' . $myrow['articleid'] . "'>" . $title . '</a>'); } } return $block; }
function tadgallery_show_re($options) { global $xoopsDB; $limit = empty($options[0]) ? 10 : intval($options[0]); $userinfo = empty($options[1]) ? 0 : intval($options[1]); $showall = empty($options[2]) ? 0 : intval($options[2]); $modhandler =& xoops_gethandler('module'); $xoopsModule =& $modhandler->getByDirname("tadgallery"); $com_modid = $xoopsModule->getVar('mid'); $sql = "select a.com_id,a.com_text,a.com_itemid,a.com_uid,b.title,b.filename,b.uid from " . $xoopsDB->prefix("xoopscomments") . " as a left join " . $xoopsDB->prefix("tad_gallery") . " as b on a.com_itemid=b.sn where a.com_modid='{$com_modid}' order by a.com_modified desc limit 0,{$limit}"; $result = $xoopsDB->query($sql); $block = $comment = ""; $i = 0; while (list($com_id, $txt, $nsn, $uid, $title, $filename, $poster_uid) = $xoopsDB->fetchRow($result)) { $uid_name = XoopsUser::getUnameFromId($uid, 1); $poster_uid_name = XoopsUser::getUnameFromId($poster_uid, 1); $comment[$i]['uid'] = $uid; $comment[$i]['uid_name'] = empty($uid_name) ? XoopsUser::getUnameFromId($uid, 0) : $uid_name; $comment[$i]['poster_uid'] = $poster_uid; $comment[$i]['poster_uid_name'] = empty($poster_uid_name) ? XoopsUser::getUnameFromId($poster_uid, 0) : $poster_uid_name; $comment[$i]['nsn'] = $nsn; $comment[$i]['com_id'] = $com_id; $comment[$i]['txt'] = $txt; $comment[$i]['title'] = empty($title) ? $filename : $title; $i++; } $block['showall'] = $showall; $block['userinfo'] = $userinfo; $block['comment'] = $comment; return $block; }
public function get($key) { if (isset($this->vars[$key]) === true) { return parent::get($key); } return $this->_getProfile($key); }
function mypics_iteminfo($category, $item_id) { $item['name'] = ''; $item['url'] = ''; if ($category == 'picture') { global $xoopsDB; $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname('mypics'); $sql = 'SELECT title, uid, url FROM ' . $xoopsDB->prefix('yogurt_images') . ' WHERE uid = ' . $item_id . ' LIMIT 1'; $result = $xoopsDB->query($sql); $result_array = $xoopsDB->fetchArray($result); $owner = new XoopsUser(); $identifier = $owner->getUnameFromId($result_array['uid']); $item['name'] = $identifier . "'s Album"; $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/index.php?uid=' . $result_array['uid']; } return $item; }
function b_mp_cont_show($options) { global $xoopsDB, $xoopsUser, $xoopsModuleConfig, $HTTP_SERVER_VARS; if (is_object($xoopsUser)) { $uid = $xoopsUser->getVar('uid'); $uname = $xoopsUser->getVar('uname'); } else { $uid = 0; $uname = ''; } $block = array(); if (!is_object($xoopsUser)) { $block['lang_none'] = _MP_BL_YOUDONTHAVE; } else { $online = 0; $offline = 0; $user = ''; $cont_handler =& xoops_gethandler('priv_msgscont'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('ct_userid', $xoopsUser->getVar('uid'))); $amount = $cont_handler->getCount($criteria); $criteria->setSort('ct_uname'); $criteria->setOrder('desc'); $pm_cont =& $cont_handler->getObjects($criteria); foreach (array_keys($pm_cont) as $i) { $poster = new XoopsUser($pm_cont[$i]->getVar('ct_contact')); /* Online poster */ if ($poster->isOnline()) { $user .= "<a href='javascript:openWithSelfMain(\"" . XOOPS_URL . "/pmlite.php?send2=1&to_userid=" . $pm_cont[$i]->getVar('ct_contact') . "\",\"pmlite\", 450, 380)'>" . $poster->getVar('uname') . "</a>, "; $online++; } else { $offline++; } } $block['online_total'] = $amount; $block['online'] = $online; $block['offline'] = $offline; $block['user'] = $user; $block['lang_online'] = _MP_BLOCK_ONLINE; $block['lang_offline'] = _MP_BLOCK_OFFLINE; $block['lang_contact'] = _MP_BLOCK_CONTACT; } return $block; }
function get_submitter_info($uid) { if ($uid <= 0) { return _GUESTS; } $poster = new XoopsUser($uid); // check if invalid uid if ($poster->uname() == '') { return ''; } if ($this->nameoruname == 'uname') { $name = $poster->uname(); } else { $name = trim($poster->name()); if ($name == "") { $name = $poster->uname(); } } return "<a href='" . XOOPS_URL . "/userinfo.php?uid={$uid}'>{$name}</a>"; }
public function getValues($keys = null, $format = null, $maxDepth = null) { $page = Page::getInstance(); $ret = parent::getValues($keys, $format, $maxDepth); $ret['rating'] = number_format($this->getVar('content_rating'), 1); // these next two lines are rather silly $ret['content_authorid'] = $this->getVar('content_author'); $ret['content_author'] = XoopsUser::getUnameFromId($this->getVar('content_author'), true); $ret['content_date'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_dateformat')); $ret['content_time'] = XoopsLocale::formatTimestamp($this->getVar('content_create'), $page->getConfig('page_timeformat')); $ret['content_rating'] = number_format($this->getVar('content_rating'), 2); return $ret; }
function addOptionUsers($gid = 0) { list($cuid) = $this->getValue(); $max = _CC_MAX_USERS; $start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : 0; $users = cc_group_users($gid, $max, $start); $opts = $this->getOptions(); // force insert current if none if ($cuid && !isset($users[$cuid]) && !isset($opts[$cuid])) { $users[$cuid] = XoopsUser::getUnameFromId($cuid); } $this->addOptionArray($users); $this->setPageNav($gid); }
/** * Returns the user name for the current keyword (if the parameter is null) */ function uname($uid = 0) { global $xoopsConfig; static $tblusers = array(); $option = -1; if (empty($uid)) { $uid = $this->getVar('uid'); } if (is_array($tblusers) && array_key_exists($uid, $tblusers)) { return $tblusers[$uid]; } $tblusers[$uid] = XoopsUser::getUnameFromId($uid); return $tblusers[$uid]; }
function showReports() { global $xoopsModule, $xoopsConfig, $xoopsSecurity; //Indica la lista a mostrar $show = isset($_REQUEST['show']) ? intval($_REQUEST['show']) : '0'; //$show = 0 Muestra todos los reportes //$show = 1 Muestra los reportes revisados //$show = 2 Muestra los reportes no revisados define('RMCSUBLOCATION', $show == 0 ? 'allreps' : ($show == 1 ? 'reviews' : 'noreviewd')); $db = XoopsDatabaseFactory::getDatabaseConnection(); //Lista de Todos los reportes $sql = "SELECT * FROM " . $db->prefix('mod_bxpress_report') . ($show ? $show == 1 ? " WHERE zapped=1" : " WHERE zapped=0 " : '') . " ORDER BY report_time DESC"; $result = $db->queryF($sql); $reports = array(); $tf = new RMTimeFormatter(0, '%T% %d%, %Y% %h%:%i%:%s%'); while ($rows = $db->fetchArray($result)) { $report = new bXReport(); $report->assignVars($rows); $user = new XoopsUser($report->user()); $post = new bXPost($report->post()); $topic = new bXTopic($post->topic()); $forum = new bXForum($post->forum()); if ($report->zappedBy() > 0) { $zuser = new XoopsUser($report->zappedBy()); } $reports[] = array('id' => $report->id(), 'post' => array('link' => $post->permalink(), 'id' => $report->post()), 'user' => $user->uname(), 'uid' => $user->uid(), 'date' => $tf->format($report->time()), 'report' => $report->report(), 'forum' => array('link' => $forum->permalink(), 'name' => $forum->name()), 'topic' => array('link' => $topic->permalink(), 'title' => $topic->title()), 'zapped' => $report->zapped(), 'zappedby' => $report->zappedby() > 0 ? array('uid' => $zuser->uid(), 'name' => $zuser->uname()) : '', 'zappedtime' => $report->zappedtime() > 0 ? $tf->format($report->zappedtime()) : ''); } RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('admin.js', 'bxpress'); RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/introduccion/standalone/1/'); RMTemplate::get()->assign('xoops_pagetitle', __('Reports Management', 'bxpress')); $bc = RMBreadCrumb::get(); $bc->add_crumb(__('Reports management', 'bxpress')); xoops_cp_header(); include RMTemplate::get()->get_template('admin/forums-reports.php', 'module', 'bxpress'); xoops_cp_footer(); }
function b_marquee_xfaq($limit, $dateformat, $itemssize) { include_once XOOPS_ROOT_PATH . '/modules/marquee/include/functions.php'; $block = array(); $myts =& MyTextSanitizer::getInstance(); $db =& Database::getInstance(); $result = $db->query("SELECT f.*, t.topic_title, t.topic_submitter FROM " . $db->prefix("xfaq_faq") . " f, " . $db->prefix("xfaq_topic") . " t WHERE f.faq_online>0 AND (f.faq_topic=t.topic_id) ORDER BY faq_date_created DESC", $limit, 0); while ($myrow = $db->fetchArray($result)) { $title = $myts->htmlSpecialChars($myrow["faq_question"]); if ($itemssize > 0) { $title = xoops_substr($title, 0, $itemssize + 3); } $block[] = array('date' => formatTimestamp($myrow['faq_date_created'], $dateformat), 'category' => $myts->htmlSpecialChars($myrow['topic_title']), 'author' => XoopsUser::getUnameFromId(intval($myrow['topic_submitter'])), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . "/modules/xfaq/faq.php?faq_id=" . $myrow['faq_id'] . "'>{$title}</a>"); } return $block; }
/** * @param int $uid * @param string $subject * @param string $body * @return bool */ private function sendPM($uid, $subject, $body) { $xoops = Xoops::getInstance(); $pm_handler = $xoops->getHandlerPrivmessage(); $pm = $pm_handler->create(); $pm->setVar("subject", $subject); // RMV-NOTIFY $pm->setVar('from_userid', !empty($this->fromUser) ? $this->fromUser->getVar('uid') : (!$xoops->isUser() ? 1 : $xoops->user->getVar('uid'))); $pm->setVar("msg_text", $body); $pm->setVar("to_userid", $uid); $pm->setVar('msg_time', time()); if (!$pm_handler->insert($pm)) { return false; } return true; }
function b_marquee_catads($limit, $dateformat, $itemssize) { global $xoopsModule, $xoopsModuleConfig, $xoopsDB; include_once XOOPS_ROOT_PATH . '/modules/catads/class/cat.php'; $block = array(); if (empty($xoopsModule) || $xoopsModule->getVar('dirname') != 'catads') { $module_handler =& xoops_gethandler('module'); $module =& $module_handler->getByDirname('catads'); $config_handler =& xoops_gethandler('config'); $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); } else { $module =& $xoopsModule; $config =& $xoopsModuleConfig; } //echo '<br />ok'; $ads_hnd =& xoops_getmodulehandler('ads', 'catads'); $criteria = new CriteriaCompo(new Criteria('waiting', '0')); $criteria->add(new Criteria('published', time(), '<')); $criteria->add(new Criteria('expired', time(), '>')); $criteria->setSort('published'); $criteria->setOrder('DESC'); $criteria->setLimit($options[0]); $nbads = $ads_hnd->getCount($criteria); $a_item = array(); $cat_buffer = array(); if ($nbads > 0) { $ads = $ads_hnd->getObjects($criteria); $ts =& MyTextSanitizer::getInstance(); foreach ($ads as $oneads) { if ($itemssize > 0) { $title = xoops_substr($oneads->getVar('ads_title'), 0, $itemssize); } else { $title = $oneads->getVar('ads_title'); } if (!isset($cat_buffer[$oneads->getVar('cat_id')])) { $tmpcat = new AdsCategory($oneads->getVar('cat_id')); $cat_buffer[$oneads->getVar('cat_id')] = $tmpcat->title(); $cat_title = $tmpcat->title(); } else { $cat_title = $cat_buffer[$oneads->getVar('cat_id')]; } $block[] = array('date' => formatTimestamp($oneads->getVar('published'), $dateformat), 'category' => '', 'author' => XoopsUser::getUnameFromId($oneads->getVar('uid')), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/catads/adsitem.php?ads_id=' . $oneads->getVar('ads_id') . "'>" . $title . '</a>'); unset($a_item); } } return $block; }
function getShouts($online, $bbcode, $limit) { global $xoopsUser; $shouts = array(); $myts =& MyTextSanitizer::getInstance(); $objs = $this->handler->getShouts($limit); $i = 0; foreach ($objs as $obj) { $uid = $obj->getVar('uid'); $shouts[$i]['uid'] = $uid; $shouts[$i]['online'] = 0; $shouts[$i]['url'] = ''; $shouts[$i]['email'] = ''; $shouts[$i]['avatar'] = $this->getDefaultAvatar(); $shouts[$i]['uname'] = $obj->getVar('uname'); $shouts[$i]['time'] = $obj->time(shoutbox_getOption('stamp_format')); $shouts[$i]['ip'] = $obj->getVar('ip'); $obj->setVar('doxcode', $bbcode); $shouts[$i]['message'] = $myts->censorString($obj->getVar('message')); if ($wordwrap = shoutbox_getOption('wordwrap_setting')) { $shouts[$i]['message'] = wordwrap($shouts[$i]['message'], $wordwrap, "\r\n", true); } if ($uid != 0) { $thisUser = new XoopsUser($uid); if ($thisUser->isOnline()) { $shouts[$i]['online'] = 1; } if ($thisUser->getVar("url") != "") { $shouts[$i]['url'] = $thisUser->getVar("url"); } if ($thisUser->getVar("user_viewemail") == 1 || $xoopsUser && $xoopsUser->isAdmin()) { $shouts[$i]['email'] = $thisUser->getVar("email"); } $shouts[$i]['avatar'] = XOOPS_URL . '/uploads/' . $thisUser->getVar("user_avatar"); } $i++; } return $shouts; }
/** * Send a message to user's email * @param object $pm {@link XoopsPrivmessage} object * @param object $user * @return bool **/ function sendEmail(&$pm, &$user) { global $xoopsConfig; if (!is_object($user)) { $user =& $GLOBALS["xoopsUser"]; } $msg = sprintf(_PM_EMAIL_DESC, $user->getVar("uname")); $msg .= "\n\n"; $msg .= formatTimestamp($pm->getVar("msg_time")); $msg .= "\n"; $from = new XoopsUser($pm->getVar("from_userid")); $to = new XoopsUser($pm->getVar("to_userid")); $msg .= sprintf(_PM_EMAIL_FROM, $from->getVar("uname") . " (" . XOOPS_URL . "/userinfo.php?uid=" . $pm->getVar("from_userid") . ")"); $msg .= "\n"; $msg .= sprintf(_PM_EMAIL_TO, $to->getVar("uname") . " (" . XOOPS_URL . "/userinfo.php?uid=" . $pm->getVar("to_userid") . ")"); $msg .= "\n"; $msg .= _PM_EMAIL_MESSAGE . ":\n"; $msg .= "\n" . $pm->getVar("subject") . "\n"; $msg .= "\n" . strip_tags(str_replace("<p>", "\n", str_replace("</p>", "\n", str_replace("<br>", "\n", str_replace("<br />", "\n", $pm->getVar("msg_text")))))) . "\n\n"; $msg .= "--------------\n"; $msg .= $xoopsConfig['sitename'] . ": " . XOOPS_URL . "\n"; $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setToEmails($user->getVar("email")); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject(sprintf(_PM_EMAIL_SUBJECT, $pm->getVar("subject"))); $xoopsMailer->setBody($msg); return $xoopsMailer->send(); }
$total_messages = !empty($_GET['total_messages']) ? intval($_GET['total_messages']) : 0; include XOOPS_ROOT_PATH . '/header.php'; $criteria = new Criteria('to_userid', $xoopsUser->getVar('uid')); $criteria->setLimit(1); $criteria->setStart($start); $criteria->setSort('msg_time'); $pm_arr =& $pm_handler->getObjects($criteria); echo "<div><h4>" . _PM_PRIVATEMESSAGE . "</h4></div><br /><a href='userinfo.php?uid=" . $xoopsUser->getVar("uid") . "'>" . _PM_PROFILE . "</a> <span style='font-weight:bold;'>»»</span> <a href='viewpmsg.php'>" . _PM_INBOX . "</a> <span style='font-weight:bold;'>»»</span> \n"; if (empty($pm_arr)) { echo '<br /><br />' . _PM_YOUDONTHAVE; } else { if (!$pm_handler->setRead($pm_arr[0])) { //echo "failed"; } echo $pm_arr[0]->getVar("subject") . "<br /><form action='readpmsg.php' method='post' name='delete" . $pm_arr[0]->getVar("msg_id") . "'><table border='0' cellpadding='4' cellspacing='1' class='outer' width='100%'><tr><th colspan='2'>" . _PM_FROM . "</th></tr><tr class='even'>\n"; $poster = new XoopsUser($pm_arr[0]->getVar("from_userid")); if (!$poster->isActive()) { $poster = false; } echo "<td valign='top'>"; if ($poster != false) { // we need to do this for deleted users echo "<a href='userinfo.php?uid=" . $poster->getVar("uid") . "'>" . $poster->getVar("uname") . "</a><br />\n"; if ($poster->getVar("user_avatar") != "") { echo "<img src='uploads/" . $poster->getVar("user_avatar") . "' alt='' /><br />\n"; } if ($poster->getVar("user_from") != "") { echo _PM_FROMC . "" . $poster->getVar("user_from") . "<br /><br />\n"; } if ($poster->isOnline()) { echo "<span style='color:#ee0000;font-weight:bold;'>" . _PM_ONLINE . "</span><br /><br />\n";
/** * Add Users as recipients for message. * Users can be passed as object or as ids * * @param array Users (ids or objects) */ public function add_users($users, $field = 'to') { if (!is_array($users)) { return; } foreach ($users as $user) { if (is_a($user, "XoopsUser")) { $this->add_user($user->gatVar('email'), $user->getVar('name') != '' ? $user->getVar('name') : $user->getVar('uname'), $field); } else { $user = new XoopsUser($user); if ($user->isNew()) { continue; } $this->add_user($user->getVar('email'), $user->getVar('name') != '' ? $user->getVar('name') : $user->getVar('uname'), $field); } } }
/** * This function deletes all image formats, except thumbnails, for specified albums. * This is useful when you need to regenerate images */ function delete_formats() { global $xoopsModuleConfig; $id = rmc_server_var($_GET, 'id', 0); $page = rmc_server_var($_GET, 'page', 1); if ($id <= 0) { redirectMsg("sets.php?page={$page}", __('Sorry, this is not a valid album!', 'galleries'), 1); die; } $set = new GSSet($id); if ($set->isNew()) { redirectMsg("sets.php?page={$page}", __('Specified Album does not exists!', 'galleries'), 1); die; } $db = Database::getInstance(); $t1 = $db->prefix("gs_images"); $t2 = $db->prefix("gs_setsimages"); $sql = "SELECT a.image FROM {$t1} a, {$t2} b WHERE b.id_set={$id} AND a.id_image=b.id_image"; $result = $db->query($sql); $dir = rtrim($xoopsModuleConfig['storedir'], '/'); if ($set->uname() == '') { $user = new XoopsUser($set->owner()); $uname = $user->uname(); } else { $uname = $set->uname(); } if ($uname == '') { redirectMsg('sets.php?page=' . $page, __('Sorry, we were unable to find the album owner!', 'galleries'), 1); break; } $dir .= '/' . $uname . '/formats'; if (!is_dir($dir)) { redirectMsg('sets.php?page=' . $page, __('There are not image formats for this album.', 'galleries'), 0); die; } while (list($image) = $db->fetchRow($result)) { @unlink($dir . '/bigset_' . $image); @unlink($dir . '/set_' . $image); @unlink($dir . '/user_' . $image); @unlink($dir . '/srh_' . $image); } $pics = $set->getPics(); $sql = "UPDATE {$t1} SET user_format=0, set_format=0, bigset_format=0, search_format=0 WHERE id_image IN (" . implode(",", $pics) . ")"; $db->queryF($sql); redirectMsg('sets.php?page=' . $page, __('Image formats deleted!', 'galleries'), 0); }
function uname() { return XoopsUser::getUnameFromId($this->uid); }
function modLink() { global $xoopsDB, $myts, $eh, $mytree, $xoopsConfig; $linkimg_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . "/modules/mylinks/images/shots/"); $lid = $_GET['lid']; xoops_cp_header(); echo "<h4>" . _MD_WEBLINKSCONF . "</h4>"; echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr class=\"odd\"><td>"; $result = $xoopsDB->query("select cid, title, url, logourl from " . $xoopsDB->prefix("mylinks_links") . " where lid={$lid}") or $eh->show("0013"); echo "<h4>" . _MD_MODLINK . "</h4><br />"; list($cid, $title, $url, $logourl) = $xoopsDB->fetchRow($result); $title = $myts->makeTboxData4Edit($title); $url = $myts->makeTboxData4Edit($url); // $url = urldecode($url); $logourl = $myts->makeTboxData4Edit($logourl); // $logourl = urldecode($logourl); $result2 = $xoopsDB->query("select description from " . $xoopsDB->prefix("mylinks_text") . " where lid={$lid}"); list($description) = $xoopsDB->fetchRow($result2); $GLOBALS['description'] = $myts->makeTareaData4Edit($description); echo "<table>"; echo "<form method='post' action='index.php'>"; echo "<tr><td>" . _MD_LINKID . "</td><td><b>{$lid}</b></td></tr>"; echo "<tr><td>" . _MD_SITETITLE . "</td><td><input type='text' name='title' value=\"{$title}\" size='50' maxlength='100' /></td></tr>\n"; echo "<tr><td>" . _MD_SITEURL . "</td><td><input type='text' name='url' value=\"{$url}\" size='50' maxlength='250' /></td></tr>\n"; echo "<tr><td valign=\"top\">" . _MD_DESCRIPTIONC . "</td><td>"; xoopsCodeTarea("description", 60, 8); xoopsSmilies("description"); //echo "<textarea name=description cols=60 rows=5>$description</textarea>"; echo "</td></tr>"; echo "<tr><td>" . _MD_CATEGORYC . "</td><td>"; $mytree->makeMySelBox("title", "title", $cid); echo "</td></tr>\n"; echo "<tr><td>" . _MD_SHOTIMAGE . "</td><td>"; //echo "<input type=text name=logourl value=\"$logourl\" size=\"50\" maxlength=\"60\"></input> echo "<select size='1' name='logourl'>"; echo "<option value=' '>------</option>"; foreach ($linkimg_array as $image) { if ($image == $logourl) { $opt_selected = "selected='selected'"; } else { $opt_selected = ""; } echo "<option value='" . $image . "' {$opt_selected}>" . $image . "</option>"; } echo "</select>"; echo "</td></tr>\n"; $shotdir = "<b>" . XOOPS_URL . "/modules/mylinks/images/shots/</b>"; echo "<tr><td></td><td>"; printf(_MD_SHOTMUST, $shotdir); echo "</td></tr>\n"; echo "</table>"; echo "<br /><br /><input type='hidden' name='lid' value='{$lid}' />\n"; echo "<input type='hidden' name='op' value='modLinkS' /><input type='submit' value='" . _MD_MODIFY . "' />"; echo "</form>\n"; echo "<table><tr><td>\n"; echo myTextForm("index.php?op=delLink&lid=" . $lid, _MD_DELETE); echo "</td><td>\n"; echo myTextForm("index.php?op=linksConfigMenu", _MD_CANCEL); echo "</td></tr></table>\n"; echo "<hr />"; $result5 = $xoopsDB->query("SELECT count(*) FROM " . $xoopsDB->prefix("mylinks_votedata") . " WHERE lid = {$lid}"); list($totalvotes) = $xoopsDB->fetchRow($result5); echo "<table width='100%'>\n"; echo "<tr><td colspan='7'><b>"; printf(_MD_TOTALVOTES, $totalvotes); echo "</b><br /><br /></td></tr>\n"; // Show Registered Users Votes $result5 = $xoopsDB->query("SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM " . $xoopsDB->prefix("mylinks_votedata") . " WHERE lid = {$lid} AND ratinguser >0 ORDER BY ratingtimestamp DESC"); $votes = $xoopsDB->getRowsNum($result5); echo "<tr><td colspan='7'><br /><br /><b>"; printf(_MD_USERTOTALVOTES, $votes); echo "</b><br /><br /></td></tr>\n"; echo "<tr><td><b>" . _MD_USER . " </b></td><td><b>" . _MD_IP . " </b></td><td><b>" . _MD_RATING . " </b></td><td><b>" . _MD_USERAVG . " </b></td><td><b>" . _MD_TOTALRATE . " </b></td><td><b>" . _MD_DATE . " </b></td><td align=\"center\"><b>" . _MD_DELETE . "</b></td></tr>\n"; if ($votes == 0) { echo "<tr><td align=\"center\" colspan=\"7\">" . _MD_NOREGVOTES . "<br /></td></tr>\n"; } $x = 0; $colorswitch = "dddddd"; while (list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp) = $xoopsDB->fetchRow($result5)) { // $ratingtimestamp = formatTimestamp($ratingtimestamp); //Individual user information $result2 = $xoopsDB->query("SELECT rating FROM " . $xoopsDB->prefix("mylinks_votedata") . " WHERE ratinguser = '******'"); $uservotes = $xoopsDB->getRowsNum($result2); $useravgrating = 0; while (list($rating2) = $xoopsDB->fetchRow($result2)) { $useravgrating = $useravgrating + $rating2; } $useravgrating = $useravgrating / $uservotes; $useravgrating = number_format($useravgrating, 1); $ratingusername = XoopsUser::getUnameFromId($ratinguser); echo "<tr><td bgcolor=\"" . $colorswitch . "\">" . $ratingusername . "</td><td bgcolor=\"{$colorswitch}\">" . $ratinghostname . "</td><td bgcolor=\"{$colorswitch}\">{$rating}</td><td bgcolor=\"{$colorswitch}\">" . $useravgrating . "</td><td bgcolor=\"{$colorswitch}\">" . $uservotes . "</td><td bgcolor=\"{$colorswitch}\">" . $ratingtimestamp . "</td><td bgcolor=\"{$colorswitch}\" align=\"center\"><b>" . myTextForm("index.php?op=delVote&lid={$lid}&rid={$ratingid}", "X") . "</b></td></tr>\n"; $x++; if ($colorswitch == "dddddd") { $colorswitch = "ffffff"; } else { $colorswitch = "dddddd"; } } // Show Unregistered Users Votes $result5 = $xoopsDB->query("SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM " . $xoopsDB->prefix("mylinks_votedata") . " WHERE lid = {$lid} AND ratinguser = 0 ORDER BY ratingtimestamp DESC"); $votes = $xoopsDB->getRowsNum($result5); echo "<tr><td colspan='7'><b><br /><br />"; printf(_MD_ANONTOTALVOTES, $votes); echo "</b><br /><br /></td></tr>\n"; echo "<tr><td colspan='2'><b>" . _MD_IP . " </b></td><td colspan='3'><b>" . _MD_RATING . " </b></td><td><b>" . _MD_DATE . " </b></b></td><td align=\"center\"><b>" . _MD_DELETE . "</b></td><br /></tr>"; if ($votes == 0) { echo "<tr><td colspan=\"7\" align=\"center\">" . _MD_NOUNREGVOTES . "<br /></td></tr>"; } $x = 0; $colorswitch = "dddddd"; while (list($ratingid, $rating, $ratinghostname, $ratingtimestamp) = $xoopsDB->fetchRow($result5)) { $formatted_date = formatTimestamp($ratingtimestamp); echo "<td colspan=\"2\" bgcolor=\"{$colorswitch}\">{$ratinghostname}</td><td colspan=\"3\" bgcolor=\"{$colorswitch}\">{$rating}</td><td bgcolor=\"{$colorswitch}\">{$formatted_date}</td><td bgcolor=\"{$colorswitch}\" aling=\"center\"><b>" . myTextForm("index.php?op=delVote&lid={$lid}&rid={$ratingid}", "X") . "</b></td></tr>"; $x++; if ($colorswitch == "dddddd") { $colorswitch = "ffffff"; } else { $colorswitch = "dddddd"; } } echo "<tr><td colspan=\"6\"> <br /></td></tr>\n"; echo "</table>\n"; echo "</td></tr></table>"; xoops_cp_footer(); }
/** * Get a list of users belonging to certain groups and matching criteria * Temporary solution * * @param int $groups IDs of groups * @param object $criteria {@link CriteriaElement} object * @param bool $asobject return the users as objects? * @param bool $id_as_key use the UID as key for the array if $asobject is TRUE * @return array Array of {@link XoopsUser} objects (if $asobject is TRUE) * or of associative arrays matching the record structure in the database. */ function getUsersByGroupLink($groups, $criteria = null, $asobject = false, $id_as_key = false) { $ret = array(); $select = $asobject ? "u.*" : "u.uid"; $sql[] = " SELECT DISTINCT {$select} " . " FROM " . $this->_uHandler->db->prefix("users") . " AS u" . " LEFT JOIN " . $this->_mHandler->db->prefix("groups_users_link") . " AS m ON m.uid = u.uid" . " WHERE 1 = 1"; if (!empty($groups)) { $sql[] = "m.groupid IN (" . implode(", ", $groups) . ")"; } $limit = $start = 0; if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) { $sql_criteria = $criteria->render(); if ($criteria->getSort() != '') { $sql_criteria .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder(); } $limit = $criteria->getLimit(); $start = $criteria->getStart(); if ($sql_criteria) { $sql[] = $sql_criteria; } } $sql_string = implode(" AND ", array_filter($sql)); if (!($result = $this->_uHandler->db->query($sql_string, $limit, $start))) { return $ret; } while ($myrow = $this->_uHandler->db->fetchArray($result)) { if ($asobject) { $user = new XoopsUser(); $user->assignVars($myrow); if (!$id_as_key) { $ret[] =& $user; } else { $ret[$myrow['uid']] =& $user; } unset($user); } else { $ret[] = $myrow['uid']; } } return $ret; }