]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/subscriptions.php
deny access to include files
[quix0rs-gnu-social.git] / actions / subscriptions.php
1 <?php
2
3 class SubscriptionsAction extends Action {
4         
5         function handle($args) {
6                 parent::handle($args);
7                 $nickname = $this->arg('nickname');
8                 $profile = Profile::staticGet('nickname', $nickname);
9                 if (!$profile) {
10                         $this->no_such_user();
11                 }
12                 $user = User::staticGet($profile->id);
13                 if (!$user) {
14                         $this->no_such_user();
15                 }
16                 $page = $this->arg('page') || 1;
17                 $this->show_subscriptions($profile, $page);
18         }
19
20         function show_subscriptions($profile, $page) {
21
22                 $sub = DB_DataObject::factory('subscriptions');
23                 $sub->subscriber = $profile->id;
24                 
25                 # We ask for an extra one to know if we need to do another page
26                 
27                 $sub->limit((($page-1)*SUBSCRIPTIONS_PER_PAGE)+1, SUBSCRIPTIONS_PER_PAGE + 1);
28
29                 $subs_count = $subs->find();
30                 
31                 common_start_element('div', 'subscriptions');
32                 
33                 $idx = 0;
34                 
35                 while ($subs->fetch()) {
36                         $idx++;
37                         if ($idx % SUBSCRIPTIONS_PER_ROW == 1) {
38                                 common_start_element('div', 'row');
39                         }
40
41                         common_start_element('a', array('title' => $subs->fullname ||
42                                                                                                    $subs->nickname,
43                                                                                         'href' => $subs->profileurl,
44                                                                                         'class' => 'subscription'));
45                         common_element('img', array('src' => $subs->avatar,
46                                                                                 'class' => 'avatar'));
47                         common_end_element('a');
48                         
49                         if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
50                                 common_end_element('div');
51                         }
52                         
53                         if ($idx == SUBSCRIPTIONS_PER_PAGE) {
54                                 break;
55                         }
56                 }
57
58                 if ($page > 1) {
59                         common_element('a', array('href' => 
60                                                                           common_local_url('subscriptions',
61                                                                                                            array('nickname' => $profile->nickname,
62                                                                                                                          'page' => $page - 1)),
63                                                                           'class' => 'prev'),
64                                            _t('Previous'));
65                 }
66                 
67                 if ($subs_count > SUBSCRIPTIONS_PER_PAGE) {
68                         common_element('a', array('href' => 
69                                                                           common_local_url('subscriptions',
70                                                                                                            array('nickname' => $profile->nickname,
71                                                                                                                          'page' => $page + 1)),
72                                                                           'class' => 'next'),
73                                            _t('Next'));
74                 }
75                 common_end_element('div');
76         }
77 }