当前位置: 首页>>代码示例>>PHP>>正文


PHP repository::static_function方法代码示例

本文整理汇总了PHP中repository::static_function方法的典型用法代码示例。如果您正苦于以下问题:PHP repository::static_function方法的具体用法?PHP repository::static_function怎么用?PHP repository::static_function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在repository的用法示例。


在下文中一共展示了repository::static_function方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: output_html

 /**
  * Builds XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string XHTML
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $USER, $OUTPUT;
     // Get strings that are used
     $strshow = get_string('on', 'repository');
     $strhide = get_string('off', 'repository');
     $strdelete = get_string('disabled', 'repository');
     $actionchoicesforexisting = array('show' => $strshow, 'hide' => $strhide, 'delete' => $strdelete);
     $actionchoicesfornew = array('newon' => $strshow, 'newoff' => $strhide, 'delete' => $strdelete);
     $return = '';
     $return .= $OUTPUT->box_start('generalbox');
     // Set strings that are used multiple times
     $settingsstr = get_string('settings');
     $disablestr = get_string('disable');
     // Table to list plug-ins
     $table = new html_table();
     $table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
     $table->align = array('left', 'center', 'center', 'center', 'center');
     $table->data = array();
     // Get list of used plug-ins
     $instances = repository::get_types();
     if (!empty($instances)) {
         // Array to store plugins being used
         $alreadyplugins = array();
         $totalinstances = count($instances);
         $updowncount = 1;
         foreach ($instances as $i) {
             $settings = '';
             $typename = $i->get_typename();
             // Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
             $typeoptionnames = repository::static_function($typename, 'get_type_option_names');
             $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
             if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
                 // Calculate number of instances in order to display them for the Moodle administrator
                 if (!empty($instanceoptionnames)) {
                     $params = array();
                     $params['context'] = array(get_system_context());
                     $params['onlyvisible'] = false;
                     $params['type'] = $typename;
                     $admininstancenumber = count(repository::static_function($typename, 'get_instances', $params));
                     // site instances
                     $admininstancenumbertext = get_string('instancesforsite', 'repository', $admininstancenumber);
                     $params['context'] = array();
                     $instances = repository::static_function($typename, 'get_instances', $params);
                     $courseinstances = array();
                     $userinstances = array();
                     foreach ($instances as $instance) {
                         if ($instance->context->contextlevel == CONTEXT_COURSE) {
                             $courseinstances[] = $instance;
                         } else {
                             if ($instance->context->contextlevel == CONTEXT_USER) {
                                 $userinstances[] = $instance;
                             }
                         }
                     }
                     // course instances
                     $instancenumber = count($courseinstances);
                     $courseinstancenumbertext = get_string('instancesforcourses', 'repository', $instancenumber);
                     // user private instances
                     $instancenumber = count($userinstances);
                     $userinstancenumbertext = get_string('instancesforusers', 'repository', $instancenumber);
                 } else {
                     $admininstancenumbertext = "";
                     $courseinstancenumbertext = "";
                     $userinstancenumbertext = "";
                 }
                 $settings .= '<a href="' . $this->baseurl . '&amp;action=edit&amp;repos=' . $typename . '">' . $settingsstr . '</a>';
                 $settings .= $OUTPUT->container_start('mdl-left');
                 $settings .= '<br/>';
                 $settings .= $admininstancenumbertext;
                 $settings .= '<br/>';
                 $settings .= $courseinstancenumbertext;
                 $settings .= '<br/>';
                 $settings .= $userinstancenumbertext;
                 $settings .= $OUTPUT->container_end();
             }
             // Get the current visibility
             if ($i->get_visible()) {
                 $currentaction = 'show';
             } else {
                 $currentaction = 'hide';
             }
             $select = new single_select($this->repository_action_url($typename, 'repos'), 'action', $actionchoicesforexisting, $currentaction, null, 'applyto' . basename($typename));
             // Display up/down link
             $updown = '';
             $spacer = $OUTPUT->spacer(array('height' => 15, 'width' => 15));
             // should be done with CSS instead
             if ($updowncount > 1) {
                 $updown .= "<a href=\"{$this->baseurl}&amp;action=moveup&amp;repos=" . $typename . "\">";
                 $updown .= "<img src=\"" . $OUTPUT->pix_url('t/up') . "\" alt=\"up\" /></a>&nbsp;";
             } else {
                 $updown .= $spacer;
             }
//.........这里部分代码省略.........
开发者ID:raymondAntonio,项目名称:moodle,代码行数:101,代码来源:adminlib.php

示例2: admin_category

 $ADMIN->add('modules', new admin_category('repositorysettings', $catname));
 $temp = new admin_settingpage('managerepositories', $managerepo);
 $temp->add(new admin_setting_heading('managerepositories', get_string('activerepository', 'repository'), ''));
 $temp->add(new admin_setting_managerepository());
 $temp->add(new admin_setting_heading('managerepositoriescommonheading', get_string('commonsettings', 'admin'), ''));
 $temp->add(new admin_setting_configtext('repositorycacheexpire', get_string('cacheexpire', 'repository'), get_string('configcacheexpire', 'repository'), 120));
 $ADMIN->add('repositorysettings', $temp);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew', get_string('addplugin', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete', get_string('deleterepository', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller', get_string('managerepositories', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew', get_string('createrepository', 'repository'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit', get_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true), '', $url);
 foreach (repository::get_types() as $repositorytype) {
     //display setup page for plugins with: general options or multiple instances (e.g. has instance config)
     $typeoptionnames = repository::static_function($repositorytype->get_typename(), 'get_type_option_names');
     $instanceoptionnames = repository::static_function($repositorytype->get_typename(), 'get_instance_option_names');
     if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
         $ADMIN->add('repositorysettings', new admin_externalpage('repositorysettings' . $repositorytype->get_typename(), $repositorytype->get_readablename(), $url . '?edit=' . $repositorytype->get_typename()), 'moodle/site:config');
     }
 }
 // Question type settings.
 $ADMIN->add('modules', new admin_category('qtypesettings', get_string('questiontypes', 'admin')));
 $ADMIN->add('qtypesettings', new admin_page_manageqtypes());
 require_once $CFG->libdir . '/questionlib.php';
 global $QTYPES;
 foreach ($QTYPES as $qtype) {
     $settingsfile = $qtype->plugin_dir() . '/settings.php';
     if (file_exists($settingsfile)) {
         $settings = new admin_settingpage('qtypesetting' . $qtype->name(), $qtype->local_name(), 'moodle/question:config');
         if ($ADMIN->fulltree) {
             include $settingsfile;
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:plugins.php

示例3: create_type

 /**
  * Create the type of repository.
  *
  * @param stdClass|array $record data to use to set up the type
  * @param array $options options for the set up of the type
  *
  * @return stdClass repository type record
  */
 public function create_type($record = null, array $options = null)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/repository/lib.php';
     $record = (array) $record;
     $type = $this->get_typename();
     $typeoptions = repository::static_function($type, 'get_type_option_names');
     $instanceoptions = repository::static_function($type, 'get_instance_option_names');
     // The type allow for user and course instances.
     if (!empty($instanceoptions)) {
         $typeoptions[] = 'enableuserinstances';
         $typeoptions[] = 'enablecourseinstances';
     }
     // Make sure all the parameters are set.
     $record = $this->prepare_type_record($record);
     foreach ($typeoptions as $option) {
         if (!isset($record[$option])) {
             throw new coding_exception("{$option} must be present in testing::create_repository_type() for {$type}");
         }
     }
     // Limit to allowed options.
     $record = array_intersect_key($record, array_flip($typeoptions));
     // Create the type.
     $plugintype = new repository_type($type, $record);
     $plugintype->create(false);
     return $DB->get_record('repository', array('type' => $type));
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:35,代码来源:repository_generator.php

