Jump to content

Pilot table updates


Ither

Recommended Posts

Short story; I'm modifying pilot edit page and including things I want. I'm not using custom fields module (just don't want to.) I've created the columns in the pilot table and have my form completed. However, I cannot for life of me figure out where everything is calling from. I looked at PilotData.class.php and I see the UpdateProfile function but it doesn't necessary tell me what specific fields it is looking for. Array is commented out (assuming code change.) Has anyone (outside of using custom fields) actually been able to get custom form and have it truly populate db? I'm little good at this, not an expert, but enough I can navigate to extent and do things.

 

    public static function updateProfile($pilotid, $params) {
    
        /*$params = array(
            'pilotid' => '',
            'code' => '',
            'email' => '',
            'location' => '',
            'hub' => '',
            'bgimage' => '',
            'retired' => false,
			'ivao' => '',
			'vatsim' => '',
            );
         */

        if(empty($pilotid)) {
            return false;
        }
        
        if (!is_array($params)) {
            return false;
        }

        /* Cleanup any specific parameters */
        if (isset($params['location'])) {
            $params['location'] = strtoupper($params['location']);
        }
                
        if (isset($params['pilotid'])) {
            unset($params['pilotid']);
        }

        $sql = "UPDATE " . TABLE_PREFIX . "pilots SET ";
        $sql .= DB::build_update($params);
        $sql .= " WHERE `pilotid`={$pilotid}";

        $res = DB::query($sql);
        
        if (DB::errno() != 0) {
            return false;
        }
        
        # Auto groups?
        $groups = Config::get('PILOT_STATUS_TYPES');
        if(isset($params['retired'])) {
            
            $info = $groups[$params['retired']];
            
            # Automatically add into these groups
            if(is_array($info['group_add']) && count($info['group_add']) > 0) {
                foreach($info['group_add'] as $group) {
                    PilotGroups::addUsertoGroup($pilotid, $group);
                }
            }
            
            if(is_array($info['group_remove']) && count($info['group_remove']) > 0) {
                foreach($info['group_remove'] as $group) {
                    PilotGroups::removeUserFromGroup($pilotid, $group);
                }
            }
        }
        
        return true;
    }

 

Edited by Ither
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...