function _replaceWildCards(&$operator, &$value) { $changes = false; if (is_array($value)) { foreach (array_keys($value) as $k) { $changes = $this->_replaceWildCards($operator, $value[$k]) || $changes; } } else { $escSearch = str_replace('|*|', '|`|', $value); if (strpos($escSearch, '*') !== false) { $escSearch = cbEscapeSQLsearch($escSearch); $escSearch = str_replace('*', '%', $escSearch); $value = str_replace('|`|', '|*|', $escSearch); $operator = $this->_operatorToLike($operator); $changes = true; } } return $changes; }
/** * Puts users posts into array * * @param moscomprofilerUser $user * @param object $forum * @return object */ function getUserPosts( $user, $forum ) { global $_CB_database; $categories = $this->getAllowedCategories( $user, $forum ); $pagingParams = $this->_getPaging( array(), array( 'fposts_' ) ); $postsNumber = $this->params->get( 'postsNumber', 10 ); switch ( $pagingParams['fposts_sortby'] ) { case 'subjectASC': $order = 'a.' . $_CB_database->NameQuote( 'subject' ) . ' ASC'; break; case 'subjectDESC': $order = 'a.' . $_CB_database->NameQuote( 'subject' ) . ' DESC'; break; case 'categoryASC': $order = 'b.' . $_CB_database->NameQuote( 'id' ) . ' ASC'; break; case 'categoryDESC': $order = 'b.' . $_CB_database->NameQuote( 'id' ) . ' DESC'; break; case 'hitsASC': $order = 'c.' . $_CB_database->NameQuote( 'hits' ) . ' ASC'; break; case 'hitsDESC': $order = 'c.' . $_CB_database->NameQuote( 'hits' ) . ' DESC'; break; case 'dateASC': $order = 'a.' . $_CB_database->NameQuote( 'time' ) . ' ASC'; break; case 'dateDESC': default: $order = 'a.' . $_CB_database->NameQuote( 'time' ) . ' DESC'; break; } $query = 'SELECT a.*' . ', b.' . $_CB_database->NameQuote( 'id' ) . ' AS category' . ', b.' . $_CB_database->NameQuote( 'name' ) . ' AS catname' . ', c.' . $_CB_database->NameQuote( 'hits' ) . ' AS threadhits' . "\n FROM " . $_CB_database->NameQuote( '#__' . $forum->prefix . '_messages' ) . ' AS a' . ', ' . $_CB_database->NameQuote( '#__' . $forum->prefix . '_categories' ) . ' AS b' . ', ' . $_CB_database->NameQuote( '#__' . $forum->prefix . '_messages' ) . ' AS c' . ', ' . $_CB_database->NameQuote( '#__' . $forum->prefix . '_messages_text' ) . ' AS d' . "\n WHERE a." . $_CB_database->NameQuote( 'catid' ) . ' = b.' . $_CB_database->NameQuote( 'id' ) . "\n AND a." . $_CB_database->NameQuote( 'thread' ) . ' = c.' . $_CB_database->NameQuote( 'id' ) . "\n AND a." . $_CB_database->NameQuote( 'id' ) . ' = d.' . $_CB_database->NameQuote( 'mesid' ) . "\n AND a." . $_CB_database->NameQuote( 'hold' ) . ' = 0' . "\n AND b." . $_CB_database->NameQuote( 'published' ) . ' = 1' . "\n AND a." . $_CB_database->NameQuote( 'userid' ) . ' = ' . (int) $user->id . ( $categories != null ? "\n AND b." . $_CB_database->NameQuote( 'id' ) . " IN ( " . $categories . " )" : null ) . ( $pagingParams['fposts_search'] ? "\n AND ( a." . $_CB_database->NameQuote( 'subject' ) . " LIKE '%" . cbEscapeSQLsearch( cbGetEscaped( $pagingParams['fposts_search'] ) ) . "%' OR d." . $_CB_database->NameQuote( 'message' ) . " LIKE '%" . cbEscapeSQLsearch( $pagingParams['fposts_search'] ) . "%' )" : null ) . "\n ORDER BY " . $order ; $_CB_database->setQuery( $query, (int) ( $pagingParams['fposts_limitstart'] ? $pagingParams['fposts_limitstart'] : 0 ), (int) $postsNumber ); $posts = $_CB_database->loadObjectList(); return ( $posts ? $posts : null ); }
/** * Puts users posts into array * * @param moscomprofilerUser $user * @param object $forum * @return object */ function getUserPosts($user, $forum) { global $_CB_framework, $_CB_database; $categories = $this->getAllowedCategories(null, $forum); $pagingParams = $this->_getPaging(array(), array('fposts_')); $postsNumber = $this->params->get('postsNumber', 10); if ($forum->prefix != 'kunena' || $forum->prefix == 'kunena' && !class_exists('KunenaForum')) { switch ($pagingParams['fposts_sortby']) { case 'subjectASC': $order = 'a.' . $_CB_database->NameQuote('subject') . ' ASC'; break; case 'subjectDESC': $order = 'a.' . $_CB_database->NameQuote('subject') . ' DESC'; break; case 'categoryASC': $order = 'b.' . $_CB_database->NameQuote('id') . ' ASC'; break; case 'categoryDESC': $order = 'b.' . $_CB_database->NameQuote('id') . ' DESC'; break; case 'hitsASC': $order = 'c.' . $_CB_database->NameQuote('hits') . ' ASC'; break; case 'hitsDESC': $order = 'c.' . $_CB_database->NameQuote('hits') . ' DESC'; break; case 'dateASC': $order = 'a.' . $_CB_database->NameQuote('time') . ' ASC'; break; case 'dateDESC': default: $order = 'a.' . $_CB_database->NameQuote('time') . ' DESC'; break; } if (strcasecmp(substr($forum->version, 0, 3), '1.7') >= 0) { $cbUser =& CBuser::getInstance((int) $user->id); if (!$cbUser) { $cbUser =& CBuser::getInstance(null); } $access = "\n AND ( ( b." . $_CB_database->NameQuote('access') . " IN ( " . implode(',', $cbUser->getAuthorisedViewLevelsIds(false)) . " )" . ' AND b.' . $_CB_database->NameQuote('accesstype') . ' = ' . $_CB_database->Quote('joomla.level') . ' )' . "\n OR ( b." . $_CB_database->NameQuote('pub_access') . " IN ( " . implode(',', $_CB_framework->acl->get_groups_below_me((int) $user->id, true)) . " )" . ' AND b.' . $_CB_database->NameQuote('accesstype') . ' = ' . $_CB_database->Quote('none') . ' )'; } else { $access = "\n AND ( b." . $_CB_database->NameQuote('pub_access') . " IN ( " . implode(',', $_CB_framework->acl->get_groups_below_me((int) $user->id, true)) . " )"; } $access .= $categories ? "\n OR b." . $_CB_database->NameQuote('id') . " IN ( " . implode(',', $categories) . " ) )" : ' )'; $query = 'SELECT a.*' . ', b.' . $_CB_database->NameQuote('id') . ' AS category' . ', b.' . $_CB_database->NameQuote('name') . ' AS catname' . ', c.' . $_CB_database->NameQuote('hits') . ' AS threadhits' . "\n FROM " . $_CB_database->NameQuote('#__' . $forum->prefix . '_messages') . " AS a" . "\n LEFT JOIN " . $_CB_database->NameQuote('#__' . $forum->prefix . '_categories') . " AS b" . ' ON a.' . $_CB_database->NameQuote('catid') . ' = b.' . $_CB_database->NameQuote('id') . "\n LEFT JOIN " . $_CB_database->NameQuote('#__' . $forum->prefix . '_messages') . " AS c" . ' ON a.' . $_CB_database->NameQuote('thread') . ' = c.' . $_CB_database->NameQuote('id') . "\n LEFT JOIN " . $_CB_database->NameQuote('#__' . $forum->prefix . '_messages_text') . " AS d" . ' ON a.' . $_CB_database->NameQuote('id') . ' = d.' . $_CB_database->NameQuote('mesid') . "\n WHERE a." . $_CB_database->NameQuote('hold') . " = 0" . "\n AND b." . $_CB_database->NameQuote('published') . " = 1" . "\n AND a." . $_CB_database->NameQuote('userid') . " = " . (int) $user->id . $access . ($pagingParams['fposts_search'] ? "\n AND ( a." . $_CB_database->NameQuote('subject') . " LIKE '%" . cbEscapeSQLsearch(cbGetEscaped($pagingParams['fposts_search'])) . "%' OR d." . $_CB_database->NameQuote('message') . " LIKE '%" . cbEscapeSQLsearch($pagingParams['fposts_search']) . "%' )" : null) . "\n ORDER BY " . $order; $_CB_database->setQuery($query, (int) ($pagingParams['fposts_limitstart'] ? $pagingParams['fposts_limitstart'] : 0), (int) $postsNumber); $posts = $_CB_database->loadObjectList(); } elseif (class_exists('KunenaForumMessageHelper')) { $where = array(); if (isset($pagingParams['fposts_search']) && $pagingParams['fposts_search'] != '') { $where[] = '( m.' . $_CB_database->NameQuote('subject') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($pagingParams['fposts_search'], true) . '%', false) . ' OR t.' . $_CB_database->NameQuote('message') . ' LIKE ' . $_CB_database->Quote('%' . $_CB_database->getEscaped($pagingParams['fposts_search'], true) . '%', false) . ' )'; } switch ($pagingParams['fposts_sortby']) { case 'subjectASC': $order = 'm.' . $_CB_database->NameQuote('subject') . ' ASC'; break; case 'subjectDESC': $order = 'm.' . $_CB_database->NameQuote('subject') . ' DESC'; break; case 'categoryASC': $order = 'm.' . $_CB_database->NameQuote('catid') . ' ASC'; break; case 'categoryDESC': $order = 'm.' . $_CB_database->NameQuote('catid') . ' DESC'; break; case 'hitsASC': $order = 'm.' . $_CB_database->NameQuote('hits') . ' ASC'; break; case 'hitsDESC': $order = 'm.' . $_CB_database->NameQuote('hits') . ' DESC'; break; case 'dateASC': $order = 'm.' . $_CB_database->NameQuote('time') . ' ASC'; break; case 'dateDESC': default: $order = 'm.' . $_CB_database->NameQuote('time') . ' DESC'; break; } $params = array('user' => (int) $user->id, 'starttime' => -1, 'where' => count($where) ? implode(' AND ', $where) : null, 'orderby' => $order); $posts = array_pop(KunenaForumMessageHelper::getLatestMessages(false, (int) ($pagingParams['fposts_limitstart'] ? $pagingParams['fposts_limitstart'] : 0), (int) $postsNumber, $params)); if ($posts) { foreach ($posts as $k => $post) { $posts[$k]->set('category', $post->getCategory()->id); $posts[$k]->set('catname', $post->getCategory()->name); $posts[$k]->set('threadhits', $post->getTopic()->hits); } } } else { $posts = null; } return $posts; }
function _callPluginTypeMethod($type, $methodName, $args) { global $_CB_database; $results = array(); if ($this->PMSpluginsList === null) { $_CB_database->setQuery("SELECT * FROM #__comprofiler_plugin p" . "\n WHERE p.published=1 " . "\n AND p.element LIKE '%" . cbEscapeSQLsearch(trim(strtolower($_CB_database->getEscaped($type)))) . ".%' " . "\n ORDER BY p.ordering"); $this->PMSpluginsList = $_CB_database->loadObjectList(); if ($_CB_database->getErrorNum()) { return $results; } } foreach ($this->PMSpluginsList as $plug) { $className = 'get' . substr($plug->element, strlen($type) + 1) . 'Tab'; $results[] = $this->_callPlugin($plug, $args, $className, $methodName); } return $results; }
function viewPlugins($option) { global $_CB_database, $_CB_framework; $limit = (int) $_CB_framework->getCfg('list_limit'); if ($limit == 0) { $limit = 10; } $limit = $_CB_framework->getUserStateFromRequest("viewlistlimit", 'limit', $limit); $lastCBlist = $_CB_framework->getUserState("view{$option}lastCBlist", null); if ($lastCBlist == 'showplugins') { $limitstart = $_CB_framework->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0); $lastSearch = $_CB_framework->getUserState("search{$option}", null); $search = $_CB_framework->getUserStateFromRequest("search{$option}", 'search', ''); if ($lastSearch != $search) { $limitstart = 0; $_CB_framework->setUserState("view{$option}limitstart", $limitstart); } $search = trim(strtolower($search)); $filter_type = $_CB_framework->getUserStateFromRequest("filter_type{$option}", 'filter_type', "0"); } else { clearSearchBox(); $search = ""; $limitstart = 0; $_CB_framework->setUserState("view{$option}limitstart", $limitstart); $_CB_framework->setUserState("view{$option}lastCBlist", "showplugins"); $filter_type = "0"; $_CB_framework->setUserState("filter_type{$option}", $filter_type); } $where = array(); // used by filter if ($filter_type) { $where[] = "m.type = '{$filter_type}'"; } if ($search) { $search = cbEscapeSQLsearch(trim(strtolower(cbGetEscaped($search)))); $where[] = "LOWER( m.name ) LIKE '%{$search}%'"; } if (!$_CB_framework->acl->amIaSuperAdmin()) { $viewAccessLevels = CBuser::getMyInstance()->getAuthorisedViewLevelsIds(true); $viewAccessLevelsCleaned = implode(',', cbArrayToInts($viewAccessLevels)); $where[] = 'm.access IN (' . $viewAccessLevelsCleaned . ')'; } // get the total number of records $query = "SELECT COUNT(*) FROM #__comprofiler_plugin AS m " . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ''); $_CB_database->setQuery($query); $total = $_CB_database->loadResult(); if ($total <= $limitstart) { $limitstart = 0; } cbimport('cb.pagination'); $pageNav = new cbPageNav($total, $limitstart, $limit); if (checkJversion() == 2) { $title = 'title'; } else { $title = 'name'; } $query = "SELECT m.*, u.name AS editor, g.{$title} AS groupname" . "\n FROM #__comprofiler_plugin AS m" . "\n LEFT JOIN #__users AS u ON u.id = m.checked_out"; if (checkJversion() == 2) { $query .= "\n LEFT JOIN #__viewlevels AS g ON g.id = m.access + IF(m.access <= 2, 1, 0)"; // fix J1.6's wrong access levels, same as g.id = IF( m.access = 0, 1, IF( m.access = 1, 2, IF( m.access = 2, 3, m.access ) ) ) } else { $query .= "\n LEFT JOIN #__groups AS g ON g.id = m.access"; } $query .= (count($where) ? "\n WHERE " . implode(' AND ', $where) : '') . "\n GROUP BY m.id" . "\n ORDER BY m.type ASC, m.ordering ASC, m.name ASC"; $_CB_database->setQuery($query, (int) $pageNav->limitstart, (int) $pageNav->limit); $rows = $_CB_database->loadObjectList(); if ($_CB_database->getErrorNum()) { echo $_CB_database->stderr(); return false; } // get list of Positions for dropdown filter $query = "SELECT type AS value, type AS text" . "\n FROM #__comprofiler_plugin" . "\n GROUP BY type" . "\n ORDER BY type"; $types[] = moscomprofilerHTML::makeOption('0', !defined('_SEL_TYPE') ? '- ' . CBTxt::T('Select Type') . ' -' : _SEL_TYPE); // Mambo 4.5.1 Compatibility $_CB_database->setQuery($query); $types = array_merge($types, $_CB_database->loadObjectList()); $lists['type'] = moscomprofilerHTML::selectList($types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_type, 2); $canAdmin = CBuser::getMyInstance()->authoriseAction('core.admin'); $canEdit = CBuser::getMyInstance()->authoriseAction('core.edit'); $canEditState = CBuser::getMyInstance()->authoriseAction('core.edit.state'); HTML_comprofiler::showPlugins($rows, $pageNav, $option, $lists, $search, $canAdmin, $canEdit, $canEditState); return true; }
function getDisplayTab($tab,$user,$ui) { global $_CB_database, $_CB_framework, $mainframe; if(!file_exists( $_CB_framework->getCfg('absolute_path') . '/components/com_mamblog/configuration.php' )){ $return = _UE_MAMBLOGNOTINSTALLED; } else { include_once ( $_CB_framework->getCfg('absolute_path') . '/components/com_mamblog/configuration.php' ); $return=""; $return .= $this->_writeTabDescription( $tab, $user ); $params = $this->params; $entriesNumber = $params->get('entriesNumber', '10'); $pagingEnabled = $params->get('pagingEnabled', 0); $searchEnabled = $params->get('searchEnabled', 0); $pagingParams = $this->_getPaging(array(),array("entries_")); if (!$searchEnabled) $pagingParams["entries_search"]=null; $sectid=""; $catid=""; if(ISSET($cfg_mamblog['sectionid'])) $sectid="\n AND a.sectionid=" . (int) $cfg_mamblog['sectionid']; if(ISSET($cfg_mamblog['categoryid'])) $catid="\n AND a.categoryid=" . (int) $cfg_mamblog['categoryid']; $where = "\n WHERE a.created_by = ". (int) $user->id ."" . "\n AND a.state = 1" . $sectid . $catid . ($pagingParams["entries_search"]? "\n AND (a.title LIKE '%".cbEscapeSQLsearch($pagingParams["entries_search"])."%'" ." OR a.introtext LIKE '%".cbEscapeSQLsearch($pagingParams["entries_search"])."%'" ." OR a.fulltext LIKE '%".cbEscapeSQLsearch($pagingParams["entries_search"])."%')" : ""); if ($pagingEnabled) { $query="SELECT COUNT(*)" . "\n FROM #__content AS a" . $where; $_CB_database->setQuery($query); $total = $_CB_database->loadResult(); if (!is_numeric($total)) $total = 0; $userHasPosts = ($total > 0 || ($pagingParams["entries_search"])); if ($pagingParams["entries_limitstart"] === null) $pagingParams["entries_limitstart"] = "0"; if ($entriesNumber > $total) $pagingParams["entries_limitstart"] = "0"; } else { $pagingParams["entries_limitstart"] = "0"; $pagingParams["entries_search"] = null; } switch ($pagingParams["entries_sortby"]) { case "title": $order = "a.title ASC, a.created DESC"; break; case "hits": $order = "a.hits DESC, a.created DESC"; break; case "date": default: $order = "a.created DESC"; break; } $query = "SELECT a.id, a.title, a.hits, a.created" // For the article plugin? //. "\n ROUND( r.rating_sum / r.rating_count ) AS rating,r.rating_count" . "\n FROM #__content AS a" //. "\n LEFT JOIN #__content_rating AS r ON r.content_id = a.id" . $where . "\n ORDER BY ".$order . "\n LIMIT " . (int) ( $pagingParams["entries_limitstart"] ? $pagingParams["entries_limitstart"] : 0 ) . "," . (int) $entriesNumber; $_CB_database->setQuery( $query ); $items = $_CB_database->loadObjectList(); if ($searchEnabled) { $searchForm = $this->_writeSearchBox($pagingParams,"entries_", "style=\"float:right;\"", "class=\"inputbox\""); } if(count($items) > 0) { if ($pagingParams["entries_search"]) $title = sprintf(_UE_BLOG_FOUNDENTRIES,$total); elseif ($pagingEnabled) $title = sprintf(_UE_BLOG_ENTRIES,$entriesNumber); else $title = sprintf(_UE_BLOG_LASTENTRIES,$entriesNumber); $return .= "<br /><div class=\"cbMBlogDiv\" style=\"text-align:left;padding-left:0px;padding-right:0px;margin:0px 0px 10px 0px;height:auto;width:100%;\">"; $return .= "<div class=\"cbMBlogTitles\" style=\"float:left;\">".$title."</div> "; $artURL="index.php?option=com_content&task=view&id="; if ($searchEnabled) $return .= $searchForm; $return .= "<br /><div style=\"clear:both;\"> </div>"; $return .= "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" style=\"margin:0px;padding:0px;width:100%;\">"; $return .= "<tr class=\"sectiontableheader\">"; $return .= "<th>".$this->_writeSortByLink($pagingParams,"entries_","date",_UE_ARTICLEDATE,true)."</th>"; $return .= "<th>".$this->_writeSortByLink($pagingParams,"entries_","title",_UE_ARTICLETITLE)."</th>"; if($_CB_framework->getCfg( 'hits' )) { $return .= "<th>".$this->_writeSortByLink($pagingParams,"entries_","hits",_UE_ARTICLEHITS)."</th>"; } $return .= "</tr>"; $i = 2; foreach($items as $item) { if ( isset( $mainframe ) && is_callable( array( $mainframe, "getItemid" ) ) ) { $itemid = $mainframe->getItemid( $item->id ); } elseif (is_callable( "JApplicationHelper::getItemid" ) ) { $itemid = JApplicationHelper::getItemid( $item->id ); } else { $itemid = null; } $itemidtxt = $itemid ? "&Itemid=" . (int) $itemid : ""; $i = ($i==1) ? 2 : 1; $return .= "<tr class=\"sectiontableentry$i\"><td>" . cbFormatDate( $item->created ) . "</td>" . "<td><a href=\"".$artURL.$item->id.$itemidtxt."\">".$item->title."</a></td>"; if($_CB_framework->getCfg( 'hits' )) $return.= "<td>".$item->hits."</td>\n"; $return .= "</tr>\n"; } $return .= "</table></div>"; if ($pagingEnabled && ($entriesNumber < $total)) { $return .= "<div style='width:95%;text-align:center;'>" .$this->_writePaging($pagingParams,"entries_",$entriesNumber,$total) ."</div>"; } } else { if ($pagingEnabled && $userHasPosts && $searchEnabled && $pagingParams["entries_search"]) { $return .= "<br /><div class=\"cbNoArticles\" style=\"text-align:left;width:95%;\">"; $return .= $searchForm; $return .= "</div>"; $return .= "<br />".sprintf(_UE_BLOG_FOUNDENTRIES, 0); } else { $return .= "<br /><br /><div class=\"cbNoArticles\" style=\"text-align:left;width:95%;\">"; $return .= _UE_NOBLOGS; $return .= "</div>"; } } } return $return; }