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


PHP field::get_for_context_level_with_name方法代码示例

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


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

示例1: xmldb_crlm_cluster_themes_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    elis
 * @subpackage curriculummanagement
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_crlm_cluster_themes_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010080602) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        //theme priority
        $theme_priority_field = new field(field::get_for_context_level_with_name('cluster', 'cluster_themepriority'));
        if (isset($theme_priority_field->owners['manual'])) {
            $theme_priority_owner = new field_owner($theme_priority_field->owners['manual']);
            $theme_priority_owner->param_help_file = 'crlm_cluster_themes/cluster_themepriority';
            $theme_priority_owner->update();
        }
        //theme selection
        $theme_field = new field(field::get_for_context_level_with_name('cluster', 'cluster_theme'));
        if (isset($theme_field->owners['manual'])) {
            $theme_owner = new field_owner($theme_field->owners['manual']);
            $theme_owner->param_help_file = 'crlm_cluster_themes/cluster_theme';
            $theme_owner->update();
        }
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:49,代码来源:upgrade.php

示例2: xmldb_crlm_cluster_classification_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    elis
 * @subpackage curriculummanagement
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_crlm_cluster_classification_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010080502) {
        /// Define table crlm_cluster_classification to be created
        $table = new XMLDBTable('crlm_cluster_classification');
        /// Adding fields to table crlm_cluster_classification
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('shortname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
        $table->addFieldInfo('params', XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null);
        /// Adding keys to table crlm_cluster_classification
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('shortname_idx', XMLDB_KEY_UNIQUE, array('shortname'));
        /// Launch create table for crlm_cluster_classification
        $result = $result && create_table($table);
    }
    if ($result && $oldversion < 2010080503) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
        // make sure we're set as owner
        if (!isset($field->owners['cluster_classification'])) {
            $owner = new field_owner();
            $owner->fieldid = $field->id;
            $owner->plugin = 'cluster_classification';
            $owner->add();
        }
        // make sure we have a default value set
        if (!field_data::get_for_context_and_field(NULL, $field)) {
            field_data::set_for_context_and_field(NULL, $field, 'regular');
        }
        $default = new clusterclassification();
        $default->shortname = 'regular';
        $default->name = get_string('cluster', 'block_curr_admin');
        $default->param_autoenrol_curricula = 1;
        $default->param_autoenrol_tracks = 1;
        $default->add();
    }
    // make sure 'manual' is an owner
    if ($result && $oldversion < 2010080504) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_CLASSIFICATION_FIELD));
        $owner = new field_owner();
        $owner->fieldid = $field->id;
        $owner->plugin = 'manual';
        $owner->param_view_capability = '';
        $owner->param_edit_capability = 'moodle/user:update';
        $owner->param_control = 'menu';
        $owner->param_options_source = 'cluster_classifications';
        $owner->add();
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:82,代码来源:upgrade.php

示例3: cluster_display_priority_append_sort_data

/**
 * Appends additional data to query parameters based on existence of theme priority field
 *
 * @param  string  $cluster_id_field  The field to join on for the cluster id
 * @param  string  $select            The current select clause
 * @param  string  $join              The current join clause
 */
function cluster_display_priority_append_sort_data($cluster_id_field, &$select, &$join)
{
    global $CURMAN;
    //make sure we can get the field we need for ordering
    if ($theme_priority_field = new field(field::get_for_context_level_with_name('cluster', CLUSTER_DISPLAY_PRIORITY_FIELD)) and $contextlevel = context_level_base::get_custom_context_level('cluster', 'block_curr_admin')) {
        $field_data_table = $CURMAN->db->prefix_table($theme_priority_field->data_table());
        //use this for easier naming in terms of sorting
        $select .= ', field_data.data AS priority ';
        $join .= "LEFT JOIN ({$CURMAN->db->prefix_table('context')} context\n                  JOIN {$field_data_table} field_data\n                    ON field_data.contextid = context.id\n                    AND field_data.fieldid = {$theme_priority_field->id})\n\n                    ON context.contextlevel = {$contextlevel}\n                    AND context.instanceid = {$cluster_id_field} ";
    }
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:18,代码来源:lib.php

示例4: userset_display_priority_append_sort_data

/**
 * Appends additional data to query parameters based on existence of theme priority field
 *
 * @param  string  $cluster_id_field  The field to join on for the cluster id
 * @param  string  $select            The current select clause
 * @param  string  $join              The current join clause
 */
function userset_display_priority_append_sort_data($userset_id_field, &$select, &$join)
{
    global $DB;
    //make sure we can get the field we need for ordering
    if ($theme_priority_field = new field(field::get_for_context_level_with_name(CONTEXT_ELIS_USERSET, USERSET_DISPLAY_PRIORITY_FIELD))) {
        $field_data_table = $theme_priority_field->data_table();
        //use this for easier naming in terms of sorting
        $select .= ', field_data.data AS priority ';
        $join .= ' LEFT JOIN ({context} context
                   JOIN {' . $field_data_table . '} field_data
                     ON field_data.contextid = context.id
                     AND field_data.fieldid = ' . $theme_priority_field->id . ')

                     ON context.contextlevel = ' . CONTEXT_ELIS_USERSET . '
                     AND context.instanceid = ' . $userset_id_field . '
                 ';
    }
}
开发者ID:jamesmcq,项目名称:elis,代码行数:25,代码来源:lib.php

