public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $clientId = UbirimiContainer::get()['session']->get('client/id');
     $loggedInUserId = UbirimiContainer::get()['session']->get('user/id');
     $workflowStepIdFrom = $request->request->get('step_id_from');
     $workflowStepIdTo = $request->request->get('step_id_to');
     $workflowId = $request->request->get('workflow_id');
     $issueId = $request->request->get('issue_id');
     $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     $workflowData = $this->getRepository(Workflow::class)->getDataByStepIdFromAndStepIdTo($workflowId, $workflowStepIdFrom, $workflowStepIdTo);
     $issue = $this->getRepository(Issue::class)->getByParameters(array('issue_id' => $issueId), $loggedInUserId);
     $canBeExecuted = $this->getRepository(Workflow::class)->checkConditionsByTransitionId($workflowData['id'], $loggedInUserId, $issue);
     if ($canBeExecuted) {
         $smtpSettings = $session->get('client/settings/smtp');
         if ($smtpSettings) {
             Email::$smtpSettings = $smtpSettings;
         }
         $date = Util::getServerCurrentDateTime();
         $this->getRepository(WorkflowFunction::class)->triggerPostFunctions($clientId, $issue, $workflowData, array(), $loggedInUserId, $date);
         // update the date_updated field
         $this->getRepository(Issue::class)->updateById($issueId, array('date_updated' => $date), $date);
         return new Response('success');
     } else {
         return new Response('can_not_be_executed');
     }
 }
Exemplo n.º 2
0
 public function importUsers($repositoryName, $user)
 {
     if ($this->session->get('client/settings/smtp')) {
         Email::$smtpSettings = $this->session->get('client/settings/smtp');
         UbirimiContainer::get()['repository']->get(Email::class)->sendNewUserRepositoryNotificationEmail($this->session->get('client/id'), $user['first_name'], $user['last_name'], $user['username'], null, $user['email'], $repositoryName);
     }
 }
Exemplo n.º 3
0
 public function newUserCustomer($firstName, $lastName, $password, $email, $clientDomain, $clientId)
 {
     $smtpSettings = UbirimiContainer::get()['repository']->get(SMTPServer::class)->getByClientId($clientId);
     if ($smtpSettings) {
         EmailRepository::$smtpSettings = $smtpSettings;
     } else {
         EmailRepository::$smtpSettings = Util::getUbirimiSMTPSettings();
     }
     UbirimiContainer::get()['repository']->get(EmailRepository::class)->sendNewCustomerNotificationEmail($clientId, $firstName, $lastName, $email, $password, $clientDomain);
 }
Exemplo n.º 4
0
 public function shareEvent($event, $userThatShares, $usersToShareWith, $noteContent)
 {
     $smtpSettings = UbirimiContainer::get()['session']->get('client/settings/smtp');
     if ($smtpSettings) {
         Email::$smtpSettings = $smtpSettings;
         for ($i = 0; $i < count($usersToShareWith); $i++) {
             $user = UbirimiContainer::get()['repository']->get(UbirimiUser::class)->getById($usersToShareWith[$i]);
             UbirimiContainer::get()['repository']->get(Email::class)->shareEvent($this->session->get('client/id'), $event, $userThatShares, $user['email'], $noteContent);
         }
     }
 }
Exemplo n.º 5
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $currentDate = Util::getServerCurrentDateTime();
     $issueId = $request->get('id');
     $clientId = $session->get('client/id');
     $loggedInUserId = $session->get('user/id');
     $issueData = $this->getRepository(Issue::class)->getByParameters(array('issue_id' => $issueId), $loggedInUserId);
     $this->getRepository(Issue::class)->updateAssignee($clientId, $issueId, $loggedInUserId, $loggedInUserId);
     // update the date_updated field
     $this->getRepository(Issue::class)->updateById($issueId, array('date_updated' => $currentDate), $currentDate);
     $userAssigned = $this->getRepository(UbirimiUser::class)->getById($loggedInUserId);
     $newUserAssignedName = $userAssigned['first_name'] . ' ' . $userAssigned['last_name'];
     $oldUserAssignedName = $issueData['ua_first_name'] . ' ' . $issueData['ua_last_name'];
     $project = $this->getRepository(YongoProject::class)->getById($issueData['issue_project_id']);
     $smtpSettings = UbirimiContainer::get()['session']->get('client/settings/smtp');
     Email::$smtpSettings = $smtpSettings;
     $this->getRepository(Email::class)->triggerAssignIssueNotification($clientId, $issueData, $oldUserAssignedName, $newUserAssignedName, $project, $loggedInUserId, null);
     $issueEvent = new IssueEvent(null, null, IssueEvent::STATUS_UPDATE);
     UbirimiContainer::get()['dispatcher']->dispatch(YongoEvents::YONGO_ISSUE_UPDATE_ASSIGNEE_EMAIL, $issueEvent);
     return new Response('');
 }
