Beispiel #1
0
 public function close_reports($report_id_list, $action)
 {
     $sql = '';
     if ($action == 'delete') {
         $sql = 'DELETE FROM ' . $this->tables['reports'];
     } elseif ($action = 'close') {
         $sql = 'UPDATE ' . $this->tables['reports'] . ' SET status=' . self::REPORT_CLOSED;
     } else {
         return false;
     }
     $sql .= ' WHERE ' . $this->db->sql_in_set('report_id', $report_id_list);
     return $this->db->sql_query($sql);
 }
    /**
     * Get the data for all reportee from the database
     *
     * @param	array	$reportee_ids	Array with the user ids of the reportees
     *
     * @return	array		Returns an array with the reportee data
     */
    protected function get_reportee_data(array $reportee_ids)
    {
        $reportee_ids = array_unique($reportee_ids);
        $reportee_data_list = array();
        $sql = 'SELECT user_id, username, user_colour
			FROM ' . USERS_TABLE . '
			WHERE ' . $this->db->sql_in_set('user_id', $reportee_ids);
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $reportee_data_list[$row['user_id']] = $row;
        }
        $this->db->sql_freeresult($result);
        return $reportee_data_list;
    }
Beispiel #3
0
    public function display_tpotm($event)
    {
        $now = time();
        $date_today = gmdate("Y-m-d", $now);
        list($year_cur, $month_cur, $day1) = split('-', $date_today);
        /* Start time for current month */
        $month_start_cur = gmmktime(0, 0, 0, $month_cur, 1, $year_cur);
        $month_start = $month_start_cur;
        $month_end = $now;
        /*
         * group_id 5 = administrators
         * group_id 4 = global moderators
         * per default into a Vanilla 3.1.x board
         */
        $group_ids = array(5, 4);
        /*
         * config time for cache, still to be fully implemented thus hardcoded
         * 900 = 15 minutes
         */
        $config_time_cache = 900;
        /* Check cached data */
        if (($row = $this->cache->get('_tpotm')) === false) {
            $sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_type, u.group_id, p.poster_id, p.post_time, COUNT(p.post_id) AS total_posts
				FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p
				WHERE u.user_id > ' . ANONYMOUS . '
					AND u.user_id = p.poster_id
						AND (u.user_type <> ' . USER_FOUNDER . ')
							AND ' . $this->db->sql_in_set('u.group_id', $group_ids, true) . '
								AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . '
				GROUP BY u.user_id
				ORDER BY total_posts DESC';
            $result = $this->db->sql_query_limit($sql, 1);
            $row = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            /* caching this data improves performance */
            $this->cache->put('_tpotm', $row, (int) $config_time_cache);
        }
        /* Let's show the Top Poster then */
        $tpotm_tot_posts = (int) $row['total_posts'];
        $tpotm_un_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
        /* Fresh installs or new Month starts give zero posts */
        $tpotm_un_nobody = $this->user->lang['TPOTM_NOBODY'];
        $tpotm_post = $this->user->lang('TPOTM_POST', (int) $tpotm_tot_posts);
        $tpotm_name = $tpotm_tot_posts < 1 ? $tpotm_un_nobody : $tpotm_un_string;
        /* you know.. template stuffs */
        $this->template->assign_vars(array('TPOTM_NAME' => $tpotm_name, 'L_TPOTM_CAT' => $this->user->lang['TPOTM_CAT'], 'L_TPOTM_NOW' => $this->user->lang['TPOTM_NOW'], 'L_TPOTM_POST' => $tpotm_post));
    }
