Inheritance: extends CI_Controller
 private function addEvent($type, $id, $email, $datetime)
 {
     echo 'Adding ' . strtoupper($type) . ' to campaign ' . $id . ' with date of ' . $datetime . ' and email of ' . $email . "\r\n";
     $StoreModel = new Store();
     $encryptedEmail = $StoreModel->encryptEmail($email);
     // Look for this email address in store table
     $StoreRows = Store::model()->with('store2contact')->findAll(array('condition' => 'email = :email', 'params' => array(':email' => $encryptedEmail)));
     // collect our warehouse_ids up to match in campaign_contact table.
     $warehouseIDs = [];
     if (sizeof($StoreRows)) {
         // Save 1 suppression row for every instance of the email address in the store table - use store_id
         foreach ($StoreRows as $Store) {
             if ($Store->store2contact != null) {
                 $warehouseIDs[] = $Store->store2contact->contact_warehouse_id;
             }
         }
         $Contacts = null;
         // check for contact
         if (sizeof($warehouseIDs) && is_numeric($id)) {
             //Bounces
             if ($type === 'bounce') {
                 $Contacts = CampaignContact::model()->updateAll(array('bounced' => $datetime), "campaign_id = :campaign_id AND warehouse_id IN (" . implode(',', $warehouseIDs) . ") AND bounced IS NULL", array(':campaign_id' => $id));
             } else {
                 $Contacts = CampaignContact::model()->updateAll(array('opened' => $datetime), "campaign_id = :campaign_id AND warehouse_id IN (" . implode(',', $warehouseIDs) . ") AND opened IS NULL", array(':campaign_id' => $id));
             }
         }
         echo 'Updated ' . sizeof($Contacts) . ' contact';
     } else {
         echo 'Campaign contact not found' . "\r\n";
     }
     echo "\r\n";
 }
Example #2
0
 public function testDumpJson()
 {
     $store = new Store();
     $store->push(__DIR__ . '/data/php.ini');
     unset($store['Session']);
     $this->assertEquals($store->dump(), (array) json_decode($store->dump('json')));
 }
    function select_value($pool_uri, $value, $pool_size)
    {
        if (!isset($this->bigfootMetabox)) {
            $bigfoot = new Store(STORE_URI);
            $this->bigfootMetabox = $bigfoot->get_metabox();
        }
        $changeset = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:cs="http://purl.org/vocab/changeset/schema#">
  <cs:ChangeSet>
    <cs:subjectOfChange rdf:resource="' . $pool_uri . '"/>
    <cs:creatorName>pool</cs:creatorName>
    <cs:changeReason>Selecting key</cs:changeReason>
    <cs:removal>
      <rdf:Statement>
        <rdf:subject rdf:resource="' . $pool_uri . '"/>
        <rdf:predicate rdf:resource="http://purl.org/vocab/value-pools/schema#value"/>
        <rdf:object>' . $value . '</rdf:object>
      </rdf:Statement>
    </cs:removal>
    <cs:addition>
      <rdf:Statement>
        <rdf:subject rdf:resource="' . $pool_uri . '"/>
        <rdf:predicate rdf:resource="http://purl.org/vocab/value-pools/schema#value"/>
        <rdf:object>' . ($pool_size + $value) . '</rdf:object>
      </rdf:Statement>
    </cs:addition>
  </cs:ChangeSet>
</rdf:RDF>';
        $response = $this->bigfootMetabox->apply_changeset_rdfxml($changeset);
        // echo "<pre>";
        // echo htmlspecialchars(print_r($response, true));
        // echo "</pre>";
        return true;
    }
Example #4
0
 public function getSharedNoteStore($linkedNotebook)
 {
     $noteStoreUrl = $linkedNotebook->noteStoreUrl;
     $noteStore = new Store($this->token, '\\EDAM\\NoteStore\\NoteStoreClient', $noteStoreUrl);
     $sharedAuth = $noteStore->authenticateToSharedNotebook($linkedNotebook->shareKey);
     $sharedToken = $sharedAuth->authenticationToken;
     return new Store($sharedToken, '\\EDAM\\NoteStore\\NoteStoreClient', $noteStoreUrl);
 }
