public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Event::create([]);
     }
 }
Esempio n. 2
0
 public function createEvent($testKey, $variantKey, $eventKey, $participantId, $metadata = null)
 {
     $value = null;
     if (isset($metadata['value'])) {
         $value = $metadata['value'];
         unset($metadata['value']);
     }
     Event::create(array('testkey' => $testKey, 'variantkey' => $variantKey, 'eventkey' => $eventKey, 'participantid' => $participantId, 'value' => $value, 'metadata' => json_encode($metadata)));
 }
Esempio n. 3
0
 /**
  * @covers ::create
  * @covers Nora\Core\Event\EventObserverClosure::__construct
  * @covers Nora\Core\Event\EventObserverClosure::notify
  */
 public function testEventObserverClosure()
 {
     $observer = EventObserver::create(function (EventIF $event) {
         $this->assertTrue($event->match('test'));
         $this->assertTrue($event->match('test1'));
     });
     $ev = Event::create('test');
     $ev->addTag('test1');
     $observer->notify($ev);
 }
 /**
  * Create a new event based data in this model
  */
 public function createNewEvent($writeUpdate = true)
 {
     $event = Event::create()->update(array('Title' => "{$this->Gallery()->Title} - {$this->ArtistName}", 'ArtistName' => $this->ArtistName, 'StartDate' => $this->StartDate, 'EndDate' => $this->EndDate, 'HasFreeDrinks' => $this->HasFreeDrinks, 'GalleryID' => $this->GalleryID));
     $event->write();
     $this->update(array('State' => 'Merged', 'EventID' => $event->ID));
     if ($writeUpdate) {
         $this->write();
     }
     return $event;
 }
Esempio n. 5
0
 public function create()
 {
     if ($this->checkData()) {
         if (isset($_GET['url'])) {
             $tempUrl = $_GET['url'];
         }
         Event::create(['title' => $_GET['title'], 'description' => $_GET['description'], 'location' => $_GET['location'], 'url' => $this->tempUrl, 'start' => $_GET['start'], 'end' => $_GET['end'], 'color' => $_GET['color'], 'textColor' => $_GET['textColor']]);
     } else {
     }
 }
Esempio n. 6
0
 function action_create()
 {
     $event = new Event($_POST);
     $event->uid = User::$current_user->uid;
     if ($event->create()) {
         Notification::add("Event created (updated) successfully.");
         Page::redirect("/events/view?eid={$event->eid}");
     }
     Notification::add("Event not created.  Please try again.");
     Page::redirect("/events/create");
 }
Esempio n. 7
0
 static function createEvent($eventType, $team, $station, $points, $data = "")
 {
     if (is_array($data)) {
         $data = json_encode($data);
     }
     // if data is an array assume its json and convert it to text
     $o = new Event();
     $o->set('eventType', $eventType);
     $o->set('teamId', $team->get('OID'));
     $o->set('stationId', $station->get('OID'));
     $o->set('points', $points);
     $o->set('data', $data);
     return $o->create();
 }
