Esempio n. 1
0
 /**
  * Catches and do some manual actions
  * 
  * @return void/string
  */
 public function catchManualAction()
 {
     $result = '';
     if (wf_CheckGet(array('subid', 'maction'))) {
         $action = vf($_GET['maction']);
         $subId = vf($_GET['subid'], 3);
         if (isset($this->allSubscribers[$subId])) {
             $subData = $this->allSubscribers[$subId];
             switch ($action) {
                 case 'subscribe':
                     $mgApi = new MegogoApi();
                     $serviceId = $this->allTariffs[$subData['tariffid']]['serviceid'];
                     $resubResult = $mgApi->subscribe($subData['login'], $serviceId);
                     log_register('MEGOGO MANUAL ACTION `' . $action . '` (' . $subData['login'] . ')');
                     if (!$resubResult) {
                         $result = $this->messages->getStyledMessage('EX_API_SUBSCRIPTION_FAIL', 'error');
                     }
                     break;
                 case 'unsubscribe':
                     $mgApi = new MegogoApi();
                     $serviceId = $this->allTariffs[$subData['tariffid']]['serviceid'];
                     $unsubResult = $mgApi->unsubscribe($subData['login'], $serviceId);
                     log_register('MEGOGO MANUAL ACTION `' . $action . '` (' . $subData['login'] . ')');
                     if (!$unsubResult) {
                         $result = $this->messages->getStyledMessage('EX_API_UNSUBSCRIPTION_FAIL', 'error');
                     }
                     break;
                 case 'activate':
                     simple_update_field('mg_subscribers', 'active', 1, "WHERE `id`='" . $subId . "';");
                     log_register('MEGOGO MANUAL ACTION `' . $action . '` (' . $subData['login'] . ')');
                     break;
                 case 'deactivate':
                     simple_update_field('mg_subscribers', 'active', 0, "WHERE `id`='" . $subId . "';");
                     log_register('MEGOGO MANUAL ACTION `' . $action . '` (' . $subData['login'] . ')');
                     break;
                 case 'delete':
                     nr_query("DELETE FROM `mg_subscribers` WHERE `id`='" . $subId . "';");
                     log_register('MEGOGO MANUAL ACTION `' . $action . '` (' . $subData['login'] . ')');
                     break;
             }
         } else {
             $result = $this->messages->getStyledMessage('EX_ID_NOEXISTS', 'error');
         }
     }
     return $result;
 }