public function execute($request) { $this->setLayout(false); sfConfig::set('sf_web_debug', false); sfConfig::set('sf_debug', false); if ($this->getRequest()->isXmlHttpRequest()) { $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8'); } $membershipId = $request->getParameter('id'); $service = new MembershipService(); $membership = $service->getMembershipById($membershipId); return $this->renderText(json_encode($membership->toArray())); }
/** * Delete Membership Type * @param sfWebRequest $request * @return unknown_type */ public function executeDeleteMembership(sfWebRequest $request) { if (count($request->getParameter('chkLocID')) > 0) { $membershipService = new MembershipService(); $membershipService->deleteMembership($request->getParameter('chkLocID')); $this->setMessage('SUCCESS', array(TopLevelMessages::DELETE_SUCCESS)); } else { $this->setMessage('NOTICE', array(TopLevelMessages::SELECT_RECORDS)); } $this->redirect('admin/listMembership'); }
public static function sysLogoff($membership_id, $wifi_server_conf_array, $aam_param_array) { $curr_connect = self::getLastWifiConnectLog($membership_id); $connect_id = null; if (!empty($curr_connect)) { $curr_wifi_time = $curr_connect->wifi_time / 60; if (2 <= $curr_connect->exit_type) { $online_time = round(($curr_connect->wifi_logout_time - $curr_connect->wifi_login_time) / 60, 2); } else { $online_time = round((time() - $curr_connect->wifi_login_time) / 60, 2); } if ($online_time >= $curr_wifi_time) { $online_time = $curr_wifi_time; } if ($curr_wifi_time == $online_time) { } elseif ($online_time < $curr_wifi_time && 1 < $curr_connect->exit_type) { } else { $connect_id = $curr_connect->id; } } // if($online_time > $curr_wifi_time && 0 == $curr_connect->exit_type){ // // } if (!empty($connect_id)) { $transaction = Yii::app()->db->beginTransaction(); try { $wifiConnectLog = WifiConnectLog::model()->findByPk($connect_id); $wifiService = WifiService::model()->find(array('condition' => 'membership_id=:membership_id', 'params' => array(':membership_id' => $membership_id))); if (!empty($wifiConnectLog) && 0 == $wifiConnectLog->exit_type && !empty($wifiService)) { if (empty($aam_param_array)) { $aam_param_array['wlanacip'] = empty($wifiConnectLog->wlanacip) ? '' : $wifiConnectLog->wlanacip; $aam_param_array['ssid'] = empty($wifiConnectLog->ssid) ? '' : $wifiConnectLog->ssid; $aam_param_array['wlanuserip'] = empty($wifiConnectLog->ip_address) ? '' : $wifiConnectLog->ip_address; $aam_param_array['wlanapmac'] = empty($wifiConnectLog->mac_address) ? '' : $wifiConnectLog->mac_address; } $membership = MembershipService::getMembership($membership_id); $aam_conf_array = isset($wifi_server_conf_array['wifi_param']) ? $wifi_server_conf_array['wifi_param'] : ''; $logoff_url = MywifiService::createWifiLogoffUrl($membership, 0, $aam_conf_array, $aam_param_array); $wifi_logoff_state = MywifiService::WifiLogOff($membership, $wifiConnectLog->wifi_service_name, 0, $logoff_url, $aam_param_array); if ('1' === $wifi_logoff_state || '2' === $wifi_logoff_state) { $wifiConnectLog->exit_type = 2; $wifiConnectLog->wifi_logout_time = time(); $curr_online_time = $wifiConnectLog->wifi_logout_time - $wifiConnectLog->wifi_login_time; if ($curr_online_time > $wifiConnectLog->wifi_time) { $curr_online_time = $wifiConnectLog->wifi_time; } $wifiConnectLog->wifi_online_time = $curr_online_time; $wifiConnectLog->save(); $wifiService->total_wifi_time -= $wifiConnectLog->wifi_online_time; if (0 > $wifiService->total_wifi_time) { $wifiService->total_wifi_time = 0; } $wifiService->save(); $transaction->commit(); } else { $transaction->commit(); } } } catch (Exception $exc) { $transaction->rollback(); } } }