Пример #1
0
 function renderInnerOutput($context = array())
 {
     $value = $this->getConfiguration('value');
     if (empty($value)) {
         return '';
     } else {
         TikiLib::lib('smarty')->loadPlugin('smarty_modifier_username');
         return smarty_modifier_username($value);
     }
 }
Пример #2
0
function smarty_function_user_selector($params, $smarty)
{
    global $prefs, $user, $userlib, $headerlib, $tikilib, $tiki_p_admin;
    require_once 'lib/userslib.php';
    $smarty->loadPlugin('smarty_modifier_username');
    static $iUserSelector = 0;
    $iUserSelector++;
    $defaults = array('user' => $user, 'group' => 'all', 'groupIds' => '', 'contact' => 'false', 'name' => 'user', 'id' => 'user_selector_' . $iUserSelector, 'multiple' => 'false', 'mustmatch' => 'true', 'style' => '', 'editable' => $tiki_p_admin, 'user_selector_threshold' => $prefs['user_selector_threshold'], 'allowNone' => 'n');
    $params = array_merge($defaults, $params);
    if (isset($params['size'])) {
        $sz = ' size="' . $params['size'] . '"';
    } else {
        $sz = '';
    }
    if ($params['editable'] != 'y') {
        $ed = ' disabled="disabled"';
    } else {
        $ed = '';
    }
    $groupNames = array();
    if (!empty($params['groupIds'])) {
        $groupIds = explode('|', $params['groupIds']);
        foreach ($groupIds as $groupId) {
            $group_info = $userlib->get_groupId_info($groupId);
            $groupNames[] = $group_info['groupName'];
        }
    }
    if ($params['group'] == 'all') {
        $ucant = $tikilib->list_users(0, 0, 'login_asc');
        $ucant = $ucant['cant'];
    } else {
        $groupNames[] = $params['group'];
    }
    // NOTE: if groupIds are present, the list of users is limited to those groups regardless of group == 'all'
    if (!empty($groupNames)) {
        $groupNames = array_unique($groupNames);
        $users = array();
        foreach ($groupNames as $groupName) {
            $group_users = $userlib->get_group_users($groupName);
            $users = array_merge($users, $group_users);
        }
        $users = array_unique($users);
        $ucant = count($users);
    }
    $ret = '';
    if ($prefs['feature_jquery_autocomplete'] == 'y' && ($ucant > $prefs['user_selector_threshold'] or $ucant > $params['user_selector_threshold'])) {
        $ret .= '<input id="' . $params['id'] . '" type="text" name="' . $params['name'] . '" value="' . htmlspecialchars($params['user']) . '"' . $sz . $ed . ' style="' . $params['style'] . '" />';
        $headerlib->add_jq_onready('$("#' . $params['id'] . '").tiki("autocomplete", "' . ($params['contact'] == 'true' ? 'usersandcontacts' : 'username') . '", {mustMatch: ' . $params['mustmatch'] . ', multiple: ' . $params['multiple'] . ' });');
    } else {
        if ($params['group'] == 'all' && empty($params['groupIds'])) {
            $usrs = $tikilib->list_users(0, -1, 'login_asc');
            $users = array();
            foreach ($usrs['data'] as $usr) {
                $users[] = $usr['login'];
            }
        }
        $ret .= '<select name="' . $params['name'] . '" id="' . $params['id'] . '"' . $sz . $ed . ' style="' . $params['style'] . '">';
        if ($params['allowNone'] === 'y') {
            $ret .= '<option value=""' . (empty($params['user']) ? ' selected="selected"' : '') . ' >' . tra('None') . '</option>';
        }
        foreach ($users as $usr) {
            if ($params['editable'] == 'y' || $usr == $params['user']) {
                if (isset($params['select'])) {
                    $ret .= '<option value="' . htmlspecialchars($usr) . '"' . ($usr == $params['select'] ? ' selected="selected"' : '') . ' >' . smarty_modifier_username($usr) . '</option>';
                } else {
                    $ret .= '<option value="' . htmlspecialchars($usr) . '"' . ($usr == $params['user'] ? ' selected="selected"' : '') . ' >' . smarty_modifier_username($usr) . '</option>';
                }
            }
        }
        $ret .= '</select>';
    }
    return $ret;
}
Пример #3
0
 /**
  * @param $tikiobj
  * @param $user
  * @param $tstart
  * @param $tstop
  * @param $offset
  * @param $maxRecords
  * @param string $sort_mode
  * @param string $find
  * @return array
  */
 function list_tiki_items($tikiobj, $user, $tstart, $tstop, $offset, $maxRecords, $sort_mode = 'name_desc', $find = '')
 {
     global $user;
     $ret = array();
     if (!is_array($tikiobj)) {
         return $ret;
     }
     $tikiobj = array_unique($tikiobj);
     if (in_array('wiki', $tikiobj)) {
         $tikiobj[] = 'wiki page';
         $tikiobj[] = 'wiki comment';
     }
     foreach ($tikiobj as $type) {
         if ($type != '' && $type != 'wiki') {
             $objectType = $type == 'wiki comment' ? 'wiki page' : $type;
             $result = $this->get_object_cal_infos($type, array($tstart, $tstop, $objectType));
             if (is_object($result)) {
                 while ($res = $result->fetchRow()) {
                     if ($res['start'] > 0) {
                         $res['show_description'] = 'y';
                         $res['visible'] = 'y';
                         $res['type'] = $type;
                         $dstart = TikiLib::make_time(0, 0, 0, TikiLib::date_format('%m', $res['start']), TikiLib::date_format('%d', $res['start']), TikiLib::date_format('%Y', $res['start']));
                         $res['time'] = TikiLib::date_format('%H%M', $res['start']);
                         $res['when'] = TikiLib::date_format('%H:%M', $res['start']);
                         $when = '<b>' . $res['when'] . '</b>';
                         $url_vars = array($res['id'], $res['id2']);
                         switch ($res['type']) {
                             case 'art':
                                 $res['description'] = $this->parse_data($res['description']);
                                 break;
                             case 'blog':
                                 $res['name'] = $res['parent'] . ' :: ' . $res['name'];
                                 break;
                             case 'dir':
                                 $res['description'] = addslashes($res['dir_url']) . '<br />' . $res['description'];
                                 break;
                             case 'forum':
                                 if ($res['fid'] > 0) {
                                     $url_vars = array($res['fid'], $res['id2'], 'threadId' . $res['id']);
                                 }
                                 break;
                             case 'gal':
                                 $res['description'] = tra('New Image Uploaded by') . ' %s';
                                 break;
                             case 'nl':
                                 $res['description'] = tra('New Subscriptions');
                                 $res['head'] = ' ... ' . $res['head'];
                                 break;
                             case 'track':
                                 $res['description'] = tra('New Item in Tracker');
                                 $res['parent'] = tra('tracker');
                                 break;
                             case 'wiki page':
                                 $res['parent'] = 'wiki';
                                 break;
                         }
                         $res['url'] = $this->get_object_url($res['type'], $url_vars);
                         if ($res['user'] != '') {
                             include_once 'lib/smarty_tiki/modifier.username.php';
                             $res['user'] = smarty_modifier_username($res['user']);
                             if (!strpos($res['description'], '%s')) {
                                 $br = $res['description'] == '' ? '' : '<br />';
                                 $res['description'] = '<i>' . tra('by') . ' %s</i>' . $br . $res['description'];
                             }
                             $res['description'] = sprintf($res['description'], $res['user']);
                         }
                         $res['description'] = str_replace(array('"', "\n|\r"), array("'", ''), $res['description']);
                         if ($res['name'] == '') {
                             $res['name'] = $res['id'];
                         }
                         $res['where'] = str_replace("\n|\r", '', addslashes($res['parent']));
                         if ((!isset($where) || $where == '') && $res['parent'] != '') {
                             $where = ' ' . tra('in') . ' <b>' . $res['where'] . '</b>';
                         }
                         if ($res['head'] == '') {
                             $res['head'] = $when . $where;
                         }
                         $res['group_description'] = $res['name'];
                         $ret[$dstart][] = $res;
                         unset($where);
                         unset($when);
                     }
                 }
             }
         }
     }
     return $ret;
 }
