1 | <?php |
---|
2 | /** |
---|
3 | * TimeSheet - fixing links lost by the bug in the links-class |
---|
4 | * |
---|
5 | * @link http://www.egroupware.org |
---|
6 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
7 | * @package timesheet |
---|
8 | * @copyright (c) 2005 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
---|
9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
---|
10 | * @version $Id$ |
---|
11 | */ |
---|
12 | |
---|
13 | $GLOBALS['phpgw_info'] = array( |
---|
14 | 'flags' => array( |
---|
15 | 'currentapp' => 'admin', |
---|
16 | )); |
---|
17 | include('../header.inc.php'); |
---|
18 | |
---|
19 | require_once(PHPGW_INCLUDE_ROOT.'/timesheet/inc/class.botimesheet.inc.php'); |
---|
20 | |
---|
21 | $bots =& new botimesheet(); |
---|
22 | $so_sql =& new so_sql('timesheet',$bots->table_name); |
---|
23 | |
---|
24 | // search timesheet which have a project-field identical to an exiting PM project, but no link to it |
---|
25 | $rows = $so_sql->search(false,'ts_id,ts_project,ts_title','','pm_id,link_id','',false,'AND',false,array('link_id IS NULL'), |
---|
26 | ' JOIN phpgw_pm_projects ON ts_project='.$so_sql->db->concat('pm_number',"': '",'pm_title'). |
---|
27 | " LEFT JOIN phpgw_links ON (link_app1='timesheet' AND link_id1=ts_id AND link_app2='projectmanager' AND link_id2=pm_id". |
---|
28 | " OR link_app1='projectmanager' AND link_id1=pm_id AND link_app2='timesheet' and link_id2=ts_id)"); |
---|
29 | |
---|
30 | echo "<h1>Fixing links to ProjectManager lost by the bug in the links-class</h1>\n"; |
---|
31 | |
---|
32 | if ($rows) |
---|
33 | { |
---|
34 | foreach($rows as $row) |
---|
35 | { |
---|
36 | if ($bots->link->link('timesheet',$row['ts_id'],'projectmanager',$row['pm_id'])) |
---|
37 | { |
---|
38 | echo "<p>relinked timesheet '$row[ts_title]' with project '$row[ts_project]'</p>\n"; |
---|
39 | } |
---|
40 | } |
---|
41 | } |
---|
42 | echo "<h3>".(is_array($rows) ? count($rows) : 0)." missing links found.</h3>\n"; |
---|