HEX
Server: Apache/2.4.25
System: Linux ion14 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64
User: (10087)
PHP: 7.4.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,system, exec, shell_exec, passthru, popen, proc_open
Upload Files
File: /home/www/web115/wordpress/wp-content/plugins/digimember/system/model/data/arcf_links.php
<?php

class ncore_ArcfLinksData extends ncore_BaseData
{

    public function set(  $fieldData )
    {
        $where = array(
            'autoresponder'    => $fieldData['autoresponder'],
            'customfield'    => $fieldData['customfield'],
        );

        $row = $this->getWhere( $where );
        if ($row)
        {
            if ($fieldData && is_array($fieldData))
            {
                $data = array();
                foreach ($fieldData as $fieldKey => $fieldValue) {
                    $data[$fieldKey] = $fieldValue;
                }
                $this->update( $row->id, $data );
            }
            else
            {
                $this->delete( $row->id );
            }
        }
        elseif ($fieldData && is_array($fieldData))
        {
            $data = array();
            foreach ($fieldData as $fieldKey => $fieldValue) {
                $data[$fieldKey] = $fieldValue;
            }
            return $this->create( $data );
        }
    }

    public function getAllForAr($id) {
        return $this->getAll(array(
            'autoresponder' => $id
        ));
    }

    public function getAllForCf($id) {
        return $this->getAll(array(
            'customfield' => $id
        ));
    }

    public function getArListByCf($id) {
        $providerList = array();
        $arLibrary = $this->api->load->library( 'autoresponder_handler' );
        $allProviders = $arLibrary->getProviders();
        $arObjects = $this->getAllForCf($id);
        foreach ($arObjects as $arObject) {
            if ($arId = ncore_retrieve($arObject,'autoresponder', false)) {
                $autoresponderPlugin = $arLibrary->plugin($arId);
                $engineName = $autoresponderPlugin->getEngine();
                if ($providerName = ncore_retrieve($allProviders, $engineName, false)) {
                    $providerList[] = $providerName;
                }
            }
        }
        if (count($providerList) > 0) {
            $output = '<p>';
            $output .= implode('</p><p>',$providerList);
            $output .= '</p>';
            return $output;
        }
        return '<p>'._ncore('none').'</p>';
    }

    public function deleteByArAndCf($ar_id, $cf_id) {
        $link = $this->getWhere(array(
            'autoresponder' => $ar_id,
            'customfield' => $cf_id
        ));
        if ($link) {
            $this->delete($link->id);
        }
    }

    public function dataType()
    {
        return NCORE_MODEL_DATA_TYPE_ARCFLINK;
    }

    protected function sqlBaseTableName()
    {
        return 'arcf_links';
    }

    protected function sqlTableMeta()
    {
       $columns = array(
            'autoresponder' => 'int',
            'customfield' => 'int',
            'mapping'    => 'string[63]',
       );

       $indexes = array();

       $meta = array(
           'columns' => $columns,
           'indexes' => $indexes,
       );

       return $meta;
    }

    /**
     * createTableIfNeeded
     * creates table of the model when called and the table doesnt exist.
     * @return bool
     */
    public function createTableIfNeeded() {
        global $wpdb;
        $table_name = $this->sqlTableName();
        $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
        if ( ! $wpdb->get_var( $query ) == $table_name ) {
            $initCore = $this->api->init();
            $initCore->forceUpgrade();
            return true;
        }
        return false;
    }

}