Exemplo n.º 6
0
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $loggedInUserId = $session->get('user/id');
     $clientId = $session->get('client/id');
     $currentDate = Util::getServerCurrentDateTime();
     $issueId = $request->request->get('issue_id');
     $userAssignedId = $request->request->get('user_assigned_id');
     $comment = Util::cleanRegularInputField($request->request->get('comment'));
     $issueData = $this->getRepository(Issue::class)->getByParameters(array('issue_id' => $issueId), $loggedInUserId);
     $this->getRepository(Issue::class)->updateAssignee($session->get('client/id'), $issueId, $session->get('user/id'), $userAssignedId, $comment);
     // update the date_updated field
     $this->getRepository(Issue::class)->updateById($issueId, array('date_updated' => $currentDate), $currentDate);
     $userAssigned = $this->getRepository(UbirimiUser::class)->getById($userAssignedId);
     $newUserAssignedName = $userAssigned['first_name'] . ' ' . $userAssigned['last_name'];
     $oldUserAssignedName = $issueData['ua_first_name'] . ' ' . $issueData['ua_last_name'];
     $project = $this->getRepository(YongoProject::class)->getById($issueData['issue_project_id']);
     $smtpSettings = UbirimiContainer::get()['session']->get('client/settings/smtp');
     Email::$smtpSettings = $smtpSettings;
     $this->getRepository(Email::class)->triggerAssignIssueNotification($clientId, $issueData, $oldUserAssignedName, $newUserAssignedName, $project, $loggedInUserId, $comment);
     return new Response('');
 }
 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $clientId = UbirimiContainer::get()['session']->get('client/id');
     $loggedInUserId = UbirimiContainer::get()['session']->get('user/id');
     $issueId = $request->request->get('issue_id');
     $fieldTypes = isset($_POST['field_types']) ? $_POST['field_types'] : array();
     $fieldValues = isset($_POST['field_values']) ? $_POST['field_values'] : array();
     $stepIdFrom = $request->request->get('step_id_from');
     $stepIdTo = $request->request->get('step_id_to');
     $workflowId = $request->request->get('workflow_id');
     $attachIdsToBeKept = isset($_POST['attach_ids']) ? $_POST['attach_ids'] : array();
     $attIdsSession = $session->has('added_attachments_in_screen') ? $session->get('added_attachments_in_screen') : array();
     $fieldTypesCustom = $request->request->get('field_types_custom');
     $fieldValuesCustom = $request->request->get('field_values_custom');
     $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     $issueCustomFieldsData = array();
     for ($i = 0; $i < count($fieldTypesCustom); $i++) {
         if ($fieldValuesCustom[$i] != 'null' && $fieldValuesCustom[$i] != '') {
             $issueCustomFieldsData[$fieldTypesCustom[$i]] = $fieldValuesCustom[$i];
         } else {
             $issueCustomFieldsData[$fieldTypesCustom[$i]] = null;
         }
     }
     for ($i = 0; $i < count($attIdsSession); $i++) {
         $attachmentId = $attIdsSession[$i];
         if (!in_array($attachmentId, $attachIdsToBeKept)) {
             $attachment = $this->getRepository(IssueAttachment::class)->getById($attachmentId);
             $this->getRepository(IssueAttachment::class)->deleteById($attachmentId);
             unlink('./../../..' . $attachment['path'] . '/' . $attachment['name']);
         }
     }
     $session->remove('added_attachments_in_screen');
     $issueData = $this->getRepository(Issue::class)->getById($issueId, $loggedInUserId);
     $workflowData = $this->getRepository(Workflow::class)->getDataByStepIdFromAndStepIdTo($workflowId, $stepIdFrom, $stepIdTo);
     // check if the transition can be executed with respect to the transition conditions
     $canBeExecuted = $this->getRepository(Workflow::class)->checkConditionsByTransitionId($workflowData['id'], $loggedInUserId, $issueData);
     if ($canBeExecuted) {
         $currentDate = Util::getServerCurrentDateTime();
         $newIssueSystemFieldsData = array('issue_project_id' => $issueData['issue_project_id']);
         for ($i = 0; $i < count($fieldTypes); $i++) {
             $newIssueSystemFieldsData[$fieldTypes[$i]] = $fieldValues[$i];
         }
         $oldIssueCustomFieldsData = array();
         foreach ($issueCustomFieldsData as $key => $value) {
             $keyData = explode("_", $key);
             $oldIssueCustomFieldsData[$keyData[0]] = $this->getRepository(CustomField::class)->getCustomFieldsDataByFieldId($issueId, $key);
             unset($issueCustomFieldsData[$key]);
             $issueCustomFieldsData[$keyData[0]] = $value;
         }
         $fieldChanges = $this->getRepository(Issue::class)->computeDifference($issueData, $newIssueSystemFieldsData, $oldIssueCustomFieldsData, $issueCustomFieldsData);
         if (in_array(Field::FIELD_COMMENT_CODE, $fieldTypes)) {
             if ($fieldValues[array_search('comment', $fieldTypes)]) {
                 $commentText = $fieldValues[array_search('comment', $fieldTypes)];
                 $this->getRepository(IssueComment::class)->add($issueId, $loggedInUserId, $commentText, $currentDate);
                 $fieldChanges[] = array('comment', $commentText);
             }
         }
         try {
             $this->getRepository(Issue::class)->updateById($issueId, $newIssueSystemFieldsData, $currentDate);
             // save custom fields
             if (count($issueCustomFieldsData)) {
                 $this->getRepository(CustomField::class)->updateCustomFieldsData($issueId, $issueCustomFieldsData, $currentDate);
             }
         } catch (\Exception $e) {
         }
         $smtpSettings = $session->get('client/settings/smtp');
         if ($smtpSettings) {
             Email::$smtpSettings = $smtpSettings;
         }
         $this->getRepository(WorkflowFunction::class)->triggerPostFunctions($clientId, $issueData, $workflowData, $fieldChanges, $loggedInUserId, $currentDate);
         // update the date_updated field
         $this->getRepository(Issue::class)->updateById($issueId, array('date_updated' => $currentDate), $currentDate);
         return new Response('success');
     } else {
         return new Response('can_not_be_executed');
     }
 }
