当前位置: 首页>>代码示例>>PHP>>正文


PHP Contact::validate方法代码示例

本文整理汇总了PHP中Contact::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::validate方法的具体用法?PHP Contact::validate怎么用?PHP Contact::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::validate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: populateModel

 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof ContactWebFormEntry');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ContactWebFormsModule', 'ContactWebFormEntry');
     }
     $contactFormAttributes = array();
     $contact = new Contact();
     $contact->owner = $model->contactWebForm->defaultOwner;
     $contact->state = $model->contactWebForm->defaultState;
     $contact->firstName = $contactFormAttributes['firstName'] = $this->seedData['firstName'][$this->index];
     $contact->lastName = $contactFormAttributes['lastName'] = $this->seedData['lastName'][$this->index];
     $contact->companyName = $contactFormAttributes['companyName'] = $this->seedData['companyName'][$this->index];
     $contact->jobTitle = $contactFormAttributes['jobTitle'] = $this->seedData['jobTitle'][$this->index];
     if ($contact->validate()) {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
         $contact->save();
     } else {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
         $contact = null;
     }
     $model->contact = $contact;
     $model->status = $contactWebFormEntryStatus;
     $model->message = $contactWebFormEntryMessage;
     $contactFormAttributes['owner'] = $model->contactWebForm->defaultOwner->id;
     $contactFormAttributes['state'] = $model->contactWebForm->defaultState->id;
     $model->serializedData = serialize($contactFormAttributes);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:34,代码来源:ContactWebFormEntryDemoDataMaker.php

