Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 4

Author Topic: [ADDON] phpEventCalendar  (Read 25993 times)

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
[ADDON] phpEventCalendar
« on: November 18, 2007, 06:53:51 AM »

Integrating phpEventCalendar http://www.ikemcg.com/pec

REMEMBER - BACKUP.  I may have missed something in the instructions (it works fine for me)
1.  Download the modified calendar package
 

2.  Unpack the files into a subdirectory named cal (it MUST be cal, or you will have to modify the package/directions) under snews (e.g if snews is installed in root directory, then directory is root/cal, or if snews is installed in subdirectory, then its root/snews/cal)

3.  Fill out config.php with your snews database information (no need to install it in another database).  Be sure to keep the prefix as pec (If you do change the prefix, you will need to edit the new search function).

4.  Add the following functions to snews.php.
NOTE: The additional cal_pages function is only necessary if you wish to have a .current class added on for css purposes. If you do not wish to have such a class, you can choose to leave the function out of snews.php (but be sure to change cal_pages to pages in default.php in the calendar package, and hard link the calendar yourself in the current pages() function)
     
Code: [Select]
function cal_pages() {
$categorySEF = get_id('category'); $pageSEF = get_id('article'); $home = l('home_sef');
echo '<li><a href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';
echo '<li><a href="'.db('website').'archive/" title="'.l('archive').'">'.l('archive').'</a></li>';
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
$title = $r['title'];
if ($r['id'] != s('display_page')) {echo '<li><a href="'.db('website').l('home_sef').'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a></li>';}
}
echo '<li><a class="current" href="'.db('website').'cal/" title="'.l('events').'">'.l('events').'</a></li>';
echo '<li><a href="'.db('website').'contact/" title="'.l('contact').'">'.l('contact').'</a></li>';
echo '<li><a href="'.db('website').'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'</a></li>';
}

Code: [Select]
function cal_breadcrumbs() {
$link = '<a href="'.db('website').'';
if ($_SESSION[db('website').'Logged_In'] == token()) {echo $link.'administration/" title="'.l('administration').'">'.l('administration').'</a> '.l('divider').' ';}
$categorySEF = get_id('category'); $articleSEF = get_id('article'); $home = l('home_sef');
echo (empty($categorySEF) || $categorySEF == $home || !empty($articleSEF)) ? $link.'" title="'.l('home').'">'.l('home').'</a>' : l('home');
echo ' '.l('divider').' '.(!empty($articleSEF) ? $link.$categorySEF.'/" title="'.l('events').'">'.l('events').'</a>' : l('events'));
}

Code: [Select]
function cal_title() {
$title = s('website_title');
$title .= ' - Calendar';
echo '<title>'.$title.'</title>';
echo '<meta http-equiv="Content-Type" content="text/html; charset='.s('charset').'" />';
echo '<meta name="description" content="'.(!empty($dmeta) ? $dmeta : s('website_description')).'" />';
echo '<meta name="keywords" content="'.(!empty($kmeta) ? $kmeta : s('website_keywords')).'" />';
if ($_SESSION[db('website').'Logged_In'] == token()) {js();}
}