示例5: xmldb_crlm_cluster_groups_upgrade

/**
 * ELIS(TM): Enterprise Learning Intelligence Suite
 * Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    elis
 * @subpackage curriculummanagement
 * @author     Remote-Learner.net Inc
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
function xmldb_crlm_cluster_groups_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    if ($result && $oldversion < 2010080602) {
        require_once $CFG->dirroot . '/curriculum/lib/customfield.class.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/lib.php';
        require_once $CFG->dirroot . '/curriculum/plugins/cluster_classification/clusterclassification.class.php';
        $field = new field(field::get_for_context_level_with_name('cluster', 'cluster_group'));
        if (isset($field->owners['manual'])) {
            $owner = new field_owner($field->owners['manual']);
            $owner->param_help_file = 'crlm_cluster_groups/cluster_groups';
            $owner->update();
        }
    }
    if ($result && $oldversion < 2010080603) {
        //retrieve the cluster context
        $context = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
        //get the cluster classification category
        $category = new field_category();
        $category->name = get_string('cluster_group_category', 'crlm_cluster_groups');
        $field = new field();
        $field->shortname = 'cluster_groupings';
        $field->name = get_string('autoenrol_groupings', 'crlm_cluster_classification');
        $field->datatype = 'bool';
        $field = field::ensure_field_exists_for_context_level($field, $context, $category);
        $owner_options = array('required' => 0, 'edit_capability' => '', 'view_capability' => '', 'control' => 'checkbox', 'columns' => 30, 'rows' => 10, 'maxlength' => 2048, 'help_file' => 'crlm_cluster_groups/cluster_groupings');
        field_owner::ensure_field_owner_exists($field, 'manual', $owner_options);
    }
    if ($result && $oldversion < 2010080604) {
        if ($field = new field(field::get_for_context_level_with_name('cluster', 'cluster_site_course_group'))) {
            $field->shortname = 'cluster_groupings';
            $field->update();
        }
    }
    return $result;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:61,代码来源:upgrade.php

示例6: get_dashboard

 /**
  * Get the user dashboard report view.
  *
  * @uses $CFG, $CURMAN
  * @param none
  * @return string The HTML for the dashboard report.
  */
 function get_dashboard()
 {
     global $CFG, $CURMAN;
     require_once CURMAN_DIRLOCATION . '/lib/curriculumstudent.class.php';
     //needed for AJAX calls
     require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_connection', "{$CFG->wwwroot}/curriculum/js/util.js", "{$CFG->wwwroot}/curriculum/js/dashboard.js"), true);
     if (optional_param('tab', '', PARAM_CLEAN) == 'archivedlp') {
         $tab = 'archivedlp';
         $show_archived = 1;
     } else {
         $tab = 'currentlp';
         $show_archived = 0;
     }
     $content = '';
     $archive_var = '_elis_curriculum_archive';
     $totalcourses = 0;
     $totalcurricula = 0;
     $completecourses = 0;
     $curriculas = array();
     $classids = array();
     $sql = 'SELECT curstu.id, curstu.curriculumid as curid, cur.name as name
               FROM ' . $CURMAN->db->prefix_table(CURASSTABLE) . ' curstu
               JOIN ' . $CURMAN->db->prefix_table(CURTABLE) . ' cur
                 ON cur.id = curstu.curriculumid
              WHERE curstu.userid = \'' . $this->id . '\' ORDER BY cur.priority ASC, cur.name ASC';
     if ($usercurs = get_records_sql($sql)) {
         foreach ($usercurs as $usercur) {
             // Check if this curricula is set as archived and whether we want to display it
             $crlm_context = get_context_instance(context_level_base::get_custom_context_level('curriculum', 'block_curr_admin'), $usercur->curid);
             $data_array = field_data::get_for_context_and_field($crlm_context, $archive_var);
             $crlm_archived = 0;
             if (is_array($data_array) && !empty($data_array)) {
                 foreach ($data_array as $data_key => $data_obj) {
                     $crlm_archived = !empty($data_obj->data) ? 1 : 0;
                 }
             }
             if ($show_archived == $crlm_archived) {
                 $totalcurricula++;
                 $curriculas[$usercur->curid]['id'] = $usercur->curid;
                 $curriculas[$usercur->curid]['name'] = $usercur->name;
                 $data = array();
                 if ($courses = curriculumcourse_get_listing($usercur->curid, 'curcrs.position, crs.name', 'ASC')) {
                     foreach ($courses as $course) {
                         $totalcourses++;
                         $course_obj = new course($course->courseid);
                         $coursedesc = $course_obj->syllabus;
                         if ($cdata = student_get_class_from_course($course->courseid, $this->id)) {
                             foreach ($cdata as $classdata) {
                                 if (!in_array($classdata->id, $classids)) {
                                     $classids[] = $classdata->id;
                                 }
                                 if ($classdata->completestatusid == STUSTATUS_PASSED) {
                                     $completecourses++;
                                 }
                                 if ($mdlcrs = moodle_get_course($classdata->id)) {
                                     $coursename = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $mdlcrs . '">' . $course->coursename . '</a>';
                                 } else {
                                     $coursename = $course->coursename;
                                 }
                                 $data[] = array($coursename, $coursedesc, $classdata->grade, $classdata->completestatusid == STUSTATUS_PASSED ? get_string('yes') : get_string('no'), $classdata->completestatusid == STUSTATUS_PASSED && !empty($classdata->completetime) ? date('M j, Y', $classdata->completetime) : get_string('na', 'block_curr_admin'));
                             }
                         } else {
                             $data[] = array($course->coursename, $coursedesc, 0, get_string('no'), get_string('na', 'block_curr_admin'));
                         }
                     }
                 }
                 $curriculas[$usercur->curid]['data'] = $data;
             } else {
                 // Keep note of the classid's regardless if set archived or not for later use in determining non-curricula courses
                 if ($courses = curriculumcourse_get_listing($usercur->curid, 'curcrs.position, crs.name', 'ASC')) {
                     foreach ($courses as $course) {
                         if ($cdata = student_get_class_from_course($course->courseid, $this->id)) {
                             foreach ($cdata as $classdata) {
                                 if (!in_array($classdata->id, $classids)) {
                                     $classids[] = $classdata->id;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Show different css for IE below version 8
     if (check_browser_version('MSIE', 7.0) && !check_browser_version('MSIE', 8.0)) {
         // IEs that are lower than version 8 do not get the float because it messes up the tabs at the top of the page for some reason
         $float_style = 'text-align:right;';
     } else {
         // Sane browsers get the float tag
         $float_style = 'text-align:right; float:right;';
     }
     // Tab header
     $field_exists = field::get_for_context_level_with_name('curriculum', $archive_var);
//.........这里部分代码省略.........
开发者ID:remotelearner,项目名称:elis.cm,代码行数:101,代码来源:user.class.php

示例7: get_field

 /**
  * Creates known user filter if present
  *
  * @uses $USER
  * @param string $fieldname
  * @param boolean $advanced
  * @return object filter
  */
 function get_field($fieldname, $advanced)
 {
     global $USER, $DB;
     $IFNULL = "COALESCE(mi, '')";
     $FULLNAME = $DB->sql_concat_join("' '", array('firstname', $IFNULL, 'lastname'));
     $FIRSTLASTNAME = $DB->sql_concat('firstname', "' '", 'lastname');
     switch ($fieldname) {
         case 'username':
             return new user_filter_text('username', get_string('username'), $advanced, 'username');
         case 'realname':
             return new pm_user_filter_text_OR('realname', get_string('fullname'), $advanced, 'fullname', array($FULLNAME, $FIRSTLASTNAME));
         case 'lastname':
             return new user_filter_text('lastname', get_string('lastname'), $advanced, 'lastname');
         case 'firstname':
             return new user_filter_text('firstname', get_string('firstname'), $advanced, 'firstname');
         case 'idnumber':
             return new user_filter_text('idnumber', get_string('idnumber'), $advanced, 'idnumber');
         case 'email':
             return new user_filter_text('email', get_string('email'), $advanced, 'email');
         case 'city':
             return new user_filter_text('city', get_string('city'), $advanced, 'city');
         case 'country':
             return new user_filter_select('country', get_string('country'), $advanced, 'country', get_string_manager()->get_list_of_countries(), $USER->country);
         case 'timecreated':
             return new user_filter_date('timecreated', get_string('timecreated'), $advanced, 'timecreated');
         case 'language':
             return new user_filter_select('language', get_string('preferredlanguage'), $advanced, 'language', get_string_manager()->get_list_of_translations(true));
         case 'clusterid':
             $clusters = userset_get_menu();
             //need to reference the user table directly to allow use of filters in DB calls that do not
             //require the full SQL query with table aliases
             return new pm_user_userset_filter('clusterid', get_string('usercluster', 'local_elisprogram'), $advanced, '{' . user::TABLE . '}.id', $clusters);
         case 'curriculumid':
             $choices = program_get_menu();
             //need to reference the user table directly to allow use of filters in DB calls that do not
             //require the full SQL query with table aliases
             return new pm_user_program_filter('curriculumid', get_string('usercurricula', 'local_elisprogram'), $advanced, '{' . user::TABLE . '}.id', $choices);
         case 'inactive':
             $inactive_options = array(get_string('o_active', 'local_elisprogram'), get_string('all'), get_string('o_inactive', 'local_elisprogram'));
             return new pm_show_inactive_filter('inactive', get_string('showinactive', 'local_elisprogram'), $advanced, 'inactive', $inactive_options);
         default:
             if (strncmp($fieldname, 'field_', 6) === 0) {
                 $f = substr($fieldname, 6);
                 if ($rec = field::get_for_context_level_with_name(CONTEXT_ELIS_USER, $f)) {
                     return new pm_custom_field_filter($fieldname, $rec->shortname, $advanced, $rec);
                 }
             }
             return null;
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:58,代码来源:user.class.php

示例8: moodle_profile_can_sync

/**
* moodle_profile_can_sync function to determine if syncing custom field to/from Moodle is possible
*
* @param  string $shortname   the custom field shortname
* @param  string $eliscontrol (optional) the custom field control type: checkbox, datetime, menu, ...
                              If not specified it's looked-up in DB
* @return bool   true if the custom field can be synced, false otherwise
* @uses   $DB
*/
function moodle_profile_can_sync($shortname, $eliscontrol = null)
{
    global $DB;
    $moodlefield = $DB->get_record('user_info_field', array('shortname' => $shortname));
    if (empty($moodlefield)) {
        return false;
    }
    $fieldowner = null;
    if (empty($eliscontrol)) {
        // eliscontrol not specified so look it up ...
        $elisfield = field::get_for_context_level_with_name(CONTEXT_ELIS_USER, $shortname);
        if (empty($elisfield->id) || empty($elisfield->owners) || !isset($elisfield->owners['manual'])) {
            return false;
            // no elis field data found
        }
        $fieldowner = new field_owner($elisfield->owners['manual']);
        $eliscontrol = $fieldowner->param_control;
        if (empty($eliscontrol)) {
            return false;
            // invalid control type found
        }
    }
    $mdldatatype = $moodlefield->datatype;
    $fieldtypenosync = get_invalid_sync_controls($mdldatatype);
    if (!empty($fieldtypenosync) && is_array($fieldtypenosync) && in_array($eliscontrol, $fieldtypenosync)) {
        return false;
        // sync not permitted
    }
    // ELIS-8363: Check for multi-valued fields that can't sync to Moodle
    if (empty($elisfield)) {
        $elisfield = field::get_for_context_level_with_name(CONTEXT_ELIS_USER, $shortname);
    }
    if (!empty($elisfield) && !empty($elisfield->multivalued) && isset($elisfield->owners['moodle_profile']) && $elisfield->owners['moodle_profile']->exclude == pm_moodle_profile::sync_to_moodle) {
        return false;
        // sync not permitted
    }
    // Handle special cases of ELIS checkbox using list
    if ($eliscontrol == 'checkbox') {
        if ($mdldatatype == 'checkbox') {
            if (empty($fieldowner)) {
                $elisfield = field::get_for_context_level_with_name(CONTEXT_ELIS_USER, $shortname);
                if (!empty($elisfield->owners) && isset($elisfield->owners['manual'])) {
                    $fieldowner = new field_owner($elisfield->owners['manual']);
                }
            }
            if (!empty($fieldowner) && (!empty($fieldowner->param_options) || !empty($fieldowner->param_options_source))) {
                return false;
            }
        } else {
            if (empty($fieldowner)) {
                $elisfield = field::get_for_context_level_with_name(CONTEXT_ELIS_USER, $shortname);
                if (!empty($elisfield->owners) && isset($elisfield->owners['manual'])) {
                    $fieldowner = new field_owner($elisfield->owners['manual']);
                }
            }
            if (!empty($fieldowner) && empty($fieldowner->param_options) && empty($fieldowner->param_options_source)) {
                return false;
            }
        }
    }
    return true;
    // sync is ok
}
开发者ID:jamesmcq,项目名称:elis,代码行数:72,代码来源:custom_fields.php

示例9: cluster_count_records

function cluster_count_records($namesearch = '', $alpha = '', $extrafilters = array())
{
    global $CURMAN;
    $select = array();
    $LIKE = $CURMAN->db->sql_compare();
    if (!empty($namesearch)) {
        $namesearch = trim($namesearch);
        $select[] = "(name {$LIKE} '%{$namesearch}%')";
    }
    if ($alpha) {
        $select[] = "(name {$LIKE} '{$alpha}%')";
    }
    if (!empty($extrafilters['contexts'])) {
        /*
         * Start of cluster hierarchy extension
         */
        $sql_condition = '0=1';
        if (cluster::all_clusters_viewable()) {
            //user has capability at system level so allow access to any cluster
            $sql_condition = '0=0';
        } else {
            //user does not have capability at system level, so filter
            $viewable_clusters = cluster::get_viewable_clusters();
            if (empty($viewable_clusters)) {
                //user has no access to any clusters, so do not allow additional access
                $sql_condition = '0=1';
            } else {
                //user has additional access to some set of clusters, so "enable" this access
                $cluster_context_level = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
                //use the context path to find parent clusters
                $like = sql_ilike();
                $parent_path = sql_concat('parent_context.path', "'/%'");
                $cluster_filter = implode(',', $viewable_clusters);
                $sql_condition = "id IN (\n                                      SELECT parent_context.instanceid\n                                      FROM {$CURMAN->db->prefix_table('context')} parent_context\n                                      JOIN {$CURMAN->db->prefix_table('context')} child_context\n                                        ON child_context.path {$like} {$parent_path}\n                                        AND parent_context.contextlevel = {$cluster_context_level}\n                                        AND child_context.contextlevel = {$cluster_context_level}\n                                        AND child_context.instanceid IN ({$cluster_filter})\n                                  )";
            }
        }
        /*
         * End of cluster hierarchy extension
         */
        $context_filter = $extrafilters['contexts']->sql_filter_for_context_level('id', 'cluster');
        //extend the basic context filter by potentially enabling access to parent clusters
        $select[] = "({$context_filter} OR {$sql_condition})";
    }
    if (isset($extrafilters['parent'])) {
        $select[] = "parent={$extrafilters['parent']}";
    }
    if (isset($extrafilters['classification'])) {
        require_once CURMAN_DIRLOCATION . '/plugins/cluster_classification/lib.php';
        $contextlevel = context_level_base::get_custom_context_level('cluster', 'block_curr_admin');
        $field = new field(field::get_for_context_level_with_name($contextlevel, CLUSTER_CLASSIFICATION_FIELD));
        $select[] = "id IN (SELECT ctx.instanceid\n                              FROM {$CURMAN->db->prefix_table('context')} ctx\n                              JOIN (SELECT ctx.id AS contextid, IFNULL(fdata.data, fdefault.data) AS data\n                                      FROM {$CURMAN->db->prefix_table('context')} ctx\n                                 LEFT JOIN {$CURMAN->db->prefix_table($field->data_table())} fdata ON fdata.contextid = ctx.id AND fdata.fieldid = {$field->id}\n                                 LEFT JOIN {$CURMAN->db->prefix_table($field->data_table())} fdefault ON fdefault.contextid IS NULL AND fdefault.fieldid = {$field->id}) fdata ON fdata.data = '{$extrafilters['classification']}' AND fdata.contextid = ctx.id\n                             WHERE ctx.contextlevel = {$contextlevel})";
    }
    $select = implode(' AND ', $select);
    return $CURMAN->db->count_records_select(CLSTTABLE, $select);
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:55,代码来源:cluster.class.php

示例10: test_customfieldoperations

 /**
  * ELIS-4797: Test Various Custom Field Operations
  */
 public function test_customfieldoperations()
 {
     $contextlevels = \local_eliscore\context\helper::get_legacy_levels();
     foreach ($contextlevels as $ctxname => $ctxlvl) {
         $category = $this->create_field_category($ctxlvl);
         $field = $this->create_field($category, $ctxlvl);
         $fieldsfetched = field::get_for_context_level($ctxlvl);
         $fieldfound = false;
         foreach ($fieldsfetched as $fieldfetched) {
             if ($fieldfetched->shortname === $field->shortname) {
                 $fieldfound = true;
             }
         }
         $this->assertTrue($fieldfound);
         $fieldfetched = field::get_for_context_level_with_name($ctxlvl, $field->shortname);
         $this->assertEquals($field->shortname, $fieldfetched->shortname);
         $fieldfetched = field::ensure_field_exists_for_context_level($field, $ctxlvl, $category);
         $this->assertEquals($field->shortname, $fieldfetched->shortname);
         $catsfetched = field_category::get_for_context_level($ctxlvl);
         $catfound = false;
         foreach ($catsfetched as $catfetched) {
             if ($catfetched->id == $category->id) {
                 $catfound = true;
             }
         }
         $this->assertTrue($catfound);
         if ($ctxlvl === CONTEXT_ELIS_PROGRAM) {
             $cur = $this->create_curriculum();
             $fielddata = field_data::get_for_context_and_field(null, $field);
             $fielddata = $fielddata->current();
             $res = $fielddata->set_for_context_from_datarecord($ctxlvl, $cur);
             $this->assertTrue($res);
         }
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:38,代码来源:customfields_test.php

示例11: cluster_count_records

function cluster_count_records($namesearch = '', $alpha = '', $extrafilters = array())
{
    global $DB;
    $filters = array();
    if (!empty($namesearch)) {
        $namesearch = trim($namesearch);
        $filters[] = new field_filter('name', "%{$namesearch}%", field_filter::LIKE);
    }
    if ($alpha) {
        $filters[] = new field_filter('name', "{$alpha}%", field_filter::LIKE);
    }
    if (!empty($extrafilters['contexts'])) {
        /*
         * Start of cluster hierarchy extension
         */
        $sql_condition = new select_filter('FALSE');
        if (userset::all_clusters_viewable()) {
            //user has capability at system level so allow access to any cluster
            $sql_condition = new select_filter('TRUE');
        } else {
            //user does not have capability at system level, so filter
            $viewable_clusters = userset::get_viewable_clusters();
            if (empty($viewable_clusters)) {
                //user has no access to any clusters, so do not allow additional access
                $sql_condition = new select_filter('FALSE');
            } else {
                //user has additional access to some set of clusters, so "enable" this access
                //use the context path to find parent clusters
                $path = $DB->sql_concat('parent_context.path', "'/%'");
                list($IN, $inparams) = $DB->get_in_or_equal($viewable_clusters, SQL_PARAMS_NAMED);
                $sql_condition = new select_filter("id IN (SELECT parent_context.instanceid\n                              FROM {context} parent_context\n                              JOIN {context} child_context\n                                ON child_context.path LIKE {$path}\n                               AND parent_context.contextlevel = " . CONTEXT_ELIS_USERSET . "\n                               AND child_context.contextlevel = " . CONTEXT_ELIS_USERSET . "\n                               AND child_context.instanceid {$IN}\n                           )", $inparams);
            }
        }
        /*
         * End of cluster hierarchy extension
         */
        $context_filter = $extrafilters['contexts']->get_filter('id', 'cluster');
        //extend the basic context filter by potentially enabling access to parent clusters
        $filters[] = new OR_filter(array($context_filter, $sql_condition));
    }
    if (isset($extrafilters['parent'])) {
        $filters[] = new field_filter('parent', $extrafilters['parent']);
    }
    if (isset($extrafilters['classification'])) {
        require_once elispm::file('plugins/usetclassify/lib.php');
        $field = new field(field::get_for_context_level_with_name(CONTEXT_ELIS_USERSET, USERSET_CLASSIFICATION_FIELD));
        $filters[] = new elis_field_filter($field, 'id', CONTEXT_ELIS_USERSET, $extrafilters['classification']);
    }
    return userset::count($filters);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:50,代码来源:userset.class.php


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