Example #1
0
 /**
  *
  * cmd posible values:
  * 'getCasesInfo' - in response there will be returned set of cases and subcases info formated in WikiText
  * 'getComment' - in response there will be returned comments for particular case
  */
 public static function getFogbugzServiceResponse()
 {
     global $wgRequest, $wgHTTPProxy, $wgFogbugzAPIConfig;
     $command = $wgRequest->getText('cmd');
     $myFBService = new FogbugzService($wgFogbugzAPIConfig['apiUrl'], $wgFogbugzAPIConfig['username'], $wgFogbugzAPIConfig['password'], $wgHTTPProxy);
     // there should be made some kind of protection from setting different value as cmd
     if ($command == 'getCasesInfo') {
         $outerIDs = $wgRequest->getArray('IDs');
         $results = array();
         try {
             $results = $myFBService->logon()->getCasesBasicInfo($outerIDs);
         } catch (Exception $e) {
             $results = array();
         }
         $preparedResults = FogbugzTag::sortAndMakeTickets($results);
         $response = new AjaxResponse();
         $response->addText(json_encode($preparedResults));
     } else {
         // this part is not in use now; it will be after adding displaying comments
         $outerIDs = $wgRequest->getText('ID');
         /* ... */
     }
     if (!$response) {
         $response = new AjaxResponse();
         $response->addText(json_encode(array('status' => wfMsg('fbtag-unknown-error'))));
     }
     return $response;
 }
Example #2
0
     wfGetDB(DB_MASTER)->delete('fogbugz_cases', '*');
     $wgMemc->set($key, null);
     echo "Database clear!\n";
 } else {
     //$command = $wgRequest->getText('cmd');
     $myFBService = new FogbugzService($wgFogbugzAPIConfig['apiUrl'], $wgFogbugzAPIConfig['username'], $wgFogbugzAPIConfig['password'], $wgHTTPProxy);
     $LastUpdated = $wgMemc->get($key);
     // we've got dtLastUpdated value
     echo "Date of last updated case:\n";
     print_r($LastUpdated);
     echo "\n";
     $DBconnMSTR = wfGetDB(DB_MASTER);
     $dateToday = new DateTime();
     if ($LastUpdated != null) {
         echo "Getting cases updated in last 15 mins...\n";
         $results = $myFBService->logon()->findAndSaveCasesToMemc('category:"Bug" lastupdated:"-15m.."', false);
         $totalLastUpdate = '';
         // value that should be written in memc after adding/updating data
         foreach ($results as $res) {
             if (strtotime($res['dtLastUpdated']) > strtotime($LastUpdated)) {
                 echo "Updating/inserting case " . $res['ixBug'] . " in database...\n";
                 replaceCase($DBconnMSTR, $res);
                 $totalLastUpdate = $res['dtLastUpdated'];
             }
         }
         if ($totalLastUpdate != '') {
             $LastUpdated = $totalLastUpdate;
         }
         $wgMemc->set($key, $LastUpdated);
     } else {
         echo "Updating whole database...\n";