本文整理汇总了PHP中Contact类的典型用法代码示例。如果您正苦于以下问题:PHP Contact类的具体用法?PHP Contact怎么用?PHP Contact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(){
$name = $this->f3->get('POST.name');
$email = $this->f3->get('POST.email');
$comments = $this->f3->get('POST.comments');
$v = new Valitron\Validator(array('Name' => $name,'Email'=>$email,'Comments'=>$comments));
$v->rule('required', ['Name','Email','Comments']);
$v->rule('email',[Email]);
if ($v->validate()) {
$contact = new Contact($this->db);
$data = array(
'name' => $name,
'email' => $email,
'comments' => $comments,
'contact_date' => date('Y-m-d H:i:s')
);
$contact->insert($data);
$response = array(
'status' => true,
'message' => 'Your message saved!'
);
}else{
$response = array(
'status' => false,
'errors' => $v->errors()
);
}
echo json_encode($response);
}
示例2: postContact
public function postContact()
{
global $smarty, $cookie;
session_start();
if ($_SESSION['validate_code'] == strtolower(Tools::getRequest('validate_code'))) {
if ($cookie->isLogged()) {
$user = new User($cookie->id_user);
$_POST['name'] = $user->first_name . ' ' . $user->last_name;
$_POST['email'] = $user->email;
if (isset($_POST['id_user'])) {
unset($_POST['id_user']);
}
$_POST['id_user'] = $user->id;
}
$contact = new Contact();
$contact->copyFromPost();
if ($contact->add()) {
$vars = array('{name}' => $contact->name, '{subject}' => $contact->subject, '{email}' => $contact->email, '{message}' => $contact->content);
Mail::Send('contact', $contact->subject, $vars, Configuration::get('TM_SHOP_EMAIL'));
$this->_success = 'Your message has been successfully sent to our team.';
} else {
$this->_errors = $contact->_errors;
}
} else {
$this->_errors[] = 'Confirmation code is error!';
}
}
示例3: createDefaultUserPermissionsAllDimension
static function createDefaultUserPermissionsAllDimension(Contact $user, $dimension_id, $remove_previous = true)
{
$role_id = $user->getUserType();
$permission_group_id = $user->getPermissionGroupId();
$dimension = Dimensions::getDimensionById($dimension_id);
if (!$dimension instanceof Dimension || !$dimension->getDefinesPermissions()) {
return;
}
try {
$shtab_permissions = array();
$new_permissions = array();
$role_permissions = self::findAll(array('conditions' => "role_id = '{$role_id}'"));
$members = Members::findAll(array('conditions' => 'dimension_id = ' . $dimension_id));
foreach ($members as $member) {
$member_id = $member->getId();
if ($remove_previous) {
ContactMemberPermissions::delete("permission_group_id = {$permission_group_id} AND member_id = {$member_id}");
}
foreach ($role_permissions as $role_perm) {
if ($member->canContainObject($role_perm->getObjectTypeId())) {
$cmp = new ContactMemberPermission();
$cmp->setPermissionGroupId($permission_group_id);
$cmp->setMemberId($member_id);
$cmp->setObjectTypeId($role_perm->getObjectTypeId());
$cmp->setCanDelete($role_perm->getCanDelete());
$cmp->setCanWrite($role_perm->getCanWrite());
$cmp->save();
$new_permissions[] = $cmp;
$perm = new stdClass();
$perm->m = $member_id;
$perm->r = 1;
$perm->w = $role_perm->getCanWrite();
$perm->d = $role_perm->getCanDelete();
$perm->o = $role_perm->getObjectTypeId();
$shtab_permissions[] = $perm;
}
}
}
if (count($shtab_permissions)) {
$cdp = ContactDimensionPermissions::instance()->findOne(array('conditions' => "permission_group_id = '{$permission_group_id}' AND dimension_id = {$dimension_id}"));
if (!$cdp instanceof ContactDimensionPermission) {
$cdp = new ContactDimensionPermission();
$cdp->setPermissionGroupId($permission_group_id);
$cdp->setContactDimensionId($dimension_id);
$cdp->setPermissionType('check');
$cdp->save();
} else {
if ($cdp->getPermissionType() == 'deny all') {
$cdp->setPermissionType('check');
$cdp->save();
}
}
$stCtrl = new SharingTableController();
$stCtrl->afterPermissionChanged($permission_group_id, $shtab_permissions);
}
return $new_permissions;
} catch (Exception $e) {
throw $e;
}
}
示例4: contact
public function contact()
{
$content = Content::find_by_permalink("contact");
$this->assign("content", $content);
$contact = new Contact();
if ($this->post) {
$contact->name = $_POST['name'];
$contact->emailaddress = $_POST['emailaddress'];
$contact->subject = $_POST['subject'];
$contact->message = $_POST['message'];
$contact->ip = Site::RemoteIP();
if ($this->csrf) {
$sent = $contact->send();
if ($sent) {
Site::flash("notice", "The email has been sent");
Redirect("contact");
}
} else {
global $site;
$site['flash']['error'] = "Invalid form submission";
}
}
$this->assign("contact", $contact);
$this->title = "Contact Us";
$this->render("contact/contact.tpl");
}
示例5: sendAction
public function sendAction()
{
if ($this->request->isPost() == true) {
$name = $this->request->getPost('name', 'string');
$email = $this->request->getPost('email', 'email');
$comments = $this->request->getPost('comments', 'string');
$name = strip_tags($name);
$comments = strip_tags($comments);
$contact = new Contact();
$contact->name = $name;
$contact->email = $email;
$contact->comments = $comments;
$contact->created_at = new Phalcon_Db_RawValue('now()');
if ($contact->save() == false) {
foreach ($contact->getMessages() as $message) {
Phalcon_Flash::error((string) $message, 'alert alert-error');
}
return $this->_forward('contact/index');
} else {
Phalcon_Flash::success('Thanks, We will contact you in the next few hours', 'alert alert-success');
return $this->_forward('index/index');
}
} else {
return $this->_forward('contact/index');
}
}
示例6: saveContactUs
/**
* save contact enquiry
*/
public function saveContactUs()
{
$name = Input::get('name');
$email = Input::get('email');
$phone = Input::get('phone');
$contact_method = Input::get('contact_method');
$enquiry = e(Input::get('enquiry'));
$invoice_number = Input::get('invoice_number');
// check for required fields
if (empty($name) || empty($email)) {
echo "Name and email are required. Please submit the form again";
return;
}
// save the data in database first
$contact = new Contact();
$contact->name = $name;
$contact->email = $email;
$contact->phone_number = $phone;
$contact->contact_method = $contact_method;
$contact->enquiry_info = $enquiry;
$contact->invoice_number = $invoice_number;
$contact->save();
// send email
/**
* configure the smtp details in app/config/mail.php
* and after that uncommet the code below to send emails
*/
// Mail::send('emails.contact.contact', Input::all('firstname'),
// function($message){
// $message->to(Config::get('contact.contact_email'))
// ->subject(Config::get('contact.contact_subject'));
// }
// );
echo "Enquiry Submitted. ThankYou.";
}
示例7: sendAction
/**
* Handles the sending the message - storing it in the database
*
* @todo Refactor this to send an email
*/
public function sendAction()
{
if ($this->request->isPost() == true) {
$forward = 'index/index';
$name = $this->request->getPost('name', 'string');
$email = $this->request->getPost('email', 'email');
$comments = $this->request->getPost('comments', 'string');
$name = strip_tags($name);
$comments = strip_tags($comments);
$contact = new Contact();
$contact->name = $name;
$contact->email = $email;
$contact->comments = $comments;
$contact->createdAt = new Phalcon_Db_RawValue('now()');
if ($contact->save() == false) {
foreach ($contact->getMessages() as $message) {
Flash::error((string) $message, 'alert alert-error');
}
$forward = 'contact/index';
} else {
$message = 'Thank you for your input. If your message requires ' . 'a reply, we will contact you as soon as possible.';
Flash::success($message, 'alert alert-success');
}
} else {
$forward = 'contact/index';
}
return $this->_forward($forward);
}
示例8: indexAction
public function indexAction()
{
$this->view->Title = 'Đặt hàng';
$this->view->headTitle($this->view->Title);
$id = $this->getRequest()->getParam("id_product");
$Product = Product::getById($id);
if ($this->getRequest()->isPost()) {
$request = $this->getRequest()->getParams();
$error = $this->_checkForm($request);
if (count($error) == 0) {
$Contact = new Contact();
$Contact->merge($request);
$Contact->created_date = date("Y-m-d H:i:s");
$Contact->save();
//$_SESSION['msg'] = "Yêu cầu đặt hàng của bạn đã được gửi, xin trân thành cảm ơn!";
My_Plugin_Libs::setSplash('<b>Yêu cầu đặt hàng của bạn đã được gửi, xin trân thành cảm ơn!</b>');
$this->_redirect($this->_helper->url('index', 'contact', 'default'));
}
if (count($error)) {
$this->view->error = $error;
}
}
$this->view->Product = $Product;
$this->view->Contact = $Contact;
}
示例9: setUp
public function setUp()
{
SugarTestHelper::setUp('beanList');
SugarTestHelper::setUp('beanFiles');
SugarTestHelper::setUp('app_strings');
SugarTestHelper::setUp('app_list_strings');
$GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
$unid = uniqid();
$contact = new Contact();
$contact->id = 'l_' . $unid;
$contact->first_name = 'Greg';
$contact->last_name = 'Brady';
$contact->new_with_id = true;
$contact->save();
$this->_contact = $contact;
if (file_exists(sugar_cached('modules/unified_search_modules.php'))) {
$this->_hasUnifiedSearchModulesConfig = true;
copy(sugar_cached('modules/unified_search_modules.php'), sugar_cached('modules/unified_search_modules.php.bak'));
unlink(sugar_cached('modules/unified_search_modules.php'));
}
if (file_exists('custom/modules/unified_search_modules_display.php')) {
$this->_hasUnifiedSearchModulesDisplay = true;
copy('custom/modules/unified_search_modules_display.php', 'custom/modules/unified_search_modules_display.php.bak');
unlink('custom/modules/unified_search_modules_display.php');
}
}
示例10: setUp
public function setUp()
{
global $current_user, $currentModule;
$mod_strings = return_module_language($GLOBALS['current_language'], "Contacts");
$beanList = array();
$beanFiles = array();
require 'include/modules.php';
$GLOBALS['beanList'] = $beanList;
$GLOBALS['beanFiles'] = $beanFiles;
$current_user = SugarTestUserUtilities::createAnonymousUser();
$unid = uniqid();
$time = date('Y-m-d H:i:s');
$contact = new Contact();
$contact->id = 'c_' . $unid;
$contact->first_name = 'testfirst';
$contact->last_name = 'testlast';
$contact->new_with_id = true;
$contact->disable_custom_fields = true;
$contact->save();
$this->c = $contact;
$beanList = array();
$beanFiles = array();
require 'include/modules.php';
$GLOBALS['beanList'] = $beanList;
$GLOBALS['beanFiles'] = $beanFiles;
}
示例11: __construct
public function __construct($arrayAccounts)
{
// browse through list
$collection = array();
if ($arrayAccounts) {
foreach ($arrayAccounts as $arrayAccount) {
if (empty($arrayAccount['name_value_list']['account_name'])) {
$arrayAccount['name_value_list']['account_name'] = "";
}
$contact = new Contact();
$contact->setId($arrayAccount['name_value_list']['id']);
$contact->setGroup($arrayAccount['name_value_list']['account_name']);
$contact->setFirstname(htmlspecialchars_decode($arrayAccount['name_value_list']['first_name'], ENT_QUOTES));
$contact->setLastname($arrayAccount['name_value_list']['last_name']);
$contact->setWorkPhone($arrayAccount['name_value_list']['phone_work']);
$contact->setWorkMobile($arrayAccount['name_value_list']['phone_mobile']);
$contact->sethomePhone('');
$contact->sethomeMobile('');
$collection[$contact->getId()] = $contact;
}
// Sort accounts by name
usort($collection, function ($a, $b) {
return strcmp($a->getFirstname(), $b->getFirstname());
});
}
// build ArrayObject using collection
return parent::__construct($collection);
}
示例12: sendMail
public function sendMail($template)
{
foreach ($this->contacts as $c) {
$contact = new Contact($c);
$contact->sendMail($template);
}
}
示例13: bindValueAndExecuteInsertOrUpdate
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();
}
示例14: maintContact
function maintContact()
{
$results = '';
if (isset($_POST['save']) and $_POST['save'] == 'Save') {
// check the token
$badToken = true;
if (!isset($_POST['token']) || !isset($_SESSION['token']) || empty($_POST['token']) || $_POST['token'] !== $_SESSION['token']) {
$results = array('', 'Sorry, go back and try again. There was a security issue.');
$badToken = true;
} else {
$badToken = false;
unset($_SESSION['token']);
// Put the sanitized variables in an associative array
// Use the FILTER_FLAG_NO_ENCODE_QUOTES to allow names like O'Connor
$item = array('id' => (int) $_POST['id'], 'first_name' => filter_input(INPUT_POST, 'first_name', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES), 'last_name' => filter_input(INPUT_POST, 'last_name', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES), 'position' => filter_input(INPUT_POST, 'position', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES), 'email' => filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING), 'phone' => filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING));
// Set up a Contact object based on the posts
$contact = new Contact($item);
if ($contact->getId()) {
$results = $contact->editRecord();
} else {
$results = $contact->addRecord();
}
}
}
return $results;
}
示例15: inscrire
function inscrire()
{
$debug = false;
$contact = new Contact();
if ($_POST["as"] == '') {
// ---- Enregistrement dans "contact" -------- //
if ($_POST["email_news"] != '') {
$num_contact = $contact->isContact($_POST["email_news"], $debug);
unset($val);
$val["id"] = $num_contact;
$val["email"] = $_POST["email_news"];
$val["newsletter"] = "on";
if ($num_contact <= 0) {
$contact->contactAdd($val, $debug);
} else {
$contact->contactModify($val, $debug);
}
}
// ------------------------------------------- //
$erreur = "false";
$message = "Inscription réalisée avec succès";
die('{
"error":' . $erreur . ',
"message":"' . $message . '"
}');
}
}