5.  Replace current function search() with this
Code: [Select]
function search() {
$search_query = clean(cleanXSS($_POST['search_query']));
echo '<h2>'.l(search_results).'</h2>';
if (strlen($search_query) < 4 || $search_query == l('search_keywords')) {echo '<p>'.l(charerror).'</p>';}
else {
$keywords = explode(' ', $search_query);
$keyCount = count($keywords);
$query = "SELECT * FROM ".db('prefix')."articles WHERE SUBSTRING(position, 1, 1) != '2' AND published = 1 AND";
if ($keyCount > 1) {
for ($i = 0; $i < $keyCount - 1; $i++) {$query = $query." (title LIKE '%$keywords[$i]%' || text LIKE '%$keywords[$i]%') &&";}
$j = $keyCount - 1;
$query = $query." (title LIKE '%$keywords[$j]%' || text LIKE '%$keywords[$j]%')";}
else {$query = $query." (title LIKE '%$keywords[0]%' || text LIKE '%$keywords[0]%')";}
$query1 = "SELECT * FROM pec_mssgs WHERE";
if ($keyCount > 1) {
for ($i = 0; $i < $keyCount - 1; $i++) {$query1 = $query1." (title LIKE '%$keywords[$i]%' || text LIKE '%$keywords[$i]%') &&";}
$j = $keyCount - 1;
$query1 = $query1." (title LIKE '%$keywords[$j]%' || text LIKE '%$keywords[$j]%')";}
else {$query1 = $query1." (title LIKE '%$keywords[0]%' || text LIKE '%$keywords[0]%')";}
$query = $query." ORDER BY id DESC";
$query1 = $query1." ORDER BY y DESC, m DESC, d DESC";
$result = mysql_query($query);
$result1 = mysql_query($query1);
$numrows = mysql_num_rows($result);
$numrows1 = mysql_num_rows($result1);
if (!$numrows and !$numrows1) {echo '<p>'.l('noresults').' <strong>'.stripslashes($search_query).'</strong>.</p>';}
else {
$totalnumrows = $numrows + $numrows1;
echo '<p><strong>'.$totalnumrows.'</strong> '.l('resultsfound').' <strong>'.stripslashes($search_query).'</strong>.</p>';
if ($numrows > 0) {
echo '<strong>Articles</strong>';
while ($r = mysql_fetch_array($result)) {
$date = date(s('date_format'), strtotime($r['date']));
echo '<p><a href="'.db('website').find_cat_sef($r['category']).'/'.$r['seftitle'].'/">'.$r['title'].'</a> - '.$date.'</p>';}}
if ($numrows1 > 0) {
echo '<strong>Events</strong><br />';
while ($r1 = mysql_fetch_array($result1)) {
echo '<p class=\"title_txt\"><a href=javascript:openPosting('
. $r1 ["id"]. ")>"
. $r1['title'] . "</a>&nbsp;-&nbsp;"
.$r1['m']. "."
.$r1['d']. "."
.$r1['y'].
"</p>"
;}}
}
}
echo '<p><br /><a href="'.db('website').'">'.l('backhome').'</a></p>';
$searched = true;
}

6.  In your SNEWS index.php, change
Code: [Select]
<?php title(); ?> to
Code: [Select]
<?php title(); search_javascript();?>
7.  After
Code: [Select]
// dependancy limiter
function dependancy() {
var category = document.forms['post']['define_category'];
var page = document.getElementById('def_page');
page.style.display = category.options[category.selectedIndex].value == '-1' ? 'inline' : 'none';
}
add
Code: [Select]
//Event Posting
function postMessage(day, month, year) {
eval(
"page" + day + " = window.open('cal/eventform.php?d=" + day + "&m=" +
month + "&y=" + 2007 + "', 'postScreen', 'toolbar=0,scrollbars=1," +
"location=0,statusbar=0,menubar=0,resizable=1,width=340,height=400');"
);
}

8.  in administration form change
Code: [Select]
echo '<p><a href="files/" title="'.l('files').'">'.l('files').'</a></p></fieldset>';to
Code: [Select]
echo '<p><a href="files/" title="'.l('files').'">'.l('files').'</a></p>';
echo '<p><a href="javascript: postMessage()" title="Add Event">Add Event</a></p></fieldset>';

9.  Add new language variable
Code: [Select]
$l['events'] = 'Calendar';
10.  Upload everything to server and run createtables.php
11.  Delete createtables.php
12.  UPDATE 11/20.  Add Calendar link to Sitemap
Code: [Select]
echo $link.'cal/">'.l('events').'</a><br />';That should be it.  I may have missed something, so please backup everything before you start.  If i did miss anything, let me know.
13.  UPDATE 11/23.  in your SNEWS index.php change 
Code: [Select]
<?php session_start(); include('snews.php'); ?>to
Code: [Select]
<?php session_start(); include('snews.php'); include('cal/functions.php'); ?>14.  UPDATE 11/23 in snews.php, hardlink the calendar in pages() function
Code: [Select]
echo '<li><a href="'.db('website').'cal/" title="'.l('events').'"><span>'.l('events').'</span></a></li>';15.  UPDATE 11/23.  I have made an error in default.php.  in the package, change
in default.php, change
Code: [Select]
<?php cal_title(); javaScript() ?>to
Code: [Select]
<?php cal_title(); javaScript(); ?>
NOTES:
1.  Calendar doesn't have SEF friendly URLs.
2.  Calendar has unpatched vulnerability http://secunia.com/advisories/25915/ (if anyone knows how to fix this, I'm all ears)
UPDATE 11/18
I have updated the cal.zip package to pass the id parameter (eventdisplay.php) through the clean(cleanXSS)) snews functions which should rectify the problem.
3.  I would love for this to not use pop-ups as much as the next guy, so if anyone has suggestions or mods, I'm all ears (I believe it would require a significant rewrite).
4.  If anyone sees inefficiencies that they can fix, once again, I'm all ears :)
5.  I will try to add recurring events to the package
6.  Doesn't validate
7.  You can add events one of 2 ways.  Either click add event in the snews admin panel after you login, or you can login to snews, and then navigate to your calendar, and click on the dates.
« Last Edit: January 05, 2009, 08:58:07 AM by mike1 »
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: [ADDON] phpEventCalendar
« Reply #1 on: November 18, 2007, 11:54:59 AM »

