![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: do_project_aed.php 156 2008-04-11 15:47:40Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/projects/do_project_aed.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 $del = w2PgetParam($_POST, 'del', 0); 7 $project_id = intval(w2PgetParam($_POST, 'project_id', 0)); 8 $isNotNew = $_POST['project_id']; 9 $perms = &$AppUI->acl(); 10 if ($del) { 11 if (!$perms->checkModuleItem('projects', 'delete', $project_id)) { 12 $AppUI->redirect('m=public&a=access_denied'); 13 } 14 } elseif ($isNotNew) { 15 if (!$perms->checkModuleItem('projects', 'edit', $project_id)) { 16 $AppUI->redirect('m=public&a=access_denied'); 17 } 18 } else { 19 if (!$perms->checkModule('projects', 'add')) { 20 $AppUI->redirect('m=public&a=access_denied'); 21 } 22 } 23 24 $obj = new CProject(); 25 $msg = ''; 26 27 $notify_owner = ($_POST['email_project_owner_box']) ? 1 : 0; 28 $notify_contacts = ($_POST['email_project_contacts_box']) ? 1 : 0; 29 30 if (!$obj->bind($_POST)) { 31 $AppUI->setMsg($obj->getError(), UI_MSG_ERROR); 32 $AppUI->redirect(); 33 } 34 35 require_once ($AppUI->getSystemClass('CustomFields')); 36 // convert dates to SQL format first 37 if ($obj->project_start_date) { 38 $date = new CDate($obj->project_start_date); 39 $obj->project_start_date = $date->format(FMT_DATETIME_MYSQL); 40 } 41 if ($obj->project_end_date) { 42 $date = new CDate($obj->project_end_date); 43 $date->setTime(23, 59, 59); 44 $obj->project_end_date = $date->format(FMT_DATETIME_MYSQL); 45 } 46 if ($obj->project_actual_end_date) { 47 $date = new CDate($obj->project_actual_end_date); 48 $obj->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); 49 } 50 51 // let's check if there are some assigned departments to project 52 if (!w2PgetParam($_POST, 'project_departments', 0)) { 53 $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array())); 54 } 55 56 // prepare (and translate) the module name ready for the suffix 57 if ($del) { 58 $canDelete = $obj->canDelete($msg, $project_id); 59 if (!$canDelete) { 60 $AppUI->setMsg($msg, UI_MSG_ERROR); 61 $AppUI->redirect(); 62 } 63 if (($msg = $obj->delete())) { 64 $AppUI->setMsg($msg, UI_MSG_ERROR); 65 $AppUI->redirect(); 66 } else { 67 if ($notify_owner) { 68 if ($msg = $obj->notifyOwner(1)) { 69 $AppUI->setMsg($msg, UI_MSG_ERROR); 70 } 71 } 72 if ($notify_contacts) { 73 if ($msg = $obj->notifyContacts(1)) { 74 $AppUI->setMsg($msg, UI_MSG_ERROR); 75 } 76 } 77 $AppUI->setMsg('Project deleted', UI_MSG_ALERT); 78 $AppUI->redirect('m=projects'); 79 } 80 } else { 81 /* $owner_id = $obj->project_owner; 82 if ($obj->project_id) { 83 $old_obj = new CProject(); 84 $old_obj->load($obj->project_id); 85 } 86 if (($owner_id != $old_obj->project_owner) || !$obj->project_id) { 87 $q = new DBQuery; 88 $q->addTable('users'); 89 $q->addQuery('user_id, contact_company as user_company, contact_department as user_department'); 90 $q->addJoin('contacts', 'con', 'contact_id = user_contact', 'inner'); 91 $q->addWhere('user_id = ' . (int)$owner_id); 92 $broker = $q->loadList(); 93 //print_r($broker);die; 94 $q->clear(); 95 $obj->project_company = $broker[0]['user_company']; 96 $obj->project_departments = $broker[0]['user_department']; 97 }*/ 98 99 if (($msg = $obj->store())) { 100 $AppUI->setMsg($msg, UI_MSG_ERROR); 101 } else { 102 $isNotNew = $_POST['project_id']; 103 // check project parents and reset them to self if they do not exist 104 if (!$obj->project_parent) { 105 $obj->project_parent = $obj->project_id; 106 $obj->project_original_parent = $obj->project_id; 107 } else { 108 $parent_project = new CProject(); 109 $parent_project->load($obj->project_parent); 110 $obj->project_original_parent = $parent_project->project_original_parent; 111 } 112 113 if (!$obj->project_original_parent) { 114 $obj->project_original_parent = $obj->project_id; 115 } 116 117 $obj->store(); 118 119 if ($importTask_projectId = w2PgetParam($_POST, 'import_tasks_from', '0')) { 120 $obj->importTasks($importTask_projectId); 121 } 122 123 $custom_fields = new CustomFields($m, 'addedit', $obj->project_id, 'edit'); 124 $custom_fields->bind($_POST); 125 $sql = $custom_fields->store($obj->project_id); // Store Custom Fields 126 if ($notify_owner) { 127 if ($msg = $obj->notifyOwner($isNotNew)) { 128 $AppUI->setMsg($msg, UI_MSG_ERROR); 129 } 130 } 131 if ($notify_contacts) { 132 if ($msg = $obj->notifyContacts($isNotNew)) { 133 $AppUI->setMsg($msg, UI_MSG_ERROR); 134 } 135 } 136 $AppUI->setMsg($isNotNew ? 'Project updated' : 'Project inserted', UI_MSG_OK); 137 } 138 $AppUI->redirect(); 139 } 140 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 9 03:00:02 2009 | Cross-referenced by PHPXref 0.7 |