$configRemove[] = array('key' => $value['key'], 'plugin' => $value['plugin']); } try { $update->save(); } catch (Exception $ex) { } } $sql = 'SELECT * FROM config WHERE `key` = "installVersionDate"'; $values = DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL); foreach ($values as $value) { $update = new update(); if ($value['plugin'] != '') { $update->setLogicalId($value['plugin']); $update->setLocalVersion($value['value']); $update->setType('plugin'); try { $update->save(); $configRemove[] = array('key' => "installVersionDate", 'plugin' => $value['plugin']); } catch (Exception $ex) { } } } foreach ($configRemove as $remove) { if (isset($remove['plugin'])) { config::remove($remove['key'], $remove['plugin']); } else { config::remove($remove['key']); } }
public function save() { $cache = cache::byKey('market::info::' . $this->getLogicalId()); if (is_object($cache)) { $cache->remove(); } $market = self::getJsonRpc(); $params = utils::o2a($this); if (isset($params['changelog'])) { unset($params['changelog']); } switch ($this->getType()) { case 'plugin': $cibDir = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId(); if (file_exists($cibDir)) { rrmdir($cibDir); } mkdir($cibDir); $exclude = array('tmp'); rcopy(realpath(dirname(__FILE__) . '/../../plugins/' . $this->getLogicalId()), $cibDir, true, $exclude, true); $tmp = dirname(__FILE__) . '/../../tmp/' . $this->getLogicalId() . '.zip'; if (file_exists($tmp)) { if (!unlink($tmp)) { throw new Exception(__('Impossible de supprimer : ', __FILE__) . $tmp . __('. Vérifiez les droits', __FILE__)); } } if (!create_zip($cibDir, $tmp)) { throw new Exception(__('Echec de création de l\'archive zip', __FILE__)); } break; default: $type = $this->getType(); if (!class_exists($type) || !method_exists($type, 'shareOnMarket')) { throw new Exception(__('Aucune fonction correspondante à : ', __FILE__) . $type . '::shareOnMarket'); } $tmp = $type::shareOnMarket($this); break; } if (!file_exists($tmp)) { throw new Exception(__('Impossible de trouver le fichier à envoyer : ', __FILE__) . $tmp); } $file = array('file' => '@' . realpath($tmp)); if (!$market->sendRequest('market::save', $params, 30, $file)) { throw new Exception($market->getError()); } $update = update::byTypeAndLogicalId($this->getType(), $this->getLogicalId()); if (!is_object($update)) { $update = new update(); $update->setLogicalId($this->getLogicalId()); $update->setType($this->getType()); } $update->setConfiguration('version', 'beta'); $update->setLocalVersion(date('Y-m-d H:i:s', strtotime('+10 minute' . date('Y-m-d H:i:s')))); $update->save(); $update->checkUpdate(); }
public static function findNewUpdateObject() { foreach (plugin::listPlugin() as $plugin) { $plugin_id = $plugin->getId(); $update = self::byTypeAndLogicalId('plugin', $plugin_id); if (!is_object($update)) { $update = new update(); $update->setLogicalId($plugin_id); $update->setType('plugin'); $update->setLocalVersion(date('Y-m-d H:i:s')); $update->save(); } $find = array(); if (method_exists($plugin_id, 'listMarketObject')) { foreach ($plugin_id::listMarketObject() as $logical_id) { $find[$logical_id] = true; $update = self::byTypeAndLogicalId($plugin_id, $logical_id); if (!is_object($update)) { $update = new update(); $update->setLogicalId($logical_id); $update->setType($plugin_id); $update->setLocalVersion(date('Y-m-d H:i:s')); $update->save(); } } foreach (self::byType($plugin_id) as $update) { if (!isset($find[$update->getLogicalId()])) { $update->remove(); } } } else { $values = array('type' => $plugin_id); $sql = 'DELETE FROM `update` WHERE type=:type'; DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW); } } }