since you are fitting snews.php with some code, you could try (I believe it will work) removing your step 6, and making the last line of the title() function
Code: [Select]
search_javascript();
just a thought
Logged
Of all the things I have lost, it is my mind that I miss the most.

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #2 on: November 18, 2007, 02:41:00 PM »

since you are fitting snews.php with some code, you could try (I believe it will work) removing your step 6, and making the last line of the title() function
Code: [Select]
search_javascript();
just a thought

The cal_title function here is for the calendar's default.php (in the modified package).  If I were to remove step 6, i would just have to add another step adding the javascript to the snews index.php title function (rather than the calendar functions.pgp).  Theoretically, I'm sure you,re right, but the current way just means less copying/pasting (if I understand what youre saying).
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: [ADDON] phpEventCalendar
« Reply #3 on: November 19, 2007, 12:17:21 PM »

indeed, but the line you are altering in index.php is
<?php title(); ?>
which is the default snews title function.
My point being, that since you are editing snews.php to add these custom functions, it would be just as easy to make the snews.php title() function call the search_javascript() function, so end of default title() would be like
Code: [Select]
...
if ($_SESSION[db('website').'Logged_In'] == token()) {js();}
search_javascript();
}
Logged
Of all the things I have lost, it is my mind that I miss the most.

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #4 on: November 19, 2007, 06:42:03 PM »

fair enough.  I'll try to make that change (and a few other changes to make the calendar more Addonish as opposed to Modish) sometime if theres interest (if not, the current method is good enough for me).
« Last Edit: November 20, 2007, 08:28:55 PM by mike1 »
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #5 on: November 23, 2007, 07:05:00 PM »

I use snewsMEMU and trying til include the PEC into the scrpit. I have tryed to go trought it a couple of times, and all the inclutions seems to bee fine. Everything gets white when i add the search_javascript into the default title function and on the top of the index.php. I have tried both of the inclution alternatives. so please help a fella..
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #6 on: November 23, 2007, 09:37:31 PM »

Nice catch.  I forgot an include in the SNEWS index.php file (i have updated the original post, step 13)
Place this right after the snews.php include but before the ?>
Code: [Select]
include('cal/functions.php');
A word of caution, I completely removed the calendar's authentication.  The only way you can add events to the calendar is if you are logged into snews (so basically single sign-on for both snews and the calendar).  I do not know how this will work in MU (so low level users may get access to editing the calendar).  In all honesty, I doubt that this will work with the MU version without some changes (although please do let me know if no changes are needed).

In the SU snews, there is a single authentication statement to check if the admin is logged in (if $session blah ==token()).  This is probably different for the MU version.  Depending on what level of user you want to be able to add/edit events, you MAY have to change the function.  However, let me know if the default package works first.  If it doesnt, I may delve into the MU version (finals are coming up, so I may not be as helpful though).
« Last Edit: November 23, 2007, 09:40:11 PM by mike1 »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [ADDON] phpEventCalendar
« Reply #7 on: November 23, 2007, 10:12:33 PM »

Yes... as Mike1 notes... the user authentication strings are different in MU than they are in SU versions... but they should be fairly easy to figure out. If not... I am sure bakercad will give you assistance if you showl him what you need to change.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #8 on: November 23, 2007, 10:53:08 PM »

should be a fairly easy change

