Ejemplo n.º 1
0
 private function bindValueAndExecuteInsertOrUpdate(PDOStatement $stm, Contact $contact)
 {
     $stm->bindValue(':name', $contact->getName(), PDO::PARAM_STR);
     $stm->bindValue(':photo', $contact->getPhoto(), PDO::PARAM_STR);
     $stm->bindValue(':email', $contact->getEmail(), PDO::PARAM_STR);
     return $stm->execute();
 }
Ejemplo n.º 2
0
	public function displayForm($mysql, $cid = 0, $ownerid = 0) {
		$name = "";
		$email = "";
		$phone = "";
		
		if($cid != 0) {
			$con = new Contact();
			switch($con->select($cid, $ownerid, $mysql)) {
				case Contact::DATABASE_ERROR :
				{
					echo "<p>A Database error has occured.</p>";
					return;
				}
				case Contact::INVALID_DATA :
				{
					echo "<p>Invalid operation requested.</p>";
					return;
				}
				case Contact::SELECT_SUCCESS : 
				{
					$name = $con->getName();
					$email = $con->getEmail();
					$phone = $con->getPhone();
					break;
				}
				default :
					break;
			}
		}
		
		echo <<<FORM
		<div id="contact">
			<form action="" method="POST">
				<input type='hidden' name='cid' value='$cid'>
				<table>
					<tbody>
						<tr>
							<td>Name</td>
							<td><input type="text" name="cname" value="$name"/></td>
						</tr>
						<tr>
							<td>Email</td>
							<td><input type="text" name="email" value="$email"/></td>
						</tr>
						<tr>
							<td>Phone</td>
							<td><input type="text" name="phone" value="$phone"/></td>
						</tr>
						<tr>
							<td><input type="reset" value="Reset"/></td>
							<td><input type="submit"  name="action" value="Save"/></td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
FORM;

	}
Ejemplo n.º 3
0
 public function editContact(Contact $contact)
 {
     $obj = $this->db[$contact->getId()];
     $obj->setName($contact->getName());
     $obj->setPhoneContact($contact->getPhoneContact());
     $obj->setEmail($contact->getEmail());
     $this->db[$contact->getId()] = $obj;
 }
Ejemplo n.º 4
0
 function testSetContactName()
 {
     //arrange
     $name = "Jane Doe";
     $phone_number = "";
     $address = "";
     $test_contact = new Contact($name, $phone_number, $address);
     //act
     $test_contact->setName("John Doe");
     $result = $test_contact->getName();
     //assert
     $this->assertEquals("John Doe", $result);
 }
Ejemplo n.º 5
0
 public function testGetters()
 {
     $account = $this->prophesize('asylgrp\\workbench\\Domain\\AccountWrapper')->reveal();
     $mail = $this->prophesize('asylgrp\\workbench\\Domain\\DataWrapper')->reveal();
     $phone = $this->prophesize('asylgrp\\workbench\\Domain\\DataWrapper')->reveal();
     $created = new \DateTimeImmutable();
     $updated = new \DateTimeImmutable();
     $contact = new Contact('foobar', $account, $mail, $phone, true, 'comment', 'id', $created, $updated);
     $this->assertSame('foobar', $contact->getName());
     $this->assertSame($account, $contact->getAccountWrapper());
     $this->assertSame($mail, $contact->getMailWrapper());
     $this->assertSame($phone, $contact->getPhoneWrapper());
     $this->assertTrue($contact->isPayoutAllowed());
     $this->assertSame('comment', $contact->getComment());
     $this->assertSame('id', $contact->getId());
     $this->assertSame($created, $contact->getCreated());
     $this->assertSame($updated, $contact->getUpdated());
 }
