<?php

/*
  PHP version 5
  Copyright (c) 2002-2019ECISP.CN、EarcLink.COM
  警告：这不是一个免费的软件，请在许可范围内使用，请尊重知识产权，侵权必究，举报有奖
  作者：黄祥云 E-mail:6326420@qq.com  QQ:6326420 TEL:18665655030 / 13797552220
*/


use application\ESPCMS_AdminAuthority;
use application\ESPCMS_Core;
use modul_application\ESPCMS_MemberDB;
use admin_application\link\MenuLink;
use admin_application\link\MemberLink;

class MemberWidget {

	private static $mothodName;

	public function __construct() {
		ESPCMS_AdminAuthority::authorityBaseVerify(true);
		self::$mothodName = 'MemberMain';
		$member_app_config = ESPCMS_Core::get_app_config('member', false);
		if (!$member_app_config['isetup']) {
			espcms_message_err('public_pack-espcms_module_file_err', array(self::$mothodName));
		}
	}

	public static function widgetOutput() {
		$espcms_widget_templates = espcms_admin_template();
		$espcms_widget_templates->libfile = true;
		$widget_read = ESPCMS_Core::get_widget_view(0, self::$mothodName);
		$widget_read['link'] = MenuLink::getLink('link', $widget_read);
		$widget_read['ajaxlink'] = MenuLink::getLink('ajaxlink', $widget_read);
		$espcms_widget_templates->into('widget_read', $widget_read);
		$output = $espcms_widget_templates->fetch('member/member_widget');
		return $output;
	}

	public static function widgetList() {
		global $espcms_admin_templates, $espcms_link_db;
		$db_table = ESPCMS_DB_PREFIX . "member";
		$db_query = $espcms_link_db->db_query(espcms_db_list_out($db_table, '', 'userid', 'DESC', 0, 5));
		while ($fetch_row = $espcms_link_db->db_array_list($db_query)) {
			$fetch_row['rankname'] = ESPCMS_MemberDB::get_member_class_view($fetch_row['mcid'], 'rankname');
			$fetch_row['edit'] = MemberLink::Member_link_array('edit', $fetch_row);
			$fetch_row['view'] = MemberLink::Member_link_array('view', $fetch_row);
			$array[] = $fetch_row;
		}
		$espcms_admin_templates->into('array', $array);
		$espcms_admin_templates->output('member/member_widget_list');
	}

}
