Пример #1
0
function installPlugin()
{
    $database = JFactory::getDBO();
    $return = '<b>' . _JNEWS_INSTALL_PLUGIN . '</b> : ';
    $error = '';
    $files = array('jnews_cb.php', 'jnews_cb.xml', 'index.html');
    if (!is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . 'jnews_cb.php')) {
        @mkdir(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755);
        @chmod(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755);
    }
    foreach ($files as $file) {
        if (is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . $file)) {
            @unlink(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/' . $file);
        } else {
            if (!@rename(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/' . $file, JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . $file)) {
                $error .= '<br /> Error copying plugin file ' . $file . ' to CB plugin directory.';
            }
        }
        //endelseif
    }
    if (is_file(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin' . DS . 'jnews_cb.php')) {
        @chmod(JNEWS_JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'plugin' . DS . 'user' . DS . 'plug_jnewscbplugin', 0755);
    }
    if (!@rmdir(JNEWSPATH_ADMIN . 'extensions' . DS . 'cbplugin/')) {
        $error .= '<br /> Error deleting the temporary cbplugin directory.';
    }
    $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_jnewscbplugin' ";
    $database->setQuery($query);
    $database->query();
    $id = $database->loadResult();
    $mysqlerror = $database->getErrorMsg();
    if (!empty($mysqlerror)) {
        $error .= '<br />Error getting plugin information from cb plugin table. Database error: <br />' . $mysqlerror . '';
    } else {
        if ($id < 1) {
            $row->name = 'jNews CB Plugin';
            $row->element = 'jnews_cb';
            $row->type = 'user';
            $row->folder = 'plug_jnewscbplugin';
            $row->ordering = '99';
            $query = "INSERT INTO `#__comprofiler_plugin` (`name` , `element`, `type`, `ordering`, `folder`) VALUES ( " . "'{$row->name}', " . "'{$row->element}', " . "'{$row->type}', " . "'{$row->ordering}', " . " '{$row->folder}' ) ";
            $database->setQuery($query);
            $database->query();
            $error .= $database->getErrorMsg();
            if (!empty($error)) {
                $error .= '<br />Error adding plug information to CB plug table.';
            }
            $query = "SELECT `id` FROM `#__comprofiler_plugin` WHERE `folder` = 'plug_jnewscbplugin' ";
            $database->setQuery($query);
            $database->query();
            $id = $database->loadResult();
            $error .= $database->getErrorMsg();
            $row = '';
            $row->title = 'Mailing Lists';
            $row->description = 'Listing of all the mailing lists for jNews';
            $row->ordering = '99';
            $row->width = '.5';
            $row->enabled = '0';
            $row->pluginclass = 'getjNewsTab';
            $row->pluginid = $id;
            $row->sys = '0';
            $row->params = 'NULL';
            $row->displaytype = 'tab';
            $row->position = 'cb_tabmain';
            $query = "INSERT INTO `#__comprofiler_tabs` (`title` , `description`, `ordering`, `width`, `enabled`, " . " `pluginclass` , `pluginid`, `sys`, `displaytype`, `params` , `position` ) VALUES ( " . "'{$row->title}', " . "'{$row->description}', " . "'{$row->ordering}', " . "'{$row->width}', " . "'{$row->enabled}', " . "'{$row->pluginclass}', " . "'{$row->pluginid}', " . "'{$row->sys}', " . "'{$row->displaytype}', " . "'{$row->params}', " . "'{$row->position}' ) ";
            $database->setQuery($query);
            $database->query();
            $error .= $database->getErrorMsg();
            if (!empty($error)) {
                $error .= '<br />Error adding plug information to CB tab table.';
            }
        }
    }
    //endelse
    if (empty($error)) {
        $xf = new jNews_Config();
        $xf->update('cb_pluginInstalled', '1');
        //$return .= jnews::M('green' , _JNEWS_INSTALL_SUCCESS,false) .'<br />';
        jnews::displayInfo(_JNEWS_INSTALL_SUCCESS, 'success');
    } else {
        //$return .= $error.jnews::M('red' , _JNEWS_INSTALL_ERROR,false) .'<br />';
        jnews::displayInfo($error, 'error');
    }
    //return $return;
}
Пример #2
0
    /**
     * This public static function is used for the view of sendReady for manual sending
     */
    public static function sendReady($mailingId, $listId, $listType)
    {
        ?>
		<div id="manualsend"></div>
		<?php 
        JHTML::_('behavior.modal');
        $formLink3 = jNews_Tools::completeLink('option=' . JNEWS_OPTION . '&act=mailing&task=send', true, false, true);
        ?>
		<form class="modal" action="<?php 
        echo $formLink3;
        ?>
" method="post" name="adminForm" autocomplete="off" id="adminForm">
			<div>
			<fieldset class="adminform">
			<legend>
				<?php 
        echo 'Sending Status';
        ?>
			</legend>
			<?php 
        $doc = JFactory::getDocument();
        $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css');
        if (empty($mailingId) || $mailingId == 0) {
            $warning = 'Please select a newsletter to be sent.';
            jnews::displayInfo($warning, 'warning');
            return;
        }
        $queueCount = jNews_Queue::getQueueCount($mailingId);
        $new = false;
        $mailing = jNews_Mailing::getOneMailing('', $mailingId, '', $new);
        if (empty($queueCount)) {
            if (empty($listId)) {
                $listIds = jNews_Mailing::getMailingList($mailingId);
            }
            if (!empty($listIds)) {
                ?>
			<br/>
			<fieldset class="adminform">
			<legend>
				<?php 
                echo $mailing->subject . ' will be sent to ';
                ?>
			</legend>
			<br/>
				<table class="adminlist" cellspacing="1" align="center">
					<tbody>
						<?php 
                $listNames = jNews_Mailing::getMailingListName($listIds);
                foreach ($listNames as $key => $listName) {
                    if (isset($listIds[$key])) {
                        ?>
									<tr><td><?php 
                        echo $listName . ' ( ' . jNews_Subscribers::getSubscribersCount($listIds[$key], true, true, true) . ' subscribers ) ';
                        ?>
</td></tr>
								<?php 
                    }
                }
                ?>
					</tbody>
				</table>
				<br/>
			</fieldset>
			<?php 
            } else {
                $warning = $mailing->subject . ' will be sent to none of the created Lists.';
                jnews::displayInfo($warning, 'warning');
            }
        } else {
            $info = 'There are ' . $queueCount . ' in the queue for the Newsletter ' . $mailing->subject . ' <br/>Do you want to continue sending this newsletter?';
            jnews::displayInfo($info, 'info');
            ?>
<input type="hidden" name="totalsend" value="<?php 
            echo $queueCount;
            ?>
" />
			<?php 
        }
        ?>
			<br/>
			<input type="submit" value="<?php 
        echo empty($queueCount) ? _JNEWS_MENU_SEND : _JNEWS_MENU_CONTINUE;
        ?>
">
			<input type="hidden" name="mailingid" value="<?php 
        echo $mailingId;
        ?>
" />
			<input type="hidden" name="option" value="<?php 
        echo JNEWS_OPTION;
        ?>
" />
			<input type="hidden" name="task" value="<?php 
        echo empty($queueCount) ? 'send' : 'continuesend';
        ?>
" />
			<input type="hidden" name="act" value="mailing" />
		<?php 
        if (version_compare(JVERSION, '3.0.0', '<')) {
            echo JHTML::_('form.token');
        } else {
            echo JHtml::_('form.token');
        }
        ?>
		</div>
		</form>
		<?php 
    }
Пример #3
0
    /**
     * This public static function is used to process the queue manually
     */
    public static function processQueueHTML($queuedMails = null, $nextQueuedMails = null, $scheduledMails = null, $mailingid = null, $sendButton = false, $SmartNewsMessageHTML = '')
    {
        $doc = JFactory::getDocument();
        $doc->addStyleSheet(JNEWS_URL_ADMIN . 'cssadmin/jnews.css');
        ?>
		<form action="<?php 
        echo jNews_Tools::completeLink('option=' . JNEWS_OPTION, true, false, true);
        ?>
" method="post" name="adminForm" autocomplete="off" id="adminForm">
		<div><fieldset class="adminform">
		<legend><?php 
        echo _JNEWS_QUEUE_STATUSSEND;
        ?>
</legend>
		<?php 
        if (empty($queuedMails) && empty($nextQueuedMails) && empty($scheduledMails)) {
            jnews::displayInfo(_JNEWS_QUEUE_EMPTYINFO, 'info');
        }
        if (!empty($queuedMails)) {
            ?>
		<fieldset class="adminform">
			<legend><?php 
            echo _JNEWS_QUEUE_READYTOSEND;
            ?>
</legend>
			<table class="adminlist" cellspacing="1" align="center">
			<tbody>
			<?php 
            $k = 0;
            $total = 0;
            foreach ($queuedMails as $key => $queuedMail) {
                $total += $queuedMail->totalSubs;
                ?>
					<tr class="<?php 
                echo "row{$k}";
                ?>
">
						<td>
							<?php 
                echo '<strong><i>' . $queuedMail->subject . '</i></strong> ' . _JNEWS_NEWSLETTER_BE_READY_SENT . ' <strong><i>' . $queuedMail->totalSubs . ' ' . _JNEWS_NEWSLETTER_BE_SUBCRIBERS . '</i></strong>';
                ?>
						</td>
					</tr>
					<?php 
                $k = 1 - $k;
            }
            ?>
				</tbody>
			</table>
			<br/>
			<input type="hidden" name="totalsend" value="<?php 
            echo $total;
            ?>
" />
			<input type="submit" onclick="document.adminForm.task.value = 'continuesend';" value="<?php 
            echo _JNEWS_MENU_SEND;
            ?>
">
		</fieldset>
		<?php 
        }
        if (!empty($scheduledMails)) {
            $sendButton = true;
            ?>
		<fieldset class="adminform">
			<legend><?php 
            echo _JNEWS_QUEUE_SCHEDULED;
            ?>
</legend>
			<table class="adminlist" cellspacing="1" align="center">
			<tbody>
			<?php 
            $k = 0;
            $mailingids = array();
            foreach ($scheduledMails as $scheduledMail) {
                if ($scheduledMail->send_date < time()) {
                    $sendButton = true;
                }
                ?>
					<tr class="<?php 
                echo "row{$k}";
                ?>
">
						<td>
							<?php 
                echo '<strong><i>' . $scheduledMail->subject . '</i></strong> will be processed after <strong><i>' . date('D, d M Y H:i:s', jnews::getNow(0, true, $scheduledMail->send_date)) . '</i></strong>';
                ?>
						</td>
					</tr>
					<?php 
                $k = 1 - $k;
                $mailingids[] = $scheduledMail->id;
            }
            ?>
				</tbody>
			</table>
			<?php 
            if ($sendButton) {
                ?>
<br/><input onclick="document.adminForm.task.value = 'generate';" type="submit" value="<?php 
                echo 'Generate';
                ?>
"><?php 
            }
            ?>
		</fieldset>
	<?php 
        }
        if (!empty($nextQueuedMails)) {
            ?>

		<fieldset class="adminform">
			<legend><?php 
            echo _JNEWS_QUEUE_SCHEDULED . ' ' . date('D, d M Y H:i:s', jnews::getNow(0, true));
            ?>
</legend>
			<table class="adminlist" cellspacing="1" align="center">
			<tbody>
			<?php 
            $k = 0;
            foreach ($nextQueuedMails as $mailingid => $nextQueuedMail) {
                ?>
					<tr class="<?php 
                echo "row{$k}";
                ?>
">
						<td>
							<?php 
                echo '<strong><i>' . $nextQueuedMail->subject . '</i></strong> ' . _JNEWS_NEWSLETTER_BE_SENT;
                echo ' <strong><i>' . $nextQueuedMail->totalSubs . ' ' . _JNEWS_NEWSLETTER_BE_SUBCRIBERS . '</i></strong>';
                echo '<br/>';
                echo JText::sprintf(_JNEWS_NEWSLETTER_BE_NEXT, date('D, d M Y H:i:s', jnews::getNow(0, true, $nextQueuedMail->send_date)));
                ?>
						</td>
					</tr>
					<?php 
                $k = 1 - $k;
            }
            ?>
				</tbody>
			</table>
		</fieldset>
	<?php 
        }
        if (!empty($SmartNewsMessageHTML)) {
            ?>
		<fieldset class="adminform">
			<legend><?php 
            echo 'Smart-Newsletter Status';
            ?>
</legend>
			<table class="adminlist" cellspacing="1" align="center">
			<tbody>
					<tr class="<?php 
            echo "row0";
            ?>
">
						<td>
							<?php 
            echo $SmartNewsMessageHTML;
            ?>
						</td>
					</tr>
				</tbody>
			</table>
			<br/>
		</fieldset>
		<?php 
        }
        ?>
	</fieldset>
	</div>
	<div class="clr"></div>
	<input type="hidden" name="mailingid" value="<?php 
        echo $mailingid;
        ?>
" />
	<input type="hidden" name="option" value="<?php 
        echo JNEWS_OPTION;
        ?>
" />
	<input type="hidden" name="task" value="continuesend" />
	<input type="hidden" name="act" value="mailing" />
<?php 
        if (version_compare(JVERSION, '3.0.0', '<')) {
            echo JHTML::_('form.token');
        } else {
            echo JHtml::_('form.token');
        }
        ?>
</form>
<?php 
    }