/** * Returns an instance of class (singleton pattern implementation). * * @return BOL_ThemeDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Cron function. */ public function checkUpdates() { if (defined('OW_PLUGIN_XP')) { return; } $pluginsRequestArray = array(array('key' => 'core', 'developerKey' => 'ow', 'build' => OW::getConfig()->getValue('base', 'soft_build'))); $plugins = $this->pluginDao->findRegularPlugins(); /* @var $plugin BOL_Plugin */ foreach ($plugins as $plugin) { $pluginsRequestArray[] = array('key' => $plugin->getKey(), 'developerKey' => $plugin->getDeveloperKey(), 'build' => $plugin->getBuild()); } $themesRequestArray = array(); $themes = $this->themeDao->findAll(); /* @var $theme BOL_Theme */ foreach ($themes as $theme) { $themesRequestArray[] = array('key' => $theme->getName(), 'developerKey' => $theme->getDeveloperKey(), 'build' => $theme->getBuild()); } $event = new OW_Event('base.on_plugin_info_update'); OW::getEventManager()->trigger($event); $data = $event->getData(); if (empty($data)) { $data = array(); } $requestUrl = OW::getRequest()->buildUrlQueryString(self::UPDATE_SERVER . 'get-items-update-info/'); $postParams = array_merge(array('plugins' => urlencode(json_encode($pluginsRequestArray)), 'themes' => urlencode(json_encode($themesRequestArray)))); $postdata = http_build_query($postParams); $options = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); $context = stream_context_create($options); $resultArray = json_decode(file_get_contents($requestUrl, false, $context), true); if (empty($resultArray) || !is_array($resultArray)) { return; } if (!empty($resultArray['plugins']) && is_array($resultArray['plugins'])) { foreach ($plugins as $plugin) { if (in_array($plugin->getKey(), $resultArray['plugins']) && (int) $plugin->getUpdate() === 0) { $plugin->setUpdate(1); $this->pluginDao->save($plugin); } } if (in_array('core', $resultArray['plugins'])) { OW::getConfig()->saveConfig('base', 'update_soft', 1); } } if (!empty($resultArray['themes']) && is_array($resultArray['themes'])) { foreach ($themes as $theme) { if (in_array($theme->getName(), $resultArray['themes']) && (int) $theme->getUpdate() === 0) { $theme->setUpdate(1); $this->themeDao->save($theme); } } } }
public function getThemesToUpdateCount() { return $this->themeDao->findThemesForUpdateCount(); }
/** * Returns themes with invalid license key * * @return array */ public function findItemsWithInvalidLicense() { return $this->themeDao->findItemsWithInvalidLicense(); }