Exemple #1
0
 public static function boardindex()
 {
     global $context, $txt, $sourcedir, $user_info;
     $data = array();
     if (($data = CacheAPI::getCache('github-feed-index', 1800)) === null) {
         $f = curl_init();
         if ($f) {
             curl_setopt_array($f, array(CURLOPT_URL => self::$my_git_api_url, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false));
             $json_response = curl_exec($f);
             $data = json_decode($json_response, true);
             CacheAPI::putCache('github-feed-index', $data, 1800);
             curl_close($f);
         }
     }
     $n = 0;
     foreach ($data as $commit) {
         if (is_array($commit) && isset($commit['commit'])) {
             $context['gitfeed'][] = array('message_short' => shorten_subject($commit['commit']['message'], 60), 'message' => nl2br($commit['commit']['message']), 'dateline' => timeformat(strtotime($commit['commit']['committer']['date'])), 'sha' => $commit['sha'], 'href' => self::$my_git_url . 'commit/' . $commit['sha']);
         }
         if (++$n > 5) {
             break;
         }
     }
     if (!empty($data)) {
         /* 
          * add our plugin directory to the list of directories to search for templates
          * and register the template hook.
          * only do this if we actually have something to display
          */
         EoS_Smarty::addTemplateDir(dirname(__FILE__));
         EoS_Smarty::getConfigInstance()->registerHookTemplate('sidebar_below_userblock', 'gitfeed_sidebar_top');
         $context['gitfeed_global']['see_all']['href'] = self::$my_git_url . 'commits/master';
         $context['gitfeed_global']['see_all']['txt'] = 'Browse all commits';
     }
 }
Exemple #2
0
 public static function profile_summary(&$memID, &$user_profile)
 {
     global $context, $user_info, $txt;
     // only show this to either admins or profile owners
     if ($user_info['is_admin'] || $memID == $user_info['id']) {
         $txt['geoip_profile_summary_label'] = 'GeoIP location info:';
         $context['region_info'] = self::getLocationRecord($user_profile[$memID]['member_ip']);
         EoS_Smarty::addTemplateDir(dirname(__FILE__));
         EoS_Smarty::getConfigInstance()->registerHookTemplate('profile_summary_extend_basic', 'geoip_profile_summary');
     }
 }
Exemple #3
0
    public static function messageindex(&$board_info)
    {
        global $context, $txt, $sourcedir, $user_info;
        loadLanguage('Activities');
        // add our plugin directory to the list of directories to search for templates.
        EoS_Smarty::addTemplateDir(dirname(__FILE__));
        // register two hook templates for the side bar top and bottom areas
        EoS_Smarty::getConfigInstance()->registerHookTemplate('sidebar_top', 'testplugin_sidebar_top');
        EoS_Smarty::getConfigInstance()->registerHookTemplate('sidebar_bottom', 'testplugin_sidebar_bottom');
        // register some global variable (that's optional though, it would be totally ok to use $context)
        // You should always assignByRef(), because it's faster and doesn't create a copy
        // of the variable
        EoS_Smarty::getSmartyInstance()->assignByRef('MYDATA', self::$mydata);
        // enable side bar in the message index display
        if ($user_info['is_admin'] && $board_info['allow_topics']) {
            $context['show_sidebar'] = true;
            $context['sidebar_template'] = 'sidebars/sidebar_on_messageindex.tpl';
            $context['sidebar_class'] = 'messageindex';
            GetSidebarVisibility('messageindex');
        } else {
            $context['show_sidebar'] = false;
        }
        $ignoreusers = !empty($user_info['ignoreusers']) ? $user_info['ignoreusers'] : array(0);
        // .. and set the name of the template
        self::$mydata['testvalue'] = 'Foo';
        @(require_once $sourcedir . '/lib/Subs-Activities.php');
        $context['act_global'] = false;
        $request = smf_db_query('SELECT a.*, t.*, b.name AS board_name FROM {db_prefix}log_activities AS a
				LEFT JOIN {db_prefix}activity_types AS t ON (t.id_type = a.id_type)
				LEFT JOIN {db_prefix}boards AS b ON (b.id_board = a.id_board)
				WHERE a.id_board = {int:id_board} AND a.id_member NOT IN({array_int:ignoredusers}) ORDER BY a.id_act DESC LIMIT 5', array('id_board' => $context['current_board'], 'ignoredusers' => $ignoreusers));
        aStreamOutput($request, false, true);
        /*
        		if(isset($context['activities'])) {
        			usort($context['activities'], function($a, $b) {
        	    		if ($a['updated'] == $b['updated'])
        	        		return 0;
        	    		return ($a['updated'] < $b['updated']) ? -1 : 1;
        			});
        		}*/
        $request = smf_db_query('SELECT m.* FROM {db_prefix}messages AS m
				WHERE m.id_board = {int:id_board} AND m.id_member NOT IN ({array_int:ignoredusers})
				ORDER BY m.id_msg DESC LIMIT 10', array('id_board' => $context['current_board'], 'ignoredusers' => $ignoreusers));
        mysql_free_result($request);
    }