// prepare (and translate) the module name ready for the suffix if ($del) { $project_id = dPgetParam($_POST, 'project_id', 0); $canDelete = $obj->canDelete($msg, $project_id); if (!$canDelete) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } if ($msg = $obj->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg("Project deleted", UI_MSG_ALERT); $AppUI->redirect("m=projects"); } } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $isNotNew = @$_POST['project_id']; if ($importTask_projectId = dPgetParam($_POST, 'import_tasks_from', '0')) { $obj->importTasks($importTask_projectId); } $AppUI->setMsg($isNotNew ? 'Project updated' : 'Project inserted', UI_MSG_OK, true); $custom_fields = new CustomFields($m, 'addedit', $obj->project_id, "edit"); $custom_fields->bind($_POST); $sql = $custom_fields->store($obj->project_id); // Store Custom Fields } $AppUI->redirect(); }
} else { $isNotNew = @$_POST['event_id']; if (!$isNotNew) { $obj->event_owner = $AppUI->user_id; } // Check for existence of clashes. if ($_POST['event_assigned'] > '' && ($clash = $obj->checkClash($_POST['event_assigned']))) { $last_a = $a; $GLOBALS['a'] = "clash"; $do_redirect = false; } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $custom_fields = new CustomFields('calendar', 'addedit', $obj->event_id, "edit"); $custom_fields->bind($_POST); $sql = $custom_fields->store($obj->event_id); // Store Custom Fields $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true); if (isset($_POST['event_assigned'])) { $obj->updateAssigned(explode(",", $_POST['event_assigned'])); } if (isset($_POST['mail_invited'])) { $obj->notify(@$_POST['event_assigned'], $isNotNew); } } } } if ($do_redirect) { $AppUI->redirect(); }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; $errorMsgArray = $this->check(); if (count($errorMsgArray) > 0) { return $errorMsgArray; } $this->company_id = (int) $this->company_id; /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ if ($this->company_id && $perms->checkModuleItem('companies', 'edit', $this->company_id)) { if ($msg = parent::store()) { return $msg; } addHistory('companies', $this->company_id, 'update', $this->company_name, $this->company_id); $stored = true; } if (0 == $this->company_id && $perms->checkModuleItem('companies', 'add')) { if ($msg = parent::store()) { return $msg; } addHistory('companies', $this->company_id, 'add', $this->company_name, $this->company_id); $stored = true; } if ($stored) { $custom_fields = new CustomFields('companies', 'addedit', $this->company_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->company_id); // Store Custom Fields } return $stored; }
if (!$obj->bind($_POST)) { $AppUI->setMsg($obj->getError(), UI_MSG_ERROR); $AppUI->redirect(); } require_once $AppUI->getSystemClass('CustomFields'); // prepare (and translate) the module name ready for the suffix $AppUI->setMsg('Company'); if ($del) { if (!$obj->canDelete($msg)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } if ($msg = $obj->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg('deleted', UI_MSG_ALERT, true); $AppUI->redirect('m=companies'); } } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } else { $custom_fields = new CustomFields($m, 'addedit', $obj->company_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($obj->company_id); // Store Custom Fields $AppUI->setMsg(@$_POST['company_id'] ? 'updated' : 'added', UI_MSG_OK, true); } $AppUI->redirect(); }
if ($msg = $obj->delete()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); } else { $AppUI->setMsg('Task deleted'); $AppUI->redirect('', -1); } } else { if ($msg = $obj->store()) { $AppUI->setMsg($msg, UI_MSG_ERROR); $AppUI->redirect(); // Store failed don't continue? } else { $custom_fields = new CustomFields($m, 'addedit', $obj->task_id, "edit"); $custom_fields->bind($_POST); $sql = $custom_fields->store($obj->task_id); // Store Custom Fields $AppUI->setMsg($task_id ? 'Task updated' : 'Task added', UI_MSG_OK); } if (isset($hassign)) { $obj->updateAssigned($hassign, $hperc_assign_ar); } if (isset($hdependencies)) { $obj->updateDependencies($hdependencies); } // If there is a set of post_save functions, then we process them if (isset($post_save)) { foreach ($post_save as $post_save_function) { $post_save_function(); } }
// check permissions for this record if (!$contact_id) { echo $AppUI->_('You are not authorized to use this page. If you should be authorized please contact Bruce Bodger to give you another valid link, thank you.'); exit; } if (!$contact->bind($_POST)) { $AppUI->setMsg($contact->getError(), UI_MSG_ERROR); $AppUI->redirect(); } // prepare (and translate) the module name ready for the suffix $AppUI->setMsg('Contact'); $isNotNew = $_POST['contact_id']; if ($msg = $contact->store($AppUI)) { $AppUI->setMsg($msg, UI_MSG_ERROR); $msg = $AppUI->_('There was an error recording your contact data, please contact the system administrator. Thank you very much.'); } else { $custom_fields = new CustomFields('contacts', 'addedit', $contact->contact_id, 'edit', 1); $custom_fields->bind($_POST); $custom_fields->store($contact->contact_id); $contact->clearUpdateKey(); $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true); echo $AppUI->_('Your contact data has been recorded successfully. Your may now close your browser windoq. Thank you very much, ' . $contact->contact_first_name); } ?> <html> <body> <?php echo $msg; ?> </body> </html>
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->w2PTrimAll(); $this->project_target_budget = str_replace(',', '', $this->project_target_budget); // ensure changes of state in checkboxes is captured $this->project_active = (int) $this->project_active; $this->project_private = (int) $this->project_private; $this->project_target_budget = $this->project_target_budget ? $this->project_target_budget : 0.0; $this->project_actual_budget = $this->project_actual_budget ? $this->project_actual_budget : 0.0; // Make sure project_short_name is the right size (issue for languages with encoded characters) if (mb_strlen($this->project_short_name) > 10) { $this->project_short_name = mb_substr($this->project_short_name, 0, 10); } if (empty($this->project_end_date)) { $this->project_end_date = null; } $errorMsgArray = $this->check(); if (count($errorMsgArray) > 0) { return $errorMsgArray; } $this->project_id = (int) $this->project_id; // convert dates to SQL format first if ($this->project_start_date) { $date = new CDate($this->project_start_date); $this->project_start_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_end_date) { $date = new CDate($this->project_end_date); $date->setTime(23, 59, 59); $this->project_end_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_actual_end_date) { $date = new CDate($this->project_actual_end_date); $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // let's check if there are some assigned departments to project if ('' != $this->project_actual_end_date) { $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array())); } // check project parents and reset them to self if they do not exist if (!$this->project_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; } else { $parent_project = new CProject(); $parent_project->load($this->project_parent); $this->project_original_parent = $parent_project->project_original_parent; } if (!$this->project_original_parent) { $this->project_original_parent = $this->project_id; } /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->company_id)) { $q = new DBQuery(); $this->project_updated = $q->dbfnNow(); if ($msg = parent::store()) { return $msg; } addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id); $stored = true; } if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) { $q = new DBQuery(); $this->project_updated = $q->dbfnNow(); $this->project_created = $q->dbfnNow(); if ($msg = parent::store()) { return $msg; } if (0 == $this->project_parent || 0 == $this->project_original_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; if ($msg = parent::store()) { return $msg; } } addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id); $stored = true; } //split out related departments and store them seperatly. $q = new DBQuery(); $q->setDelete('project_departments'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_departments) { $departments = explode(',', $this->project_departments); foreach ($departments as $department) { $q->addTable('project_departments'); $q->addInsert('project_id', $this->project_id); $q->addInsert('department_id', $department); $q->exec(); $q->clear(); } } //split out related contacts and store them seperatly. $q->setDelete('project_contacts'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_contacts) { $contacts = explode(',', $this->project_contacts); foreach ($contacts as $contact) { if ($contact) { $q->addTable('project_contacts'); $q->addInsert('project_id', $this->project_id); $q->addInsert('contact_id', $contact); $q->exec(); $q->clear(); } } } if ($stored) { $custom_fields = new CustomFields('projects', 'addedit', $this->project_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->project_id); // Store Custom Fields } return $stored; }
$AppUI->redirect(); } else { $AppUI->setMsg('deleted', UI_MSG_ALERT, true); $AppUI->redirect('m=contacts'); } } else { if ($result = $obj->store($AppUI)) { if (is_array($result)) { $AppUI->setMsg($result, UI_MSG_ERROR, true); $AppUI->holdObject($obj); $AppUI->redirect('m=contacts&a=addedit'); } } else { $custom_fields = new CustomFields($m, 'addedit', $obj->contact_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($obj->contact_id); // Store Custom Fields $updatekey = $obj->getUpdateKey(); if ($notifyasked && !$updatekey) { $rnow = new CDate(); $obj->contact_updatekey = MD5($rnow->format(FMT_DATEISO)); $obj->contact_updateasked = $rnow->format(FMT_DATETIME_MYSQL); $obj->contact_lastupdate = ''; $obj->updateNotify(); } elseif ($notifyasked && $updatekey) { } else { $obj->contact_updatekey = ''; } $obj->store($AppUI); $AppUI->setMsg($isNotNew ? 'updated' : 'added', UI_MSG_OK, true); }