Beispiel #4
0
 /**
  * Forum check
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function viewtopic_get_post_data($event)
 {
     $topic_data = $event['topic_data'];
     $sql_ary = $event['sql_ary'];
     $post_list = $event['post_list'];
     $s_sfpo = !empty($topic_data['sfpo_guest_enable']) && $this->user->data['user_id'] == ANONYMOUS;
     if ($s_sfpo) {
         $this->user->add_lang_ext('rmcgirr83/sfpo', 'common');
         $post_list = array((int) $topic_data['topic_first_post_id']);
         $sql_ary['WHERE'] = $this->db->sql_in_set('p.post_id', $post_list) . ' AND u.user_id = p.poster_id';
         $topic_replies = $this->content_visibility->get_count('topic_posts', $topic_data, $event['forum_id']) - 1;
         $redirect = '&amp;redirect=' . urlencode(str_replace('&amp;', '&', build_url(array('_f_'))));
         $this->template->assign_vars(array('S_SFPO' => true, 'SFPO_MESSAGE' => $topic_replies ? $this->user->lang('SFPO_MSG_REPLY', $topic_replies) : '', 'U_SFPO_LOGIN' => append_sid("{$this->root_path}ucp.{$this->php_ext}", 'mode=login' . $redirect)));
     }
     $event['post_list'] = $post_list;
     $event['sql_ary'] = $sql_ary;
 }
 /**
  * Get top_flags
  * displayed on the index page
  */
 public function top_flags()
 {
     // grab all the flags
     $sql_array = array('SELECT' => 'user_flag, COUNT(user_flag) AS fnum', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => $this->db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' AND user_flag > 0', 'GROUP_BY' => 'user_flag', 'ORDER_BY' => 'fnum DESC');
     // we limit the number of flags to display to the number set in the ACP settings
     $result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_array), $this->config['flags_num_display']);
     $count = 0;
     $flags = $this->cache->get('_user_flags');
     while ($row = $this->db->sql_fetchrow($result)) {
         ++$count;
         $this->template->assign_block_vars('flag', array('FLAG' => $this->get_user_flag($row['user_flag']), 'FLAG_USERS' => $this->user->lang('FLAG_USERS', (int) $row['fnum']), 'U_FLAG' => $this->helper->route('rmcgirr83_nationalflags_getflags', array('flag_id' => $flags[$row['user_flag']]['flag_id']))));
     }
     $this->db->sql_freeresult($result);
     if ($count) {
         $this->template->assign_vars(array('U_FLAGS' => $this->helper->route('rmcgirr83_nationalflags_display'), 'S_FLAGS' => true));
     }
 }
    /**
     * Clear user reputation
     *
     * @param int $user_id User id
     * @param array $data Reputation data
     * @param arrat $post_ids Post IDs
     * @access public
     * @return null
     */
    public function clear_user_reputation($user_id, $data, $post_ids)
    {
        // Required fields
        $fields = array('user_id_to', 'reputation_item_id');
        foreach ($fields as $field) {
            if (!isset($data[$field])) {
                throw new \pico\reputation\exception\invalid_argument(array($field, 'FIELD_MISSING'));
            }
        }
        $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\tSET user_reputation = 0\n\t\t\tWHERE user_id = {$user_id}";
        $this->db->sql_query($sql);
        $sql = 'UPDATE ' . POSTS_TABLE . '
			SET post_reputation = 0
			WHERE ' . $this->db->sql_in_set('post_id', $post_ids, false, true);
        $this->db->sql_query($sql);
        $sql = 'DELETE FROM ' . $this->reputations_table . "\n\t\t\tWHERE user_id_to = {$user_id}";
        $this->db->sql_query($sql);
        $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_REPUTATION_CLEARED', false, array('user_id_to' => isset($data['username_to']) ? $data['username_to'] : $data['user_id_to']));
    }
    /**
     * Display flag
     *
     * @param $flag_id		int		the id of the flag
     * @param $start		int		page number we start at
     * @param $limit		int		limit to display for pagination
     * @return null
     * @access public
     */
    protected function display_flag($flag_id, $start, $limit)
    {
        //let's get the flag requested
        $sql = 'SELECT flag_id, flag_name, flag_image
			FROM ' . $this->flags_table . '
			WHERE flag_id = ' . (int) $flag_id;
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // now users that have the flag
        $sql = 'SELECT *
			FROM ' . USERS_TABLE . '
			WHERE user_flag = ' . (int) $row['flag_id'] . '
				AND ' . $this->db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
			ORDER BY username_clean';
        $result = $this->db->sql_query_limit($sql, $limit, $start);
        $rows = $this->db->sql_fetchrowset($result);
        $this->db->sql_freeresult($result);
        // for counting of total flag users
        $result = $this->db->sql_query($sql);
        $row2 = $this->db->sql_fetchrowset($result);
        $total_users = (int) count($row2);
        $this->db->sql_freeresult($result);
        unset($row2);
        foreach ($rows as $userrow) {
            $user_id = $userrow['user_id'];
            $username = $this->auth->acl_get('u_viewprofile') ? get_username_string('full', $user_id, $userrow['username'], $userrow['user_colour']) : get_username_string('no_profile', $user_id, $userrow['username'], $userrow['user_colour']);
            $this->template->assign_block_vars('user_row', array('JOINED' => $this->user->format_date($userrow['user_regdate']), 'VISITED' => empty($userrow['user_lastvisit']) ? ' - ' : $this->user->format_date($userrow['user_lastvisit']), 'POSTS' => $userrow['user_posts'] ? $userrow['user_posts'] : 0, 'USERNAME_FULL' => $username, 'U_SEARCH_USER' => $this->auth->acl_get('u_search') ? append_sid("{$this->root_path}search.{$this->php_ext}", "author_id={$user_id}&amp;sr=posts") : ''));
        }
        $this->pagination->generate_template_pagination(array('routes' => array('rmcgirr83_nationalflags_getflags', 'rmcgirr83_nationalflags_getflags_page'), 'params' => array('flag_id' => $flag_id)), 'pagination', 'page', $total_users, $limit, $start);
        $flag_image = $this->functions->get_user_flag($row['flag_id']);
        $users_count = $total_users;
        $total_users = $this->user->lang('FLAG_USERS', (int) $total_users);
        $this->template->assign_vars(array('FLAG' => html_entity_decode($row['flag_name']), 'FLAG_IMAGE' => $flag_image, 'TOTAL_USERS' => $total_users, 'S_VIEWONLINE' => $this->auth->acl_get('u_viewonline'), 'S_FLAGS' => true, 'S_FLAG_USERS' => !empty($users_count) ? true : false, 'MESSAGE_TEXT' => empty($users_count) ? $this->user->lang['NO_USER_HAS_FLAG'] : ''));
        // Assign breadcrumb template vars for the flags page
        $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('rmcgirr83_nationalflags_display'), 'FORUM_NAME' => $this->user->lang('NATIONAL_FLAGS')));
        // Assign breadcrumb template vars for the flags page
        $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('rmcgirr83_nationalflags_getflags', array('flag_id' => $flag_id)), 'FORUM_NAME' => $row['flag_name']));
    }
