コード例 #1
0
 public function run($eventId)
 {
     if (isset(Yii::app()->session["userId"])) {
         Event::delete($eventId, Yii::app()->session["userId"]);
     }
     Rest::json(array('result' => true, "msg" => Yii::t("event", "Event removed")));
 }
コード例 #2
0
function _ops_delete($OID = 0, $CID = 0)
{
    $OID = max(0, intval($OID));
    $CID = max(0, intval($CID));
    $msg = '';
    loginRequireMgmt();
    if (!loginCheckPermission(USER::TEST_EVENT)) {
        redirect("errors/401");
    }
    $itemName = "Event";
    $urlPrefix = "test_event";
    $object = new Event($OID, $CID);
    if (!$object->exists()) {
        $msg = "{$itemName} not found!";
    } else {
        transactionBegin();
        if ($object->delete()) {
            transactionCommit();
            $msg = "{$itemName} deleted!";
        } else {
            TransactionRollback();
            $msg = "{$itemName} delete failed!";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}
コード例 #3
0
function eventmanager_action()
{
    global $_, $conf, $myUser;
    switch ($_['action']) {
        case 'eventmanager_save_event':
            if ($myUser->can('event', 'c') || $myUser->can('event', 'u')) {
                $event = new Event();
                $event = $_['eventId'] != '' ? $event->getById($_['eventId']) : $event;
                $event->setName($_['eventName']);
                $event->setYear($_['eventYear']);
                $event->setMonth($_['eventMonth']);
                $event->setDay($_['eventDay']);
                $event->setHour($_['eventHour']);
                $event->setMinut($_['eventMinut']);
                $event->setRepeat('0');
                $content = array();
                //Todo, prendre en compte le multi action ([1],[2]...)
                $event->setRecipients(array());
                $event->addRecipient($_['eventTarget']);
                $content[0]['type'] = $_['eventType'];
                $event->setState($_['eventState']);
                switch ($content[0]['type']) {
                    case 'talk':
                        $content[0]['sentence'] = $_['eventContent'];
                        break;
                    case 'sound':
                        $content[0]['file'] = $_['eventContent'];
                        break;
                    case 'command':
                        $content[0]['program'] = $_['eventContent'];
                        break;
                    case 'gpio':
                        $content[0]['gpios'] = $_['eventContent'];
                        break;
                }
                $event->setContent($content[0]);
                //$event->setRecipients('all'); //@TODO
                $event->save();
                header('location:index.php?module=eventmanager');
            } else {
                header('location:index.php?module=eventmanager&error=Vous n\'avez pas le droit de faire ça!');
            }
            break;
        case 'eventmanager_delete_event':
            if ($myUser->can('event', 'd')) {
                $event = new Event();
                $event->delete(array('id' => $_['id']));
                header('location:index.php?module=eventmanager');
            } else {
                header('location:index.php?module=eventmanager&error=Vous n\'avez pas le droit de faire ça!');
            }
            break;
    }
}
コード例 #4
0
 public function afterDelete()
 {
     parent::afterDelete();
     $sql = "SELECT *\n                FROM `events`\n                WHERE `smtp_id` = ?i";
     $result = self::$_msql->getAll($sql, $this->smtp_id);
     if ($result) {
         foreach ($result as $item) {
             $modelEvent = new Event();
             $modelEvent->fillFromArray($item);
             $modelEvent->delete();
         }
     }
 }
コード例 #5
0
ファイル: events.php プロジェクト: byronwall/runnDAILY
 function delete()
 {
     //check permissions
     if (!isset($_POST["e_eid"])) {
         Notification::add("Could not delete the event.");
         Page::redirect("/events");
     }
     $event = new Event($_POST);
     if ($event->delete()) {
         Notification::add("Event was deleted.");
         Page::redirect("/events");
     }
     Notification::add("Error deleting.");
     Page::redirect("/events");
 }
コード例 #6
0
 public function afterDelete()
 {
     parent::afterDelete();
     $sql = "SELECT *\n                FROM `events`\n                WHERE `template_id` = ?i";
     $result = self::$_msql->getAll($sql, $this->template_id);
     if ($result) {
         foreach ($result as $item) {
             $modelEvent = new Event();
             $modelEvent->fillFromArray($item);
             $modelEvent->delete();
         }
     }
     // delete template files
     if ($this->template_id) {
         $fileHtml = Config::get()->basePath . '/files/' . self::FOLDER . '/body_html/template_id_' . $this->template_id;
         $filePlain = Config::get()->basePath . '/files/' . self::FOLDER . '/body_plain/template_id_' . $this->template_id;
         unlink($fileHtml);
         unlink($filePlain);
     }
 }
コード例 #7
0
ファイル: events.php プロジェクト: ricardocasares/Eventor
 function delete($id = FALSE)
 {
     $e = new Event($id);
     $e->delete();
     $this->session->set_flashdata('msg', '<div class="alert alert-success"><a class="close" data-dismiss="alert">×</a>THe event was succesfully deleted.</div>');
     redirect($this->agent->referrer());
 }
コード例 #8
0
 public static function delete_by_id($event_id)
 {
     $e = new Event();
     $e->event_id = $event_id;
     $e->delete();
 }
コード例 #9
0
 public function testDeleteForceCascadeManyToMany()
 {
     $event = new Event();
     $event->setTitle('Delete Restrict Event');
     $event->setStartDate(new fDate());
     $event->associateArtists(array(1));
     $event->store();
     $event->delete(TRUE);
     $this->assertEquals(FALSE, $event->exists());
 }
コード例 #10
0
 /**
  * delete
  */
 public function Delete($param)
 {
     try {
         if (isset($param['key'])) {
             $key = $param['key'];
             TTransaction::open('samples');
             $object = new Event($key);
             $object->delete();
             TTransaction::close();
             $posAction = new TAction(array('AgendaView', 'reload'));
             // shows the success message
             new TMessage('info', 'Record deleted', $posAction);
         }
     } catch (Exception $e) {
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         TTransaction::rollback();
     }
 }
コード例 #11
0
ファイル: LocationTest.php プロジェクト: ksecor/civicrm
 /**
  * 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.');
 }
コード例 #12
0
ファイル: event_class_add.php プロジェクト: sabasco/gnscms
if ($action == 'enableEvent') {
    $event = new Event();
    $event->storeFormValues($_GET);
    $event->updateStatus();
}
// disable the event
if ($action == 'disableEvent') {
    $event = new Event();
    $event->storeFormValues($_GET);
    $event->updateStatus();
}
// delete the event
if ($action == 'deleteEvent') {
    $event = new Event();
    $event->storeFormValues($_GET);
    $event->delete();
}
// if $_POST is detected
if (isset($_POST['events'])) {
    $_SESSION['postevents'] = $_POST['events'] != '' ? $_POST['events'] : 0;
}
if (isset($_GET['newGroup']) && $_GET['newGroup'] != '') {
    // Update the events access level for new groups
    $update = "UPDATE " . DB_PREFIX . "groups SET events = :events WHERE id = :id";
    $st = $conn->prepare($update);
    $st->bindValue(":events", $_SESSION['postevents'], PDO::PARAM_INT);
    $st->bindValue(":id", $_GET['newGroup'], PDO::PARAM_INT);
    $st->execute();
} else {
    if (isset($_POST['events']) && !isset($_GET['newGroup'])) {
        // Update the events access level for existing groups
コード例 #13
0
ファイル: events.delete.php プロジェクト: shiyamalan/csespn
<?php

require_once './global.inc.php';
verify_oauth_session_exists();
if (HttpSession::currentUser()->getOrganization()->access_level < 4) {
    echo "Access denied";
    die;
}
require_once './global.inc.php';
$event_id = $_POST["event_id"];
$result = Event::delete($event_id);
echo json_encode($result);
コード例 #14
0
ファイル: get.php プロジェクト: anasanzari/tathva-organizer
function eventManipultion()
{
    global $session;
    global $db;
    if ($session->haveAccess(1, 0, 0, 0)) {
        if (!isset($_GET['eventcode']) && !isset($_GET['eventop'])) {
            $out['status'] = 'fail';
            $out['error'] = '<!---- Gold Fish ---->';
        } else {
            $eventcode = $_GET['eventcode'];
            $eventop = $_GET['eventop'];
            if ($eventop == 'validate') {
                Event::updateColumn($db, $eventcode, Event::EVENT_VALIDATE, 1);
                $out['data'] = "validate";
            } else {
                if ($eventop == "invalidate") {
                    Event::updateColumn($db, $eventcode, Event::EVENT_VALIDATE, 0);
                    $out['data'] = "invalidate";
                } else {
                    if ($eventop == "delete") {
                        Event::delete($db, $eventcode);
                        $out['data'] = "delete";
                    } else {
                        $out['data'] = "invalid operation!!";
                    }
                }
            }
            $out['status'] = 'success';
        }
    } else {
        $out['status'] = 'fail';
        $out['error'] = 'no access';
    }
    return $out;
}
コード例 #15
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Event();
         $model->model_uset_id = $this->user->user_id;
         if ($model->findByPk($id)) {
             $model->delete();
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('events_not_deleted'));
         } else {
             $countE = AF::get($_POST, 'countE', 100000);
             if (count($modelsID) >= $countE) {
                 $link = AF::link(array('events' => 'view'));
                 Message::echoJsonRedirect($link);
             } else {
                 Message::echoJsonSuccess(__('events_deleted'));
             }
         }
     }
     $this->redirect();
 }
コード例 #16
0
 /**
  * checks db values for financial item
  */
 public function checkItemValues($contribution)
 {
     $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
     $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType(4, $relationTypeId);
     $query = "SELECT eft1.entity_id, ft.total_amount, eft1.amount FROM civicrm_financial_trxn ft INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution') \nINNER JOIN civicrm_entity_financial_trxn eft1 ON (eft1.financial_trxn_id = eft.financial_trxn_id AND eft1.entity_table = 'civicrm_financial_item')\nWHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2";
     $queryParams[1] = array($contribution->id, 'Integer');
     $queryParams[2] = array($toFinancialAccount, 'Integer');
     $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
     $amounts = array(100.0, 50.0);
     while ($dao->fetch()) {
         $this->assertEquals(150.0, $dao->total_amount, 'Mismatch of total amount paid.');
         $this->assertEquals($dao->amount, array_pop($amounts), 'Mismatch of amount proportionally assigned to financial item');
     }
     Contact::delete($this->_contactId);
     Event::delete($this->_eventId);
 }
コード例 #17
0
 public static function delete(Section $section)
 {
     /*
     	TODO:
     	Upon deletion it should update all data-sources/events attached to it.
     	Either by deleting them, or making section $unknown.
     
     	I think deletion is best because if the section is renamed, the rename()
     	function will take care of moving the dependancies, so there should be
     	no data-sources/events to delete anyway.
     
     	However, if you delete page accidentally (hm, even though you clicked
     	confirm), do you really want your data-sources/events to just be deleted?
     
     	Verdict?
     */
     // 	Remove fields:
     foreach ($section->fields as $field) {
         $field->remove();
     }
     // 	Remove sync data:
     Symphony::Database()->delete('tbl_sections_sync', array($section->guid), '`section` = "%s"');
     //	Remove entry metadata
     Symphony::Database()->delete('tbl_entries', array($section->handle), '`section` = "%s"');
     if (General::deleteFile(SECTIONS . '/' . $section->handle . '.xml')) {
         //	Cleanup Datasources
         foreach (new DataSourceIterator() as $datasource) {
             $ds = DataSource::load($datasource);
             if ($ds->parameters()->section == $section->handle) {
                 DataSource::delete($ds);
             }
         }
         //	Cleanup Events
         foreach (new EventIterator() as $event) {
             $ev = Event::load($event);
             if ($ev->parameters()->source == $section->handle) {
                 Event::delete($ev);
             }
         }
     }
 }
コード例 #18
0
ファイル: deleteevent.php プロジェクト: nsystem1/clanscripts
 *
 * Author: Bluethrust Web Development
 * E-mail: support@bluethrust.com
 * Website: http://www.bluethrust.com
 *
 * License: http://www.bluethrust.com/license.php
 *
 */
include "../../../_setup.php";
include_once "../../../classes/member.php";
include_once "../../../classes/rank.php";
include_once "../../../classes/consoleoption.php";
include_once "../../../classes/event.php";
$member = new Member($mysqli);
$member->select($_SESSION['btUsername']);
$objMember = new Member($mysqli);
$eventObj = new Event($mysqli);
$consoleObj = new ConsoleOption($mysqli);
$cID = $consoleObj->findConsoleIDByName("Manage My Events");
$consoleObj->select($cID);
if ($member->authorizeLogin($_SESSION['btPassword']) && $eventObj->select($_POST['eID'])) {
    $memberInfo = $member->get_info();
    $eventInfo = $eventObj->get_info_filtered();
    if ($eventInfo['member_id'] == $memberInfo['member_id']) {
        if ($_POST['confirmDelete'] == 1) {
            $eventObj->delete();
        } else {
            echo "\n\t\t\t\n\t\t\t\t<div id='confirmDeleteMessage' style='display: none'>\n\t\t\t\t\n\t\t\t\t\t<p class='main' align='center'>Are you sure you want to delete the event, <b>" . $eventInfo['title'] . "</b>?</p>\n\t\t\t\t\n\t\t\t\t</div>\t\t\t\n\t\t\t\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\n\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\n\t\t\t\t\t\t\$('#confirmDeleteMessage').dialog({\n\t\t\t\t\t\t\n\t\t\t\t\t\t\ttitle: 'Delete Event',\n\t\t\t\t\t\t\tmodal: true,\n\t\t\t\t\t\t\tzIndex: 99999,\n\t\t\t\t\t\t\tshow: 'scale',\n\t\t\t\t\t\t\twidth: 400,\n\t\t\t\t\t\t\tresizable: false,\n\t\t\t\t\t\t\tbuttons: {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t'Yes': function() {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\$.post('" . $MAIN_ROOT . "members/events/include/deleteevent.php', { confirmDelete: 1, eID: '" . $eventInfo['event_id'] . "' }, function(data) {\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "members/console.php?cID=" . $cID . "'\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t'Cancel': function() {\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\$(this).dialog('close');\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t\n\t\t\t\t</script>\n\t\t\t\t\n\t\t\t\t\n\t\t\t";
        }
    }
}
コード例 #19
0
 public function testAddUpdateDeleteEvent()
 {
     //    Dal::register_query_callback("explain_query");
     echo "getting a user\n";
     $user = Test::get_test_user();
     $testusername = $user->first_name . " " . $user->last_name;
     echo "test user = {$testusername}\n";
     /* setup some times and time strings */
     $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
     $tomorrow = mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"));
     $yesterday = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
     $lastmonth = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
     $nextmonth = mktime(0, 0, 0, date("m") + 1, date("d"), date("Y"));
     $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1);
     $oneday = 60 * 60 * 24;
     $simple_dateformat = "Y-m-d";
     /* use the constants in the format parameter */
     // something like: Mon, 15 Aug 2005 15:12:46 UTC
     $now_rfc822 = date(DATE_RFC822);
     // something like: 2000-07-01T00:00:00+00:00
     // $now_atom = date(DATE_ATOM);
     // create an Event
     echo "create and save Event\n";
     $e = new Event();
     $e->content_id = "http://myevent.info/1";
     // anything basically
     $e->user_id = $user->user_id;
     $e->event_title = "Test Event for {$testusername}";
     $now = time();
     $nowplusoneday = $now + $oneday;
     $e->start_time = date(DATE_ATOM, $now);
     $e->end_time = date(DATE_ATOM, $now + 60 * 60);
     // duration 1h
     $e->event_data = array('description' => "This Event takes place to test the class Event", 'start' => $now, 'end' => $now + 60 * 60);
     $e->save();
     // print_r($e);
     // see if we got it
     echo "Retrieving Event {$e->event_id}\n";
     $e2 = new Event();
     $e2->load($e->event_id);
     echo "Testing integrity of dates\n";
     // print_r($e2);
     // see if the stored timestamps match
     $this->assertEquals($now, $e2->event_data['start']);
     // see if our dates survived the DB conversion roundtrip
     $this->assertEquals($now, strtotime($e2->start_time));
     $this->assertEquals($now + 60 * 60, strtotime($e2->end_time));
     // create two EventAssociations
     $ea1 = new EventAssociation();
     $ea2 = new EventAssociation();
     $ea1->user_id = $user->user_id;
     $ea2->user_id = $user->user_id;
     // user EventAssocoiation
     $ea1->assoc_target_type = 'user';
     $ea1->assoc_target_id = $user->user_id;
     // could very well be other user
     $ea1->assoc_target_name = $testusername;
     $ea1->event_id = $e->event_id;
     $ea1->save();
     // network EventAssocoiation
     // find a network the user is member of
     // $networks = Network::get_user_networks($user->user_id);
     $network = Network::get_mothership_info();
     // use the mothership
     // print_r($network);
     $ea2->assoc_target_type = 'network';
     $ea2->assoc_target_id = $network->network_id;
     // could very well be other user
     $ea2->assoc_target_name = $network->name;
     $ea2->event_id = $e->event_id;
     $ea2->save();
     echo "Testing EventAssociations for Event {$e->event_id}\n";
     $assoc_ids = EventAssociation::find_for_event($e->event_id);
     // print_r($assoc_ids);
     $a_cnt = count($assoc_ids);
     $this->assertEquals($a_cnt, 2, "expected 2 assocs, got {$a_cnt}\n");
     echo "Testing EventAssociations::find_for_target_and_delta for Network\n";
     $assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id);
     // find_for_target_and_delta($target_type, $target_id, $range_start = NULL, $range_end = NULL)
     // print_r($assoc_ids);
     $a_cnt = count($assoc_ids);
     // we expect at least one (or more, the user might have others too)
     $this->assertTrue($a_cnt >= 1, "expected 1 or more assocs, got {$a_cnt}\n");
     echo "Testing EventAssociations::find_for_target_and_delta for Today\n";
     /*
     echo "yesterday = " . date(DATE_ATOM, $yesterday) . "\n";
     echo "today = " . date(DATE_ATOM, $today) . "\n";
     echo "event start_time = " . date(DATE_ATOM, strtotime($e2->start_time)) . "\n";
     echo "event end_time = " . date(DATE_ATOM, strtotime($e2->end_time)) . "\n";
     echo "tomorrow = " . date(DATE_ATOM, $tomorrow) . "\n";
     */
     $assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id, date(DATE_ATOM, $today), date(DATE_ATOM, $tomorrow));
     print_r($assoc_ids);
     /* 
     $assocs = EventAssociation::load_in_list($assoc_ids);
     print_r($assocs);
     */
     $a_cnt = count($assoc_ids);
     // we expect at least one (or more, the user might have others too)
     $this->assertTrue($a_cnt >= 1, "expected 1 or more assocs, got {$a_cnt}\n");
     echo "Testing if the EventAssociations now show up in Tomorrow's Calendar\n";
     $assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id, date(DATE_ATOM, $tomorrow), date(DATE_ATOM, $tomorrow + $oneday));
     print_r($assoc_ids);
     $a_cnt2 = count($assoc_ids);
     // we expect one less than before
     $this->assertTrue($a_cnt2 < $a_cnt, "expected " . $a_cnt - 1 . " assocs, got {$a_cnt2}\n");
     echo "Modifying original Event\n";
     $e2->title = "changed title";
     $e2->end_time = date(DATE_ATOM, $nextmonth);
     $e2->save();
     // see if we got it
     $e3 = new Event();
     $e3->load($e->event_id);
     echo "Testing integrity of dates again in the Event\n";
     // see if our dates survived the DB conversion roundtrip
     $this->assertEquals($now, strtotime($e3->start_time));
     $this->assertEquals(date(DATE_ATOM, strtotime($e3->end_time)), date(DATE_ATOM, $nextmonth));
     echo "Testing if modified dates made it to the EventAssociations\n";
     $assoc_ids = EventAssociation::find_for_event($e3->event_id);
     $assocs = EventAssociation::load_in_list($assoc_ids);
     echo "e3 end_time: " . date(DATE_ATOM, strtotime($assocs[0]->end_time)) . "\nnextmonth: " . date(DATE_ATOM, $nextmonth) . "\n";
     $this->assertEquals(date(DATE_ATOM, strtotime($assocs[0]->end_time)), date(DATE_ATOM, $nextmonth));
     echo "Testing if the EventAssociations now show up in Tomorrow's Calendar\n";
     echo "test range: " . date(DATE_ATOM, $tomorrow) . " - " . date(DATE_ATOM, $tomorrow + $oneday) . "\n";
     echo "event duration: " . date(DATE_ATOM, strtotime($e3->start_time)) . " - " . date(DATE_ATOM, strtotime($e3->end_time)) . "\n";
     // print_r($e3);
     $assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id, date(DATE_ATOM, $tomorrow), date(DATE_ATOM, $tomorrow + $oneday));
     print_r($assoc_ids);
     $a_cnt = count($assoc_ids);
     // we expect at least one (or more, the user might have others too)
     $this->assertTrue($a_cnt >= 1, "expected 1 or more assocs, got {$a_cnt}\n");
     echo "Deleting Event {$e->event_id}\n";
     Event::delete($e->event_id);
     // try loading
     $this->assertNull($e3->load($e->event_id));
     echo "Testing if all EventAssociations have been removed\n";
     $assoc_ids = EventAssociation::find_for_event($e->event_id);
     $a_cnt = count($assoc_ids);
     $this->assertEquals($a_cnt, 0, "expected 0 assocs, got {$a_cnt}\n");
 }
