public function Install() { $tables = $sequences = array(); $this->Process("installer", "GetApi", "installer")->install($this->addon_name); $this->db->StartTransaction(); require dirname(__FILE__) . '/schema.' . SENDSTUDIO_DATABASE_TYPE . '.php'; foreach ($queries as $query) { $qry = str_replace('%%TABLEPREFIX%%', $this->db->TablePrefix, $query); $result = $this->db->Query($qry); if (!$result) { $this->db->RollbackTransaction(); throw new Interspire_Addons_Exception("There was a problem running query " . $qry . ": " . $this->db->GetErrorMsg(), Interspire_Addons_Exception::DatabaseError); } } $this->enabled = true; $this->configured = true; try { $status = parent::Install(); } catch (Interspire_Addons_Exception $e) { $this->db->RollbackTransaction(); throw new Exception("Unable to install addon {$this->GetId()} " . $e->getMessage()); } $this->db->CommitTransaction(); return true; }
/** * Install * This addon has no settings to it can automatically be configured and enabled when it's installed * * @uses enabled * @uses configured * @uses Interspire_Addons::Install * @uses Interspire_Addons_Exception * * @throws Throws an Interspire_Addons_Exception if something in the install process fails. * @return True Returns true if everything works ok. */ public function Install() { $this->enabled = true; $this->configured = true; try { $status = parent::Install(); } catch (Interspire_Addons_Exception $e) { throw new Exception("Unable to install addon {$this->GetId()} " . $e->getMessage()); } return true; }
public function Install() { $tables = $sequences = array(); if (!$this->isEnabled("installer")) { throw new Interspire_Addons_Exception("The Addon (Advanced Addons Installer) is required", Interspire_Addons_Exception::AddonDoesntExist); } else { $this->Process("installer", "GetApi", "installer")->install($this->addon_name); } $this->db->StartTransaction(); require dirname(__FILE__) . '/schema.' . SENDSTUDIO_DATABASE_TYPE . '.php'; foreach ($queries as $query) { $qry = str_replace('%%TABLEPREFIX%%', $this->db->TablePrefix, $query); $result = $this->db->Query($qry); if (!$result) { $this->db->RollbackTransaction(); throw new Interspire_Addons_Exception("There was a problem running query " . $qry . ": " . $this->db->GetErrorMsg(), Interspire_Addons_Exception::DatabaseError); } } $this->enabled = true; $this->configured = true; try { $status = parent::Install(); } catch (Interspire_Addons_Exception $e) { $this->db->RollbackTransaction(); throw new Exception("Unable to install addon {$this->GetId()} " . $e->getMessage()); } $this->db->CommitTransaction(); $result = $this->db->Query("SELECT method FROM " . SENDSTUDIO_TABLEPREFIX . "fbl LIMIT 1"); if (!$result) { $result = $this->db->Query("ALTER TABLE `" . SENDSTUDIO_TABLEPREFIX . "fbl` ADD `method` INT( 11 ) NOT NULL DEFAULT '1'"); } $result = $this->db->Query("SELECT fbl FROM " . SENDSTUDIO_TABLEPREFIX . "list_subscribers LIMIT 1"); if (!$result) { $result = $this->db->Query("ALTER TABLE `" . SENDSTUDIO_TABLEPREFIX . "list_subscribers` ADD `fbl` INT( 11 ) NOT NULL DEFAULT '0'"); } $result = $this->db->Query("SELECT fbl FROM " . SENDSTUDIO_TABLEPREFIX . "list_subscribers_unsubscribe LIMIT 1"); if (!$result) { $result = $this->db->Query("ALTER TABLE `" . SENDSTUDIO_TABLEPREFIX . "list_subscribers_unsubscribe` ADD `fbl` INT( 11 ) NOT NULL DEFAULT '0'"); } $result = $this->db->Query("SELECT fbl FROM " . SENDSTUDIO_TABLEPREFIX . "stats_newsletters LIMIT 1"); if (!$result) { $result = $this->db->Query("ALTER TABLE `" . SENDSTUDIO_TABLEPREFIX . "stats_newsletters` ADD `fbl` INT( 11 ) NOT NULL DEFAULT '0'"); } return true; }
/** * Install * This is called when the addon is installed in the main application. * In this case, it simply sets the default settings and then calls the parent install method to add itself to the database. * * @uses default_settings * @uses Interspire_Addons::Install * @uses Interspire_Addons_Exception * * @throws Throws an Interspire_Addons_Exception if something goes wrong with the install process. * @return True Returns true if all goes ok with the install. */ public function Install() { $this->settings = $this->default_settings; $this->db->StartTransaction(); $prefix = $this->db->TablePrefix; $query = "SHOW TABLES LIKE '{$prefix}surveys'"; $result = $this->db->Query($query); $row = $this->db->Fetch($result); if (empty($row)) { require_once dirname(__FILE__) . '/schema.' . SENDSTUDIO_DATABASE_TYPE . '.php'; foreach ($queries as $query) { $qry = str_replace('%%TABLEPREFIX%%', $this->db->TablePrefix, $query); $result = $this->db->Query($qry); if (!$result) { throw new Interspire_Addons_Exception("Unable to install addon, query failed: " . $qry); } } } $this->enabled = true; $this->configured = true; try { $status = parent::Install(); } catch (Interspire_Addons_Exception $e) { throw new Exception("Unable to install addon {$this->GetId}();" . $e->getMessage()); } $this->db->CommitTransaction(); return true; }