コード例 #1
0
ファイル: ClientService.php プロジェクト: nyeholt/relapse
 /**
  * Save a contact against a given client object
  * 
  *
  * @param array|Contact $params 
  * @return Contact
  */
 public function saveContact($params)
 {
     $contact = null;
     try {
         $this->dbService->beginTransaction();
         // Get an existing one
         $contact = $this->dbService->saveObject($params, 'Contact');
         // check for a user object to also update
         if ($contact->id) {
             $user = $this->userService->getUserByField('contactid', $contact->id);
             if ($user) {
                 $params = array('firstname' => $contact->firstname, 'lastname' => $contact->lastname, 'email' => $contact->email);
                 $this->userService->updateUser($user, $params);
             }
         }
         $this->trackerService->track('update-contact', $contact->id, null, null, print_r($params, true));
         $this->dbService->commit();
     } catch (Exception $e) {
         $this->dbService->rollback();
         $this->log->err("Failed creating contact for params " . print_r($params, true) . ": " . $e->getMessage());
         $contact = null;
         throw $e;
     }
     return $contact;
 }
コード例 #2
0
ファイル: ExpenseService.php プロジェクト: nyeholt/relapse
 /**
  * Set the status of an expense.
  */
 public function setExpenseStatus(Expense $expense, $status)
 {
     $expense->status = $status;
     $expense->approver = za()->getUser()->getUsername();
     $this->dbService->beginTransaction();
     $this->dbService->saveObject($expense);
     $this->trackerService->track('expense-status-changed', $expense->approver . ' set status to ' . $status);
     $this->dbService->commit();
 }
コード例 #3
0
ファイル: FeatureService.php プロジェクト: nyeholt/relapse
 /**
  * Delete a feature and all sub features.
  */
 public function deleteFeature(Feature $feature)
 {
     $this->dbService->beginTransaction();
     $childFeatures = $this->getChildFeatures($feature);
     foreach ($childFeatures as $child) {
         $this->deleteFeature($child);
     }
     $this->dbService->delete($feature);
     $this->dbService->commit();
 }
コード例 #4
0
ファイル: ItemLinkService.php プロジェクト: nyeholt/relapse
 /**
  * Deletes an item 
  */
 public function deleteItem($item)
 {
     try {
         $this->dbService->beginTransaction();
         $this->dbService->delete('itemlink', 'toid = ' . $item->id . ' OR fromid = ' . $item->id);
         $this->dbService->commit();
     } catch (Exception $e) {
         $this->log->error("Failed deleting item " . get_class($item) . ' #' . $item->id);
         $this->dbService->rollback();
     }
 }
コード例 #5
0
ファイル: ProjectService.php プロジェクト: nyeholt/relapse
 /**
  * As above, this goes through and sets all timesheet entries 
  * that have been locked against a given timesheet to being
  * unlocked
  *
  * @param Timesheet $timesheet
  */
 public function unlockTimesheet(Timesheet $timesheet)
 {
     try {
         $this->dbService->beginTransaction();
         $this->dbService->update('timesheetrecord', array('timesheetid' => 0), 'timesheetid=' . (int) $timesheet->id);
         $timesheet->locked = 0;
         $this->saveTimesheet($timesheet);
         $this->dbService->commit();
     } catch (Exception $e) {
         $this->dbService->rollback();
         throw $e;
     }
 }
コード例 #6
0
ファイル: UserService.php プロジェクト: nyeholt/relapse
 /**
  * Set the leave status
  */
 public function setLeaveStatus(LeaveApplication $leaveApplication, $status, $daysAffected = 0)
 {
     $leaveApplication->status = $status;
     $leaveApplication->approver = za()->getUser()->getUsername();
     if ($daysAffected) {
         $leaveApplication->days = $daysAffected;
     }
     $this->dbService->beginTransaction();
     if ($status == LeaveApplication::LEAVE_DENIED) {
         $leaveApplication->days = 0;
     }
     $this->dbService->saveObject($leaveApplication);
     if ($status == LeaveApplication::LEAVE_APPROVED) {
         // if it's leave approved, need to create a task in the relevant project milestone
         // and make sure the user has time added for it
     }
     $this->applyTimeForLeave($leaveApplication);
     $this->trackerService->track('leave-updated', "Leave application for {$leaveApplication->username} set to {$status}");
     $this->dbService->commit();
     // send a message to the user
     $msg = new TemplatedMessage('leave-updated.php', array('model' => $leaveApplication));
     $this->notificationService->notifyUser('Leave Application Updated', $leaveApplication->username, $msg);
 }