set_file(array('itemstats'=>'itemstatistics.thtml', 'statrow'=>'singlestat.thtml')); $retval=''; if ($showsitestats == 1) { // This shows in the summary box $total_pages=DB_count($_TABLES['table1']); // Fill this with count for summary $summary_label = "{plugin}"; // Fill this with label displayed $retval = ""; $retval .= ""; $retval .= "
$summary_label" . $total_pages . "  
"; } else { // This fills the top the box Use the following as a template $result = DB_query("SELECT id, title, hits from {$_TABLES['table1'] WHERE hits > 0 ORDER BY hits desc LIMIT 10"); $nrows = DB_numRows($result); $retval .= COM_startBlock("Top Ten Static Pages"); if ($nrows > 0) { $stat_templates->set_var('item_label',"Page Title"); $stat_templates->set_var('stat_name',"Hits"); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); $stat_templates->set_var('item_url', $_CONF['site_url'] . '/{plugin}/index.php?item=' . $A['id']); $stat_templates->set_var('item_text', $A['title']); $stat_templates->set_var('item_stat', $A['hits']); $stat_templates->parse('stat_row','statrow',true); } $stat_templates->parse('output','itemstats'); $retval .= $stat_templates->finish($stat_templates->get_var('output')); } else { $retval .= 'It appears that there are no {plugin}s on this site or no one has ever viewed them.'; } $retval .= COM_endBlock(); } return $retval; } /** * Geeklog is asking us to provide any new items that show up in the type drop-down * on search.php. Let's let users search! * */ function plugin_searchtypes_{plugin}() { global $LANG_PL00; $tmp['{plugin}'] = $LANG_PL00['externpages']; return $tmp; } /** * this searches for pages matching the user query and returns an array of * for the header and table rows back to search.php where it will be formated and * printed * * @query string Keywords user is looking for * @datestart date/time Start date to get results for * @dateend date/time End date to get results for * @topic string The topic they were searching in * @type string Type of items they are searching * @author string Get all results by this author * */ function plugin_dopluginsearch_{plugin}($query, $datestart, $dateend, $topic, $type, $author) { global $_TABLES, $_CONF, $LANG_PL00; if (empty($type)) { $type = 'all'; } // Bail if we aren't supppose to do our search if ($type <> 'all' AND $type <> '{plugin}') { $plugin_results = new Plugin(); $plugin_results->plugin_name = '{plugin}'; $plugin_results->searchlabel = $LANG_PL00['externpages'] . $LANG_PL00['results']; return $plugin_results; } // Build search SQL - Modified to exclude static PHP pages from search. $sql = "SELECT * from " . $_TABLES['{plugin}']; $result = DB_query($sql); // OK, now create new plugin object and insert table header labels require_once($_CONF['path_system'] . 'classes/plugin.class.php'); $plugin_results = new Plugin(); $plugin_results->plugin_name = '{plugin}'; $plugin_results->searchlabel = $LANG_PL00['externpages'] . $LANG_PL00['results']; $plugin_results->addSearchHeading($LANG_PL00['titlemsg']); $plugin_results->addSearchHeading($LANG_PL00['urlmsg']); $plugin_results->addSearchHeading($LANG_PL00['hitsmsg']); $mycount = DB_numRows($result); // NOTE if any of your data items need to be links then add them here! // make sure data elements are in an array and in the same order as your // headings above! for ($i = 1; $i <= $mycount; $i++) { $A = DB_fetchArray($result); if(SEC_hasAccess($A[owner_id],$A[group_id],$A[perm_owner],$A[perm_group],$A[perm_members],$A[perm_anon])){ // Get text to search $cnts = implode('',file($pth)); // Search it if (stristr($cnts,$query) != '') { $rcnt++; $A['title'] = stripslashes($A['title']); $row = array($A['title'], '' . $A['url'] . "", $A['hits']); $plugin_results->addSearchResult($row); } } } $plugin_results->num_searchresults = $rcnt; $plugin_results->num_itemssearched = DB_count($_TABLES['{plugin}']); return $plugin_results; } /** * * Example Plugin Moderation Functions * authored by Vincent Furia, http://furia.dyndns.org * */ /** * * Checks that the current user has the rights to moderate the * plugin, returns true if this is the case, false otherwise * * @return boolean Returns true if moderator * */ function plugin_ismoderator_lists() { global $_USER, $_TABLES; return SEC_hasRights('lists.admin'); } /** * Returns the number of submissions waiting moderation * * Calculates the number of submissions that are currently waiting * to be moderated and returns that number. * * @return int number of submissions awaiting moderation */ function plugin_submissioncount_lists() { global $_TABLES; return DB_count($_TABLES['listssubmission']); } /** * Performs plugin exclusive work for items approved by moderation * * While moderation.php handles the actual move from submission * to tables, within the function we handle all other approval * relate tasks * * @param string $id Identifying string * @return string Any wanted HTML output * */ function plugin_moderationapprove_lists($id) { global $_TABLES, $_USER, $_CONF; $result = DB_query("SELECT * FROM " . $_TABLES['groups'] . " WHERE grp_name = 'lists Admin'"); $group = DB_fetchArray($result); if ($_CONF['listsarchive'] == 'optional') { $archive = $_CONF['listsarchivedefault']; } elseif ($_CONF['listsarchive'] == 'no') { $archive = 0; } else { // $_CONF['listsarchive'] == 'yes' $archive = 1; } $sql = "UPDATE " . $_TABLES['lists'] . " SET owner_id = " . $_USER['uid'] . ", group_id = " . $group['grp_id'] . ", html = " . $_CONF['listshtml'] . ", archive = $archive WHERE ml_id = '$id'"; $result = DB_query($sql); if (DB_error()) { return 'Error'; } return ''; } /** * Performs plugin exclusive work for items deleted by moderation * * While moderation.php handles the actual removal from submission * table, within this function we handle all other deletion * relate tasks * * @param string $id Identifying string * @return string Any wanted HTML output * */ function plugin_moderationdelete_lists($id) { global $_TABLES; // these tables should not contain any rows with ml_id = $id // this is done 'just in case' DB_delete($_TABLES['listsubscriptions'], 'ml_id', $id); DB_delete($_TABLES['listarchive'], 'ml_id', $id); DB_delete($_TABLES['listpermissions'], 'ml_id', $id); } /** * saves submission to listssubmission table * * takes data input by submission form and populates the submission * table. * * @param array $A array (key => value) of form items * @return boolean returns true if successful * */ function plugin_savesubmission_lists($A) { global $_TABLES, $_USER, $_CONF; // check for missing fields if (empty($A['ml_name']) || empty($A['ml_descr'])) { return false; } if (empty($_USER['uid'])) { $owner_id = 1; } else { $owner_id = $_USER['uid']; } if (SEC_hasRights('links.admin')) { $result = DB_getItem($_TABLES['groups'], '*', "grp_name = 'lists Admin'"); if ($_CONF['listsarchive'] == 'optional') { $archive = $_CONF['listsarchivedefault']; } elseif ($_CONF['listsarchive'] == 'no') { $archive = 0; } else { // $_CONF['listsarchive'] == 'yes' $archive = 1; } DB_save($_TABLES['lists'], 'ml_id, ml_name, ml_descr, html, archive, owner_id, group_id', "'" . COM_makeSid() . "', '" . $A['ml_name'] . "', '" . $A['ml_descr'] . "', " . $_CONF['listshtml'] . ", $archive, $owner_id, " . $result['grp_id']); } elseif ($_CONF['listssubmission'] == 1) { DB_save($_TABLES['listssubmission'], 'ml_id, ml_name, ml_descr', "'" . COM_makeSid() . "', '" . $A['ml_name'] . "', '" . $A['ml_descr'] . "'"); } else { return false; } if (DB_error()) { return false; } return true; } /** * returns list of moderation values * * The array returned contains (in order): the row 'id' label, main plugin * table, moderation fields (comma seperated), and plugin submission table * * @return array Returns array of useful moderation values * */ function plugin_moderationvalues_lists() { global $_TABLES; return array('ml_id', $_TABLES['lists'], 'ml_id, ml_name, ml_descr' , $_TABLES['listssubmission']); } /** * show lists for moderation on submissions page * * Uses the Plugin class to return data required by moderation.php to list * plugin objects that need to be moderated. * * @return Plugin return Plugin class containing submission data * */ function plugin_itemlist_lists() { global $_TABLES; if (plugin_ismoderator_lists()) { $plugin = new Plugin(); $plugin->submissionlabel = 'Mailing List Submissions'; $plugin->getsubmissionssql = "SELECT ml_id as id, ml_name, ml_descr FROM " . $_TABLES['listssubmission']; $plugin->addSubmissionHeading('List Name'); $plugin->addSubmissionHeading('List Description'); return $plugin; } } /** * Returns the plugins submission form * * Returns a string contain the HTML of the submission form for the plugin. * * @return string The HTML form * */ function plugin_submit_lists() { global $_CONF, $LANG12, $HTTP_POST_VARS; if ($_CONF['listssubmission'] == 0 && !SEC_hasRights('lists.admin')) { return "Submission queue disabled for mailing lists"; } if ($HTTP_POST_VARS['mode'] == $LANG12[32]) { // preview $A = $HTTP_POST_VARS; $ml_id = $A['ml_id']; } else { $ml_id = COM_makesid(); } $template = new Template($_CONF['path'] . "plugins/lists/templates/public"); $template->set_file(array('form' => 'submit_form.thtml')); $template->set_var('site_url', $_CONF['site_url']); $template->set_var('lang_name', 'List Name'); $template->set_var('ml_name', $A['ml_name']); $template->set_var('lang_descr', 'Description'); $template->set_var('ml_descr', $A['ml_descr']); $template->set_var('ml_id', $ml_id); $template->set_var('lang_preview', $LANG12[32]); $template->set_var('lang_save', $LANG12[8]); return $template->parse('output', 'form'); } ?>