コード例 #20
0
 /**
  * FixEventLevel() method (Setting ',' values), resolveDefaults(assinging value to array) method
  */
 public function testfixEventLevel()
 {
     $paramsSet['title'] = 'Price Set';
     $paramsSet['name'] = CRM_Utils_String::titleToVar('Price Set');
     $paramsSet['is_active'] = FALSE;
     $paramsSet['extends'] = 1;
     $priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
     $paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'Text', 'price' => 10, 'option_label' => array('1' => 'Price Field'), 'option_value' => array('1' => 10), 'option_name' => array('1' => 10), 'option_weight' => array('1' => 1), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1);
     $ids = array();
     $pricefield = CRM_Price_BAO_PriceField::create($paramsField, $ids);
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceField', $pricefield->id, 'label', 'id', $paramsField['label'], 'Check DB for created pricefield');
     $eventId = $this->_eventId;
     $participantParams = array('send_receipt' => 1, 'is_test' => 0, 'is_pay_later' => 0, 'event_id' => $eventId, 'register_date' => date('Y-m-d') . " 00:00:00", 'role_id' => 1, 'status_id' => 1, 'source' => 'Event_' . $eventId, 'contact_id' => $this->_contactId, 'note' => 'Note added for Event_' . $eventId, 'fee_level' => 'Price_Field - 55');
     $participant = CRM_Event_BAO_Participant::add($participantParams);
     //Checking for participant added in the table.
     $this->assertDBCompareValue('CRM_Event_BAO_Participant', $this->_contactId, 'id', 'contact_id', $participant->id, 'Check DB for created participant');
     $values = array();
     $ids = array();
     $params = array('id' => $participant->id);
     CRM_Event_BAO_Participant::getValues($params, $values, $ids);
     $this->assertNotEquals(count($values), 0, 'Checking for empty array.');
     CRM_Event_BAO_Participant::resolveDefaults($values[$participant->id]);
     if ($values[$participant->id]['fee_level']) {
         CRM_Event_BAO_Participant::fixEventLevel($values[$participant->id]['fee_level']);
     }
     $deletePricefield = CRM_Price_BAO_PriceField::deleteField($pricefield->id);
     $this->assertDBNull('CRM_Price_BAO_PriceField', $pricefield->id, 'name', 'id', 'Check DB for non-existence of Price Field.');
     $deletePriceset = CRM_Price_BAO_PriceSet::deleteSet($priceset->id);
     $this->assertDBNull('CRM_Price_BAO_PriceSet', $priceset->id, 'title', 'id', 'Check DB for non-existence of Price Set.');
     Participant::delete($participant->id);
     Contact::delete($this->_contactId);
     Event::delete($eventId);
 }