Beispiel #8
0
 /**
  * Get all user IDs that have specific ACL for album
  *
  * @param	string	$acl		One of the permissions, Exp: i_view; *_count permissions are not allowed!
  * @param	int		$album_id	Album ID we want info for
  *
  * return	array	$user_ids	Return user IDs as array
  */
 public function acl_users_ids($acl, $album_id)
 {
     if (strstr($acl, '_count') != 0) {
         return array();
     }
     // Let's load album data
     $sql = 'SELECT * FROM ' . $this->table_albums . ' WHERE album_id = ' . (int) $album_id;
     $result = $this->db->sql_query($sql);
     $album_data = $this->db->sql_fetchrow($result);
     $this->db->sql_freeresult($result);
     // Let's request roles
     // If album user_id is different then 0 then this is user album.
     // So we need to request all roles for perm_system -2(own) and -3(user)
     if ($album_data['album_user_id'] != 0) {
         $sql = 'SELECT * FROM ' . $this->table_permissions . ' WHERE ' . $this->db->sql_in_set('perm_system', array(-2, -3));
     } else {
         $sql = 'SELECT * FROM ' . $this->table_permissions . ' WHERE perm_album_id = ' . $album_id;
     }
     $result = $this->db->sql_query($sql);
     $roles_id = array();
     // Now we build the array to test
     while ($row = $this->db->sql_fetchrow($result)) {
         $roles_id['roles'][] = (int) $row['perm_role_id'];
         $roles_id[$row['perm_role_id']]['user_id'][] = (int) $row['perm_user_id'];
         $roles_id[$row['perm_role_id']]['group_id'][] = (int) $row['perm_group_id'];
     }
     $this->db->sql_freeresult($result);
     // Now we will select the roles that have the setted ACL
     $sql = 'SELECT role_id FROM ' . $this->table_roles . ' WHERE ' . $acl . ' = 1 and ' . $this->db->sql_in_set('role_id', $roles_id['roles'], false, true);
     $result = $this->db->sql_query($sql);
     $roles = array();
     while ($row = $this->db->sql_fetchrow($result)) {
         $roles[] = (int) $row['role_id'];
     }
     $this->db->sql_freeresult($result);
     // Let's cycle trough roles and build user_ids with user_ids from roles
     $user_ids = array();
     foreach ($roles as $id) {
         $user_ids = array_merge($user_ids, $roles_id[$id]['user_id']);
         // Let's query groups
         $sql = 'SELECT * FROM ' . USER_GROUP_TABLE . ' WHERE ' . $this->db->sql_in_set('group_id', $roles_id[$id]['group_id'], false, true);
         $result = $this->db->sql_query($sql);
         while ($row = $this->db->sql_fetchrow($result)) {
             if ($row['user_pending'] == 0) {
                 $user_ids[] = $row['user_id'];
             }
         }
         $this->db->sql_freeresult($result);
     }
     // Now we cycle the $user_ids to remove 0 and make ids unique
     $returning_value = array();
     foreach ($user_ids as $id) {
         if ($id != 0) {
             $returning_value[$id] = (int) $id;
         }
     }
     $user_ids = array();
     foreach ($returning_value as $id) {
         $user_ids[] = (int) $id;
     }
     return $user_ids;
 }