/**
  * Creates the list of objects. Sets the parameter $p_hasNextElements to
  * true if this list is limited and elements still exist in the original
  * list (from which this was truncated) after the last element of this
  * list.
  *
  * @param int $p_start
  * @param int $p_limit
  * @param bool $p_hasNextElements
  * @return array
  */
 protected function CreateList($p_start = 0, $p_limit = 0, array $p_parameters, &$p_count)
 {
     $operator = new Operator('is');
     $context = CampTemplate::singleton()->context();
     $comparisonOperation = new ComparisonOperation('debate_nr', $operator, $context->debate->number);
     $this->m_constraints[] = $comparisonOperation;
     $comparisonOperation = new ComparisonOperation('debateanswer_nr', $operator, $context->debateanswer->number);
     $this->m_constraints[] = $comparisonOperation;
     $debateAnswerAttachmentsList = DebateAnswerAttachment::GetList($this->m_constraints, $this->m_order, $p_start, $p_limit, $p_count);
     $metaDebateAnswerAttachmentsList = array();
     foreach ($debateAnswerAttachmentsList as $debateAnswerAttachment) {
         $metaDebateAnswerAttachmentsList[] = new MetaAttachment($debateAnswerAttachment->getAttachmentId());
     }
     return $metaDebateAnswerAttachmentsList;
 }
 /**
  * Gets an issue list based on the given parameters.
  *
  * @param array $p_parameters
  *    An array of ComparisonOperation objects
  * @param string $p_order
  *    An array of columns and directions to order by
  * @param integer $p_count
  *    The count of answers.
  *
  * @return array $debateAnswerAttachmentsList
  *    An array of Attachment objects
  */
 public static function GetList(array $p_parameters, $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;
     }
     // sets the where conditions
     foreach ($p_parameters as $param) {
         $comparisonOperation = self::ProcessListParameters($param);
         if (empty($comparisonOperation)) {
             continue;
         }
         if (strpos($comparisonOperation['left'], 'debate_nr') !== false) {
             $debate_nr = $comparisonOperation['right'];
         }
         if (strpos($comparisonOperation['left'], 'debateanswer_nr') !== false) {
             $debateanswer_nr = $comparisonOperation['right'];
         }
     }
     $sqlClauseObj = new SQLSelectClause();
     // sets the columns to be fetched
     $tmpDebateAnswerAttachment = new DebateAnswerAttachment($language_id, $debate_nr);
     $columnNames = $tmpDebateAnswerAttachment->getColumnNames(true);
     foreach ($columnNames as $columnName) {
         $sqlClauseObj->addColumn($columnName);
     }
     // sets the main table for the query
     $mainTblName = $tmpDebateAnswerAttachment->getDbTableName();
     $sqlClauseObj->setTable($mainTblName);
     unset($tmpDebateAnswerAttachment);
     if (empty($debateanswer_nr) || empty($debate_nr)) {
         return;
     }
     $sqlClauseObj->addWhere("fk_debate_nr = " . $g_ado_db->escape($debate_nr));
     $sqlClauseObj->addWhere("fk_debateanswer_nr = " . $g_ado_db->escape($debateanswer_nr));
     if (!is_array($p_order)) {
         $p_order = array();
     }
     // sets the ORDER BY condition
     $p_order = count($p_order) > 0 ? $p_order : self::$s_defaultOrder;
     $order = self::ProcessListOrder($p_order);
     foreach ($order as $orderColumn => $orderDirection) {
         $sqlClauseObj->addOrderBy($orderColumn . ' ' . $orderDirection);
     }
     $sqlQuery = $sqlClauseObj->buildQuery();
     // count all available results
     $countRes = $g_ado_db->Execute($sqlQuery);
     $p_count = $countRes->recordCount();
     //get the wanted rows
     $debateAnswerAttachments = $g_ado_db->Execute($sqlQuery);
     // builds the array of debate objects
     $debateAnswerAttachmentsList = array();
     while ($debateAnswerAttachment = $debateAnswerAttachments->FetchRow()) {
         $debateAnswerAttachment = new Attachment($debateAnswerAttachment['fk_attachment_id']);
         if ($debateAnswerAttachment->exists()) {
             $debateAnswerAttachmentsList[] = $debateAnswerAttachment;
         }
     }
     return $debateAnswerAttachmentsList;
 }
Example #3
0
<?php

$DebateAnswerAttachments = DebateAnswerAttachment::getDebateAnswerAttachments($f_debate_nr, $f_debateanswer_nr);
?>
<center>
<TABLE width="95%" style="border: 1px solid #EEEEEE;">
<TR>
	<TD>
		<TABLE width="100%" bgcolor="#EEEEEE" cellpadding="3" cellspacing="0">
		<TR>
			<TD align="left">
			<STRONG><?php 
