dPmsg('Updating version information');
    // No matter what occurs we should update the database version in the dpversion table.
    if (empty($lastDBUpdate)) {
        $lastDBUpdate = $code_updated;
    }
    $sql = "UPDATE dpversion\n SET db_version = '{$dp_version_major}',\n last_db_update = '{$lastDBUpdate}',\n code_version = '{$current_version}',\n last_code_update = '{$code_updated}'\n WHERE 1";
    $db->Execute($sql);
} else {
    $dbMsg = 'Not Created';
    if (!$dbc) {
        $dbErr = 1;
        $dbMsg .= '<br/>No Database Connection available! ' . ($db ? $db->ErrorMsg() : '');
    }
}
// always create the config file content
dPmsg('Creating config');
$config = '<?php ' . "\n";
$config .= 'if (!defined(\'DP_BASE_DIR\')) {' . "\n";
$config .= '	die(\'You should not access this file directly.\');' . "\n";
$config .= '}' . "\n";
$config .= '### Copyright (c) 2004, The dotProject Development Team dotproject.net and sf.net/projects/dotproject ###' . "\n";
$config .= '### All rights reserved. Released under GPL License. For further Information see LICENSE ###' . "\n";
$config .= "\n";
$config .= '### CONFIGURATION FILE AUTOMATICALLY GENERATED BY THE DOTPROJECT INSTALLER ###' . "\n";
$config .= '### FOR INFORMATION ON MANUAL CONFIGURATION AND FOR DOCUMENTATION SEE ./includes/config-dist.php ###' . "\n";
$config .= "\n";
$config .= '$dPconfig[\'dbtype\'] = \'' . $dbtype . '\';' . "\n";
$config .= '$dPconfig[\'dbhost\'] = \'' . $dbhost . '\';' . "\n";
$config .= '$dPconfig[\'dbname\'] = \'' . $dbname . '\';' . "\n";
$config .= '$dPconfig[\'dbuser\'] = \'' . $dbuser . '\';' . "\n";
$config .= '$dPconfig[\'dbpass\'] = \'' . $dbpass . '\';' . "\n";
        if (!checkCompanyId($contact_company)) {
            dPmsg('Error found in contact_company in the contact ' . getContactGeneralInformation($contact));
        }
    } else {
        if ($contact_company != "") {
            $company_id = fetchCompanyId($contact_company);
            // If we find company_id
            if (!$company_id) {
                // We need to create the new company
                $company_id = insertCompany($contact_company);
            }
            if ($company_id) {
                updateContactCompany($contact, $company_id);
                dPmsg("Contact's company updated - " . getContactGeneralInformation($contact) . " - ({$company_id}) {$contact_company}");
            } else {
                dPmsg("Unable to update contact's company - " . getContactGeneralInformation($contact));
            }
        }
    }
}
function updateContactCompany($contact_array, $company_id)
{
    $q = new DBQuery();
    $q->addTable('contacts');
    $q->addUpdate('contact_company = ' . $company_id);
    $q->addWhere('contact_id = ' . $contact_array['contact_id']);
    db_exec($q->prepareUpdate());
}
function getContactGeneralInformation($contact_array)
{
    $contact_info = '(' . $contact_array['contact_id'] . ') ';
// Responsable de tarea
$perms->add_acl($viewINA_perms, null, array($resp_role), null, array($admin_mods), 1, 1, null, null, "user");
$perms->add_acl($view_perms, null, array($resp_role), null, array($non_admin_mods), 1, 1, null, null, "user");
$perms->add_acl($all_perms, null, array($resp_role), null, array($log_tareas), 1, 1, null, null, "user");
// Consultor
$perms->add_acl($view_perms, null, array($cons_role), null, array($non_admin_mods), 1, 1, null, null, "user");
$perms->add_acl($viewINA_perms, null, array($cons_role), null, array($admin_mods), 1, 1, null, null, "user");
dPmsg("Converting admin user permissions to Administrator Role");
// Now we have the basics set up we need to create objects for all users
$sql = "SELECT user_id, user_username, permission_id from users\nLEFT JOIN permissions ON permission_user = users.user_id and permission_grant_on = 'all' \nAND permission_item = -1 and permission_value = -1";
$res = db_exec($sql);
if ($res) {
    while ($row = db_fetch_assoc($res)) {
        // Add the basic ARO
        $perms->add_object("user", $row["user_username"], $row["user_id"], 1, 0, "aro");
        if ($row["permission_id"]) {
            $perms->add_group_object($admin_role, "user", $row["user_id"], "aro");
        }
    }
}
dPmsg("Searching for add-on modules to add to new permissions");
// Upgrade permissions for custom modules
$sql = "SELECT mod_directory, mod_name, permissions_item_table\n\tFROM modules\n\tWHERE mod_ui_active = 1\n\tAND mod_type = 'user'";
$custom_modules = db_loadList($sql);
foreach ($custom_modules as $mod) {
    $perms->addModule($mod['mod_directory'], $mod['mod_name']);
    $perms->addGroupItem($mod['mod_directory'], "non_admin");
    if (isset($mod['permissions_item_table']) && $mod['permissions_item_table']) {
        $perms->addModuleSection($mod['permissions_item_table']);
    }
}
Example #4
0
                contact_email,
                contact_phone,
                contact_phone2,
                contact_mobile,
                contact_address1,
                contact_address2,
                contact_city,
                contact_state,
                contact_zip,
                contact_country,
                contact_icq,
                contact_icon,
                contact_owner)
                VALUES  (\'' . $user['user_first_name'] . "', '" . $user['user_last_name'] . "', '" . $user['user_birthday'] . "', " . dPgetParam($user, 'user_company', 0) . ", '" . dPgetParam($user, 'user_department', 0) . "', '" . $user['user_email'] . "', '" . $user['user_phone'] . "', '" . $user['user_home_phone'] . "', '" . $user['user_mobile'] . "', '" . $user['user_address1'] . "', '" . $user['user_address2'] . "', '" . $user['user_city'] . "', '" . $user['user_state'] . "', '" . $user['user_zip'] . "', '" . $user['user_country'] . "', '" . $user['user_icq'] . "', '" . $user['user_pic'] . "', '" . $user['user_owner'] . "')";
    db_exec($sql);
    $msg = db_error();
    $sql = 'INSERT INTO user_preferences VALUES (' . $user['user_id'] . ', \'USERFORMAT\', \'user\')';
    db_exec($sql);
    $msg = db_error();
    if ($msg) {
        dPmsg($msg);
    }
    $sql = 'UPDATE users 
                        SET user_contact=LAST_INSERT_ID() 
                        WHERE user_id = ' . $user['user_id'];
    db_exec($sql);
    $msg = db_error();
    if ($msg) {
        dPmsg($msg);
    }
}
Example #5
0
    dPmsg("Updating version information");
    // No matter what occurs we should update the database version in the dpversion table.
    if (empty($lastDBUpdate)) {
        $lastDBUpdate = $code_updated;
    }
    $sql = "UPDATE dpversion\n\t\tSET db_version = '{$dp_version_major}',\n\t\tlast_db_update = '{$lastDBUpdate}',\n\t\tcode_version = '{$current_version}',\n\t\tlast_code_update = '{$code_updated}'\n\t\tWHERE 1";
    $db->Execute($sql);
} else {
    $dbMsg = "Not Created";
    if (!$dbc) {
        $dbErr = 1;
        $dbMsg .= "<br/>No Database Connection available! " . ($db ? $db->ErrorMsg() : '');
    }
}
// always create the config file content
dPmsg("Creating config");
$config = "<?php \n";
$config .= "### Copyright (c) 2004, The dotProject Development Team dotproject.net and sf.net/projects/dotproject ###\n";
$config .= "### All rights reserved. Released under GPL License. For further Information see LICENSE ###\n";
$config .= "\n";
$config .= "### CONFIGURATION FILE AUTOMATICALLY GENERATED BY THE DOTPROJECT INSTALLER ###\n";
$config .= "### FOR INFORMATION ON MANUAL CONFIGURATION AND FOR DOCUMENTATION SEE ./includes/config-dist.php ###\n";
$config .= "\n";
$config .= "\$dPconfig['dbtype'] = '{$dbtype}';\n";
$config .= "\$dPconfig['dbhost'] = '{$dbhost}';\n";
$config .= "\$dPconfig['dbname'] = '{$dbname}';\n";
$config .= "\$dPconfig['dbuser'] = '******';\n";
$config .= "\$dPconfig['dbpass'] = '******';\n";
$config .= "\$dPconfig['dbpersist'] = " . ($dbpersist ? 'true' : 'false') . ";\n";
$config .= "\$dPconfig['root_dir'] = \$baseDir;\n";
$config .= "\$dPconfig['base_url'] = \$baseUrl;\n";
Example #6
0
/**
 * DEVELOPERS PLEASE NOTE:
 *
 * For the new upgrader/installer to work, this code must be structured
 * correctly.  In general if there is a difference between the from
 * version and the to version, then all updates should be performed.
 * If the $last_udpated is set, then a partial update is required as this
 * is a CVS update.  Make sure you create a new case block for any updates
 * that you require, and set $latest_update to the date of the change.
 *
 * Each case statement should fall through to the next, so that the
 * complete update is run if the last_updated is not set.
 *
 * FURTHER NOTE:  As of 2.1, individual upgrade*.php files are deprecated
 * as they are not necessary.  ALL UPDATE CODE needs to be in upgrade_latest.php.
 * The individual SQL files are still required, however.
 */
