Example #1
0
 public function edit($id)
 {
     //$this->output->enable_profiler(true);
     $id = (int) $id;
     $this->load->model('Campaign');
     $this->form_validation->set_rules('name', 'Name', 'required');
     $this->layout->add_basic_assets()->menu();
     if ($this->form_validation->run() === false) {
         $campaign = Campaign::find($id);
         $data = array('action' => $this->router->method, 'id' => $id, 'name' => $campaign->get_name());
         $create_edit = $this->layout->views('controllers/Campaign/actions/create_edit', $data, array(), true);
         $this->layout->action_view(array('create_edit' => $create_edit));
     } else {
         $data = array('name' => $this->input->post('name'));
         $result = Campaign::update($id, $data);
         if ($result === true) {
             $this->layout->view('others/form_success');
         } elseif ($result instanceof Standard_error) {
             $this->layout->views('others/form_failure', array('message' => $result->message));
             $data = array('action' => $this->router->method, 'id' => $id, 'name' => $this->input->post('name'));
             $create_edit = $this->layout->views('controllers/Campaign/actions/create_edit', $data, array(), true);
             $this->layout->action_view(array('create_edit' => $create_edit));
         }
     }
 }
Example #2
0
<?php

/**
 * Envoi d'une campagne de SMS
 *
 * PHP version 5
 *
 * @category Ajax
 * @package  LeQG
 * @author   Damien Senger <*****@*****.**>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
$campagne = array('titre' => $_GET['titre'], 'message' => $_GET['message']);
$campaign = Campaign::create('sms');
$campaign = new Campaign($campaign);
$campaign->update('titre', $campagne['titre']);
$campaign->update('message', $campagne['message']);
$var = $_GET;
$var['criteres'] = trim($var['criteres'], ';');
$campaign->addRecipients(People::listing($var, 0, false));
echo $campaign->get('id');
 function precampaignfinishedAction()
 {
     $this->view->activeTab = 'Campaign';
     $this->view->title = $this->view->title = $this->view->translate("Wildfire") . " - " . $this->view->translate("You_are_in");
     //precampaignsurvey的css使用的是layout_survey
     $this->_helper->layout->setLayout("layout_survey");
     $id = (int) $this->_request->getParam('survey');
     $campaignModel = new Campaign();
     $this->view->campaign = $campaignModel->fetchRow("pre_campaign_survey=" . $id . " or " . "pre_campaign_survey_en=" . $id);
     $db = Zend_Registry::get('db');
     if ($this->view->campaign != null) {
         $campaignId = $this->view->campaign->id;
     }
     $consumer = $this->_currentUser;
     //TOCHECK
     //$select_extra_info = $db->select ();
     //$select_extra_info->from ( "consumer",array ('consumer.*', 'consumer_extra_info.gender as gender','consumer_extra_info.education as education','consumer_extra_info.income as income'  ));
     //$select_extra_info->joinLeft ( "consumer_extra_info","consumer.id = consumer_extra_info.consumer_id",null);
     //$select_extra_info->where("consumer.id = ".$this->_currentUser->id );
     //$consumer2 = $db->fetchRow ( $select_extra_info );
     //Zend_Debug::dump($consumer2);die;
     if ($this->view->campaign != null && $campaignId != null && $campaignId > 0) {
         // check if precampaign poll is finished
         //			$select1 = $db->select();
         //			$select1->from('campaign', 'pre_campaign_survey');
         //			$select1->where('campaign.id = ?',$campaignId);
         //			$previewCamSurvey = $db->fetchOne($select1);
         //			$indicate2Connect = new Indicate2_Connect();
         //			$ids = array($previewCamSurvey);
         //			$wsResult = $indicate2Connect->getAnswerSetCount($consumer->email,$ids);
         //
         //			if ($wsResult==0){
         //				$this->_redirect('campaign/precampaign/survey/'.$previewCamSurvey);
         //			}else{
         $campaignInvitationModel = new CampaignInvitation();
         $campaignInvitation = $campaignInvitationModel->fetchRow("campaign_id=" . $campaignId . " and consumer_id=" . $consumer->id);
         if ($campaignInvitation == null) {
             $this->_redirect('http://community.wildfire.asia/public/home');
         }
         $id = $campaignInvitation->id;
         //Zend_Debug::dump($campaignInvitation);
         $campaignInvitation->state = "ACCEPTED";
         $campaignInvitation->save();
         //2011-05-19 ham.bao add the badge
         //			$consumerBadgeModel = new ConsumerBadge();
         //			$notificationModel = new Notification();
         //			$consumerBadgeData  = $consumerBadgeModel->fetchRow('badge='.$this->view->campaign->badge .' and consumer='.$consumer->id);
         //			if(!count($consumerBadgeData)){
         //				$row = $consumerBadgeModel->createRow();
         //				$row->consumer = $consumer->id;
         //				$row->badge    = $this->view->campaign->badge;
         //				$row->create_date = date("Y-m-d H:i:s");
         //				$row->save();
         //				// add notification
         //				$notificationModel->createRecord("CONSUMER_BADGE",$consumer->id);
         //
         //			}
         //2011-05-19 ham.bao add the badge
         $result = $db->fetchOne("SELECT COUNT(*) FROM campaign_participation WHERE campaign_invitation_id=:t1", array('t1' => $id));
         if ($result == 0) {
             //2011-02-22 ham.bao add the logic to calculate the number of participation
             $campaignModel->update(array('participation' => $this->view->campaign->participation + 1), 'id = ' . $this->view->campaign->id);
             if ($this->view->campaign->participation + 1 >= $this->view->campaign->total) {
                 $campaignInvitationModel->update(array('state' => 'EXPIRED'), ' state = "NEW" and campaign_id =' . $this->view->campaign->id);
                 $signauthcodeModel = new SignupAuthCode();
                 $signauthcodeModel->update(array('auto_invitation' => 0), 'auto_invitation =' . $this->view->campaign->id);
             }
             //create participation
             $campaignParticipationModel = new CampaignParticipation();
             $currentTime = date("Y-m-d H:i:s");
             $row = $campaignParticipationModel->createRow();
             $row->campaign_invitation_id = $id;
             $row->accept_date = $currentTime;
             $row->state = 'NEW';
             $row->save();
             //send "welcome to campaign" mail
             //set the content of mail
             $emailSubject = $this->view->translate('Welcome_to_Spark_Campaign_Email_subject_campaign_' . $campaignId);
             $emailBody = $this->view->translate('Welcome_to_Spark_Campaign_Email_body_campaign_' . $campaignId);
             $stringChange = array('?USERNAME?' => $this->_currentUser['name']);
             $emailBody = strtr($emailBody, $stringChange);
             //send...
             $config = Zend_Registry::get('config');
             $smtpSender = new Zend_Mail_Transport_Smtp($config->smtp->welcome->mail->server, array('username' => $config->smtp->welcome->mail->username, 'password' => $config->smtp->welcome->mail->password, 'auth' => $config->smtp->welcome->mail->auth, 'ssl' => $config->smtp->welcome->mail->ssl, 'port' => $config->smtp->welcome->mail->port));
             Zend_Mail::setDefaultTransport($smtpSender);
             $mail = new Zend_Mail('utf-8');
             $langNamespace = new Zend_Session_Namespace('Lang');
             if ($langNamespace->lang == 'en' || $langNamespace->lang == 'EN') {
                 $mail->setSubject($emailSubject);
             } else {
                 $mail->setSubject("=?UTF-8?B?" . base64_encode($emailSubject) . "?=");
             }
             $mail->setBodyText($emailBody);
             $mail->setFrom($config->smtp->welcome->mail->username, $this->view->translate('Wildfire'));
             $mail->addTo($this->_currentUser['email']);
             $mail->send();
         }
     }
     //edit ConsumerContactForm();
     $form = new ConsumerContactForm(array('relative' => $this->view->campaign->relative));
     $consumer = $this->_currentUser;
     $order = new Zend_Db_Expr(' id ');
     $consumerFriend = new ConsumerFriend();
     $friends = $consumerFriend->fetchAll('consumer= ' . $consumer->id . ' and campaign=' . $this->view->campaign->id, $order);
     $this->view->friendsNum = count($friends);
     //consumer_extra_info
     /*$consumer_extra_info = new ConsumerExtraInfo();
         //TOCHECK
     		$consumerextra = $consumer_extra_info->fetchAll("consumer_id= ".$consumer->id);*/
     $select_consumer_extra_info = $db->select();
     $select_consumer_extra_info->from('consumer_extra_info', '*')->where('consumer_extra_info.consumer_id = ?', $consumer->id);
     $consumerextra = $db->fetchAll($select_consumer_extra_info);
     if ($this->_request->getPost()) {
         $formData = $this->_request->getPost();
         $form->populate($formData);
         $this->view->city = $formData["city"];
         $this->view->province = $formData["province"];
         $this->view->encity = $formData["city"];
     } else {
         $form->populate($consumer->toArray());
         $form->birthdate->setValue($consumerextra[0]['birthdate']);
         $form->gender->setValue($consumerextra[0]['gender']);
         $form->education->setValue($consumerextra[0]['education']);
         $form->income->setValue($consumerextra[0]['income']);
         $form->telephone->setValue($consumer->company_phone);
         // zh city
         if ($consumer["city"] != NULL && $consumer["province"] != NULL) {
             $this->view->city = $consumer["city"];
             $this->view->province = $consumer["province"];
         }
         // en city
         if ($consumer["city"] != NULL && $consumer["province"] == NULL) {
             $this->view->encity = $consumer["city"];
         }
         if (count($friends)) {
             $i = 1;
             foreach ($friends as $friend) {
                 $name = 'friend_name_' . $i;
                 $email = 'friend_email_' . $i;
                 $phone = 'friend_phone_' . $i;
                 $address = 'friend_address_' . $i;
                 $message = 'friend_message_' . $i;
                 $form->{$name}->setValue($friend->name);
                 $form->{$email}->setValue($friend->email);
                 $form->{$phone}->setValue($friend->phone);
                 $form->{$address}->setValue($friend->address);
                 $form->{$message}->setValue($friend->message);
                 $i++;
             }
         }
     }
     //var_dump($form);die;
     $langNamespace = new Zend_Session_Namespace('Lang');
     $this->view->language = $langNamespace->lang;
     $this->view->form = $form;
     $this->view->friendsLimit = $this->view->campaign->relative;
     //Zend_Debug::dump($this->_request->getPost ());
     //Zend_Debug::dump($this->view->friendsLimit);
 }
