/** * Tax constructor. * @param Registry $registry */ public function __construct($registry) { $this->config = $registry->get('config'); $this->customer = $registry->get('customer'); $this->db = $registry->get('db'); $this->session = $registry->get('session'); // If shipping address is being used if (isset($this->session->data['shipping_address_id'])) { $address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->session->data['shipping_address_id'] . "'"); $this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']); } elseif (isset($this->session->data['guest']['shipping'])) { $this->setShippingAddress($this->session->data['guest']['shipping']['country_id'], $this->session->data['guest']['shipping']['zone_id']); } elseif ($this->customer->isLogged() && $this->config->get('config_tax_customer') == 'shipping') { $address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->customer->getAddressId() . "'"); $this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']); } elseif ($this->config->get('config_tax_default') == 'shipping') { $this->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); } if (isset($this->session->data['payment_address_id'])) { $address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->session->data['payment_address_id'] . "'"); $this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']); } elseif (isset($this->session->data['guest']['payment'])) { $this->setPaymentAddress($this->session->data['guest']['payment']['country_id'], $this->session->data['guest']['payment']['zone_id']); } elseif ($this->customer->isLogged() && $this->config->get('config_tax_customer') == 'payment') { $address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->customer->getAddressId() . "'"); $this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']); } elseif ($this->config->get('config_tax_default') == 'payment') { $this->setPaymentAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); } $this->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); }
public function updateBitlyAccessToken($access_token) { $activeSystem = $this->getActiveSystem(); $activeSystem->setBitlyAccessToken($access_token); $this->em->persist($activeSystem); $this->em->flush(); }
public function __construct() { $this->prefix = DB_PREFIX; $this->sdsdb = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $registry = new Registry(); $registry->set('db', $this->sdsdb); }
/** * User constructor. * @param Registry $registry */ public function __construct($registry) { $this->db = $registry->get('db'); $this->request = $registry->get('request'); $this->session = $registry->get('session'); if (isset($this->session->data['user_id'])) { $user_query = $this->db->query("SELECT * FROM user WHERE user_id = '" . (int) $this->session->data['user_id'] . "' AND status = '1'"); if ($user_query->num_rows) { $this->user_id = $user_query->row['user_id']; $this->username = $user_query->row['username']; /* [webme] deny order deletions by specified user_group - begin */ $this->usergroup_id = $user_query->row['user_group_id']; /* [webme] deny order deletions by specified user_group - end */ $this->db->query("\r\n\t\t\t\t\tUPDATE user \r\n\t\t\t\t\tSET ip = :ip\r\n\t\t\t\t\tWHERE user_id = :userId\r\n\t\t\t\t\t", [':ip' => $this->request->server['REMOTE_ADDR'], ':userId' => $this->session->data['user_id']], false, true); $user_group_query = $this->db->query("SELECT permission FROM user_group WHERE user_group_id = '" . (int) $user_query->row['user_group_id'] . "'"); $permissions = unserialize($user_group_query->row['permission']); if (is_array($permissions)) { foreach ($permissions as $key => $value) { $this->permission[$key] = $value; } } } else { $this->logout(); } } }
/** * Stores an Identifier Range. * * @param boolean $updateNulls True to update fields even if they are null. * * @return boolean True on success, false on failure. * * @since 1.6 */ public function store($updateNulls = false) { // Transform the params field if (isset($this->params) && is_array($this->params)) { $registry = new Registry(); $registry->loadArray($this->params); $this->params = (string) $registry; } // Get date and user $date = JFactory::getDate(); $user = JFactory::getUser(); if ($this->id) { // Existing item $this->modified_by = $user->get('username'); $this->modified = $date->toSql(); } else { // New item $this->created_by = $user->get('username'); $this->created = $date->toSql(); $this->category = strlen($this->range_begin); $this->free = $this->range_end - $this->range_begin + 1; $this->next = $this->range_begin; } return parent::store($updateNulls); }
/** * @param SymfonyStyle|null $io */ public function updateCode(SymfonyStyle $io = null) { $io->title('CampaignChain Data Update'); if (empty($this->versions)) { $io->warning('No code updater Service found, maybe you didn\'t enable a bundle?'); return; } $io->comment('The following data versions will be updated'); $migratedVersions = array_map(function (DataUpdateVersion $version) { return $version->getVersion(); }, $this->em->getRepository('CampaignChainUpdateBundle:DataUpdateVersion')->findAll()); $updated = false; foreach ($this->versions as $version => $class) { if (in_array($version, $migratedVersions)) { continue; } $io->section('Version ' . $class->getVersion()); $io->listing($class->getDescription()); $io->text('Begin data update'); $result = $class->execute($io); if ($result) { $dbVersion = new DataUpdateVersion(); $dbVersion->setVersion($version); $this->em->persist($dbVersion); $this->em->flush(); $io->text('Data update finished'); } $updated = true; } if (!$updated) { $io->success('All data is up to date.'); } else { $io->success('Every data version has been updated.'); } }
private function cleanDB() { $this->mainlogrepo->getLoggableListener()->setEnabled(false); $this->doctrine->getConnection()->executeQuery('SET foreign_key_checks = 0'); $this->doctrine->getManager()->getFilters()->disable('softdeleteable'); foreach ($this->mainlogrepo->findAll() as $result) { $this->doctrine->getManager()->remove($result); } $this->doctrine->getManager()->flush(); $fixturesClasses = array(get_class(new Comment()), get_class(new RelatedArticle()), get_class(new User()), get_class(new Article())); foreach ($fixturesClasses as $fixturesClass) { $manager = $this->doctrine->getManagerForClass($fixturesClass); $repo = $manager->getRepository($fixturesClass); foreach ($repo->findAll() as $result) { $manager->remove($result); } $manager->flush(); $manager->clear(); } //make twice to be sure ??? foreach ($fixturesClasses as $fixturesClass) { $manager = $this->doctrine->getManagerForClass($fixturesClass); $repo = $manager->getRepository($fixturesClass); foreach ($repo->findAll() as $result) { $manager->remove($result); } $manager->flush(); $manager->clear(); } $this->doctrine->getManager()->getFilters()->enable('softdeleteable'); $this->doctrine->getConnection()->executeQuery('SET foreign_key_checks = 1'); $this->mainlogrepo->getLoggableListener()->setEnabled(true); }
/** * Customer constructor. * * @param Registry $registry */ public function __construct($registry) { $this->config = $registry->get('config'); $this->db = $registry->get('db'); $this->request = $registry->get('request'); $this->session = $registry->get('session'); if (isset($this->session->data['customer_id'])) { $customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND STATUS = '1'"); if ($customer_query->num_rows) { $this->customer_id = $customer_query->row['customer_id']; $this->firstname = $customer_query->row['firstname']; $this->lastname = $customer_query->row['lastname']; $this->email = $customer_query->row['email']; $this->telephone = $customer_query->row['telephone']; $this->fax = $customer_query->row['fax']; $this->newsletter = $customer_query->row['newsletter']; $this->customer_group_id = $customer_query->row['customer_group_id']; $this->address_id = $customer_query->row['address_id']; $this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(isset($this->session->data['cart']) ? serialize($this->session->data['cart']) : '') . "', wishlist = '" . $this->db->escape(isset($this->session->data['wishlist']) ? serialize($this->session->data['wishlist']) : '') . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int) $this->customer_id . "'"); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_ip WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "'"); if (!$query->num_rows) { $this->db->query("INSERT INTO " . DB_PREFIX . "customer_ip SET customer_id = '" . (int) $this->session->data['customer_id'] . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', date_added = NOW()"); } } else { $this->logout(); } } }
public static function is_registered($index) { if (self::$_registry === null) { return false; } return self::$_registry->exists_offset($index); }
public function execute(SymfonyStyle $io = null) { $currentProfiles = $this->em->getRepository('CampaignChainLocationGoogleAnalyticsBundle:Profile')->findAll(); if (empty($currentProfiles)) { $io->text('There is no Profile entity to update'); return true; } foreach ($currentProfiles as $profile) { if (substr($profile->getProfileId(), 0, 2) != 'UA') { continue; } $profile->setPropertyId($profile->getProfileId()); $gaProfileUrl = $profile->getLocation()->getUrl(); $google_base_url = 'https:\\/\\/www.google.com\\/analytics\\/web\\/#report\\/visitors-overview\\/a' . $profile->getAccountId() . 'w\\d+p'; $pattern = '/' . $google_base_url . '(.*)/'; preg_match($pattern, $gaProfileUrl, $matches); if (!empty($matches) && count($matches) == 2) { $profile->setProfileId($matches[1]); $profile->setIdentifier($profile->getProfileId()); } $this->em->persist($profile); } $this->em->flush(); return true; }
/** * @expectedException \Zend_Acl_Role_Registry_Exception * @expectedExceptionMessage Parent Role id '26' does not exist */ public function testAddParentWrongParentId() { $roleId = 1; $parentRoleId = 2; list($role, ) = $this->initRoles($roleId, $parentRoleId); $this->model->addParent($role, 26); }
public function getBrand() { $product = $this->registry->registry('current_product'); $collection = $this->_brandFactory->create()->getCollection(); $collection->addFieldToFilter('attribute_id', $product->getManufacturer()); return $collection->getFirstItem(); }
/** * Stores a publisher. * * @param boolean $updateNulls True to update fields even if they are null. * * @return boolean True on success, false on failure. * * @since 1.6 */ public function store($updateNulls = false) { // Transform the params field if (isset($this->params) && is_array($this->params)) { $registry = new Registry(); $registry->loadArray($this->params); $this->params = (string) $registry; } // Get date and user $date = JFactory::getDate(); $user = JFactory::getUser(); if ($this->id) { // Existing item $this->modified_by = $user->get('username'); $this->modified = $date->toSql(); } else { // New item $this->created_by = $user->get('username'); $this->created = $date->toSql(); } // Question 7: from array to comma separated string if (is_array($this->question_7)) { if (count($this->question_7) > 0) { $this->question_7 = implode(',', $this->question_7); } else { $this->question_7 = ''; } } else { $this->question_7 = ''; } return parent::store($updateNulls); }
* @var Registry */ protected $_registry; /** * Cria uma variável para a view. Não pode ser sobrescrito * @param string $var nome da variável * @param mixed $value valor da variável * @return void
/** * Load and register a model * * @static * @access public * @param Core\Registry $registry DPI container * @param string $name Model name * @return mixed */ public static function loadModel(Registry $registry, $name) { if (!isset($registry->{$name})) { $class = '\\Model\\' . ucfirst($name); $registry->{$name} = new $class($registry); } return $registry->shared($name); }
public function __call($method, $args) { if (!$this->registry->has('extensions')) { return null; } array_unshift($args, $this); $return = call_user_func_array(array($this->extensions, $method), $args); return $return; }
/** * Weight constructor. * * @param Registry $registry */ public function __construct($registry) { $this->db = $registry->get('db'); $this->config = $registry->get('config'); $weight_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int) $this->config->get('config_language_id') . "'"); foreach ($weight_class_query->rows as $result) { $this->weights[$result['weight_class_id']] = array('weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']); } }
/** * Length constructor. * * @param Registry $registry */ public function __construct($registry) { $this->db = $registry->get('db'); $this->config = $registry->get('config'); $length_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class mc LEFT JOIN " . DB_PREFIX . "length_class_description mcd ON (mc.length_class_id = mcd.length_class_id) WHERE mcd.language_id = '" . (int) $this->config->get('config_language_id') . "'"); foreach ($length_class_query->rows as $result) { $this->lengths[$result['length_class_id']] = array('length_class_id' => $result['length_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']); } }
public function testConstructor() { $testValues = $this->exampleValues(); $data = array('test1' => $testValues); $reg = new Registry(); $this->assertNull($reg->get('test1', 'a'), 'empty registry should return null'); $reg = new Registry($data); $this->assertEquals('A', $reg->get('test1', 'a')); }
/** * @param $id */ public function removeOperation($id) { try { $operation = $this->getNewsItemByOperation($id); $this->em->remove($operation); $this->em->flush(); } catch (\Exception $e) { } }
/** * {@inheritdoc} */ public function iterate(IterateEvent $event) { foreach ($this->doctrine->getManagers() as $name => $manager) { if (!$manager->isOpen()) { throw new \RuntimeException(sprintf('The doctrine manager: %s is closed', $name)); } $manager->getUnitOfWork()->clear(); } }
/** * Stores an identifier. * * @param boolean $updateNulls True to update fields even if they are null. * * @return boolean True on success, false on failure. * * @since 1.6 */ public function store($updateNulls = false) { // Transform the params field if (isset($this->params) && is_array($this->params)) { $registry = new Registry(); $registry->loadArray($this->params); $this->params = (string) $registry; } return parent::store($updateNulls); }
public function testDelElement() { $reg = new Registry(); $element = array("numbers" => array(1, 2, 3, 4, 5), "letters" => array("a", "b", "c", "...")); $reg->add($element); $count = $reg->elementCount(); $this->assertEqual(1, $count); $reg->delete($element); $count = $reg->elementCount(); $this->assertEqual(0, $count); }
/** * @param $name * @param array $params * @throws \Jironett\Registers\DuplicateKeyException */ public function addRegistry($name, $params = []) { if (array_key_exists($name, $this->registers)) { throw new DuplicateKeyException("The registry with name " . $name . " already exists"); } $registry = new Registry(); $dataType = isset($params['dataType']) ? $params['dataType'] : null; $class = isset($params['class']) ? $params['class'] : null; $registry->setDataType($dataType, $class); $this->registers[$name] = $registry; }
/** * @param string $operationId * @return string * @throws \Exception */ public function execute($operationId) { /** @var NewsItem $newsItem */ $newsItem = $this->em->getRepository('CampaignChainOperationLinkedInBundle:NewsItem')->findOneByOperation($operationId); if (!$newsItem) { throw new \Exception('No news item found for an operation with ID: ' . $operationId); } //have images? $images = $this->em->getRepository('CampaignChainHookImageBundle:Image')->getImagesForOperation($newsItem->getOperation()); // if the message does not contain a url, we need to skip the content block if (is_null($newsItem->getLinkUrl())) { // LinkedIn accepts an image link only if we also provided a submitted URL. if ($images) { throw new \Exception('To include an image, you must also provide a URL in the text message.'); return self::STATUS_WARNING; } $content = ['comment' => $newsItem->getMessage(), 'visibility' => ['code' => 'anyone']]; } else { /* * process urls and add tracking * important: both the urls in the message and submitted url field must be identical */ $newsItem->setLinkUrl($this->ctaService->processCTAs($newsItem->getLinkUrl(), $newsItem->getOperation())->getContent()); $newsItem->setMessage($this->ctaService->processCTAs($newsItem->getMessage(), $newsItem->getOperation())->getContent()); $content = ['comment' => $newsItem->getMessage(), 'content' => ['title' => $newsItem->getLinkTitle(), 'description' => $newsItem->getLinkDescription(), 'submitted-url' => $newsItem->getLinkUrl()], 'visibility' => ['code' => 'anyone']]; if ($images) { //Linkedin can handle only 1 image $content['content']['submitted-image-url'] = $this->cacheManager->getBrowserPath($images[0]->getPath(), "campaignchain_linkedin_news_item"); } } $activity = $newsItem->getOperation()->getActivity(); $locationModuleIdentifier = $activity->getLocation()->getLocationModule()->getIdentifier(); $isCompanyPageShare = 'campaignchain-linkedin-page' == $locationModuleIdentifier; $connection = $this->client->getConnectionByActivity($activity); if ($isCompanyPageShare) { $response = $connection->shareOnCompanyPage($activity, $content); } else { $response = $connection->shareOnUserPage($content); } $newsItem->setUrl($response['updateUrl']); $newsItem->setUpdateKey($response['updateKey']); // Set Operation to closed. $newsItem->getOperation()->setStatus(Action::STATUS_CLOSED); $location = $newsItem->getOperation()->getLocations()[0]; $location->setIdentifier($response['updateKey']); $location->setUrl($response['updateUrl']); $location->setName($newsItem->getOperation()->getName()); $location->setStatus(Medium::STATUS_ACTIVE); // Schedule data collection for report $this->reportShareNewsItem->schedule($newsItem->getOperation()); $this->em->flush(); $this->message = 'The message "' . $newsItem->getMessage() . '" with the ID "' . $newsItem->getUpdateKey() . '" has been posted on LinkedIn. See it on LinkedIn: <a href="' . $newsItem->getUrl() . '">' . $newsItem->getUrl() . '</a>'; return self::STATUS_OK; }
public function database($driver, $hostname, $username, $password, $database, $prefix = null, $charset = 'UTF8') { $file = DIR_ROOT . "'/system/database/{$driver}.php"; $class = 'Database' . preg_replace('/[^a-zA-Z0-9]/', '', $driver); if (file_exists($file)) { include $file; $this->registry->set(str_replace('/', '_', $driver), new $class()); } else { trigger_error('Error: Could not load database ' . $driver . '!'); exit; } }
/** * Registering Functions */ function register_project($include_id) { if (Item::delete_holder_by_include_id($include_id)) { if (Item::register_holder("project", "Project", $include_id) == false) { return false; } } else { return false; } if (Folder::delete_type_by_include_id($include_id)) { if (Folder::register_type("project_folder", "ProjectFolder", $include_id) == false) { return false; } if (Folder::register_type("project_status_folder", "ProjectStatusFolder", $include_id) == false) { return false; } } else { return false; } if (ValueVar::delete_by_include_id($include_id)) { if (ValueVar::register_type("project", "ProjectValueVar", false, $include_id) == false) { return false; } } else { return false; } if (!Registry::is_value("project_user_default_quota")) { $registry = new Registry(null); $registry->create("project_user_default_quota", $include_id, "1073741824"); } if (!Registry::is_value("project_user_default_permission")) { $registry = new Registry(null); $registry->create("project_user_default_permission", $include_id, "15"); } if (!Registry::is_value("project_leader_default_permission")) { $registry = new Registry(null); $registry->create("project_leader_default_permission", $include_id, "51"); } if (!Registry::is_value("project_quality_manager_default_permission")) { $registry = new Registry(null); $registry->create("project_quality_manager_default_permission", $include_id, "1"); } if (!Registry::is_value("project_group_default_permission")) { $registry = new Registry(null); $registry->create("project_group_default_permission", $include_id, "1"); } if (!Registry::is_value("project_organisation_unit_default_permission")) { $registry = new Registry(null); $registry->create("project_organisation_unit_default_permission", $include_id, "1"); } return true; }
/** * Checks whether the Activities belonging to a Campaign and marked with * mustValidate are executable. * * @param Campaign $campaign * @return array */ public function hasExecutableActivities(Campaign $campaign) { $activities = $this->em->getRepository('CampaignChainCoreBundle:Activity')->findBy(array('campaign' => $campaign, 'mustValidate' => true)); if (count($activities)) { foreach ($activities as $activity) { $isExecutable = $this->activityService->isExecutableByCampaign($activity); if (!$isExecutable['status']) { return $isExecutable; } } } return array('status' => true); }
public function __construct() { /* * Sets $loginStatus result of the authorization check. **/ $this->loginStatus = LoginStatus::getLoginStatus(); $this->registry = Registry::getInstance(); $request = $this->registry->getObject('request'); /* * Contains $_POST * */ $this->post_data = $request->getPostData(); }
public function __construct() { $this->prefix = DB_PREFIX; if (DB_DRIVER == 'mysql') { $file = DIR_DATABASE . 'mysqli.php'; require_once $file; $this->sdsdb = new DBMySQLi(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); } else { $this->sdsdb = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); } $registry = new Registry(); $registry->set('db', $this->sdsdb); }