function dPupgrade($from_version, $to_version, $last_updated)
{
    $latest_update = '20080728';
    // Set to the latest upgrade date.
    if (empty($last_updated) || empty($from_version)) {
        $last_updated = '00000000';
    }
    $perms = new dPacl();
    // Place the upgrade code here, depending on the last_updated date.
    // DO NOT REMOVE PREVIOUS VERSION CODE!!!
    switch ($last_updated) {
        case '00000000':
            $sql = 'SELECT project_id, project_departments, project_contacts FROM projects';
            $projects = db_loadList($sql);
            //split out related departments and store them seperatly.
            $sql = 'DELETE FROM project_departments';
            db_exec($sql);
            //split out related contacts and store them seperatly.
            $sql = 'DELETE FROM project_contacts';
            db_exec($sql);
            foreach ($projects as $project) {
                $p_id = $project['project_id'] ? $project['project_id'] : '0';
                $departments = explode(',', $project['project_departments']);
                foreach ($departments as $department) {
                    $sql = 'INSERT INTO project_departments (project_id, department_id) values (' . $p_id . ', ' . $department . ')';
                    if ($p_id && $department) {
                        db_exec($sql);
                    }
                }
                $contacts = explode(',', $project['project_contacts']);
                foreach ($contacts as $contact) {
                    $sql = 'INSERT INTO project_contacts (project_id, contact_id) values (' . $p_id . ', ' . $contact . ')';
                    if ($p_id && $contact) {
                        db_exec($sql);
                    }
                }
            }
            /**
             *  This segment will extract all the task/department and task/contact relational info and populate the task_departments and task_contacts tables.
             **/
            $sql = 'SELECT task_id, task_departments, task_contacts FROM tasks';
            $tasks = db_loadList($sql);
            //split out related departments and store them seperatly.
            $sql = 'DELETE FROM task_departments';
            db_exec($sql);
            //split out related contacts and store them seperatly.
            $sql = 'DELETE FROM task_contacts';
            db_exec($sql);
            foreach ($tasks as $task) {
                $departments = explode(',', $task['task_departments']);
                foreach ($departments as $department) {
                    if ($department) {
                        $sql = 'INSERT INTO task_departments (task_id, department_id) values (' . $task['task_id'] . ', ' . $department . ')';
                        db_exec($sql);
                    }
                }
                $contacts = explode(',', $task['task_contacts']);
                foreach ($contacts as $contact) {
                    if ($contact) {
                        $sql = 'INSERT INTO task_contacts (task_id, contact_id) values (' . $task['task_id'] . ', ' . $contact . ')';
                        db_exec($sql);
                    }
                }
            }
            $sql = 'ALTER TABLE `projects` ADD `project_active` TINYINT(4) DEFAULT 1';
            db_exec($sql);
            if (strcmp($from_version, '2') < 0) {
                include DP_BASE_DIR . '/db/upgrade_contacts.php';
            }
            include DP_BASE_DIR . '/db/upgrade_permissions.php';
            // Fallthrough
        // Fallthrough
        case '20050314':
            // Add the permissions for task_log
            dPmsg('Adding Task Log permissions');
            $perms->add_object('app', 'Task Logs', 'task_log', 11, 0, 'axo');
            $all_mods = $perms->get_group_id('all', null, 'axo');
            $nonadmin = $perms->get_group_id('non_admin', null, 'axo');
            $perms->add_group_object($all_mods, 'app', 'task_log', 'axo');
            $perms->add_group_object($nonadmin, 'app', 'task_log', 'axo');
        case '20050316':
            include DP_BASE_DIR . '/db/upgrade_contacts_company.php';
        case '20070521':
            // DP2.1RC2
        // DP2.1RC2
        case '20071014':
            // DP2.1
            // Add view of users table to guest and project worker roles
            $guest = $perms->get_group_id('guest', null, 'aro');
            $worker = $perms->get_group_id('normal', null, 'aro');
            $perms->add_acl(array('application' => array('view')), null, array($worker, $guest), array('app' => array('users')), null, 1, 1, null, null, 'user');
            // TODO:  Add new versions here.  Keep this message above the default label.
        // TODO:  Add new versions here.  Keep this message above the default label.
        case '20071104':
            // Last changed date.
            // Add the permissions for task_log
            dPmsg('Adding File Folder permissions');
            $perms->add_object('app', 'File Folders', 'file_folders', 6, 0, 'axo');
            $all_mods = $perms->get_group_id('all', null, 'axo');
            $nonadmin = $perms->get_group_id('non_admin', null, 'axo');
            $perms->add_group_object($all_mods, 'app', 'file_folders', 'axo');
            $perms->add_group_object($nonadmin, 'app', 'file_folders', 'axo');
        case '20071114':
        case '20071204':
        case '20071218':
        default:
            break;
    }
    return $latest_update;
}
$perms->add_acl($access_perms, null, array($anon_role), null, array($non_admin_mods), 1, 1, null, null, 'user');
// Worker has All on non-admin
$perms->add_acl($all_perms, null, array($worker_role), null, array($non_admin_mods), 1, 1, null, null, 'user');
// Set view permissions to users table to guest and worker roles.
$perms->add_acl($view_perms, null, array($worker_role, $guest_role), array('app' => array('users')), null, 1, 1, null, null, 'user');
// Now we have the basic set up we need to create objects for all users
dPmsg('Converting admin user permissions to Administrator Role');
$sql = 'SELECT user_id, user_username, permission_id ' . 'FROM ' . $dbprefix . 'users LEFT JOIN ' . $dbprefix . 'permissions ON permission_user = user_id' . ' WHERE permission_grant_on = ' . "'all'" . " AND permission_item = -1 AND permission_value = -1";
$res = db_exec($sql);
if ($res) {
    while ($row = db_fetch_assoc($res)) {
        // Add the basic ARO
        $perms->add_object('user', $row['user_username'], $row['user_id'], 1, 0, 'aro');
        if ($row['permission_id']) {
            $perms->add_group_object($admin_role, 'user', $row['user_id'], 'aro');
        }
    }
}
// Upgrade permissions for custom modules
dPmsg('Searching for add-on modules to add to new permissions');
$sql = 'SELECT mod_directory, mod_name, permissions_item_table FROM ' . $dbprefix . 'modules ' . 'WHERE mod_ui_active = 1 AND mod_type = ' . "'user'";
$custom_modules = db_loadList($sql);
foreach ($custom_modules as $mod) {
    $perms->addModule($mod['mod_directory'], $mod['mod_name']);
    $perms->addGroupItem($mod['mod_directory'], 'non_admin');
    if (isset($mod['permissions_item_table']) && $mod['permissions_item_table']) {
        $perms->addModuleSection($mod['permissions_item_table']);
    }
}
// Finally we need to regenerate the cached permissions.
$perms->regeneratePermissions();
Example #8
0
 function setMsg($msg, $msgno = '', $append = false)
 {
     return dPmsg($msgno . $msg);
 }
