aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Admin/Queue.php
blob: 8a843083b969c911ad167fdbec75ee653877e2f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

namespace Zotlabs\Module\Admin;

use Zotlabs\Lib\Queue as LibQueue;

class Queue {



	function get() {

		$o = '';

		$expert = ((array_key_exists('expert',$_REQUEST)) ? intval($_REQUEST['expert']) : 0);

		if($_REQUEST['drophub']) {
			hubloc_mark_as_down($_REQUEST['drophub']);
			LibQueue::remove_by_posturl($_REQUEST['drophub']);
		}

		if($_REQUEST['emptyhub']) {
			LibQueue::remove_by_posturl($_REQUEST['emptyhub']);
		}

		if($_REQUEST['deliverhub']) {

			$hubq = q("SELECT * FROM outq WHERE outq_posturl = '%s'",
				dbesc($_REQUEST['deliverhub'])
			);

			foreach ($hubq as $q) {
				LibQueue::deliver($q, true);
			}
		}

		$r = dbq("select count(outq_posturl) as total, max(outq_priority) as priority, outq_posturl from outq
			where outq_delivered = 0 group by outq_posturl order by total desc");

		for($x = 0; $x < count($r); $x ++) {
			$r[$x]['eurl'] = urlencode($r[$x]['outq_posturl']);
			$r[$x]['connected'] = datetime_convert('UTC',date_default_timezone_get(),$r[$x]['connected'],'Y-m-d');
		}

		$o = replace_macros(get_markup_template('admin_queue.tpl'), array(
			'$banner' => t('Queue Statistics'),
			'$numentries' => t('Total Entries'),
			'$priority' => t('Priority'),
			'$desturl' => t('Destination URL'),
			'$nukehub' => t('Mark hub permanently offline'),
			'$deliverhub' => t('Retry delivery to this hub'),
			'$empty' => t('Empty queue for this hub'),
			'$lastconn' => t('Last known contact'),
			'$hasentries' => ((count($r)) ? true : false),
			'$entries' => $r,
			'$expert' => $expert
		));

		return $o;
	}




}