public function setUp() { $this->container = m::mock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $service = m::mock('\\stdClass'); $service->shouldReceive('consume')->with('foobar')->once(); $this->container->shouldReceive('get')->with('consumer.bar')->once()->andReturn($service); }
public function load($resource, $type = null) { $typCfg = explode('_', $type); $res = explode('@', $resource); if (isset($this->loaded[$res[0]])) { throw new \RuntimeException('Do not add the "nyrocms" with "' . $res[0] . '" loader twice'); } $rootContent = $this->container->get('nyrocms_db')->getContentRepository()->findOneBy(array('level' => 0, 'handler' => $res[0])); if (!$rootContent) { throw new \RuntimeException('No root content found with handler "' . $res[0] . '"'); } /* @var $rootContent \NyroDev\NyroCmsBundle\Model\Content */ $routes = new RouteCollection(); $locale = $this->container->get('nyrocms')->getDefaultLocale($rootContent); $locales = $this->container->get('nyrocms')->getLocales($rootContent, true); $routes->add($res[0] . '_homepage_noLocale', new Route('/' . (in_array('forceLang', $typCfg, true) ? $locale . '/' : ''), array('_controller' => $res[1] . ':index', '_locale' => $locale, '_config' => $res[0]), array(), array(), $rootContent->getHost())); if ($rootContent->getXmlSitemap()) { $routes->add($res[0] . '_sitemap_xml_index', new Route('/sitemap.{_format}', array('_controller' => $res[1] . ':sitemapIndexXml', '_config' => $res[0]), array('_format' => 'xml'), array(), $rootContent->getHost())); $routes->add($res[0] . '_sitemapXml', new Route('/{_locale}/sitemap.{_format}', array('_controller' => $res[1] . ':sitemapXml', '_locale' => $locale, '_config' => $res[0]), array('_locale' => $locales, '_format' => 'xml'), array(), $rootContent->getHost())); } $routes->add($res[0] . '_homepage', new Route('/{_locale}/', array('_controller' => $res[1] . ':index', '_locale' => $locale, '_config' => $res[0]), array('_locale' => $locales), array(), $rootContent->getHost())); $routes->add($res[0] . '_search', new Route('/{_locale}/search', array('_controller' => $res[1] . ':search', '_locale' => $locale, '_config' => $res[0]), array('_locale' => $locales), array(), $rootContent->getHost())); $routes->add($res[0] . '_content_spec_handler', new Route('/{_locale}/{url}/{id}/{title}/handler/{handler}', array('_controller' => $res[1] . ':contentSpec', '_locale' => $locale, '_config' => $res[0]), array('_locale' => $locales, 'url' => '.+', 'id' => '\\d+', 'handler' => '.+'), array(), $rootContent->getHost())); $routes->add($res[0] . '_content_spec', new Route('/{_locale}/{url}/{id}/{title}', array('_controller' => $res[1] . ':contentSpec', '_locale' => $locale, '_config' => $res[0]), array('_locale' => $locales, 'url' => '.+', 'id' => '\\d+'), array(), $rootContent->getHost())); $routes->add($res[0] . '_content_handler', new Route('/{_locale}/{url}/handler/{handler}', array('_controller' => $res[1] . ':content', '_locale' => $locale, '_config' => $res[0]), array('_locale' => $locales, 'url' => '.+', 'handler' => '.+'), array(), $rootContent->getHost())); $routes->add($res[0] . '_content', new Route('/{_locale}/{url}', array('_controller' => $res[1] . ':content', '_locale' => $locale, '_config' => $res[0]), array('_locale' => $locales, 'url' => '.+'), array(), $rootContent->getHost())); $this->loaded[$res[0]] = true; return $routes; }
/** * Copies the SOAP body part from one SOAP container to another. * * @param ContainerInterface $fromContainer * @param ContainerInterface $toContainer */ public function copyBody(ContainerInterface $fromContainer, ContainerInterface $toContainer) { $fromSoap = $fromContainer->getSoapMessage(); $toSoap = $toContainer->getSoapMessage(); $toSoap->copyBodyFromMessage($fromSoap); $toContainer->setSoapMessage($toSoap); }
public function load(ObjectManager $manager) { $data = (include __DIR__ . '/../fixtures/user/users.php'); $encoder = $this->container->get('security.password_encoder'); $userManager = $this->container->get('medievistes.user_manager'); $connection = $manager->getConnection(); if ($connection->getDatabasePlatform()->getName() === 'mysql') { $connection->exec("ALTER TABLE {$manager->getClassMetadata(User::class)->getTableName()} AUTO_INCREMENT = 1;"); } foreach ($data as $userData) { $class = $userManager->getUserClass($userData['type']); $user = (new $class())->setId((int) $userData['id'])->setUsername($userData['username'])->setEmail($userData['email'])->setPlainPassword($userData['plain_password'])->setSalt(md5(uniqid(null, true)))->enable((bool) $userData['is_active'])->setCreatedAt(new \DateTime($userData['created_at']))->setUpdatedAt(new \DateTime($userData['updated_at'])); if (!empty($userData['activation_link_id'])) { $user->setActivationLink($this->getReference("activation-link-{$userData['activation_link_id']}")); } foreach ($userData['roles'] as $role) { $user->addRole($role); } foreach ($userData['troops'] as $troop) { $association = (new Association())->setUser($user)->setTroop($this->getReference("troop-{$troop['troop_id']}"))->setRole($this->getReference("troop-role-{$troop['role_id']}")); $user->addTroopAssociation($association); $manager->persist($association); } $password = $encoder->encodePassword($user, $userData['plain_password']); $user->setPassword($password); $manager->persist($user); $manager->flush(); $this->addReference("user-{$user->getId()}", $user); } $manager->clear($class); $manager->clear(Association::class); }
/** * Perfom loading of services from a configuration into a container * @param Packfire\FuelBlade\ContainerInterface $container The container to be loaded with the services * @param array The collection of services to be loaded * @since 1.1.1 */ public static function load(ContainerInterface $container, array $services) { foreach ($services as $key => $service) { if (isset($service['class'])) { $package = $service['class']; $params = isset($service['parameters']) ? $service['parameters'] : null; $container[$key] = $container->share(function ($c) use($package, $params) { if (class_exists($package)) { $reflect = new \ReflectionClass($package); if ($params) { foreach ($params as &$param) { $match = array(); if (is_string($param) && preg_match('/^@{1}([^@].+?)$/', $param, $match)) { if (isset($c[$match[1]])) { $param = $c[$match[1]]; } } } $instance = $reflect->newInstanceArgs($params); } else { $instance = $reflect->newInstance(); } if ($instance instanceof ConsumerInterface) { return $instance($c); } return $instance; } }); } else { throw new ServiceLoadingException($key); } } }
function main($id, $mode) { global $phpbb_container, $user, $template, $config, $request; $this->phpbb_container = $phpbb_container; $this->user = $user; $this->template = $template; $this->config = $config; $this->request = $request; $this->log = $this->phpbb_container->get('log'); $this->tpl_name = 'acp_codebox_plus'; $this->page_title = $this->user->lang('CODEBOX_PLUS_TITLE'); add_form_key('o0johntam0o/acp_codebox_plus'); if ($this->request->is_set_post('submit')) { if (!check_form_key('o0johntam0o/acp_codebox_plus')) { trigger_error('FORM_INVALID'); } $this->config->set('codebox_plus_syntax_highlighting', $request->variable('codebox_plus_syntax_highlighting', 0)); $this->config->set('codebox_plus_expanded', $request->variable('codebox_plus_expanded', 0)); $this->config->set('codebox_plus_download', $request->variable('codebox_plus_download', 0)); $this->config->set('codebox_plus_login_required', $request->variable('codebox_plus_login_required', 0)); $this->config->set('codebox_plus_prevent_bots', $request->variable('codebox_plus_prevent_bots', 0)); $this->config->set('codebox_plus_captcha', $request->variable('codebox_plus_captcha', 0)); $this->config->set('codebox_plus_max_attempt', $request->variable('codebox_plus_max_attempt', 0)); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'CODEBOX_PLUS_LOG_MSG'); trigger_error($this->user->lang('CODEBOX_PLUS_SAVED') . adm_back_link($this->u_action)); } $this->template->assign_vars(array('U_ACTION' => $this->u_action, 'S_CODEBOX_PLUS_VERSION' => isset($this->config['codebox_plus_version']) ? $this->config['codebox_plus_version'] : 0, 'S_CODEBOX_PLUS_SYNTAX_HIGHLIGHTING' => isset($this->config['codebox_plus_syntax_highlighting']) ? $this->config['codebox_plus_syntax_highlighting'] : 0, 'S_CODEBOX_PLUS_EXPANDED' => isset($this->config['codebox_plus_expanded']) ? $this->config['codebox_plus_expanded'] : 0, 'S_CODEBOX_PLUS_DOWNLOAD' => isset($this->config['codebox_plus_download']) ? $this->config['codebox_plus_download'] : 0, 'S_CODEBOX_PLUS_LOGIN_REQUIRED' => isset($this->config['codebox_plus_login_required']) ? $this->config['codebox_plus_login_required'] : 0, 'S_CODEBOX_PLUS_PREVENT_BOTS' => isset($this->config['codebox_plus_prevent_bots']) ? $this->config['codebox_plus_prevent_bots'] : 0, 'S_CODEBOX_PLUS_CAPTCHA' => isset($this->config['codebox_plus_captcha']) ? $this->config['codebox_plus_captcha'] : 0, 'S_CODEBOX_PLUS_MAX_ATTEMPT' => isset($this->config['codebox_plus_max_attempt']) ? $this->config['codebox_plus_max_attempt'] : 0)); }
public function setUp() { $this->pwfc = $this->getMockBuilder('Symfony\\Cmf\\Bundle\\CoreBundle\\PublishWorkflow\\PublishWorkflowChecker')->disableOriginalConstructor()->getMock(); $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $this->container->expects($this->any())->method('get')->with('cmf_core.publish_workflow.checker')->will($this->returnValue($this->pwfc)); $this->voter = new MenuContentVoter($this->container); $this->token = new AnonymousToken('', ''); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->container = (include './config/container.php'); $this->config = $this->container->get('config')['dataStore']; $this->dbTableName = $this->config['testDbTable']['tableName']; $this->adapter = $this->container->get('db'); $this->object = $this->container->get('testDbTable'); }
/** * set current parent template from matching theme * @return type */ public function getCurrentLayoutTemplate() { $theme_schema = $this->builder->getCurrentThemeSchema(); if (array_key_exists('theme', $theme_schema)) { $currentThemePath = $this->container->get('layout.layout_theme.helper')->getThemeBundle() . '::themes/' . $theme_schema['theme'] . '/'; return $currentThemePath . $theme_schema['template']; } return ''; }
/** * If you want to make a failure handler with injected parameters (like provider key),<br /> * create a service named "security.authentication.failure_handler.your_firewall_name.ajax_form_login"<br /> * where "your_firewall_name" is like "secured_area" in Symfony Sandbox example. * * @param ContainerInterface $container * @param int $id * @param array $config * * @return string */ protected function createAuthenticationFailureHandler($container, $id, $config) { if (isset($config['failure_handler'])) { return $config['failure_handler']; } $id = 'security.authentication.failure_handler.' . $id . '.' . str_replace('-', '_', $this->getKey()); $failureHandler = $container->setDefinition($id, new DefinitionDecorator('divi.ajax_login.ajax_athentication_failure_handler')); $failureHandler->replaceArgument(2, array_intersect_key($config, $this->defaultFailureHandlerOptions)); return $id; }
public function load(ObjectManager $manager) { # news post $news = new News(); $news->setUser($this->getReference('c4d3r-user')); $news->setContent("Welcome to your first website"); $news->setWebsite($this->container->getParameter("maxim_cms.website")); $manager->persist($news); $manager->flush(); }
public function buildForm(FormBuilderInterface $builder, array $options) { if (count($options['contacts']) > 1) { $choices = array(); foreach ($options['contacts'] as $k => $v) { $choices[$k] = $this->container->get('nyrodev')->trans($v['name']); } $builder->add('dest', ChoiceType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.dest'), 'placeholder' => '', 'choices' => $choices, 'required' => true)); } $builder->add('lastname', TextType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.lastname'), 'constraints' => array(new Constraints\NotBlank())))->add('firstname', TextType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.firstname'), 'constraints' => array(new Constraints\NotBlank())))->add('company', TextType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.company'), 'required' => false))->add('phone', TextType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.phone'), 'required' => false))->add('email', EmailType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.email'), 'constraints' => array(new Constraints\NotBlank(), new Constraints\Email())))->add('message', TextareaType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.message'), 'constraints' => array(new Constraints\NotBlank())))->add('submit', SubmitType::class, array('label' => $this->container->get('nyrodev')->trans('nyrocms.handler.contact.send'))); }
/** * @param $property * @return mixed|null * @throws Exception */ public function __get($property) { if (!is_object($this->dependencyInjector) || !$this->dependencyInjector instanceof ContainerInterface) { throw new Exception('A dependency injection object is required'); } if ($this->dependencyInjector->has($property)) { $service = $this->dependencyInjector->get($property); $this->{$property} = $service; return $service; } return null; }
/** * Returns the rendered breadcrumbs * * @return string */ public function renderBreadcrumbs() { $router = $this->container->get('router'); $request = $this->container->get('request'); $route = $request->get('_route'); try { $params = $router->match(rawurldecode($request->getPathInfo())); } catch (MethodNotAllowedException $e) { return; } return $this->container->get("templating")->render("XiBreadcrumbsBundle:Default:breadcrumbs.html.twig", array('breadcrumbs' => $this->service->getBreadcrumbs((string) $route, $params))); }
/** * {@inheritdoc} */ protected function setUp() { $kernel = static::createKernel(); $kernel->boot(); $this->_em = self::createTestEntityManager(); $this->_container = $kernel->getContainer(); $this->_container->set('doctrine.orm.entity_manager', $this->_em); if (!isset($GLOBALS['TEST_CHARGED'])) { $this->_createSchemas(); $this->_insertData(); $GLOBALS['TEST_CHARGED'] = true; } }
/** * {@inheritdoc} */ protected function setUp() { $kernel = static::createKernel(); $kernel->boot(); $this->_container = $kernel->getContainer(); $this->_em = $this->_container->get('doctrine.orm.entity_manager'); AnnotationRegistry::registerFile($kernel->getRootDir() . "/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); if (!isset($GLOBALS['TEST_CHARGED'])) { $this->_createSchemas(); $this->_insertData(); $GLOBALS['TEST_CHARGED'] = true; } }
public final function __call($func, $args) { if ($this->_medoo && method_exists($this->_medoo, $func)) { $r = new RunTimeUtil(); $ret = call_user_func_array(array($this->_medoo, $func), $args); $time = $r->spent(); $logs = $this->_medoo->log(); Log::Info('db', "#method:{$func}#sql:" . end($logs) . "#ret:" . json_encode($ret) . "#runtime:{$time}"); return $ret; } else { Log::Error('db', "#method{$func}#args" . json_encode($args) . "#message:no funcs or client is null"); return null; } }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $this->container = $this->getContainer(); $output->writeln("<comment>Updating...</comment>\n"); $em = $this->container->get('doctrine.orm.entity_manager'); $loader = new ContainerAwareLoader($this->container); $loader->loadFromDirectory($input->getOption('fixtures')); $purger = new ORMPurger($em); $executor = new ORMExecutor($em, $purger); $executor->setLogger(function ($message) use($output) { $output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message)); }); $executor->execute($loader->getFixtures(), true); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->container = (include './config/container.php'); $this->adapter = $this->container->get('db'); $this->tableName = 'test_create_table'; $this->object = new TableManagerMysql($this->adapter, $this->config); if ($this->object->hasTable($this->tableName)) { $this->object->deleteTable($this->tableName); } if ($this->object->hasTable('table_master')) { $this->object->deleteTable('table_master'); } if ($this->object->hasTable('table_slave')) { $this->object->deleteTable('table_slave'); } }
public function load(ObjectManager $manager) { $data = (include __DIR__ . '/../fixtures/troop/troops.php'); foreach ($data as $troopData) { $troop = (new Troop())->setId((int) $troopData['id'])->setName($troopData['name'])->setSlug($this->container->get('medievistes.slugger')->slugify($troopData['name']))->setDescription($troopData['description'])->setAddress($this->getReference("address-{$troopData['address_id']}")); if (isset($troopData['coat-of-arms'])) { $troop->setCoatOfArms((new CoatOfArms())->setName($troopData['name'])->setPath($troopData['coat-of-arms'])); } foreach ($troopData['centuries'] as $century) { $troop->addCentury($this->getReference("century-{$century}")); } $manager->persist($troop); $this->addReference("troop-{$troop->getId()}", $troop); } $manager->flush(); $manager->clear(Troop::class); }
public function resolveFileCollision($fileName, $clientOriginalName, $attempt = 1) { if ($this->hasNamer()) { $firstNamer = current($this->config['namer']); $newFileName = call_user_func(array($this->container->get($firstNamer['service']), 'resolveCollision'), $fileName, $attempt); //return dirName and path $resolveData = $this->useDirectoryNamer($newFileName, $clientOriginalName); $resolveData[] = $newFileName; return $resolveData; } throw new \Exception('Filename resolving collision not supported (namer is empty).Duplicate filename ' . $fileName); }
function main($id, $mode) { global $user, $template, $cache, $config, $phpbb_root_path, $phpEx, $phpbb_container, $request; $this->config = $config; $this->phpbb_container = $phpbb_container; $this->config_text = $this->phpbb_container->get('config_text'); $this->log = $this->phpbb_container->get('log'); $this->request = $request; $this->template = $template; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $phpEx; $this->user->add_lang_ext('davidiq/reimg', 'reimg_acp'); $this->tpl_name = 'reimg'; $this->page_title = 'ACP_REIMG_SETTINGS'; $form_name = 'acp_reimg'; add_form_key($form_name); $reimg_swap_portrait = $this->request->variable('reimg_swap_portrait', (bool) $this->config['reimg_swap_portrait']); $reimg_resize_sig_img = $this->request->variable('reimg_resize_sig_img', (bool) $this->config['reimg_resize_sig_img']); $reimg_link = $this->request->variable('reimg_link', $this->config['reimg_link']); $reimg_zoom = $this->request->variable('reimg_zoom', $this->config['reimg_zoom']); $reimg_attachments = $this->request->variable('reimg_attachments', (bool) $this->config['reimg_attachments']); $reimg_for_all = $this->request->variable('reimg_for_all', (bool) $this->config['reimg_for_all']); if ($this->request->is_set_post('submit')) { if (!check_form_key($form_name)) { trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); } //Update configuration now $this->config->set('reimg_swap_portrait', $reimg_swap_portrait); $this->config->set('reimg_resize_sig_img', $reimg_resize_sig_img); $this->config->set('reimg_link', $reimg_link); $this->config->set('reimg_zoom', $reimg_zoom); $this->config->set('reimg_attachments', $reimg_attachments); $this->config->set('reimg_for_all', $reimg_for_all); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_REIMG_UPDATED'); trigger_error($user->lang['REIMG_UPDATED'] . adm_back_link($this->u_action)); } $template->assign_vars(array('S_REIMG_SWAP_PORTRAIT' => $reimg_swap_portrait, 'S_REIMG_RESIZE_SIG_IMG' => $reimg_resize_sig_img, 'S_REIMG_LINK' => $this->select_reimg_link_method($reimg_link), 'S_REIMG_ZOOM' => $this->select_reimg_zoom_method($reimg_zoom), 'S_REIMG_ATTACHMENTS' => $reimg_attachments, 'S_REIMG_FOR_ALL' => $reimg_for_all, 'U_ACTION' => $this->u_action)); }
public function load($routingResource, $type = null) { $routes = parent::load($routingResource, $type); if (!$this->use) { return $routes; } /* @var $request Request */ $request = $this->container->get("request"); foreach ($this->am->getNames() as $name) { $asset = $this->am->get($name); $formula = $this->am->getFormula($name); $debug = isset($formula[2]['debug']) ? $formula[2]['debug'] : $this->am->isDebug(); $combine = isset($formula[2]['combine']) ? $formula[2]['combine'] : !$debug; if (!$combine && $debug) { $i = 0; foreach ($asset as $leaf) { $routeName = "_assetic_" . $name . "_" . $i++; $route = $routes->get($routeName); if ($route && ($pos = strpos($leaf->getSourcePath(), '.')) !== false && in_array(substr($leaf->getSourcePath(), $pos), ['.js', '.css', '.scss'])) { if ($this->https == self::HTTPS_MODE_DETECT && $request->isSecure() || $this->https == self::HTTPS_MODE_FULL) { $route->setHost($this->host . ($this->portHttps ? ":" . $this->portHttps : "")); if ($this->portHttps) { $route->setSchemes("https"); } $route->setPath($leaf->getSourceRoot() . "/" . $leaf->getSourcePath() . "?" . $route->getPath()); } else { $route->setHost($this->host . ":" . ($this->port ? ":" . $this->port : "")); if ($this->port) { $route->setSchemes("http"); } $route->setPath($leaf->getSourceRoot() . "/" . $leaf->getSourcePath() . "?" . $route->getPath()); } } } } } return $routes; }
/** * {@inheritdoc} */ protected function setUp() { $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $this->command = new FixMediaContextCommand(); $this->command->setContainer($this->container); $this->application = new Application(); $this->application->add($this->command); $this->tester = new CommandTester($this->application->find('sonata:media:fix-media-context')); $this->pool = $pool = $this->getMockBuilder('Sonata\\MediaBundle\\Provider\\Pool')->disableOriginalConstructor()->getMock(); $this->contextManger = $contextManger = $this->getMock('Sonata\\ClassificationBundle\\Model\\ContextManagerInterface'); $this->categoryManger = $categoryManger = $this->getMockBuilder('Sonata\\ClassificationBundle\\Entity\\CategoryManager')->disableOriginalConstructor()->getMock(); $this->container->expects($this->any())->method('get')->will($this->returnCallback(function ($id) use($pool, $contextManger, $categoryManger) { switch ($id) { case 'sonata.media.pool': return $pool; case 'sonata.classification.manager.context': return $contextManger; case 'sonata.classification.manager.category': return $categoryManger; } return; })); }
/** * @throws ExecutionException */ private function registerAliases() { foreach ($this->serviceAliases as $alias => $concrete) { $ex = null; try { $this->container->alias($alias, $concrete); } catch (Error $ex) { } catch (Exception $ex) { } if ($ex !== null) { throw new ExecutionException("Alias [{$alias}] could not have be registered.", $ex); } } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->container = (include './config/container.php'); $this->object = new DataStore\Factory\DbTableAbstractFactory(); $this->adapter = $this->container->get('db'); }
protected function saveError(ContainerInterface $container, ValidatorReflectionInterface $validator, $name, $index) { $error = $container->getMessageProvider()->get($validator->type(), $validator->params()); $container->getReport()->addError($name, $error, $index); }
public function advanced_profile_system($event) { $member = $event['member']; $user_id = (int) $member['user_id']; // Get user_id of user we are viewing $username = $member['username']; $user_extra_rank_data = array('title' => null, 'img' => null, 'img_src' => null); $ranks_sql = 'SELECT * FROM ' . RANKS_TABLE . ' WHERE rank_special != 1'; $normal_ranks = $this->db->sql_query($ranks_sql); $spec_sql = 'SELECT rank_special FROM ' . RANKS_TABLE . ' WHERE rank_id = ' . $member['user_rank']; $special = $this->db->sql_query($spec_sql); if ($special !== 1) { if ($member['user_posts'] !== false) { if (!empty($normal_ranks)) { foreach ($normal_ranks as $rank) { if ($member['user_posts'] >= $rank['rank_min']) { $user_extra_rank_data['title'] = $rank['rank_title']; $user_extra_rank_data['img_src'] = !empty($rank['rank_image']) ? $this->phpbb_root_path . $this->config['ranks_path'] . '/' . $rank['rank_image'] : ''; $user_extra_rank_data['img'] = !empty($rank['rank_image']) ? '<img src="' . $user_extra_rank_data['img_src'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : ''; break; } } } } } $this->template->assign_vars(array('EXTRA_RANK_TITLE' => $user_extra_rank_data['title'], 'EXTRA_RANK_IMG' => $user_extra_rank_data['img'])); /**************** * PROFILE VIEWS * ****************/ // Make sure we have a session Make sure user is not a bot. Do not increase view count if viewing own profile. if (isset($this->user->data['session_page']) && !$this->user->data['is_bot'] && $this->user->data['user_id'] != $user_id) { $incr_profile_views = 'UPDATE ' . USERS_TABLE . ' SET user_profile_views = user_profile_views + 1 WHERE user_id = ' . $user_id; $this->db->sql_query($incr_profile_views); } /**************** * ACTIVITY FEED * ****************/ $activity_feed_ary = array('SELECT' => 'p.*, t.*, u.username, u.user_colour', 'FROM' => array(POSTS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = p.poster_id'), array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'p.topic_id = t.topic_id')), 'WHERE' => $this->db->sql_in_set('t.forum_id', array_keys($this->auth->acl_getf('f_read', true))) . ' AND t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_visibility = 1 AND p.poster_id = ' . $user_id, 'ORDER_BY' => 'p.post_time DESC'); $activity_feed = $this->db->sql_build_query('SELECT', $activity_feed_ary); $activity_feed_result = $this->db->sql_query_limit($activity_feed, 5); // Only get last five posts while ($af_row = $this->db->sql_fetchrow($activity_feed_result)) { $topic_id = $af_row['topic_id']; $post_id = $af_row['post_id']; $post_date = $this->user->format_date($af_row['post_time']); $post_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}", 't=' . $topic_id . '&p=' . $post_id) . '#p' . $post_id; // Parse the posts $af_row['bbcode_options'] = ($af_row['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) + ($af_row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) + ($af_row['enable_magic_url'] ? OPTION_FLAG_LINKS : 0); $text = generate_text_for_display($af_row['post_text'], $af_row['bbcode_uid'], $af_row['bbcode_bitfield'], $af_row['bbcode_options']); // Set a max length for the post to display $cutoff = ' …'; $text = strlen($text) > 200 ? mb_substr($text, 0, 200) . $cutoff : $text; // See if user is able to view posts.. $this->template->assign_block_vars('af', array('SUBJECT' => $af_row['post_subject'], 'TEXT' => $text, 'TIME' => $post_date, 'URL' => $post_url)); } $this->db->sql_freeresult($activity_feed_result); // Master gave Dobby a sock, now Dobby is free! /*************** * TOTAL TOPICS * ***************/ $tt = 'SELECT COUNT(topic_poster) AS topic_author_count FROM ' . TOPICS_TABLE . ' WHERE topic_poster = ' . $user_id; $total_topics_result = $this->db->sql_query($tt); $total_topics = (int) $this->db->sql_fetchfield('topic_author_count'); $this->db->sql_freeresult($total_topics_result); // Master gave Dobby a sock, now Dobby is free! /*************** * FRIENDS LIST * ***************/ $sql_friend = array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . $user_id . ' AND z.friend = 1 AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC'); $sql_friend_list = $this->db->sql_build_query('SELECT_DISTINCT', $sql_friend); $friend_result = $this->db->sql_query($sql_friend_list); while ($friend_row = $this->db->sql_fetchrow($friend_result)) { $img = phpbb_get_user_avatar($friend_row); // Use phpBB's Built in Avatar creator, for all types $has_avatar = false; if ($img == '') { $has_avatar = false; // This friend has no avatar.. } else { $has_avatar = true; // This friend has an avatar $offset = 25; //Start off the img src $end = strpos($img, '"', $offset); // Find end of img src $length = $end - $offset; // Determine src length $friend_avatar = substr($img, $offset, $length); // Grab just the src } $this->template->assign_block_vars('friends', array('USERNAME' => get_username_string('full', $friend_row['user_id'], $friend_row['username'], $friend_row['user_colour']), 'AVATAR' => $friend_avatar, 'HAS_AVATAR' => $has_avatar)); } $this->db->sql_freeresult($friend_result); // Master gave Dobby a sock, now Dobby is free! /******* * WALL * *******/ // INSERTING A WALL POST add_form_key('postwall'); $sendwall = isset($_POST['sendwall']) ? true : false; if ($sendwall) { if (check_form_key('postwall') && $this->auth->acl_get('u_wall_post')) { $msg_text = $this->request->variable('msg_text', '', true); $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage $allow_bbcode = $allow_urls = $allow_smilies = true; generate_text_for_storage($msg_text, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $msg_time = time(); $wall_ary = array('user_id' => $user_id, 'poster_id' => $this->user->data['user_id'], 'msg' => $msg_text, 'msg_time' => (int) $msg_time, 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'bbcode_options' => $options); $insertwall = 'INSERT INTO ' . $this->wall_table . ' ' . $this->db->sql_build_array('INSERT', $wall_ary); $this->db->sql_query($insertwall); if ($user_id != $this->user->data['user_id']) { $msg_id = (int) $this->db->sql_nextid(); $poster_name = get_username_string('no_profile', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']); $notification_msg = $msg_text; strip_bbcode($notification_msg, $uid); $wall_notification_data = array('msg_id' => $msg_id, 'user_id' => $user_id, 'poster_name' => $poster_name, 'notification_msg' => strlen($notification_msg) > 30 ? substr($notification_msg, 0, 30) . '...' : $notification_msg); $phpbb_notifications = $this->container->get('notification_manager'); $phpbb_notifications->add_notifications('posey.aps.notification.type.wall', $wall_notification_data); } } else { trigger_error($this->user->lang['FORM_INVALID']); } } // DISPLAYING WALL POSTS $getwall_ary = array('SELECT' => 'w.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height', 'FROM' => array($this->wall_table => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = w.poster_id')), 'WHERE' => 'w.user_id = ' . $user_id, 'ORDER_BY' => 'w.msg_id DESC'); $getwall = $this->db->sql_build_query('SELECT_DISTINCT', $getwall_ary); $wallresult = $this->db->sql_query_limit($getwall, 10); // Only get latest 10 wall posts while ($wall = $this->db->sql_fetchrow($wallresult)) { $wall_msg = generate_text_for_display($wall['msg'], $wall['bbcode_uid'], $wall['bbcode_bitfield'], $wall['bbcode_options']); // Parse wall message text $msg_id = $wall['msg_id']; $msg_time = $this->user->format_date($wall['msg_time']); $this->template->assign_block_vars('wall', array('MSG' => $wall_msg, 'ID' => $wall['msg_id'], 'MSG_TIME' => $msg_time, 'POSTER' => get_username_string('full', $wall['poster_id'], $wall['username'], $wall['user_colour']), 'POSTER_AVATAR' => phpbb_get_user_avatar($wall), 'S_HIDDEN_FIELDS' => build_hidden_fields(array('deletewallid' => $wall['msg_id'])))); } $this->db->sql_freeresult($wallresult); // Master gave Dobby a sock, now Dobby is free! // DELETE WALL POST $deletewall = isset($_POST['deletewall']) ? true : false; if ($deletewall) { if (confirm_box(true)) { $deletewallid = request_var('deletewallid', 0); $delete_msg = 'DELETE FROM ' . $this->wall_table . ' WHERE msg_id = ' . $deletewallid; $this->db->sql_query($delete_msg); $msg_deleted_redirect = append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=viewprofile&u=" . $user_id . "#wall"); $message = $this->user->lang['CONFIRM_WALL_DEL'] . '<br /><br />' . sprintf($this->user->lang['RETURN_WALL'], '<a href="' . $msg_deleted_redirect . '">', $username, '</a>'); meta_refresh(3, $msg_deleted_redirect); trigger_error($message); } else { $s_hidden_fields = build_hidden_fields(array('deletewall' => true, 'deletewallid' => request_var('deletewallid', 0))); confirm_box(false, $this->user->lang['CONFIRM_WALL_DEL_EXPLAIN'], $s_hidden_fields); } } /*********************** * Let's set some links * ***********************/ $post_wall_action = append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=viewprofile&u=" . $user_id); // Needed for wall form $total_topics_url = append_sid("{$this->phpbb_root_path}search.{$this->phpEx}", 'author_id=' . $user_id . '&sr=topics'); // Link to search URL for user's topics /**************************** * ASSIGN TEMPLATE VARIABLES * ****************************/ $this->template->assign_vars(array('TOTAL_TOPICS' => $total_topics, 'PROFILE_VIEWS' => $member['user_profile_views'], 'NO_WALL_POSTS' => sprintf($this->user->lang['FIRST_POST_WALL'], '<strong>' . $username . '</strong>'), 'USER_NO_POSTS' => sprintf($this->user->lang['USER_NO_POSTS'], '<strong>' . $username . '</strong>'), 'COVERPHOTO' => $member['user_coverphoto'], 'CP_PANEL_ID' => $this->config['cp_panel_id'] ? $this->config['cp_panel_id'] : 1, 'FL_ENABLED' => $this->config['fl_enabled'] ? true : false, 'CP_ENABLED' => $this->config['cp_enabled'] ? true : false, 'AF_ENABLED' => $this->config['af_enabled'] ? true : false, 'U_SEARCH_USER_TOPICS' => $total_topics_url, 'S_POST_WALL' => $post_wall_action, 'S_CAN_POST_WALL' => $this->auth->acl_get('u_wall_post') ? true : false, 'S_CAN_READ_WALL' => $this->auth->acl_get('u_wall_read') ? true : false, 'S_CAN_DEL_WALL' => $this->auth->acl_get('u_wall_del') ? true : false, 'S_MOD_DEL_WALL' => $this->auth->acl_get('m_wall_del') ? true : false)); }
protected function get($containerId) { return self::$container->get($containerId); }
/** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static('', $container->get('features.manager'), $container->get('features_assigner'), $container->get('config.factory')); }