Exemple #1
0
    /**
     * Submit profile field for validation
     */
    public function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
    {
        $sql_where = '';
        switch ($mode) {
            case 'register':
                // If the field is required we show it on the registration page
                $sql_where .= ' AND f.field_show_on_reg = 1';
                break;
            case 'profile':
                // Show hidden fields to moderators/admins
                if (!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_')) {
                    $sql_where .= ' AND f.field_show_profile = 1';
                }
                break;
            default:
                trigger_error('Wrong profile mode specified', E_USER_ERROR);
                break;
        }
        $sql = 'SELECT l.*, f.*
			FROM ' . $this->fields_language_table . ' l, ' . $this->fields_table . ' f
			WHERE l.lang_id = ' . (int) $lang_id . "\n\t\t\t\tAND f.field_active = 1\n\t\t\t\t{$sql_where}\n\t\t\t\tAND l.field_id = f.field_id\n\t\t\tORDER BY f.field_order";
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $profile_field = $this->type_collection[$row['field_type']];
            $cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row);
            $check_value = $cp_data['pf_' . $row['field_ident']];
            if (($cp_result = $profile_field->validate_profile_field($check_value, $row)) !== false) {
                // If the result is not false, it's an error message
                $cp_error[] = $cp_result;
            }
        }
        $this->db->sql_freeresult($result);
    }
Exemple #2
0
    /**
     * Determine whether the user is allowed to read and/or moderate the forum of the topic
     *
     * @param	array	$topic_ids	Array with the topic ids
     *
     * @return	array		Returns an array with two keys 'm_' and 'read_f' which are also an array of topic_id => forum_id sets when the permissions are given. Sample:
     *						array(
     *							'permission' => array(
     *								topic_id => forum_id
     *							),
     *						),
     */
    protected function get_topic_auth(array $topic_ids)
    {
        $forum_auth = array('f_read' => array(), 'm_' => array());
        $topic_ids = array_unique($topic_ids);
        $sql = 'SELECT topic_id, forum_id
			FROM ' . TOPICS_TABLE . '
			WHERE ' . $this->db->sql_in_set('topic_id', array_map('intval', $topic_ids));
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $row['topic_id'] = (int) $row['topic_id'];
            $row['forum_id'] = (int) $row['forum_id'];
            if ($this->auth->acl_get('f_read', $row['forum_id'])) {
                $forum_auth['f_read'][$row['topic_id']] = $row['forum_id'];
            }
            if ($this->auth->acl_gets('a_', 'm_', $row['forum_id'])) {
                $forum_auth['m_'][$row['topic_id']] = $row['forum_id'];
            }
        }
        $this->db->sql_freeresult($result);
        return $forum_auth;
    }