コード例 #21
0
ファイル: event_controller.php プロジェクト: euridium/event
function event_controller()
{
    global $mysqli, $redis, $user, $session, $route, $timestore_adminkey;
    global $feed;
    include "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $timestore_adminkey);
    require "Modules/event/event_model.php";
    $event = new Event($mysqli, $redis);
    $userid = $session['userid'];
    if ($route->action == 'add' && $session['write']) {
        $eventfeed = intval(get('eventfeed'));
        $eventtype = intval(get('eventtype'));
        $eventvalue = floatval(get('eventvalue'));
        $action = intval(get('action'));
        $setfeed = intval(get('setfeed'));
        $setemail = get('setemail');
        $setvalue = floatval(get('setvalue'));
        $callcurl = get('callcurl');
        $mutetime = get('mutetime');
        $priority = get('priority');
        $message = get('message');
        $mqtttopic = get('mqtttopic');
        $mqttqos = get('mqttqos');
        $event->add($userid, $eventfeed, $eventtype, $eventvalue, $action, $setfeed, $setemail, $setvalue, $callcurl, $message, $mutetime, $priority, $mqtttopic, $mqttqos);
        $result = "Event added";
    }
    if ($route->action == 'edit' && $session['write']) {
        $eventid = intval(get('eventid'));
        $eventfeed = intval(get('eventfeed'));
        $eventtype = intval(get('eventtype'));
        $eventvalue = floatval(get('eventvalue'));
        $action = intval(get('action'));
        $setfeed = intval(get('setfeed'));
        $setemail = get('setemail');
        $setvalue = floatval(get('setvalue'));
        $callcurl = get('callcurl');
        $mutetime = get('mutetime');
        $priority = get('priority');
        $message = get('message');
        $mqtttopic = get('mqtttopic');
        $mqttqos = get('mqttqos');
        $event->update($userid, $eventid, $eventfeed, $eventtype, $eventvalue, $action, $setfeed, $setemail, $setvalue, $callcurl, $message, $mutetime, $priority, $mqtttopic, $mqttqos);
        $result = "Event updated";
    } else {
        if ($route->action == 'delete' && $session['write']) {
            $id = intval(get('id'));
            $event->delete($userid, $id);
            $result = "Event deleted";
        } else {
            if ($route->action == 'status' && $session['write']) {
                $id = intval(get('id'));
                $status = intval(get('status'));
                $event->set_status($userid, $id, $status);
                $result = "Event deleted";
            } else {
                if ($route->action == 'test' && $session['write']) {
                    $id = intval(get('id'));
                    $feedid = intval(get('feedid'));
                    $event->test($userid, $id, $feedid);
                    $result = "Event Test Sent";
                } else {
                    if ($route->action == 'settings' && $session['write']) {
                        $settings = $event->get_settings($session['userid']);
                        $result = view("Modules/event/event_settings_view.php", array('settings' => $settings));
                    } else {
                        if ($route->action == 'savesettings' && $session['write']) {
                            // Store userlang in database
                            $prowlkey = post('prowlkey');
                            $nmakey = post('nmakey');
                            $smtpserver = post('smtpserver');
                            $smtpuser = post('smtpuser');
                            $salt = $user->get_salt($session['userid']);
                            $smtppassword = trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, post('smtppassword'), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
                            $smtpport = preg_replace('/[^\\w\\s-]/', '', post('smtpport'));
                            $consumerkey = post('consumerkey');
                            $consumersecret = post('consumersecret');
                            $usertoken = post('usertoken');
                            $usersecret = post('usersecret');
                            $mqttbrokerip = post('mqttbrokerip');
                            $mqttbrokerport = post('mqttbrokerport');
                            $mqttusername = post('mqttusername');
                            $mqttpassword = trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, post('mqttpassword'), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
                            $result = $event->set_settings($session['userid'], $prowlkey, $consumerkey, $consumersecret, $usertoken, $usersecret, $smtpserver, $smtpuser, $smtppassword, $smtpport, $nmakey, $mqttbrokerip, $mqttbrokerport, $mqttusername, $mqttpassword);
                        } else {
                            if ($session['write']) {
                                $list = $event->eventlist($userid);
                                $feeds = $feed->get_user_feeds($userid);
                                $result = view("Modules/event/event_list.php", array('event_list' => $list, 'feeds' => $feeds));
                            }
                        }
                    }
                }
            }
        }
    }
    return array('content' => $result);
}