<?php
/**
 * @package embed-sharepoint-onedrive-documents
 * @author miniOrange
 * @link https://plugins.miniorange.com
 */


namespace MoSharePointObjectSync\API;

use MoSharePointObjectSync\Wrappers\pluginConstants;
use MoSharePointObjectSync\Wrappers\wpWrapper;
class SyncMOSPS
{
    private static $cron;
    public static function getObserver() : SyncMOSPS
    {
        if (isset(self::$cron)) {
            goto eK;
        }
        self::$cron = new SyncMOSPS();
        eK:
        return self::$cron;
    }
    public function mo_sps_sync_doc_schedule($FE)
    {
        $lA = wpWrapper::mo_sps_get_option(pluginConstants::SYNC_INTERVAL);
        if (!empty($lA)) {
            goto Ib;
        }
        $lA = 30;
        Ib:
        $FE["\155\x6f\x5f\x73\160\x73\x5f\x73\171\156\143\137\x64\157\x63"] = array("\x69\156\164\145\x72\166\x61\x6c" => 60 * $lA, "\144\x69\x73\160\x6c\x61\171" => __("\x53\150\x61\x72\x65\120\x6f\x69\156\164\40\x53\x79\x6e\143"));
        return $FE;
    }
    public function mo_sps_cron_custom_schedule($FE)
    {
        $DG = wpWrapper::mo_sps_get_option("\155\x65\144\x69\141\x5f\x6c\151\142\x5f\x73\171\156\x63\x5f\143\157\x6e\x66\151\147");
        $km = isset($DG["\x73\x79\156\143\137\151\x6e\x74\145\x72\x76\x61\x6c"]) ? $DG["\x73\x79\x6e\143\137\151\x6e\x74\x65\162\x76\x61\154"] : '';
        if (empty($km)) {
            goto gn;
        }
        $FE["\155\x6f\137\163\x70\163\137\x73\171\156\x63\x5f\x64\157\x63"] = array("\x69\x6e\164\145\x72\x76\x61\x6c" => $km * 60, "\x64\x69\163\x70\154\x61\171" => __("\120\162\x6f\166\151\163\151\157\156\x69\x6e\147\x20\x6d\x65\x64\x69\x61\40\x73\x79\156\143"));
        $FE["\x6d\157\x5f\x73\x70\163\137\x6d\x65\144\x69\x61\x5f\x63\x68\x69\x6c\x64"] = array("\x69\x6e\164\x65\162\166\x61\154" => 60, "\x64\151\x73\x70\154\141\171" => __("\x50\162\x6f\x76\151\x73\151\157\x6e\x69\x6e\x67\x20\x6d\145\x64\x69\141\x20\143\x68\151\154\x64\x20\x73\x79\x6e\143"));
        gn:
        return $FE;
    }
    public function mo_sps_sync_doc_action($ki, $Bs)
    {
        $QC = wpWrapper::mo_sps_get_option(pluginConstants::APP_CONFIG);
        $QC = !empty($QC) ? $QC : array();
        $Gi = Azure::getClient($QC);
        $Gi->mo_sps_sync_doc_media_lib();
    }
    public function mo_sps_folder_sync_action($Vb)
    {
        $QC = wpWrapper::mo_sps_get_option(pluginConstants::APP_CONFIG);
        $QC = !empty($QC) ? $QC : array();
        $Gi = Azure::getClient($QC);
        $Gi->mo_sps_sync_folder_files_in_media($Vb);
    }
    public function mo_sps_generate_url()
    {
        $v1 = $_GET["\146\x69\154\x65\x5f\151\144"];
        $hn = $_GET["\x64\x72\151\166\145\x5f\x69\144"];
        $KY = wpWrapper::mo_sps_get_option(pluginConstants::APP_CONFIG);
        if (!(!$KY || empty($KY))) {
            goto Um;
        }
        return;
        Um:
        $Gi = Azure::getClient($KY);
        $KY = $Gi->mo_sps_get_file_download_url($v1, $hn);
        $K7 = file_get_contents($KY["\144\x6f\167\156\154\157\x61\144\x5f\x75\x72\154"]);
        header("\103\157\x6e\164\x65\156\x74\x2d\164\x79\x70\145\72" . $KY["\146\x69\154\145\x5f\x74\x79\160\145"]);
        echo $K7;
        exit;
    }
}
