public static function install($key) { global $lC_Database, $lC_Language, $lC_Vqmod, $lC_Addons; $isTemplate = strstr($key, 'lC_Template_') ? true : false; if ($isTemplate) { $key = str_replace('lC_Template_', '', $key); if (!file_exists(DIR_FS_ADMIN . 'includes/templates/' . $key . '.php')) { // get the addon phar from the store self::getAddonPhar($key, 'template'); // apply the addon phar if (file_exists(DIR_FS_WORK . 'addons/' . $key . '.phar')) { lC_Updates_Admin::applyPackage(DIR_FS_WORK . 'addons/' . $key . '.phar', 'template'); } } self::_resetAddons(); return true; } else { // is addon or language if (!file_exists(DIR_FS_CATALOG . 'addons/' . $key . '/controller.php')) { // get the addon phar from the store self::getAddonPhar($key); $phar = new Phar(DIR_FS_WORK . 'addons/' . $key . '.phar', 0); $meta = $phar->getMetadata(); // apply the addon phar if (file_exists(DIR_FS_WORK . 'addons/' . $key . '.phar')) { lC_Updates_Admin::applyPackage(DIR_FS_WORK . 'addons/' . $key . '.phar'); } if ($meta['type'] == 'language') { return true; } } // sanity check to see if the object is already installed $okToInstall = true; $Qchk = $lC_Database->query("select id from :table_templates_boxes where modules_group LIKE '%" . $key . "%'"); $Qchk->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qchk->execute(); if ($Qchk->numberOfRows() > 0) { $okToInstall = false; } $Qchk->freeResult(); if (file_exists(DIR_FS_CATALOG . 'addons/' . $key . '/controller.php') && $okToInstall === true) { include_once DIR_FS_CATALOG . 'addons/' . $key . '/controller.php'; $addon = $key; $addon = new $addon(); $modules_group = $addon->getAddonType() . '|' . $key; $addon->install(); $code = $addon->getAddonType(); $title = $addon->getAddonTitle(); // check for payment or shipping modules and adjust addon $code to module $code if (is_dir(DIR_FS_CATALOG . 'addons/' . $addon->getAddonCode() . '/modules/payment/')) { $lC_DirectoryListing = new lC_DirectoryListing(DIR_FS_CATALOG . 'addons/' . $addon->getAddonCode() . '/modules/payment/'); $lC_DirectoryListing->setCheckExtension('php'); foreach ($lC_DirectoryListing->getFiles() as $ao) { if (isset($ao['name'])) { $code = substr($ao['name'], 0, strpos($ao['name'], '.')); $title = str_replace('_', ' ', $key); $modules_group = 'payment|' . $key; break; } } } else { if (is_dir(DIR_FS_CATALOG . 'addons/' . $addon->getAddonCode() . '/modules/shipping/')) { $lC_DirectoryListing = new lC_DirectoryListing(DIR_FS_CATALOG . 'addons/' . $addon->getAddonCode() . '/modules/shipping/'); $lC_DirectoryListing->setCheckExtension('php'); foreach ($lC_DirectoryListing->getFiles() as $ao) { if (isset($ao['name'])) { $code = substr($ao['name'], 0, strpos($ao['name'], '.')); $title = str_replace('_', ' ', $key); $modules_group = 'shipping|' . $key; break; } } } } if (empty($code) === false) { $Qdel = $lC_Database->query('delete from :table_templates_boxes where modules_group = :modules_group'); $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qdel->bindValue(':modules_group', $modules_group); $Qdel->execute(); $Qinstall = $lC_Database->query('insert into :table_templates_boxes (title, code, author_name, author_www, modules_group) values (:title, :code, :author_name, :author_www, :modules_group)'); $Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); $Qinstall->bindValue(':title', $title); $Qinstall->bindValue(':code', $code); $Qinstall->bindValue(':author_name', $addon->getAddonAuthor()); $Qinstall->bindValue(':author_www', $addon->getAddonAuthorWWW()); $Qinstall->bindValue(':modules_group', $modules_group); $Qinstall->execute(); self::_resetAddons(); return true; } } } return false; }
public static function verifyProductsAreDownloaded($products) { $productsArr = explode('|', $products); $cnt = 0; foreach ($productsArr as $key => $product) { $parts = explode(':', $product); $type = $parts[0]; $item = $parts[1]; if ($type == 'template') { if (!file_exists(DIR_FS_ADMIN . 'includes/templates/' . $item . '.php')) { // get the template phar and apply it } } else { // addon if (!file_exists(DIR_FS_CATALOG . 'addons/' . $item . '/controller.php')) { // download the addon phar lC_Store_Admin::getAddonPhar($item); // apply the phar package if (file_exists(DIR_FS_WORK . 'addons/' . $item . '.phar')) { lC_Updates_Admin::applyPackage(DIR_FS_WORK . 'addons/' . $item . '.phar'); } } } $cnt++; } }
/** * Deploy the update package * * @access public * @return json */ public static function installUpdate() { if (lC_Updates_Admin::applyPackage()) { $result['rpcStatus'] = RPC_STATUS_SUCCESS; } echo json_encode($result); }