示例2: testCreateAndGetContactWebFormEntryById

 public function testCreateAndGetContactWebFormEntryById()
 {
     $allAttributes = ContactWebFormsUtil::getAllAttributes();
     $placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
     $contactFormAttributes = ContactWebFormsUtil::getAllPlacedAttributes($allAttributes, $placedAttributes);
     $attributes = array_keys($contactFormAttributes);
     $this->assertTrue(ContactsModule::loadStartingData());
     $contactStates = ContactState::getByName('New');
     $contactWebForm = new ContactWebForm();
     $contactWebForm->name = 'Test Form';
     $contactWebForm->redirectUrl = 'http://google.com';
     $contactWebForm->submitButtonLabel = 'Save';
     $contactWebForm->defaultState = $contactStates[0];
     $contactWebForm->defaultOwner = Yii::app()->user->userModel;
     $contactWebForm->serializedData = serialize($attributes);
     $contactWebForm->save();
     $contact = new Contact();
     $contact->owner = $contactWebForm->defaultOwner;
     $contact->state = $contactWebForm->defaultState;
     $contact->firstName = 'Super';
     $contact->lastName = 'Man';
     $contact->jobTitle = 'Superhero';
     $contact->companyName = 'Test Inc.';
     if ($contact->validate()) {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
     } else {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
     }
     $contact->save();
     foreach ($contactFormAttributes as $attributeName => $attributeValue) {
         $contactFormAttributes[$attributeName] = $contact->{$attributeName};
     }
     $contactFormAttributes['owner'] = $contactWebForm->defaultOwner->id;
     $contactFormAttributes['state'] = $contactWebForm->defaultState->id;
     $contactWebFormEntry = new ContactWebFormEntry();
     $contactWebFormEntry->serializedData = serialize($contactFormAttributes);
     $contactWebFormEntry->status = $contactWebFormEntryStatus;
     $contactWebFormEntry->message = $contactWebFormEntryMessage;
     $contactWebFormEntry->contactWebForm = $contactWebForm;
     $contactWebFormEntry->contact = $contact;
     $this->assertTrue($contactWebFormEntry->save());
     $contactWebFormEntryId = $contactWebFormEntry->id;
     unset($contactWebFormEntry);
     $contactWebFormEntry = ContactWebFormEntry::getById($contactWebFormEntryId);
     $this->assertEquals('Test Form', $contactWebFormEntry->contactWebForm->name);
     $this->assertEquals('Super', $contactWebFormEntry->contact->firstName);
     $this->assertEquals('Man', $contactWebFormEntry->contact->lastName);
     $contactFormAttributes = unserialize($contactWebFormEntry->serializedData);
     $this->assertEquals('Super', $contactFormAttributes['firstName']);
     $this->assertEquals('Man', $contactFormAttributes['lastName']);
     $this->assertEquals('Superhero', $contactFormAttributes['jobTitle']);
     $this->assertEquals('Test Inc.', $contactFormAttributes['companyName']);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:55,代码来源:ContactWebFormEntryTest.php

示例3: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aContact !== null) {
             if (!$this->aContact->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aContact->getValidationFailures());
             }
         }
         if ($this->asfGuardUser !== null) {
             if (!$this->asfGuardUser->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
             }
         }
         if (($retval = UserPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collSessions !== null) {
             foreach ($this->collSessions as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collSingleSignOnKeys !== null) {
             foreach ($this->collSingleSignOnKeys as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collSystemEventSubscriptions !== null) {
             foreach ($this->collSystemEventSubscriptions as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collSystemEventInstances !== null) {
             foreach ($this->collSystemEventInstances as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:homer6,项目名称:blank_altumo,代码行数:65,代码来源:BaseUser.php

示例4: actionShow

 /**
  * 浏览
  */
 public function actionShow($name)
 {
     $contactModel = new Contact();
     $title_alias = CHtml::encode(strip_tags($name));
     $bagecmsPageModel = Page::model()->find('title_alias=:titleAlias', array('titleAlias' => $title_alias));
     if (false == $bagecmsPageModel) {
         throw new CHttpException(404, '内容不存在');
     }
     $this->_seoTitle = empty($bagecmsPageModel->seo_title) ? $bagecmsPageModel->title . ' - ' . $this->_conf['site_name'] : $bagecmsPageModel->seo_title;
     $tpl = empty($bagecmsPageModel->template) ? 'show' : $bagecmsPageModel->template;
     if (isset($_POST['Contact'])) {
         $contactModel->attributes = $_POST['Contact'];
         if ($contactModel->validate() and $contactModel->save()) {
             Yii::app()->user->setFlash('success', '提交成功!');
         }
     }
     $this->render($tpl, array('bagecmsPage' => $bagecmsPageModel, 'title_alias' => $title_alias, 'contactModel' => $contactModel));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:21,代码来源:PageController.php

示例5: actionContact

 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = new Contact();
     $model->unsetAttributes();
     if (isset($_POST['Contact'])) {
         if (!Yii::app()->user->isGuest) {
             $model->name = User::getNameById(Yii::app()->user->id);
             $model->email = Yii::app()->user->email;
         }
         $model->attributes = $_POST['Contact'];
         if ($model->validate() && $model->save()) {
             $headers = "From: {$model->email}\r\nReply-To: {$model->email}";
             mail(Yii::app()->params['adminEmail'], $model->subject, $model->body, $headers);
             Yii::app()->user->setFlash('contact', '感谢您的意见,我会尽快回复!');
             $this->refresh();
         } else {
             //var_dump($model->errors);
         }
     }
     $this->render('contact', array('model' => $model));
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:24,代码来源:SiteController.php

示例6: actionAddContact

 public function actionAddContact()
 {
     $contact = new Contact();
     if (!empty($_POST)) {
         $contact->attributes = $_POST['Contact'];
         if (!$contact->validate()) {
             $errors = $contact->getErrors();
         } else {
             if (!$contact->save()) {
                 throw new Exception("Unable to save contact: " . print_r($contact->getErrors(), true));
             }
             Audit::add('admin-Contact', 'add', $contact->id);
             $this->redirect(array('/admin/editContact?contact_id=' . $contact->id));
         }
     }
     $this->render('/admin/addcontact', array('contact' => $contact, 'errors' => @$errors));
 }
开发者ID:openeyeswales,项目名称:OpenEyes,代码行数:17,代码来源:AdminController.php

示例7: store_contact

 public function store_contact()
 {
     if ($this->isPostRequest()) {
         $input_data = Input::all();
         // input all data
         $model = new Contact();
         //save data into
         if ($model->validate($input_data)) {
             DB::beginTransaction();
             try {
                 $model->create($input_data);
                 DB::commit();
                 Session::flash('message', 'Submitted Successfully ! We will get back to you soon.');
             } catch (Exception $e) {
                 //If there are any exceptions, rollback the transaction`
                 DB::rollback();
                 Session::flash('danger', 'Failed !');
             }
         }
     } else {
         Session::flash('danger', 'Invalid Request !');
     }
     return Redirect::back();
 }
开发者ID:selimppc,项目名称:ecies,代码行数:24,代码来源:HomeController.php

示例8: attemptToMatchAndSaveLeadOrContact

 protected static function attemptToMatchAndSaveLeadOrContact($emailMessage, $type, $emailMessageId)
 {
     assert('$type == "Contact" || $type == "Lead"');
     assert('is_int($emailMessageId)');
     if (isset($_POST[$type])) {
         if (isset($_POST['ajax']) && $_POST['ajax'] === strtolower($type) . '-inline-create-form-' . $emailMessageId) {
             $contact = new Contact();
             $contact->setAttributes($_POST[$type][$emailMessageId]);
             $contact->validate();
             $errorData = ZurmoActiveForm::makeErrorsDataAndResolveForOwnedModelAttributes($contact);
             echo CJSON::encode($errorData);
             Yii::app()->end(0, false);
         } else {
             $contact = new Contact();
             $contact->setAttributes($_POST[$type][$emailMessageId]);
             if (!$contact->save()) {
                 throw new FailedToSaveModelException();
             }
             ArchivedEmailMatchingUtil::resolveContactToSenderOrRecipient($emailMessage, $contact);
             $emailMessage->folder = EmailFolder::getByBoxAndType($emailMessage->folder->emailBox, EmailFolder::TYPE_ARCHIVED);
             if (!$emailMessage->save()) {
                 throw new FailedToSaveModelException();
             }
         }
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:DefaultController.php

示例9: function

use Propel\Runtime\Propel;
use Propel\Runtime\Formatter\ObjectFormatter;
/* CONTACTS */
$app->get('/contacts', function ($request, $response, $args) {
    $contacts = ContactQuery::create()->find();
    $response->getBody()->write(parseToJSONArray($contacts));
    return $response;
});
$app->post('/contacts', function ($request, $response, $args) {
    $parsedBody = $request->getParsedBody();
    if ($parsedBody == null) {
        return err_general_error($response, "Provide a body to create a new contacts");
    }
    $contact = new Contact();
    $contact->fromArray($parsedBody);
    if ($contact->validate()) {
        $contact->save();
    } else {
        return err_general_error($response, "Validation failed");
    }
    /* Response with resulting contact */
    $response->getBody()->write($contact->toJSON());
    return $response;
});
$app->get('/contacts/{id}', function ($request, $response, $args) {
    $id = $request->getAttribute('id');
    $contact = ContactQuery::create()->findPK($id);
    $response->getBody()->write($contact->toJSON());
    return $response;
});
$app->put('/contacts/{id}', function ($request, $response, $args) {
开发者ID:noppelmax,项目名称:la_apiv3,代码行数:31,代码来源:ContactRoutes.php

示例10: actionContact

 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = new Contact();
     if (isset($_POST['Contact'])) {
         $model->attributes = $_POST['Contact'];
         $model->createdatetime = new CDbExpression('NOW()');
         if ($model->validate()) {
             $model->save();
             $body = $model->fullname . '<br />Email: ' . $model->email . '<br />Điện thoại: ' . $model->phone . '<br />Chủ đề: ' . $model->title . '<br /><hr /><br />' . $model->content;
             $this->SendMail(array('mailto' => Config::model()->getValueByKey('address_received_mail'), 'replyto' => $model->email, 'subject' => $model->title, 'body' => $body));
             Yii::app()->user->setFlash('contact', 'Nội dung liên hệ của bạn đã được gửi đến chúng tôi. Chúng tôi sẽ phản hồi bạn trong thời gian sớm nhất. Xin chân thành cảm ơn!');
             $this->refresh();
         }
     }
     $this->pageTitle = Yii::t('site', 'Contact') . ' - ' . Config::model()->getValueByKey('sitetitle');
     $this->metaDescription = Config::model()->getValueByKey('metadescription');
     $this->metaKeywords = Config::model()->getValueByKey('metakeywords');
     $this->render('contact', array('model' => $model));
 }
开发者ID:phantsang,项目名称:xzsUuJg0keDWW5Rx679PHBVBJ,代码行数:22,代码来源:SiteController.php

示例11: actionContact

 public function actionContact($uid)
 {
     $this->uid = $uid;
     $data = array('uid' => $uid, 'url' => "http://" . Yii::app()->params['bucket'] . "." . Yii::app()->params['domain'] . "/");
     //标签
     $data['labelInfo'] = $this->GetTags($uid);
     $contactModel = new Contact();
     if (isset($_POST['Contact'])) {
         $contactModel->attributes = $_POST['Contact'];
         $tmp = $_POST['Contact'];
         if ($contactModel->validate()) {
             $contactModel->time = time();
             $contactModel->userid = $uid;
             $tmp['uid'] = $uid;
             if ($contactModel->save()) {
                 Yii::app()->user->setFlash('contactstatus', 'YES,给Ta写信成功。(⊙_⊙)(⊙_⊙)(⊙_⊙)');
                 //$this->SendContactMessage($tmp);
                 $this->redirect(array("contact", 'uid' => $uid));
             } else {
                 Yii::app()->user->setFlash('contactstatus', 'Sorry,系统错误,写信失败。(>﹏<)');
                 $this->redirect(array("contact", 'uid' => $uid));
             }
         }
     }
     $data['contactModel'] = $contactModel;
     $this->render('contact', $data);
 }
开发者ID:biggtfish,项目名称:A-Simple-CMS,代码行数:27,代码来源:IndexController.php

示例12: actionContact

 public function actionContact($who)
 {
     $this->uid = $uid = $who;
     $data = array('uid' => $uid, 'url' => "http://" . Yii::app()->params['bucket'] . "." . Yii::app()->params['domain'] . "/");
     $this->Myaccess($uid);
     $data['labelInfo'] = $this->getTags($uid);
     $contactModel = new Contact();
     if (isset($_POST['Contact'])) {
         $contactModel->attributes = $_POST['Contact'];
         $tmp = $_POST['Contact'];
         if ($contactModel->validate()) {
             $contactModel->time = time();
             $contactModel->userid = $uid;
             $tmp['uid'] = $uid;
             if ($contactModel->save()) {
                 Yii::app()->user->setFlash('contactstatus', 'YES,给Ta写信成功 :)');
                 $this->redirect(array("contact", 'who' => $uid));
             } else {
                 Yii::app()->user->setFlash('contactstatus', 'Sorry,系统错误,写信失败 :(');
                 $this->redirect(array("contact", 'who' => $uid));
             }
         }
     }
     $data['contactModel'] = $contactModel;
     $this->layout = "//layouts/empty";
     $this->render('contact', $data);
 }
开发者ID:returncn,项目名称:chen-xia-cms,代码行数:27,代码来源:IndexController.php

示例13: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id, $sale_mode = 'N')
 {
     $model = $this->loadModel($id);
     $contact = Contact::model()->conatctByID($model->contact_id);
     $has_error = "";
     if (!$contact) {
         $contact = new Contact();
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (Yii::app()->user->checkAccess('client.update')) {
         if (isset($_POST['Client'])) {
             $model->attributes = $_POST['Client'];
             $contact->attributes = $_POST['Contact'];
             if ($_POST['Client']['year'] !== "" || $_POST['Client']['month'] !== "" || $_POST['Client']['day'] !== "") {
                 $dob = $_POST['Client']['year'] . '-' . $_POST['Client']['month'] . '-' . $_POST['Client']['day'];
                 $model->dob = $dob;
             }
             // validate BOTH $a and $b
             $valid = $model->validate();
             $valid = $contact->validate() && $valid;
             //if ($model->validate())
             if ($valid) {
                 $transaction = $model->dbConnection->beginTransaction();
                 try {
                     if (isset($_POST['Contact'])) {
                         $contact->save();
                         $model->contact_id = $contact->id;
                     }
                     if ($model->save()) {
                         $client_fname = $model->first_name . ' ' . $model->last_name;
                         Account::model()->saveAccount($model->id, $client_fname);
                         $price_tier_id = $model->price_tier_id;
                         $transaction->commit();
                         if ($sale_mode == 'Y') {
                             Yii::app()->shoppingCart->setCustomer($id);
                             Yii::app()->shoppingCart->setPriceTier($price_tier_id);
                             $this->redirect(array('saleItem/index'));
                         } else {
                             Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, '<strong>' . ucfirst($model->first_name) . '</strong> have been saved successfully!');
                             $this->redirect(array('admin'));
                         }
                     }
                 } catch (Exception $e) {
                     $transaction->rollback();
                     print_r($e);
                 }
             } else {
                 $has_error = "has-error";
             }
         }
     } else {
         throw new CHttpException(403, 'You are not authorized to perform this action');
     }
     if (Yii::app()->request->isAjaxRequest) {
         $cs = Yii::app()->clientScript;
         $cs->scriptMap = array('jquery.js' => false, 'bootstrap.js' => false, 'jquery.min.js' => false, 'bootstrap.notify.js' => false, 'bootstrap.bootbox.min.js' => false);
         echo CJSON::encode(array('status' => 'render', 'div' => $this->renderPartial('_form', array('model' => $model), true, false)));
         Yii::app()->end();
     } else {
         $this->render('update', array('model' => $model, 'contact' => $contact, 'has_error' => $has_error));
     }
 }
开发者ID:soklux,项目名称:bakou-pos,代码行数:68,代码来源:ClientController.php


注:本文中的Contact::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。