Example #4
0
            $data->templateWrite($_POST['templateEditor']);
            break;
        case 'launch':
            $data->launch();
            break;
        case 'newTemplate':
            $data->templateEmpty();
            break;
        case 'modificationObjetCampagne':
            $data->object($_POST['objet']);
            break;
        case 'copieTemplate':
            $data->templateCopy($_GET['template']);
            break;
        case 'modificationSMSCampagne':
            $data->update('message', $_POST['message']);
            break;
        case 'updateTracking':
            $data->trackingUpdate();
            break;
        case 'test':
            $data->testing();
            Core::goPage('campagne', array('id' => $_GET['id']), true);
            break;
    }
}
Configuration::write('tpl.actuel', $data->get('type'));
Core::loadHeader();
if ($data->get('type') == 'email') {
    ?>
<h2 id="titre-campagne" <?php 
**
**    ACH is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with Open Source ACH. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////// */
include "code/includes.php";
$active_campaign = new Campaign();
$active_campaign->populateFromAttribute($_REQUEST["keyword"], "keyword");
foreach ($_REQUEST as $field => $value) {
    $active_campaign->{$field} = addslashes($value);
}
$active_campaign->update();
Campaign::setStatusMessage("Saved!");
?>

<html>
<head>
	<title>Updating...</title>
	<meta http-equiv=Refresh content="0; url=campaign/<?php 
echo $active_campaign->keyword;
?>
">
</head>



<body>