Example #9
0
/**
 * DEVELOPERS PLEASE NOTE:
 *
 * For the new upgrader/installer to work, this code must be structured
 * correctly.  In general if there is a difference between the from
 * version and the to version, then all updates should be performed.
 * If the $last_udpated is set, then a partial update is required as this
 * is a CVS update.  Make sure you create a new case block for any updates
 * that you require, and set $latest_update to the date of the change.
 *
 * Each case statement should fall through to the next, so that the
 * complete update is run if the last_updated is not set.
 *
 * FURTHER NOTE:  As of 2.1, individual upgrade*.php files are deprecated
 * as they are not necessary.  ALL UPDATE CODE needs to be in upgrade_latest.php.
 * The individual SQL files are still required, however.
 */
function dPupgrade($from_version, $to_version, $last_updated)
{
    $latest_update = '20070217';
    // Set to the latest upgrade date.
    if (empty($last_updated) || empty($from_version)) {
        $last_updated = '00000000';
    }
    // Place the upgrade code here, depending on the last_updated date.
    // DO NOT REMOVE PREVIOUS VERSION CODE!!!
    switch ($last_updated) {
        case '00000000':
            $sql = "SELECT project_id, project_departments, project_contacts FROM projects";
            $projects = db_loadList($sql);
            //split out related departments and store them seperatly.
            $sql = 'DELETE FROM project_departments';
            db_exec($sql);
            //split out related contacts and store them seperatly.
            $sql = 'DELETE FROM project_contacts';
            db_exec($sql);
            foreach ($projects as $project) {
                $p_id = $project['project_id'] ? $project['project_id'] : '0';
                $departments = explode(',', $project['project_departments']);
                foreach ($departments as $department) {
                    $sql = 'INSERT INTO project_departments (project_id, department_id) values (' . $p_id . ', ' . $department . ')';
                    if ($p_id && $department) {
                        db_exec($sql);
                    }
                }
                $contacts = explode(',', $project['project_contacts']);
                foreach ($contacts as $contact) {
                    $sql = 'INSERT INTO project_contacts (project_id, contact_id) values (' . $p_id . ', ' . $contact . ')';
                    if ($p_id && $contact) {
                        db_exec($sql);
                    }
                }
            }
            /**
             *  This segment will extract all the task/department and task/contact relational info and populate the task_departments and task_contacts tables.
             **/
            $sql = "SELECT task_id, task_departments, task_contacts FROM tasks";
            $tasks = db_loadList($sql);
            //split out related departments and store them seperatly.
            $sql = 'DELETE FROM task_departments';
            db_exec($sql);
            //split out related contacts and store them seperatly.
            $sql = 'DELETE FROM task_contacts';
            db_exec($sql);
            foreach ($tasks as $task) {
                $departments = explode(',', $task['task_departments']);
                foreach ($departments as $department) {
                    if ($department) {
                        $sql = 'INSERT INTO task_departments (task_id, department_id) values (' . $task['task_id'] . ', ' . $department . ')';
                        db_exec($sql);
                    }
                }
                $contacts = explode(',', $task['task_contacts']);
                foreach ($contacts as $contact) {
                    if ($contact) {
                        $sql = 'INSERT INTO task_contacts (task_id, contact_id) values (' . $task['task_id'] . ', ' . $contact . ')';
                        db_exec($sql);
                    }
                }
            }
            $sql = "ALTER TABLE `projects` ADD `project_active` TINYINT(4) DEFAULT 1";
            db_exec($sql);
            include DP_BASE_DIR . "/db/upgrade_contacts.php";
            include DP_BASE_DIR . "/db/upgrade_permissions.php";
            // Fallthrough
        // Fallthrough
        case '20050314':
            // Add the permissions for task_log
            dPmsg("Adding Task Log permissions");
            $perms =& new dPacl();
            $perms->add_object('app', 'Task Logs', 'task_log', 11, 0, 'axo');
            $all_mods = $perms->get_group_id('all', null, 'axo');
            $nonadmin = $perms->get_group_id('non_admin', null, 'axo');
            $perms->add_group_object($all_mods, 'app', 'task_log', 'axo');
            $perms->add_group_object($nonadmin, 'app', 'task_log', 'axo');
        case '20050316':
            include DP_BASE_DIR . "/db/upgrade_contacts_company.php";
            // TODO:  Add new versions here.  Keep this message above the default label.
        // TODO:  Add new versions here.  Keep this message above the default label.
        default:
            break;
    }
    return $latest_update;
}
Example #10
0
    dPmsg('バージョン情報更新');
    // No matter what occurs we should update the database version in the dpversion table.
    if (empty($lastDBUpdate)) {
        $lastDBUpdate = $code_updated;
    }
    $sql = "UPDATE dpversion\n SET db_version = '{$dp_version_major}',\n last_db_update = '{$lastDBUpdate}',\n code_version = '{$current_version}',\n last_code_update = '{$code_updated}'\n WHERE 1";
    $db->Execute($sql);
} else {
    $dbMsg = '作成されません';
    if (!$dbc) {
        $dbErr = 1;
        $dbMsg .= '<br/>有効なデータベースコネクションがありません! ' . ($db ? $db->ErrorMsg() : '');
    }
}
// always create the config file content
dPmsg('コンフィグファイル作成');
$config = '<?php ' . "\n";
$config .= 'if (!defined(\'DP_BASE_DIR\')) {' . "\n";
$config .= '	die(\'このファイルに直接アクセスすることは出来ません。\');' . "\n";
$config .= '}' . "\n";
$config .= '### Copyright (c) 2004, The dotProject Development Team dotproject.net and sf.net/projects/dotproject ###' . "\n";
$config .= '### All rights reserved. Released under GPL License. For further Information see LICENSE ###' . "\n";
$config .= "\n";
$config .= '### CONFIGURATION FILE AUTOMATICALLY GENERATED BY THE DOTPROJECT INSTALLER ###' . "\n";
$config .= '### FOR INFORMATION ON MANUAL CONFIGURATION AND FOR DOCUMENTATION SEE ./includes/config-dist.php ###' . "\n";
$config .= "\n";
$config .= '$dPconfig[\'dbtype\'] = \'' . $dbtype . '\';' . "\n";
$config .= '$dPconfig[\'dbhost\'] = \'' . $dbhost . '\';' . "\n";
$config .= '$dPconfig[\'dbname\'] = \'' . $dbname . '\';' . "\n";
$config .= '$dPconfig[\'dbuser\'] = \'' . $dbuser . '\';' . "\n";
$config .= '$dPconfig[\'dbpass\'] = \'' . $dbpass . '\';' . "\n";
/**
 * DEVELOPERS PLEASE NOTE:
 *
 * For the new upgrader/installer to work, this code must be structured
 * correctly.  In general if there is a difference between the from
 * version and the to version, then all updates should be performed.
 * If the $last_udpated is set, then a partial update is required as this
 * is a CVS update.  Make sure you create a new case block for any updates
 * that you require, and set $latest_update to the date of the change.
 *
 * Each case statement should fall through to the next, so that the
 * complete update is run if the last_updated is not set.
 */
