Commit 635d11ec authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Fixed MANTIS-5614 (Smart topic notifications CPF was required when it should not be)

parent 2bb079a1
Loading
Loading
Loading
Loading
+33 −30
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class Module_admin_version
        $info['organisation'] = 'ocProducts';
        $info['hacked_by'] = null;
        $info['hack_version'] = null;
        $info['version'] = 17;
        $info['version'] = 18;
        $info['locked'] = true;
        $info['update_require_upgrade'] = true;
        return $info;
@@ -798,8 +798,7 @@ class Module_admin_version
                    }
                    $start += $max;
                }
            }
            while (count($keywords) > 0);
            } while (count($keywords) > 0);

            $GLOBALS['SITE_DB']->delete_table_field('seo_meta', 'meta_keywords');

@@ -857,7 +856,7 @@ class Module_admin_version

            add_privilege('SUBMISSION', 'edit_meta_fields');
            add_privilege('SUBMISSION', 'perform_webstandards_check_by_default');
            $GLOBALS['FORUM_DRIVER']->install_create_custom_field('smart_topic_notification', 20, /*locked=*/1, /*viewable=*/0, /*settable=*/1, /*required=*/1, '', 'tick', 0, '0');
            $GLOBALS['FORUM_DRIVER']->install_create_custom_field('smart_topic_notification', 20, /*locked=*/1, /*viewable=*/0, /*settable=*/1, /*required=*/0, '', 'tick', 0, '0');

            $GLOBALS['SITE_DB']->create_table('email_bounces', array(
                'id' => '*AUTO',
@@ -993,6 +992,10 @@ class Module_admin_version
            ));
            $GLOBALS['SITE_DB']->create_index('post_tokens', 'generation_time', array('generation_time'));
        }

        if ((!is_null($upgrade_from)) && ($upgrade_from < 18)) { // LEGACY 10.0.46
            $GLOBALS['FORUM_DRIVER']->install_edit_custom_field('smart_topic_notification', 'smart_topic_notification', 20, /*locked=*/1, /*viewable=*/0, /*settable=*/1, /*required=*/0, '', 'tick', 0, '0');
        }
    }

    /**
+41 −0
Original line number Diff line number Diff line
@@ -54,6 +54,47 @@ function _helper_install_create_custom_field($this_ref, $name, $length, $locked
    return !is_null($id);
}

/**
 * Edit a custom profile field.
 *
 * @param  string $old_name The name of the current custom field
 * @param  string $new_name The new name of the custom profile field (blank: do not rename)
 * @param  integer $length The new length of the custom field
 * @param  BINARY $locked Whether the field is locked
 * @param  BINARY $viewable Whether the field is for viewing
 * @param  BINARY $settable Whether the field is for setting
 * @param  BINARY $required Whether the field is required
 * @param  string $description Description
 * @param  string $type The field type
 * @param  BINARY $encrypted Whether the field is encrypted
 * @param  ?string $default Default field value (null: standard for field type)
 * @return boolean Whether the custom field was edited successfully
 * @ignore
 */
function _helper_install_edit_custom_field($this_ref, $old_name, $new_name, $length, $locked = 1, $viewable = 0, $settable = 0, $required = 0, $description = '', $type = 'long_text', $encrypted = 0, $default = null)
{
    cns_require_all_forum_stuff();
    require_code('cns_members_action2');

    $old_name = 'cms_' . $old_name;
    if ($new_name != '') {
        $new_name = 'cms_' . $new_name;
    } else {
        $new_name = 'cms_' . $old_name;
    }

    $id = $this_ref->connection->query_select_value_if_there('f_custom_fields', 'id', array($this_ref->connection->translate_field_ref('cf_name') => $old_name));
    if (!is_null($id)) {
        if (is_null($default)) {
            $default = (strpos($new_name, 'points') !== false) ? '0' : '';
        }
        cns_edit_custom_field($id, $new_name, $description, $default, $viewable, $viewable, $settable, $encrypted, $required, 0, 0, null, '', $type, 0, '');
        return true;
    }

    return false;
}