in eventdisplay.php, eventform.php, eventsubmit.php, and functions.php, wherever I have inserted
Code: [Select]
if ($_SESSION[db('website').'Logged_In'] == token() {change to
Code: [Select]
if ($_SESSION[db('website').'Logged_In'] == token() && get_identity($_SESSION['id'], 'level') < '4') {where you change 4 to the level of user you want to be able to edit the calendar (the only numbers you should use are 4, 3, or 2).

NOT TESTED :)
« Last Edit: November 23, 2007, 11:15:16 PM by mike1 »
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #9 on: November 24, 2007, 12:12:55 AM »

Thanx for everything, but I still have the same problem exept that I now can se the original page index.  The index in Cal is stil unavalable og white. I have not started on the mod in the MU section yet, but I will after I got the hang of the problem with the inclution of phpEventCalendar.


www.xclusive.name <---- it seems like everything is workin fine, since I don't have any errors.. Please help me get this to work.
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #10 on: November 24, 2007, 01:01:22 AM »

can you post your calendar index.php and default.php files?

also, Keyrocks changed snews.php to core.php in his package.  you will have to make the change in the include statements in the cal package (index.php, eventdisplay.php, eventsubmit.php, eventform.php).
« Last Edit: November 24, 2007, 01:25:46 AM by mike1 »
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #11 on: November 24, 2007, 01:16:26 AM »

Code: [Select]
<?php
session_start
();
require(
"config.php");
require(
"./lang/lang." LANGUAGE_CODE ".php");
require(
"functions.php");
include(
"../snewsMU.php");

# testing whether var set necessary to suppress notices when E_NOTICES on
$month 
(isset($_GET['month'])) ? (int) $_GET['month'] : null;
$year =
(isset($_GET['year'])) ? (int) $_GET['year'] : null;

# set month and year to present if month 
# and year not received from query string
$m = (!$month) ? date("n") : $month;
$y = (!$year)  ? date("Y") : $year;

$scrollarrows scrollArrows($m$y);

require(
"./templates/" TEMPLATE_NAME ".php");
?>




Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php cal_title(); javaScript() ?>
<link rel="stylesheet" type="text/css" href="css/default.css">
    <link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<div class="wrap">
<div id="logo">
<h1><?php echo s('website_title'); ?></h1>
</div>

<ul id="menu">
<?php cal_pages(); ?>
</ul>

<div id="subheader">
<div id="breadcrumbs">
<?php cal_breadcrumbs(); ?>
</div>

<div id="search">
<?php searchform(); ?>
</div>
</div>

<div id="left">
<h3>Categories:</h3>
<ul>
<?php categories(); ?>
</ul>

<h3>New Articles:</h3>
<ul>
<?php menu_articles(0,3); ?>
</ul>

<h3>New comments:</h3>
<ul>
<?php new_comments(530); ?>
</ul>

<?php extra(); ?>
</div>

<div id="right">
            <table cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td>
<?php echo $scrollarrows ?>
<span class="date_header">
&nbsp;<?php echo $lang['months'][$m-1?>&nbsp;<?php echo $y ?></span>
</td>

<!-- form tags must be outside of <td> tags -->
<form name="monthYear">
<td align="right">
<?php monthPullDown($m$lang['months']); yearPullDown($y); ?>
<input type="button" value="GO" onClick="submitMonthYear()">
</td>
</form>

</tr>

<tr>
<td colspan="2" bgcolor="#000000">
<?php echo writeCalendar($m$y); ?></td>
</tr>

</table>
</div>

<div id="footer">
<ul id="rss">
<?php rss_links(); ?>
</ul>
<p>Barbecued by <a href="http://snews.solucija.com/" title="Single file CMS">sNews</a> &middot; <?php login_link(); ?></p>
</div>
</div>
</body>
</html>

The changes to core.php is not made in snewsMEMU, it's called snewsMU.php, atleast that I can see. And as you can see I have made the changes in index.php to snewsMU.php.

« Last Edit: November 24, 2007, 01:22:05 AM by Anders Hansen »
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #12 on: November 24, 2007, 01:20:27 AM »

did you also make the change in the other files I specified?
Logged

Anders Hansen

  • Newbie
  • *
  • Karma: 0
  • Posts: 35
  • Yehaaaaa
    • Kaff
Re: [ADDON] phpEventCalendar
« Reply #13 on: November 24, 2007, 01:30:29 AM »

did you also make the change in the other files I specified?

Yes..
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
Re: [ADDON] phpEventCalendar
« Reply #14 on: November 24, 2007, 01:35:26 AM »

in default.php, change
Code: [Select]
<?php cal_title(); javaScript() ?>to
Code: [Select]
<?php cal_title(); javaScript(); ?>
That is an error in the package on my part.  My apologies
« Last Edit: November 24, 2007, 01:39:08 AM by mike1 »
Logged
Pages: [1] 2 3 4