function displayUserList()
 {
     global $serendipity;
     $userlist = serendipity_fetchUsers();
     $content = "";
     foreach ($userlist as $user) {
         if (function_exists('serendipity_authorURL')) {
             $entryLink = serendipity_authorURL($user);
         } else {
             $entryLink = serendipity_rewriteURL(PATH_AUTHORS . '/' . serendipity_makePermalink(PERM_AUTHORS, array('id' => $user['authorid'], 'title' => $user['realname'])));
         }
         $content .= sprintf("<a href=\"%s\" title=\"%s\">%s</a><br />\n", $entryLink, function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET));
     }
     return $content;
 }
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $authors_query = "SELECT realname, username, authorid FROM {$serendipity['dbPrefix']}authors";
     $row_authors = serendipity_db_query($authors_query);
     echo '<ul class="plainList">';
     foreach ($row_authors as $entry) {
         if (function_exists('serendipity_authorURL')) {
             $entryLink = serendipity_authorURL($entry);
         } else {
             $entryLink = serendipity_rewriteURL(PATH_AUTHORS . '/' . serendipity_makePermalink(PERM_AUTHORS, array('id' => $entry['authorid'], 'title' => $entry['realname'])));
         }
         echo '<li><a href="' . $entryLink . '">' . $entry['realname'] . '</a></li>';
     }
     echo '</ul>';
 }
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $sort = $this->get_config('sort_order');
     if ($sort == 'none') {
         $sort = '';
     } else {
         $sort .= ' ' . $this->get_config('sort_method');
     }
     $is_count = serendipity_db_bool($this->get_config('showartcount'));
     $mincount = (int) $this->get_config('mincount');
     $authors = serendipity_fetchUsers(null, 'hidden', $is_count);
     $html = '';
     $image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif'));
     $image = $image == "'none'" || $image == 'none' ? '' : $image;
     $html .= '<ul class="plainList">' . "\n";
     if (is_array($authors) && count($authors)) {
         foreach ($authors as $auth) {
             if ($is_count) {
                 if ($auth['artcount'] < $mincount) {
                     continue;
                 }
                 $entrycount = " ({$auth['artcount']})";
             } else {
                 $entrycount = "";
             }
             $html .= '<li>';
             if (!empty($image)) {
                 $html .= '<a class="serendipity_xml_icon" href="' . serendipity_feedAuthorURL($auth, 'serendipityHTTPPath') . '"><img src="' . $image . '" alt="XML" style="border: 0px" /></a> ';
             }
             $html .= '<a href="' . serendipity_authorURL($auth, 'serendipityHTTPPath') . '" title="' . serendipity_specialchars($auth['realname']) . '">' . serendipity_specialchars($auth['realname']) . $entrycount . '</a>';
             $html .= '</li>' . "\n";
         }
     }
     $html .= '</ul>' . "\n";
     $html .= sprintf('<div><a href="%s" title="%s">%s</a></div>', $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'], ALL_AUTHORS, ALL_AUTHORS);
     print $html;
 }
/**
 * Passes the list of fetched entries from serendipity_fetchEntries() on to the Smarty layer
 *
 * This function contains all the core logic to group and prepare entries to be shown in your
 * $entries.tpl template. It groups them by date, so that you can easily loop on the set of
 * entries.
 * This function is not only used for printing all entries, but also for printing individual
 * entries.
 * Several central Event hooks are executed here for the whole page flow, like header+footer data.
 *
 * @see serendipity_fetchEntries()
 * @see serendipity_searchEntries()
 * @access public
 * @param   array       The array of entries with all of its data
 * @param   boolean     Toggle whether the extended portion of an entry is requested (via $serendipity['GET']['id'] single entry view)
 * @param   boolean     Indicates if this is a preview
 * @param   string      The name of the SMARTY block that this gets parsed into
 * @param   boolean     Indicates whether the assigned smarty variables should be parsed. When set to "return", no smarty parsing is done.
 * @param   boolean     Indicates whether to apply footer/header event hooks
 * @param   boolean     Indicates whether the pagination footer should be displayed
 * @param   mixed       Indicates whether the input $entries array is already grouped in preparation for the smarty $entries output array [TRUE], or if it shall be grouped by date [FALSE] or if a plugin hook shall be executed to modify data ['plugin']. This setting can also be superseded by a 'entry_display' hook.
 * @return
 */
