示例#1
0
 public function medalCallBack()
 {
     $medal_name = t($_REQUEST['medal']);
     $method_name = t($_REQUEST['method']);
     $param = unserialize(urldecode($_REQUEST['param']));
     echo medal($medal_name)->{$method_name}($param);
 }
示例#2
0
 /**
  * 勋章Widget - 关闭提示消息
  */
 public function medalCloseAlert()
 {
     $_POST['medal_id'] = intval($_POST['medal_id']);
     $medal_path_name = M('medal')->where('`medal_id`=' . $_POST['medal_id'])->getField('path_name');
     medal($medal_path_name)->closeMedalAlert($this->mid, $_POST['medal_id']);
 }
示例#3
0
 /**
  * 获取用户勋章的widget数据
  * 
  * @param int  $uid
  * @param bool $hide_inactive	是否隐藏用户禁用的勋章
  * @param bool $hide_unreceived 是否隐藏用户未获得的勋章
  * @return array
  */
 public function getMedalWidgetData($uid, $hide_inactive = true, $hide_unreceived = true)
 {
     $data['uid'] = $uid;
     // 获取勋章数据,并将数组转换为 array($medal_id => $array) 的形式
     $medal = $this->__changeArrayKey($this->getActiveMedal());
     $user_medal = $this->__changeArrayKey($this->getUserMedal($data['uid']));
     // 轮询获取勋章详情
     $data['user_medal'] = array();
     foreach ($medal as $k => $v) {
         // 检查用户是否禁用勋章
         if ($hide_inactive && !empty($user_medal[$k]) && !$user_medal[$k]['is_active']) {
             continue;
         }
         $temp_medal_data = medal($v['path_name'])->getMedalStatus($data['uid'], $k, $user_medal[$k], $v);
         if (empty($data['alert']) && $temp_medal_data['is_alert_on'] && !empty($temp_medal_data['alert_message'])) {
             $data['alert'] = array('medal_id' => $k, 'content' => $temp_medal_data['alert_message']);
         }
         // 勋章的获取时间为0时表示用户未获得勋章, 不显示该勋章(注: 该勋章的alert_message仍然可以有效)
         if ($hide_unreceived && intval($temp_medal_data['received_time']) <= 0) {
             unset($temp_medal_data);
             continue;
         } else {
             $temp_medal_data['received_time'] = $temp_medal_data['received_time'] <= 0 ? 0 : date('Y-m-d H:i', $temp_medal_data['received_time']);
             $temp_medal_data['is_active'] = isset($user_medal[$k]['is_active']) ? $user_medal[$k]['is_active'] : '1';
             $temp_medal_data['medal_id'] = $v['medal_id'];
             $temp_medal_data['path_name'] = $v['path_name'];
             $data['user_medal'][$k] = $temp_medal_data;
             unset($temp_medal_data);
         }
     }
     unset($medal, $user_medal);
     return $data;
 }