/**
 * Upgrade routine for 3.3.0
 *
 * @since 3.3.0
 * @return void
 */
function wpas_upgrade_330()
{
    // Add default values for e-mail template when client closes own ticket
    wpas_update_option('enable_closed_client', get_settings_defaults('enable_closed_client'));
    wpas_update_option('subject_closed_client', get_settings_defaults('subject_closed_client'));
    wpas_update_option('content_closed_client', get_settings_defaults('content_closed_client'));
}
Esempio n. 2
0
 function test_default_options()
 {
     if (!function_exists('get_settings_defaults')) {
         require WPAS_PATH . 'includes/admin/settings/functions-settings.php';
     }
     $options = get_option('wpas_options');
     $defaults = serialize(get_settings_defaults());
     $this->assertEquals($defaults, $options);
 }
/**
 * Fired for each blog when the plugin is activated.
 *
 * @since    1.0.0
 */
function wpas_single_activate()
{
    /**
     * Full list of capabilities.
     *
     * This is the full list of capabilities
     * that will be given to administrators.
     *
     * @var array
     */
    $full_cap = apply_filters('wpas_user_capabilities_full', array('view_ticket', 'view_private_ticket', 'edit_ticket', 'edit_other_ticket', 'edit_private_ticket', 'delete_ticket', 'delete_reply', 'delete_private_ticket', 'delete_other_ticket', 'assign_ticket', 'close_ticket', 'reply_ticket', 'settings_tickets', 'ticket_taxonomy', 'create_ticket', 'attach_files'));
    /**
     * Partial list of capabilities.
     *
     * A partial list of capabilities given to agents in addition to
     * the author capabilities. Agents should be used if no other access
     * than the tickets is required.
     *
     * @var array
     */
    $agent_cap = apply_filters('wpas_user_capabilities_agent', array('view_ticket', 'view_private_ticket', 'edit_ticket', 'edit_other_ticket', 'edit_private_ticket', 'assign_ticket', 'close_ticket', 'reply_ticket', 'create_ticket', 'delete_reply', 'attach_files'));
    /**
     * Very limited list of capabilities for the clients.
     */
    $client_cap = apply_filters('wpas_user_capabilities_client', array('view_ticket', 'create_ticket', 'close_ticket', 'reply_ticket', 'attach_files'));
    /* Get roles to copy capabilities from */
    $editor = get_role('editor');
    $author = get_role('author');
    $subscriber = get_role('subscriber');
    $admin = get_role('administrator');
    /* Add the new roles */
    $manager = add_role('wpas_manager', __('Support Supervisor', 'awesome-support'), $editor->capabilities);
    // Has full capabilities for the plugin in addition to editor capabilities
    $tech = add_role('wpas_support_manager', __('Support Manager', 'awesome-support'), $subscriber->capabilities);
    // Has full capabilities for the plugin only
    $agent = add_role('wpas_agent', __('Support Agent', 'awesome-support'), $author->capabilities);
    // Has limited capabilities for the plugin in addition to author's capabilities
    $client = add_role('wpas_user', __('Support User', 'awesome-support'), $subscriber->capabilities);
    // Has posting & replying capapbilities for the plugin in addition to subscriber's capabilities
    /**
     * Add full capacities to admin roles
     */
    foreach ($full_cap as $cap) {
        // Add all the capacities to admin in addition to full WP capacities
        if (null != $admin) {
            $admin->add_cap($cap);
        }
        // Add full plugin capacities to manager in addition to the editor capacities
        if (null != $manager) {
            $manager->add_cap($cap);
        }
        // Add full plugin capacities only to technical manager
        if (null != $tech) {
            $tech->add_cap($cap);
        }
    }
    /**
     * Add limited capacities ot agents
     */
    foreach ($agent_cap as $cap) {
        if (null != $agent) {
            $agent->add_cap($cap);
        }
    }
    /**
     * Add limited capacities to users
     */
    foreach ($client_cap as $cap) {
        if (null != $client) {
            $client->add_cap($cap);
        }
    }
    add_option('wpas_options', serialize(get_settings_defaults()));
    add_option('wpas_setup', 'pending');
    add_option('wpas_redirect_about', true);
    add_option('wpas_support_products', 'pending');
    add_option('wpas_db_version', WPAS_DB_VERSION);
    add_option('wpas_version', WPAS_VERSION);
}