Ejemplo n.º 1
0
function human_time_diff($from, $to = '')
{
    if (empty($to)) {
        $to = time();
    }
    $diff = (int) abs($to - $from);
    if ($diff <= 3600) {
        $mins = round($diff / 60);
        if ($mins <= 1) {
            $mins = 1;
        }
        /* translators: min=minute */
        $since = formatCount($mins, 'min', 'mins');
    } else {
        if ($diff <= 86400 && $diff > 3600) {
            $hours = round($diff / 3600);
            if ($hours <= 1) {
                $hours = 1;
            }
            $since = formatCount($hours, 'hour', 'hours');
        } elseif ($diff >= 86400) {
            $days = round($diff / 86400);
            if ($days <= 1) {
                $days = 1;
            }
            $since = formatCount($days, 'day', 'days');
        }
    }
    $formatted = $to - $from < 0 ? "in " . $since : $since . " ago";
    return $formatted;
}
Ejemplo n.º 2
0
function printStats($title, $stats_object, $green_limit, $yellow_limit, $critical)
{
    $count = @$stats_object["count"];
    $color = "#CCFFFF";
    // start with blue for count 0
    if ($count > 0) {
        $color = "#99FF66";
    }
    if ($count > $green_limit) {
        $color = "#FFFF66";
    }
    if ($count > $yellow_limit) {
        $color = "#FF9966";
    }
    if ($count > $critical) {
        $color = "#CC3366";
    }
    $log_color = $color;
    $log_warning = "";
    if (@$stats_object["log_timestamp"]) {
        $delta = time() - @$stats_object["log_timestamp"];
        if ($delta > 600) {
            $log_color = "#CC3366";
            $log_warning = " log too old - (" . $delta . ") seconds from now";
        }
    }
    $date_format = "%y-%m-%d %H:%M:%S";
    $restart_div = $stats_object["service_name"] ? "<div style='position:relative; float:right; '  onClick='restartBatch (\"" . $stats_object["service_name"] . "\")'>&nbsp;</div>" : "";
    $str = "<div style='padding:5px;background-color:{$color}'> " . $restart_div . "<b>{$title}</b> <br>" . "path : " . @$stats_object["path"] . "<br>" . "count: " . formatCount($stats_object) . "<br>";
    if (@$stats_object["full_stats"]) {
        $str .= "<div style='padding: 0 0 0 10px '>";
        // extra stats per status
        foreach ($stats_object["full_stats"] as $status => $stats_per_status) {
            if ($status == BatchJob::BATCHJOB_STATUS_FINISHED) {
                continue;
            }
            // don't include the BatchJob::BATCHJOB_STATUS_FINISHED in this loop
            $str .= "status " . formatStatus($status) . ": count: " . formatCount($stats_per_status) . "<br>";
        }
        $str .= "</div>";
    }
    if (@$stats_object["successful_stats"]) {
        $str .= "<div style='background-color:white;'>";
        // extra stats per status
        $stats_per_status = $stats_object["successful_stats"];
        $str .= "successful count: " . formatCount($stats_per_status) . "<br>";
        $str .= "</div>";
    }
    $str .= "log: " . @$stats_object["log_name"] . "<br> " . "<div style='background-color:{$log_color}'>time: " . @strftime($date_format, @$stats_object["log_timestamp"]) . "{$log_warning}</div>" . " size: " . @$stats_object["log_size"] . " b " . "</div>";
    return $str;
}
Ejemplo n.º 3
0
    }
}
// num joined
$numJoined = $task->getNumAccepted();
// num needed
$numNeeded = $task->getNumNeeded();
if (empty($numNeeded)) {
    $numNeeded = '&#8734; people';
} else {
    $numNeeded = $numNeeded - $numJoined;
    if ($numNeeded < 0) {
        $numNeeded = 0;
    }
    $numNeeded = formatCount($numNeeded, 'person', 'people');
}
$numJoined = formatCount($numJoined, 'person', 'people');
$fork = $SOUP->fork();
$fork->set('title', 'Task Members');
$fork->set('id', $id);
if ($hasJoinPermission) {
    $fork->set('creatable', true);
    $fork->set('createLabel', 'Join Task');
} elseif ($hasLeavePermission) {
    $fork->set('creatable', true);
    $fork->set('createLabel', 'Leave Task');
}
$fork->startBlockSet('body');
?>


<script type="text/javascript">
Ejemplo n.º 4
0
<?php 
if ($updates != null) {
    echo '<ul class="segmented-list updates">';
    foreach ($updates as $u) {
        echo '<li>';
        echo '<h6 class="primary"><a href="' . Url::update($u->getID()) . '">' . $u->getTitle() . '</a>';
        if ($u->isLatestUpdate()) {
            $accept = Accepted::load($u->getAcceptedID());
            $statusName = Accepted::getStatusName($accept->getStatus());
            echo ' <span class="status">' . $statusName . '</span>';
        }
        echo '</h6>';
        // .primary
        echo '<p class="secondary">';
        echo 'posted ' . formatTimeTag($u->getDateCreated());
        $comments = $u->getComments();
        echo ' <span class="slash">/</span> ' . formatCount(count($comments), 'comment', 'comments', 'no');
        echo '</p>';
        // .secondary
        echo '</li>';
    }
    echo '</ul>';
} else {
    echo "<p>(none)</p>";
}
?>


