[ Index ] |
|
Code source de dotProject 2.1 RC1 |
1 <?php 2 3 if (! defined('DP_BASE_DIR')) { 4 die("You must not call this file directly, it is run automatically on install/upgrade"); 5 } 6 include_once DP_BASE_DIR."/includes/config.php"; 7 include_once DP_BASE_DIR."/includes/main_functions.php"; 8 require_once DP_BASE_DIR."/includes/db_adodb.php"; 9 include_once DP_BASE_DIR."/includes/db_connect.php"; 10 include_once DP_BASE_DIR."/install/install.inc.php"; 11 require_once DP_BASE_DIR."/classes/permissions.class.php"; 12 13 /** 14 * DEVELOPERS PLEASE NOTE: 15 * 16 * For the new upgrader/installer to work, this code must be structured 17 * correctly. In general if there is a difference between the from 18 * version and the to version, then all updates should be performed. 19 * If the $last_udpated is set, then a partial update is required as this 20 * is a CVS update. Make sure you create a new case block for any updates 21 * that you require, and set $latest_update to the date of the change. 22 * 23 * Each case statement should fall through to the next, so that the 24 * complete update is run if the last_updated is not set. 25 * 26 * FURTHER NOTE: As of 2.1, individual upgrade*.php files are deprecated 27 * as they are not necessary. ALL UPDATE CODE needs to be in upgrade_latest.php. 28 * The individual SQL files are still required, however. 29 */ 30 function dPupgrade($from_version, $to_version, $last_updated) 31 { 32 33 $latest_update = '20070217'; // Set to the latest upgrade date. 34 35 if (empty($last_updated) || empty($from_version)) { 36 $last_updated = '00000000'; 37 } 38 39 // Place the upgrade code here, depending on the last_updated date. 40 // DO NOT REMOVE PREVIOUS VERSION CODE!!! 41 switch ($last_updated) { 42 case '00000000': 43 $sql = "SELECT project_id, project_departments, project_contacts FROM projects"; 44 $projects = db_loadList( $sql ); 45 46 //split out related departments and store them seperatly. 47 $sql = 'DELETE FROM project_departments'; 48 db_exec( $sql ); 49 //split out related contacts and store them seperatly. 50 $sql = 'DELETE FROM project_contacts'; 51 db_exec( $sql ); 52 53 foreach ($projects as $project){ 54 $p_id = (($project['project_id'])?$project['project_id']:'0'); 55 $departments = explode(',',$project['project_departments']); 56 foreach($departments as $department){ 57 $sql = 'INSERT INTO project_departments (project_id, department_id) values ('.$p_id.', '.$department.')'; 58 if ($p_id && $department) { 59 db_exec( $sql ); 60 } 61 } 62 63 $contacts = explode(',',$project['project_contacts']); 64 foreach($contacts as $contact){ 65 $sql = 'INSERT INTO project_contacts (project_id, contact_id) values ('.$p_id.', '.$contact.')'; 66 if ($p_id && $contact) { 67 db_exec( $sql ); 68 } 69 } 70 } 71 72 /** 73 * This segment will extract all the task/department and task/contact relational info and populate the task_departments and task_contacts tables. 74 **/ 75 76 $sql = "SELECT task_id, task_departments, task_contacts FROM tasks"; 77 $tasks = db_loadList( $sql ); 78 79 //split out related departments and store them seperatly. 80 $sql = 'DELETE FROM task_departments'; 81 db_exec( $sql ); 82 //split out related contacts and store them seperatly. 83 $sql = 'DELETE FROM task_contacts'; 84 db_exec( $sql ); 85 86 foreach ($tasks as $task){ 87 $departments = explode(',',$task['task_departments']); 88 foreach($departments as $department){ 89 if ($department) { 90 $sql = 'INSERT INTO task_departments (task_id, department_id) values ('.$task['task_id'].', '.$department.')'; 91 db_exec( $sql ); 92 } 93 } 94 95 $contacts = explode(',',$task['task_contacts']); 96 foreach($contacts as $contact){ 97 if ($contact) { 98 $sql = 'INSERT INTO task_contacts (task_id, contact_id) values ('.$task['task_id'].', '.$contact.')'; 99 db_exec( $sql ); 100 } 101 } 102 } 103 104 $sql = "ALTER TABLE `projects` ADD `project_active` TINYINT(4) DEFAULT 1"; 105 db_exec( $sql ); 106 107 include DP_BASE_DIR."/db/upgrade_contacts.php"; 108 include DP_BASE_DIR."/db/upgrade_permissions.php"; 109 110 // Fallthrough 111 case '20050314': 112 // Add the permissions for task_log 113 dPmsg("Adding Task Log permissions"); 114 $perms =& new dPacl; 115 $perms->add_object('app', 'Task Logs', 'task_log', 11, 0, 'axo'); 116 $all_mods = $perms->get_group_id('all', null, 'axo'); 117 $nonadmin = $perms->get_group_id('non_admin', null, 'axo'); 118 $perms->add_group_object($all_mods, 'app', 'task_log', 'axo'); 119 $perms->add_group_object($nonadmin, 'app', 'task_log', 'axo'); 120 case '20050316': 121 include DP_BASE_DIR."/db/upgrade_contacts_company.php"; 122 // TODO: Add new versions here. Keep this message above the default label. 123 default: 124 break; 125 } 126 127 return $latest_update; 128 } 129 130 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 18 19:46:52 2007 | par Balluche grâce à PHPXref 0.7 |