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/mail_text.php
<?php

class ncore_MailTextData extends ncore_BaseData
{
    public function getForHook( $hook, $ref_id )
    {
        $ref_id = ncore_washInt( $ref_id );

        $where = array(
            'hook' => $hook,
            'ref_id' => $ref_id,
        );

        $mail_text = $this->getWhere( $where );

        if ($mail_text)
        {
            return $mail_text;
        }

        /** @var digimember_MailHookLogic $model */
        $model = $this->api->load->model( 'logic/mail_hook' );
        list( $subject, $message ) = $model->defaultMailText( $hook );

        $data = $where;
        $data['subject'] = $subject;
        $data['body_html'] = $message;
        $id = $this->create( $data );

        $obj = $this->get( $id );

        return $obj;
    }

    public function getForProductId( $ref_id )
    {
        $ref_id = ncore_washInt( $ref_id );
        $where = array(
            'ref_id' => $ref_id,
        );
        $mail_text_data = $this->getWhere( $where );
        if ($mail_text_data)
        {
            return $mail_text_data;
        }
        return false;
    }

    public function copyForProduct($fromProduct, $toProduct) {
        $mailText = $this->getForProductId($fromProduct);
        if ($mailText) {
            $copy['subject'] = $mailText->subject;
            $copy['body_html'] = $mailText->body_html;
            $copy['hook'] = $mailText->hook;
            $copy['send_policy'] = $mailText->send_policy;
            $copy['attachment'] = $mailText->attachment;
            $copy['ref_id'] = $toProduct;
            $copy['table'] = $mailText->table;
            $copy['status'] = $mailText->status;
            $this->create($copy);
        }
    }

    public function setForHook( $hook, $ref_id, $subject, $message )
    {
        $obj = $this->getForHook( $hook, $ref_id );

        $id = $obj->id;

        $data = array(
            'subject'   => $subject,
            'body_html' => $message,
        );

        return $this->update( $id, $data );
    }

    //
    // protected section
    //
    protected function isUniqueInBlog() {

        return true;
    }

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

    protected function sqlTableMeta()
    {
       $columns = array(
        'subject' => 'string[255]',
        'body_html' => 'longtext',
        'hook' => 'string[31]',
        'send_policy' => 'string[31]',
        'attachment' => 'string[255]',
        'ref_id' => 'id',
       );

       $indexes = array( 'ref_id', 'hook' );

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

       return $meta;
    }

    public function addAttachmentIfNeeded() {
        $row = false;
        global $wpdb;
        $table_name = $this->sqlTableName();
        $row = $wpdb->get_results(  "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '".$table_name."' AND column_name = 'attachment'"  );
        if ( is_array($row) && count($row) < 1 ) {
            $initCore = $this->api->init();
            $initCore->forceUpgrade();
            return true;
        }
        return false;
    }

}