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


PHP Campaign::getErrors方法代码示例

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


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

示例1: actionCreateFromTag

 /**
  * Create a campaign for all contacts with a certain tag.
  *
  * This action will create and save the campaign and redirect the user to
  * edit screen to fill in the email message, etc.  It is intended to provide
  * a fast workflow from tags to campaigns.
  *
  * @param string $tag
  */
 public function actionCreateFromTag($tag)
 {
     //enusre tag sanity
     if (empty($tag) || strlen(trim($tag)) == 0) {
         Yii::app()->user->setFlash('error', Yii::t('marketing', 'Invalid tag value'));
         $this->redirect(Yii::app()->request->getUrlReferrer());
     }
     //ensure sacred hash
     if (substr($tag, 0, 1) != '#') {
         $tag = '#' . $tag;
     }
     //only works for contacts
     $modelType = 'Contacts';
     $now = time();
     //get all contact ids from tags
     $ids = Yii::app()->db->createCommand()->select('itemId')->from('x2_tags')->where('type=:type AND tag=:tag')->group('itemId')->order('itemId ASC')->bindValues(array(':type' => $modelType, ':tag' => $tag))->queryColumn();
     //create static list
     $list = new X2List();
     $list->name = Yii::t('marketing', 'Contacts for tag') . ' ' . $tag;
     $list->modelName = $modelType;
     $list->type = 'campaign';
     $list->count = count($ids);
     $list->visibility = 1;
     $list->assignedTo = Yii::app()->user->getName();
     $list->createDate = $now;
     $list->lastUpdated = $now;
     //create campaign
     $campaign = new Campaign();
     $campaign->name = Yii::t('marketing', 'Mailing for tag') . ' ' . $tag;
     $campaign->type = 'Email';
     $campaign->visibility = 1;
     $campaign->assignedTo = Yii::app()->user->getName();
     $campaign->createdBy = Yii::app()->user->getName();
     $campaign->updatedBy = Yii::app()->user->getName();
     $campaign->createDate = $now;
     $campaign->lastUpdated = $now;
     $transaction = Yii::app()->db->beginTransaction();
     try {
         if (!$list->save()) {
             throw new Exception(array_shift(array_shift($list->getErrors())));
         }
         $campaign->listId = $list->nameId;
         if (!$campaign->save()) {
             throw new Exception(array_shift(array_shift($campaign->getErrors())));
         }
         foreach ($ids as $id) {
             $listItem = new X2ListItem();
             $listItem->listId = $list->id;
             $listItem->contactId = $id;
             if (!$listItem->save()) {
                 throw new Exception(array_shift(array_shift($listItem->getErrors())));
             }
         }
         $transaction->commit();
         $this->redirect($this->createUrl('update', array('id' => $campaign->id)));
     } catch (Exception $e) {
         $transaction->rollBack();
         Yii::app()->user->setFlash('error', Yii::t('marketing', 'Could not create mailing') . ': ' . $e->getMessage());
         $this->redirect(Yii::app()->request->getUrlReferrer());
     }
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:70,代码来源:MarketingController.php

示例2: testRequiredAttributes

 /**
  * @depends testCreateAndGetCampaignListById
  */
 public function testRequiredAttributes()
 {
     $campaign = new Campaign();
     $this->assertFalse($campaign->save());
     $errors = $campaign->getErrors();
     $this->assertNotEmpty($errors);
     $this->assertCount(7, $errors);
     $this->assertArrayHasKey('name', $errors);
     $this->assertEquals('Name cannot be blank.', $errors['name'][0]);
     $this->assertArrayHasKey('supportsRichText', $errors);
     $this->assertEquals('Supports HTML cannot be blank.', $errors['supportsRichText'][0]);
     $this->assertArrayHasKey('subject', $errors);
     $this->assertEquals('Subject cannot be blank.', $errors['subject'][0]);
     $this->assertArrayHasKey('fromName', $errors);
     $this->assertEquals('From Name cannot be blank.', $errors['fromName'][0]);
     $this->assertArrayHasKey('fromAddress', $errors);
     $this->assertEquals('From Address cannot be blank.', $errors['fromAddress'][0]);
     $this->assertArrayHasKey('textContent', $errors);
     $this->assertEquals('Please provide at least one of the contents field.', $errors['textContent'][0]);
     $this->assertArrayHasKey('marketingList', $errors);
     $this->assertEquals('Marketing List cannot be blank.', $errors['marketingList'][0]);
     $campaign->name = 'Test Campaign Name2';
     $campaign->supportsRichText = 0;
     $campaign->status = Campaign::STATUS_ACTIVE;
     $campaign->fromName = 'From Name2';
     $campaign->fromAddress = 'from2@zurmo.com';
     $campaign->subject = 'Test Subject2';
     $campaign->htmlContent = 'Test Html Content2';
     $campaign->textContent = 'Test Text Content2';
     $campaign->fromName = 'From Name2';
     $campaign->fromAddress = 'from2@zurmo.com';
     $campaign->marketingList = self::$marketingList;
     $this->assertTrue($campaign->save());
     $id = $campaign->id;
     unset($campaign);
     $campaign = Campaign::getById($id);
     $this->assertEquals('Test Campaign Name2', $campaign->name);
     $this->assertEquals(0, $campaign->supportsRichText);
     $this->assertEquals(Campaign::STATUS_ACTIVE, $campaign->status);
     $this->assertEquals('From Name2', $campaign->fromName);
     $this->assertEquals('from2@zurmo.com', $campaign->fromAddress);
     $this->assertEquals('Test Subject2', $campaign->subject);
     $this->assertEquals('Test Html Content2', $campaign->htmlContent);
     $this->assertEquals('Test Text Content2', $campaign->textContent);
     $this->assertTrue(time() + 15 > DateTimeUtil::convertDbFormatDateTimeToTimestamp($campaign->sendOnDateTime));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:49,代码来源:CampaignTest.php

示例3: testDummyHtmlContentThrowsValidationErrorWhenTextContentIsEmpty

 /**
  * @depends testCreateAndGetCampaignListById
  */
 public function testDummyHtmlContentThrowsValidationErrorWhenTextContentIsEmpty()
 {
     $campaign = new Campaign();
     $campaign->name = 'Another Test Campaign Name';
     $campaign->supportsRichText = 1;
     $campaign->status = Campaign::STATUS_ACTIVE;
     $campaign->fromName = 'Another From Name';
     $campaign->fromAddress = 'anotherfrom@zurmo.com';
     $campaign->subject = 'Another Test Subject';
     $campaign->textContent = '';
     $campaign->htmlContent = "<html>\n<head>\n</head>\n<body>\n</body>\n</html>";
     $campaign->marketingList = self::$marketingList;
     $this->assertFalse($campaign->save());
     $errorMessages = $campaign->getErrors();
     $this->assertEquals(1, count($errorMessages));
     $this->assertTrue(array_key_exists('textContent', $errorMessages));
     $this->assertEquals(1, count($errorMessages['textContent']));
     $this->assertEquals('Please provide at least one of the contents field.', $errorMessages['textContent'][0]);
     $campaign->htmlContent = 'Text Content';
     $this->assertTrue($campaign->save());
     $id = $campaign->id;
     unset($campaign);
     $campaign = Campaign::getById($id);
     $this->assertEquals('Another Test Campaign Name', $campaign->name);
     $this->assertEquals(1, $campaign->supportsRichText);
     $this->assertEquals(Campaign::STATUS_ACTIVE, $campaign->status);
     $this->assertEquals('Another From Name', $campaign->fromName);
     $this->assertEquals('anotherfrom@zurmo.com', $campaign->fromAddress);
     $this->assertEquals('Another Test Subject', $campaign->subject);
     $this->assertEquals(null, $campaign->textContent);
     $this->assertEquals('Text Content', $campaign->htmlContent);
     $this->assertEquals(self::$marketingList->id, $campaign->marketingList->id);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:36,代码来源:CampaignTest.php

示例4: deleteAction

 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Campaign();
         $model->model_uset_id = $this->user->user_id;
         if ($model->findByPk($id)) {
             // if beforeDelete() returns an error, indicate this to the user
             if (!$model->delete($id)) {
                 $errors = TRUE;
             }
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('campaign_no_deleted'));
         } else {
             Message::echoJsonSuccess(__('campaign_deleted'));
         }
     }
     $this->redirect();
 }
开发者ID:,项目名称:,代码行数:31,代码来源:


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