Ejemplo n.º 1
0
 /**
  * @param $tablename
  * @param bool $networkwide
  */
 public function createTable($tablename, $networkwide = false)
 {
     global $wpdb;
     $query = '
     CREATE TABLE IF NOT EXISTS `%s` (
       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
       `priority` int(11) NOT NULL,
       `message` varchar(255) CHARACTER SET utf8 NOT NULL,
       `type` smallint(4) NOT NULL,
       `timestamp` datetime NOT NULL,
       `extra` longtext COLLATE utf8_unicode_ci NOT NULL,
       PRIMARY KEY (`id`)
     );
     ';
     if (!$networkwide) {
         // single blog installation
         $wpdb->query(sprintf($query, $wpdb->prefix . $tablename));
     } else {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $wpdb->query(sprintf($query, $wpdb->prefix . $tablename));
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager $pm
  * @param $networkwide
  * @return mixed
  */
 public function execute(IfwPsn_Wp_Plugin_Manager $pm, $networkwide = false)
 {
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $this->_refreshPresentVersion($pm);
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         $this->_refreshPresentVersion($pm);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param IfwPsn_Wp_Plugin_Manager|null $pm
  * @return mixed|void
  */
 public static function execute($pm)
 {
     if (!$pm instanceof IfwPsn_Wp_Plugin_Manager) {
         return;
     }
     if (IfwPsn_Wp_Proxy_Blog::isMultisite()) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $pm->getOptions()->reset();
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         $pm->getOptions()->reset();
     }
 }
Ejemplo n.º 4
0
 /**
  * @param bool $networkwide
  */
 public function execute($networkwide = false)
 {
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         // get the current blog id
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         // loop through all blogs
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             // execute networkwide task
             $this->_execute();
         }
         // switch back to current blog
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // no network found or no networkwide execution requested
         // execute single blog task
         $this->_execute();
     }
 }
Ejemplo n.º 5
0
 /**
  * (non-PHPdoc)
  * @see IfwPsn_Wp_Plugin_Installer_ActivationInterface::execute()
  */
 public function execute(IfwPsn_Wp_Plugin_Manager $pm, $networkwide = false)
 {
     if ($pm->isPremium() && IfwPsn_Wp_Proxy_Blog::isPluginActive('post-status-notifier-lite/post-status-notifier-lite.php')) {
         trigger_error(sprintf(__('The Lite version of this plugin is still activated. Please deactivate it! Refer to the <a href=\\"%s\\">Upgrade Howto</a>.', 'psn'), 'http://docs.ifeelweb.de/post-status-notifier/upgrade_howto.html'));
     }
     $this->_dbPatcher = new Psn_Patch_Database();
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             // give every site in the network the default time limit of 30 seconds
             set_time_limit(30);
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             $this->_createTable();
             $this->_presetOptions($pm);
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         $this->_createTable();
         $this->_presetOptions($pm);
     }
 }
Ejemplo n.º 6
0
 /** (non-PHPdoc)
  * @see IfwPsn_Wp_Plugin_Installer_UninstallInterface::execute()
  */
 public static function execute($pm, $networkwide = false)
 {
     // handle the DB
     if (IfwPsn_Wp_Proxy_Blog::isMultisite() && $networkwide == true) {
         // multisite installation
         $currentBlogId = IfwPsn_Wp_Proxy_Blog::getBlogId();
         foreach (IfwPsn_Wp_Proxy_Blog::getMultisiteBlogIds() as $blogId) {
             IfwPsn_Wp_Proxy_Blog::switchToBlog($blogId);
             self::_dropTable($pm);
         }
         IfwPsn_Wp_Proxy_Blog::switchToBlog($currentBlogId);
     } else {
         // single blog installation
         self::_dropTable($pm);
     }
     // remove update action
     if ($pm->getConfig()->plugin->autoupdate == 1) {
         IfwPsn_Wp_Proxy_Action::remove('in_plugin_update_message-' . $pm->getPathinfo()->getFilenamePath(), array($pm->getBootstrap()->getUpdateManager(), 'onPluginUpdateMessage'), 10, 3);
         IfwPsn_Wp_Proxy_Filter::remove('pre_set_site_transient_update_plugins', array($pm->getBootstrap()->getUpdateManager(), 'checkForPremiumUpdate'));
         if ($pm->isPremium()) {
             IfwPsn_Wp_Proxy_Filter::remove('plugins_api', array($pm->getBootstrap()->getUpdateManager(), 'getPluginInfo'), 10, 3);
         }
     }
 }