Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 143

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 19th March 2024 02:35 Europe/London time based on the source file dated 18th August 2023 11:35 Europe/London time.