function dPupgrade($from_version, $to_version, $last_updated)
{
    global $baseDir;
    $latest_update = '20050316';
    // Set to the latest upgrade date.
    /**
     *  This segment will extract all the project/department and project/contact relational info and populate the project_departments and project_contacts tables.
     **/
    if ($from_version != $to_version || $last_updated == '') {
        $last_updated = '00000000';
    }
    switch ($last_updated) {
        case '00000000':
            $sql = "SELECT project_id, project_departments, project_contacts FROM projects";
            $projects = db_loadList($sql);
            //split out related departments and store them seperatly.
            $sql = 'DELETE FROM project_departments';
            db_exec($sql);
            //split out related contacts and store them seperatly.
            $sql = 'DELETE FROM project_contacts';
            db_exec($sql);
            foreach ($projects as $project) {
                $departments = explode(',', $project['project_departments']);
                foreach ($departments as $department) {
                    $sql = 'INSERT INTO project_departments (project_id, department_id) values (' . $project['project_id'] . ', ' . $department . ')';
                    db_exec($sql);
                }
                $contacts = explode(',', $project['project_contacts']);
                foreach ($contacts as $contact) {
                    $sql = 'INSERT INTO project_contacts (project_id, contact_id) values (' . $project['project_id'] . ', ' . $contact . ')';
                    db_exec($sql);
                }
            }
            /**
             *  This segment will extract all the task/department and task/contact relational info and populate the task_departments and task_contacts tables.
             **/
            $sql = "SELECT task_id, task_departments, task_contacts FROM tasks";
            $tasks = db_loadList($sql);
            //split out related departments and store them seperatly.
            $sql = 'DELETE FROM task_departments';
            db_exec($sql);
            //split out related contacts and store them seperatly.
            $sql = 'DELETE FROM task_contacts';
            db_exec($sql);
            foreach ($tasks as $task) {
                $departments = explode(',', $task['task_departments']);
                foreach ($departments as $department) {
                    $sql = 'INSERT INTO task_departments (task_id, department_id) values (' . $task['task_id'] . ', ' . $department . ')';
                    db_exec($sql);
                }
                $contacts = explode(',', $task['task_contacts']);
                foreach ($contacts as $contact) {
                    $sql = 'INSERT INTO task_contacts (task_id, contact_id) values (' . $task['task_id'] . ', ' . $contact . ')';
                    db_exec($sql);
                }
            }
            include "{$baseDir}/db/upgrade_contacts.php";
            include "{$baseDir}/db/upgrade_permissions.php";
            // Fallthrough
        // Fallthrough
        case '20050314':
            // Add the permissions for task_log
            dPmsg("Adding Task Log permissions");
            $perms =& new dPacl();
            $perms->add_object('app', 'Task Logs', 'task_log', 11, 0, 'axo');
            $all_mods = $perms->get_group_id('all', null, 'axo');
            $nonadmin = $perms->get_group_id('non_admin', null, 'axo');
            $perms->add_group_object($all_mods, 'app', 'task_log', 'axo');
            $perms->add_group_object($nonadmin, 'app', 'task_log', 'axo');
        case '20050316':
            include "{$baseDir}/db/upgrade_contacts_company.php";
        default:
            break;
    }
    return $latest_update;
}
        include_once "{$baseDir}/db/upgrade_permissions.php";
        // Always required on install.
    }
    dPmsg("Updating version information");
    // No matter what occurs we should update the database version in the dpversion table.
    $sql = "UPDATE dpversion\n SET db_version = '{$dp_version_major}',\n last_db_update = '{$lastDBUpdate}',\n code_version = '{$current_version}',\n last_code_update = '{$code_updated}'\n WHERE 1";
    $db->Execute($sql);
} else {
    $dbMsg = "No creado";
    if (!$dbc) {
        $dbErr = 1;
        $dbMsg .= "<br/>Imposible conectar a la Base de Datos " . ($db ? $db->ErrorMsg() : '');
    }
}
// always create the config file content
dPmsg("Creando configuración");
$config = "<?php \n";
$config .= "### Copyright (c) 2004, The dotProject Development Team dotproject.net and sf.net/projects/dotproject ###\n";
$config .= "### All rights reserved. Released under BSD License. For further Information see ./includes/config-dist.php ###\n";
$config .= "\n";
$config .= "### CONFIGURATION FILE AUTOMATICALLY GENERATED BY THE DOTPROJECT INSTALLER ###\n";
$config .= "### FOR INFORMATION ON MANUAL CONFIGURATION AND FOR DOCUMENTATION SEE ./includes/config-dist.php ###\n";
$config .= "\n";
$config .= "\$dPconfig['dbtype'] = \"{$dbtype}\";\n";
$config .= "\$dPconfig['dbhost'] = \"{$dbhost}\";\n";
$config .= "\$dPconfig['dbname'] = \"{$dbname}\";\n";
$config .= "\$dPconfig['dbuser'] = \"{$dbuser}\";\n";
$config .= "\$dPconfig['dbpass'] = \"{$dbpass}\";\n";
$config .= "\$dPconfig['dbpersist'] = " . ($dbpersist ? 'true' : 'false') . ";\n";
$config .= "\$dPconfig['root_dir'] = \$baseDir;\n";
$config .= "\$dPconfig['base_url'] = \$baseUrl;\n";