Code Search for Developers
 
 
  

rm_duplicates.php from Group-Office groupware at Krugle


Show rm_duplicates.php syntax highlighted

<?php

require('../../Group-Office.php');

function is_duplicate_contact($record)
{
	$db = new db();
	
	$record = array_map('addslashes', $record);
	
	$sql = "SELECT id FROM ab_contacts WHERE ".
		"addressbook_id='".$record['addressbook_id']."' AND ".
		"first_name='".$record['first_name']."' AND ".
		"middle_name='".$record['middle_name']."' AND ".
		"last_name='".$record['last_name']."' AND ".
		"email='".$record['email']."'";
		
	$db->query($sql);
	if($db->num_rows()>1)
	{
		return true;
	}
	return false;
}


$db = new db();

$sql = "SELECT *
	FROM `ab_contacts`
	ORDER BY mtime DESC";
	
$db->query($sql);

require('../../modules/addressbook/classes/addressbook.class.inc');
$ab = new addressbook();

$counter = 0;
while($db->next_record())
{
	if(is_duplicate_contact($db->Record))
	{
		$ab->delete_contact($db->f('id'));
		$counter++;
	}
}
echo 'Deleted '.$counter.' duplicate contacts';



require('../../modules/calendar/classes/calendar.class.inc');
$cal = new calendar();

function is_duplicate_event($record)
{
	$db = new db();
	
	$record = array_map('addslashes', $record);
	
	$sql = "SELECT id FROM cal_events INNER JOIN cal_events_calendars ON cal_events.id=cal_events_calendars.event_id WHERE ".
		"name='".$record['name']."' AND ".
		"start_time='".$record['start_time']."' AND ".
		"end_time='".$record['end_time']."' AND ".
		"calendar_id='".$record['calendar_id']."' AND ".
		"user_id='".$record['user_id']."'";
		
	$db->query($sql);
	if($db->num_rows()>1)
	{
		return true;
	}
	return false;
}



$sql = "SELECT id, name, start_time, end_time, user_id, calendar_id FROM `cal_events` INNER JOIN cal_events_calendars ON cal_events.id=cal_events_calendars.event_id ORDER BY mtime DESC";

$db->query($sql);

$counter = 0;
while($db->next_record())
{
	if(is_duplicate_event($db->Record))
	{
		$cal->delete_event($db->f('id'));
		$counter++;
	}
}
echo 'Deleted '.$counter.' duplicate events';




See more files for this project here

Group-Office groupware

Group-Office is a powerfull modular Internet/Intranet application framework. It features calendaring, project management, e-mail, tasks, addressbook, file management.

Project homepage: http://sourceforge.net/projects/group-office
Programming language(s): JavaScript,Pascal,PHP
License: other

  195.inc
  202.inc
  213.inc
  216.inc
  218.inc
  alias.sh
  check_links.php
  clean_events.php
  convert_links.php
  createmodule.php
  generatecode.php
  get_new_acl.php
  grant_all_to_admins.php
  reset_db_sequence.php
  rm_duplicates.php
  test_ical_import.php
  test_update_script.php
  test_vcard_export.php
  test_vcard_import.php
  update_shares.php
  vcal.icf
  vcard.vcf