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


PHP Accounts::validate方法代码示例

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


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

示例1: actionCreate

 public function actionCreate()
 {
     $model = new Clients();
     $account = new Accounts();
     $preference = new Preferences();
     if (isset($_POST['Clients'], $_POST['Accounts'], $_POST['Preferences'])) {
         $model->attributes = $_POST['Clients'];
         $account->attributes = $_POST['Accounts'];
         $preference->attributes = $_POST['Preferences'];
         $model->login_name = $account->login_name;
         $model->client_code = RandomGenerator::generateString(AdminGlobals::CLIENT_CODE_LENGTH);
         $model->subscription_status = "active";
         $preference->prepaid_passwd = RandomGenerator::generateString(AdminGlobals::PREPAID_PASSWD_LENGTH);
         $account->account_name = $model->client_name;
         $account->email = $model->email;
         $account->is_visible = 0;
         $valid = $model->validate();
         $valid = $account->validate() && $valid;
         $valid = $preference->validate() && $valid;
         if ($valid) {
             $transaction = Yii::app()->db->beginTransaction();
             $success = $model->save(false);
             if ($success) {
                 $account->client_id = $preference->client_id = $model->id;
             }
             $success = $success && $account->save(false);
             $success = $success && $preference->save(false);
             if ($success) {
                 $transaction->commit();
                 if (Yii::app()->request->isAjaxRequest) {
                     $this->renderPartial('view', array('model' => $this->loadModel($model->id), 'account' => $account, 'preference' => $preference), false, true);
                     Yii::app()->end();
                 }
                 $this->redirect(array('view', 'id' => $model->id));
             }
             $transaction->rollBack();
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('create', array('model' => $model, 'account' => $account, 'preference' => $preference), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'account' => $account, 'preference' => $preference));
 }
开发者ID:thehiddennepali,项目名称:Sample-Code,代码行数:44,代码来源:ClientsController.php

示例2: actionAdduser

 public function actionAdduser()
 {
     $model = new Accounts();
     // uncomment the following code to enable ajax-based validation
     /*
     if(isset($_POST['ajax']) && $_POST['ajax']==='accounts-edituser-form')
     {
     	echo CActiveForm::validate($model);
     	Yii::app()->end();
     }
     */
     if (isset($_POST['Accounts'])) {
         $model->attributes = $_POST['Accounts'];
         if ($model->validate()) {
             $newSalt = $this->generateSalt(10);
             $newPass = md5($newSalt . $model->password);
             $model->salt = $newSalt;
             $model->password = $newPass;
             $model->save();
             $this->redirect(array('index'));
         }
     }
     $this->render('adduser', array('model' => $model));
 }
开发者ID:Covert-Inferno,项目名称:prohd,代码行数:24,代码来源:AdminController.php

示例3: actionCreateRecords

 public function actionCreateRecords()
 {
     $contact = new Contacts();
     $account = new Accounts();
     $opportunity = new Opportunity();
     $users = User::getNames();
     if (isset($_POST['Contacts']) && isset($_POST['Accounts']) && isset($_POST['Opportunity'])) {
         $contact->setX2Fields($_POST['Contacts']);
         $account->setX2Fields($_POST['Accounts']);
         $opportunity->setX2Fields($_POST['Opportunity']);
         $validAccount = true;
         if ($account->validate() == false) {
             $validAccount = false;
             // validate other models so that the user gets feedback
             $contact->validate();
             $opportunity->validate();
         }
         if ($validAccount) {
             $allValid = true;
             $a = $this->createAccount($account, $account->attributes, '1');
             // Contact and Opportunity require Account id for lookup field
             $contact->company = Fields::nameId($account->name, $account->id);
             if ($contact->validate() == false) {
                 $allValid = false;
             }
             $c = $this->createContact($contact, $contact->attributes, '1');
             $opportunity->accountName = Fields::nameId($account->name, $account->id);
             $opportunity->contactName = Fields::nameId($contact->name, $contact->id);
             if ($opportunity->validate() == false) {
                 $allValid = false;
             }
             $o = $this->createOpportunity($opportunity, $opportunity->attributes, '1');
             if ($allValid && $c && $a && $o) {
                 // all records created?
                 Relationships::create('Contacts', $contact->id, 'Accounts', $account->id);
                 Relationships::create('Opportunity', $opportunity->id, 'Contacts', $contact->id);
                 Relationships::create('Opportunity', $opportunity->id, 'Accounts', $account->id);
                 if (isset($_GET['ret'])) {
                     if ($_GET['ret'] == 'contacts') {
                         $this->redirect(array("/contacts/contacts/view", 'id' => $contact->id));
                     } else {
                         if ($_GET['ret'] == 'accounts') {
                             $this->redirect(array("/accounts/accounts/view", 'id' => $account->id));
                         } else {
                             if ($_GET['ret'] == 'opportunities') {
                                 $this->redirect(array("/opportunities/opportunities/view", 'id' => $opportunity->id));
                             }
                         }
                     }
                 } else {
                     $this->redirect(array("/contacts/contacts/view", $contact->id));
                 }
             } else {
                 // otherwise clean up
                 $types = array('account' => 'Accounts', 'contact' => 'Contacts', 'opportunity' => 'Opportunity');
                 foreach ($types as $model => $type) {
                     if (${$model} && isset(${$model}->id)) {
                         $modelId = ${$model}->id;
                         ${$model}->delete();
                         // delete all new actions and events from creating/deleting records
                         foreach (array('Actions', 'Events') as $meta) {
                             X2Model::model($meta)->deleteAllByAttributes(array('associationId' => $modelId, 'associationType' => $type));
                         }
                     }
                 }
             }
         }
     }
     $this->render('createRecords', array('contact' => $contact, 'account' => $account, 'opportunity' => $opportunity, 'users' => $users));
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:70,代码来源:SiteController.php


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