예제 #1
0
    public function getContent()
    {
        global $sql;
        $pager = new Pager('users', Kio::getStat('total', 'users'), Kio::getConfig('limit', 'users'));
        $pager->sort(array(t('Nickname') => 'nickname', t('Group') => 'g_name', t('Gender') => 'gender', t('Title') => 'title', t('Location') => 'locality', t('Country') => 'country', t('Registered') => 'registered'), 'registered', 'asc');
        $query = $sql->query('
			SELECT id, name, inline, members
			FROM ' . DB_PREFIX . 'groups
			ORDER BY display_order');
        while ($row = $query->fetch()) {
            if ($row['inline']) {
                $row['name'] = sprintf($row['inline'], $row['name']);
            }
            $groups[] = $row;
        }
        $query = $sql->query('
			SELECT u.id, u.nickname, u.email, u.registered, u.group_id, u.gender, u.locality, u.country, u.communicator, u.title, g.name g_name
			FROM ' . DB_PREFIX . 'users u
			LEFT JOIN ' . DB_PREFIX . 'groups g ON g.id = u.group_id
			ORDER BY ' . $pager->orderBy . '
			LIMIT ' . $pager->limit . '
			OFFSET ' . $pager->offset);
        while ($row = $query->fetch()) {
            $row['nickname'] = User::format($row['id'], $row['nickname'], $row['group_id']);
            switch ($row['gender']) {
                case 1:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/male.png" alt="' . t('Male') . '" title="' . t('Male') . '" />';
                    break;
                case 2:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/female.png" alt="' . t('Female') . '" title="' . t('Female') . '" />';
                    break;
                default:
                    $row['gender'] = '';
            }
            $users[] = $row;
        }
        try {
            $tpl = new PHPTAL('modules/users/users.tpl.html');
            $tpl->sort = $pager->sorters;
            $tpl->users = $users;
            $tpl->groups = $groups;
            $tpl->pagination = $pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
예제 #2
0
<?php

// KioCMS - Kiofol Content Managment System
// modules/news/admin/categories.php
$total_categories = current($sql->query('SELECT COUNT(id) AS categories FROM ' . DB_PREFIX . 'news_categories')->fetch());
if ($total_categories) {
    $pager = new Pager('admin/modules/news/categories', $total_categories);
    $pager->limit();
    $pager->sort(array($lang2['ID'] => 'id', $lang2['CATEGORY_NAME'] => 'name', $lang2['DESCRIPTION'] => 'description', $lang2['TOTAL_ENTRIES'] => 'entries'), 'id', 'desc');
    $query = $sql->query('
		SELECT *
		FROM ' . DB_PREFIX . 'news_categories
		ORDER BY ' . $pager->order . '
		LIMIT ' . $pager->limit . '
		OFFSET ' . $pager->offset);
    while ($row = $query->fetch()) {
        $categories[] = $row;
    }
    $tpl = new PHPTAL('modules/news/admin/categories.html');
    $tpl->system = $system;
    $tpl->total_categories = $total_categories;
    $tpl->sorters = $pager->sorters;
    $tpl->limit_form = $pager->limit_form;
    $tpl->categories = $categories;
    $tpl->lang_admin = $lang_admin;
    $tpl->lang_system = $lang_system;
    $tpl->pagination = $pager->paginate();
    echo $tpl->execute();
} else {
    echo $lang[14];
}
예제 #3
0
파일: box.php 프로젝트: rafalenden/KioCMS
<?php

// KioCMS - Kiofol Content Managment System
// modules/pm/box.php
$kio->addPath(t(ucfirst(u1)), 'pm/' . u1);
$module->subcodename = 'box';
$pager = new Pager('pm/' . u1, $user->{'pm_' . u1}, $cfg->pm['limit']);
$pager->sort(array(t('Subject') => 'subject', t('Message') => 'message', u1 == 'outbox' ? t('To') : t('From') => 'nickname', t('Sent') => 'sent'), 'sent', 'asc');
// Reset new messages counter
if ($user->pm_new) {
    $sql->exec('UPDATE ' . DB_PREFIX . 'users SET pm_new = 0 WHERE id = ' . $user->id);
}
switch ($_POST['action']) {
    // Delete messages
    case 'delete':
        $delete = true;
        break;
        // Mark messages as read
    // Mark messages as read
    case 'read':
        $set = 'is_read = 1';
        break;
        // Mark messages as unread
    // Mark messages as unread
    case 'unread':
        $set = 'is_read = 0';
}
if ($set || $delete && is_array($_POST['messages'])) {
    if ($set) {
        $sql->exec('UPDATE ' . DB_PREFIX . 'pm SET ' . $set);
    } else {
예제 #4
0
    private function getFolder($folder_id)
    {
        global $sql;
        Kio::addTitle(t(ucfirst(u1)));
        Kio::addBreadcrumb(t(ucfirst(u1)), 'pm/' . u1);
        $note = new Notifier();
        $this->subcodename = 'box';
        $pager = new Pager('pm/' . u1, User::${'pm' . ucfirst(u1)}, Kio::getConfig('limit', 'pm'));
        $pager->sort(array(t('Subject') => 'subject', t('Message') => 'message', u1 == 'outbox' ? t('To') : t('From') => 'nickname', t('Sent') => 'sent'), 'sent', 'asc');
        // Reset new messages counter
        if (User::$pmNew) {
            $sql->exec('UPDATE ' . DB_PREFIX . 'users SET pm_new = 0 WHERE id = ' . UID);
        }
        if (isset($_POST['action']) && !empty($_POST['messages'])) {
            $action_messages = implode(', ', array_map('intval', $_POST['messages']));
            switch ($_POST['action']) {
                // Mark messages as read
                case 'read':
                    $sql->exec('
						UPDATE ' . DB_PREFIX . 'pm
						SET is_read = 1
						WHERE id IN(' . $action_messages . ')
							AND folder = ' . $folder_id . '
							AND owner_id = ' . UID);
                    break;
                    // Mark messages as unread
                // Mark messages as unread
                case 'unread':
                    $sql->exec('
						UPDATE ' . DB_PREFIX . 'pm
						SET is_read = 0
						WHERE id IN(' . $action_messages . ')
							AND folder = ' . $folder_id . '
							AND owner_id = ' . UID);
                    break;
                    // Delete messages
                // Delete messages
                case 'delete':
                    $sql->exec('
						DELETE FROM ' . DB_PREFIX . 'pm
						WHERE id IN(' . $action_messages . ')
							AND folder = ' . $folder_id . '
							AND owner_id = ' . UID);
            }
            redirect(HREF . PATH);
        }
        $stmt = $sql->query('
			SELECT pm.*, u.nickname, u.group_id
			FROM ' . DB_PREFIX . 'pm pm
			LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = pm.connector_id
			WHERE pm.owner_id = ' . UID . ' AND pm.folder = ' . $folder_id . '
			ORDER BY ' . $pager->orderBy . '
			LIMIT ' . $pager->limit . '
			OFFSET ' . $pager->offset);
        if ($stmt->rowCount()) {
            $messages = array();
            while ($row = $stmt->fetch()) {
                if ($row['connector_id']) {
                    $row['nickname'] = User::format($row['connector_id'], $row['nickname'], $row['group_id']);
                }
                $messages[] = $row;
            }
            try {
                $tpl = new PHPTAL('modules/pm/pm.tpl.html');
                $tpl->messages = $messages;
                $tpl->sort = $pager->sorters;
                $tpl->total = User::${'pm' . ucfirst(u1)};
                $tpl->max = Kio::getConfig(u1 . '_max', 'pm');
                $tpl->note = $note;
                $tpl->pager = $pager;
                $tpl->pagination = $pager->getLinks();
                return $tpl->execute();
            } catch (Exception $e) {
                return template_error($e);
            }
        } else {
            return $note->info(t('There is no messages in the box.'));
        }
    }