function _ops_update()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = '';
    loginRequireMgmt();
    if (!loginCheckPermission(USER::TEST_EVENT)) {
        redirect("errors/401");
    }
    $itemName = "Event";
    $urlPrefix = "test_event";
    $object = new Event();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            $object->merge($_POST);
            if ($object->update()) {
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $object->merge($_POST);
        transactionBegin();
        if ($object->create()) {
            transactionCommit();
            $msg = "{$itemName} created!";
        } else {
            transactionRollback();
            $msg = "{$itemName} Create failed";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}
 /**
  * Return Event and Gallery data
  */
 public function createModels()
 {
     $eventData = array();
     $galleryData = array();
     // 1:1 data
     $eventData['Title'] = $this->summary;
     $eventData['StartDate'] = $this->start_dateTime;
     $eventData['EndDate'] = $this->end_dateTime;
     // Extract from summary format
     $summary = trim($this->summary);
     if (is_string($summary) && strlen($summary)) {
         $summary_parts = explode(' - ', $summary);
         if (count($summary_parts) === 2) {
             $galleryData['Title'] = $summary_parts[0];
             $eventData['ArtistName'] = $summary_parts[1];
         }
     }
     // Create models
     $event = Event::create()->update($eventData);
     $gallery = Gallery::create()->update($galleryData);
     return array('Event' => $event, 'Gallery' => $gallery);
 }
Esempio n. 10
0
 /**
  * create
  */
 public function create()
 {
     $res = new Response();
     // Ugh, php...check if !hash
     if (is_array($this->params) && !empty($this->params) && preg_match('/^\\d+$/', implode('', array_keys($this->params)))) {
         foreach ($this->params as $data) {
             array_push($res->data, Event::create($data)->to_hash());
         }
         $res->success = true;
         $res->message = "Created " . count($res->data) . ' records';
     } else {
         if ($rec = Event::create($this->params)) {
             $res->data = $rec->to_hash();
             $res->success = true;
             $res->message = "Created record";
         } else {
             $res->success = false;
             $res->message = "Failed to create record";
         }
     }
     return $res->to_json();
 }
Esempio n. 11
0
 public function __construct()
 {
     self::authorizeFromEnv();
     $this->data = array('parameters' => array("key" => "value"));
     $this->datas = array();
     // CRUD ___________________________________
     // Create
     for ($x = 0; $x <= 2; $x++) {
         $this->datas[] = Event::create($this->data);
     }
     $this->created = $this->datas[0];
     // Retrieve
     $this->retrieved = Event::retrieve($this->created->id);
     // Update
     // Delete
     $this->deleted = $this->created->delete();
     // List
     $this->order = Event::all(array("order" => "id"));
     $this->orderInv = Event::all(array("order" => "-id"));
     $this->limit5 = Event::all(array("limit" => "5", "order" => "id"));
     $this->limit1 = Event::all(array("start_after" => $this->limit5[1]->id, "end_before" => $this->limit5[3]->id));
     $this->oneId = Event::all(array("id" => $this->limit5[1]->id));
 }
Esempio n. 12
0
function saveEvent($arr, $name)
{
    $now = new DateTime();
    if (strtotime($arr['start_time']) > $now->getTimestamp()) {
        echo $arr['name'] . ', ';
        var_dump($arr);
        $date = date('Y-m-d H:i:s', strtotime($arr['start_time']));
        if (!isset($arr['place']['location']['longitude']) || !isset($arr['place']['location']['latitude'])) {
            $loc = getLngLat($arr['place']['name']);
        } else {
            $loc = getPlaceName($arr['place']['location']['longitude'] . ' ' . $arr['place']['location']['latitude']);
        }
        if ($loc) {
            $lnglat = $loc['lng'] . ' ' . $loc['lat'];
            $place = $loc['place'];
        } else {
            $place = $arr['place']['name'];
            $loc = $arr['place']['location']['longitude'] . ' ' . $arr['place']['location']['latitude'];
        }
        $event = array('TITLE' => $arr['name'], 'DESCRIPTION' => $arr['description'], 'PLACE' => $place, 'EVENTDATE' => $date, 'PLACELNGLAT' => $lnglat, 'FACEBOOKID' => $id, 'EMAIL' => '', 'URL' => '', 'FACEBOOKEVENTID' => $arr['id'], 'FACEBOOKID' => $name);
        $addEvent = new Event();
        $addEvent->create($event);
    }
}
Esempio n. 13
0
 require_once 'MysqlEntity.class.php';
 class_exists('Update') or (require_once 'Update.class.php');
 Update::ExecutePatch(true);
 require_once 'Feed.class.php';
 require_once 'Event.class.php';
 require_once 'User.class.php';
 require_once 'Folder.class.php';
 require_once 'Configuration.class.php';
 $cryptographicSalt = User::generateSalt();
 $synchronisationCode = substr(sha1(rand(0, 30) . time() . rand(0, 30)), 0, 10);
 $root = substr($_['root'], strlen($_['root']) - 1) == '/' ? $_['root'] : $_['root'] . '/';
 // DOSSIERS À CONSERVER TELS QUELS, SI DÉJÀ EXISTANTS
 $feedManager = new Feed();
 $feedManager->create();
 $eventManager = new Event();
 $eventManager->create();
 // COMPTE ADMINISTRATEUR, RÀZ SI NÉCESSAIRE
 $userManager = new User();
 if ($userManager->tableExists()) {
     // Suppose qu'il n'y a qu'un seul utilisateur
     $userManager->truncate();
 }
 $userManager->create();
 $admin = new User();
 $admin->setLogin($_['login']);
 $admin->setPassword($_['password'], $cryptographicSalt);
 $admin->save();
 $_SESSION['currentUser'] = serialize($admin);
 // DOSSIERS DE FLUX, RECRÉE LE DOSSIER GÉNÉRAL SI NÉCESSAIRE
 $folderManager = new Folder();
 $folderManager->create();
Esempio n. 14
0
 /**
  * Test cancel order api
  */
 public function testCancelWithParticipant()
 {
     $this->_eventId = Event::create($this->_individualId);
     $eventParams = array('id' => $this->_eventId, 'financial_type_id' => 4, 'is_monetary' => 1);
     $this->callAPISuccess('event', 'create', $eventParams);
     $participantParams = array('financial_type_id' => 4, 'event_id' => $this->_eventId, 'role_id' => 1, 'status_id' => 1, 'fee_currency' => 'USD', 'contact_id' => $this->_individualId);
     $participant = $this->callAPISuccess('Participant', 'create', $participantParams);
     $extraParams = array('contribution_mode' => 'participant', 'participant_id' => $participant['id']);
     $contribution = $this->addOrder(TRUE, 100, $extraParams);
     $paymentParticipant = array('participant_id' => $participant['id'], 'contribution_id' => $contribution['id']);
     $this->callAPISuccess('ParticipantPayment', 'create', $paymentParticipant);
     $params = array('contribution_id' => $contribution['id']);
     $this->callAPISuccess('order', 'cancel', $params);
     $order = $this->callAPISuccess('Order', 'get', $params);
     $expectedResult = array($contribution['id'] => array('total_amount' => 100, 'contribution_id' => $contribution['id'], 'contribution_status' => 'Cancelled', 'net_amount' => 100));
     $this->checkPaymentResult($order, $expectedResult);
     $participantPayment = $this->callAPISuccess('ParticipantPayment', 'getsingle', $params);
     $participant = $this->callAPISuccess('participant', 'get', array('id' => $participantPayment['participant_id']));
     $this->assertEquals($participant['values'][$participant['id']]['participant_status'], 'Cancelled');
     $this->callAPISuccess('Contribution', 'Delete', array('id' => $contribution['id']));
 }
Esempio n. 15
0
<?php

/**
 * Création d'un nouvel événement
 *
 * 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
 */
$event = Event::create($_GET['contact']);
$event = new Event($event);
echo $event->json();
Esempio n. 16
0
 /**
  * deleteLocBlock() method
  * delete the location block
  * created with various elements.
  * 
  */
 function testDeleteLocBlock()
 {
     //create test event record.
     $eventId = Event::create();
     $params['location'][1] = array('location_type_id' => 1, 'is_primary' => 1, 'address' => array('street_address' => 'Saint Helier St', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', 'city' => 'Newark', 'postal_code' => '01903', 'country_id' => 1228, 'state_province_id' => 1029, 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973'), 'email' => array('1' => array('email' => '*****@*****.**')), 'phone' => array('1' => array('phone_type_id' => 1, 'phone' => '303443689'), '2' => array('phone_type_id' => 2, 'phone' => '9833910234')), 'im' => array('1' => array('name' => 'jane.doe', 'provider_id' => 1)));
     $params['entity_id'] = $eventId;
     $params['entity_table'] = 'civicrm_event';
     //create location block.
     //with various elements
     //like address, phone, email, im.
     require_once 'CRM/Core/BAO/Location.php';
     $location = CRM_Core_BAO_Location::create($params, null, true);
     $locBlockId = CRM_Utils_Array::value('id', $location);
     //update event record with location block id
     require_once 'CRM/Event/BAO/Event.php';
     $eventParams = array('id' => $eventId, 'loc_block_id' => $locBlockId);
     CRM_Event_BAO_Event::add($eventParams);
     //delete the location block
     CRM_Core_BAO_Location::deleteLocBlock($locBlockId);
     //Now check DB for location elements.
     //Now check DB for Address
     $this->assertDBNull('CRM_Core_DAO_Address', 'Saint Helier St', 'id', 'street_address', 'Database check, Address deleted successfully.');
     //Now check DB for Email
     $this->assertDBNull('CRM_Core_DAO_Email', '*****@*****.**', 'id', 'email', 'Database check, Email deleted successfully.');
     //Now check DB for Phone
     $this->assertDBNull('CRM_Core_DAO_Phone', '303443689', 'id', 'phone', 'Database check, Phone deleted successfully.');
     //Now check DB for Mobile
     $this->assertDBNull('CRM_Core_DAO_Phone', '9833910234', 'id', 'phone', 'Database check, Mobile deleted successfully.');
     //Now check DB for IM
     $this->assertDBNull('CRM_Core_DAO_IM', 'jane.doe', 'id', 'name', 'Database check, IM deleted successfully.');
     //cleanup DB by deleting the record.
     Event::delete($eventId);
     //Now check DB for Event
     $this->assertDBNull('CRM_Event_DAO_Event', $eventId, 'id', 'id', 'Database check, Event deleted successfully.');
 }
Esempio n. 17
0
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP') != 1) {
    G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
    G::header('location: ../login/login');
    die;
}
global $_DBArray;
//get the posted fields of new Event and create a new record of that
require_once 'classes/model/Event.php';
$oEvent = new Event();
$envUId = $oEvent->create($_POST);
$_SESSION['EVN_UID'] = $envUId;
require_once 'eventsEditAction.php';
die;
/*
//this page is showing the parameters for setup email messages and triggers,
//probably this will be changed soon.
$aTemplates   = array();
$aTemplates[] = array('TEMPLATE1' => 'char',
      	              'TEMPLATE2' => 'char');
$sDirectory = PATH_DATA_MAILTEMPLATES . $_POST['PRO_UID'] . PATH_SEP;
G::verifyPath($sDirectory, true);
$oDirectory   = dir($sDirectory);
while ($sObject = $oDirectory->read()) {
  if (($sObject !== '.') && ($sObject !== '..')) {
    $aTemplates[] = array('TEMPLATE1' => $sObject,
Esempio n. 18
0
 private function redirect()
 {
     //just alter here, create a case for new modules.(class)
     switch ($this->module) {
         case "condominium":
             $controller = new Condominium();
             break;
         case "tower":
             $controller = new Tower();
             break;
         case "client":
             $controller = new Client();
             break;
         case "apartment":
             $controller = new Apartment();
             break;
         case "garage":
             $controller = new Garage();
             break;
         case "parking":
             $controller = new Parking();
             break;
         case "warning":
             $controller = new Warning();
             break;
         case "common-area":
             $controller = new CommonArea();
             break;
         case "research":
             $controller = new Research();
             break;
         case "answers":
             $controller = new Answers();
             break;
         case "result":
             $controller = new Result();
             break;
         case "booking":
             $controller = new Booking();
             break;
         case "event":
             $controller = new Event();
             break;
         default:
             echo json_encode(array("error" => "invalid module"));
             return false;
             break;
     }
     switch ($this->mode) {
         case 'create':
             $return = $controller->create();
             break;
         case 'read':
             $return = $controller->create();
             break;
         case 'update':
             $return = $controller->create();
             break;
         case 'delete':
             $return = $controller->create();
             break;
         case 'delete':
             $return = $controller->create();
             break;
         case 'login':
             $return = $controller->login();
             break;
         default:
             $return = array("error" => "invalid module");
             break;
     }
     echo json_encode($return);
 }
 /**
  * Test create order api for participant
  */
 public function testAddOrderForPariticipant()
 {
     require_once 'CiviTest/Event.php';
     $this->_eventId = Event::create($this->_individualId);
     $p = array('contact_id' => $this->_individualId, 'receive_date' => '2010-01-20', 'total_amount' => 300, 'financial_type_id' => $this->_financialTypeId, 'contribution_status_id' => 1);
     $priceFields = $this->createPriceSet();
     foreach ($priceFields['values'] as $key => $priceField) {
         $lineItems[$key] = array('price_field_id' => $priceField['price_field_id'], 'price_field_value_id' => $priceField['id'], 'label' => $priceField['label'], 'field_title' => $priceField['label'], 'qty' => 1, 'unit_price' => $priceField['amount'], 'line_total' => $priceField['amount'], 'financial_type_id' => $priceField['financial_type_id'], 'entity_table' => 'civicrm_participant');
     }
     $p['line_items'][] = array('line_item' => $lineItems, 'params' => array('contact_id' => $this->_individualId, 'event_id' => $this->_eventId, 'status_id' => 1, 'role_id' => 1, 'register_date' => '2007-07-21 00:00:00', 'source' => 'Online Event Registration: API Testing'));
     $order = $this->callAPISuccess('order', 'create', $p);
     $params = array('contribution_id' => $order['id']);
     $order = $this->callAPISuccess('order', 'get', $params);
     $expectedResult = array($order['id'] => array('total_amount' => 300, 'contribution_id' => $order['id'], 'contribution_status' => 'Completed', 'net_amount' => 300));
     $this->checkPaymentResult($order, $expectedResult);
     $this->callAPISuccessGetCount('ParticipantPayment', $params, 1);
     $this->callAPISuccess('Contribution', 'Delete', array('id' => $order['id']));
     $p['line_items'][] = array('line_item' => $lineItems, 'params' => array('contact_id' => $this->individualCreate(), 'event_id' => $this->_eventId, 'status_id' => 1, 'role_id' => 1, 'register_date' => '2007-07-21 00:00:00', 'source' => 'Online Event Registration: API Testing'));
     $p['total_amount'] = 600;
     $order = $this->callAPISuccess('order', 'create', $p);
     $expectedResult = array($order['id'] => array('total_amount' => 600, 'contribution_status' => 'Completed', 'net_amount' => 600));
     $paymentParticipant = array('contribution_id' => $order['id']);
     $order = $this->callAPISuccess('order', 'get', $paymentParticipant);
     $this->checkPaymentResult($order, $expectedResult);
     $this->callAPISuccessGetCount('ParticipantPayment', $paymentParticipant, 2);
     $this->callAPISuccess('Contribution', 'Delete', array('id' => $order['id']));
 }