putGS("Files");
?>
</STRONG>
			</TD>
			<?php 
if (isset($f_edit_mode) && $f_edit_mode == "edit" && $g_user->hasPermission('AddFile')) {
    ?>
			<TD align="right">
				<IMG src="<?php 
    p($Campsite["ADMIN_IMAGE_BASE_URL"]);
    ?>
/add.png" border="0">
				<A href="javascript: void(0);" onclick="window.open('<?php 
    echo camp_html_article_url($articleObj, $f_language_id, "files/popup.php");
    ?>
', 'attach_file', 'scrollbars=yes, resizable=yes, menubar=no, toolbar=no, width=500, height=400, top=200, left=100');"><?php 
    putGS("Attach");
    ?>
</A>
Example #4
0
$f_debate_nr = Input::Get('f_debate_nr', 'int', 0);
$f_debateanswer_nr = Input::Get('f_debateanswer_nr', 'int', 0);
$f_fk_language_id = Input::Get('f_fk_language_id', 'int', 0);
$f_attachment_id = Input::Get('f_attachment_id', 'int', 0);
$attachmentObj = new Attachment($f_attachment_id);
if (!$attachmentObj->exists()) {
    camp_html_display_error(getGS('Attachment does not exist.'), null, true);
    exit;
}
$filePath = dirname($attachmentObj->getStorageLocation()) . '/' . $attachmentObj->getFileName();
if (!is_writable(dirname($filePath))) {
    camp_html_add_msg(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $filePath, basename($attachmentObj->getStorageLocation())));
    //camp_html_goto_page(camp_html_article_url($articleObj, $f_language_id, 'edit.php'));
    exit;
}
$DebateAnswerAttachment = new DebateAnswerAttachment($f_debate_nr, $f_debateanswer_nr, $f_attachment_id);
$DebateAnswerAttachment->delete();
// Go back to upload screen.
camp_html_add_msg(getGS("File '\$1' deleted.", $attachmentObj->getFileName()), "ok");
$attachmentObj->delete();
?>
<script>
location.href="popup.php?f_debate_nr=<?php 
p($f_debate_nr);
?>
&f_debateanswer_nr=<?php 
p($f_debateanswer_nr);
?>
&f_fk_language_id=<?php 
p($f_fk_language_id);
?>
Example #5
0
    $attributes['fk_language_id'] = @$f_language_id;
}
if ($f_content_disposition == "attachment") {
    $attributes['content_disposition'] = "attachment";
}
if (!empty($_FILES['f_file'])) {
    $file = Attachment::OnFileUpload($_FILES['f_file'], $attributes);
} else {
    camp_html_goto_page(camp_html_article_url($articleObj, @$f_language_id, 'files/popup.php'));
}
// Check if image was added successfully
if (PEAR::isError($file)) {
    camp_html_add_msg($file->getMessage());
    camp_html_goto_page($BackLink);
}
$DebateAnswerAttachment = new DebateAnswerAttachment($f_debate_nr, $f_debateanswer_nr, $file->getAttachmentId());
$DebateAnswerAttachment->create();
// Go back to upload screen.
camp_html_add_msg(getGS("File '\$1' added.", $file->getFileName()), "ok");
?>
<script>
location.href="popup.php?f_debate_nr=<?php 
p($f_debate_nr);
?>
&f_debateanswer_nr=<?php 
p($f_debateanswer_nr);
?>
&f_fk_language_id=<?php 
p($f_fk_language_id);
?>
";
Example #6
0
 /**
  * Delete debate from database.  This will
  * only delete one specific translation of the debate question.
  *
  * @return boolean
  */
 function delete()
 {
     // Delte DebateAnswerAttachments
     DebateAnswerAttachment::OnDebateAnswerDelete($this->getDebateNumber(), $this->getNumber());
     // Delete from plugin_debate_answer table
     $deleted = parent::delete();
     /*
     if ($deleted) {
         if (function_exists("camp_load_translation_strings")) {
             camp_load_translation_strings("api");
         }
         $logtext = getGS('Article #$1: "$2" ($3) deleted.',
             $this->m_data['Number'], $this->m_data['Name'],    $this->getLanguageName())
             ." (".getGS("Publication")." ".$this->m_data['IdPublication'].", "
             ." ".getGS("Issue")." ".$this->m_data['NrIssue'].", "
             ." ".getGS("Section")." ".$this->m_data['NrSection'].")";
         Log::Message($logtext, null, 32);
     }
     */
     $CampCache = CampCache::singleton();
     $CampCache->clear('user');
     return $deleted;
 }