/** * Transforms an object (issue) to a string (number). * * @param Issue|null $issue * @return string */ public function transform($issue) { if (null === $issue) { return ''; } return $issue->getId(); }
public function testGetIssueId() { $testIssueId = 'T-2'; $xml = simplexml_load_file($this->filename); $issue = new Issue($xml); $this->assertEquals($testIssueId, $issue->getId()); }
/** * Transforms an object (model) to a string (id). * * @param Issue|null $model * @return string */ public function transform($model) { if (null === $model) { return ''; } return $model->getId(); }
/** * Transforms an object (issue) to a string (number). * * @param Issue|null $entity * @return string */ public function transform($entity) { if (null === $entity) { return ''; } return $entity->getId(); }
/** * Transforms an object (issue) to a string (number). * * @param Issue|null $issue * @return string */ public function transform($issue) { if (null === $issue) { return ''; } $this->id = $issue->getId(); return $issue->getFirstName() . " " . $issue->getSurname() . "(" . $issue->getAddress() . ")"; }
/** * @covers PubObjectCache */ public function testAddIssue() { $nullVar = null; $cache = new PubObjectCache(); $issue = new Issue(); $issue->setId('1'); self::assertFalse($cache->isCached('issues', $issue->getId())); $cache->add($issue, $nullVar); self::assertTrue($cache->isCached('issues', $issue->getId())); $retrievedIssue = $cache->get('issues', $issue->getId()); self::assertEquals($issue, $retrievedIssue); }
/** * Deletes an attachment * * @param Issue $issue * @param Attachment $attachment * @return bool * @throws Exception * @throws NotAuthorizedException * @throws NotFoundException * @throws \Exception */ public function deleteAttachment(Issue $issue, Attachment $attachment) { $issueId = $issue->getId(); $attachmentId = $attachment->getId(); $result = $this->request('DELETE', '/issue/' . rawurlencode($issueId) . '/attachment/' . rawurlencode($attachmentId)); $response = $result['response']; if ($response['http_code'] == 200) { return true; } return false; }
/** * * @param SmartyHelper $smartyHelper * @param Issue $issue * @param int $userid * @param int $teamid */ public static function dashboardSettings(SmartyHelper $smartyHelper, Issue $issue, $userid, $teamid) { $isel = new IssueSelection(); $isel->addIssue($issue->getId()); $pluginDataProvider = PluginDataProvider::getInstance(); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_ISSUE_SELECTION, $isel); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_TEAM_ID, $teamid); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_SESSION_USER_ID, $userid); // start date is min(1st_timetrack, issue_creation_date) $startT = $issue->getDateSubmission(); $firstTT = $issue->getFirstTimetrack(); if (NULL != $firstTT) { $startT = min(array($issue->getDateSubmission(), $firstTT->getDate())); } // end date is last_timetrack or now if none $eTs = NULL == $firstTT ? time() : $issue->getLatestTimetrack()->getDate(); $endT = mktime(23, 59, 59, date('m', $eTs), date('d', $eTs), date('Y', $eTs)); //echo "start $startT end $endT<br>"; // Calculate a nice day interval $nbWeeks = ($endT - $startT) / 60 / 60 / 24; $interval = ceil($nbWeeks / 20); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_START_TIMESTAMP, $startT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_END_TIMESTAMP, $endT); $pluginDataProvider->setParam(PluginDataProviderInterface::PARAM_INTERVAL, $interval); $dashboardName = 'Tasks_prj' . $issue->getProjectId(); // save the DataProvider for Ajax calls $_SESSION[PluginDataProviderInterface::SESSION_ID . $dashboardName] = serialize($pluginDataProvider); // create the Dashboard $dashboard = new Dashboard($dashboardName); // settings are common all tasks of a project $dashboard->setDomain(IndicatorPluginInterface::DOMAIN_TASK); $dashboard->setCategories(array(IndicatorPluginInterface::CATEGORY_QUALITY, IndicatorPluginInterface::CATEGORY_ACTIVITY, IndicatorPluginInterface::CATEGORY_ROADMAP, IndicatorPluginInterface::CATEGORY_PLANNING, IndicatorPluginInterface::CATEGORY_RISK)); $dashboard->setTeamid($teamid); $dashboard->setUserid($userid); $data = $dashboard->getSmartyVariables($smartyHelper); foreach ($data as $smartyKey => $smartyVariable) { $smartyHelper->assign($smartyKey, $smartyVariable); } }
/** * @param Issue $issue * @param boolean $isManager * @return mixed[] */ private function getSmartyDirftedIssue(Issue $issue, $isManager) { $driftMgr = $isManager ? $issue->getDriftMgr() : 0; $drift = $issue->getDrift(); $driftMgrColor = NULL; if ($isManager) { if ($driftMgr < -1) { $driftMgrColor = "#61ed66"; } else { if ($driftMgr > 1) { $driftMgrColor = "#fcbdbd"; } } $driftMgr = round($driftMgr, 2); } $driftColor = NULL; if ($drift < -1) { $driftColor = "#61ed66"; } else { if ($drift > 1) { $driftColor = "#fcbdbd"; } } return array('issueURL' => Tools::issueInfoURL($issue->getId()), 'mantisURL' => Tools::mantisIssueURL($issue->getId(), NULL, true), 'projectName' => $issue->getProjectName(), 'targetVersion' => $issue->getTargetVersion(), 'driftMgrColor' => $driftMgrColor, 'driftMgr' => $driftMgr, 'driftColor' => $driftColor, 'drift' => round($drift, 2), 'backlog' => $issue->getBacklog(), 'progress' => round(100 * $issue->getProgress()), 'currentStatusName' => $issue->getCurrentStatusName(), 'summary' => $issue->getSummary()); }
/** * use min(first timetrack, first status change) as startDate * * @param Issue $issue * @param type $backlogStartDate * @return type */ private function findStartDate(Issue $issue, $backlogStartDate) { // sometimes people add a timetrack but forget to update the status, // in this case the date of the first timetrack will be used $tt = $issue->getFirstTimetrack(); $ttDate = NULL; if (NULL != $tt) { $ttDate = $tt->getDate(); if (self::$logger->isDebugEnabled()) { self::$logger->debug("findStartDate() issue=" . $issue->getId() . ": first timetrack on " . date("Y-m-d", $tt->getDate())); } } // use status to find startDate $statusDate = $this->findStartDateFromStatus($issue, $backlogStartDate); // startDate is the older one if (NULL == $ttDate) { // statusDate is never NULL $startDate = $statusDate; } else { $startDate = min($ttDate, $statusDate); if (self::$logger->isDebugEnabled()) { self::$logger->debug("findStartDate() issue=" . $issue->getId() . ": startDate=" . date("Y-m-d", $startDate) . ' : min(' . date("Y-m-d", $ttDate) . ',' . date("Y-m-d", $statusDate) . ')'); } } return $startDate; }
public function __construct(Issue $issue, $normValue) { $this->bugid = $issue->getId(); #echo "=== NormalizedBacklog $this->bugid normValue=$normValue<br>"; $this->normalize($issue, $normValue); }
/** * Save issue settings. */ function execute($issueId = 0) { $journal =& Request::getJournal(); $issueDao =& DAORegistry::getDAO('IssueDAO'); if ($issueId) { $issue = $issueDao->getIssueById($issueId); $isNewIssue = false; } else { $issue = new Issue(); $isNewIssue = true; } $volume = $this->getData('volume'); $number = $this->getData('number'); $year = $this->getData('year'); $showVolume = $this->getData('showVolume'); $showNumber = $this->getData('showNumber'); $showYear = $this->getData('showYear'); $showTitle = $this->getData('showTitle'); $issue->setJournalId($journal->getId()); $issue->setTitle($this->getData('title'), null); // Localized $issue->setVolume(empty($volume) ? 0 : $volume); $issue->setNumber(empty($number) ? 0 : $number); $issue->setYear(empty($year) ? 0 : $year); if (!$isNewIssue) { $issue->setDatePublished($this->getData('datePublished')); // If the Editor has asked to reset article publication dates for content // in this issue, set them all to the specified issue publication date. if ($this->getData('resetArticlePublicationDates')) { $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticles =& $publishedArticleDao->getPublishedArticles($issue->getId()); foreach ($publishedArticles as $publishedArticle) { $publishedArticle->setDatePublished($this->getData('datePublished')); $publishedArticleDao->updatePublishedArticle($publishedArticle); } } } $issue->setDescription($this->getData('description'), null); // Localized $issue->setStoredPubId('publisher-id', $this->getData('publicIssueId')); $issue->setShowVolume(empty($showVolume) ? 0 : $showVolume); $issue->setShowNumber(empty($showNumber) ? 0 : $showNumber); $issue->setShowYear(empty($showYear) ? 0 : $showYear); $issue->setShowTitle(empty($showTitle) ? 0 : $showTitle); $issue->setCoverPageDescription($this->getData('coverPageDescription'), null); // Localized $issue->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage')); foreach (array_keys($this->getData('coverPageDescription')) as $locale) { if (!array_key_exists($locale, $showCoverPage)) { $showCoverPage[$locale] = 0; } } $issue->setShowCoverPage($showCoverPage, null); // Localized $hideCoverPageArchives = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageArchives')); foreach (array_keys($this->getData('coverPageDescription')) as $locale) { if (!array_key_exists($locale, $hideCoverPageArchives)) { $hideCoverPageArchives[$locale] = 0; } } $issue->setHideCoverPageArchives($hideCoverPageArchives, null); // Localized $hideCoverPageCover = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageCover')); foreach (array_keys($this->getData('coverPageDescription')) as $locale) { if (!array_key_exists($locale, $hideCoverPageCover)) { $hideCoverPageCover[$locale] = 0; } } $issue->setHideCoverPageCover($hideCoverPageCover, null); // Localized $issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN); // See bug #6324 if ($this->getData('enableOpenAccessDate')) { $issue->setOpenAccessDate($this->getData('openAccessDate')); } else { $issue->setOpenAccessDate(null); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $issue); // if issueId is supplied, then update issue otherwise insert a new one if ($issueId) { $issue->setId($issueId); $this->issue =& $issue; parent::execute(); $issueDao->updateIssue($issue); } else { $issue->setPublished(0); $issue->setCurrent(0); $issueId = $issueDao->insertIssue($issue); $issue->setId($issueId); } import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->uploadedFileExists('coverPage')) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName('coverPage'); $type = $publicFileManager->getUploadedFileType('coverPage'); $newFileName = 'cover_issue_' . $issueId . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($type); $publicFileManager->uploadJournalFile($journal->getId(), 'coverPage', $newFileName); $issue->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale()); $issue->setFileName($newFileName, $this->getFormLocale()); // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName); $issue->setWidth($width, $this->getFormLocale()); $issue->setHeight($height, $this->getFormLocale()); $issueDao->updateIssue($issue); } if ($publicFileManager->uploadedFileExists('styleFile')) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName('styleFile'); $newFileName = 'style_' . $issueId . '.css'; $publicFileManager->uploadJournalFile($journal->getId(), 'styleFile', $newFileName); $issue->setStyleFileName($newFileName); $issue->setOriginalStyleFileName($publicFileManager->truncateFileName($originalFileName, 127)); $issueDao->updateIssue($issue); } return $issueId; }