Esempio n. 20
0
 /**
  * creates row tasks from an Route Array
  * @param string $aTasks
  * @return array
  */
 public function createRouteRows($aRoutes)
 {
     $routeID = array();
     $aField = array();
     $taskParallel = '';
     $taskSecJoin = '';
     $taskEvaluate = '';
     $taskParallelEv = '';
     $taskSelect = '';
     $taskDiscriminator = '';
     foreach ($aRoutes as $key => $row) {
         $sRouteType = $row['ROU_TYPE'];
         $oRoute = new Route();
         $oProcessMap = new processMap();
         $oTask = new Task();
         $oEvent = new Event();
         //unset ($row['ROU_UID']);
         //Saving Gateway into the GATEWAY table
         $idTask = $row['TAS_UID'];
         $nextTask = $row['ROU_NEXT_TASK'];
         if ($nextTask == "-1") {
             $end = 1;
         }
         if ($sRouteType != 'SEQUENTIAL') {
             switch ($sRouteType) {
                 case 'PARALLEL':
                     if ($idTask != $taskParallel) {
                         $taskParallel = $idTask;
                         $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
                     }
                     break;
                 case 'SEC-JOIN':
                     if ($nextTask != $taskSecJoin) {
                         $taskSecJoin = $nextTask;
                         $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
                     }
                     break;
                 case 'EVALUATE':
                     if ($idTask != $taskEvaluate) {
                         $taskEvaluate = $idTask;
                         $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
                     }
                     break;
                 case 'PARALLEL-BY-EVALUATION':
                     if ($idTask != $taskParallelEv) {
                         $taskParallelEv = $idTask;
                         $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
                     }
                     break;
                 case 'SELECT':
                     if ($idTask != $taskSelect) {
                         $taskSelect = $idTask;
                         $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
                     }
                     break;
                 case 'DISCRIMINATOR':
                     if ($nextTask != $taskDiscriminator) {
                         $taskDiscriminator = $nextTask;
                         $sGatewayUID = $oProcessMap->saveNewGateway($row['PRO_UID'], $row['TAS_UID'], $row['ROU_NEXT_TASK']);
                     }
                     break;
             }
             $row['GAT_UID'] = $sGatewayUID;
         }
         if ($oRoute->routeExists($row['ROU_UID'])) {
             $oRoute->remove($row['ROU_UID']);
         }
         $routeID = $oRoute->create($row);
         //saving end event while import old processes
         if (isset($end) && $end == 1) {
             if (!$oEvent->existsByTaskUidFrom($idTask)) {
                 if ($sRouteType == "SEQUENTIAL") {
                     $aTaskDetails = $oTask->load($idTask);
                     $positionX = $aTaskDetails['TAS_POSX'] + $aTaskDetails['TAS_WIDTH'] / 2;
                     $positionY = $aTaskDetails['TAS_POSY'] + $aTaskDetails['TAS_HEIGHT'] + 10;
                     $aData['PRO_UID'] = $row['PRO_UID'];
                     $aData['EVN_TYPE'] = 'bpmnEventEmptyEnd';
                     $aData['EVN_POSX'] = $positionX;
                     $aData['EVN_POSY'] = $positionY;
                     $aData['EVN_TAS_UID_FROM'] = $idTask;
                     $aData['EVN_STATUS'] = 'ACTIVE';
                     $aData['EVN_RELATED_TO'] = 'MULTIPLE';
                     $aData['EVN_WHEN'] = '1';
                     $aData['EVN_ACTION'] = '';
                     $sEvn_uid = $oEvent->create($aData);
                     $aField['ROU_UID'] = $routeID;
                     $aField['ROU_EVN_UID'] = $sEvn_uid;
                     $oRoute->update($aField);
                     $end = 0;
                 }
             }
         }
     }
     return;
 }