Exemplo n.º 8
0
 public function emailIssueWorkLogDeleted($issue, $project, $extraInformation)
 {
     $smtpSettings = $this->session->get('client/settings/smtp');
     if ($smtpSettings) {
         Email::$smtpSettings = $smtpSettings;
         // notify people
         $eventId = UbirimiContainer::get()['repository']->get(IssueEvent::class)->getByClientIdAndCode($this->session->get('client/id'), IssueEvent::EVENT_ISSUE_WORKLOG_DELETED_CODE, 'id');
         $users = UbirimiContainer::get()['repository']->get(YongoProject::class)->getUsersForNotification($issue['issue_project_id'], $eventId, $issue, $this->session->get('user/id'));
         while ($users && ($userToNotify = $users->fetch_array(MYSQLI_ASSOC))) {
             if ($userToNotify['user_id'] == $this->session->get('user/id') && !$userToNotify['notify_own_changes_flag']) {
                 continue;
             }
             UbirimiContainer::get()['repository']->get(Email::class)->sendEmailNotificationWorkLogDeleted($issue, $this->session->get('client/id'), $project, $userToNotify, $extraInformation, $this->session->get('user'));
         }
     }
 }
Exemplo n.º 9
0
        switch ($reminderPeriod) {
            case ReminderPeriod::PERIOD_MINUTE:
                date_add($dateTemporary, date_interval_create_from_date_string($reminderValue . ' minutes'));
                $eventStartDateReminder = date_format($dateTemporary, 'Y-m-d H:i:s');
                break;
            case ReminderPeriod::PERIOD_HOUR:
                date_add($dateTemporary, date_interval_create_from_date_string($reminderValue . ' hours'));
                $eventStartDateReminder = date_format($dateTemporary, 'Y-m-d H:i:s');
                break;
            case ReminderPeriod::PERIOD_DAY:
                date_add($dateTemporary, date_interval_create_from_date_string($reminderValue . ' days'));
                $eventStartDateReminder = date_format($dateTemporary, 'Y-m-d H:i:s');
                break;
            case ReminderPeriod::PERIOD_WEEK:
                date_add($dateTemporary, date_interval_create_from_date_string($reminderValue . ' weeks'));
                $eventStartDateReminder = date_format($dateTemporary, 'Y-m-d H:i:s');
                break;
        }
        if ($eventStartDateReminder >= $eventStartDate) {
            // send the reminder
            $mailer = Email::getMailer($smtpSettings);
            $message = Swift_Message::newInstance($emailSubject)->setFrom(array($smtpSettings['from_address']))->setTo(array($reminder['email']))->setBody($emailBody, 'text/html');
            $mailer->send($message);
            // update the reminder as fired
            UbirimiContainer::get()['repository']->get(EventReminder::class)->setAsFired($reminder['id']);
        }
    }
}
if (null !== $fp) {
    fclose($fp);
}