Exemplo n.º 1
0
function PhotoUploaded()
{
    $tmp_file = $_FILES['photo']['tmp_name'];
    $content_dir = dirname(__FILE__) . "/ressources/conf/upload";
    if (!is_dir($content_dir)) {
        @mkdir($content_dir);
    }
    if (!@is_uploaded_file($tmp_file)) {
        $_GET["Photo_error"] = '{error_unable_to_upload_file} ' . $tmp_file;
        exit;
    }
    $name_file = $_FILES['photo']['name'];
    if (file_exists($content_dir . "/" . $name_file)) {
        @unlink($content_dir . "/" . $name_file);
    }
    if (!move_uploaded_file($tmp_file, $content_dir . "/" . $name_file)) {
        $_GET["Photo_error"] = "{error_unable_to_move_file} : " . $content_dir . "/" . $name_file;
        exit;
    }
    $file = $content_dir . "/" . $name_file;
    if (isset($_POST["uid"])) {
        $_GET["uid"] = $_POST["uid"];
        $user = new user($_POST["uid"]);
        $user->jpegPhoto_datas = file_get_contents($file);
        $user->add_user();
        if (is_file($user->thumbnail_path)) {
            unlink($user->thumbnail_path);
        }
        return null;
    }
    if (isset($_POST["employeeNumber"])) {
        $_GET["employeeNumber"] = $_POST["employeeNumber"];
        $user = new contacts($_SESSION["uid"], $_POST["employeeNumber"]);
        $user->jpegPhoto_datas = file_get_contents($file);
        if ($_SESSION["uid"] != -100) {
            $ldap = new clladp();
            $user2 = new user($_SESSION["uid"]);
            $dn = "cn={$user->sn} {$user->givenName},ou={$user2->uid},ou=People,dc={$user2->ou},dc=NAB,{$ldap->suffix}";
            if ($dn == $user->dn) {
                $user->Save();
            } else {
                $tpl = new templates();
                echo $tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}');
            }
        }
        if (is_file($user->thumbnail_path)) {
            unlink($user->thumbnail_path);
        }
        return null;
    }
}
Exemplo n.º 2
0
function ParseContacts($uid)
{
    if ($uid == "--all") {
        ParseAllcontacts();
        return;
    }
    $ct = new user($uid);
    $f = new zarafa_contacts();
    $f->connect(null, $ct->uid, $ct->password);
    $contacts = $f->ParseContacts();
    while (list($num, $contact) = each($contacts)) {
        if ($contact["email1"] == null) {
            continue;
        }
        $_contact = new contacts($ct->uid);
        $employeeNumber = $_contact->employeeNumberByEmail($contact["email1"]);
        if ($employeeNumber != null) {
            $_contact = new contacts($ct->uid, $employeeNumber);
            if ($_contact->modifyTimestamp == $contact["last_modification_time"]) {
                continue;
            }
        }
        $_contact->displayName = $contact["display_name"];
        $_contact->fileAs = $contact["fileas"];
        $_contact->givenName = $contact["given_name"];
        // First Name=$contact["gender"];
        $_contact->telephoneNumber = $contact["office_telephone_number"];
        $_contact->homePhone = $contact["home_telephone_number"];
        $_contact->homePostalAddress = $contact["home_address_street"] . ", {$contact["home_address_postal_code"]} {$contact["home_address_city"]} {$contact["home_address_state"]}  {$contact["home_address_country"]}";
        $_contact->street = $contact["business_street"];
        //$_contact->postOfficeBox=$contact["gender"];//Professional address
        $_contact->postalCode = $contact["business_postcode"];
        $_contact->postalAddress = $contact["business_street"];
        $_contact->l = $contact["business_city"];
        //	Business city
        $_contact->st = $contact["business_state"];
        //	Business state/province
        $_contact->c = $contact["business_country"];
        // 	Country
        $_contact->mail = $contact["email1"];
        $_contact->mobile = $contact["cellular_telephone_number"];
        $_contact->labeledURI = $contact["business_home_page"];
        // personal URL
        $_contact->modifyTimestamp = $contact["last_modification_time"];
        //when entry was modified
        $_contact->department = $contact["department_name"];
        $_contact->o = $contact["company_name"];
        $_contact->note = $contact["notes"];
        if (isset($contact["email2"])) {
            $_contact->mozillaSecondEmail[] = $contact["email2"];
        }
        if (isset($contact["email3"])) {
            $_contact->mozillaSecondEmail[] = $contact["email3"];
        }
        $_contact->mozillaNickname = $contact["nickname"];
        $_contact->facsimileTelephoneNumber = $contact["primary_fax_number"];
        $_contact->Fax = $contact["primary_fax_number"];
        $_contact->nsMSNid = $contact["IM1"];
        $_contact->businessRole = $contact["profession"];
        $_contact->managerName = $contact["manager_name"];
        $_contact->assistantName = $contact["assistant"];
        if (isset($contact["birthday"])) {
            $_contact->birthDate = date("Y-m-d", $contact["birthday"]);
        }
        $_contact->spouseName = $contact["spouse_name"];
        if (isset($contact["wedding_anniversary"])) {
            $_contact->anniversary = date("Y-m-d", $contact["wedding_anniversary"]);
        }
        $_contact->modifyTimestamp = $contact["last_modification_time"];
        $_contact->title = $contact["title"];
        //Working title, as opposed to personell title. e.g. "Project leader", etc.
        $_contact->sn = $contact["surname"];
        // Last Name=$contact["gender"];
        $_contact->NoExport = true;
        $_contact->Save();
        sleep(1);
    }
}
Exemplo n.º 3
0
function CONTACT_SAVE()
{
    $uid = $_SESSION["uid"];
    if (isset($_GET["uidUser"])) {
        writelogs("Save employee id \"{$_GET["uidUser"]}\"", __FUNCTION__, __FILE__);
        $contact = new contacts($uid, null, $_GET["uidUser"]);
    } else {
        $employeeNumber = $_GET["employeeNumber"];
        writelogs("Save employee number \"{$employeeNumber}\"", __FUNCTION__, __FILE__);
        $contact = new contacts($uid, $employeeNumber);
    }
    while (list($num, $ligne) = each($_GET)) {
        $ligne = utf8_encode($ligne);
        writelogs("Save {$num}=\"" . $ligne . "\"", __FUNCTION__, __FILE__);
        $contact->{$num} = $ligne;
    }
    echo $contact->Save();
}
Exemplo n.º 4
0
function CONTACT_SAVE()
{
    $uid = $_SESSION["uid"];
    if ($_POST["uidUser"] != null) {
        writelogs("{$_SESSION["uid"]}:: Save employee id \"{$_POST["uidUser"]}\"", __FUNCTION__, __FILE__);
        $contact = new contacts($uid, null, $_POST["uidUser"]);
    }
    if ($_POST["employeeNumber"] != null) {
        $employeeNumber = $_POST["employeeNumber"];
        writelogs("{$_SESSION["uid"]}::Save employee number \"{$employeeNumber}\"", __FUNCTION__, __FILE__);
        $contact = new contacts($uid, $employeeNumber);
    }
    if ($_POST["employeeNumber"] == null && $_POST["uidUser"] == null) {
        writelogs("{$_SESSION["uid"]}::Add employee", __FUNCTION__, __FILE__);
        $contact = new contacts($uid, null);
    }
    while (list($num, $ligne) = each($_POST)) {
        $ligne = ParseSpecialsCharacters($ligne);
        $ligne = utf8_encode($ligne);
        writelogs("{$_SESSION["uid"]}::Save {$num}=\"" . $ligne . "\"", __FUNCTION__, __FILE__);
        $contact->{$num} = $ligne;
    }
    echo $contact->Save();
}