Esempio n. 21
0
 /**
  * Launch an email tracking
  *
  * @param array  $result  Send email result
  * @param string $numero  Send numero
  * @param int    $contact Person ID
  *
  * @return void
  **/
 public function tracking(array $result, $numero = null, $contact = null)
 {
     switch ($this->_campaign['type']) {
         case 'email':
             switch ($result['status']) {
                 case 'rejected':
                     $query = Core::query('campaign-tracking-reject');
                     $query->bindValue(':campaign', $this->_campaign['id'], PDO::PARAM_INT);
                     $query->bindValue(':id', $result['_id']);
                     $query->bindValue(':email', $result['email']);
                     $query->bindValue(':status', $result['status']);
                     $query->bindValue(':reject', $result['reject_reason']);
                     $query->execute();
                     break;
                 default:
                     $query = Core::query('campaign-tracking');
                     $query->bindValue(':campaign', $this->_campaign['id'], PDO::PARAM_INT);
                     $query->bindValue(':id', $result['_id']);
                     $query->bindValue(':email', $result['email']);
                     $query->bindValue(':status', $result['status']);
                     $query->execute();
                     $query = Core::query('contact-by-email');
                     $query->bindValue(':coord', $result['email']);
                     $query->execute();
                     $contact = $query->fetch(PDO::FETCH_ASSOC);
                     $event = Event::create($contact['contact']);
                     $event = new Event($event);
                     $event->update('historique_type', 'email');
                     $event->update('historique_objet', $this->_campaign['objet']);
                     $event->update('historique_date', date('Y-m-d'));
                     $event->update('campagne_id', $this->_campaign['id']);
                     $e = new Evenement($contact['contact'], false, true);
                     $e->modification('historique_type', 'email');
                     $e->modification('campagne_id', $this->_campaign['id']);
                     $e->modification('historique_objet', $this->_campaign['objet']);
                     break;
             }
             break;
         case 'sms':
             $query = Core::query('campaign-sms-tracking');
             $query->bindValue(':campaign', $this->_campaign['id'], PDO::PARAM_INT);
             $query->bindValue(':numero', $numero);
             $query->bindValue(':id', $result->id());
             $query->execute();
             $event = Event::create($contact);
             $event = new Event($event);
             $event->update('historique_type', 'sms');
             $event->update('historique_objet', $this->_campaign['titre']);
             $event->update('historique_notes', $this->_campaign['message']);
             $event->update('historique_date', date('Y-m-d'));
             $event->update('campagne_id', $this->_campaign['id']);
             break;
     }
 }
