Beispiel #1
0
function group_actions($command, $values)
{
    // Set initial return value
    $r = false;
    $ga = explode(';', $command);
    $mode = $ga[0];
    switch ($mode) {
        case "account":
            foreach ($values as $key => $value) {
                // key contains mail
                $key1 = explode('@', $key);
                // Create right DN for account and domain
                $dn = 'mail=' . $key . ',vd=' . $key1[1] . ',' . LDAP_BASE;
                $dn_domain = 'vd=' . $key1[1] . ',' . LDAP_BASE;
                // Pre-load values for account adn domain
                $self_values = PhammLdap::phamm_self_values($dn, $filter = "(objectClass=*)");
                $domain_values = PhammLdap::phamm_self_values($dn_domain, $filter = "(objectClass=*)");
                // (string) needed for TRUE and FALSE not real boolean...
                $entry[$ga[1]] = (string) $ga[2];
                $is_alias = in_array('VirtualMailAlias', $self_values[0]["objectclass"]) ? true : false;
                foreach ($entry as $k_entry => $v_entry) {
                    if ($v_entry == 'TRUE') {
                        $max_key = strtolower('max' . $k_entry);
                        if (isset($domain_values[0][$max_key][0])) {
                            $max_val = $domain_values[0][$max_key][0];
                            $active_val = PhammLdap::phamm_self_values($dn_domain, '(&(objectClass=*)(' . $k_entry . '=TRUE))');
                            if ($active_val["count"] >= $max_val) {
                                phamm_print_message('warning', sprintf(_("The maximum number of attribute %s (%s) has been reached or exceeded!"), $k_entry, $max_val));
                                return false;
                            }
                        }
                    }
                }
                // Delete immediate if VirtualMailAlias
                if (isset($entry["delete"]) && $is_alias) {
                    $r = PhammLdap::phamm_delete($dn, $recursive = false);
                } else {
                    $r = PhammLdap::phamm_modify($dn, $entry);
                }
            }
            break;
        case "domain":
            foreach ($values as $key => $value) {
                // Create right DN
                // $dn = 'cn=postmaster,vd='.$key.','.LDAP_BASE;
                $dn = 'vd=' . $key . ',' . LDAP_BASE;
                // (string) needed for TRUE and FALSE not real boolean...
                $entry[$ga[1]] = (string) $ga[2];
                // Change single value
                $r = PhammLdap::phamm_modify($dn, $entry);
            }
            break;
        case "postmaster":
            foreach ($values as $key => $value) {
                // Create right DN
                // $dn = 'cn=postmaster,vd='.$key.','.LDAP_BASE;
                $dn = 'cn=postmaster,vd=' . $key . ',' . LDAP_BASE;
                // (string) needed for TRUE and FALSE not real boolean...
                $entry[$ga[1]] = (string) $ga[2];
                // Change single value
                $r = PhammLdap::phamm_modify($dn, $entry);
            }
            break;
    }
    return $r;
}
Beispiel #2
0
         unset($entry["cn"]);
         unset($entry["sn"]);
         unset($entry["givenname"]);
         $entry["lastChange"] = time();
         if ($password1) {
             $entry["userPassword"] = phamm_password_hash($password1);
         }
         // Clear creationdata
         if (isset($entry["creationdate"])) {
             unset($entry["creationdate"]);
         }
         $r = PhammLdap::phamm_modify('cn=postmaster,vd=' . $domain . ',' . LDAP_BASE, $entry);
         $log->phamm_log($pn, $_SESSION["login"]["username"], $action . ' postmaster@' . $domain, $r);
         // Update domain values
         $entry_domain = purge_empty_values($values["domain"]);
         $r_d = PhammLdap::phamm_modify('vd=' . $domain . ',' . LDAP_BASE, $entry_domain);
         $log->phamm_log($pn, $_SESSION["login"]["username"], 'update_domain ' . $domain, $r);
     }
     if ($r) {
         phamm_print_message('success', sprintf("Account %s succesfully updated", $account));
         refresh('main.php?action=domain_view&domain=' . $domain, $force_meta = false, REFRESH_TIME);
     } else {
         phamm_print_message('error', sprintf(_("account %s not updated!"), $account));
     }
     break;
 case "domain_property":
     $dn = 'vd=' . $domain . ',' . LDAP_BASE;
     $values = PhammLdap::phamm_search($dn, $filter = "objectClass=VirtualDomain");
     $dn_postmaster = 'cn=postmaster,vd=' . $domain . ',' . LDAP_BASE;
     $values_postmaster = PhammLdap::phamm_search($dn_postmaster, $filter = "cn=postmaster");
     phamm_print_xhtml(form_add_domain_2($domain, 'update_account', $values, $values_postmaster));