Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Customizing Members List Enhanced

Background: I have some custom fields in the Users table, and I have already modified MembersListEnhanced to display those fields.

Ok, so now for the hard part...

There are a few binary fields, let's call one "Manager", but rather than using a 0/1 for the value, I'm using Yes/No. So what I'd like to do, is modify MembersListEnhanced, and basically add functionality as such:

If the current user who is looking at the members list has a Manager field = Yes, then he is allowed to modify a few specified fields for other users. Are there access restrictions in place that would prevent this? In other words, is this even feasible?

Comments

  • Options
    peregrineperegrine MVP
    edited August 2014

    you could base the fields available based on role or register permission seems much cleaner to me.

    if they are one role they see one view a different role a different view

    you could also change register permissions.

    roles are additive.

    there is already one example in the plugin, of how its done.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Yeah, I'm still trying to decide whether to use Roles, Groups using the Groups plugin, or a field that I've added. Can't really hash out the pros and cons of each.

  • Options

    My main question is, will Garden/Vanilla prevent a user from editting a profile field for another user?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited August 2014

    Yes, but it is dependent of the permissions you set up for them in the dashboard. The way it validates the user is through their transient key which is related to user Id when they log in and if they have a certain permission to do things like edit their own profile or edit anyone's profile. But that is determined by the permissions you give them. If you set up something wrong, there is a possibility of inadvertently allow people to edit others profiles which should be not allowed.

  • Options

    @Skullduggery said:
    My main question is, will Garden/Vanilla prevent a user from editting a profile field for another user?

    the best way to determine that is login as user for the specific role you are interested and test it.

    generally you would only want admin role to have the profile/edit box checked in the roles

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Interesting... that's essentially what I want to do, is create a role that allows you to edit other peoples profiles, but I want it more granular than that. I want that role to only be able to edit a select few fields on other peoples profiles.

  • Options

    what fields? e.g.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Ok, Here are my custom fields:

    LeagueManager, Owner, GeneralManager, Team
    they're all filled with values of Yes/No except Team, which is a large drop down list of teams.

    I want LeagueManager to be able to edit all 4 fields for any user.
    I want Owner to be able to edit GeneralManager for any user, so long as that user's Team matches his Team.

  • Options
    peregrineperegrine MVP
    edited August 2014

    look at MyAttachments plugin for an example.

    you could probably do something like this

    modify it so there is a form that reads the manager and owner fields based on the sesssion id before it allows a view or permissions to change the form which is populated from the four fields pulled up based on id number in the url.

    then validate and save.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    I'm looking at the My Attachments plugin, but can't really wrap my brain around it. Grrr.

  • Options
    peregrineperegrine MVP
    edited August 2014

    take one step at a time.

    e,g, you want to add a profile tab - create a new plugn to do just that - just add a link stub.
    then do the next step and so on.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    peregrineperegrine MVP
    edited August 2014

    by the way the title has nothing to do with thread.

    which is building a draftpicks plugin.

    @‌Skullduggery

    install it and you will see an option on user page.

    here is a really, really basic start. It doesn't save anything per se, except provde a clickable link to a view, it does no permission checking.

    but its a little bit of a framework.

    if you haven't gotten this far. spend a few days on adding things, and then if you have a problem with something, some one can probably suggest something.

    or provide something better than this rough idea. you can look at other plugins get more ideas.

    plugins/DraftPicks/default.php

        <?php if(!defined('APPLICATION')) exit();
        $PluginInfo['DraftPicks'] = array(
            'Name' => 'Draft Picks',
            'Description' => 'Add a draft picks option to profile tabs menu',
            'Version' => '1.0',
            'Author' => 'Sample',
         );
    
    
    
        class DraftPicks extends Gdn_Plugin {
    
    
         // add link to profile tab
          public function ProfileController_AddProfileTabs_handler($Sender) {
    
          $Sender->AddProfileTab('draftpicks', '/profile/draftpicks/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name), 'DraftPicks', T('Draft Picks'));
          }
    
          public function ProfileController_DraftPicks_Create($Sender, $Args) {
            $Session = Gdn::Session();
            // parse out the sent args
            $UserID = GetValue(0, $Args, $Session->UserID);
            $Sender->GetUserInfo($UserID, 'Cannot be NULL');
    
            if($UserID < 1) {
              throw NotFoundException('User');
            }
    
           // $DraftPicksModel = new DraftPicksModel();
    
           // go to view
            $Sender->SetTabView('draftpicks', $this->GetView('draftpicks.php'), 'Profile');    
            $Sender->Render();
          }
        }
    

    plugins/views/draftpicks.php

        <?php if (!defined('APPLICATION')) exit();
        echo '<div class="FormTitleWrapper">';
        echo '<h1 class="H">' .  T('Choose Your ...') . "</h1>";
                        $Session = Gdn::Session();
                        $SessionUser = $Session->UserID;
                        echo  "This is the session user id: $SessionUser";
                        $ProfileUser = $this->User->Name;
                        $ProfileUserID = $this->User->UserID;
    
                        echo  " This is the userid and name  who we are looking at: $ProfileUserID :$ProfileUser  ";
    
        echo $this->Form->Open();
        echo $this->Form->Errors();
    
        ?>
    
    
        <p></p>
    
    
        <ul>
             <li>
              <?php
    
    
                        $optionarray[0] = 'Name 0';
                        $optionarray[1] = 'Name 1';
    
    
                    $Fields = array('TextField' => 'Code', 'ValueField' => 'Code');
                    echo $this->Form->DropDown('MyField', $optionarray, $Fields);
              ?>
           </li>
         </ul>
    
        <?php echo $this->Form->Close(T('Save')); ?>
         </div>
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    what would be cool is to have avatars of all possible picks. And drag and drop players into team slots.

    similar to the way the categories are moveable and droppable in dasboard. it would be alot of work, but a pretty cool plugin.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    edited August 2014

    @peregrine said:
    take one step at a time.

    e,g, you want to add a profile tab - create a new plugn to do just that - just add a link stub.
    then do the next step and so on.

    I am, I am! B)

    What I'm actually trying to do is the first step before there is any sort of draft. Which is: Administrator manually chooses a "League Manager", and either that field in the Users table gets updated to reflect that, or he is assigned to a custom role "LeagueManager". Either way should in theory work.

    League Manager similarly chooses Owners (team owners). Owners are the ones who draft from the pool of Free Agents (which are any members who are have not updated their profile field of Active to "Retired", and who are not already assigned to a Team - which is the other profile field).

    edit: The more I think about it, I guess I would be fine with manually doing this as the Administrator as well, but if I were able to figure out how to let one user edit another users User table, that would solve the major hurdle I see going forward.

    But if I can't figure out those first two steps... then man, I've got my work cut out for me. I'm looking through the wiki's - but what I can't find are all the available functions that can be used... where is that? Do I just gather that information from looking at other plugins?

    For example, where do I see a list of all the public functions (e.g. ProfileController_AddProfileTabs_handler)

  • Options
    peregrineperegrine MVP
    edited August 2014

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.