Example #5
0
 public function testRootNode()
 {
     $store = new Store($this->getSession(), "SpacesStore");
     $root = $store->rootNode;
     $this->assertNotNull($root, "root node unexpectedly null");
     $this->assertNotNull($root->id, "root node id unexpectedly null");
     $this->assertEquals($store->__toString(), $root->store->__toString());
 }
 public function process(array $case)
 {
     // Allows for data to be re-read from the DB instead of being fetched
     // from the store-id-cache
     if (isset($case['store']['clear-cache']) && $case['store']['clear-cache']) {
         $this->store->clear();
     }
     $this->assertRdfOutputForCase($case);
 }
 public function actionAdmin()
 {
     $model = new Store('search');
     $model->unsetAttributes();
     if (isset($_GET['Store'])) {
         $model->setAttributes($_GET['Store']);
     }
     $this->render('admin', array('model' => $model));
 }
Example #8
0
 /** @dataProvider dataMerge */
 public function testMerge($mode, $newBarValue)
 {
     $store = new Store(':');
     $store->set('foo:bar', 'baz');
     $mergeData = ['foo' => ['bar' => 'quux', 'fizz' => 'buzz']];
     $store->merge($mergeData, $mode);
     self::assertEquals($newBarValue, $store->get('foo:bar'));
     self::assertEquals('buzz', $store->get('foo:fizz'));
 }