示例4: validation

 /**
  * Validate moodle form data
  *
  * @param array $data moodle form data
  * @param array $files
  * @return array errors
  */
 public function validation($data, $files)
 {
     $errors = array();
     $plugin = $this->_customdata['plugin'];
     $instance = isset($this->_customdata['instance']) && is_subclass_of($this->_customdata['instance'], 'repository') ? $this->_customdata['instance'] : null;
     if (!$instance) {
         $errors = repository::static_function($plugin, 'type_form_validation', $this, $data, $errors);
     } else {
         $errors = $instance->type_form_validation($this, $data, $errors);
     }
     return $errors;
 }
开发者ID:isuruAb,项目名称:moodle,代码行数:19,代码来源:lib.php

示例5: redirect

     redirect($baseurl);
     exit;
 } else {
     if ($fromform = $mform->get_data()) {
         if (!confirm_sesskey()) {
             print_error('confirmsesskeybad', '', $baseurl);
         }
         if ($edit) {
             $settings = array();
             $settings['name'] = $fromform->name;
             foreach ($configs as $config) {
                 $settings[$config] = $fromform->{$config};
             }
             $success = $instance->set_option($settings);
         } else {
             $success = repository::static_function($plugin, 'create', $plugin, 0, get_context_instance_by_id($contextid), $fromform);
             $data = data_submitted();
         }
         if ($success) {
             $savedstr = get_string('configsaved', 'repository');
             //admin_externalpage_print_header();
             print_heading($savedstr);
             redirect($baseurl, $savedstr, 3);
         } else {
             print_error('instancenotsaved', 'repository', $baseurl);
         }
         exit;
     } else {
         // Display the form
         // admin_externalpage_print_header();
         print_heading(get_string('configplugin', 'repository_' . $plugin));
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:manage_instances.php

示例6: array

 if ($fromform = $mform->get_data()) {
     if ($edit) {
         $settings = array();
         $settings['name'] = $fromform->name;
         if (!$instance->readonly) {
             foreach ($configs as $config) {
                 if (isset($fromform->{$config})) {
                     $settings[$config] = $fromform->{$config};
                 } else {
                     $settings[$config] = null;
                 }
             }
         }
         $success = $instance->set_option($settings);
     } else {
         $success = repository::static_function($plugin, 'create', $plugin, 0, $context, $fromform);
         $data = data_submitted();
     }
     if ($success) {
         redirect($parenturl);
     } else {
         print_error('instancenotsaved', 'repository', $parenturl);
     }
     exit;
 } else {
     echo $OUTPUT->header();
     echo $OUTPUT->heading(get_string('configplugin', 'repository_' . $plugin));
     echo $OUTPUT->box_start();
     $mform->display();
     echo $OUTPUT->box_end();
     $return = false;
开发者ID:nmicha,项目名称:moodle,代码行数:31,代码来源:repositoryinstance.php

示例7: array

 $typename = $i->get_typename();
 // Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
 $typeoptionnames = repository::static_function($typename, 'get_type_option_names');
 $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
 if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
     // Calculate number of instances in order to display them for the Moodle administrator
     if (!empty($instanceoptionnames)) {
         $params = array();
         $params['context'] = array(get_system_context());
         $params['onlyvisible'] = false;
         $params['type'] = $typename;
         $admininstancenumber = count(repository::static_function($typename, 'get_instances', $params));
         // site instances
         $admininstancenumbertext = get_string('instancesforsite', 'repository', $admininstancenumber);
         $params['context'] = array();
         $instances = repository::static_function($typename, 'get_instances', $params);
         $courseinstances = array();
         $userinstances = array();
         foreach ($instances as $instance) {
             if ($instance->context->contextlevel == CONTEXT_COURSE) {
                 $courseinstances[] = $instance;
             } else {
                 if ($instance->context->contextlevel == CONTEXT_USER) {
                     $userinstances[] = $instance;
                 }
             }
         }
         // course instances
         $instancenumber = count($courseinstances);
         $courseinstancenumbertext = get_string('instancesforcourses', 'repository', $instancenumber);
         // user private instances
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:repository.php

示例8: print_error

 } else {
     if ($fromform = $mform->get_data()) {
         if (!confirm_sesskey()) {
             print_error('confirmsesskeybad', '', $baseurl);
         }
         if ($edit) {
             $settings = array();
             $settings['name'] = $fromform->name;
             if (!$instance->readonly) {
                 foreach ($configs as $config) {
                     $settings[$config] = $fromform->{$config};
                 }
             }
             $success = $instance->set_option($settings);
         } else {
             $success = repository::static_function($plugin, 'create', $plugin, 0, get_system_context(), $fromform);
             $data = data_submitted();
         }
         if ($success) {
             $savedstr = get_string('configsaved', 'repository');
             admin_externalpage_print_header();
             echo $OUTPUT->heading($savedstr);
             redirect($baseurl, $savedstr, 3);
         } else {
             print_error('instancenotsaved', 'repository', $baseurl);
         }
         exit;
     } else {
         admin_externalpage_print_header();
         echo $OUTPUT->heading(get_string('configplugin', 'repository_' . $plugin));
         echo $OUTPUT->box_start();
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:repositoryinstance.php

示例9: print_simple_box_start

            if ($edit) {
                $typeoptionnames = repository::static_function($edit, 'get_type_option_names');
                $instanceoptionnames = repository::static_function($edit, 'get_instance_option_names');
                if (empty($typeoptionnames) && empty($instanceoptionnames)) {
                    $displaysettingform = false;
                }
            }
            if ($displaysettingform) {
                print_simple_box_start();
                $mform->display();
                print_simple_box_end();
            }
            $return = false;
            //display instances list and creation form
            if ($edit) {
                $instanceoptionnames = repository::static_function($edit, 'get_instance_option_names');
                if (!empty($instanceoptionnames)) {
                    repository::display_instances_list(get_context_instance(CONTEXT_SYSTEM), $edit);
                }
            }
        }
    }
} else {
    if (!empty($hide)) {
        if (!confirm_sesskey()) {
            print_error('confirmsesskeybad', '', $baseurl);
        }
        $repositorytype = repository::get_type_by_typename($hide);
        if (empty($repositorytype)) {
            print_error('invalidplugin', 'repository', '', $hide);
        }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:repository.php

示例10: output_html

 /**
  * Builds XHTML to display the control
  *
  * @param string $data Unused
  * @param string $query
  * @return string XHTML
  */
 public function output_html($data, $query = '')
 {
     global $CFG, $USER, $OUTPUT;
     $output = $OUTPUT->box_start('generalbox');
     $namestr = get_string('name');
     $settingsstr = get_string('settings');
     $updownstr = get_string('updown', 'repository');
     $hiddenstr = get_string('hiddenshow', 'repository');
     $deletestr = get_string('delete');
     $plugins = get_plugin_list('repository');
     $instances = repository::get_types();
     $instancesnumber = count($instances);
     $alreadyplugins = array();
     $table = new html_table();
     $table->head = array($namestr, $updownstr, $hiddenstr, $deletestr, $settingsstr);
     $table->align = array('left', 'center', 'center', 'center', 'center');
     $table->data = array();
     $updowncount = 1;
     foreach ($instances as $i) {
         $settings = '';
         //display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
         $typeoptionnames = repository::static_function($i->get_typename(), 'get_type_option_names');
         $instanceoptionnames = repository::static_function($i->get_typename(), 'get_instance_option_names');
         if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
             //calculate number of instances in order to display them for the Moodle administrator
             if (!empty($instanceoptionnames)) {
                 $admininstancenumber = count(repository::static_function($i->get_typename(), 'get_instances', array(get_context_instance(CONTEXT_SYSTEM)), null, false, $i->get_typename()));
                 $admininstancenumbertext = " <br/> " . $admininstancenumber . " " . get_string('instancesforadmin', 'repository');
                 $instancenumber = count(repository::static_function($i->get_typename(), 'get_instances', array(), null, false, $i->get_typename())) - $admininstancenumber;
                 $instancenumbertext = "<br/>" . $instancenumber . " " . get_string('instancesforothers', 'repository');
             } else {
                 $admininstancenumbertext = "";
                 $instancenumbertext = "";
             }
             $settings .= '<a href="' . $this->baseurl . '&amp;edit=' . $i->get_typename() . '">' . $settingsstr . '</a>' . $admininstancenumbertext . $instancenumbertext . "\n";
         }
         $delete = '<a href="' . $this->baseurl . '&amp;delete=' . $i->get_typename() . '">' . $deletestr . '</a>' . "\n";
         $hidetitle = $i->get_visible() ? get_string('clicktohide', 'repository') : get_string('clicktoshow', 'repository');
         $hiddenshow = ' <a href="' . $this->baseurl . '&amp;hide=' . $i->get_typename() . '">' . '<img src="' . $OUTPUT->old_icon_url('i/' . ($i->get_visible() ? 'hide' : 'show')) . '"' . ' alt="' . $hidetitle . '" ' . ' title="' . $hidetitle . '" />' . '</a>' . "\n";
         // display up/down link
         $updown = '';
         if ($updowncount > 1) {
             $updown .= "<a href=\"{$this->baseurl}&amp;move=up&amp;type=" . $i->get_typename() . "\">";
             $updown .= "<img src=\"" . $OUTPUT->old_icon_url('t/up') . "\" alt=\"up\" /></a>&nbsp;";
         } else {
             $updown .= "<img src=\"" . $OUTPUT->old_icon_url('spacer.gif') . "\" class=\"icon\" alt=\"\" />&nbsp;";
         }
         if ($updowncount < count($instances)) {
             $updown .= "<a href=\"{$this->baseurl}&amp;move=down&amp;type=" . $i->get_typename() . "\">";
             $updown .= "<img src=\"" . $OUTPUT->old_icon_url('t/down') . "\" alt=\"down\" /></a>";
         } else {
             $updown .= "<img src=\"" . $OUTPUT->old_icon_url('spacer.gif') . "\" class=\"icon\" alt=\"\" />";
         }
         $updowncount++;
         $table->data[] = array($i->get_readablename(), $updown, $hiddenshow, $delete, $settings);
         //display a grey row if the type is defined as not visible
         if (!$i->get_visible()) {
             $table->rowclasses[] = 'dimmed_text';
         } else {
             $table->rowclasses[] = '';
         }
         if (!in_array($i->get_typename(), $alreadyplugins)) {
             $alreadyplugins[] = $i->get_typename();
         }
     }
     $output .= $OUTPUT->table($table);
     $instancehtml = '<div><h3>';
     $instancehtml .= get_string('addplugin', 'repository');
     $instancehtml .= '</h3><ul>';
     $addable = 0;
     foreach ($plugins as $p => $dir) {
         if (!in_array($p, $alreadyplugins)) {
             $instancehtml .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/repository.php?sesskey=' . sesskey() . '&amp;new=' . $p . '">' . get_string('add', 'repository') . ' "' . get_string('repositoryname', 'repository_' . $p) . '" ' . '</a></li>';
             $addable++;
         }
     }
     $instancehtml .= '</ul>';
     $instancehtml .= '</div>';
     if ($addable) {
         $output .= $instancehtml;
     }
     $output .= $OUTPUT->box_end();
     return highlight($query, $output);
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:91,代码来源:adminlib.php

示例11: definition

 /**
  * Definition of the moodleform
  * @global object $CFG
  */
 public function definition()
 {
     global $CFG;
     // type of plugin, string
     $this->plugin = $this->_customdata['plugin'];
     $this->instance = isset($this->_customdata['instance']) && is_a($this->_customdata['instance'], 'repository_type') ? $this->_customdata['instance'] : null;
     $this->action = $this->_customdata['action'];
     $this->pluginname = $this->_customdata['pluginname'];
     $mform =& $this->_form;
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'action', $this->action);
     $mform->setType('action', PARAM_TEXT);
     $mform->addElement('hidden', 'repos', $this->plugin);
     $mform->setType('repos', PARAM_SAFEDIR);
     // let the plugin add its specific fields
     $classname = 'repository_' . $this->plugin;
     require_once $CFG->dirroot . '/repository/' . $this->plugin . '/lib.php';
     //add "enable course/user instances" checkboxes if multiple instances are allowed
     $instanceoptionnames = repository::static_function($this->plugin, 'get_instance_option_names');
     $result = call_user_func(array($classname, 'type_config_form'), $mform, $classname);
     if (!empty($instanceoptionnames)) {
         $sm = get_string_manager();
         $component = 'repository';
         if ($sm->string_exists('enablecourseinstances', 'repository_' . $this->plugin)) {
             $component .= '_' . $this->plugin;
         }
         $mform->addElement('checkbox', 'enablecourseinstances', get_string('enablecourseinstances', $component));
         $component = 'repository';
         if ($sm->string_exists('enableuserinstances', 'repository_' . $this->plugin)) {
             $component .= '_' . $this->plugin;
         }
         $mform->addElement('checkbox', 'enableuserinstances', get_string('enableuserinstances', $component));
     }
     // set the data if we have some.
     if ($this->instance) {
         $data = array();
         $option_names = call_user_func(array($classname, 'get_type_option_names'));
         if (!empty($instanceoptionnames)) {
             $option_names[] = 'enablecourseinstances';
             $option_names[] = 'enableuserinstances';
         }
         $instanceoptions = $this->instance->get_options();
         foreach ($option_names as $config) {
             if (!empty($instanceoptions[$config])) {
                 $data[$config] = $instanceoptions[$config];
             } else {
                 $data[$config] = '';
             }
         }
         // XXX: set plugin name for plugins which doesn't have muliti instances
         if (empty($instanceoptionnames)) {
             $data['pluginname'] = $this->pluginname;
         }
         $this->set_data($data);
     }
     $this->add_action_buttons(true, get_string('save', 'repository'));
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:61,代码来源:lib.php

示例12: mnet_get_functions

/**
 * Parse a file to find out what functions/methods exist in it, and add entries
 * for the remote-call-enabled functions to the database.
 *
 * The path to a file, e.g. auth/mnet/auth.php can be thought of as
 * type/parentname/docname
 *
 * @param  string   $type           mod, auth or enrol
 * @param  string   $parentname     Implementation of type, e.g. 'mnet' in the
 *                                  case of auth/mnet/auth.php
 * @return bool                     True on success, else false
 */
function mnet_get_functions($type, $parentname)
{
    global $CFG, $DB;
    $dataobject = new stdClass();
    $docname = $type . '.php';
    $publishes = array();
    if ('mod' == $type) {
        $docname = 'rpclib.php';
        $relname = '/mod/' . $parentname . '/' . $docname;
        $filename = $CFG->dirroot . $relname;
        if (file_exists($filename)) {
            include_once $filename;
        }
        $mnet_publishes = $parentname . '_mnet_publishes';
        if (function_exists($mnet_publishes)) {
            (array) ($publishes = $mnet_publishes());
        }
    } else {
        if ('portfolio' == $type) {
            $docname = 'lib.php';
            $relname = '/portfolio/type/' . $parentname . '/' . $docname;
            $filename = $CFG->dirroot . $relname;
            require_once $CFG->libdir . '/portfoliolib.php';
            $publishes = (array) portfolio_static_function($parentname, 'mnet_publishes');
        } else {
            if ('repository' == $type) {
                $docname = 'repository.class.php';
                $relname = '/repository/' . $parentname . '/' . $docname;
                $filename = $CFG->dirroot . $relname;
                require_once $CFG->dirroot . '/repository/lib.php';
                $publishes = (array) repository::static_function($parentname, 'mnet_publishes');
            } else {
                // auth or enrol
                $relname = '/' . $type . '/' . $parentname . '/' . $docname;
                $filename = $CFG->dirroot . $relname;
                if (file_exists($filename)) {
                    include_once $filename;
                }
                $class = $type . ($type == 'enrol' ? 'ment' : '') . '_plugin_' . $parentname;
                if (class_exists($class)) {
                    $object = new $class();
                    if (method_exists($object, 'mnet_publishes')) {
                        (array) ($publishes = $object->mnet_publishes());
                    }
                }
            }
        }
    }
    $methodServiceArray = array();
    foreach ($publishes as $service) {
        if (is_array($service['methods'])) {
            foreach ($service['methods'] as $methodname) {
                $methodServiceArray[$methodname][] = $service;
            }
        }
    }
    // Disable functions that don't exist (any more) in the source
    // Should these be deleted? What about their permissions records?
    $rpcrecords = $DB->get_records('mnet_rpc', array('parent' => $parentname, 'parent_type' => $type), 'function_name ASC ');
    if (!empty($rpcrecords)) {
        foreach ($rpcrecords as $rpc) {
            if (!array_key_exists($rpc->function_name, $methodServiceArray)) {
                $rpc->enabled = 0;
                $DB->update_record('mnet_rpc', $rpc);
            }
        }
    }
    if (!file_exists($filename)) {
        return false;
    }
    if (extension_loaded('tokenizer')) {
        include_once "{$CFG->dirroot}/{$CFG->admin}/mnet/MethodTable.php";
        $functions = (array) MethodTable::create($filename, false);
    }
    foreach ($methodServiceArray as $method => $servicearray) {
        if (!empty($functions[$method])) {
            $details = $functions[$method];
            $profile = $details['arguments'];
            if (!isset($details['returns'])) {
                array_unshift($profile, array('type' => 'void', 'description' => 'No return value'));
            } else {
                array_unshift($profile, $details['returns']);
            }
            $dataobject->profile = serialize($profile);
            $dataobject->help = $details['description'];
        } else {
            $dataobject->profile = serialize(array(array('type' => 'void', 'description' => 'No return value')));
            $dataobject->help = '';
//.........这里部分代码省略.........
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:adminlib.php

示例13: plugin_init

 /**
  * is run when moodle administrator add the plugin
  */
 public static function plugin_init()
 {
     //here we create a default instance for this type
     $id = repository::static_function('flickr_public', 'create', 'flickr_public', 0, get_system_context(), array('name' => '', 'email_address' => null, 'usewatermarks' => false), 0);
     if (empty($id)) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:nmicha,项目名称:moodle,代码行数:13,代码来源:lib.php

示例14: test_can_be_edited_by_user

    public function test_can_be_edited_by_user() {
        $this->resetAfterTest(true);

        $syscontext = context_system::instance();
        $course = $this->getDataGenerator()->create_course();
        $coursecontext = context_course::instance($course->id);
        $roleid = create_role('A role', 'arole', 'A role', '');
        set_role_contextlevels($roleid, array($syscontext->contextlevel, $coursecontext->contextlevel));
        $user = $this->getDataGenerator()->create_user();
        $this->setUser($user);

        $plugintype = new repository_type('flickr_public');
        $plugintype->create(true);
        $params = array(
            'name' => 'Flickr Public'
        );

        // Instance on a site level.
        $repoid = repository::static_function('flickr_public', 'create', 'flickr_public', 0, $syscontext, $params);
        $systemrepo = repository::get_repository_by_id($repoid, $syscontext);

        role_assign($roleid, $user->id, $syscontext->id);
        assign_capability('moodle/site:config', CAP_ALLOW, $roleid, $syscontext, true);
        assign_capability('repository/flickr_public:view', CAP_ALLOW, $roleid, $syscontext, true);
        accesslib_clear_all_caches_for_unit_testing();
        $this->assertTrue($systemrepo->can_be_edited_by_user());

        assign_capability('repository/flickr_public:view', CAP_PROHIBIT, $roleid, $syscontext, true);
        assign_capability('moodle/site:config', CAP_PROHIBIT, $roleid, $syscontext, true);
        accesslib_clear_all_caches_for_unit_testing();
        $this->assertFalse($systemrepo->can_be_edited_by_user());

        assign_capability('repository/flickr_public:view', CAP_ALLOW, $roleid, $syscontext, true);
        assign_capability('moodle/site:config', CAP_PROHIBIT, $roleid, $syscontext, true);
        accesslib_clear_all_caches_for_unit_testing();
        $this->assertFalse($systemrepo->can_be_edited_by_user());

        role_unassign($roleid, $user->id, $syscontext->id);
        accesslib_clear_all_caches_for_unit_testing();

        // Instance on a course level.
        $this->getDataGenerator()->enrol_user($user->id, $course->id, $roleid);

        $repoid = repository::static_function('flickr_public', 'create', 'flickr_public', 0, $coursecontext, $params);
        $courserepo = repository::get_repository_by_id($repoid, $coursecontext);

        assign_capability('moodle/course:update', CAP_ALLOW, $roleid, $coursecontext, true);
        assign_capability('repository/flickr_public:view', CAP_ALLOW, $roleid, $coursecontext, true);
        accesslib_clear_all_caches_for_unit_testing();
        $this->assertTrue($courserepo->can_be_edited_by_user());

        assign_capability('repository/flickr_public:view', CAP_PROHIBIT, $roleid, $coursecontext, true);
        accesslib_clear_all_caches_for_unit_testing();
        $this->assertFalse($courserepo->can_be_edited_by_user());

        assign_capability('moodle/course:update', CAP_ALLOW, $roleid, $coursecontext, true);
        assign_capability('repository/flickr_public:view', CAP_PROHIBIT, $roleid, $coursecontext, true);
        accesslib_clear_all_caches_for_unit_testing();
        $this->assertFalse($courserepo->can_be_edited_by_user());

        role_unassign($roleid, $user->id, $coursecontext->id);
        accesslib_clear_all_caches_for_unit_testing();

        // Instance on a user level.
        $otheruser = $this->getDataGenerator()->create_user();
        $otherusercontext = context_user::instance($otheruser->id);
        role_assign($roleid, $user->id, $syscontext->id);
        assign_capability('repository/flickr_public:view', CAP_ALLOW, $roleid, $syscontext, true);
        accesslib_clear_all_caches_for_unit_testing();

        // Editing someone else's instance.
        $repoid = repository::static_function('flickr_public', 'create', 'flickr_public', 0, $otherusercontext, $params);
        $userrepo = repository::get_repository_by_id($repoid, $syscontext);
        $this->assertFalse($userrepo->can_be_edited_by_user());

        // Editing my own instance.
        $usercontext = context_user::instance($user->id);
        $repoid = repository::static_function('flickr_public', 'create', 'flickr_public', 0, $usercontext, $params);
        $userrepo = repository::get_repository_by_id($repoid, $syscontext);
        $this->assertTrue($userrepo->can_be_edited_by_user());

    }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:82,代码来源:repository_test.php

示例15: definition

 /**
  * Definition of the moodleform
  * @global object $CFG
  */
 public function definition()
 {
     global $CFG;
     // type of plugin, string
     $this->plugin = $this->_customdata['plugin'];
     $this->instance = isset($this->_customdata['instance']) && is_a($this->_customdata['instance'], 'repository_type') ? $this->_customdata['instance'] : null;
     $mform =& $this->_form;
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'edit', $this->instance ? $this->instance->get_typename() : 0);
     $mform->addElement('hidden', 'new', $this->plugin);
     $mform->addElement('hidden', 'plugin', $this->plugin);
     // let the plugin add its specific fields
     if (!$this->instance) {
         $result = repository::static_function($this->plugin, 'type_config_form', $mform);
     } else {
         $classname = 'repository_' . $this->instance->get_typename();
         $result = call_user_func(array($classname, 'type_config_form'), $mform);
     }
     //add "enable course/user instances" checkboxes if multiple instances are allowed
     $instanceoptionnames = repository::static_function($this->plugin, 'get_instance_option_names');
     if (!empty($instanceoptionnames)) {
         $mform->addElement('checkbox', 'enablecourseinstances', get_string('enablecourseinstances', 'repository'));
         $mform->addElement('checkbox', 'enableuserinstances', get_string('enableuserinstances', 'repository'));
     }
     // set the data if we have some.
     if ($this->instance) {
         $data = array();
         $option_names = call_user_func(array($classname, 'get_type_option_names'));
         if (!empty($instanceoptionnames)) {
             $option_names[] = 'enablecourseinstances';
             $option_names[] = 'enableuserinstances';
         }
         $instanceoptions = $this->instance->get_options();
         foreach ($option_names as $config) {
             if (!empty($instanceoptions[$config])) {
                 $data[$config] = $instanceoptions[$config];
             } else {
                 $data[$config] = '';
             }
         }
         $this->set_data($data);
     }
     $this->add_action_buttons(true, get_string('save', 'repository'));
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:48,代码来源:lib.php


注:本文中的repository::static_function方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。