<?php if ($f_edit_mode == "edit" && $g_user->hasPermission('plugin_debate_admin')) { ?> <a class="iframe ui-state-default icon-button right-floated" href="<?php p("/{$ADMIN}/debate/assign_popup.php?f_debate_item=article&f_language_id={$articleObj->getLanguageId()}&f_article_nr=" . $articleObj->getArticleNumber()); ?> "><span class="ui-icon ui-icon-plusthick"></span><?php putGS('Attach'); ?> </a> <div class="clear"></div> <?php } ?> <ul class="block-list"> <?php foreach (DebateArticle::getAssignments(null, $articleObj->getLanguageId(), $articleObj->getArticleNumber()) as $debateArticle) { $debate = $debateArticle->getDebate($articleObj->getLanguageId()); ?> <li><?php echo htmlspecialchars($debate->getName()), ' (', htmlspecialchars($debate->getLanguageName()), ')'; ?> </li> <?php } ?> </ul> </div>
$u++; } } ?> <script> try { window.opener.document.forms['section_edit'].onsubmit(); window.opener.document.forms['section_edit'].submit(); } catch (e) {} window.close(); </script> <?php break; case 'article': foreach ($f_debate_exists as $debate_nr => $val) { $DebateArticle = new DebateArticle($debate_nr, $f_language_id, $f_article_nr); if (array_key_exists($debate_nr, $f_debate_checked) && !$DebateArticle->exists()) { $DebateArticle->create(); $p_a++; } elseif (!array_key_exists($debate_nr, $f_debate_checked) && $DebateArticle->exists()) { $DebateArticle->delete(); $p_u++; } } ?> <script> try { //window.opener.document.forms['article_edit'].f_message.value = "<?php putGS("\$1/\$2 debates assigned/unassigned.", $p_a, $p_u); ?> ";
foreach (DebatePublication::GetAssignments(null, $f_publication_id) as $assignObj) { $assigned[$assignObj->getDebateNumber()] = true; } break; case 'issue': foreach (DebateIssue::GetAssignments(null, $f_language_id, $f_issue_nr, $f_publication_id) as $assignObj) { $assigned[$assignObj->getDebateNumber()] = true; } break; case 'section': foreach (DebateSection::GetAssignments(null, $f_language_id, $f_section_nr, $f_issue_nr, $f_publication_id) as $assignObj) { $assigned[$assignObj->getDebateNumber()] = true; } break; case 'article': foreach (DebateArticle::GetAssignments(null, $f_language_id, $f_article_nr) as $assignObj) { $assigned[$assignObj->getDebateNumber()] = true; } break; default: camp_html_display_error(getGS('Invalid input'), 'javascript: window.close()'); exit; break; } ?> <table style="margin-top: 10px; margin-left: 15px; margin-right: 15px;" cellpadding="0" cellspacing="0"> <TR> <TD style="padding: 3px; background-color: #EEE; border-top: 1px solid #8baed1; border-left: 1px solid #8baed1; border-bottom: 1px solid #8baed1;"> <B><?php putGS("Attach Debates"); ?>
/** * Gets an issue list based on the given parameters. * * @param array $p_parameters * An array of ComparisonOperation objects * @param string item * An indentifier which assignment should be used (publication/issue/section/article) * @param string $p_order * An array of columns and directions to order by * @param integer $p_start * The record number to start the list * @param integer $p_limit * The offset. How many records from $p_start will be retrieved. * * @return array $issuesList * An array of Issue objects */ public static function GetList(array $p_parameters, $p_item = null, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count) { global $g_ado_db; if (!is_array($p_parameters)) { return null; } // adodb::selectLimit() interpretes -1 as unlimited if ($p_limit == 0) { $p_limit = -1; } $selectClauseObj = new SQLSelectClause(); // sets the where conditions foreach ($p_parameters as $param) { $comparisonOperation = self::ProcessListParameters($param); if (empty($comparisonOperation)) { continue; } if (strpos($comparisonOperation['left'], '_assign_publication_id') !== false) { $assign_publication_id = $comparisonOperation['right']; } elseif (strpos($comparisonOperation['left'], '_assign_issue_nr') !== false) { $assign_issue_nr = $comparisonOperation['right']; } elseif (strpos($comparisonOperation['left'], '_assign_section_nr') !== false) { $assign_section_nr = $comparisonOperation['right']; } elseif (strpos($comparisonOperation['left'], '_assign_article_nr') !== false) { $assign_article_nr = $comparisonOperation['right']; } elseif (strpos($comparisonOperation['left'], '_current') !== false) { $whereCondition = "date_begin <= NOW()"; $selectClauseObj->addWhere($whereCondition); $whereCondition = "date_end >= NOW()"; $selectClauseObj->addWhere($whereCondition); } elseif (strpos($comparisonOperation['left'], 'language_id') !== false) { $language_id = $comparisonOperation['right']; $whereCondition = $g_ado_db->escapeOperation($comparisonOperation); $selectClauseObj->addWhere($whereCondition); } elseif (strpos($comparisonOperation['left'], 'number') !== false) { $whereCondition = $g_ado_db->escapeOperation($comparisonOperation); $selectClauseObj->addWhere($whereCondition); } else { $whereCondition = $g_ado_db->escapeOperation($comparisonOperation); $selectClauseObj->addWhere($whereCondition); } } // sets the columns to be fetched $tmpPoll = new Debate(); $columnNames = $tmpPoll->getColumnNames(true); foreach ($columnNames as $columnName) { $selectClauseObj->addColumn($columnName); } // sets the main table for the query $mainTblName = $tmpPoll->getDbTableName(); $selectClauseObj->setTable($mainTblName); unset($tmpPoll); switch ($p_item) { case 'publication': if (empty($assign_publication_id)) { return; } $tmpAssignObj = new DebatePublication(); $assignTblName = $tmpAssignObj->getDbTableName(); $join = "LEFT JOIN `{$assignTblName}` AS j\n ON\n j.fk_debate_nr = `{$mainTblName}`.debate_nr\n AND j.fk_publication_id = '{$assign_publication_id}'"; $selectClauseObj->addJoin($join); $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL'); $selectClauseObj->setDistinct('plugin_debate.debate_nr'); break; case 'issue': if (empty($assign_publication_id) || empty($assign_issue_nr)) { return; } $tmpAssignObj = new DebateIssue(); $assignTblName = $tmpAssignObj->getDbTableName(); $join = "LEFT JOIN {$assignTblName} AS j\n ON\n j.fk_debate_nr = `{$mainTblName}`.debate_nr\n AND j.fk_issue_nr = '{$assign_issue_nr}'\n AND j.fk_publication_id = '{$assign_publication_id}'"; if (isset($language_id)) { $join .= " AND j.fk_issue_language_id = '{$language_id}'"; } $selectClauseObj->addJoin($join); $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL'); $selectClauseObj->setDistinct('plugin_debate.debate_nr'); break; case 'section': if (empty($assign_publication_id) || empty($assign_issue_nr) || empty($assign_section_nr)) { return; } $tmpAssignObj = new DebateSection(); $assignTblName = $tmpAssignObj->getDbTableName(); $join = "LEFT JOIN `{$assignTblName}` AS j\n ON\n j.fk_debate_nr = `{$mainTblName}`.debate_nr\n AND j.fk_section_nr = '{$assign_section_nr}'\n AND j.fk_issue_nr = '{$assign_issue_nr}'\n AND j.fk_publication_id = '{$assign_publication_id}'"; if (isset($language_id)) { $join .= " AND j.fk_section_language_id = '{$language_id}'"; } $selectClauseObj->addJoin($join); $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL'); $selectClauseObj->setDistinct('plugin_debate.debate_nr'); break; case 'article': if (empty($assign_article_nr)) { return; } $tmpAssignObj = new DebateArticle(); $assignTblName = $tmpAssignObj->getDbTableName(); $join = "LEFT JOIN `{$assignTblName}` AS j\n ON\n j.fk_debate_nr = `{$mainTblName}`.debate_nr\n AND j.fk_article_nr = '{$assign_article_nr}'"; if (isset($language_id)) { $join .= " AND j.fk_article_language_id = '{$language_id}'"; } $selectClauseObj->addJoin($join); $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL'); $selectClauseObj->setDistinct('plugin_debate.debate_nr'); break; } if (is_array($p_order)) { $order = Debate::ProcessListOrder($p_order); // sets the order condition if any foreach ($order as $orderField => $orderDirection) { $selectClauseObj->addOrderBy($orderField . ' ' . $orderDirection); } } $sqlQuery = $selectClauseObj->buildQuery(); // count all available results $countRes = $g_ado_db->Execute($sqlQuery); if (!is_null($countRes)) { $p_count = $countRes->recordCount(); } //get the wanted rows $debateRes = $g_ado_db->SelectLimit($sqlQuery, $p_limit, $p_start); // builds the array of debate objects $debatesList = array(); while ($debate = $debateRes->FetchRow()) { $debateObj = new Debate($debate['fk_language_id'], $debate['debate_nr']); if ($debateObj->exists()) { $debatesList[] = $debateObj; } } return $debatesList; }
/** * Call this if an publication is deleted * * @param int $p_publication_id */ public static function OnArticleDelete($p_article_language_id, $p_article_nr) { foreach (DebateArticle::getAssignments(null, $p_article_language_id, $p_article_nr) as $record) { $record->delete(); } }