/**
 * @param $mod_reference
 * @param null $params
 * @return bool
 */
function module_since_last_visit_new($mod_reference, $params = null)
{
    global $user;
    $smarty = TikiLib::lib('smarty');
    include_once 'tiki-sefurl.php';
    if (!$user) {
        return false;
    }
    if (!isset($params['use_jquery_ui']) || $params['use_jquery_ui'] != 'y') {
        $smarty->assign('use_jquery_ui', 'n');
    } else {
        $smarty->assign('use_jquery_ui', 'y');
    }
    if (!isset($params['date_as_link']) || $params['date_as_link'] != 'n') {
        $smarty->assign('date_as_link', 'y');
    } else {
        $smarty->assign('date_as_link', 'n');
    }
    if (!isset($params['fold_sections']) || $params['fold_sections'] != 'y') {
        $smarty->assign('default_folding', 'block');
        $smarty->assign('opposite_folding', 'none');
    } else {
        $smarty->assign('default_folding', 'none');
        $smarty->assign('opposite_folding', 'block');
    }
    if (empty($params['commentlength'])) {
        $params['commentlength'] = 40;
    }
    $resultCount = $mod_reference['rows'];
    global $prefs;
    $userlib = TikiLib::lib('user');
    $tikilib = TikiLib::lib('tiki');
    $smarty->loadPlugin('smarty_modifier_username');
    $ret = array();
    if ($params == null) {
        $params = array();
    }
    if ((empty($params['calendar_focus']) || $params['calendar_focus'] != 'ignore') && strpos($_SERVER['SCRIPT_NAME'], 'tiki-calendar.php') !== false && !empty($_REQUEST['todate'])) {
        $last = $_REQUEST['todate'];
        $_SESSION['slvn_last_login'] = $last;
        $smarty->assign('tpl_module_title', tra('Changes since'));
    } else {
        if (isset($_SESSION['slvn_last_login'])) {
            $last = $_SESSION['slvn_last_login'];
            $smarty->assign('tpl_module_title', tra('Changes since'));
        } else {
            $last = $tikilib->getOne('select `lastLogin` from `users_users` where `login`=?', array($user));
            $smarty->assign('tpl_module_title', tra('Since your last visit...'));
            if (!$last || !empty($params['daysAtLeast'])) {
                $now = TikiLib::lib('tiki')->now;
                if (!$last) {
                    $last = $now;
                }
                if (!empty($params['daysAtLeast']) && $now - $last < $params['daysAtLeast'] * 60 * 60 * 24) {
                    $last = $now - $params['daysAtLeast'] * 60 * 60 * 24;
                    $smarty->assign('tpl_module_title', tr('In the last %0 days...', $params['daysAtLeast']));
                }
            }
        }
    }
    $ret['lastLogin'] = $last;
    $ret['items']['comments']['label'] = tra('new comments');
    $ret['items']['comments']['cname'] = 'slvn_comments_menu';
    //TODO: should be a function on commentslib.php or use one of the existent functions
    $query = 'select `object`,`objectType`,`title`,`commentDate`,`userName`,`threadId`, `parentId`, `approved`, `archived`, `data`' . " from `tiki_comments` where `commentDate`>? and `objectType` != 'forum' order by `commentDate` desc";
    $result = $tikilib->query($query, array((int) $last), $resultCount);
    $count = 0;
    while ($res = $result->fetchRow()) {
        $ret['items']['comments']['list'][$count]['href'] = TikiLib::lib('comments')->getHref($res['objectType'], $res['object'], $res['threadId']);
        switch ($res['objectType']) {
            case 'article':
                $perm = 'tiki_p_read_article';
                $ret['items']['comments']['list'][$count]['href'] = filter_out_sefurl($ret['items']['comments']['list'][$count]['href'], 'article', $res['title']);
                break;
            case 'post':
                $perm = 'tiki_p_read_blog';
                $ret['items']['comments']['list'][$count]['href'] = filter_out_sefurl($ret['items']['comments']['list'][$count]['href'], 'blogpost', $res['title']);
                break;
            case 'blog':
                $perm = 'tiki_p_read_blog';
                $ret['items']['comments']['list'][$count]['href'] = filter_out_sefurl($ret['items']['comments']['list'][$count]['href'], 'blog', $res['title']);
                break;
            case 'faq':
                $perm = 'tiki_p_view_faqs';
                break;
            case 'file gallery':
                $perm = 'tiki_p_view_file_gallery';
                break;
            case 'image gallery':
                $perm = 'tiki_p_view_image_gallery';
                break;
            case 'poll':
                // no perm check for viewing polls, only a perm for taking them
                break;
            case 'wiki page':
                $perm = 'tiki_p_view';
                break;
            default:
                // note trackeritme needs more complex perms checking due to status and ownership
                $perm = 'tiki_p_read_comments';
                break;
        }
        if ($res['approved'] == 'n' || $res['archived'] == 'y') {
            $visible = $userlib->user_has_perm_on_object($user, $res['object'], $res['objectType'], 'tiki_p_admin_comments');
        } else {
            if ($res['objectType'] === 'trackeritem') {
                $item = Tracker_Item::fromId($res['object']);
                $visible = $item->canView();
            } else {
                $visible = !isset($perm) || $userlib->user_has_perm_on_object($user, $res['object'], $res['objectType'], $perm);
            }
        }
        if ($visible) {
            $ret['items']['comments']['list'][$count]['title'] = $tikilib->get_short_datetime($res['commentDate']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['userName']);
            $ret['items']['comments']['list'][$count]['label'] = TikiLib::lib('comments')->process_comment_title($res, $params['commentlength']);
            if ($res['archived'] == 'y') {
                $ret['items']['comments']['list'][$count]['label'] .= tra(' (archived)');
            }
            $count++;
        }
    }
    $ret['items']['comments']['count'] = $count;
    /////////////////////////////////////////////////////////////////////////
    // FORUMS
    if ($prefs['feature_forums'] == 'y') {
        $ret['items']['posts']['label'] = tra('new posts');
        $ret['items']['posts']['cname'] = 'slvn_posts_menu';
        $query = 'select `posts`.`object`,`posts`.`objectType`,`posts`.`title`,`posts`.`commentDate`,' . ' `posts`.`userName`,`posts`.`threadId`, `posts`.`parentId`,`topics`.`title` `topic_title`' . ' from `tiki_comments` `posts`' . ' left join `tiki_comments` `topics` ON `posts`.`parentId` = `topics`.`threadId`' . " where `posts`.`commentDate`>? and `posts`.`objectType` = 'forum'" . ' order by `posts`.`commentDate` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['object'], $res['objectType'], 'tiki_p_forum_read')) {
                $ret['items']['posts']['list'][$count]['href'] = 'tiki-view_forum_thread.php?forumId=' . $res['object'] . '&comments_parentId=';
                if ($res['parentId']) {
                    $ret['items']['posts']['list'][$count]['href'] .= $res['parentId'] . '#threadId' . $res['threadId'];
                } else {
                    $ret['items']['posts']['list'][$count]['href'] .= $res['threadId'];
                }
                $ret['items']['posts']['list'][$count]['title'] = $tikilib->get_short_datetime($res['commentDate']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['userName']);
                if ($res['parentId'] == 0 || $prefs['forum_reply_notitle'] != 'y') {
                    $ret['items']['posts']['list'][$count]['label'] = $res['title'];
                } else {
                    $ret['items']['posts']['list'][$count]['label'] = $res['topic_title'];
                }
                ++$count;
            }
        }
        $ret['items']['posts']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // WIKI PAGES
    if ($prefs['feature_wiki'] == 'y') {
        $ret['items']['pages']['label'] = tra('wiki pages changed');
        $ret['items']['pages']['cname'] = 'slvn_pages_menu';
        $query = 'select `pageName`, `user`, `lastModif` from `tiki_pages` where `lastModif`>? order by `lastModif` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['pageName'], 'wiki page', 'tiki_p_view')) {
                $ret['items']['pages']['list'][$count]['href'] = filter_out_sefurl('tiki-index.php?page=' . urlencode($res['pageName']));
                $ret['items']['pages']['list'][$count]['title'] = $tikilib->get_short_datetime($res['lastModif']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['pages']['list'][$count]['label'] = $res['pageName'];
                $count++;
            }
        }
        $ret['items']['pages']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // ARTICLES
    if ($prefs['feature_articles'] == 'y') {
        $ret['items']['articles']['label'] = tra('new articles');
        $ret['items']['articles']['cname'] = 'slvn_articles_menu';
        if ($userlib->user_has_permission($user, 'tiki_p_edit_article')) {
            $query = 'select `articleId`,`title`,`publishDate`,`authorName` from `tiki_articles` where `created`>? and `expireDate`>? order by `articleId` desc';
            $bindvars = array((int) $last, time());
        } else {
            $query = 'select `articleId`,`title`,`publishDate`,`authorName` from `tiki_articles` where `publishDate`>? and `publishDate`<=? and `expireDate`>? order by `articleId` desc';
            $bindvars = array((int) $last, time(), time());
        }
        $result = $tikilib->query($query, $bindvars, $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['articleId'], 'article', 'tiki_p_read_article')) {
                $ret['items']['articles']['list'][$count]['href'] = filter_out_sefurl('tiki-read_article.php?articleId=' . $res['articleId'], 'article', $res['title']);
                $ret['items']['articles']['list'][$count]['title'] = $tikilib->get_short_datetime($res['publishDate']) . ' ' . tra('by') . ' ' . $res['authorName'];
                $ret['items']['articles']['list'][$count]['label'] = $res['title'];
                $count++;
            }
        }
        $ret['items']['articles']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // FAQs
    if ($prefs['feature_faqs'] == 'y') {
        $ret['items']['faqs']['label'] = tra('new FAQs');
        $ret['items']['faqs']['cname'] = 'slvn_faqs_menu';
        $query = 'select `faqId`, `title`, `created` from `tiki_faqs` where `created`>? order by `created` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['faqId'], 'faq', 'tiki_p_view_faq')) {
                $ret['items']['faqs']['list'][$count]['href'] = 'tiki-view_faq.php?faqId=' . $res['faqId'];
                $ret['items']['faqs']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']);
                $ret['items']['faqs']['list'][$count]['label'] = $res['title'];
                $count++;
            }
        }
        $ret['items']['faqs']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // BLOGS
    if ($prefs['feature_blogs'] == 'y') {
        $ret['items']['blogs']['label'] = tra('new blogs');
        $ret['items']['blogs']['cname'] = 'slvn_blogs_menu';
        $query = "select `blogId`, `title`, `user`, `created` from `tiki_blogs` where `created`>? order by `created` desc";
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['blogId'], 'blog', 'tiki_p_read_blog')) {
                $ret['items']['blogs']['list'][$count]['href'] = filter_out_sefurl('tiki-view_blog.php?blogId=' . $res['blogId'], 'blog', $res['title']);
                $ret['items']['blogs']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['blogs']['list'][$count]['label'] = $res['title'];
                $count++;
            }
        }
        $ret['items']['blogs']['count'] = $count;
        $ret['items']['blogPosts']['label'] = tra('new blog posts');
        $ret['items']['blogPosts']['cname'] = 'slvn_blogPosts_menu';
        $query = 'select `postId`, `blogId`, `title`, `user`, `created` from `tiki_blog_posts` where `created`>? order by `created` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['blogId'], 'blog', 'tiki_p_read_blog')) {
                $ret['items']['blogPosts']['list'][$count]['href'] = filter_out_sefurl('tiki-view_blog_post.php?postId=' . $res['postId'], 'blogpost', $res['title']);
                $ret['items']['blogPosts']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['blogPosts']['list'][$count]['label'] = $res['title'];
                $count++;
            }
        }
        $ret['items']['blogPosts']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // IMAGE GALLERIES
    if ($prefs['feature_galleries'] == 'y') {
        // image galleries
        $ret['items']['imageGalleries']['label'] = tra('new image galleries');
        $ret['items']['imageGalleries']['cname'] = 'slvn_imageGalleries_menu';
        $query = "select `galleryId`,`name`,`created`,`user` from `tiki_galleries` where `created`>? order by `created` desc";
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) {
                $ret['items']['imageGalleries']['list'][$count]['href'] = 'tiki-browse_gallery.php?galleryId=' . $res['galleryId'];
                $ret['items']['imageGalleries']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['imageGalleries']['list'][$count]['label'] = $res['name'];
                $count++;
            }
        }
        $ret['items']['imageGalleries']['count'] = $count;
        // images
        $ret['items']['images']['label'] = tra('new images');
        $ret['items']['images']['cname'] = 'slvn_images_menu';
        $query = 'select `imageId`,`galleryId`,`name`,`created`,`user` from `tiki_images` where `created`>? order by `created` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'image gallery', 'tiki_p_view_image_gallery')) {
                $ret['items']['images']['list'][$count]['href'] = 'tiki-browse_image.php?galleryId=' . $res['galleryId'] . '&imageId=' . $res['imageId'];
                $ret['items']['images']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['images']['list'][$count]['label'] = $res['name'];
                $count++;
            }
        }
        $ret['items']['images']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // FILE GALLERIES
    if ($prefs['feature_file_galleries'] == 'y') {
        // file galleries
        $ret['items']['fileGalleries']['label'] = tra('new file galleries');
        $ret['items']['fileGalleries']['cname'] = 'slvn_fileGalleries_menu';
        $query = 'select `galleryId`,`name`,`created`,`user` from `tiki_file_galleries` where `created`>? order by `created` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'file gallery', 'tiki_p_view_file_gallery')) {
                $ret['items']['fileGalleries']['list'][$count]['href'] = filter_out_sefurl('tiki-list_file_gallery.php?galleryId=' . $res['galleryId'], 'file gallery');
                $ret['items']['fileGalleries']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['fileGalleries']['list'][$count]['label'] = $res['name'];
                $count++;
            }
        }
        $ret['items']['fileGalleries']['count'] = $count;
        // files
        $ret['items']['files']['label'] = tra('new files');
        //get_strings tra('new files');
        $ret['items']['files']['cname'] = 'slvn_files_menu';
        $query = 'select `fileId`, `galleryId`,`name`,`filename`,`created`,`user` from `tiki_files` where `created`>? order by `created` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['galleryId'], 'file gallery', 'tiki_p_view_file_gallery')) {
                $ret['items']['files']['list'][$count]['href'] = filter_out_sefurl('tiki-list_file_gallery.php?galleryId=' . $res['galleryId'] . '&fileId=' . $res['fileId'] . '&view=page', 'file gallery');
                $ret['items']['files']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['files']['list'][$count]['label'] = $res['name'] . ' (' . $res['filename'] . ')';
                $count++;
            }
        }
        $ret['items']['files']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // POLLS
    if ($prefs['feature_polls'] == 'y') {
        $ret['items']['polls']['label'] = tra('new polls');
        $ret['items']['polls']['cname'] = 'slvn_polls_menu';
        $query = 'select `pollId`, `title`, `publishDate` from `tiki_polls` where `publishDate`>? order by `publishDate` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            $ret['items']['polls']['list'][$count]['href'] = 'tiki-poll_results.php?pollId=' . $res['pollId'];
            $ret['items']['polls']['list'][$count]['title'] = $tikilib->get_short_datetime($res['publishDate']);
            $ret['items']['polls']['list'][$count]['label'] = $res['title'];
            $count++;
        }
        $ret['items']['polls']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // NEW USERS
    if (!isset($params['showuser']) || $params['showuser'] != 'n') {
        $ret['items']['users']['label'] = tra('new users');
        $ret['items']['users']['cname'] = 'slvn_users_menu';
        $query = 'select `login`, `registrationDate` from `users_users` where `registrationDate`>? and `provpass`=?';
        $result = $tikilib->query($query, array((int) $last, ''), $resultCount);
        $count = 0;
        $slvn_tmp_href = $userlib->user_has_permission($user, 'tiki_p_admin') ? 'tiki-assignuser.php?assign_user='******'tiki-user_information.php?view_user='******'items']['users']['list'][$count]['href'] = $slvn_tmp_href . rawurlencode($res['login']);
            $ret['items']['users']['list'][$count]['title'] = $tikilib->get_short_datetime($res['registrationDate']);
            $ret['items']['users']['list'][$count]['label'] = smarty_modifier_username($res['login']);
            $count++;
        }
        $ret['items']['users']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // TRACKER ITEMS
    // This breaks out tracker updates into sub-sections, by tracker, separating new items and updated items.
    // NEW TRACKER ITEMS
    if ($prefs['feature_trackers'] == 'y' && (!isset($params['showtracker']) || $params['showtracker'] != 'n')) {
        $ret['items']['trackers']['label'] = tra('new tracker items');
        $ret['items']['trackers']['cname'] = 'slvn_trackers_menu';
        $query = 'select `itemId`, `trackerId`, `created`, `lastModif`  from `tiki_tracker_items` where `created`>? order by `created` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        $counta = array();
        $tracker_name = array();
        $cachelib = TikiLib::lib('cache');
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['trackerId'], 'tracker', 'tiki_p_view_trackers')) {
                // Initialize tracker counter if needed.
                if (!isset($counta[$res['trackerId']])) {
                    $counta[$res['trackerId']] = 0;
                }
                // Pull Tracker Name
                if ($res['trackerId'] > 0 && !isset($tracker_name[$res['trackerId']])) {
                    $query = "select `name` from `tiki_trackers` where `trackerId` = ?";
                    $tracker_name[$res['trackerId']] = $tikilib->getOne($query, $res['trackerId']);
                }
                $ret['items']['trackers']['tid'][$res['trackerId']]['label'] = tra('in') . ' ' . tra($tracker_name[$res['trackerId']]);
                $ret['items']['trackers']['tid'][$res['trackerId']]['cname'] = 'slvn_tracker' . $res['trackerId'] . '_menu';
                $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['href'] = filter_out_sefurl('tiki-view_tracker_item.php?itemId=' . $res['itemId'], 'trackeritem');
                $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['title'] = $tikilib->get_short_datetime($res['created']);
                // routine to verify field in tracker that's used as label
                $cacheKey = 'trackerItemLabel' . $res['itemId'];
                if (!($label = $cachelib->getCached($cacheKey))) {
                    $query = 'select `fieldId` from `tiki_tracker_fields` where `isMain` = ? and `trackerId` = ? order by `position`';
                    $fieldId = $tikilib->getOne($query, array('y', $res['trackerId']));
                    $query = 'select `value` from `tiki_tracker_item_fields` where `fieldId` = ? and `itemId` = ?';
                    $label = $tikilib->getOne($query, array($fieldId, $res['itemId']));
                    $cachelib->cacheItem($cacheKey, $label);
                }
                // If the label is empty (b:0;), then use the item ID
                if ($label == 'b:0;' || $label == '') {
                    $label = 'Trk i' . $res['trackerId'] . ' - ID: ' . $res['itemId'];
                }
                $ret['items']['trackers']['tid'][$res['trackerId']]['list'][$counta[$res['trackerId']]]['label'] = $label;
                $counta[$res['trackerId']]++;
                $ret['items']['trackers']['tid'][$res['trackerId']]['count'] = $counta[$res['trackerId']];
                $count++;
            }
        }
        $ret['items']['trackers']['count'] = $count;
        /////////////////////////////////////////////////////////////////////////
        // UPDATED TRACKER ITEMS - ignore updates on same day as creation
        $ret['items']['utrackers']['label'] = tra('updated tracker items');
        $ret['items']['utrackers']['cname'] = 'slvn_utrackers_menu';
        $query = 'select `itemId`, `trackerId`, `created`, `lastModif`' . ' from `tiki_tracker_items` where `lastModif`>? and `lastModif`!=`created`' . ' order by `lastModif` desc';
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        $countb = array();
        $cachelib = TikiLib::lib('cache');
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['trackerId'], 'tracker', 'tiki_p_view_trackers')) {
                // Initialize tracker counter if needed.
                if (!isset($countb[$res['trackerId']])) {
                    $countb[$res['trackerId']] = 0;
                }
                // Pull Tracker Name
                if (!isset($tracker_name[$res['trackerId']])) {
                    $query = 'select `name` from `tiki_trackers` where `trackerId` = ?';
                    $tracker_name[$res['trackerId']] = $tikilib->getOne($query, $res['trackerId']);
                }
                $ret['items']['utrackers']['tid'][$res['trackerId']]['label'] = tra('in') . ' ' . tra($tracker_name[$res['trackerId']]);
                $ret['items']['utrackers']['tid'][$res['trackerId']]['cname'] = 'slvn_utracker' . $res['trackerId'] . '_menu';
                $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['href'] = filter_out_sefurl('tiki-view_tracker_item.php?itemId=' . $res['itemId'], 'trackeritem');
                $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['title'] = $tikilib->get_short_datetime($res['lastModif']);
                // routine to verify field in tracker that's used as label
                $cacheKey = 'trackerItemLabel' . $res['itemId'];
                if (!($label = $cachelib->getCached($cacheKey))) {
                    $query = 'select `fieldId` from `tiki_tracker_fields` where `isMain` = ? and `trackerId` = ? order by `position`';
                    $fieldId = $tikilib->getOne($query, array('y', $res['trackerId']));
                    $query = 'select `value` from `tiki_tracker_item_fields` where `fieldId` = ? and `itemId` = ?';
                    $label = $tikilib->getOne($query, array($fieldId, $res['itemId']));
                    $cachelib->cacheItem($cacheKey, $label);
                }
                // If the label is empty (b:0;), then use the item ID
                if ($label == 'b:0;' || $label == '') {
                    $label = 'Trk i' . $res['trackerId'] . ' - ID: ' . $res['itemId'];
                }
                $ret['items']['utrackers']['tid'][$res['trackerId']]['list'][$countb[$res['trackerId']]]['label'] = $label;
                $countb[$res['trackerId']]++;
                $ret['items']['utrackers']['tid'][$res['trackerId']]['count'] = $countb[$res['trackerId']];
                $count++;
            }
        }
        $ret['items']['utrackers']['count'] = $count;
    }
    /////////////////////////////////////////////////////////////////////////
    // CALENDARS & THEIR EVENTS
    if ($prefs['feature_calendar'] == 'y') {
        $ret['items']['calendar']['label'] = tra('new calendars');
        $ret['items']['calendar']['cname'] = 'slvn_calendar_menu';
        $query = "select `calendarId`, `name`, `user`, `created` from `tiki_calendars` where `created`>? order by `created` desc";
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['calendarId'], 'calendar', 'tiki_p_view_calendar')) {
                $ret['items']['calendar']['list'][$count]['href'] = filter_out_sefurl('tiki-calendar.php?calIds[]=' . $res['calendarId'], 'calendar', $res['name']);
                $ret['items']['calendar']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']);
                $ret['items']['calendar']['list'][$count]['label'] = $res['name'];
                $count++;
            }
        }
        $ret['items']['calendar']['count'] = $count;
        $ret['items']['events']['label'] = tra('new events');
        $ret['items']['events']['cname'] = 'slvn_events_menu';
        $query = "select `calitemId`, `calendarId`, `name`, `user`, `created`, `start` from `tiki_calendar_items` where `created`>? order by `created` desc";
        $result = $tikilib->query($query, array((int) $last), $resultCount);
        $count = 0;
        while ($res = $result->fetchRow()) {
            if ($userlib->user_has_perm_on_object($user, $res['calendarId'], 'calendar', 'tiki_p_view_events')) {
                $ret['items']['events']['list'][$count]['href'] = filter_out_sefurl('tiki-calendar_edit_item.php?viewcalitemId=' . $res['calitemId'], 'event', $res['name']);
                $ret['items']['events']['list'][$count]['title'] = $tikilib->get_short_datetime($res['created']) . ' ' . tra('by') . ' ' . smarty_modifier_username($res['user']) . ', ' . tra('starting on') . ' ' . $tikilib->get_short_datetime($res['start']);
                $ret['items']['events']['list'][$count]['label'] = $res['name'];
                $count++;
            }
        }
        $ret['items']['events']['count'] = $count;
    }
    //////////////////////////////////////////////////////////////////////////
    // SUMMARY
    //get the total of items
    $ret['cant'] = 0;
    $ret['nonempty'] = 0;
    foreach ($ret['items'] as $item) {
        $ret['cant'] += $item['count'];
        if ($item['count'] > 0) {
            $ret['nonempty']++;
        }
    }
    if ($ret['nonempty'] > 0) {
        $ret['li_width'] = min(22, (int) 90 / $ret['nonempty']);
    } else {
        $ret['li_width'] = 90;
    }
    $smarty->assign('slvn_info', $ret);
}
Пример #5
0
         switch ($words[0]) {
             case '/part':
             case '/close':
                 echo "minichat_removechannel('" . $channel . "');\n";
                 $closed = true;
                 if (!isset($_SESSION['minichat_channels'])) {
                     initchannelssession($chans);
                 }
                 $k = array_search($words[1], $_SESSION['minichat_channels']);
                 if ($k !== false) {
                     unset($_SESSION['minichat_channels'][$k]);
                 }
                 break;
         }
     } else {
         $tikilib->query("INSERT INTO tiki_minichat (nick,user,ts,channel,msg) VALUES (?,?,?,?,?)", array(smarty_modifier_username($user), $user, $tikilib->now, $channel, $msg));
         $lastid = 0;
     }
     $lasttimeout = $timeout_min;
 }
 if ($closed) {
     continue;
 }
 if (empty($channel)) {
     continue;
 }
 if ($lastid > 0) {
     $result = $tikilib->query("SELECT MAX(id) AS maxid FROM tiki_minichat WHERE channel=?", array($channel));
     $res = $result->fetchRow();
     $maxid = $res['maxid'];
     if ($maxid != $lastid) {
Пример #6
0
                $editpageconflict = 'y';
            } elseif ($tiki_p_edit === 'y') {
                $_SESSION[$editLockPageId] = $tikilib->semaphore_set($page);
            }
            $semUser = $tikilib->get_semaphore_user($page);
            $beingedited = 'y';
        } else {
            if (!empty($_SESSION[$editLockPageId])) {
                $tikilib->semaphore_unset($page, $_SESSION[$editLockPageId]);
            }
        }
    }
    if ($editpageconflict === 'y' && !isset($_REQUEST["conflictoverride"])) {
        include_once 'lib/smarty_tiki/modifier.userlink.php';
        include_once 'lib/smarty_tiki/modifier.username.php';
        $msg = tr("This page is being edited by %0. Please check with the user before editing the page,\totherwise the changes will be stored as two separate versions in the history and you will have to manually merge them later.", smarty_modifier_username($semUser));
        $msg .= '<br /><br /><a href="tiki-editpage.php?page=';
        $msg .= urlencode($page);
        $msg .= '&conflictoverride=y">' . tra('Override lock and carry on with edit') . '</a>';
        $smarty->assign('msg', $msg);
        $smarty->assign('errortitle', tra('Page is currently being edited'));
        $smarty->display("error.tpl");
        die;
    }
}
$category_needed = false;
$contribution_needed = false;
if (isset($_REQUEST['lock_it']) && $_REQUEST['lock_it'] === 'on') {
    $lock_it = 'y';
} else {
    $lock_it = 'n';
Пример #7
0
 /**
  * Generate the e-mail body
  *
  * @param array $report_cache changes for objects the user is watching
  * @param array $report_preferences user preferences for receiving the report
  * @return string email body string
  */
 public function makeEmailBody(array $report_cache, array $report_preferences)
 {
     global $userlib;
     $change_array = $this->makeChangeArray($report_cache);
     $body = '';
     $morechanges = 0;
     foreach ($change_array as $eventName => $changes) {
         $eventObject = $this->factory->build($changes[0]['event']);
         $body .= '<b>' . $eventObject->getTitle() . "</b><br />\n";
         foreach ($changes as $key => $change) {
             if ($report_preferences['view'] == "short" and $key > 0) {
                 $morechanges++;
             } elseif ($report_preferences['view'] == "detailed" or $key == 0) {
                 if ($morechanges > 0) {
                     $body .= "   " . tr('and %0 more changes of the same type.', $morechanges) . "<br>\n";
                     $morechanges = 0;
                 }
                 if ($report_preferences['type'] == 'plain') {
                     $body .= "   ";
                 } else {
                     $body .= "&nbsp;&nbsp;&nbsp;";
                 }
                 $body .= $this->tikilib->get_short_datetime(strtotime($change['time'])) . ": ";
                 if (isset($change['data']['user'])) {
                     include_once 'lib/smarty_tiki/modifier.username.php';
                     $change['data']['user'] = smarty_modifier_username($change['data']['user']);
                 }
                 $body .= $eventObject->getOutput($change);
                 $body .= "<br>\n";
             }
         }
     }
     if ($report_preferences['type'] == 'plain') {
         $body = strip_tags($body);
     }
     if (empty($change_array)) {
         return tr('Nothing has happened.');
     } else {
         return $body;
     }
 }
Пример #8
0
 function getTabularSchema()
 {
     $permName = $this->getConfiguration('permName');
     $baseKey = $this->getBaseKey();
     $name = $this->getConfiguration('name');
     $schema = new Tracker\Tabular\Schema($this->getTrackerDefinition());
     $schema->addNew($permName, 'userlink')->setLabel($name)->setPlainReplacement('username')->setRenderTransform(function ($value) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_modifier_userlink');
         if ($value) {
             return smarty_modifier_userlink($value);
         }
     });
     $schema->addNew($permName, 'realname')->setLabel($name)->setReadOnly(true)->setRenderTransform(function ($value) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_modifier_username');
         if ($value) {
             return smarty_modifier_username($value, true, false, false);
         }
     });
     $schema->addNew($permName, 'username-itemlink')->setLabel($name)->setPlainReplacement('username')->addQuerySource('itemId', 'object_id')->setRenderTransform(function ($value, $extra) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_function_object_link');
         if ($value) {
             return smarty_function_object_link(['type' => 'trackeritem', 'id' => $extra['itemId'], 'title' => $value], $smarty);
         }
     });
     $schema->addNew($permName, 'realname-itemlink')->setLabel($name)->setPlainReplacement('realname')->addQuerySource('itemId', 'object_id')->setRenderTransform(function ($value, $extra) {
         $smarty = TikiLib::lib('smarty');
         $smarty->loadPlugin('smarty_function_object_link');
         $smarty->loadPlugin('smarty_modifier_username');
         if ($value) {
             return smarty_function_object_link(['type' => 'trackeritem', 'id' => $extra['itemId'], 'title' => smarty_modifier_username($value, true, false, false)], $smarty);
         }
     });
     $schema->addNew($permName, 'username')->setLabel($name)->setRenderTransform(function ($value) {
         return $value;
     })->setParseIntoTransform(function (&$info, $value) use($permName) {
         $info['fields'][$permName] = $value;
     });
     return $schema;
 }