Example #9
0
 /**
  * Handle the event.
  *
  * @param  ClearCache  $event
  * @return void
  */
 public function handle(ClearCache $event)
 {
     if (!is_array($event->tags)) {
         return $this->cache->tags($event->tags)->flush();
     }
     foreach ($event->tags as $tag) {
         $this->cache->tags($tag)->flush();
     }
     return;
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 protected function update()
 {
     if (!isset($this->store)) {
         throw new NotOpenException(tr('Session already closed.'));
     }
     if (!$this->updated) {
         return;
     }
     $this->store->write($this->data);
     $this->updated = false;
 }
Example #11
0
 function testDelete()
 {
     $name = "Zelds";
     $test_store = new Store($name);
     $test_store->save();
     $name = "Granite";
     $test_brand = new Brand($name);
     $test_brand->save();
     $test_brand->addStore($test_brand);
     $test_brand->delete();
     $this->assertEquals([], $test_brand->getStores());
 }
Example #12
0
File: State.php Project: jivoo/core
 /**
  * Close, save (if mutable), and unlock state data.
  *
  * @throws NotOpenException If the state has already been closed.
  */
 public function close()
 {
     if (!isset($this->store)) {
         throw new NotOpenException('State already closed.');
     }
     if ($this->updated and $this->store->isMutable()) {
         $this->store->write($this->data);
     }
     $this->store->close();
     $this->store = null;
     $this->updated = false;
 }
Example #13
0
 function test_getStoreName()
 {
     //arrange
     $store_name = "Payless";
     $id = 1;
     $test_Store = new Store($store_name, $id);
     //act
     $result = $test_Store->getStoreName();
     //assert
     $this->assertEquals($store_name, $result);
     //for debugging
     var_dump($test_Store);
 }
Example #14
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Store();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
Example #15
0
 public function run()
 {
     $route = $this->router->match($this->request);
     if ($route === false) {
         $actionName = self::ACTION_NOT_FOUND;
     } else {
         $actionName = $route->getName();
     }
     if (!$this->actions->has($actionName)) {
         throw new \Exception(sprintf('Action %s not found', $actionName));
     }
     $this->store->setFileName($actionName);
     if ($this->request->isAjax()) {
         $this->view->setRenderType(View::RENDER_JSON);
     } else {
         $this->view->setContentView('error');
     }
     $action = $this->actions->get($actionName);
     call_user_func_array($action, array($this));
     if (is_callable($this->postAction)) {
         call_user_func_array($this->postAction, array($this));
     }
     $this->response->setContent($this->view->render());
     $this->response->send();
 }
 public function edit($id)
 {
     $param['pageNo'] = 3;
     $param['agent'] = AgentModel::find($id);
     $param['stores'] = StoreModel::where('company_id', Session::get('company_id'))->get();
     return View::make('company.agent.edit')->with($param);
 }
Example #17
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $result = Managers::model()->find('name=? and is_quit=?', array($this->username, "0"));
     if ($result) {
         if ($result->password == md5($this->username . md5($this->password))) {
             $this->_id = $result->id;
             $this->errorCode = self::ERROR_NONE;
             $token = md5($result->id . $this->password);
             //Yii::app()->cache_redis->set($result->id.'.UserToken',$token);
             $store = Store::model()->findAll('manager=:id', array(':id' => $result->id));
             $store_ids = array();
             if ($store) {
                 foreach ($store as $key => $val) {
                     $store_ids[] = $val->id;
                 }
             }
             Yii::app()->user->setState('token', $token);
             Yii::app()->user->setState('info', $result);
             Yii::app()->user->setState('store', $store);
             Yii::app()->user->setState('store_ids', $store_ids);
         } else {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
 private function recursive($foreign, &$order)
 {
     foreach ($foreign as $f) {
         $many = $this->store->getManager()->getConnection()->getSchemaManager()->listTableForeignKeys($f->getForeignTableName());
         if (count($many) > 0) {
             $this->recursive($many, $order);
             if (!isset($order[$f->getForeignTableName()])) {
                 $order[$f->getForeignTableName()] = $f->getForeignTableName();
             }
         } else {
             if (!isset($order[$f->getForeignTableName()])) {
                 $order[$f->getForeignTableName()] = $f->getForeignTableName();
             }
         }
     }
 }
Example #19
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Store();
     }
     return self::$instance;
 }
Example #20
0
 public function run($args)
 {
     exit('Disabled');
     $Stores = Store::model()->with('organisation')->findAll();
     foreach ($Stores as $Store) {
         if (strlen($Store->email)) {
             print $Store->first_name . ',' . $Store->last_name . ',' . $Store->email . ',' . $Store->organisation->title . ',' . $this->getEmailPrefs($Store->contact_email) . "\r\n";
             //print $Store->last_name . "\n";
             //print $Store->address_line_1 . "\n\n\n";
             //print $Store->phone . "\n\n\n";
             //print $Store->mobile . "\n\n\n";
         }
     }
     exit;
     /*
     $StoreModel = new Store;
     $email = $StoreModel->encryptEmail($email);
     
     $Store = Store::model()->findAll(array(
     	
     	'condition' => 'email = :email',
     	'params' => array(
     		':email' => $email,
     	),
     	
     ));
     
     print_r($Store);
     */
 }
Example #21
0
 public static function initialize($path)
 {
     Config::setPath($path . 'config/');
     self::$request = Request::instance();
     self::$config = Config::instance();
     self::$store = Store::instance();
 }
Example #22
0
 public function testFactory()
 {
     $this->assertInstanceOf('Store_Local', Store::factory());
     $this->assertInstanceOf('Store_Local', Store::factory(Store::Local));
     $this->assertInstanceOf('Store_Session', Store::factory(Store::Session));
     $this->assertEquals(false, Store::factory('Undefined type'));
 }
Example #23
0
 public function validateQueue(Person $person)
 {
     if ($this->queue->size() >= 10) {
         throw new Exception('В этот магазин могут встать не более 10 покупателей');
     }
     return parent::validateQueue($person);
 }
 /**
  * @covers QueueController::Add
  * @todo Implement testAdd().
  */
 public function testAdd()
 {
     $person = Person::factory('adult');
     $person->name = 'Poehavshiy';
     $person->add();
     $store = Store::factory('Grocery');
     $store->name = 'Prison';
     $store->add();
     $product = new Product();
     $product->name = 'Sladkiy hleb';
     $product->add();
     $request = Application::getInstance()->request;
     $request->setParams(array('storeId' => $store->id, 'personId' => $person->id, 'product_' . $product->id => 'on'));
     $personId = $request->p('personId');
     $storeId = $request->p('storeId');
     $store = Store::get($storeId);
     $person = Person::get($personId);
     $store->queue->add($person);
     $person->basket->drop();
     $name = 'product_' . $product->id;
     $value = $product;
     if (preg_match_all('/^product_(\\d+)$/', $name, $matches)) {
         $person->basket->add(Product::get($matches[1][0]));
     }
 }
Example #25
0
 /**
  * 
  * Salva los datos con el nombre y ruta especificado
  * 
  * $this->getStore()
  *               ->getExporter()
  *               ->setEntities(array(
  *                   '\examples\exampleBundle\Model\Entity\Persona'
  *               ))
  *               ->save(__DIR__ . '/exportExample.php');
  * 
  * @param string $file nombre del archivo a salvar con los datos
  */
 public function save($file)
 {
     $definition = array();
     foreach ($this->entities as $entity) {
         $meta = $this->store->getManager()->getMetadataFactory()->getMetadataFor($entity);
         $table = $meta->getTableName();
         $association = $meta->associationMappings;
         foreach ($association as $map) {
             if (isset($map['joinTable']) and isset($map['joinTable']['name'])) {
                 $mapTable = $map['joinTable']['name'];
                 if (!isset($definition[$mapTable])) {
                     $resultmap = $this->store->getManager()->getConnection()->executeQuery("SELECT * FROM {$mapTable}");
                     $definition[$mapTable] = $resultmap->fetchAll(\PDO::FETCH_ASSOC);
                 }
             }
         }
         $result = $this->store->getManager()->getConnection()->executeQuery("SELECT * FROM {$table}");
         $definition[$table] = $result->fetchAll(\PDO::FETCH_ASSOC);
     }
     foreach ($this->tables as $table) {
         $result = $this->store->getManager()->getConnection()->executeQuery("SELECT * FROM {$table}");
         $definition[$table] = $result->fetchAll(\PDO::FETCH_ASSOC);
     }
     $time = date("F d Y h:i:s A");
     file_put_contents($file, "<?php\n /**\n  * THIS FILE IS GENERATED BY RAPTOR EXPORTER, TO EASLY UPLOAD THIS FILE AGAIN INTO THE \n  * DATABASE USE THE IMPORTER CLASS.\n  * \n  * Generated {$time}\n  */\n \n\$create=" . var_export($this->entities, true) . ";\n\$data=" . var_export($definition, true) . ";\n\n");
 }
Example #26
0
 public function set($resource, $value)
 {
     if (is_array($value)) {
         $value = $this->array2object($value);
     }
     parent::set($resource, $value);
     return $this;
 }
Example #27
0
 public function testSetData()
 {
     $store = Store::factory(Store::Local, 'test');
     $store->set('key', 'val');
     $data = array('key2' => 'val2', 'key3' => 'val3');
     $store->setData($data);
     $this->assertEquals($data, $store->getData());
 }
Example #28
0
 public static function connect()
 {
     if (!self::$instance) {
         self::$instance = new Memcache();
         self::$instance->addServer('127.0.0.1', 11211);
     }
     return self::$instance;
 }
Example #29
0
 public static function get()
 {
     if (null == self::$instance) {
         self::$instance = new Redis('localhost');
         self::$instance->connect();
     }
     return self::$instance;
 }
Example #30
0
 /**
  * Save configuration. If this is not the root configuration, the root
  * configuration will be saved instead.
  * @return boolean True if the configuration was saved.
  */
 public function save()
 {
     if ($this->root !== $this) {
         return $this->root->save();
     }
     if (!isset($this->store)) {
         return false;
     }
     if (!$this->updated) {
         return true;
     }
     $this->store->open(true);
     $this->store->write($this->data);
     $this->store->close();
     $this->updated = false;
     return true;
 }