Completed
Push — master ( ad816b...2d800d )
by Mikael
03:10
created

CInterface::getSessionDetails()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 14
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 20
rs 9.4285
1
<?php
2
3
namespace Anax\AddOn\PHPBB;
4
5
/**
6
 * Create a interface for PHPBB.
7
 * 
8
 */
9
class CInterface {
10
11
    /**
12
     * Sample function to integrate with a phpbb installation and lend some
13
     * information on the authorized user.
14
     *
15
     * @param string $path is the install path of PHPBB.
16
     * @return array with details of user.
17
     */
18
    function getSessionDetails($path) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
19
        global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template, $auth;
20
21
        define('IN_PHPBB', true);
22
        $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $path;
23
        $phpEx = "php"; //substr(strrchr(__FILE__, '.'), 1);
24
        include("$path/common.php");
25
26
        // Start session management
27
        $user->session_begin();
28
        $auth->acl($user->data);
29
        $user->setup();
30
31
        return array(
32
            'is_anonymous'  => ($user->data['user_id'] == ANONYMOUS),
33
            'user_acronym'  => $user->data['username_clean'],
34
            'user_email'    => $user->data['user_email'],
35
            'session_id'    => $user->data['session_id'],
36
        );
37
    }
38
39
40
41
 /**
42
   * Get latest topics.
43
   *
44
   * @param int $max items to return.
45
   * @return array
46
   */
47
   /*
48
  public function LatestTopics($max=3) {
49
    global $auth, $db;
50
51
    // Create arrays
52
    $topics = array();
53
    
54
    // Get forums that current user has read rights to.
55
    $forums = array_unique(array_keys($auth->acl_getf('f_read', true)));
56
    
57
    // Get active topics.
58
    $sql="SELECT *
59
    FROM " . TOPICS_TABLE . "
60
    WHERE topic_approved = '1' AND " . $db->sql_in_set('forum_id', $forums) . "
61
    ORDER BY topic_last_post_time DESC";
62
    $result = $db->sql_query_limit($sql, $max);
63
    while ($r = $db->sql_fetchrow($result)) {
64
        $topics[] = $r;
65
    }
66
    $db->sql_freeresult($result);
67
    
68
    $items = array();
69
    foreach($topics as $t) {
70
      // Get folder img, topic status/type related information
71
      //$topic_tracking_info = get_complete_topic_tracking($t['forum_id'], $t['topic_id']);
72
      //$unread_topic = (isset($topic_tracking_info[$t['topic_id']]) && $t['topic_last_post_time'] > $topic_tracking_info[$t['topic_id']]) ? true : false;
73
      //topic_status($t, $t['topic_replies'], $unread_topic, $folder_img, $folder_alt, $topic_type);
74
      // href = $phpbb_root_path . 'viewtopic.php?f=' . $t['forum_id'] . '&amp;t=' . $t['topic_id'] . '&amp;p=' . $t['topic_last_post_id'] . '#p' . $t['topic_last_post_id'];
75
      $item['forum_id'] = $t['forum_id'];
76
      $item['topic_id'] = $t['topic_id'];
77
      $item['topic_last_post_id'] = $t['topic_last_post_id'];
78
      $item['topic_title'] = $t['topic_title'];
79
      $items[] = $item;
80
    }
81
82
    return($items);
83
  }
84
*/
85
}
86