Пример #1
0
 public function execute()
 {
     $startedAt = time();
     $startedAt -= $startedAt % 60;
     $campaign = new Campaign($this->campaign);
     Defero::pushCampaign($campaign->id(), $startedAt, $this->startId, $this->endId);
 }
Пример #2
0
 public function add()
 {
     $this->_throwIfNotSet("reference");
     $this->_throwIfNotSet("description");
     $this->_throwIfNotSet("name");
     $this->_throwIfNotSet("type");
     $this->_throwIfNotSet("sendType");
     $type = strtoupper($this->type);
     $sendType = strtoupper($this->sendType);
     $campaign = new Campaign();
     $campaign->reference = $this->reference;
     $campaign->description = $this->description;
     $campaign->name = $this->name;
     $campaign->type = CampaignType::$type();
     $campaign->sendType = SendType::$sendType();
     $campaign->contactId = $this->contactId ?: 0;
     $campaign->active = $this->active ?: 1;
     $campaign->saveChanges();
     echo "Added campaign id {$campaign->id()} ({$campaign->name})";
 }
Пример #3
0
 public function renderClone($id)
 {
     $campaign = new Campaign($id);
     $form = new DeferoForm('cloneForm');
     $form->addTextElement('currentReference', $campaign->reference);
     $form->addTextElement('newReference');
     $form->addSubmitElement('Clone');
     $form->getElement('currentReference')->addAttribute('disabled');
     $form->hydrate($this->request()->postVariables());
     if (!$form->getData('newReference')) {
         return '<h3>Clone ' . $campaign->name . '</h3>' . $form;
     }
     try {
         $campaign->reference = $form->getData('newReference');
         $campaign->saveAsNew();
         $newId = $campaign->id();
         $campaign = new Campaign($newId);
         $oldCampaign = new Campaign($id);
         $languages = $this->config('i18n')->getArr('languages');
         $msg = $campaign->message();
         $oldMsg = $oldCampaign->message();
         foreach ($languages as $lang) {
             $msg->setLanguage($lang)->reload();
             $oldMsg->setLanguage($lang)->reload();
             $oldData = $oldMsg->jsonSerialize();
             unset($oldData['id'], $oldData['campaign_id'], $oldData['created_at'], $oldData['updated_at']);
             $msg->hydrate($oldData);
             foreach ($msg->getRawAttributes() as $attr) {
                 $attr->setModified();
             }
             $msg->saveChanges();
         }
         return Redirect::to("/campaigns/{$newId}")->with("msg", new TransportMessage('info', 'Campaign Cloned'));
     } catch (\Exception $e) {
         return Redirect::to("/campaigns/{$id}")->with('msg', new TransportMessage("error", $e->getMessage()));
     }
 }