/** * Performs search on all stories * * @return object plugin object * */ private function _searchStories() { global $_TABLES, $_DB_dbms, $LANG09; // Make sure the query is SQL safe $query = trim(DB_escapeString($this->_query)); $sql = 'SELECT s.sid AS id, s.title AS title, s.introtext AS description, '; $sql .= 'UNIX_TIMESTAMP(s.date) AS date, s.uid AS uid, s.hits AS hits, '; $sql .= 'CONCAT(\'/article.php?story=\',s.sid) AS url '; $sql .= 'FROM ' . $_TABLES['stories'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topic_assignments'] . ' AS ta '; $sql .= 'WHERE (draft_flag = 0) AND (date <= NOW()) AND (u.uid = s.uid) '; $sql .= 'AND ta.type = \'article\' AND ta.id = sid '; $sql .= COM_getPermSQL('AND') . COM_getTopicSQL('AND', 0, 'ta') . COM_getLangSQL('sid', 'AND') . ' '; if (!empty($this->_topic)) { // Retrieve list of inherited topics if ($this->_topic == TOPIC_ALL_OPTION) { // Stories do not have an all option so just return all stories that meet the requirements and permissions //$sql .= "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$this->_topic."')) "; } else { $tid_list = TOPIC_getChildList($this->_topic); $sql .= "AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '" . $this->_topic . "'))) "; } } if (!empty($this->_author)) { $sql .= 'AND (s.uid = \'' . $this->_author . '\') '; } $search_s = new SearchCriteria('stories', $LANG09[65]); $columns = array('title' => 'title', 'introtext', 'bodytext'); $sql .= $search_s->getDateRangeSQL('AND', 'date', $this->_dateStart, $this->_dateEnd); list($sql, $ftsql) = $search_s->buildSearchSQL($this->_keyType, $query, $columns, $sql); $sql .= " GROUP BY s.sid"; $search_s->setSQL($sql); $search_s->setFTSQL($ftsql); $search_s->setRank(5); $search_s->setURLRewrite(true); // Search Story Comments $sql = 'SELECT c.cid AS id, c.title AS title, c.comment AS description, '; $sql .= 'UNIX_TIMESTAMP(c.date) AS date, c.uid AS uid, \'0\' AS hits, '; // MSSQL has a problem when concatenating numeric values if ($_DB_dbms == 'mssql') { $sql .= '\'/comment.php?mode=view&cid=\' + CAST(c.cid AS varchar(10)) AS url '; } else { $sql .= 'CONCAT(\'/comment.php?mode=view&cid=\',c.cid) AS url '; } $sql .= 'FROM ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topic_assignments'] . ' AS ta, ' . $_TABLES['comments'] . ' AS c '; $sql .= 'LEFT JOIN ' . $_TABLES['stories'] . ' AS s ON ((s.sid = c.sid) '; $sql .= COM_getPermSQL('AND', 0, 2, 's') . COM_getLangSQL('sid', 'AND', 's') . ') '; $sql .= 'WHERE (u.uid = c.uid) AND (s.draft_flag = 0) AND (s.commentcode >= 0) AND (s.date <= NOW()) '; $sql .= 'AND ta.type = \'article\' AND ta.id = s.sid ' . COM_getTopicSQL('AND', 0, 'ta'); if (!empty($this->_topic)) { if ($this->_topic == TOPIC_ALL_OPTION) { // Stories do not have an all option so just return all story comments that meet the requirements and permissions //$sql .= "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$this->_topic."')) "; } else { $sql .= "AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '" . $this->_topic . "'))) "; } } if (!empty($this->_author)) { $sql .= 'AND (c.uid = \'' . $this->_author . '\') '; } $search_c = new SearchCriteria('comments', array($LANG09[65], $LANG09[66])); $columns = array('title' => 'c.title', 'comment'); $sql .= $search_c->getDateRangeSQL('AND', 'c.date', $this->_dateStart, $this->_dateEnd); list($sql, $ftsql) = $search_c->buildSearchSQL($this->_keyType, $query, $columns, $sql); $sql .= " GROUP BY id"; $search_c->setSQL($sql); $search_c->setFTSQL($ftsql); $search_c->setRank(2); return array($search_s, $search_c); }
/** * Display year view * * @param Template $template reference of the template * @param string $dir_topic current topic * @param int $year year to display * @return string list of months (+ number of stories) for given year */ function DIR_displayYear($template, $dir_topic, $year) { global $_CONF, $_TABLES, $LANG_MONTH, $LANG_DIR; $retval = ''; $currentTime = time(); $currentYear = date('Y', $currentTime); $currentMonth = date('m', $currentTime); $start = sprintf('%04d-01-01 00:00:00', $year); $end = sprintf('%04d-12-31 23:59:59', $year); $monthsql = array(); $monthsql['mysql'] = "SELECT DISTINCT MONTH(s.date) AS month, COUNT(DISTINCT s.sid) AS count\n FROM {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta\n WHERE (s.date >= '{$start}') AND (s.date <= '{$end}') AND (s.draft_flag = 0) AND (s.date <= NOW())\n AND ta.type = 'article' AND ta.id = s.sid "; $monthsql['pgsql'] = "SELECT EXTRACT(Month from date) AS month,COUNT(DISTINCT sid) AS count\n FROM {$_TABLES['stories']} , {$_TABLES['topic_assignments']} ta\n WHERE (date >= '{$start}') AND (date <= '{$end}') AND (draft_flag = 0) AND (date <= NOW())\n AND ta.type = 'article' AND ta.id = sid "; if ($dir_topic !== 'all') { // Retrieve list of inherited topics $tid_list = TOPIC_getChildList($dir_topic); $monthsql['mysql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))"; $monthsql['pgsql'] .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$dir_topic}')))"; } else { $monthsql['mysql'] .= COM_getTopicSQL('AND', 0, 'ta'); $monthsql['pgsql'] .= COM_getTopicSQL('AND', 0, 'ta'); } $monthsql['mysql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY month, date ORDER BY date ASC"; $monthsql['pgsql'] .= COM_getPermSql('AND') . COM_getLangSQL('sid', 'AND') . " GROUP BY month, date ORDER BY DATE ASC"; $mresult = DB_query($monthsql); $nummonths = DB_numRows($mresult); if ($nummonths > 0) { $items = array(); $lastm = 1; for ($j = 0; $j < $nummonths; $j++) { $M = DB_fetchArray($mresult); for (; $lastm < $M['month']; $lastm++) { $items[] = DIR_monthLink($dir_topic, $year, $lastm, 0); } $lastm = $M['month'] + 1; $items[] = DIR_monthLink($dir_topic, $year, $M['month'], $M['count']); } if ($year == $currentYear) { $fillm = $currentMonth; } else { $fillm = 12; } if ($lastm <= $fillm) { for (; $lastm <= $fillm; $lastm++) { $items[] = DIR_monthLink($dir_topic, $year, $lastm, 0); } } $retval .= COM_makeList($items); } else { if (TEMPLATE_EXISTS) { $retval .= $template->parse('message', 'no-articles') . LB; } else { $retval .= '<p>' . $LANG_DIR['no_articles'] . '</p>' . LB; } } $retval .= LB; return $retval; }
/** * Provide list of stories * * @param string $current_topic (optional) currently selected topic * @return string HTML for the list of stories * */ function liststories($current_topic = '') { global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG09, $LANG_ADMIN, $LANG_ACCESS, $LANG24; require_once $_CONF['path_system'] . 'lib-admin.php'; $retval = ''; if (empty($current_topic)) { $current_topic = TOPIC_ALL_OPTION; } $seltopics = TOPIC_getTopicListSelect($current_topic, 2); if (empty($seltopics)) { $retval .= COM_showMessage(101); return $retval; } if ($current_topic == TOPIC_ALL_OPTION) { // Retrieve list of inherited topics // $tid_list = TOPIC_getChildList(TOPIC_ROOT); // Retrieve list of all topics user has access to (did not do inherit way since may not see all stories has access too) $tid_list = TOPIC_getList(0, true, false); if (empty($tid_list)) { $retval .= COM_showMessage(101); return $retval; } $excludetopics = " (tid IN ('" . implode("','", $tid_list) . "')) "; } else { // Retrieve list of inherited topics $tid_list = TOPIC_getChildList($current_topic); // Get list of blocks to display (except for dynamic). This includes blocks for all topics, and child blocks that are inherited $excludetopics = " (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$current_topic}')))"; /* $seltopics = COM_topicList('tid,topic', $current_topic, 1, true); if (empty($seltopics)) { $retval .= COM_showMessage(101); return $retval; } */ } $filter = $LANG_ADMIN['topic'] . ': <select name="tid" style="width: 125px" onchange="this.form.submit()">' . $seltopics . '</select>'; $header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false), array('text' => $LANG_ADMIN['copy'], 'field' => 'copy', 'sort' => false), array('text' => $LANG_ADMIN['title'], 'field' => 'title', 'sort' => true), array('text' => $LANG_ACCESS['access'], 'field' => 'access', 'sort' => false), array('text' => $LANG24[34], 'field' => 'draft_flag', 'sort' => true)); if ($_CONF['show_fullname'] == 1) { $header_arr[] = array('text' => $LANG24[7], 'field' => 'fullname', 'sort' => true); // author } else { $header_arr[] = array('text' => $LANG24[7], 'field' => 'username', 'sort' => true); // author } $header_arr[] = array('text' => $LANG24[15], 'field' => 'unixdate', 'sort' => true); // date $header_arr[] = array('text' => $LANG_ADMIN['topic'], 'field' => 'tid', 'sort' => true); $header_arr[] = array('text' => $LANG24[32], 'field' => 'featured', 'sort' => true); if (SEC_hasRights('story.ping') && ($_CONF['trackback_enabled'] || $_CONF['pingback_enabled'] || $_CONF['ping_enabled'])) { $header_arr[] = array('text' => $LANG24[20], 'field' => 'ping', 'sort' => false); } $defsort_arr = array('field' => 'unixdate', 'direction' => 'desc'); $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/story.php?mode=edit', 'text' => $LANG_ADMIN['create_new'])); $menu_arr[] = array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']); $form_arr = array('bottom' => '', 'top' => ''); $retval .= COM_startBlock($LANG24[22], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= ADMIN_createMenu($menu_arr, $LANG24[23], $_CONF['layout_url'] . '/images/icons/story.' . $_IMAGE_TYPE); $text_arr = array('has_extras' => true, 'form_url' => $_CONF['site_admin_url'] . '/story.php'); $sql = "SELECT {$_TABLES['stories']}.*, {$_TABLES['users']}.username, {$_TABLES['users']}.fullname, " . "UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} " . "LEFT JOIN {$_TABLES['users']} ON {$_TABLES['stories']}.uid={$_TABLES['users']}.uid " . "LEFT JOIN {$_TABLES['topic_assignments']} ta ON ta.type = 'article' AND ta.id = sid " . "WHERE 1=1 "; if (!empty($excludetopics)) { $excludetopics = 'AND ' . $excludetopics; } $query_arr = array('table' => 'stories', 'sql' => $sql, 'query_group' => "sid,{$_TABLES['users']}.username,{$_TABLES['users']}.fullname", 'query_fields' => array('title', 'introtext', 'bodytext', 'sid', 'tid'), 'default_filter' => $excludetopics . COM_getPermSQL('AND')); // Add in topic filter so it is remembered with paging $pagenavurl = '&tid=' . $current_topic; $retval .= ADMIN_list('story', 'ADMIN_getListField_stories', $header_arr, $text_arr, $query_arr, $defsort_arr, $filter, '', '', $form_arr, true, $pagenavurl); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * Figure out the current topic for a plugin. If permissions or language wrong * will find default else end with a '' topic (which is all). Needs to be run * on page that is affected by the topic after lib-common.php so it can grab * topic in url if need be. Also if pass blank $type and $id then return just last topic * * @param string $type Type of object to find topic access about. * @param string/array $id ID of object * @return void * */ function TOPIC_getTopic($type = '', $id = '') { global $_TABLES, $topic; $find_another = false; $found = false; // Double check $topic = COM_applyFilter($topic); if ($topic == TOPIC_ALL_OPTION) { $topic = ''; // Do not use 'all' option. Nothing is the same thing } // See if user has access to view topic if ($topic != '') { $test_topic = DB_getItem($_TABLES['topics'], 'tid', "tid = '{$topic}' " . COM_getPermSQL('AND')); if (strtolower($topic) != strtolower($test_topic)) { $topic = ''; } else { // Make it equal to the db version since case maybe different $topic = $test_topic; } } // Check and return Previous topic if ($topic == '') { // Blank could mean all topics or that we do not know topic // retrieve previous topic $last_topic = SESS_getVariable('topic'); } else { $last_topic = $topic; } // *********************************** // Special Cases if ($type == '') { // used by search, submit, etc to find last topic $topic = $last_topic; $found = true; } elseif ($type == 'comment') { if ($id != '') { // Find comment objects topic $sql = "SELECT type, sid\n FROM {$_TABLES['comments']}\n WHERE cid = '{$id}'"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $A = DB_fetchArray($result); // Found comment object so now reset type and id variables $type = $A['type']; $id = $A['sid']; } else { // Could not find comment so set topic to nothing (all) $topic = ''; $found = true; } } else { // If no id then probably a submit form $topic = $last_topic; $found = true; } } // *********************************** if (!$found) { if ($last_topic != '') { // see if object belongs to topic or any child inherited topics $tid_list = TOPIC_getChildList($last_topic); $sql = "SELECT ta.tid\n FROM {$_TABLES['topics']} t, {$_TABLES['topic_assignments']} ta\n WHERE t.tid = ta.tid\n AND ta.type = '{$type}' AND ta.id = '{$id}'\n AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$last_topic}')))\n " . COM_getLangSQL('tid', 'AND', 't') . COM_getPermSQL('AND', 0, 2, 't') . " ORDER BY tdefault DESC, tid ASC"; // Order by default first and then tid alphabetically since no defined sort order of topics. This needs to be the same as when topics are displayed (index.php) $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $A = DB_fetchArray($result); $topic = $A['tid']; // Default topic if returned else first topic in order by tid // Need to check if topic assignment exists for last topic if so make that the topic instead while ($A = DB_fetchArray($result)) { if ($last_topic == $A['tid']) { $topic = $A['tid']; } } } else { $find_another = true; } } else { $find_another = true; } if ($find_another) { // Find another topic to set, most likely default $sql = "SELECT ta.*\n FROM {$_TABLES['topics']} t, {$_TABLES['topic_assignments']} ta\n WHERE t.tid = ta.tid\n AND ta.type = '{$type}' AND ta.id = '{$id}'\n " . COM_getLangSQL('tid', 'AND', 't') . COM_getPermSQL('AND', 0, 2, 't') . "\n ORDER by ta.tdefault DESC"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $A = DB_fetchArray($result); $topic = $A['tid']; } else { $topic = ''; } } } }
/** * used for the list of topics in admin/topic.php * * @param string $fieldName * @param string $fieldValue * @param array $A * @param array $icon_arr * @param string $token * @return string */ function ADMIN_getListField_topics($fieldName, $fieldValue, $A, $icon_arr, $token) { global $_CONF, $LANG_ACCESS, $_TABLES, $LANG27, $LANG32; $retval = false; $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); switch ($fieldName) { case 'edit': if ($access == 3) { $editUrl = $_CONF['site_admin_url'] . '/topic.php?mode=edit&tid=' . $A['tid']; $retval = COM_createLink($icon_arr['edit'], $editUrl); } break; case 'sortnum': if ($_CONF['sortmethod'] === 'sortnum') { $style = 'style="vertical-align: middle;"'; $upImage = $_CONF['layout_url'] . '/images/admin/up.png'; $downImage = $_CONF['layout_url'] . '/images/admin/down.png'; $url = $_CONF['site_admin_url'] . '/topic.php?mode=change_sortnum' . '&tid=' . $A['tid'] . '&' . CSRF_TOKEN . '=' . $token . '&where='; $retval .= COM_createLink("<img {$style} alt=\"+\" src=\"{$upImage}\"" . XHTML . ">", $url . 'up', array('title' => $LANG32[44])); $retval .= ' ' . $fieldValue . ' '; $retval .= COM_createLink("<img {$style} alt=\"-\" src=\"{$downImage}\"" . XHTML . ">", $url . 'dn', array('title' => $LANG32[45])); } else { $retval = $fieldValue; } break; case 'image': $retval = ''; if (!empty($A['imageurl'])) { $imageUrl = COM_getTopicImageUrl($A['imageurl']); $image_tag = '<img src="' . $imageUrl . '" width="24" height="24" id="topic-' . $A['tid'] . '" class="admin-topic-image" alt=""' . XHTML . '>'; $url = COM_buildURL($_CONF['site_url'] . '/index.php?topic=' . $A['tid']); $retval = COM_createLink($image_tag, $url); } break; case 'topic': $default = $A['is_default'] == 1 ? $LANG27[24] : ''; $level = -1; $tid = $A['tid']; while ($tid !== TOPIC_ROOT) { $tid = DB_getItem($_TABLES['topics'], 'parent_id', "tid = '{$tid}'"); $level++; } $level *= 15; $content = '<span style="margin-left:' . $level . 'px">' . $fieldValue . '</span>'; $url = COM_buildURL($_CONF['site_url'] . '/index.php?topic=' . $A['tid']); $retval = COM_createLink($content, $url) . $default; break; case 'access': $retval = $LANG_ACCESS['readonly']; if ($access == 3) { $retval = $LANG_ACCESS['edit']; } break; case 'inherit': case 'hidden': $yes = empty($LANG27[50]) ? 'Yes' : $LANG27[50]; $no = empty($LANG27[50]) ? 'No' : $LANG27[51]; $retval = $fieldValue == 1 ? $yes : $no; break; case 'story': // Retrieve list of inherited topics $tid_list = TOPIC_getChildList($A['tid']); // Calculate number of stories in topic, includes any inherited ones $sql = "SELECT sid FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta " . "WHERE (draft_flag = 0) AND (date <= NOW()) " . COM_getPermSQL('AND') . "AND ta.type = 'article' AND ta.id = sid " . "AND (ta.tid IN({$tid_list}) " . "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$A['tid']}'))) " . "GROUP BY sid"; $result = DB_query($sql); $numRows = DB_numRows($result); $retval = COM_numberFormat($numRows); break; default: $retval = $fieldValue; break; } return $retval; }
/** * Shows Geeklog blocks * * Returns HTML for blocks on a given side and, potentially, for * a given topic. Currently only used by static pages. * * @param string $side Side to get blocks for (right or left for now) * @param string $topic Only get blocks for this topic * @see function COM_showBlock * @return string HTML Formated blocks * */ function COM_showBlocks($side, $topic = '') { global $_CONF, $_TABLES, $_USER, $LANG21, $topic, $page, $_TOPICS; $retval = ''; // Get user preferences on blocks if (!isset($_USER['noboxes']) || !isset($_USER['boxes'])) { if (!COM_isAnonUser()) { $result = DB_query("SELECT boxes,noboxes FROM {$_TABLES['userindex']} " . "WHERE uid = '{$_USER['uid']}'"); list($_USER['boxes'], $_USER['noboxes']) = DB_fetchArray($result); } else { $_USER['boxes'] = ''; $_USER['noboxes'] = 0; } } $blocksql['mssql'] = "SELECT bid, is_enabled, name, b.type, title, blockorder, cast(content as text) as content, cache_time, "; $blocksql['mssql'] .= "rdfurl, rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id, "; $blocksql['mssql'] .= "group_id, perm_owner, perm_group, perm_members, perm_anon, allow_autotags,UNIX_TIMESTAMP(rdfupdated) AS date "; $blocksql['mysql'] = "SELECT b.*,UNIX_TIMESTAMP(rdfupdated) AS date "; $blocksql['pgsql'] = 'SELECT b.*, date_part(\'epoch\', rdfupdated) AS date '; $blocksql['mysql'] .= "FROM {$_TABLES['blocks']} b, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'block' AND ta.id = bid AND is_enabled = 1"; $blocksql['mssql'] .= "FROM {$_TABLES['blocks']} b, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'block' AND ta.id = bid AND is_enabled = 1"; $blocksql['pgsql'] .= "FROM {$_TABLES['blocks']} b, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'block' AND ta.id::integer = bid AND is_enabled = 1"; $commonsql = ''; if ($side === 'left') { $commonsql .= " AND onleft = 1"; } else { $commonsql .= " AND onleft = 0"; } // Figure out topic access $topic_access = 0; if (!empty($topic) && $topic != TOPIC_ALL_OPTION && $topic != TOPIC_HOMEONLY_OPTION) { $topic_index = TOPIC_getIndex($topic); if ($topic_index > 0) { $topic_access = $_TOPICS[$topic_index]['access']; } } if (!empty($topic) && $topic != TOPIC_ALL_OPTION && $topic != TOPIC_HOMEONLY_OPTION && $topic_access > 0) { // Retrieve list of inherited topics $tid_list = TOPIC_getChildList($topic); // Get list of blocks to display (except for dynamic). This includes blocks // for all topics, and child blocks that are inherited $commonsql .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$topic}')) OR ta.tid = 'all')"; } else { if (COM_onFrontpage()) { $commonsql .= " AND (ta.tid = '" . TOPIC_HOMEONLY_OPTION . "' OR ta.tid = '" . TOPIC_ALL_OPTION . "')"; } else { $commonsql .= " AND (ta.tid = '" . TOPIC_ALL_OPTION . "')"; } } if (!empty($_USER['boxes'])) { $BOXES = str_replace(' ', ',', $_USER['boxes']); $commonsql .= " AND (bid NOT IN ({$BOXES}) OR bid = '-1')"; } $commonsql .= " GROUP BY bid "; $commonsql .= ' ORDER BY blockorder,title ASC'; $blocksql['mysql'] .= $commonsql; $blocksql['mssql'] .= $commonsql; $blocksql['pgsql'] .= $commonsql; $result = DB_query($blocksql); $nrows = DB_numRows($result); // convert result set to an array of associated arrays $blocks = array(); for ($i = 0; $i < $nrows; $i++) { $blocks[] = DB_fetchArray($result); } // Check and see if any plugins have blocks to show $pluginBlocks = PLG_getBlocks($side, $topic); $blocks = array_merge($blocks, $pluginBlocks); // sort the resulting array by block order $column = 'blockorder'; $sortedBlocks = $blocks; $num_sortedBlocks = count($sortedBlocks); for ($i = 0; $i < $num_sortedBlocks - 1; $i++) { for ($j = 0; $j < $num_sortedBlocks - 1 - $i; $j++) { if ($sortedBlocks[$j][$column] > $sortedBlocks[$j + 1][$column]) { $tmp = $sortedBlocks[$j]; $sortedBlocks[$j] = $sortedBlocks[$j + 1]; $sortedBlocks[$j + 1] = $tmp; } } } $blocks = $sortedBlocks; // Loop though resulting sorted array and pass associative arrays // to COM_formatBlock foreach ($blocks as $A) { if ($A['type'] === 'dynamic' || SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) > 0) { $retval .= COM_formatBlock($A, $_USER['noboxes']); } } return $retval; }
/** * Checking if comment feeds are up to date * * @param int $feed id of feed to be checked * @param string $topic topic * @param string $update_data data describing current feed contents * @param string $limit number of entries or number of hours * @param string $updated_type (optional) type of feed to be updated * @param string $updated_topic (optional) feed's "topic" to be updated * @param string $updated_id (optional) id of entry that has changed * @return boolean true: feed data is up to date; false: isn't * */ function plugin_feedupdatecheck_comment($feed, $topic, $update_data, $limit, $updated_type = '', $updated_topic = '', $updated_id = '') { global $_TABLES, $_TOPICS; $is_current = true; if ($updated_type != 'comment') { // we're not interested $updated_type = ''; $updated_topic = ''; $updated_id = ''; } /* Original $sql = "SELECT c.cid, UNIX_TIMESTAMP(c.date) AS modified " ." FROM {$_TABLES['comments']} as c " ." JOIN {$_TABLES['stories']} as s ON s.sid = c.sid " ." JOIN {$_TABLES['topics']} as t ON t.tid = s.tid " .COM_getPermSQL('WHERE', 1, 2, 's') .COM_getPermSQL('AND', 1, 2, 't') ." AND type='article' "; */ /* if( $topic != 'all' ) { $sql .= " AND topic='{$topic}' "; } */ // If topic is all then make it root so all topics are returned (since articles cannot belong to all topics) if ($topic == TOPIC_ALL_OPTION or empty($topic)) { $topic = TOPIC_ROOT; } // Retrieve list of inherited topics for anonymous user $tid_list = TOPIC_getChildList($topic, 1); $sql = "SELECT c.cid, UNIX_TIMESTAMP(c.date) AS modified " . "FROM {$_TABLES['comments']} c, {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta " . "WHERE (s.draft_flag = 0) AND (s.date <= NOW()) " . COM_getPermSQL('AND', 1, 2, 's') . " AND ta.type = 'article' AND ta.id = s.sid " . " AND c.type = 'article' AND s.sid = c.sid " . "AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$topic}'))) " . "GROUP BY c.cid " . "ORDER BY modified DESC LIMIT 0, {$limit} "; $result = DB_query($sql); $num = DB_numRows($result); $cids = array(); for ($i = 0; $i < $num; $i++) { $A = DB_fetchArray($result); if ($A['cid'] == $updated_id) { // this feed has to be updated - no further checks needed return false; } $cids[] = $A['cid']; } $current = implode(',', $cids); return $current != $update_data ? false : true; }
/** * Get content for a feed that holds stories from one topic. * * @param string $tid topic id * @param string $limit number of entries or number of stories * @param string $link link to topic * @param string $update list of story ids * @return array content of the feed * */ function SYND_getFeedContentPerTopic($tid, $limit, &$link, &$update, $contentLength, $feedType, $feedVersion, $fid) { global $_TABLES, $_CONF, $LANG01; $content = array(); $sids = array(); if (DB_getItem($_TABLES['topics'], 'perm_anon', "tid = '{$tid}'") >= 2) { $where = ''; if (!empty($limit)) { if (substr($limit, -1) == 'h') { $limitsql = ''; $hours = substr($limit, 0, -1); $where = " AND date >= DATE_SUB(NOW(),INTERVAL {$hours} HOUR)"; } else { $limitsql = ' LIMIT ' . $limit; } } else { $limitsql = ' LIMIT 10'; } $topic = stripslashes(DB_getItem($_TABLES['topics'], 'topic', "tid = '{$tid}'")); // Retrieve list of inherited topics for anonymous user $tid_list = TOPIC_getChildList($tid, 1); //$sql = "SELECT sid,uid,title,introtext,bodytext,postmode,UNIX_TIMESTAMP(date) AS modified,commentcode,trackbackcode FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() AND tid = '$tid' AND perm_anon > 0 ORDER BY date DESC $limitsql"; $sql = "SELECT sid,uid,title,introtext,bodytext,postmode,UNIX_TIMESTAMP(date) AS modified,commentcode,trackbackcode\n FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n WHERE draft_flag = 0 AND date <= NOW() AND perm_anon > 0\n AND ta.type = 'article' AND ta.id = sid\n AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$tid}')))\n GROUP BY sid\n ORDER BY date DESC {$limitsql}"; $result = DB_query($sql); $nrows = DB_numRows($result); for ($i = 1; $i <= $nrows; $i++) { $row = DB_fetchArray($result); $sids[] = $row['sid']; $storytitle = stripslashes($row['title']); $fulltext = stripslashes($row['introtext'] . "\n" . $row['bodytext']); $fulltext = PLG_replaceTags($fulltext); $storytext = $contentLength == 1 ? $fulltext : COM_truncateHTML($fulltext, $contentLength, ' ...'); $fulltext = trim($fulltext); $fulltext = str_replace(array("\r\n", "\r"), "\n", $fulltext); if ($row['postmode'] == 'plaintext') { if (!empty($storytext)) { $storytext = COM_nl2br($storytext); } if (!empty($fulltext)) { $fulltext = COM_nl2br($fulltext); } } $storylink = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $row['sid']); $extensionTags = PLG_getFeedElementExtensions('article', $row['sid'], $feedType, $feedVersion, $tid, $fid); if ($_CONF['trackback_enabled'] && $feedType == 'RSS' && $row['trackbackcode'] >= 0) { $trbUrl = TRB_makeTrackbackUrl($row['sid']); $extensionTags['trackbacktag'] = '<trackback:ping>' . htmlspecialchars($trbUrl) . '</trackback:ping>'; } $article = array('title' => $storytitle, 'summary' => $storytext, 'text' => $fulltext, 'link' => $storylink, 'uid' => $row['uid'], 'author' => COM_getDisplayName($row['uid']), 'date' => $row['modified'], 'format' => $row['postmode'], 'topic' => $topic, 'extensions' => $extensionTags); if ($row['commentcode'] >= 0) { $article['commenturl'] = $storylink . '#comments'; } $content[] = $article; } } $link = $_CONF['site_url'] . '/index.php?topic=' . $tid; $update = implode(',', $sids); return $content; }
} } elseif ($statuscode == STORY_DELETE_ON_EXPIRE) { COM_errorLog("Delete Story and comments: {$sid}, Topic: {$expiretopic}, Title: {$title}, Expired: {$expire}"); STORY_doDeleteThisStoryNow($sid); } } // Figure out different settings to display stories in a topic $sql = " (date <= NOW()) AND (draft_flag = 0)"; if (empty($topic)) { $sql .= COM_getLangSQL('tid', 'AND', 'ta'); } // if a topic was provided only select those stories. $tid_list = ''; if (!empty($topic)) { // Retrieve list of inherited topics $tid_list = TOPIC_getChildList($topic); // Could have empty list if $topic does not exist or does not have permission so let it equal topic and will error out properly at end if (empty($tid_list)) { $tid_list = "'" . $topic . "'"; } $sql .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$topic}')))"; } else { $sql .= " AND frontpage = 1 AND ta.tdefault = 1"; } if (strtolower($topic) != strtolower($archivetid)) { $sql .= " AND ta.tid != '{$archivetid}' "; } $sql .= COM_getPermSQL('AND', 0, 2, 's'); if (!empty($U['aids'])) { $sql .= " AND s.uid NOT IN (" . str_replace(' ', ",", $U['aids']) . ") "; }
function fncEdit($message = "", $wkymlmguserflg = false) { global $_CONF; global $_TABLES; global $LANG_ASSIST_ADMIN; global $LANG_ADMIN; global $_ASSIST_CONF; global $LANG_ASSIST_INTROBODY; global $LANG_ASSIST_TOENV; global $LANG31; global $_SCRIPTS; $retval = ''; //メッセージ表示 if (!empty($message)) { $retval .= COM_startBlock($LANG_ASSIST_ADMIN['msg'], '', COM_getBlockTemplate('_msg_block', 'header')); $retval .= $message; $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); // clean 'em up $fromname = COM_applyFilter($_POST['fromname']); $replyto = COM_applyFilter($_POST['replyto']); $sprefix = COM_applyFilter($_POST['sprefix']); $sid = COM_applyFilter($_POST['sid']); $testto = COM_applyFilter($_POST['testto']); $uidfrom = COM_applyFilter($_POST['uidfrom'], true); $uidto = COM_applyFilter($_POST['uidto'], true); // hiroron start 2010/07/13 $dt_year = COM_applyFilter($_POST['datetime_year'], true); $dt_month = COM_applyFilter($_POST['datetime_month'], true); $dt_day = COM_applyFilter($_POST['datetime_day'], true); $dt_hour = COM_applyFilter($_POST['datetime_hour'], true); $dt_minute = COM_applyFilter($_POST['datetime_minute'], true); $datetime_value = COM_convertDate2Timestamp($dt_year . '-' . $dt_month . '-' . $dt_day, $dt_hour . ':' . $dt_minute . ':00'); // 冒頭文 本文 introbody $introbody = COM_applyFilter($_POST['introbody'], true); //送信先環境 $toenv = COM_applyFilter($_POST['toenv'], true); //送信先グループ $selectgroup = COM_applyFilter($_POST['selectgroup'], true); // ユーザの受信許可設定を無視して送る $overstyr = COM_applyFilter($_POST['overstyr'], true); //一括予約 $bulkmm = COM_applyFilter($_POST['bulkmm'], true); $bulkcnt = COM_applyFilter($_POST['bulkcnt'], true); } else { $fromname = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_fromname'"); $fromname = COM_stripslashes($fromname); if ($fromname == "") { $fromname = $_CONF['site_name']; } $replyto = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_replyto'"); $replyto = COM_stripslashes($replyto); if ($replyto == "") { $replyto = $_CONF['site_mail']; } $sprefix = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_sprefix'"); $sprefix = COM_stripslashes($sprefix); $sid = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_sid'"); $sid = COM_stripslashes($sid); $testto = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_testto'"); $testto = COM_stripslashes($testto); $uidfrom = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_uidfrom'"); $uidfrom = COM_stripslashes($uidfrom); $uidto = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_uidto'"); $uidto = COM_stripslashes($uidto); // hiroron start 2010/07/13 $datetime_value = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_re_datetime'"); // 冒頭文 本文 introbody $introbody = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_introbody'"); //送信先環境 $toenv = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_toenv'"); //送信先グループ $selectgroup = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_selectgroup'"); // ユーザの受信許可設定を無視して送る $overstyr = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_overstyr'"); $bulkmm = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_bulkmm'"); $bulkcnt = DB_getItem($_TABLES['vars'], 'value', "name = 'assist_bulkcnt'"); } $retval .= COM_startBlock($LANG_ASSIST_ADMIN['edit'], '', COM_getBlockTemplate('_admin_block', 'header')); $pi_name = "assist"; $tmplfld = assist_templatePath('admin', 'default', $pi_name); $templates = new Template($tmplfld); // Loads jQuery UI datepicker if (version_compare(VERSION, '2.0.0') >= 0) { $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker'); $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n'); $_SCRIPTS->setJavaScriptFile('datepicker', '/javascript/datepicker.js'); $langCode = COM_getLangIso639Code(); $toolTip = 'Click and select a date'; // Should be translated $imgUrl = $_CONF['site_url'] . '/images/calendar.png'; $_SCRIPTS->setJavaScript("jQuery(function () {" . " geeklog.datepicker.set('datetime', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE); } $templates->set_file('editor', "newsletter.thtml"); //-- $templates->set_var('lang_must', $LANG_ASSIST_ADMIN['must']); $templates->set_var('site_url', $_CONF['site_url']); $templates->set_var('site_admin_url', $_CONF['site_admin_url']); $token = SEC_createToken(); $retval .= SEC_getTokenExpiryNotice($token); $templates->set_var('gltoken_name', CSRF_TOKEN); $templates->set_var('gltoken', $token); $templates->set_var('xhtml', XHTML); $templates->set_var('script', THIS_PLUGIN . "/" . THIS_SCRIPT); //----- $w = ""; $logfile = $_CONF['path_log'] . 'assist_newsletter.log'; if (!file_exists($logfile)) { $w .= sprintf($LANG_ASSIST_ADMIN['mail_logfile'], $logfile); } else { if (!is_writable($logfile)) { $w .= sprintf($LANG_ASSIST_ADMIN['mail_logfile'], $logfile); } } $tid = $_ASSIST_CONF['newsletter_tid']; $topicname = DB_getItem($_TABLES['topics'], 'topic', "tid = '{$tid}'"); if ($topicname == "") { $topicname = $tid; } $w .= sprintf($LANG_ASSIST_ADMIN['mail_msg'], $topicname); $templates->set_var('mail_msg', $w); $templates->set_var('mail_msg1', $LANG_ASSIST_ADMIN['mail_msg1']); $templates->set_var('mail_msg2', $LANG_ASSIST_ADMIN['mail_msg2']); $templates->set_var('mail_msg3', $LANG_ASSIST_ADMIN['mail_msg3']); $templates->set_var('mail_msg4', $LANG_ASSIST_ADMIN['mail_msg4']); $templates->set_var('lang_fromname', $LANG_ASSIST_ADMIN['fromname']); //@@@@@ $templates->set_var('help_fromname', $LANG_ASSIST_ADMIN['help']); $templates->set_var('fromname', $fromname); //replyto $templates->set_var('lang_replyto', $LANG_ASSIST_ADMIN['replyto']); $templates->set_var('replyto', $replyto); //subject_prefix $templates->set_var('lang_sprefix', $LANG_ASSIST_ADMIN['sprefix']); $templates->set_var('sprefix', $sprefix); //sid $templates->set_var('lang_sid', $LANG_ASSIST_ADMIN['sid']); $templates->set_var('sid', $sid); //FOR GL2.0.0 if (COM_versionCompare(VERSION, "2.0.0", '>=')) { //$where ="s.sid = t.id AND t.tid=\"".$tid."\""; //$tables="{$_TABLES['stories']} AS s ,{$_TABLES['topic_assignments']} AS ta"; $topics = TOPIC_getChildList($tid); $where = "s.sid = ta.id "; if ($topics == "") { $where .= " AND tid=\"" . $tid . "\""; } else { $where .= " AND ta.tid IN ({$topics})"; } $tables = "{$_TABLES['stories']} AS s "; $tables .= " ,{$_TABLES['topic_assignments']} AS ta"; $optionlist_sid = "<option value=''>{$LANG_ASSIST_ADMIN['select_sid']}</option>" . LB; $optionlist_sid .= COM_optionList($tables, 'distinct s.sid,s.title,s.date*-1', $sid, 2, $where); } else { $where = "tid=\"" . $tid . "\""; $optionlist_sid = "<option value=''>{$LANG_ASSIST_ADMIN['select_sid']}</option>" . LB; $optionlist_sid .= COM_optionList($_TABLES['stories'], 'sid,title,date*-1', $sid, 2, $where); } $templates->set_var('optionlist_sid', $optionlist_sid); // 冒頭文 本文 introbody $templates->set_var('lang_introbody', $LANG_ASSIST_ADMIN['introbody']); $list_introbody = assist_getradiolist($LANG_ASSIST_INTROBODY, "introbody", $introbody); $templates->set_var('list_introbody', $list_introbody); //送信先環境 $templates->set_var('lang_toenv', $LANG_ASSIST_ADMIN['toenv']); $list_toenv = assist_getradiolist($LANG_ASSIST_TOENV, "toenv", $toenv); $templates->set_var('list_toenv', $list_toenv); //送信先グループ $thisUsersGroups = SEC_getUserGroups(); uksort($thisUsersGroups, 'strcasecmp'); $optionlist_selectgroup = ''; if ($wkymlmguserflg == true) { $optionlist_selectgroup .= '<option value="' . 99999 . '"'; if ($selectgroup > 0 && $selectgroup == "99999") { $optionlist_selectgroup .= ' selected="selected"'; } $optionlist_selectgroup .= '>' . $LANG_ASSIST_ADMIN['wkymlmguser_user'] . '</option>' . LB; } foreach ($thisUsersGroups as $groupName => $groupID) { if ($groupName != 'All Users') { $optionlist_selectgroup .= '<option value="' . $groupID . '"'; if ($selectgroup > 0 && $selectgroup == $groupID) { $optionlist_selectgroup .= ' selected="selected"'; } $optionlist_selectgroup .= '>' . ucwords($groupName) . '</option>' . LB; } } $templates->set_var('lang_selectgroup', $LANG_ASSIST_ADMIN['selectgroup']); $templates->set_var('optionlist_selectgroup', $optionlist_selectgroup); // ユーザの受信許可設定を無視して送る $templates->set_var('lang_overstyr', $LANG31['14']); if ($overstyr == 0) { $templates->set_var('is_checked_overstyr', ''); } else { $templates->set_var('is_checked_overstyr', 'checked="checked"'); } //testto $templates->set_var('lang_testto', $LANG_ASSIST_ADMIN['testto']); $templates->set_var('testto', $testto); //uidfrom-to $templates->set_var('lang_sendto', $LANG_ASSIST_ADMIN['sendto']); $templates->set_var('lang_uidfrom', $LANG_ASSIST_ADMIN['uidfrom']); $templates->set_var('uidfrom', $uidfrom); $templates->set_var('lang_uidto', $LANG_ASSIST_ADMIN['uidto']); $templates->set_var('uidto', $uidto); $templates->set_var('lang_sendto_remarks', $LANG_ASSIST_ADMIN['sendto_remarks']); if ($wkymlmguserflg == true) { $templates->set_var('user_wkymlmguser', $LANG_ASSIST_ADMIN['wkymlmguser_on']); } else { $templates->set_var('user_wkymlmguser', $LANG_ASSIST_ADMIN['wkymlmguser_off']); } // hiroron start 2010/07/13 if ($datetime_value === "") { $datetime_value = time(); } $datetime_month = date('m', $datetime_value); $datetime_day = date('d', $datetime_value); $datetime_year = date('Y', $datetime_value); $datetime_hour = date('H', $datetime_value); $datetime_minute = date('i', $datetime_value); $month_options = COM_getMonthFormOptions($datetime_month); $day_options = COM_getDayFormOptions($datetime_day); $year_options = COM_getYearFormOptions($datetime_year); $hour_options = COM_getHourFormOptions($datetime_hour, 24); $minute_options = COM_getMinuteFormOptions($datetime_minute); $templates->set_var('lang_reserv_datetime', $LANG_ASSIST_ADMIN['reserv_datetime']); $templates->set_var('datetime', 'datetime'); $templates->set_var('datetime_year_options', $year_options); $templates->set_var('datetime_month_options', $month_options); $templates->set_var('datetime_day_options', $day_options); $templates->set_var('datetime_hour_options', $hour_options); $templates->set_var('datetime_minute_options', $minute_options); $templates->set_var('lang_yy', $LANG_ASSIST_ADMIN['yy']); $templates->set_var('lang_mm', $LANG_ASSIST_ADMIN['mm']); $templates->set_var('lang_dd', $LANG_ASSIST_ADMIN['dd']); // hiroron end 2010/07/13 $templates->set_var('lang_reserv_datetime_remarks', $LANG_ASSIST_ADMIN['reserv_datetime_remarks']); //予約送信 //$templates->set_var( 'lang_bulkbooking', $LANG_ASSIST_ADMIN['mail_bulkbooking']); $templates->set_var('minute', $LANG_ASSIST_ADMIN['minute']); $templates->set_var('every', $LANG_ASSIST_ADMIN['every']); $templates->set_var('increments', $LANG_ASSIST_ADMIN['increments']); $templates->set_var('bulkmm', $bulkmm); $templates->set_var('bulkcnt', $bulkcnt); // SAVE、CANCEL ボタン $templates->set_var('lang_save', $LANG_ADMIN['save']); $templates->set_var('lang_cancel', $LANG_ADMIN['cancel']); $templates->set_var('lang_testsend', $LANG_ASSIST_ADMIN['mail_test']); $templates->set_var('lang_send', $LANG_ASSIST_ADMIN['mail_send']); // hiroron start 2010/07/13 $templates->set_var('lang_reserv', $LANG_ASSIST_ADMIN['mail_reserv']); // hiroron end 2010/07/13 // hiroron start 2010/07/15 $templates->set_var('list_reserv', fncListReserv()); // hiroron end 2010/07/15 // $templates->parse('output', 'editor'); $retval .= $templates->finish($templates->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }