Textpattern | PHP Cross Reference | Content Management Systems |
Description: Generates a list of authors.
1 <?php 2 3 /* 4 * Textpattern Content Management System 5 * http://textpattern.com 6 * 7 * Copyright (C) 2016 The Textpattern Development Team 8 * 9 * This file is part of Textpattern. 10 * 11 * Textpattern is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation, version 2. 14 * 15 * Textpattern is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with Textpattern. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 /** 25 * Generates a list of authors. 26 * 27 * @since 4.6.0 28 */ 29 30 namespace Textpattern\Tag\Syntax; 31 32 class Authors 33 { 34 /** 35 * Generates a list of authors. 36 * 37 * @param array $atts 38 * @param string $thing 39 * @return string 40 */ 41 42 public static function renderAuthors($atts, $thing = null) 43 { 44 global $thisauthor, $txp_groups; 45 46 extract(lAtts(array( 47 'break' => '', 48 'class' => '', 49 'form' => '', 50 'group' => '', 51 'label' => '', 52 'labeltag' => '', 53 'limit' => '', 54 'name' => '', 55 'offset' => '', 56 'sort' => 'name ASC', 57 'wraptag' => '', 58 ), $atts)); 59 60 $sql = array("1 = 1"); 61 $sql_limit = ''; 62 $sql_sort = " ORDER BY ".doSlash($sort); 63 64 if ($name) { 65 $sql[] = "name IN (".join(', ', quote_list(do_list($name))).")"; 66 } 67 68 if ($group !== '') { 69 $privs = do_list($group); 70 $groups = array_flip($txp_groups); 71 72 foreach ($privs as &$priv) { 73 if (isset($groups[$priv])) { 74 $priv = $groups[$priv]; 75 } 76 } 77 78 $sql[] = 'convert(privs, char) in ('.join(', ', quote_list($privs)).')'; 79 } 80 81 if ($limit !== '' || $offset) { 82 $sql_limit = " LIMIT ".intval($offset).", ".($limit === '' ? PHP_INT_MAX : intval($limit)); 83 } 84 85 $rs = safe_rows_start( 86 "user_id as id, name, RealName as realname, email, privs, last_access", 87 'txp_users', 88 join(" AND ", $sql)." $sql_sort $sql_limit" 89 ); 90 91 if ($rs && numRows($rs)) { 92 $out = array(); 93 94 if ($thing === null && $form !== '') { 95 $thing = fetch_form($form); 96 } 97 98 while ($a = nextRow($rs)) { 99 $oldauthor = $thisauthor; 100 $thisauthor = $a; 101 $out[] = parse($thing); 102 $thisauthor = $oldauthor; 103 } 104 105 unset($thisauthor); 106 107 return doLabel($label, $labeltag).doWrap($out, $wraptag, $break, $class); 108 } 109 110 return ''; 111 } 112 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title