Exemple #1
0
 public function add($pendingClientData)
 {
     try {
         $conn = UbirimiContainer::get()['db.connection'];
         $data = json_decode($pendingClientData['data'], true);
         $clientId = UbirimiContainer::get()['repository']->get(UbirimiClient::class)->create(null, $data['companyDomain'], $data['baseURL'], $data['adminEmail'], null, null, null, UbirimiClient::INSTANCE_TYPE_ON_DEMAND, Util::getServerCurrentDateTime());
         // create the user
         $userId = UbirimiContainer::get()['repository']->get(UbirimiUser::class)->createAdministratorUser($data['adminFirstName'], $data['adminLastName'], $data['adminUsername'], $data['adminPass'], $data['adminEmail'], $clientId, 20, 1, 1, Util::getServerCurrentDateTime());
         $columns = 'code#summary#priority#status#created#type#updated#reporter#assignee';
         UbirimiContainer::get()['repository']->get(UbirimiUser::class)->updateDisplayColumns($userId, $columns);
         UbirimiContainer::get()['repository']->get(UbirimiClient::class)->install($clientId);
         UbirimiContainer::get()['repository']->get(EmailQueue::class)->add($clientId, '*****@*****.**', $data['adminEmail'], null, 'Your account details - Ubirimi.com', Util::getTemplate('_newAccount.php', array('username' => $data['adminUsername'], 'companyDomain' => $data['companyDomain'], 'emailAddress' => $data['adminEmail'])), Util::getServerCurrentDateTime());
         $conn->commit();
     } catch (\Exception $e) {
         $conn->rollback();
         throw new \Exception(sprintf('Could not install client [%s]. Error [%s]', $data['companyName'], $e->getMessage()));
     }
 }
Exemple #2
0
 public function shareEvent($clientId, $event, $userThatShares, $userToSendEmailAddress, $noteContent)
 {
     if (Email::$smtpSettings) {
         $subject = Email::$smtpSettings['email_prefix'] . ' ' . $userThatShares['first_name'] . ' ' . $userThatShares['last_name'] . ' shared event ' . $event['name'] . ' with you';
         $date = Util::getServerCurrentDateTime();
         UbirimiContainer::get()['repository']->get(EmailQueue::class)->add($clientId, Email::$smtpSettings['from_address'], $userToSendEmailAddress, null, $subject, Util::getTemplate('_eventShare.php', array('event' => $event, 'userThatShares' => $userThatShares, 'noteContent' => $noteContent, 'clientDomain' => Util::getSubdomain())), $date);
     }
 }
    $data = explode('=', $searchParameter);
    $searchParameters[$data[0]] = $data[1];
}
$user = UbirimiContainer::get()['repository']->get(UbirimiUser::class)->getById($filter['user_id']);
$smtpSettings = UbirimiContainer::get()['repository']->get(SMTPServer::class)->getByClientId($user['client_id']);
if (!$smtpSettings) {
    die('No SMPT server defined');
}
$clientSettings = UbirimiContainer::get()['repository']->get(UbirimiClient::class)->getSettings($user['client_id']);
$client = UbirimiContainer::get()['repository']->get(UbirimiClient::class)->getById($user['client_id']);
$subject = $smtpSettings['email_prefix'] . " Filter - " . $filter['name'];
$usersToNotify = array();
if ($filterSubscription['user_id']) {
    $user = UbirimiContainer::get()['repository']->get(UbirimiUser::class)->getById($filterSubscription['user_id']);
    $usersToNotify[] = $user;
} else {
    if ($filterSubscription['group_id']) {
        $users = UbirimiContainer::get()['repository']->get(UbirimiGroup::class)->getDataByGroupId($filterSubscription['group_id']);
        while ($users && ($user = $users->fetch_array(MYSQLI_ASSOC))) {
            $usersToNotify[] = $user;
        }
    }
}
foreach ($usersToNotify as $user) {
    $issues = UbirimiContainer::get()['repository']->get(Issue::class)->getByParameters($searchParameters, $filterSubscription['user_id'], null, $filterSubscription['user_id']);
    $columns = explode('#', $user['issues_display_columns']);
    UbirimiContainer::get()['repository']->get(EmailQueue::class)->add($user['client_id'], $smtpSettings['from_address'], $user['email'], null, $subject, Util::getTemplate('_filterSubscription.php', array('issues' => $issues, 'searchParameters' => $searchParameters, 'clientSettings' => $clientSettings, 'columns' => $columns, 'userId' => $user['id'], 'clientId' => $user['client_id'], 'cliMode' => true, 'client_domain' => $client['company_domain'])), Util::getServerCurrentDateTime());
}
if (null !== $fp) {
    fclose($fp);
}
    if (!flock($fp, LOCK_EX | LOCK_NB)) {
        echo "Unable to obtain lock for process_event_reminders task.\n";
        exit(-1);
    }
}
require_once __DIR__ . '/../web/bootstrap_cli.php';
$reminders = UbirimiContainer::get()['repository']->get(EventReminder::class)->getRemindersToBeFired();
while ($reminders && ($reminder = $reminders->fetch_array(MYSQLI_ASSOC))) {
    $currentDate = Util::getServerCurrentDateTime();
    $smtpSettings = UbirimiContainer::get()['repository']->get(SMTPServer::class)->getByClientId($reminder['client_id']);
    if ($smtpSettings) {
        $reminderPeriod = $reminder['cal_event_reminder_period_id'];
        $reminderValue = $reminder['value'];
        $eventStartDate = $reminder['date_from'];
        $emailSubject = 'Reminder: ' . $reminder['name'] . ' @ ' . date('j M Y', strtotime($eventStartDate)) . ' (' . $reminder['calendar_name'] . ')';
        $emailBody = Util::getTemplate('_eventReminder.php', array('event_name' => $reminder['name'], 'when' => $eventStartDate, 'calendar_name' => $reminder['calendar_name']));
        $dateTemporary = date_create(date('Y-m-d H:i:s', time()));
        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: