Exemple #1
0
    public static function lists($mailingEdit, $list, $show, $lType, $arId, $indicate = false, $isEdit = false)
    {
        $mainframe = JFactory::getApplication();
        if (!isset($mailingEdit)) {
            $mailingEdit = new stdClass();
        }
        $listType = JRequest::getVar('listype');
        if (!isset($mailingEdit->list_type)) {
            $mySess = JFactory::getSession();
            if (!empty($mySess)) {
                $mailingEdit->list_type = $mySess->get('listype', '', 'LType');
            }
        }
        $listType = !empty($listType) ? $listType : $mailingEdit->list_type;
        $typeList = !empty($listType) && $listType == 2 ? 2 : 1;
        ?>
	<div style="padding: 2px;"><span style="font-size: 12px;"><?php 
        if ($lType != 2) {
            //echo _JNEWS_SUBS_LIST;
            //}else{
            if ($typeList == 2) {
                echo _JNEWS_SUBS_LIST_CAMPAIGN;
            } else {
                echo _JNEWS_SUBS_LIST_LABEL;
            }
            //edif
        }
        ?>
</span></div>
	<table class="<?php 
        echo jnews::myTheme();
        ?>
">
		<thead>
				<tr>
					<th class="title">
						#
					</th>
					<th class="title">
						<?php 
        echo _JNEWS_LIST_NAME;
        ?>
					</th>
					<th class="title" style="min-width:200px;">
						<?php 
        echo _JNEWS_SUBS_LIST_RECEIVE;
        ?>
					</th>
				</tr>
		</thead>
		<tbody>

		<?php 
        $my = JFactory::getUser();
        $ownedlists = 0;
        if ($GLOBALS[JNEWS . 'enable_jsub']) {
            $ownedlists = jNews_Lists::getOwnedlists($my->id);
        }
        if (jnews::checkPermissions('admin')) {
            if ($lType == 2) {
                $lists = jNews_Lists::getLists('', 1, '', '', false, true, true, false, false);
            } else {
                $lists = jNews_Lists::getLists('', $typeList, '', '', false, true, true, false, false);
            }
        } else {
            if ($lType == 2) {
                $lists = jNews_Lists::getLists('', 1, '', '', false, true, true, false, false, '', '', $ownedlists, $my->id);
            } else {
                $lists = jNews_Lists::getLists('', $typeList, '', '', false, true, true, false, false, '', '', $ownedlists, $my->id);
            }
        }
        $k = 0;
        $i = 0;
        //$listId=JRequest::getVar('listId');
        if (empty($listId)) {
            $listId = JRequest::getVar('listid');
        }
        $ls = array();
        $myKey = null;
        foreach ($lists as $key => $list) {
            if ($list->id == $listId) {
                $myKey = $key;
                break;
            }
        }
        if (isset($myKey)) {
            $ls[] = $lists[$myKey];
            unset($lists[$myKey]);
            $lists = array_merge($ls, $lists);
        }
        $listsA = array();
        if (!$mainframe->isAdmin()) {
            foreach ($lists as $list) {
                if (empty($list->params)) {
                    $listsA[] = $list;
                }
            }
        } else {
            $listsA = $lists;
        }
        foreach ($listsA as $list) {
            ?>
				<tr class="<?php 
            echo "row{$k}";
            ?>
">
					<td width="5%">
						<center>
							<?php 
            echo $i + 1;
            ?>
					 	</center>
					</td>
					<td>
						<?php 
            $getMailingId = !empty($mailingEdit->id) ? $mailingEdit->id : JRequest::getVar('mailingid');
            $result = jNews_Mailing::mailingListFound($getMailingId, $list->id);
            $result = $result ? 1 : 0;
            if ($result == 0) {
                $lstID = JRequest::getVar('listid');
                $result = $lstID == $list->id ? 1 : 0;
            }
            //check if this view will be displayed upon the creation of new list
            if ($lType == 2) {
                $result = jNews_Lists::followupListFound($arId, $list->id);
            }
            //public static function booleanlist( $name, $attribs = null, $selected = null, $yes='yes', $no='no', $id=false )
            $text = '<b>List ID: </b>' . $list->id;
            $text .= '<br/>' . str_replace(array("'", '"'), array("&#039;", '&quot;'), $list->list_desc);
            $title = str_replace(array("'", '"'), array("&#039;", '&quot;'), $list->list_name);
            //echo jNews_Tools::toolTip( $tip, '', 280, 'tooltip.png',  $title, '', 0 );
            echo JHTML::_('tooltip', $text, $title, 'tooltip.png', $title);
            ?>
					</td>
					<td  width="100px" nowrap="nowrap">
						<center>
							<?php 
            //if the listid in the request is equal to this listid the default value of the radio button should be yes
            if ($listId == $list->id) {
                echo jnews::HTML_BooleanList("aca_mailing_addto[" . $list->id . "]", 'class="inputbox"', 1, 'Yes', 'No');
            } else {
                echo jnews::HTML_BooleanList("aca_mailing_addto[" . $list->id . "]", 'class="inputbox"', $result, 'Yes', 'No');
            }
            ?>
						</center>
					</td>
				</tr>
			<?php 
            $k = 1 - $k;
            $i++;
        }
        if (count($lists > 3)) {
            ?>
				<tr>
					<td colspan="3" align="center" nowrap="nowrap">
						<script language="javascript" type="text/javascript">
							function updateStatus(statusval){
								<?php 
            foreach ($lists as $row) {
                ?>
								window.document.getElementById('aca_mailing_addto[<?php 
                echo $row->id;
                ?>
]'+statusval).checked = true;
								<?php 
            }
            ?>
							}
						</script>
						<div style="float:right; font-size: 12px;"><a title="Click to select all list" href="#" onclick="updateStatus(1);"><?php 
            echo _JNEWS_SUBS_LIST_TOALL;
            ?>
</a> | <a href="#" onclick="updateStatus(0);"><?php 
            echo _JNEWS_SUBS_LIST_TONONE;
            ?>
</a></div>
					</td>
				</tr>
			<?php 
        }
        ?>
		</tbody>
	</table>
		<?php 
    }