/**
 * Get an array of attributes to take in from the installer. Almost all forums require a table prefix, which the requirement there-of is defined through this function.
 * The attributes have 4 values in an array
+7 −4
Original line number Diff line number Diff line
@@ -1339,7 +1339,7 @@ function cns_unban_member($member_id)
 * @param  BINARY $required Whether the field is to be shown on the join form
 * @param  BINARY $show_in_posts Whether this field is shown in posts and places where member details are highlighted (such as an image in a member gallery).
 * @param  BINARY $show_in_post_previews Whether this field is shown in preview places, such as in the forum member tooltip.
 * @param  integer $order The order of this field relative to other fields.
 * @param  ?integer $order The order of this field relative to other fields. (null: keep the current order)
 * @param  LONG_TEXT $only_group The usergroups that this field is confined to (comma-separated list).
 * @param  ID_TEXT $type The type of the field.
 * @set    short_text long_text short_trans long_trans integer upload picture url list tick float
@@ -1367,7 +1367,6 @@ function cns_edit_custom_field($id, $name, $description, $default, $public_view,
        'cf_required' => $required,
        'cf_show_in_posts' => $show_in_posts,
        'cf_show_in_post_previews' => $show_in_post_previews,
        'cf_order' => $order,
        'cf_only_group' => $only_group,
        'cf_type' => $type,
        'cf_show_on_join_form' => $show_on_join_form,
@@ -1376,6 +1375,10 @@ function cns_edit_custom_field($id, $name, $description, $default, $public_view,
    $map += lang_remap('cf_name', $_name, $name, $GLOBALS['FORUM_DB']);
    $map += lang_remap('cf_description', $_description, $description, $GLOBALS['FORUM_DB']);

    if ($order !== null) {
        $map['cf_order'] = $order;
    }

    $GLOBALS['FORUM_DB']->query_update('f_custom_fields', $map, array('id' => $id), '', 1);

    require_code('cns_members_action');
+41 −0
Original line number Diff line number Diff line
@@ -112,6 +112,22 @@ class Forum_driver_aef extends Forum_driver_base
        return true;
    }

    /**
     * Edit a custom profile field.
     *
     * @param  string $old_name The name of the current custom field
     * @param  string $new_name The new name of the custom profile field (blank: do not rename)
     * @param  integer $length The new length of the custom field
     * @return boolean Whether the custom field was edited successfully
     */
    public function install_edit_custom_field($old_name, $new_name, $length)
    {
        if ($new_name != '') {
            $this->connection->query('ALTER TABLE ' . $this->connection->get_table_prefix() . 'users RENAME COLUMN cms_' . $old_name . ' TO cms_' . $new_name, null, null, true);
        }
        return true;
    }

    /**
     * Get an array of attributes to take in from the installer. Almost all forums require a table prefix, which the requirement there-of is defined through this function.
     * The attributes have 4 values in an array
@@ -821,6 +837,31 @@ class Forum_driver_aef extends Forum_driver_base
        return $tempid;
    }

    /**
     * Get rows of members after the given one.
     * It cannot be assumed there are no gaps in member IDs, as members may be deleted.
     *
     * @param  ?MEMBER $member_id The member ID to increment (null: find the very first members)
     * @param  integer $total Number of members to retrieve
     * @return array Member rows
     */
    public function get_next_members($member_id, $total = 1)
    {
        // LEGACY
        $sql = 'SELECT * FROM ' . $this->connection->get_table_prefix() . 'users WHERE id<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id());
        $sql .= ' ORDER BY id ASC';
        $rows = $this->connection->query($sql, $total);

        // Reset member row cache to free memory
        unset($this->MEMBER_ROWS_CACHED);
        $this->MEMBER_ROWS_CACHED = [];
        foreach ($rows as $row) {
            $this->MEMBER_ROWS_CACHED[$row['id']] = $row;
        }

        return $rows;
    }

    /**
     * Try to find a member with the given IP address
     *
+54 −0
Original line number Diff line number Diff line
@@ -173,6 +173,28 @@ class Forum_driver_cns extends Forum_driver_base
        return _helper_install_create_custom_field($this, $name, $length, $locked, $viewable, $settable, $required, $description, $type, $encrypted, $default);
    }

    /**
     * Edit a custom profile field.
     *
     * @param  string $old_name The name of the current custom field
     * @param  string $new_name The new name of the custom profile field (blank: do not rename)
     * @param  integer $length The new length of the custom field
     * @param  BINARY $locked Whether the field is locked
     * @param  BINARY $viewable Whether the field is for viewing
     * @param  BINARY $settable Whether the field is for setting
     * @param  BINARY $required Whether the field is required
     * @param  string $description Description
     * @param  string $type The field type
     * @param  BINARY $encrypted Whether the field is encrypted
     * @param  ?string $default Default field value (null: standard for field type)
     * @return boolean Whether the custom field was edited successfully
     */
    public function install_edit_custom_field($old_name, $new_name, $length, $locked = 1, $viewable = 0, $settable = 0, $required = 0, $description = '', $type = 'long_text', $encrypted = 0, $default = null)
    {
        require_code('cns_forum_driver_helper_install');
        return _helper_install_edit_custom_field($this, $old_name, $new_name, $length, $locked, $viewable, $settable, $required, $description, $type, $encrypted, $default);
    }

    /**
     * Get an array of attributes to take in from the installer. Almost all forums require a table prefix, which the requirement there-of is defined through this function.
     * The attributes have 4 values in an array
@@ -957,6 +979,38 @@ class Forum_driver_cns extends Forum_driver_base
        return $tempid;
    }

    /**
     * Get rows of members after the given one.
     * It cannot be assumed there are no gaps in member IDs, as members may be deleted.
     *
     * @param  ?MEMBER $member_id The member ID to increment (null: find the very first members)
     * @param  integer $total Number of members to retrieve
     * @return array Member rows
     */
    public function get_next_members($member_id, $total = 1)
    {
        $sql = 'SELECT * FROM ' . $this->connection->get_table_prefix() . 'f_members WHERE id<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id());
        if ($member_id !== null) {
            $join_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_join_time');
            $sql .= ' AND (m_join_time>' . strval($join_time) . ' OR m_join_time=' . strval($join_time) . ' AND id>' . strval($member_id) . ')';
        }
        $sql .= ' AND ' . db_string_equal_to('m_validated_email_confirm_code', '');
        if (addon_installed('validation')) {
            $sql .= ' AND m_validated=1';
        }
        $sql .= ' ORDER BY m_join_time ASC,id ASC';
        $rows = $this->connection->query($sql, $total);

        // Reset member row cache to free memory
        unset($this->MEMBER_ROWS_CACHED);
        $this->MEMBER_ROWS_CACHED = [];
        foreach ($rows as $row) {
            $this->MEMBER_ROWS_CACHED[$row['id']] = $row;
        }

        return $rows;
    }

    /**
     * Try to find a member with the given IP address
     *
Loading