Esempio n. 22
0
    /**

     * Create Event rows from an array, removing those Objects

     * with the same UID, and recreaiting the records from the array data.

     *

     * @param $Event array.

     * @return void

     */

    public function createEventRows ($Event)

    {

        foreach ($Event as $key => $row) {

            $oEvent = new Event();

            if ($oEvent->Exists( $row['EVN_UID'] )) {

                $oEvent->remove( $row['EVN_UID'] );

            }

            $res = $oEvent->create( $row );

        }

        return;

    }
Esempio n. 23
0
 /**
  * Add participant with contribution
  *
  * @return array
  */
 protected function addParticipantWithContribution()
 {
     // creating price set, price field
     require_once 'CiviTest/Event.php';
     $this->_contactId = Contact::createIndividual();
     $this->_eventId = Event::create($this->_contactId);
     $paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 4);
     $paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
     $paramsSet['is_active'] = TRUE;
     $paramsSet['financial_type_id'] = 4;
     $paramsSet['extends'] = 1;
     $priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
     $priceSetId = $priceset->id;
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
     $paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'CheckBox', 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_value' => array('1' => 100, '2' => 200), 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_weight' => array('1' => 1, '2' => 2), 'option_amount' => array('1' => 100, '2' => 200), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1, '2' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1, 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'));
     $priceField = CRM_Price_BAO_PriceField::create($paramsField);
     $eventParams = array('id' => $this->_eventId, 'financial_type_id' => 4, 'is_monetary' => 1);
     CRM_Event_BAO_Event::create($eventParams);
     CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceSetId);
     $priceFields = $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $priceField->id));
     $participantParams = array('financial_type_id' => 4, 'event_id' => $this->_eventId, 'role_id' => 1, 'status_id' => 14, 'fee_currency' => 'USD', 'contact_id' => $this->_contactId);
     $participant = CRM_Event_BAO_Participant::add($participantParams);
     $contributionParams = array('total_amount' => 150, 'currency' => 'USD', 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'contribution_status_id' => 1, 'partial_payment_total' => 300.0, 'partial_amount_pay' => 150, 'contribution_mode' => 'participant', 'participant_id' => $participant->id);
     foreach ($priceFields['values'] as $key => $priceField) {
         $lineItems[1][$key] = array('price_field_id' => $priceField['price_field_id'], 'price_field_value_id' => $priceField['id'], 'label' => $priceField['label'], 'field_title' => $priceField['label'], 'qty' => 1, 'unit_price' => $priceField['amount'], 'line_total' => $priceField['amount'], 'financial_type_id' => $priceField['financial_type_id']);
     }
     $contributionParams['line_item'] = $lineItems;
     $contributions = CRM_Contribute_BAO_Contribution::create($contributionParams);
     $paymentParticipant = array('participant_id' => $participant->id, 'contribution_id' => $contributions->id);
     $ids = array();
     CRM_Event_BAO_ParticipantPayment::create($paymentParticipant, $ids);
     return array($lineItems, $contributions);
 }
 /**
  * Add participant with contribution
  *
  * @return array
  */
 protected function createParticipantWithContribution()
 {
     // creating price set, price field
     $this->_contactId = Contact::createIndividual();
     $this->_eventId = Event::create($this->_contactId);
     $eventParams = array('id' => $this->_eventId, 'financial_type_id' => 4, 'is_monetary' => 1);
     $this->callAPISuccess('event', 'create', $eventParams);
     $priceFields = $this->createPriceSet('event', $this->_eventId);
     $participantParams = array('financial_type_id' => 4, 'event_id' => $this->_eventId, 'role_id' => 1, 'status_id' => 14, 'fee_currency' => 'USD', 'contact_id' => $this->_contactId);
     $participant = $this->callAPISuccess('Participant', 'create', $participantParams);
     $contributionParams = array('total_amount' => 150, 'currency' => 'USD', 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'contribution_status_id' => 1, 'partial_payment_total' => 300.0, 'partial_amount_pay' => 150, 'contribution_mode' => 'participant', 'participant_id' => $participant['id']);
     foreach ($priceFields['values'] as $key => $priceField) {
         $lineItems[1][$key] = array('price_field_id' => $priceField['price_field_id'], 'price_field_value_id' => $priceField['id'], 'label' => $priceField['label'], 'field_title' => $priceField['label'], 'qty' => 1, 'unit_price' => $priceField['amount'], 'line_total' => $priceField['amount'], 'financial_type_id' => $priceField['financial_type_id']);
     }
     $contributionParams['line_item'] = $lineItems;
     $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
     $paymentParticipant = array('participant_id' => $participant['id'], 'contribution_id' => $contribution['id']);
     $ids = array();
     $this->callAPISuccess('ParticipantPayment', 'create', $paymentParticipant);
     return array($lineItems, $contribution);
 }