function serendipity_printEntries($entries, $extended = 0, $preview = false, $smarty_block = 'ENTRIES', $smarty_fetch = true, $use_hooks = true, $use_footer = true, $use_grouped_array = false)
{
    global $serendipity;
    if ($use_hooks) {
        $addData = array('extended' => $extended, 'preview' => $preview);
        serendipity_plugin_api::hook_event('entry_display', $entries, $addData);
        if (isset($entries['clean_page']) && $entries['clean_page'] === true) {
            if ($serendipity['view'] == '404') {
                $serendipity['view'] = 'plugin';
            }
            $serendipity['smarty']->assign(array('plugin_clean_page' => true, 'view' => $serendipity['view']));
            serendipity_smarty_fetch($smarty_block, 'entries.tpl', true);
            return;
            // no display of this item
        }
    }
    // We shouldn't return here, because we want Smarty to handle the output
    if (!is_array($entries) || $entries[0] == false || !isset($entries[0]['timestamp'])) {
        $entries = array();
    }
    // A plugin executed in entry_display should be able to change the way of ordering entries. Forward-Thinking. ;)
    if (isset($entries['use_grouped_array'])) {
        $use_grouped_array = $entries['use_grouped_array'];
    }
    if ($use_grouped_array === false) {
        // Use grouping by date (default)
        $dategroup = array();
        for ($x = 0, $num_entries = count($entries); $x < $num_entries; $x++) {
            if (!empty($entries[$x]['properties']['ep_is_sticky']) && serendipity_db_bool($entries[$x]['properties']['ep_is_sticky'])) {
                $entries[$x]['is_sticky'] = true;
                $key = 'sticky';
            } else {
                $key = date('Ymd', serendipity_serverOffsetHour($entries[$x]['timestamp']));
            }
            $dategroup[$key]['date'] = $entries[$x]['timestamp'];
            $dategroup[$key]['is_sticky'] = isset($entries[$x]['is_sticky']) && serendipity_db_bool($entries[$x]['is_sticky']) ? true : false;
            $dategroup[$key]['entries'][] =& $entries[$x];
        }
    } elseif ($use_grouped_array === 'plugin') {
        // Let a plugin do the grouping
        serendipity_plugin_api::hook_event('entry_groupdata', $entries);
        $dategroup =& $entries;
    } else {
        $dategroup =& $entries;
    }
    foreach ($dategroup as $dategroup_idx => $properties) {
        foreach ($properties['entries'] as $x => $_entry) {
            if ($smarty_fetch === 'return') {
                $entry =& $dategroup[$dategroup_idx]['entries'][$x];
                // PHP4 Compat
            } else {
                // DISABLED - made problems with custom plugins
                // $entry = &$properties['entries'][$x]; // PHP4 Compat
                $entry =& $dategroup[$dategroup_idx]['entries'][$x];
                // PHP4 Compat
            }
            if (!empty($entry['properties']['ep_cache_body'])) {
                $entry['body'] =& $entry['properties']['ep_cache_body'];
                $entry['is_cached'] = true;
            }
            //--JAM: Highlight-span search terms
            if ($serendipity['action'] == 'search') {
                $searchterms = str_replace('"', '', $serendipity['GET']['searchterms']);
                $searchterms = explode($searchterms, ' ');
                foreach ($searchterms as $searchdx => $searchterm) {
                    $searchclass = "foundterm foundterm" . $searchdx;
                    $entry['body'] = str_replace($searchterm, '<span class="' . $searchclass . '">' . $searchterm . '</span>', $entry['body']);
                }
            }
            if (!empty($entry['properties']['ep_cache_extended'])) {
                $entry['extended'] =& $entry['properties']['ep_cache_extended'];
                $entry['is_cached'] = true;
            }
            if ($preview) {
                $entry['author'] = $entry['realname'];
                $entry['authorid'] = $serendipity['authorid'];
            }
            $addData = array('from' => 'functions_entries:printEntries');
            if ($entry['is_cached']) {
                $addData['no_scramble'] = true;
            }
            serendipity_plugin_api::hook_event('frontend_display', $entry, $addData);
            if ($preview) {
                $entry['author'] = $entry['realname'];
                $entry['authorid'] = $serendipity['authorid'];
            }
            $entry['author'] = htmlspecialchars($entry['author']);
            $authorData = array('authorid' => $entry['authorid'], 'username' => $entry['loginname'], 'email' => $entry['email'], 'realname' => $entry['author']);
            $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
            $entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false, array('timestamp' => $entry['timestamp']));
            $entry['html_title'] = $entry['title'];
            $entry['title'] = htmlspecialchars($entry['title']);
            $entry['title_rdf'] = preg_replace('@-{2,}@', '-', $entry['html_title']);
            $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title_rdf'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
            $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_' . $entry['id'] . '.rdf');
            $entry['title_rdf'] = htmlspecialchars($entry['title_rdf']);
            $entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&amp;serendipity[entry]=' . $entry['id'];
            $entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&amp;serendipity[entry]=' . $entry['id'];
            $entry['allow_comments'] = serendipity_db_bool($entry['allow_comments']);
            $entry['moderate_comments'] = serendipity_db_bool($entry['moderate_comments']);
            $entry['viewmode'] = $serendipity['GET']['cview'] == VIEWMODE_LINEAR ? VIEWMODE_LINEAR : VIEWMODE_THREADED;
            $entry['link_popup_comments'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&amp;serendipity[type]=comments';
            $entry['link_popup_trackbacks'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&amp;serendipity[type]=trackbacks';
            $entry['link_edit'] = $serendipity['baseURL'] . 'serendipity_admin.php?serendipity[action]=admin&amp;serendipity[adminModule]=entries&amp;serendipity[adminAction]=edit&amp;serendipity[id]=' . $entry['id'];
            $entry['link_trackback'] = $serendipity['baseURL'] . 'comment.php?type=trackback&amp;entry_id=' . $entry['id'];
            $entry['link_viewmode_threaded'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&amp;serendipity[cview]=' . VIEWMODE_THREADED;
            $entry['link_viewmode_linear'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&amp;serendipity[cview]=' . VIEWMODE_LINEAR;
            $entry['link_author'] = serendipity_authorURL($authorData);
            if (is_array($entry['categories'])) {
                foreach ($entry['categories'] as $k => $v) {
                    if (!isset($entry['categories'][$k]['category_link'])) {
                        $entry['categories'][$k]['category_link'] = serendipity_categoryURL($entry['categories'][$k]);
                    }
                }
            }
            if (strlen($entry['extended'])) {
                $entry['has_extended'] = true;
            }
            if (isset($entry['exflag']) && $entry['exflag'] && ($extended || $preview)) {
                $entry['is_extended'] = true;
            }
            if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0) {
                $entry['has_comments'] = true;
                $entry['label_comments'] = $entry['comments'] == 1 ? COMMENT : COMMENTS;
            }
            if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['trackbacks'] > 0) {
                $entry['has_trackbacks'] = true;
                $entry['label_trackbacks'] = $entry['trackbacks'] == 1 ? TRACKBACK : TRACKBACKS;
            }
            if ($_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityAuthorid'] == $entry['authorid'] || serendipity_checkPermission('adminEntriesMaintainOthers'))) {
                $entry['is_entry_owner'] = true;
            }
            $entry['display_dat'] = '';
            serendipity_plugin_api::hook_event('frontend_display:html:per_entry', $entry);
            $entry['plugin_display_dat'] =& $entry['display_dat'];
            if ($preview) {
                ob_start();
                serendipity_plugin_api::hook_event('backend_preview', $entry);
                $entry['backend_preview'] = ob_get_contents();
                ob_end_clean();
            }
            /* IF WE ARE DISPLAYING A FULL ENTRY */
            if (isset($serendipity['GET']['id'])) {
                $comment_add_data = array('comments_messagestack' => isset($serendipity['messagestack']['comments']) ? (array) $serendipity['messagestack']['comments'] : array(), 'is_comment_added' => isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true : false, 'is_comment_moderate' => isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'moderate' ? true : false);
                $serendipity['smarty']->assign($comment_add_data);
                serendipity_displayCommentForm($entry['id'], $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'], true, $serendipity['POST'], true, serendipity_db_bool($entry['moderate_comments']), $entry);
            }
            // END FULL ENTRY LOGIC
        }
        // end foreach-loop (entries)
    }
    // end foreach-loop (dates)
    if (!isset($serendipity['GET']['id']) && (!isset($serendipity['hidefooter']) || $serendipity['hidefooter'] == false) && $num_entries <= $serendipity['fetchLimit'] && $use_footer) {
        serendipity_printEntryFooter();
    }
    if ($smarty_fetch === 'return') {
        return $dategroup;
    }
    $serendipity['smarty']->assign_by_ref('entries', $dategroup);
    unset($entries, $dategroup);
    if (isset($serendipity['short_archives']) && $serendipity['short_archives']) {
        serendipity_smarty_fetch($smarty_block, 'entries_summary.tpl', true);
    } elseif ($smarty_fetch == true) {
        serendipity_smarty_fetch($smarty_block, 'entries.tpl', true);
    }
}
/**
 * Create a permalink for the given input data
 *
 * You can pass an entry array, or an author array to this function
 * and then get a permalink valid for that array
 *
 * @access public
 * @param   array       The input data used for building the permalink
 * @param   string      The type of the permalink (entry|category|author)
 * @return  string      The permalink
 */
function serendipity_getPermalink(&$data, $type = 'entry')
{
    switch ($type) {
        case 'entry':
            return serendipity_archiveURL($data['id'], $data['title'], '', false, array('timestamp' => $data['timestamp']));
            break;
        case 'category':
            return serendipity_categoryURL($data, '', false);
            break;
        case 'author':
            return serendipity_authorURL($data, '', false);
            break;
    }
    return false;
}
Ejemplo n.º 6
0
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $sort = $this->get_config('sort_order');
     if ($sort == 'none') {
         $sort = '';
     } else {
         $sort .= ' ' . $this->get_config('sort_method');
     }
     $is_form = serendipity_db_bool($this->get_config('allow_select'));
     $is_count = serendipity_db_bool($this->get_config('showartcount'));
     $mincount = (int) $this->get_config('mincount');
     $authors = serendipity_fetchUsers(null, null, $is_count);
     $html = '';
     if ($is_form) {
         $html .= '<form action="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?frontpage" method="post">';
     }
     $image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif'));
     $image = $image == "'none'" || $image == 'none' ? '' : $image;
     $html .= '<ul class="plainList">' . "\n";
     if (is_array($authors) && count($authors)) {
         foreach ($authors as $auth) {
             if ($is_count) {
                 if ($auth['artcount'] < $mincount) {
                     continue;
                 }
                 $entrycount = " ({$auth['artcount']})";
             } else {
                 $entrycount = "";
             }
             $html .= '<li>';
             if ($is_form) {
                 $html .= '<input style="width: 15px" type="checkbox" name="serendipity[multiAuth][]" value="' . $auth['authorid'] . '" />';
             }
             if (!empty($image)) {
                 $html .= '<a class="serendipity_xml_icon" href="' . serendipity_feedAuthorURL($auth, 'serendipityHTTPPath') . '"><img src="' . $image . '" alt="XML" style="border: 0px" /></a> ';
             }
             $html .= '<a href="' . serendipity_authorURL($auth, 'serendipityHTTPPath') . '" title="' . htmlspecialchars($auth['realname']) . '">' . htmlspecialchars($auth['realname']) . $entrycount . '</a>';
             $html .= '</li>' . "\n";
         }
     }
     $html .= '</ul>' . "\n";
     if ($is_form) {
         $html .= '<div><input type="submit" name="serendipity[isMultiAuth]" value="' . GO . '" /></div>';
     }
     $html .= sprintf('<div><a href="%s" title="%s">%s</a></div>', $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'], ALL_AUTHORS, ALL_AUTHORS);
     if ($is_form) {
         $html .= '</form>';
     }
     print $html;
 }
 function add_authors(&$sitemap_xml)
 {
     global $serendipity;
     // fetch authors and their last entry date (tested with: mysql, sqlite, postgres)
     $authors = serendipity_db_query('SELECT
                 authors.authorid as id,
                 realname,
                 username,
                 email,
                 MAX(entries.last_modified) as time
             FROM
                 ' . $serendipity['dbPrefix'] . 'authors authors,
                 ' . $serendipity['dbPrefix'] . 'entries entries
             WHERE authors.authorid = entries.authorid
             GROUP BY
                 authors.authorid,
                 authors.realname,
                 authors.username,
                 authors.email
             ORDER BY authors.authorid', false, 'assoc');
     if (is_array($authors)) {
         // add authors
         foreach ($authors as $author) {
             $max = 0 + $author['time'];
             /* v0.9 */
             if (version_compare((double) $serendipity['version'], '0.9', '>=')) {
                 $data = array('authorid' => $author['id'], 'realname' => $author['realname'], 'username' => $author['username'], 'email' => $author['email']);
                 $url = serendipity_authorURL($data);
             } else {
                 $url = serendipity_rewriteURL(PATH_AUTHORS . '/' . serendipity_makePermalink(PERM_AUTHORS, array('id' => $author['id'], 'title' => $author['realname'])));
             }
             $this->addtoxml($sitemap_xml, $url, $max, 0.2);
         }
     }
 }
 function getUser($user)
 {
     if (function_exists('serendipity_authorURL')) {
         $link = serendipity_authorURL($user, 'serendipityHTTPPath');
     } else {
         $link = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cat['categoryid'], 'title' => $cat['category_name'])), 'baseURL');
     }
     return array('link' => $link, 'title' => AUTHOR . ' ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET)));
 }
Ejemplo n.º 9
0
                /* TODO: Add username to list once tom figures out how to fix uneven rowstyles */
                ?>
        <td><img src="<?php 
                echo $img;
                ?>
" alt="" style="border: 0px none ; vertical-align: bottom; display: inline;" /> <?php 
                echo htmlspecialchars($user['realname']);
                ?>
</td>
        <td width="100" align="center"><?php 
                echo $user['userlevel'];
                ?>
</td>
        <td width="300" align="right"> 
                                       <a target="_blank" href="<?php 
                echo serendipity_authorURL($user);
                ?>
" title="<?php 
                echo PREVIEW . ' ' . $user['realname'];
                ?>
" class="serendipityIconLink">
                                        <img src="<?php 
                echo serendipity_getTemplateFile('admin/img/zoom.png');
                ?>
" alt="<?php 
                echo PREVIEW;
                ?>
" /><?php 
                echo PREVIEW;
                ?>
</a>
Ejemplo n.º 10
0
if ($serendipity['GET']['adminAction'] != 'delete') {
    $data['delete'] = false;
    if (serendipity_checkPermission('adminUsersMaintainOthers')) {
        $users = serendipity_fetchUsers('');
    } elseif (serendipity_checkPermission('adminUsersMaintainSame')) {
        $users = serendipity_fetchUsers('', serendipity_getGroups($serendipity['authorid'], true));
    } else {
        $users = serendipity_fetchUsers($serendipity['authorid']);
    }
    $data['users'] = $users;
    $data['urlFormToken'] = serendipity_setFormToken('url');
    if (is_array($users)) {
        foreach ($users as $user => $userdata) {
            if ($userdata['userlevel'] < $serendipity['serendipityUserlevel'] || $userdata['authorid'] == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) {
                $data['users'][$user]['isEditable'] = true;
                $data['users'][$user]['authorUrl'] = serendipity_authorURL($userdata);
            }
            $data['users'][$user]['userlevel_name'] = $serendipity['permissionLevels'][$userdata['userlevel']];
        }
    }
    if (!(isset($_POST['NEW']) || $serendipity['GET']['adminAction'] == 'new') && serendipity_checkPermission('adminUsersCreateNew')) {
        $data['new'] = true;
    }
}
if ($serendipity['GET']['adminAction'] == 'edit' && serendipity_checkPermission('adminUsersDelete') || (isset($_POST['NEW']) || $serendipity['GET']['adminAction'] == 'new') && serendipity_checkPermission('adminUsersCreateNew')) {
    $data['adminAction'] = $serendipity['GET']['adminAction'];
    $data['show_form'] = true;
    $data['formToken'] = serendipity_setFormToken();
    if ($serendipity['GET']['adminAction'] == 'edit') {
        $user = serendipity_fetchUsers($serendipity['GET']['userid']);
        $group_intersect = serendipity_intersectGroup($user[0]['authorid']);