Get editable fields

@param int $instanceid
@return field_controller[]
171576
public function get_editable_fields(int $instanceid) : array {
        $handler = $this;
        return array_filter($this->get_fields(),
            function($field) use($handler, $instanceid) {
                return $handler->can_edit($field, $instanceid);
            }
        );
    }
596569
public List<TableProperty> getEditableColumns(CmsMessageBundleEditorTypes.EditMode mode) {

        return m_editorState.get(mode).getEditableColumns();
    }
79782
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            "Root.Main",
            array(
                TextareaField::create(
                    'Title'
                )->setRows(1),
                HTMLEditorField::create(
                    'Content'
                )
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
509674
public function getCMSFields()
    {
        $fields = $this->scaffoldFormFields(
            array(
                // Don't allow has_many/many_many relationship editing before the record is first saved
                'includeRelations' => ($this->ID > 0),
                'tabbed' => true,
                'ajaxSafe' => true
            )
        );
        $fields->removeByName(
            array(
                'Title',
                'Instance',
                'Style',
                'Objects'
            )
        );
        if (!$this->IsMain) {
            $fields->addFieldsToTab(
                'Root.Main',
                array(
                    TextField::create(
                        'Title',
                        _t('PlaceableObject_Preset.TITLE', 'Title')
                    ),
                    DropdownField::create(
                        'Instance',
                        _t('PlaceableObject_Preset.INSTANCE', 'Instance'),
                        singleton('PlaceableObject_Preset')->dbObject('Instance')->enumValues()
                    )
                )
            );
        }
        if ($this->Styles) {
            $fields->addFieldToTab(
                'Root.Main',
                DropdownField::create(
                    'Style',
                    _t('PlaceableObject_Preset.STYLE', 'Style'),
                    $this->Styles
                )->setEmptyString(_t('PlaceableObject_Preset.DEFAULTSTYLE', 'Default'))
            );
        }
        $fields->addFieldsToTab(
            'Root.Objects',
            array(
                LabelField::create(
                    'ObjectsDescription',
                    _t('PlaceableObject_Preset.OBJECTSDESCRIPTION', 'List of all objects that use this use this preset.')
                ),
                GridField::create(
                    'Objects',
                    _t('PlaceableObject_Preset.OBJECTS', 'Objects'),
                    $this->Objects(),
                    GridFieldConfig_Base::create()
                )
            )
        );
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
529680
public List<String> listInstanceIDs(final Set<String> instanceIDs) {
        Set<String> allInstanceIDs = allMockEc2Instances.keySet();
        if (null == instanceIDs || instanceIDs.size() == 0) {
            return new ArrayList<String>(allInstanceIDs);
        } else {
            List<String> filteredInstanceIDs = new ArrayList<String>();
            for (String id : allInstanceIDs) {
                if (null != id && instanceIDs.contains(id)) {
                    filteredInstanceIDs.add(id);
                }
            }
            return filteredInstanceIDs;
        }
    }
1246196
public function getEditor($editorId)
    {
        return $this->getFilters()->filter(function (WysiwygEditorInterface $editor) use ($editorId) {
            return $editor->getId() == $editorId;
        })->first();
    }
1182155
public function getUserCapabilities(string $userId): array
    {
        if (empty($this->userCapabilities)) {
            $this->userCapabilities = Utils::fetchUserCapabilities($userId);
        }

        return $this->userCapabilities;
    }
996299
public List<String> getDatabaseDdl(String instanceId, String databaseId) {
    // [START getDatabaseDdl]
    List<String> statementsInDb = dbAdminClient.getDatabaseDdl(instanceId, databaseId);
    // [END getDatabaseDdl]
    return statementsInDb;
  }
390088
public function delete_instance(int $instanceid) {
        $fielddata = api::get_instance_fields_data($this->get_fields(), $instanceid, false);
        foreach ($fielddata as $data) {
            $data->delete();
        }
    }
454584
public function Edit($UserID) {
      $this->Permission('Garden.Users.Edit');
      
      // Page setup
      $this->AddJsFile('user.js');
      $this->Title(T('Edit User'));
      $this->AddSideMenu('dashboard/user');

      // By default, people with access here can freely assign all roles
      $RoleModel = new RoleModel();
      $RoleData = $AllRoles = $RoleModel->GetArray();

      // Hide personal info roles
      if (!CheckPermission('Garden.PersonalInfo.View')) {
         $RoleData = array_filter($RoleData, 'RoleModel::FilterPersonalInfo');
      }

      $UserModel = new UserModel();
      $User = $UserModel->GetID($UserID, DATASET_TYPE_ARRAY);
      
      // Determine if username can be edited
      $CanEditUsername = (bool)C("Garden.Profile.EditUsernames") || Gdn::Session()->CheckPermission('Garden.Users.Edit');
      $this->SetData('_CanEditUsername', $CanEditUsername);
      
      // Determine if emails can be edited
      $CanEditEmail = (
              Gdn::Session()->CheckPermission('Garden.Users.Edit') && 
              Gdn::Session()->CheckPermission('Garden.PersonalInfo.View')
           );
      $this->SetData('_CanEditEmail', $CanEditEmail);
      
      // Decide if they have ability to confirm users
      $Confirmed = (bool)GetValueR('Confirmed', $User);
      $CanConfirmEmail = (
              UserModel::RequireConfirmEmail() &&
              Gdn::Session()->CheckPermission('Garden.Users.Edit') && 
              Gdn::Session()->CheckPermission('Garden.PersonalInfo.View'));
      $this->SetData('_CanConfirmEmail', $CanConfirmEmail);
      $this->SetData('_EmailConfirmed', $Confirmed);
      $User['ConfirmEmail'] = (int)$Confirmed;

      // Set the model on the form.
      $this->Form->SetModel($UserModel);

      // Make sure the form knows which item we are editing.
      $this->Form->AddHidden('UserID', $UserID);

      try {
         
         $AllowEditing = TRUE;
         $this->EventArguments['AllowEditing'] = &$AllowEditing;
         $this->EventArguments['TargetUser'] = &$User;
         
         // These are all the 'effective' roles for this edit action. This list can
         // be trimmed down from the real list to allow subsets of roles to be
         // edited.
         $this->EventArguments['RoleData'] = &$RoleData;
         
         $UserRoleData = $UserModel->GetRoles($UserID)->ResultArray();
         $RoleIDs = ConsolidateArrayValuesByKey($UserRoleData, 'RoleID');
         $RoleNames = ConsolidateArrayValuesByKey($UserRoleData, 'Name');
         $UserRoleData = ArrayCombine($RoleIDs, $RoleNames);
         $this->EventArguments['UserRoleData'] = &$UserRoleData;
         
         $this->FireEvent("BeforeUserEdit");
         $this->SetData('AllowEditing', $AllowEditing);
         
         $this->Form->SetData($User);
         if ($this->Form->AuthenticatedPostBack()) {
            
            if (!$CanEditUsername)
               $this->Form->SetFormValue("Name", $User['Name']);
            
            // Allow mods to confirm/unconfirm emails
            $this->Form->RemoveFormValue('Confirmed');
            $Confirmation = $this->Form->GetFormValue('ConfirmEmail', null);
            $Confirmation = !is_null($Confirmation) ? (bool)$Confirmation : null;

            if ($CanConfirmEmail && is_bool($Confirmation))
               $this->Form->SetFormValue('Confirmed', (int)$Confirmation);
            
            // If a new password was specified, add it to the form's collection
            $ResetPassword = $this->Form->GetValue('ResetPassword', FALSE);
            $NewPassword = $this->Form->GetValue('NewPassword', '');
            if ($ResetPassword == 'Manual') 
               $this->Form->SetFormValue('Password', $NewPassword);
            
            // Role changes
            
            // These are the new roles the editing user wishes to apply to the target
            // user, adjusted for his ability to affect those roles
            $RequestedRoles = $this->Form->GetFormValue('RoleID');
            
            if (!is_array($RequestedRoles)) $RequestedRoles = array();
            $RequestedRoles = array_flip($RequestedRoles);
            $UserNewRoles = array_intersect_key($RoleData, $RequestedRoles);
            
            // These roles will stay turned on regardless of the form submission contents 
            // because the editing user does not have permission to modify them
            $ImmutableRoles = array_diff_key($AllRoles, $RoleData);
            $UserImmutableRoles = array_intersect_key($ImmutableRoles, $UserRoleData);
            
            // Apply immutable roles
            foreach ($UserImmutableRoles as $IMRoleID => $IMRoleName)
               $UserNewRoles[$IMRoleID] = $IMRoleName;
            
            // Put the data back into the forum object as if the user had submitted 
            // this themselves
            $this->Form->SetFormValue('RoleID', array_keys($UserNewRoles));
            
            if ($this->Form->Save(array('SaveRoles' => TRUE)) !== FALSE) {
               if ($this->Form->GetValue('ResetPassword', '') == 'Auto') {
                  $UserModel->PasswordRequest($User['Email']);
                  $UserModel->SetField($UserID, 'HashMethod', 'Reset'); 
               }

               $this->InformMessage(T('Your changes have been saved.'));
            }
            
            $UserRoleData = $UserNewRoles;
         }
      } catch (Exception $Ex) {
         $this->Form->AddError($Ex);
      }
      
      $this->SetData('User', $User);
      $this->SetData('Roles', $RoleData);
      $this->SetData('UserRoles', $UserRoleData);
      
      $this->Render();
   }
324178
protected function resolveEditableField(FieldContract $control, array $editable = array())
    {
        $name = $control->get('name');
        if ($control->force_editable) {
            return $control;
        }
        $shouldBeEdited = false;
        foreach ($editable as $editableField) {
            if ($name == $editableField['name']) {
                $shouldBeEdited = true;
                break;
            }
        }
        $disable    = $shouldBeEdited ? [] : ['disabled' => 'disabled', 'readonly' => 'readonly'];
        $attributes = array_merge($control->get('attributes'), $disable);
        $control->attributes($attributes);
        return $control;
    }
1030872
public function getCarouselEditFields()
    {
        // This is *required* otherwise TinyMCE in SilverStripe 3.3 will
        // not be enabled and the <textarea> will simply disappear
        // without apparent reasons
        if (method_exists('HtmlEditorConfig', 'require_js')) {
            HtmlEditorConfig::require_js();
        }

        $fields = FieldList::create();
        $fields->push(CarouselCaptionField::create('Content', _t('CarouselPage.Caption')));
        return $fields;
    }
396246
public static function get_instance_info($instanceid) {
        global $DB, $CFG;

        require_once($CFG->libdir . '/enrollib.php');

        $params = self::validate_parameters(self::get_instance_info_parameters(), array('instanceid' => $instanceid));

        // Retrieve self enrolment plugin.
        $enrolplugin = enrol_get_plugin('self');
        if (empty($enrolplugin)) {
            throw new moodle_exception('invaliddata', 'error');
        }

        self::validate_context(context_system::instance());

        $enrolinstance = $DB->get_record('enrol', array('id' => $params['instanceid']), '*', MUST_EXIST);
        $course = $DB->get_record('course', array('id' => $enrolinstance->courseid), '*', MUST_EXIST);
        if (!core_course_category::can_view_course_info($course) && !can_access_course($course)) {
            throw new moodle_exception('coursehidden');
        }

        $instanceinfo = (array) $enrolplugin->get_enrol_info($enrolinstance);
        if (isset($instanceinfo['requiredparam']->enrolpassword)) {
            $instanceinfo['enrolpassword'] = $instanceinfo['requiredparam']->enrolpassword;
        }
        unset($instanceinfo->requiredparam);

        return $instanceinfo;
    }
1214149
public function get_user_enrolments($userid) {
        global $DB;
        list($instancessql, $params, $filter) = $this->get_instance_sql();
        $params['userid'] = $userid;
        $userenrolments = $DB->get_records_select('user_enrolments', "enrolid $instancessql AND userid = :userid", $params);
        $instances = $this->get_enrolment_instances();
        $plugins = $this->get_enrolment_plugins(false);
        $inames = $this->get_enrolment_instance_names();
        foreach ($userenrolments as &$ue) {
            $ue->enrolmentinstance     = $instances[$ue->enrolid];
            $ue->enrolmentplugin       = $plugins[$ue->enrolmentinstance->enrol];
            $ue->enrolmentinstancename = $inames[$ue->enrolmentinstance->id];
        }
        return $userenrolments;
    }
1273784
private function getEditableProperties()
    {
        if (!isset($this->_editableProperties)) {
            $reflection = new ReflectionClass('WhEditableField');
            $this->_editableProperties = array_map(
                function ($d) {
                    return $d->getName();
                },
                $reflection->getProperties()
            );
        }
        return $this->_editableProperties;
    }
1221570
protected function get_activity($instanceid) {
        global $DB;

        if (empty($this->activitiesdata[$this->get_module_name()][$instanceid])) {
            $this->activitiesdata[$this->get_module_name()][$instanceid] = $DB->get_record($this->get_module_name(),
                array('id' => $instanceid), '*', MUST_EXIST);
        }
        return $this->activitiesdata[$this->get_module_name()][$instanceid];

    }
1204616
public function can_edit(field_controller $field, int $instanceid = 0) : bool {
        if ($instanceid) {
            $context = $this->get_instance_context($instanceid);
            return (!$field->get_configdata_property('locked') ||
                    has_capability('moodle/course:changelockedcustomfields', $context));
        } else {
            $context = $this->get_parent_context();
            return (!$field->get_configdata_property('locked') ||
                guess_if_creator_will_have_course_capability('moodle/course:changelockedcustomfields', $context));
        }
    }