/** * The setter of the field issue_id. * @param Issue $issue - the issue related to the reply */ public function setIssue(Issue $issue) { if ($issue == NULL) { throw new InvalidArgumentException('[Model\\IssueReply] Invalid Model\\Issue.'); } $this->issue_id = $issue->getIssueId(); }
camp_html_goto_page($backLink); } $changed = true; $changed &= $issueObj->setName($f_issue_name); if ($issueObj->getWorkflowStatus() == 'Y') { $changed &= $issueObj->setPublicationDate($f_publication_date); } //@New theme management $resourceId = new ResourceId('Publication/Edit'); $themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1); $outputSettingIssueService = $resourceId->getService(IOutputSettingIssueService::NAME); $outputService = $resourceId->getService(IOutputService::NAME); $issueService = $resourceId->getService(IIssueService::NAME); $syncRsc = $resourceId->getService(ISyncResourceService::NAME); $newOutputSetting = false; $outSetIssues = $outputSettingIssueService->findByIssue($issueObj->getIssueId()); if (count($outSetIssues) > 0) { $outSetIssue = $outSetIssues[0]; } else { $outSetIssue = new OutputSettingsIssue(); $outSetIssue->setOutput($outputService->findByName('Web')); $outSetIssue->setIssue($issueService->getById($issueObj->getIssueId())); $newOutputSetting = true; } $outSetIssue->setThemePath($syncRsc->getThemePath($f_theme_id)); if ($f_issue_template_id != null && $f_issue_template_id != '0') { $outSetIssue->setFrontPage($syncRsc->getResource('frontPage', $f_issue_template_id)); } else { $outSetIssue->setFrontPage(null); } if ($f_section_template_id != null && $f_section_template_id != '0') {
/** * Create an issue of a product. * @param Product $product - the product which the issue points to * @param String $productVersion - the version of the product where the issue found * @param String $issueCategorySlug - the unique slug of the category of the issue * @param User $hunter - the user who found the issue * @param String $issueTitle - the title of the issue * @param String $issueDescription - the description of the issue * @param boolean $isTokenValid - whether the CSRF token is correct * @return an array with data validation result */ public function createIssue($product, $productVersion, $issueCategorySlug, $hunter, $issueTitle, $issueDescription, $isTokenValid) { $issueCategory = $this->getIssueCategoryObjectUsingSlug($issueCategorySlug); $result = array('isSuccessful' => false, 'isProductExists' => $product != NULL, 'isProductVersionEmpty' => empty($productVersion), 'isProductVersionLegal' => $this->isProductVersionLegal($productVersion), 'isIssueCategoryEmpty' => $issueCategory == NULL, 'isUserLoggedIn' => $hunter != NULL, 'isIssueTitleEmpty' => empty($issueTitle), 'isIssueTitleLegal' => $this->isIssueTitleLegal($issueTitle), 'isDescriptionEmpty' => empty($issueDescription), 'isTokenValid' => $isTokenValid); $result['isSuccessful'] = $result['isProductExists'] && !$result['isProductVersionEmpty'] && $result['isProductVersionLegal'] && !$result['isIssueCategoryEmpty'] && $result['isUserLoggedIn'] && !$result['isIssueTitleEmpty'] && $result['isIssueTitleLegal'] && !$result['isDescriptionEmpty'] && $result['isTokenValid']; if ($result['isSuccessful']) { $issueStatus = IssueStatus::findFirst("issue_status_slug = 'unconfirmed'"); $issue = new Issue(); $issue->setProduct($product); $issue->setProductVersion($productVersion); $issue->setIssueCategory($issueCategory); $issue->setIssueStatus($issueStatus); $issue->setHunter($hunter); $issue->setIssueTitle($issueTitle); $issue->setIssueDescription($issueDescription); if (!$issue->create()) { $result['isSuccessful'] = false; } else { $result['issueId'] = $issue->getIssueId(); } } return $result; }
public static function GetIssueTemplate($p_lngId, $p_pubId, $p_issNr) { global $g_ado_db; $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheKey = $cacheService->getCacheKey(array('GetIssueTemplate', $p_lngId, $p_pubId, $p_issNr), 'issue'); if ($cacheService->contains($cacheKey)) { return $cacheService->fetch($cacheKey); } else { $resourceId = new ResourceId('template_engine/classes/CampSystem'); $outputService = $resourceId->getService(IOutputService::NAME); if (!\Zend_Registry::isRegistered('webOutput')) { $cacheKeyWebOutput = $cacheService->getCacheKey(array('OutputService', 'Web'), 'outputservice'); if ($cacheService->contains($cacheKeyWebOutput)) { \Zend_Registry::set('webOutput', $cacheService->fetch($cacheKeyWebOutput)); } else { $webOutput = $outputService->findByName('Web'); $cacheService->save($cacheKeyWebOutput, $webOutput); \Zend_Registry::set('webOutput', $webOutput); } } /* @var $templateSearchService ITemplateSearchService */ $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME); $issueObj = new Issue($p_pubId, $p_lngId, $p_issNr); $data = $templateSearchService->getFrontPage($issueObj->getIssueId(), \Zend_Registry::get('webOutput')); if (empty($data)) { $data = self::GetInvalidURLTemplate($p_pubId, $p_issNr, $p_lngId); } $cacheService->save($cacheKey, $data); return $data; } }
/** * Create a copy of the article, but make it a translation * of the current one. * * @param int $p_languageId * @param int $p_userId * @param string $p_name * @return Article */ public function createTranslation($p_languageId, $p_userId, $p_name) { $translator = \Zend_Registry::get('container')->getService('translator'); // Construct the duplicate article object. $articleCopy = new Article(); $articleCopy->m_data['IdPublication'] = $this->m_data['IdPublication']; $articleCopy->m_data['NrIssue'] = $this->m_data['NrIssue']; $articleCopy->m_data['NrSection'] = $this->m_data['NrSection']; $articleCopy->m_data['IdLanguage'] = $p_languageId; $articleCopy->m_data['Number'] = $this->m_data['Number']; $values = array(); // Copy some attributes $values['ShortName'] = $this->m_data['ShortName']; $values['Type'] = $this->m_data['Type']; $values['OnFrontPage'] = $this->m_data['OnFrontPage']; $values['OnSection'] = $this->m_data['OnFrontPage']; $values['Public'] = $this->m_data['Public']; $values['ArticleOrder'] = $this->m_data['ArticleOrder']; $values['comments_enabled'] = $this->m_data['comments_enabled']; $values['comments_locked'] = $this->m_data['comments_locked']; $values['rating_enabled'] = $this->m_data['rating_enabled']; // Change some attributes $values['Name'] = $p_name; $values['Published'] = 'N'; $values['IsIndexed'] = 'N'; $values['IdUser'] = $p_userId; // for internall relations in entity we need also to keep sectionId and issueId $issueObj = new Issue($this->m_data['IdPublication'], $p_languageId, $this->m_data['NrIssue']); $sectionObj = new Section($this->m_data['IdPublication'], $this->m_data['NrIssue'], $p_languageId, $this->m_data['NrSection']); $values['issue_id'] = $issueObj->getIssueId(); $values['section_id'] = $sectionObj->getSectionId(); // Create the record $success = $articleCopy->__create($values); if (!$success) { return false; } $articleCopy->setProperty('UploadDate', 'NOW()', true, true); $articleCopy->setProperty('LockUser', 'NULL', true, true); $articleCopy->setProperty('LockTime', 'NULL', true, true); // Insert an entry into the article type table. $articleCopyData = new ArticleData($articleCopy->m_data['Type'], $articleCopy->m_data['Number'], $articleCopy->m_data['IdLanguage']); $articleCopyData->create(); $origArticleData = $this->getArticleData(); $origArticleData->copyToExistingRecord($articleCopy->getArticleNumber(), $p_languageId); $logtext = $translator->trans('Article translated to $4 ($5)', array('$4' => $articleCopy->getTitle(), '$5' => $articleCopy->getLanguageName()), 'api'); Log::ArticleMessage($this, $logtext, null, 31); // geo-map processing Geo_Map::OnCreateTranslation($this->m_data['Number'], $this->m_data['IdLanguage'], $p_languageId); return $articleCopy; }
$errorStr = $translator->trans('There was an error reading the issue parameter.', array(), 'issues'); } } if ($errorStr != "") { camp_html_display_error($errorStr, null, true); } $resourceId = new ResourceId('Publication/Edit'); $themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1); /* @var $themeManagementService \Newscoop\Service\Implementation\ThemeManagementServiceLocal */ $outputSettingIssueService = $resourceId->getService(IOutputSettingIssueService::NAME); /* @var $outputSettingIssueService \Newscoop\Service\Implementation\OutputSettingIssueServiceDoctrine */ $issueService = $resourceId->getService(IIssueService::NAME); /* @var $issueService \Newscoop\Service\Implementation\IssueServiceDoctrine */ $outputService = $resourceId->getService(IOutputService::NAME); $syncRsc = $resourceId->getService(ISyncResourceService::NAME); $outputIssueSettings = current($outputSettingIssueService->findByIssue($issueObj->getIssueId())); /* @var $outputIssueSettings \Newscoop\Entity\Output\OutputSettingsIssue */ $publicationThemes = $themeManagementService->getThemes($publicationObj->getPublicationId()); if (!$outputIssueSettings) { if (count($publicationThemes) > 0) { $themePath = $publicationThemes[0]->getPath(); $outputIssueSettings = new OutputSettingsIssue(); $outputIssueSettings->setOutput($outputService->findByName('Web')); $outputIssueSettings->setIssue($issueService->getById($issueObj->getIssueId())); $outputIssueSettings->setThemePath($syncRsc->getThemePath($themePath)); $outputIssueSettings->setFrontPage(null); $outputIssueSettings->setSectionPage(null); $outputIssueSettings->setArticlePage(null); $outputSettingIssueService->insert($outputIssueSettings); } else { $errorStr = $translator->trans('This issue cannot be previewed. Please make sure the publication has a theme assigned.', array(), 'issues');
public static function GetIssueTemplate($p_lngId, $p_pubId, $p_issNr) { global $g_ado_db; if (CampCache::IsEnabled()) { $paramString = $p_lngId . '_' . $p_pubId . '_' . $p_issNr; $cacheKey = __CLASS__ . '_IssueTemplate_' . $paramString; $issueTemplate = CampCache::singleton()->fetch($cacheKey); if ($issueTemplate !== false && !empty($issueTemplate)) { return $issueTemplate; } } $resourceId = new ResourceId('template_engine/classes/CampSystem'); /* @var $templateSearchService ITemplateSearchService */ $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME); $outputService = $resourceId->getService(IOutputService::NAME); $issueObj = new Issue($p_pubId, $p_lngId, $p_issNr); $data = $templateSearchService->getFrontPage($issueObj->getIssueId(), $outputService->findByName('Web')); if (empty($data)) { $data = self::GetInvalidURLTemplate($p_pubId, $p_issNr, $p_lngId); } if (CampCache::IsEnabled()) { CampCache::singleton()->store($cacheKey, $data); } return $data; }