Esempio n. 25
0
 /**
  * Fires a event, and returns it's generated event object.
  * @param $eventName: string   -> the name of the event to be fired
  * @param ...$eventArgs: any[] -> event arguments
  * @return \browserfs\Event    -> event object
  * @throws \Exception
  */
 public final function fire($eventName)
 {
     if (!is_string($eventName)) {
         throw new \browserfs\Exception('Invalid argument $eventName: string expected');
     } else {
         if (!strlen($eventName)) {
             throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected');
         }
     }
     if (!isset($this->events[$eventName])) {
         return;
     }
     $eventArgs = array_slice(func_get_args(), 1);
     $event = Event::create($eventName, $eventArgs);
     try {
         $this->fireId++;
         // run the loop on a copy, in order to allow the $this->off method
         // to work properly
         $copy = [];
         foreach ($this->events[$eventName] as &$subscriber) {
             $copy[] =& $subscriber;
         }
         foreach ($copy as &$subscriber) {
             $subscriber['fireId'] = $this->fireId;
             call_user_func($subscriber['callback'], $event);
             if ($event->isPropagationStopped()) {
                 break;
             }
         }
         if (isset($this->events[$eventName])) {
             // remove the fired "once" listeners
             for ($i = count($this->events[$eventName]) - 1; $i >= 0; $i--) {
                 if ($this->events[$eventName][$i]['fireId'] === $this->fireId) {
                     if ($this->events[$eventName][$i]['once'] === true) {
                         // remove event
                         array_splice($this->events[$eventName], $i, 1);
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         throw new \browserfs\Exception("Error firing event " . $eventName, 0, $e);
     }
     return $event;
 }
Esempio n. 26
0
<?php

include '../../inc/init.inc';
if (isset($event_link) && $event_link != "") {
    if (!isset($data)) {
        $data = file_get_contents(SITE_PATH . "service/parse.link.php?url=" . $event_link);
    }
    $data = json_decode($data);
    if ($data == null || count($data) == 0) {
        throw new Exception('Invalid parse' . print_r($data, true));
    }
    if ($data->total_images > 0 && isset($cur_image) && $cur_image > 0) {
        $data->image = $data->images[$cur_image - 1];
    }
    $args['data'] = json_encode($data);
    $args['link'] = $event_link;
}
if (isset($event_compose) && !empty($event_compose)) {
    $args['content'] = $event_compose;
}
if ($args) {
    $args['privacy'] = empty($res->user->privacy) ? User::$PRIVACY_PUBLIC : $res->user->privacy;
    $args['user_id'] = $res->user->id;
    $event = Event::create($args);
    $res->load('timeline', array('createEvent' => true));
}
$res->load('timeline', array('createEvent' => false));
 public function test_eager_loading_belongs_to_with_no_related_rows()
 {
     $e1 = Event::create(array('venue_id' => 200, 'host_id' => 200, 'title' => 'blah', 'type' => 'Music'));
     $e2 = Event::create(array('venue_id' => 200, 'host_id' => 200, 'title' => 'blah2', 'type' => 'Music'));
     $events = Event::find(array($e1->id, $e2->id), array('include' => 'venue'));
     foreach ($events as $e) {
         $this->assert_null($e->venue);
     }
     $this->assert_sql_has("WHERE id IN(?,?)", ActiveRecord\Table::load('Event')->last_sql);
     $this->assert_sql_has("WHERE id IN(?,?)", ActiveRecord\Table::load('Venue')->last_sql);
 }
 public function testEagerLoadingBelongsToWithNoRelatedRows()
 {
     $e1 = Event::create(array('venue_id' => 200, 'host_id' => 200, 'title' => 'blah', 'type' => 'Music'));
     $e2 = Event::create(array('venue_id' => 200, 'host_id' => 200, 'title' => 'blah2', 'type' => 'Music'));
     $events = Event::find(array($e1->id, $e2->id), array('include' => 'venue'));
     foreach ($events as $e) {
         $this->assertNull($e->venue);
     }
     $this->assertSqlHas("WHERE id IN(?,?)", ActiveRecord\Table::load('Event')->lastSql);
     $this->assertSqlHas("WHERE id IN(?,?)", ActiveRecord\Table::load('Venue')->lastSql);
 }
Esempio n. 29
0
 public function setUp()
 {
     parent::setUp();
     $this->_contactId = Contact::createIndividual();
     $this->_eventId = Event::create($this->_contactId);
 }
 public function saveExtddEvents($oData)
 {
     $oTask = new Task();
     $oEvent = new Event();
     $sEvn_uid = '';
     $aData = array();
     $aData['PRO_UID'] = $oData->uid;
     $aData['EVN_TYPE'] = $oData->evn_type;
     $aData['EVN_POSX'] = $oData->position->x;
     $aData['EVN_POSY'] = $oData->position->y;
     $aData['EVN_STATUS'] = 'ACTIVE';
     $aData['EVN_WHEN'] = '1';
     $aData['EVN_ACTION'] = '';
     if (preg_match("/Inter/", $aData['EVN_TYPE'])) {
         $aData['EVN_RELATED_TO'] = 'MULTIPLE';
     }
     if (preg_match("/Start/", $aData['EVN_TYPE'])) {
         $aData['EVN_RELATED_TO'] = 'MULTIPLE';
     }
     $sEvn_uid = $oData->evn_uid;
     $oEventData = EventPeer::retrieveByPK($sEvn_uid);
     if (is_null($oEventData)) {
         $sEvn_uid = $oEvent->create($aData);
     } else {
         $aData['EVN_UID'] = $sEvn_uid;
         $oEvent->update($aData);
     }
     $oEncode->uid = $sEvn_uid;
     //$oJSON = new Services_JSON();
     return Bootstrap::json_encode($oEncode);
     //$oJSON->encode( $oEncode );
 }