/** * @return string json string of timer data */ function getJson() { $authenticationAndSecurity = new authenticationAndSecurity(); $reporterCookieName = 'timerCookie'; if (null !== $authenticationAndSecurity->getcookie($reporterCookieName)) { $reporterName = $authenticationAndSecurity->getSingleCookie($reporterCookieName); } else { die('Error: no reporter cookie'); } $json = $this->getTimeJsonFile($reporterName); return $json; }
/** * send posts to Youtrack * @param array $posts * @return array $posts */ function sendPostData($posts) { $authenticationAndSecurity = new authenticationAndSecurity(); foreach ($posts as $postskey => $singlePost) { foreach ($singlePost as $key => $field) { if ($field == '') { unset($singlePost[$key]); } } if (null !== $authenticationAndSecurity->getPost("user")) { $singlePost['reporterName'] = $authenticationAndSecurity->getPost("user"); } else { $reporterCookieName = 'myCookie'; if (null !== $authenticationAndSecurity->getcookie($reporterCookieName)) { $singlePost['reporterName'] = $authenticationAndSecurity->getSingleCookie($reporterCookieName); } else { echo 'Error: no reporter cookie or user set in customSettings' . $GLOBALS["newline"]; } } $workflow = new ApiWriter(); // try { // // requires youtrack admin permissions to import with xml content // $workflow->updateTracker($singlePost); // $posts[$postskey] = array_merge( ['upload success' => 'success'] , $posts[$postskey] ); // } catch (Exception $e) { //if( $e->getResponse() ) { // $HTTPResponseStatusCode = $e->getResponse()->getStatusCode(); // if previous ticket import permission issues, possibly not admin user // if($HTTPResponseStatusCode = 403){ $workflow->stdUserUpdateTracker($singlePost, $postskey); $posts[$postskey] = array_merge(['upload success' => 'success'], $posts[$postskey]); // } // }else{ // error_log($e); // echo 'IMPORT ISSUE FAILED:: unable to import ticket to '.$singlePost['project'].' with summary "'.$singlePost['summary'].'"'.$GLOBALS["newline"]; // $posts[$postskey] = array_merge( ['upload success' => 'failed'] , $posts[$postskey] ); // } // } } return $posts; }
/** * save the timing data * @param $json * @return bool */ function saveJson($json) { $authenticationAndSecurity = new authenticationAndSecurity(); $reporterCookieName = 'timerCookie'; if (null !== $authenticationAndSecurity->getcookie($reporterCookieName)) { $reporterName = $authenticationAndSecurity->getSingleCookie($reporterCookieName); } else { die('Error: no reporter cookie'); } if ($this->createTimeJsonFile($reporterName, $json)) { $this->removeOldFiles($reporterName); return true; } else { return false; } }