function is_plugin_skipped($file) { $name = get_plugin_name(str_replace(WP_PLUGIN_DIR . '/', '', $file)); $skipped_plugins = \WP_CLI::get_runner()->config['skip-plugins']; if (true === $skipped_plugins) { return true; } if (!is_array($skipped_plugins)) { $skipped_plugins = explode(',', $skipped_plugins); } return in_array($name, array_filter($skipped_plugins)); }
/** * Prints tables of detected plugins, one table per plugin type, * and prints whether they are part of the standard Moodle * distribution or not. */ function print_plugin_tables() { global $DB; $plugins_standard = array(); $plugins_standard['mod'] = array('assignment', 'chat', 'choice', 'data', 'feedback', 'folder', 'forum', 'glossary', 'hotpot', 'imscp', 'label', 'lesson', 'page', 'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki'); $plugins_standard['blocks'] = array('activity_modules', 'admin', 'admin_bookmarks', 'admin_tree', 'blog_menu', 'blog_tags', 'calendar_month', 'calendar_upcoming', 'comments', 'course_list', 'course_summary', 'glossary_random', 'html', 'loancalc', 'login', 'mentees', 'messages', 'mnet_hosts', 'news_items', 'online_users', 'participants', 'quiz_results', 'recent_activity', 'rss_client', 'search', 'search_forums', 'section_links', 'site_main_menu', 'social_activities', 'tag_flickr', 'tag_youtube', 'tags'); $plugins_standard['filter'] = array('activitynames', 'algebra', 'censor', 'emailprotect', 'filter', 'mediaplugin', 'multilang', 'tex', 'tidy'); $plugins_installed = array(); $installed_mods = $DB->get_records('modules', null, 'name'); $installed_blocks = $DB->get_records('block', null, 'name'); foreach ($installed_mods as $mod) { $plugins_installed['mod'][] = $mod->name; } foreach ($installed_blocks as $block) { $plugins_installed['blocks'][] = $block->name; } $plugins_installed['filter'] = array(); $plugins_ondisk = array(); $plugins_ondisk['mod'] = array_keys(get_plugin_list('mod')); $plugins_ondisk['blocks'] = array_keys(get_plugin_list('block')); $plugins_ondisk['filter'] = array_keys(get_plugin_list('filter')); $strstandard = get_string('standard'); $strnonstandard = get_string('nonstandard'); $strmissingfromdisk = '(' . get_string('missingfromdisk') . ')'; $strabouttobeinstalled = '(' . get_string('abouttobeinstalled') . ')'; $html = ''; $html .= '<table class="generaltable plugincheckwrapper" cellspacing="4" cellpadding="1"><tr valign="top">'; foreach ($plugins_ondisk as $cat => $list_ondisk) { $strcaption = get_string($cat); if ($cat == 'mod') { $strcaption = get_string('activitymodule'); } elseif ($cat == 'filter') { $strcaption = get_string('managefilters'); } $html .= '<td><table class="plugincompattable generaltable boxaligncenter" cellspacing="1" cellpadding="5" ' . 'id="' . $cat . 'compattable" summary="compatibility table"><caption>' . $strcaption . '</caption>' . "\n"; $html .= '<tr class="r0"><th class="header c0">' . get_string('directory') . "</th>\n" . '<th class="header c1">' . get_string('name') . "</th>\n" . '<th class="header c2">' . get_string('status') . "</th>\n</tr>\n"; $row = 1; foreach ($list_ondisk as $k => $plugin) { $status = 'ok'; $standard = 'standard'; $note = ''; if (!in_array($plugin, $plugins_standard[$cat])) { $standard = 'nonstandard'; $status = 'warning'; } // Get real name and full path of plugin $plugin_name = "[[{$plugin}]]"; $plugin_path = "{$cat}/{$plugin}"; $plugin_name = get_plugin_name($plugin, $cat); // Determine if the plugin is about to be installed if ($cat != 'filter' && !in_array($plugin, $plugins_installed[$cat])) { $note = $strabouttobeinstalled; $plugin_name = $plugin; } $html .= "<tr class=\"r{$row}\">\n" . "<td class=\"cell c0\">{$plugin_path}</td>\n" . "<td class=\"cell c1\">{$plugin_name}</td>\n" . "<td class=\"{$standard} {$status} cell c2\">" . ${'str' . $standard} . " {$note}</td>\n</tr>\n"; $row++; // If the plugin was both on disk and in the db, unset the value from the installed plugins list if ($key = array_search($plugin, $plugins_installed[$cat])) { unset($plugins_installed[$cat][$key]); } } // If there are plugins left in the plugins_installed list, it means they are missing from disk foreach ($plugins_installed[$cat] as $k => $missing_plugin) { // Make sure the plugin really is missing from disk if (!in_array($missing_plugin, $plugins_ondisk[$cat])) { $standard = 'standard'; $status = 'warning'; if (!in_array($missing_plugin, $plugins_standard[$cat])) { $standard = 'nonstandard'; } $plugin_name = $missing_plugin; $html .= "<tr class=\"r{$row}\">\n" . "<td class=\"cell c0\">?</td>\n" . "<td class=\"cell c1\">{$plugin_name}</td>\n" . "<td class=\"{$standard} {$status} cell c2\">" . ${'str' . $standard} . " {$strmissingfromdisk}</td>\n</tr>\n"; $row++; } } $html .= '</table></td>'; } $html .= '</tr></table><br />'; echo $html; }
/** * Set a setting for a plugin. * * @param string $name The name - note, can't be "title". * @param mixed $value The value. * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from. */ function set_plugin_setting($name, $value, $plugin_name = "") { if (!$plugin_name) { $plugin_name = get_plugin_name(); } $plugin = find_plugin_settings($plugin_name); if (!$plugin) { $plugin = new ElggPlugin(); } if ($name != 'title') { // Hook to validate setting $value = trigger_plugin_hook('plugin:setting', 'plugin', array('plugin' => $plugin_name, 'name' => $name, 'value' => $value), $value); $plugin->title = $plugin_name; $plugin->access_id = ACCESS_PUBLIC; $plugin->save(); $plugin->{$name} = $value; return $plugin->getGUID(); } return false; }
/** * Adds an item to the menu register * * @param string $menu_name The name of the top-level menu * @param string $menu_url The URL of the page * @param array $menu_children Optionally, an array of submenu items * @return true|false Depending on success */ function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "") { global $CONFIG; if (!isset($CONFIG->menucontexts)) { $CONFIG->menucontexts = array(); } if (empty($context)) { $context = get_plugin_name(); } $CONFIG->menucontexts[] = $context; return add_to_register('menu', $menu_name, $menu_url, $menu_children); }
<?php global $schoolManagement, $pdo; $teachers_data = $schoolManagement->teachers_data()->get(); $plugin_url = 'http://' . dirname($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '/plugins/' . get_plugin_name(); $config = ['table' => 'scl_teachers', 'type' => 'teacher']; if (isset($_POST['editTeacherData'])) { $configg = ['action' => 'edit', 'file' => $_FILES['edit-teacher-image'], 'username' => $_POST['username'], 'extension' => pathinfo($_FILES['edit-teacher-image']['name'])['extension']]; $config = array_merge($configg, $config); $schoolManagement->setTeacherData($_POST)->sendProfileData($config)->setUserDataField($_POST, $config)->updateUser(); if ($schoolManagement->status) { echo '<script>profileUpdated()</script>'; echo "<meta http-equiv='refresh' content='1;url='>"; } else { echo '<script>error()</script>'; } } elseif (isset($_POST['editPassword'])) { $configg = ['username' => $_POST['username']]; $config = array_merge($configg, $config); $schoolManagement->matchPassword($_POST); if ($schoolManagement->status) { $schoolManagement->setPasswordField($_POST)->changePassword($config['username']); if ($schoolManagement->status) { echo '<script>passwordChanged()</script>'; } else { echo '<script>error()</script>'; } } else { echo '<script>passNotMatched()</script>'; } } elseif (isset($_POST['addNewTeacher'])) {
/** * Returns the functional context of a page * * @return string The context, or 'main' if no context has been provided */ function get_context() { global $CONFIG; if (isset($CONFIG->context) && !empty($CONFIG->context)) { return $CONFIG->context; } if ($context = get_plugin_name(true)) { return $context; } return "main"; }