Example #1
0
            }
        }
        ?>
        <script>
        try {
        window.opener.document.forms['issue_edit'].onsubmit();
        window.opener.document.forms['issue_edit'].submit();
        } catch (e) {}
        window.close();
        </script>
        <?php
    break;

    case 'section':
        foreach ($f_poll_exists as $poll_nr => $val) {
            $PollSection = new PollSection($poll_nr, $f_language_id, $f_section_nr, $f_issue_nr, $f_publication_id);

            if (array_key_exists($poll_nr, $f_poll_checked) && !$PollSection->exists()) {
                $PollSection->create();
                $a++;
            } elseif (!array_key_exists($poll_nr, $f_poll_checked) && $PollSection->exists()) {
                $PollSection->delete();
                $u++;
            }
        }
        ?>
        <script>
        try {
        window.opener.document.forms['section_edit'].onsubmit();
        window.opener.document.forms['section_edit'].submit();
        } catch (e) {}
Example #2
0
 /**
  * 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);
         } else {
             $whereCondition = $g_ado_db->escapeOperation($comparisonOperation);
             $selectClauseObj->addWhere($whereCondition);
         }
     }
     // sets the columns to be fetched
     $tmpPoll = new Poll();
     $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 PollPublication();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN `{$assignTblName}` AS j\n                            ON\n                            j.fk_poll_nr = `{$mainTblName}`.poll_nr\n                            AND j.fk_publication_id = '{$assign_publication_id}'";
             $selectClauseObj->addJoin($join);
             $selectClauseObj->addWhere('j.fk_poll_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_poll.poll_nr');
             break;
         case 'issue':
             if (empty($assign_publication_id) || empty($assign_issue_nr)) {
                 return;
             }
             $tmpAssignObj = new PollIssue();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN {$assignTblName} AS j\n                            ON\n                            j.fk_poll_nr = `{$mainTblName}`.poll_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_poll_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_poll.poll_nr');
             break;
         case 'section':
             if (empty($assign_publication_id) || empty($assign_issue_nr) || empty($assign_section_nr)) {
                 return;
             }
             $tmpAssignObj = new PollSection();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN `{$assignTblName}` AS j\n                            ON\n                            j.fk_poll_nr = `{$mainTblName}`.poll_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_poll_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_poll.poll_nr');
             break;
         case 'article':
             if (empty($assign_article_nr)) {
                 return;
             }
             $tmpAssignObj = new PollArticle();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN `{$assignTblName}` AS j\n                            ON\n                            j.fk_poll_nr = `{$mainTblName}`.poll_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_poll_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_poll.poll_nr');
             break;
     }
     if (is_array($p_order)) {
         $order = Poll::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);
     $p_count = $countRes->recordCount();
     //get the wanted rows
     $pollRes = $g_ado_db->SelectLimit($sqlQuery, $p_limit, $p_start);
     // builds the array of poll objects
     $pollsList = array();
     while ($poll = $pollRes->FetchRow()) {
         $pollObj = new Poll($poll['fk_language_id'], $poll['poll_nr']);
         if ($pollObj->exists()) {
             $pollsList[] = $pollObj;
         }
     }
     return $pollsList;
 }
Example #3
0
 /**
  * Call this if an section is deleted
  *
  * @param int $p_fk_publication_id
  */
 public static function OnSectionDelete($p_fk_section_language_id, $p_fk_section_nr, $p_fk_issue_nr, $p_fk_publication_id)
 {      
     foreach (PollSection::getAssignments(null, $p_fk_section_language_id, $p_fk_section_nr, $p_fk_issue_nr, $p_fk_publication_id) as $record) {
         $record->delete();   
     }   
 }
Example #4
0
<?php 
camp_html_display_msgs();
$assigned = array();
switch ($f_poll_item) {
    case 'publication':
        foreach (PollPublication::GetAssignments(null, $f_publication_id) as $assignObj) {
            $assigned[$assignObj->getPollNumber()] = true;
        }
        break;
    case 'issue':
        foreach (PollIssue::GetAssignments(null, $f_language_id, $f_issue_nr, $f_publication_id) as $assignObj) {
            $assigned[$assignObj->getPollNumber()] = true;
        }
        break;
    case 'section':
        foreach (PollSection::GetAssignments(null, $f_language_id, $f_section_nr, $f_issue_nr, $f_publication_id) as $assignObj) {
            $assigned[$assignObj->getPollNumber()] = true;
        }
        break;
    case 'article':
        foreach (PollArticle::GetAssignments(null, $f_language_id, $f_article_nr) as $assignObj) {
            $assigned[$assignObj->getPollNumber()] = 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">
Example #5
0
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="6" CLASS="table_input" width="806">
<TR>
	<TD>
		<B><?php  putGS("Polls"); ?></B>
	</TD>
    <?php if ($g_user->hasPermission('plugin_poll')) {  ?>
    	<TD align="right">
    		<IMG src="<?php p($Campsite["ADMIN_IMAGE_BASE_URL"]);?>/configure.png" border="0">
    		<A href="javascript: void(0);" onclick="window.open('<?php p("/$ADMIN/poll/assign_popup.php?f_poll_item=section&amp;f_section_nr=$section_nr&amp;f_language_id=$section_language_id&amp;f_issue_nr=$issue_nr&amp;f_publication_id=$publication_id"); ?>', 'assign_poll', 'scrollbars=yes, resizable=yes, menubar=no, toolbar=no, width=800, height=600, top=200, left=100');"><?php putGS("Edit"); ?></A>
    	</TD>
    <?php } ?>
</TR>
<TR>
	<TD colspan="2">
		<HR NOSHADE SIZE="1" COLOR="BLACK">
	</TD>
</TR>
<TR>
    <TD>
    	<div style="overflow: auto; max-height: 50px">  
        <?php
        foreach (PollSection::getAssignments(null, $section_language_id, $section_nr, $issue_nr, $publication_id) as $pollIssue) {
            $poll = $pollIssue->getPoll($section_language_id);	
            p($poll->getName());
    		p("&nbsp;({$poll->getLanguageName()})<br>");
    	} 
    	?>
    	</div>
    </TD>
</TR>
</TABLE>