Collections functions
General functions
Render functions
Theme permission functions
Resource functions

create_tab()

Description

Create a new system tab record
NOTE: order_by should only be set when re-ordering the set by the user. {@see sql_reorder_records('tab', $refs)}

Parameters

ColumnTypeDefaultDescription
$tab array

Return

bool|int Return new tab record ID or FALSE otherwise

Location

include/tab_functions.php lines 119 to 144

Definition

 
function create_tab(array $tab)
    {
    
$name trim($tab['name'] ?? '');
    if(
$name !== '' && acl_can_manage_tabs())
        {
        
ps_query('
            INSERT INTO tab (`name`, order_by)
                     VALUES (
                        ?,
                        (
                            SELECT * FROM (
                                (SELECT ifnull(tab.order_by, 0) + 10 FROM tab ORDER BY ref DESC LIMIT 1)
                                UNION SELECT 10
                            ) AS nob
                            LIMIT 1
                        ))'
,
             [
's'$name]
         );
        
$ref sql_insert_id();
        
log_activity(nullLOG_CODE_CREATED$name'tab''name'$ref);

        return 
$ref;
        }

    return 
false;
    }

This article was last updated 26th September 2022 14:35 Europe/London time based on the source file dated 30th June 2022 11:10 Europe/London time.