Ejemplo n.º 6
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/JobOpening.php";
require_once __DIR__ . "/../src/Contact.php";
$app = new Silex\Application();
// Home Page
$app->get("/", function () {
    return "\n        <!DOCTYPE html>\n        <html>\n        <head>\n            <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n            <title>Post a Job</title>\n        </head>\n\n        <body>\n            <div class='container'>\n                <div class='row'>\n                  <div class='col-sm-6'>\n                    <h1>Post a Job</h1>\n                    <form action='/results'>\n                        <div class='form-group'>\n                            <label for='title'>Enter the job title:</label>\n                            <input id='title' name='title' class='form-control' type='text'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='description'>Enter the job description:</label>\n                            <input id='description' name='description' class='form-control' type='text'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='name'>Enter your name:</label>\n                            <input id='name' name='name' class='form-control' type='text'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='phone'>Enter your phone number:</label>\n                            <input id='phone' name='phone' class='form-control' type='number'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='email'>Enter your email:</label>\n                            <input id='email' name='email' class='form-control' type='text'>\n                        </div>\n                        <button type='submit' class='btn-success'>Submit</button>\n                    </form>\n                  </div>\n                </div>\n            </div>\n        </body>\n        </html>";
});
// Results Page
$app->get("/results", function () {
    $contact = new Contact($_GET['name'], $_GET['phone'], $_GET['email']);
    $newJob = new JobOpening($_GET['title'], $_GET['description'], $contact);
    $output = "<h3>Job: " . $newJob->getTitle() . "</h3>\n        <h4>Description: " . $newJob->getDescription() . "</h4>\n        <p>Name: " . $contact->getName() . "</p>\n        <p>Phone: " . $contact->getPhone() . "</p>\n        <p>email: " . $contact->getEmail() . "</p><hr>";
    return "\n        <!DOCTYPE html>\n        <html>\n        <head>\n            <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n            <title>Posted Job</title>\n        </head>\n\n        <body>\n            <div class='container'>\n                <div class='row'>\n                  <div class='col-sm-8'>" . $output . "</div>\n                </div>\n            </div>\n        </body>\n        </html>";
});
return $app;
Ejemplo n.º 7
0
 public function update(Contact $contact)
 {
     try {
         return $this->contactsManagerCollection->update(array('email' => $contact->getEmail()), array('name' => $contact->getName(), 'email' => $contact->getEmail(), 'photo' => $contact->getPhoto()), array('safe' => true));
     } catch (MongoCursorException $e) {
         //log
     }
     return false;
 }
 /**
  * Add team contacts to the notified user list
  **/
 function getTeamContacts()
 {
     global $DB, $CFG_GLPI;
     $query = "SELECT `items_id`\n                FROM `glpi_projecttaskteams`\n                WHERE `glpi_projecttaskteams`.`itemtype` = 'Contact'\n                      AND `glpi_projecttaskteams`.`projecttasks_id` = '" . $this->obj->fields["id"] . "'";
     $contact = new Contact();
     foreach ($DB->request($query) as $data) {
         if ($contact->getFromDB($data['items_id'])) {
             $this->addToAddressesList(array("email" => $contact->fields["email"], "name" => $contact->getName(), "language" => $CFG_GLPI["language"], 'usertype' => NotificationTarget::ANONYMOUS_USER));
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * Print the HTML array for entreprises on the current contact
  *
  *@return Nothing (display)
  **/
 static function showForContact(Contact $contact)
 {
     global $DB, $CFG_GLPI;
     $instID = $contact->fields['id'];
     if (!$contact->can($instID, READ)) {
         return false;
     }
     $canedit = $contact->can($instID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT `glpi_contacts_suppliers`.`id`,\n                       `glpi_suppliers`.`id` AS entID,\n                       `glpi_suppliers`.`name` AS name,\n                       `glpi_suppliers`.`website` AS website,\n                       `glpi_suppliers`.`fax` AS fax,\n                       `glpi_suppliers`.`phonenumber` AS phone,\n                       `glpi_suppliers`.`suppliertypes_id` AS type,\n                       `glpi_suppliers`.`is_deleted`,\n                       `glpi_entities`.`id` AS entity\n                FROM `glpi_contacts_suppliers`, `glpi_suppliers`\n                LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_suppliers`.`entities_id`)\n                WHERE `glpi_contacts_suppliers`.`contacts_id` = '{$instID}'\n                      AND `glpi_contacts_suppliers`.`suppliers_id` = `glpi_suppliers`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_suppliers", '', '', true) . "\n                ORDER BY `glpi_entities`.`completename`, `name`";
     $result = $DB->query($query);
     $suppliers = array();
     $used = array();
     if ($number = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $suppliers[$data['id']] = $data;
             $used[$data['entID']] = $data['entID'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='contactsupplier_form{$rand}' id='contactsupplier_form{$rand}'\n                method='post' action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Add a supplier') . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         echo "<input type='hidden' name='contacts_id' value='{$instID}'>";
         Supplier::dropdown(array('used' => $used, 'entity' => $contact->fields["entities_id"], 'entity_sons' => $contact->fields["is_recursive"]));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number) {
         $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_top .= "</th>";
         $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= "</th>";
     }
     $header_end .= "<th>" . __('Supplier') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Third party type') . "</th>";
     $header_end .= "<th>" . __('Phone') . "</th>";
     $header_end .= "<th>" . __('Fax') . "</th>";
     $header_end .= "<th>" . __('Website') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $used = array();
     if ($number > 0) {
         Session::initNavigateListItems('Supplier', sprintf(__('%1$s = %2$s'), Contact::getTypeName(1), $contact->getName()));
         foreach ($suppliers as $data) {
             $ID = $data["id"];
             Session::addToNavigateListItems('Supplier', $data["entID"]);
             $used[$data["entID"]] = $data["entID"];
             $website = $data["website"];
             if (!empty($website)) {
                 $website = $data["website"];
                 if (!preg_match("?https*://?", $website)) {
                     $website = "http://" . $website;
                 }
                 $website = "<a target=_blank href='{$website}'>" . $data["website"] . "</a>";
             }
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit) {
                 echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
             }
             echo "<td class='center'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id=" . $data["entID"] . "'>" . Dropdown::getDropdownName("glpi_suppliers", $data["entID"]) . "</a></td>";
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entity"]);
             echo "</td>";
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_suppliertypes", $data["type"]);
             echo "</td>";
             echo "<td class='center' width='80'>" . $data["phone"] . "</td>";
             echo "<td class='center' width='80'>" . $data["fax"] . "</td>";
             echo "<td class='center'>" . $website . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Ejemplo n.º 10
0
    $contact = new Contact();
}
$errors = array();
if (FormHelpers::donePOST()) {
    $errors = $contact->processAddEdit($_POST);
    if (sizeof($errors) == 0) {
        $contact->saveToDb();
        $show_form = false;
        ?>
<div class="message">
    The contact has been saved. <br />
    <a href="?page=contact&id=<?php 
        p($contact->getId());
        ?>
">Return to "<?php 
        p($contact->getName());
        ?>
"</a> | 
    <a href="?page=contacts">Return to contacts list</a>
</div>
<?php 
    }
}
if ($show_form) {
    ?>
<div class="section">
    <h1><?php 
    p($contact->getId() > 0 ? 'Edit' : 'Add');
    ?>
 Contact</h1>
    <h2>General Settings</h2>
Ejemplo n.º 11
0
 public function updateContact(Contact $contact)
 {
     if ($contact != null && ($contact->getId() == null || $contact->getId() == -1)) {
         return false;
     }
     try {
         if ($contact->getAddress() != null && $contact->getAddress()->getId() != null && $contact->getAddress()->getId() != -1) {
             $this->addressService->updateAddress($contact->getAddress());
         }
         if (!parent::getBdd()->inTransaction()) {
             parent::getBdd()->beginTransaction();
         }
         $query = "UPDATE CONTACT SET firstName = :fName, name = :name, mail = :mail,\n                      phone = :phone, phone2 = :phone2, phone3 = :phone3, company = :company, type = :type, exchangeId = :exchangeId\n                      WHERE id = :id";
         $request = parent::getBdd()->prepare($query);
         $request->bindParam(':id', $contact->getId());
         if ($contact->getFirstName() != null) {
             $request->bindParam(':fName', $contact->getFirstName());
         } else {
             $request->bindValue(':fName', null);
         }
         if ($contact->getName() != null) {
             $request->bindParam(':name', $contact->getName());
         } else {
             $request->bindValue(':name', null);
         }
         if ($contact->getMail() != null) {
             $request->bindParam(':mail', $contact->getMail());
         } else {
             $request->bindValue(':mail', null);
         }
         if ($contact->getPhone() != null) {
             $request->bindParam(':phone', $contact->getPhone());
         } else {
             $request->bindValue(':phone', null);
         }
         if ($contact->getPhone2() != null) {
             $request->bindParam(':phone2', $contact->getPhone2());
         } else {
             $request->bindValue(':phone2', null);
         }
         if ($contact->getPhone3() != null) {
             $request->bindParam(':phone3', $contact->getPhone3());
         } else {
             $request->bindValue(':phone3', null);
         }
         if ($contact->getCompany() != null) {
             $request->bindParam(':company', $contact->getCompany());
         } else {
             $request->bindValue(':company', null);
         }
         if ($contact->getType() != null && $contact->getType()->getId() != null && $contact->getType()->getId() != -1) {
             $request->bindParam(':type', $contact->getType()->getId());
         } elseif ($contact->getType() != null && ($contact->getType()->getId() == null || $contact->getType()->getId() == -1) && $contact->getType()->getLabel() != null) {
             $typeId = $this->typeService->getTypeIdByLabel($contact->getType()->getLabel());
             if ($typeId != -1) {
                 $request->bindParam(':type', $typeId);
             } else {
                 $request->bindValue(':type', null);
             }
         } else {
             $request->bindValue(':type', null);
         }
         if ($contact->getExchangeId() != null) {
             $request->bindParam(':exchangeId', $contact->getExchangeId());
         } else {
             $request->bindValue(':exchangeId', null);
         }
         $request->execute();
         parent::getBdd()->commit();
         $request->closeCursor();
         return true;
     } catch (Exception $e) {
         error_log($e->getMessage());
     }
     return false;
 }
Ejemplo n.º 12
0
">Return to contact</a>
</div>
<?php 
    }
}
if ($show_form) {
    ?>
<div class="section">
    <h1><?php 
    p($channel->getId() > 0 ? 'Edit' : 'Add');
    ?>
 Channel</h1>
    <h2>Information</h2>
    <div class="form-field"><strong>Contact:</strong> <?php 
    $c = new Contact($channel->getOwner());
    p($c->getName());
    ?>
</div>
    <div class="form-field"><strong>Channel Type: </strong><?php 
    p($channel->getName());
    ?>
    <div class="form-field"><strong>Description: </strong><?php 
    p($channel->getDescription());
    ?>
</div>
    </div>

    <h2>Configuration</h2>
    <?php 
    if ($channel->getId() != null) {
        FormHelpers::startForm('POST', '?page=channel&id=' . $channel->getId());
Ejemplo n.º 13
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../src/JobOpening.php';
require_once __DIR__ . '/../src/Contact.php';
$app = new Silex\Application();
$app->get("/", function () {
    return "\n            <!DOCTYPE html>\n            <html>\n            <head>\n              <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n              <link rel='stylesheet' href='css/styles.css'>\n              <title>Job Board</title>\n            </head>\n            <body>\n                <div class='container'>\n                    <h1>Job Board</h1>\n                    <form action='/job'>\n                        <div class='form-group'>\n                            <label for='title'>Enter job title:</label>\n                            <input id='title' name='title' class='form-control' type='text'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='description'>Enter job description:</label>\n                            <input id='description' name='description' class='form-control' type='text'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='name'>Enter your name:</label>\n                            <input id='name' name='name' class='form-control' type='text'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='phone_number'>Enter phone number: </label>\n                            <input id='phone_number' name='phone_number' class='form-control' type='text'>\n                        </div>\n                        <div class='form-group'>\n                            <label for='email'>Enter your email:</label>\n                            <input id='email' name='email' class='form-control' type='text'>\n                        </div>\n                        <button type='submit' class='btn-primary'>Submit</button>\n                    </form>\n                </div>\n            </body>\n            </html>\n            ";
});
$app->get("/job", function () {
    $new_job = new JobOpening($_GET["title"], $_GET["description"]);
    $new_contact = new Contact($_GET["name"], $_GET["phone_number"], $_GET["email"]);
    $output = "";
    $output = $output . "<div class='box'><p>Title: " . $new_job->getTitle() . "</p>\n            <p> Description: " . $new_job->getDescription() . "</p>\n            <p> Name: " . $new_contact->getName() . "</p>\n            <p> Phone Number: " . $new_contact->getPhoneNumber() . "</p>\n            <p> Email: " . $new_contact->getEmail() . "</div></p>";
    return "\n            <!DOCTYPE html>\n            <html>\n            <head>\n                <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n                <link rel='stylesheet' href='css/styles.css'>\n                <title>Job Posted!</title>\n            </head>\n            <body>\n                <div class='container'>\n                    <h1>Your job has been posted!</h1>\n                    <h3>The job details are:</h3>\n                    <p>{$output}</p>\n                </div>\n            </body>\n            </html>\n        ";
});
return $app;
Ejemplo n.º 14
0
 public function addContact(Contact $c)
 {
     try {
         $request = new EWSType_CreateItemType();
         $contact = new EWSType_ContactItemType();
         if ($c->getFirstName() != null) {
             $contact->GivenName = $c->getFirstName();
         }
         if ($c->getType() != null) {
             $contact->Surname = $c->getName() . ' -- ' . $c->getType()->getLabel();
         } else {
             $contact->Surname = $c->getName();
         }
         if ($c->getMail() != null) {
             $email = new EWSType_EmailAddressDictionaryEntryType();
             $email->Key = new EWSType_EmailAddressKeyType();
             $email->Key->_ = EWSType_EmailAddressKeyType::EMAIL_ADDRESS_1;
             $email->_ = $c->getMail();
             $contact->EmailAddresses = new EWSType_EmailAddressDictionaryType();
             $contact->EmailAddresses->Entry[] = $email;
         }
         if ($c->getCompany() != null) {
             $contact->CompanyName = $c->getCompany();
         }
         $addr = $c->getAddress();
         if ($addr != null) {
             $address = new EWSType_PhysicalAddressDictionaryEntryType();
             $address->Key = new EWSType_PhysicalAddressKeyType();
             $address->Key->_ = EWSType_PhysicalAddressKeyType::BUSINESS;
             if ($addr->getLine1() != null) {
                 if ($addr->getLine2() != null) {
                     $address->Street = $addr->getLine1() . ' ' . $addr->getLine2();
                 } else {
                     $address->Street = $addr->getLine1();
                 }
             }
             if ($addr->getCity() != null) {
                 $address->City = $addr->getCity();
             }
             if ($addr->getZipCode() != null) {
                 $address->PostalCode = $addr->getZipCode();
             }
             $contact->PhysicalAddresses = new EWSType_PhysicalAddressDictionaryType();
             $contact->PhysicalAddresses->Entry[] = $address;
         }
         if ($c->getPhone() != null) {
             $phone = new EWSType_PhoneNumberDictionaryEntryType();
             $phone->Key = new EWSType_PhoneNumberKeyType();
             $phone->Key->_ = EWSType_PhoneNumberKeyType::BUSINESS_PHONE;
             $phone->_ = $c->getPhone();
             $contact->PhoneNumbers->Entry[] = $phone;
         }
         if ($c->getPhone2() != null) {
             $phone = new EWSType_PhoneNumberDictionaryEntryType();
             $phone->Key = new EWSType_PhoneNumberKeyType();
             $phone->Key->_ = EWSType_PhoneNumberKeyType::BUSINESS_PHONE_2;
             $phone->_ = $c->getPhone2();
             if ($contact->PhoneNumbers == null) {
                 $contact->PhoneNumbers = new EWSType_PhoneNumberDictionaryType();
             }
             $contact->PhoneNumbers->Entry[] = $phone;
         }
         if ($c->getPhone3() != null) {
             $phone = new EWSType_PhoneNumberDictionaryEntryType();
             $phone->Key = new EWSType_PhoneNumberKeyType();
             $phone->Key->_ = EWSType_PhoneNumberKeyType::OTHER_PHONE;
             $phone->_ = $c->getPhone3();
             if ($contact->PhoneNumbers == null) {
                 $contact->PhoneNumbers = new EWSType_PhoneNumberDictionaryType();
             }
             $contact->PhoneNumbers->Entry[] = $phone;
         }
         $contact->FileAsMapping = new EWSType_FileAsMappingType();
         //?
         $contact->FileAsMapping->_ = EWSType_FileAsMappingType::FIRST_SPACE_LAST;
         $request->Items->Contact[] = $contact;
         $result = parent::getEws()->CreateItem($request);
         if ($result->ResponseMessages->CreateItemResponseMessage->Items->Contact->ItemId->Id != null) {
             $c->setExchangeId($result->ResponseMessages->CreateItemResponseMessage->Items->Contact->ItemId->Id);
         }
         return true;
     } catch (Exception $e) {
         error_log($e->getMessage());
     }
     return false;
 }