Skip to content
Browse files

updated

  • Loading branch information...
1 parent 7400add commit 392b812e834071ad7a032766eefd76e92a001483 @silentworks committed Oct 6, 2011
Showing with 55 additions and 18 deletions.
  1. +0 −5 disable.php
  2. +8 −3 enable.php
  3. +28 −0 sql/uninstall.sql
  4. +13 −6 uninstall.php
  5. +6 −4 utils.php
View
5 disable.php
@@ -9,10 +9,5 @@
* and GPL (license/gpl-license.txt) licenses.
*/
-/**
- * Security measure for Wolf 0.7.0+
- */
-include_once TAGGER_ROOT . "security.php";
-
Flash::set('success', __('Tagger: Successfully disabled plugin.'));
redirect(get_url('setting'));
View
11 enable.php
@@ -12,18 +12,23 @@
/**
* Tagger Utils
*/
-include_once TAGGER_ROOT . "utils.php";
+$tagger_dir = dirname(__FILE__) . '/';
+include_once $tagger_dir . "utils.php";
$PDO = Record::getConnection();
$driver = strtolower($PDO->getAttribute(Record::ATTR_DRIVER_NAME));
if ($driver == 'mysql') {
$query = $PDO->query("SELECT * FROM ".TABLE_PREFIX."page WHERE behavior_id = 'tagger'");
-
if(!$query->rowCount()){
// Create Pages
- executioner(file(dirname(__file__) . '/sql/install.sql'), TABLE_PREFIX);
+ executioner(
+ file($tagger_dir . 'sql/install.sql'),
+ array(
+ '{prefix}' => TABLE_PREFIX
+ )
+ );
}
}
View
28 sql/uninstall.sql
@@ -0,0 +1,28 @@
+# Sequel Pro dump
+# Version 2492
+# http://code.google.com/p/sequel-pro
+#
+# Host: 127.0.0.1 (MySQL 5.1.52)
+# Database: wolf
+# Generation Time: 2010-12-28 19:20:46 +0000
+# ************************************************************
+
+
+# Dump of table wlf_page
+# ------------------------------------------------------------
+
+DELETE FROM `{prefix}page` WHERE `behavior_id` = 'tagger';
+
+
+# Dump of table wlf_page_part
+# ------------------------------------------------------------
+
+DELETE FROM `{prefix}page_part` WHERE `page_id` = '{page_id}';
+
+
+# Dump of table wlf_snippet
+# ------------------------------------------------------------
+
+DELETE FROM `{prefix}snippet` WHERE `name` = 'tags';
+DELETE FROM `{prefix}snippet` WHERE `name` = 'tagger_tpl_default';
+DELETE FROM `{prefix}snippet` WHERE `name` = 'tagger_tpl_count';
View
19 uninstall.php
@@ -12,6 +12,9 @@
/**
* Security measure for Wolf 0.7.0+
*/
+$tagger_dir = dirname(__FILE__) . '/';
+include_once $tagger_dir . "utils.php";
+
$PDO = Record::getConnection();
$driver = strtolower($PDO->getAttribute(Record::ATTR_DRIVER_NAME));
if ($driver == 'mysql')
@@ -21,18 +24,22 @@
if($query->rowCount())
{
$page = $query->fetch(PDO::FETCH_ASSOC);
- var_dump($page); die;
-
- $PDO->exec("DROP FROM ".TABLE_PREFIX."page WHERE page_id = " . $page['id']);
- $PDO->exec("DROP FROM ".TABLE_PREFIX."page WHERE behavior_id = 'tagger'");
+
+ executioner(
+ file($tagger_dir . 'sql/uninstall.sql'),
+ array(
+ '{prefix}' => TABLE_PREFIX,
+ '{page_id}' => $page['id']
+ )
+ );
- if (Plugin::deleteAllSettings('tagger') === false) {
+ /*if (Plugin::deleteAllSettings('tagger') === false) {
Flash::set('error', __('Tagger: Unable to remove plugin settings.'));
redirect(get_url('setting'));
}
else {
Flash::set('success', __('Tagger: Successfully removed plugin settings.'));
redirect(get_url('setting'));
- }
+ }*/
}
}
View
10 utils.php
@@ -3,8 +3,10 @@
* Tagger Utilities
*/
-function executioner($file_path, $table_prefix)
+function executioner($file_path, $params = array())
{
+ $PDO = Record::getConnection();
+
// Temporary variable, used to store current query
$sql = '';
@@ -24,11 +26,11 @@ function executioner($file_path, $table_prefix)
if (substr(trim($line), -1, 1) == ';')
{
// Perform the query
- if ($table_prefix)
+ if (!empty($params))
{
- $sql = str_replace('{prefix}', TABLE_PREFIX, $sql);
+ $sql = str_replace(array_keys($params), $params, $sql);
}
-
+
$PDO->exec($sql) or die('Error performing query \'<strong>' . $sql . '\': ' . mysql_error() . '<br /><br />');
// Reset temp variable to empty
$sql = '';

0 comments on commit 392b812

Please sign in to comment.
Something went wrong with that request. Please try again.