Ejemplo n.º 1
0
function plugin_addressing_MassiveActionsProcess($data)
{
    $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
    switch ($data['action']) {
        case 'plugin_addressing_allow':
            if ($data['itemtype'] == 'Profile') {
                $profglpi = new Profile();
                $prof = new PluginAddressingProfile();
                foreach ($data["item"] as $key => $val) {
                    if ($profglpi->getFromDB($key) && $profglpi->fields['interface'] != 'helpdesk') {
                        if ($prof->getFromDBByProfile($key)) {
                            if ($prof->update(array('id' => $prof->fields['id'], 'profiles_id' => $key, 'addressing' => $data['use']))) {
                                $res['ok']++;
                            } else {
                                $res['ko']++;
                            }
                        } else {
                            if ($prof->add(array('id' => $prof->fields['id'], 'profiles_id' => $key, 'addressing' => $data['use']))) {
                                $res['ok']++;
                            } else {
                                $res['ko']++;
                            }
                        }
                    } else {
                        $res['ko']++;
                    }
                }
            }
            break;
    }
    return $res;
}