Ejemplo n.º 1
0
/**
* Send an email notification for a new submission.
*
* @param    string  $table  Table where the new submission can be found
* @param    string  $story  Story object that was submitted.
*
*/
function sendNotification($table, $story)
{
    global $_CONF, $_TABLES, $LANG01, $LANG08, $LANG24, $LANG29, $LANG_ADMIN;
    $title = COM_undoSpecialChars($story->displayElements('title'));
    $introtext = COM_undoSpecialChars($story->displayElements('introtext') . "\n" . $story->displayElements('bodytext'));
    if ($story->_postmode === 'html') {
        $introtext = strip_tags($introtext);
    } else {
        $introtext = str_replace('<br' . XHTML . '>', "\n", $introtext);
    }
    $storyauthor = COM_getDisplayName($story->displayelements('uid'));
    $topic = TOPIC_getTopicAdminColumn('article', $story->getSid());
    $mailbody = "{$LANG08['31']}: {$title}\n" . "{$LANG24['7']}: {$storyauthor}\n" . "{$LANG08['32']}: " . strftime($_CONF['date']) . "\n" . "{$LANG_ADMIN['topic']}: {$topic}\n\n";
    if ($_CONF['emailstorieslength'] > 0) {
        if ($_CONF['emailstorieslength'] > 1) {
            $introtext = MBYTE_substr($introtext, 0, $_CONF['emailstorieslength']) . '...';
        }
        $mailbody .= $introtext . "\n\n";
    }
    if ($table == $_TABLES['storysubmission']) {
        $mailbody .= "{$LANG01['10']} <{$_CONF['site_admin_url']}/moderation.php>\n\n";
    } else {
        $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid());
        $mailbody .= $LANG08[33] . ' <' . $articleUrl . ">\n\n";
    }
    $mailsubject = $_CONF['site_name'] . ' ' . $LANG29[35];
    $mailbody .= "\n------------------------------\n";
    $mailbody .= "\n{$LANG08['34']}\n";
    $mailbody .= "\n------------------------------\n";
    COM_mail($_CONF['site_mail'], $mailsubject, $mailbody);
}
Ejemplo n.º 2
0
/**
 * used for the lists of submissions and draft stories in admin/moderation.php
 *
 * @param  string $fieldName
 * @param  string $fieldValue
 * @param  array  $A
 * @param  array  $icon_arr
 * @return string
 */
function ADMIN_getListField_moderation($fieldName, $fieldValue, $A, $icon_arr)
{
    global $_CONF, $_TABLES, $LANG_ADMIN;
    $type = '';
    if (isset($A['_moderation_type'])) {
        $type = $A['_moderation_type'];
    }
    switch ($fieldName) {
        case 'edit':
            $retval = COM_createLink($icon_arr['edit'], $A['edit']);
            break;
        case 'delete':
            $retval = "<input type=\"radio\" name=\"action[{$A['row']}]\" value=\"delete\"" . XHTML . ">";
            break;
        case 'approve':
            $retval = "<input type=\"radio\" name=\"action[{$A['row']}]\" value=\"approve\"" . XHTML . ">" . "<input type=\"hidden\" name=\"id[{$A['row']}]\" value=\"{$A[0]}\"" . XHTML . ">";
            break;
        case 'day':
            $retval = strftime($_CONF['daytime'], $A['day']);
            break;
        case 'tid':
            $retval = DB_getItem($_TABLES['topics'], 'topic', "tid = '{$A['tid']}'");
            break;
        case 'uid':
            $name = '';
            if ($A['uid'] == 1) {
                $name = htmlspecialchars(COM_stripslashes(DB_getItem($_TABLES['commentsubmissions'], 'name', "cid = '{$A['id']}'")));
            }
            if (empty($name)) {
                $name = COM_getDisplayName($A['uid']);
            }
            if ($A['uid'] == 1) {
                $retval = $name;
            } else {
                $retval = COM_createLink($name, $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['uid']);
            }
            break;
        case 'publishfuture':
            if (!SEC_inGroup('Comment Submitters', $A['uid']) && $A['uid'] > 1) {
                $retval = "<input type=\"checkbox\" name=\"publishfuture[]\" value=\"{$A['uid']}\"" . XHTML . ">";
            } else {
                $retval = $LANG_ADMIN['na'];
            }
            break;
        default:
            if ($fieldName == 4 && ($type === 'story' || $type === 'story_draft')) {
                $retval = TOPIC_getTopicAdminColumn('article', $A[0]);
            } elseif ($fieldName == 2 && $type === 'comment') {
                $commentText = COM_getTextContent($A['comment']);
                $excerpt = htmlspecialchars(COM_truncate($commentText, 140, '...'));
                // try to provide a link to the parent item (e.g. article, poll)
                $info = PLG_getItemInfo($A['type'], $A['sid'], 'title,url');
                if (empty($info) || empty($info[0]) || empty($info[1])) {
                    // if not available, display excerpt from the comment
                    $retval = htmlspecialchars(COM_truncate($commentText, 40, '...'));
                    if (strlen($commentText) > 40) {
                        $retval = '<span title="' . $excerpt . '">' . $retval . '</span>';
                    }
                } else {
                    $retval = COM_createLink($info[0], $info[1], array('title' => $excerpt));
                }
            } else {
                $retval = COM_makeClickableLinks(stripslashes($fieldValue));
            }
            break;
    }
    return $retval;
}