/** * Prepare data for report * * Save list of activated plugins and last activation date, set timer for the specified plugin * * @param string plugin name */ public function initRequest($extension_name) { if ($extension_name == '') { return false; } // get list of active plugins $active_plugins = array(); $extension_model = WPRC_Loader::getModel('extensions'); $active_plugins_names = $extension_model->getActivePlugins(); $active_plugins_names[] = $extension_name; // add current extension to the list of active plugins // get all active plugins data $extensions_tree = $extension_model->getFullExtensionsTree(); $extensions_tree['themes'] = $extension_model->changeExtensionsKey($extensions_tree['themes'], 'Name'); $active_plugins_all_data = array(); if (array_key_exists('plugins', $extensions_tree)) { if (count($extensions_tree['plugins']) > 0) { foreach ($active_plugins_names as $active_plugin) { if (!array_key_exists($active_plugin, $extensions_tree['plugins'])) { continue; } $active_plugins_all_data[$active_plugin] = $extensions_tree['plugins'][$active_plugin]; } //for($i=0; $i<count($active_plugins_names); $i++) //{ // if(!array_key_exists($active_plugins_names[$i],$extensions_tree['plugins'])) // { // continue; // } // // $active_plugins_all_data[$active_plugins_names[$i]] = $extensions_tree['plugins'][$active_plugins_names[$i]]; //} } } if (count($active_plugins_all_data) > 0) { foreach ($active_plugins_all_data as $plugin_path => $plugin_attr) { if (!is_array($plugin_attr)) { continue; } $version = ''; if (array_key_exists('Version', $plugin_attr)) { $version = $plugin_attr['Version']; } $name = ''; if (array_key_exists('Name', $plugin_attr)) { $name = $plugin_attr['Name']; } $slug = ''; if (array_key_exists('extension_slug', $plugin_attr)) { $slug = $plugin_attr['extension_slug']; } $repository_url = ''; if (array_key_exists('repository_endpoint_url', $plugin_attr)) { $repository_url = $plugin_attr['repository_endpoint_url']; } $active_plugins[$plugin_path] = array('name' => $name, 'type' => 'plugin', 'path' => $plugin_path, 'version' => $version, 'slug' => $slug, 'repository_url' => $repository_url); } } //$current_theme = $extension_model->getCurrentTheme(); $current_theme_name = $extension_model->getCurrentThemeName(); $current_theme = array(); if (isset($extensions_tree['themes'][$current_theme_name])) { $current_theme = $extensions_tree['themes'][$current_theme_name]; } if ($extension_name != $current_theme_name) { $version = ''; if (array_key_exists('Version', $current_theme)) { $version = $current_theme['Version']; } $slug = ''; if (array_key_exists('extension_slug', $current_theme)) { $slug = $current_theme['extension_slug']; } $repository_url = ''; if (array_key_exists('repository_endpoint_url', $current_theme)) { $repository_url = $current_theme['repository_endpoint_url']; } if (array_key_exists('Name', $current_theme)) { $active_plugins[$current_theme['Name']] = array('name' => $current_theme['Name'], 'type' => 'theme', 'path' => null, 'version' => $version, 'slug' => $slug, 'repository_url' => $repository_url); } } // save list of extensions and update last activation date $edm = WPRC_Loader::getExtensionDataManager('extension', $extension_name); $extension_data = array('activated_extensions' => $active_plugins, 'last_activation_date' => time()); $edm->updateExtensionData($extension_data); // set timer for extension WPRC_Loader::includeExtensionTimer(); $timer_is_set = WPRC_ExtensionTimer::setTimer($extension_name); $msg = ''; if (!$timer_is_set) { $msg = 'Timer wasn\'t set!<br>'; return false; } // remove extension from the list of plugins $this->removeSentReportsListItem($extension_name); }