<?php 
$fork->endBlockSet();
$fork->render('site/partial/panel');
Ejemplo n.º 5
0
    foreach ($emails as $e) {
        // generate code
        //		$code = sha1(microtime(true).mt_rand(10000,90000));
        // send invitation
        $invite = new Invitation(array('inviter_id' => Session::getUserID(), 'invitee_email' => $e, 'project_id' => $project->getID(), 'trusted' => $trusted, 'invitation_message' => $message));
        $invite->save();
        // log event
        $logEvent = new Event(array('event_type_id' => 'invite_member_email', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $invite->getID(), 'data_1' => $e, 'data_2' => $message, 'data_3' => $trusted));
        $logEvent->save();
        // compose email
        $body = "<p>" . formatUserLink(Session::getUserID()) . ' invited you to join the project ' . formatProjectLink($project->getID()) . '.</p>';
        if (!empty($message)) {
            $body .= '<blockquote>' . formatInvitationMessage($message) . '</blockquote>';
        }
        if ($trusted) {
            $body .= '<p>If you accept this invitation, you will become a <a href="' . Url::help() . '">trusted member</a> of this project.</p>';
        }
        $body .= '<p>To respond to this invitation, <a href="' . Url::consent($e) . '">register</a> a free account on ' . PIPELINE_NAME . ' using this email address (' . $e . ').</p>';
        $email = array('to' => $e, 'subject' => '[' . PIPELINE_NAME . '] Invitation to join the project ' . $project->getTitle(), 'message' => $body);
        // send email
        Email::send($email);
    }
    // send us back
    $numInvitations = count($users) + count($emails);
    Session::setMessage(formatCount($numInvitations, 'invitation', 'invitations') . ' sent.');
    $json = array('success' => '1');
    echo json_encode($json);
} else {
    $json = array('error' => 'Invalid action.');
    exit(json_encode($json));
}
Ejemplo n.º 6
0
<?php

require_once TEMPLATE_PATH . '/site/helper/format.php';
$massEmailAddresses = User::getMassEmailAddresses();
$numMassEmails = formatCount(count($massEmailAddresses), 'user', 'users');
$fork = $SOUP->fork();
$fork->set('title', 'Mass Email');
$fork->startBlockSet('body');
?>

<script type="text/javascript">

$(document).ready(function(){
	//$('#txtSubject').focus();
	$('#btnSendEmail').click(function(){
		buildPost({
			'processPage': '<?php 
echo Url::adminProcess();
?>
',
			'info':{
				'subject': $('#txtSubject').val(),
				'body': $('#txtBody').val()
			},
			'buttonID': '#btnSendEmail'
		});
	});
});

</script>
Ejemplo n.º 7
0
<?php 
}
?>

<?php 
if (empty($discussions)) {
    echo '<p>(none)</p>';
} elseif ($size == 'small') {
    echo '<ul class="segmented-list discussions">';
    foreach ($discussions as $d) {
        echo '<li>';
        $cssLock = $d->getLocked() ? ' locked' : '';
        echo '<h6 class="primary' . $cssLock . '"><a href="' . Url::discussion($d->getID()) . '">' . $d->getTitle() . '</a></h6>';
        echo '<p class="secondary">';
        $numReplies = count($d->getReplies());
        echo formatCount($numReplies, 'reply', 'replies', 'no') . ' <span class="slash">/</span> ';
        if ($numReplies > 0) {
            $lastReply = $d->getLastReply();
            echo 'last reply ' . formatTimeTag($lastReply->getDateCreated()) . ' by ' . formatUserLink($lastReply->getCreatorID(), $project->getID());
        } else {
            echo 'posted ' . formatTimeTag($d->getDateCreated()) . ' by ' . formatUserLink($d->getCreatorID(), $project->getID());
        }
        echo '</p>';
        echo '</li>';
    }
    echo '</ul>';
} else {
    ?>
	<table class="items discussions">
		<tr>
			<th style="padding-left: 22px;">Discussion</th>
Ejemplo n.º 8
0
function formatUserStrip($userID = null, $projectID = null)
{
    if ($userID === null || $projectID === null) {
        return null;
    }
    $numTasksLed = formatCount(count(Task::getByLeaderID($projectID, $userID)), 'task', 'tasks', 'no');
    $numTaskContributions = formatCount(count(Update::getByUserID($userID, $projectID)), 'task contribution', 'task contributions', 'no');
    $numTaskComments = formatCount(count(Comment::getByUserID($userID, $projectID)), 'task comment', 'task comments', 'no');
    $strip = $numTasksLed . ' led <span class="slash">/</span> ' . $numTaskContributions . ' <span class="slash">/</span> ' . $numTaskComments;
    return $strip;
}