Esempio n. 1
0
function addContactExist()
{
    //global all variables
    global $contactForm;
    $allUser = $_POST['user'];
    $contactType = new PersonType($_POST['type']);
    $group = new Contact($_GET['groupID']);
    $allnames = array();
    foreach ($allUser as $id => $value) {
        $contact = new Person($value);
        if ($group->add_contact($contact->get_contact_id(), $contactType->get_contact_type_id(), $contact->get_first_name() . " " . $contact->get_last_name() . " is added to this group")) {
            $finish = true;
            array_push($allnames, $contact->get_first_name() . " " . $contact->get_last_name() . " to " . $contactType->get_name());
        } else {
            $link = $_SERVER['PHP_SELF'] . "?action=showGroup&groupID=" . $_GET['groupID'];
            $contactForm->error("Warning: Failed to update. Reason: " . $contact->get_error(), $link);
            $finish = false;
            break;
        }
    }
    if ($finish) {
        $status = "success";
        $string = "";
        foreach ($allnames as $id => $value) {
            $string .= $value . ". ";
        }
        $_SESSION['action'] = "Added Contact: " . $string;
        echo "<meta http-equiv=\"REFRESH\" content=\"0;url=" . $_SERVER['PHP_SELF'] . "?action=showGroup&groupID=" . $_GET['groupID'] . "&add=" . $status . "\">";
        //2010-01-04 08:56:34
    }
}
Esempio n. 2
0
 function remove_contact($contact_id, $contact_type_id)
 {
     // First check if this is a valid contactid
     $contact = new Person($contact_id);
     if (!$contact->get_contact_id()) {
         $this->error = "Invalid contact id, could not find contact information";
         return false;
     }
     // check if this is a valid contact type
     $contact_type = new PersonType($contact_type_id);
     if (!$contact_type->get_contact_type_id()) {
         $this->error = "Invalid contact type id, could not find contact type";
         return false;
     }
     if (!is_numeric($this->group_id)) {
         $this->error = "Invalid group id";
         return false;
     }
     $query = "delete from groups_contacts  WHERE \n\t\t\t\tgroup_id = '{$this->group_id}' AND\n\t\t\t\tcontact_id = '{$contact_id}' AND\n\t\t\t\tcontact_type = '{$contact_type_id}'";
     // execute the query
     $result = mysql_query($query);
     if (!$result) {
         $this->error = mysql_error() . "  ---query:   {$query}";
         return false;
     }
     return true;
 }