Posted on: 03/26/05 04:26pm
By: thechadd
Posted on: 03/26/05 04:33pm
By: machinari
Posted on: 03/26/05 07:59pm
By: thechadd
<?php // // +---------------------------------------------------------------------------+ // | Birthday Plugin 1.0 for Geeklog - The Ultimate Weblog | // +---------------------------------------------------------------------------+ // | functions.inc | // | This file does two things: 1) it implements the necessary Geeklog Plugin | // | API method and 2) implements all the common code needed by the birthdays | // | PHP files. | // | | // | This is a generic functions.inc for Geeklog 1.3.6. Edit this file with | // | your favorite editor and replace every instance of birthdays with the name| // | of your plugin. You will then have a skeletal working functions.inc. | // | See documentation to fill in API implementations you man need. | // | You must also fill in the two arrays in the uninstall routine for it to | // | work properly. | // +---------------------------------------------------------------------------+ // | Copyright (C) 2002 by the following authors: | // | | // | Author: | // | Constructed with the Universal Plugin | // | Copyright (C) 2002 by the following authors: | // | Tom Willett - twillett@users.sourceforge.net | // | Blaine Lang - langmail@sympatico.ca | // | The Universal Plugin is based on prior work by: | // | Tony Bibbs - tony@tonybibbs.com | // +---------------------------------------------------------------------------+ // | | // | This program is free software; you can redistribute it and/or | // | modify it under the terms of the GNU General Public License | // | as published by the Free Software Foundation; either version 2 | // | of the License, or (at your option) any later version. | // | | // | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software Foundation, | // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | // | | // +---------------------------------------------------------------------------+ // /** * This is the generic functions.inc for the Universal Plugin Toolkit for Geeklog. * You need to change all instances of birthdays with the name of your plugin. */ /** * Language file Include */ $langfile = $_CONF['path'] . 'plugins/birthdays/language/' . $_CONF['language'] . '.php'; if (file_exists ($langfile)) { include_once ($langfile); } else { include_once ($_CONF['path'] . 'plugins/birthdays/language/english.php'); } /* * Include birthdays config file */ require_once ($_CONF['path'] . 'plugins/birthdays/config.php'); // +---------------------------------------------------------------------------+ // | Geeklog Plugin API Implementations | // +---------------------------------------------------------------------------+ /** * Returns the items for this plugin that should appear on the main menu * * NOTE: this MUST return the url/value pairs in the following format * $<arrayname>[<label>] = <url> * * Universal Plugin: Uncomment and fill in variables; * * @return array Associative array of menu items to be added to menu * */ function plugin_getmenuitems_birthdays() { // global $_CONF; // // $menulabel = "birthdays"; // Put your menu label here // $menurul = $_CONF['site_url'] . "/birthdays/index.php"; // Menu url here // $menuitems = array(); // if (SEC_hasRights('birthdays.view')) { // $menuitems["$menulabel"] = $menurul; // } return $menuitems; } /** * Check to see if this Plugin uses comments * * Geeklog is checking to see if this plugin supports comments, tell it no! * NOTE: to support comments you must use the same date/time based ID for your * widget. In other words, to make primary keys for your plugin you should call * makesid(). Comments are keyed off of that...it is a limitation on how geeklog * does comments. * * @return boolean true or false * */ function plugin_commentsupport_birthdays() { return false; } /** * Shows the statistics for the plugin on stats.php. If * $showsitestats is 1 then we are to only print the overall stats in the 'site * statistics' box otherwise we show the detailed stats for the plugin * * Universal Plugin: Modify/uncomment use it * * @param int showsitestate Flag to let us know which stats to get * @return string returns formatted HTML to insert in stats page * */ function plugin_showstats_birthdays($showsitestats) { // global $_CONF, $_TABLES; // $stat_templates = new Template($_CONF['path_layout'] . 'stats'); // $stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml', // 'statrow'=>'singlestat.thtml')); $retval=''; // if ($showsitestats == 1) { // This shows in the summary box // $total_pages=DB_count($_TABLES['birthdays']); // Fill this with count for summary // $summary_label = "birthdays"; // Fill this with label displayed // $retval = "<table border = '0' width='100%' cellspacing='0' cellpadding='0'>"; // $retval .= "<tr><td>$summary_label</td>"; // $retval .= "<td align='right'>" . $total_pages . "   </td></tr></table>"; // } else { // This fills the top the box Use the following as a template // $result = DB_query("SELECT id, title, hits from {$_TABLES['birthdays'] 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'] . '/birthdays/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 birthdayss on this site or no one has ever viewed them.'; // } // $retval .= COM_endBlock(); // } return $retval; } /** * This will put an option for the plugin in the command and control block on moderation.php * * Add the plugin name, icon and link to the command and control block in moderation.php * * @return array Array containing (plugin name, admin url, url of plugin icon) * */ function plugin_cclabel_birthdays() { global $_CONF; return array('birthdays',$_CONF['site_admin_url'] . '/plugins/birthdays/index.php',$_CONF['site_url'] . '/birthdays/images/birthdays.gif'); } /** * Returns the administrative option for this plugin * * Adds the plugin to the Admin menu * * Universal Plugin: Modify/Uncomment use it * * @return array Array containing (plugin name, plugin admin url, # of items in plugin or '') * */ function plugin_getadminoption_birthdays() { // global $_CONF, $_TABLES; // if (SEC_hasRights('birthdays.admin')) { // return array('birthdays', $_CONF['site_admin_url'] . '/plugins/birthdays/index.php', DB_count($_TABLES['birthdays'])); // } } /** * Returns the user option for this plugin * * Adds the plugin to the user menu * * Universal Plugin: modify/uncomment use it * * @return array Array containing (plugin name, plugin user url, 0) * */ function plugin_getuseroption_birthdays() { // global $_CONF; // if (SEC_hasRights('birthdays.edit,birthdays.view','OR')) { // return array('birthdays', $_CONF['site_url'] . '/birthdays/index.php', 0); // } } /** * Removes the datastructures for this plugin from the Geeklog database. * This routine will get called from the Plugin install program if user select De-Install or if Delete is used in the Plugin Editor. * The Plugin Installer will also call this routine upon and install error to remove anything it has created. * The Plugin installer will pass the optional parameter which will then double check that plugin has first been disabled. * * For this plugin, this routine will also remove the Block definition. * * Returns True if all Plugin related data is removed without error * * @param string $installCheck Defult is blank but if set, check if plugin is disabled first * * @return boolean True if successful false otherwise * */ function plugin_uninstall_birthdays($installCheck='') { global $_TABLES, $LANG_BD00; // The birthdayss need to be changed to the name of your plugin // $pi_name='birthdays'; $FEATURES = array ( 'birthdays.admin', 'birthdays.view'); $TABLES = array ('birthdays'); // Check and see if plugin is still enabled - if so display warning and exit if ($installCheck != '' && DB_getItem($_TABLES['plugins'],'pi_enabled', 'pi_name = "' .$pi_name. '"')) { COM_errorLog("Plugin is installed and enabled. Disable first if you want to de-install it",1); $display .= COM_startBlock($LANG_BD00['warning']); $display .= $LANG_BD00['enabled']; $display .= COM_endBlock(); echo $display; return false; exit; } // Ok to proceed and delete plugin // Unregister the plugin with Geeklog COM_errorLog('Attempting to unregister the birthdays plugin from Geeklog',1); DB_query("DELETE FROM {$_TABLES['plugins']} WHERE pi_name = 'birthdays'",1); // Drop birthdays tables foreach($TABLES as $table) { $t = $_TABLES["$table"]; COM_errorLog("Removing Table $t",1); DB_query("DROP TABLE $t",1); } // Remove Security for this plugin $grp_id = DB_getItem($_TABLES['vars'], 'value', "name = '{$pi_name}_gid'"); COM_errorLog("Removing $pi_name Admin Group", 1); DB_query("DELETE FROM {$_TABLES['groups']} WHERE grp_id = $grp_id",1); DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = '{$pi_name}_gid'"); COM_errorLog("Removing root users from admin of $pi_name"); DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id = $grp_id",1); // Remove all the associated features -- access rights foreach ($FEATURES as $feature) { COM_errorLog("Removing $feature feature and rights to it",1); $feat_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '$feature'"); DB_query("DELETE FROM {$_TABLES['access']} WHERE acc_ft_id = $feat_id",1); DB_query("DELETE FROM {$_TABLES['features']} WHERE ft_id = $feat_id",1); } COM_errorLog('...success',1); return true; } function block_birthdays() { global $_TABLES,$_USER,$LANG_BD00,$_CONF; $retval=''; $curmonth=strftime("%m")+0; $stmt = "SELECT * FROM {$_TABLES['users']} as users,{$_TABLES['birthdays']} as bdays WHERE users.uid=bdays.uid and users.uid='".$_USER['uid']."'"; $result= DB_query("$stmt"); $nrows = DB_numRows($result); if (($nrows <= 0) && (!empty($_USER['uid']))) { $retval="<a href=".$_CONF['site_url']."/birthdays/index.php?mode=edit&uid=".$_USER['uid']."><small>".$LANG_BD00['add']."</small></a><br>"; } $stmt = "SELECT * FROM {$_TABLES['users']} as users,{$_TABLES['birthdays']} as bdays WHERE users.uid=bdays.uid and bdays.month='$curmonth'"; $result = DB_query("$stmt"); $nrows = DB_numRows($result); if ($nrows > 0) { $retval.='<b>This Month</b><ul>'; for ($i = 1; $i <=$nrows; $i++) { $A = DB_fetchArray($result); if ($A['day'] > "") { $retval.="<li>".$A['username']; $retval.=" ".display_birthday($A['day'],$A['month']); } } $retval.='</ul>'; } else { $retval.="No Birthdays this month."; } ++$curmonth; if ($curmonth > 12) { $curmonth=1; } $stmt = "SELECT * FROM {$_TABLES['users']} as users,{$_TABLES['birthdays']} as bdays WHERE users.uid=bdays.uid and bdays.month='$curmonth'"; $result = DB_query("$stmt"); $nrows = DB_numRows($result); if ($nrows > 0) { $retval.='<b>Coming Up</b><ul>'; for ($i = 1; $i <=$nrows; $i++) { $A = DB_fetchArray($result); if ($A['day'] > "") { $retval.="<li>".$A['username']; $retval.=" ".display_birthday($A['day'],$A['month']); } } $retval.='</ul>'; } $retval.="[<a href=".$_CONF['site_url']."/birthdays>".$LANG_BD00['more']."</a>]"; return $retval; } function getMonthName($month) { global $LANG_BD00; $month = $month - 1; switch ($month) { case 0: return $LANG_BD00['jan']; break; case 1: return $LANG_BD00['feb']; break; case 2: return $LANG_BD00['mar']; break; case 3: return $LANG_BD00['apr']; break; case 4: return $LANG_BD00['may']; break; case 5: return $LANG_BD00['jun']; break; case 6: return $LANG_BD00['jul']; break; case 7: return $LANG_BD00['aug']; break; case 8: return $LANG_BD00['sep']; break; case 9: return $LANG_BD00['oct']; break; case 10: return $LANG_BD00['nov']; break; case 11: return $LANG_BD00['dec']; break; default: return 0; break; } } function display_birthday($day,$month) { global $_BD_CONF; switch ($_BD_CONF['format']) { case "dmmm": $m=substr(getMonthName($month),0,3); $retval="$m/$day"; break; case "dm": $retval="$day/$month"; break; case "md": $retval="$month/$day"; break; case "mmmd": $m=substr(getMonthName($month),0,3); $retval="$m/$day"; break; default: $retval="$month/$day"; } return $retval; } function select_day($day) { $str='<select name=day>'; for($i=1;$i <= 31; ++$i) { if ($day == $i) { $selected='selected'; } else { $selected=''; } $str.="<option value=$i $selected>$i"; } $str.='</select>'; return $str; } function select_month($month) { global $_CONF,$LANG_BD00; if(empty($month)) { $month=strftime("%m")+0; } $str="<form name=frm action=". $_CONF['site_url'] . "/birthdays/index.php>" . "<input type=hidden name=mode value='list'> ".$LANG_BD00['select']." Month: <select name=filter_month onChange='javascript:document.frm.submit();return true'><option value='all'>ALL"; for ($i=1; $i <= 12; ++$i) { if ($i==$month) { $selected='selected'; } else { $selected=''; } $str.="<option value=$i $selected>".getMonthName($i); } $str.="</select></form>"; return $str; } ?>
Posted on: 03/26/05 09:55pm
By: machinari
Posted on: 03/26/05 10:23pm
By: thechadd
Posted on: 01/31/06 10:18pm
By: zaurav
Warning: phpblock_birthdays(/home/zaurav/public_html/../plugins/birthdays/functions.inc): failed to open stream: No such file or directory in /home/zaurav/public_html/system/lib-custom.php on line 760 Warning: phpblock_birthdays(): Failed opening '/home/zaurav/public_html/../plugins/birthdays/functions.inc' for inclusion (include_path='/home/zaurav/public_html/system/pear/:.:/usr/lib/php:/usr/local/lib/php') in /home/zaurav/public_html/system/lib-custom.php on line 760 An SQL error has occured. Please see error.log for details
Table 'zaurav_gklg1.birthdays' doesn't exist. SQL in question: SELECT * FROM gl_users as users,birthdays as bdays WHERE users.uid=bdays.uid and users.uid='2'