Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 116 to 140

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 17th November 2024 15:05 Europe/London time based on the source file dated 16th May 2024 18:10 Europe/London time.