@EXT\Route(
"/periode/{periode}/eleve/{eleve}/print/",
name="laurentBulletinPrintEleve",
options = {"expose"=true}
)


@param Periode $periode
@param User $eleve

@return array|Response
350169
public function printEleveAction(Request $request, Periode $periode, User $eleve)
    {
        $this->checkOpenPrintPdf($request);

        if ($periode->getTemplate() === 'FinalExamPrint') {

            return $this->printFinalExam($periode, $eleve);
        }
        $totaux = [];
        $totauxMatieres = [];
        $recap = 0;

        if (!$periode->getOnlyPoint()){
            $pemps = $this->pempRepo->findPeriodeEleveMatiere($eleve, $periode);
            $pemds = $this->pemdRepo->findPeriodeElevePointDivers($eleve, $periode);

        } else {
            $pemps = array();
            $pemds = array();

            $periodes = array(1, 2, 3);

            foreach ($periodes as $per){
                $periode = $this->periodeRepo->findOneById($per);
                $pemps[] = $this->pempRepo->findPeriodeEleveMatiere($eleve, $periode);
                $pemds[] = $this->pemdRepo->findPeriodeElevePointDivers($eleve, $periode);

                $totaux[] = $this->totauxManager->getTotalPeriode($periode, $eleve);

            }
            $totauxMatieres = $this->totauxManager->getTotalPeriodes($eleve);
        }

        $template = 'LaurentBulletinBundle::Templates/'.$periode->getTemplate().'.html.twig';


        foreach ($totaux as $total) {
            $recap += $total['totalPourcentage'] / 3;
        }

        $recap = round($recap, 1);

        $params = array('pemps' => $pemps, 'pemds' => $pemds, 'eleve' => $eleve, 'periode' => $periode, 'totaux' => $totaux, 'totauxMatieres' => $totauxMatieres, 'recap' => $recap);

        return $this->render($template, $params);
    }
108659
public function start_el( &$output, $item, $depth = 0, $args = array(), $current_object_id = 0 )
	{
		global $wp_query, $wpdb;
		$indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent


		// só faz pesquisa pelos filhos no primeiro nível
		$has_children = 0;
		if($depth == 0){
			$has_children = $wpdb -> get_var( "SELECT COUNT(meta_id) FROM {$wpdb->prefix}postmeta WHERE meta_key='_menu_item_menu_item_parent' AND meta_value='" . $item->ID . "'" );

		}

		// depth dependent classes
		$depth_classes = array(
			( $depth == 0 ? 'dropdown' : 'sub-menu-item' ),
			$item->current ? 'active' : '',

		);
		$depth_class_names = esc_attr( implode( ' ', $depth_classes ) );

		// passed classes
		$classes = empty( $item->classes ) ? array() : (array) $item->classes;
		$class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) );

		// build html
		$output .= $indent . '<li id="nav-menu-item-'. $item->ID . '" class="' . $depth_class_names . ' ' . $class_names . '">';

		// link attributes
		// <a href="#" class="dropdown-toggle" data-toggle="dropdown">biblioteca <b class="caret"></b></a>
		$attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
		$attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
		$attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
		$attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
		$attributes .= ' class="menu-link menu-depth-'.$depth . ( $depth > 0 ? '' : ' dropdown-toggle' ) . '"';
		$attributes .= $has_children > 0 ? ' data-toggle="dropdown"' : '';

		$caret = $has_children > 0 ? ' <b class="caret"></b>' : '';

		$item_output = sprintf( '%1$s<a%2$s>%3$s%4$s%5$s</a>%6$s',
			$args->before,
			$attributes,
			$args->link_before,
			apply_filters( 'the_title', $item->title, $item->ID ),
			$args->link_after . $caret,
			$args->after
		);

		// build html
		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
	}
706031
public function printUsers($username, $start_from, $sort_by, $sort_dir, $show_group)
    {
        $userlist_data = [];

        $username = Container::get('hooks')
            ->fire('model.userlist.print_users_start', $username, $start_from, $sort_by, $sort_dir, $show_group);

        // Retrieve a list of user IDs, LIMIT is (really) expensive so we only fetch the
        // IDs here then later fetch the remaining data
        $result = DB::forTable('users')
            ->select('u.id')
            ->tableAlias('u')
            ->whereGt('u.id', 1)
            ->whereNotEqual('u.group_id', ForumEnv::get('FEATHER_UNVERIFIED'));

        if ($username != '') {
            $result = $result->whereLike('u.username', str_replace('*', '%', $username));
        }
        if ($show_group > -1) {
            $result = $result->where('u.group_id', $show_group);
        }

        $result = $result->orderByExpr($sort_by . ' ' . $sort_dir)
            ->orderByAsc('u.id')
            ->limit(50)
            ->offset($start_from);

        $result = Container::get('hooks')->fireDB('model.userlist.print_users_query', $result);
        $result = $result->findMany();

        if ($result) {
            $user_ids = [];
            foreach ($result as $cur_user_id) {
                $user_ids[] = $cur_user_id['id'];
            }

            // Grab the users
            $result['select'] = ['u.id', 'u.username', 'u.title', 'u.num_posts', 'u.registered',
                'g.g_id', 'g.g_user_title'];

            $result = DB::forTable('users')
                ->tableAlias('u')
                ->selectMany($result['select'])
                ->leftOuterJoin(DB::prefix() . 'groups', ['g.g_id', '=', 'u.group_id'], 'g')
                ->whereIn('u.id', $user_ids)
                ->orderByExpr($sort_by . ' ' . $sort_dir)
                ->orderByAsc('u.id');
            $result = Container::get('hooks')->fireDB('model.userlist.print_users_grab_query', $result);
            $result = $result->find_many();

            foreach ($result as $user_data) {
                $userlist_data[] = $user_data;
            }
        }

        $userlist_data = Container::get('hooks')->fire('model.userlist.print_users', $userlist_data);

        return $userlist_data;
    }
154400
public function &get($idSite, $period)
    {
        if (!isset($this->data[$idSite][$period])) {
            $this->data[$idSite][$period] = $this->defaultRow;
        }
        return $this->data[$idSite][$period];
    }
483630
public function showDataChartAction(Request $request, User $eleve)
    {
        $this->checkOpenPrintPdf($request);
        $json = $this->totauxManager->getDataChart($eleve, true);
        $jsonNoCeb = $this->totauxManager->getDataChart($eleve, false);

        return $this->render(
            'LaurentBulletinBundle::BulletinShowDataChart.html.twig',
            array('json' => $json, 'jsonNoCeb' => $jsonNoCeb, 'eleve' => $eleve)
        );
    }
274746
public function scopeActiveOn($query, $period)
    {
        return $query->whereHas('periods', function($query) use ($period){
            $query->where('academic_periods_id', $period);
        });
    }
1091399
public function user_list($userlist, $exclusivemode) {
        $tagfeed = new core_tag\output\tagfeed();
        foreach ($userlist as $user) {
            $userpicture = $this->output->user_picture($user, array('size' => $exclusivemode ? 100 : 35));
            $fullname = fullname($user);
            if (user_can_view_profile($user)) {
                $profilelink = new moodle_url('/user/view.php', array('id' => $user->id));
                $fullname = html_writer::link($profilelink, $fullname);
            }
            $tagfeed->add($userpicture, $fullname);
        }

        $items = $tagfeed->export_for_template($this->output);

        if ($exclusivemode) {
            $output = '<div><ul class="inline-list">';
            foreach ($items['items'] as $item) {
                $output .= '<li><div class="user-box">'. $item['img'] . $item['heading'] ."</div></li>\n";
            }
            $output .= "</ul></div>\n";
            return $output;
        }

        return $this->output->render_from_template('core_tag/tagfeed', $items);
    }
672536
public static function data_for_messagearea_search_users($userid, $search, $limitnum = 0) {
        global $CFG, $PAGE, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $systemcontext = context_system::instance();

        $params = array(
            'userid' => $userid,
            'search' => $search,
            'limitnum' => $limitnum
        );
        $params = self::validate_parameters(self::data_for_messagearea_search_users_parameters(), $params);
        self::validate_context($systemcontext);

        if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
            throw new moodle_exception('You do not have permission to perform this action.');
        }

        list($contacts, $courses, $noncontacts) = \core_message\api::search_users(
            $params['userid'],
            $params['search'],
            $params['limitnum']
        );

        $search = new \core_message\output\messagearea\user_search_results($contacts, $courses, $noncontacts);

        $renderer = $PAGE->get_renderer('core_message');
        return $search->export_for_template($renderer);
    }
190391
public function createNewPageFromTemplate($user, $data)
    {
        if (empty($user)) {
            throw new TrackingException('A valid user is required in ' . get_class($this));
        }
        $validatedData = $data;
        /** @var \Rcm\Entity\Page $page */
        $page = $this->pageRepo->findOneBy(
            [
                'pageId' => $validatedData['page-template'],
                'pageType' => 't'
            ]
        );

        if (empty($page)) {
            throw new PageNotFoundException(
                'No template found for page id: '
                . $validatedData['page-template']
            );
        }

        $pageData = [
            'name' => $validatedData['name'],
            'pageTitle' => $validatedData['pageTitle'],
            'pageType' => 'n', // "n" means "normal"
            'createdByUserId' => $user->getId(),
            'createdReason' => 'New page from template in ' . get_class($this),
            'author' => $user->getName(),
        ];

        $createdPage = $resultRevisionId = $this->pageRepo->copyPage(
            $this->currentSite,
            $page,
            $pageData
        );

        $this->immuteblePageVersionRepo->createUnpublished(
            new PageLocator(
                $this->currentSite->getSiteId(),
                $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType())
            ),
            $this->immutablePageContentFactory->__invoke(
                $createdPage->getPageTitle(),
                $createdPage->getDescription(),
                $createdPage->getKeywords(),
                $this->revisionRepo->find($resultRevisionId)->getPluginWrappers()->toArray()
            ),
            $user->getId(),
            __CLASS__ . '::' . __FUNCTION__
        );
    }
202097
public function getRemovedMessages(User $user, $search = '', $page = 1)
    {
        $query = $search === '' ?
            $this->userMessageRepo->findRemoved($user, false):
            $this->userMessageRepo->findRemovedByObjectOrSender($user, $search, false);

        return $this->pagerFactory->createPager($query, $page);
    }
833163
public function Activity($UserReference = '', $Username = '', $UserID = '', $Page = '') {
      $this->Permission('Garden.Profiles.View');
      $this->EditMode(FALSE);
      
      // Object setup
      $Session = Gdn::Session();
      $this->ActivityModel = new ActivityModel();
      
      // Calculate offset.
      list($Offset, $Limit) = OffsetLimit($Page, 30);
      
      // Get user, tab, and comment
      $this->GetUserInfo($UserReference, $Username, $UserID);
      $UserID = $this->User->UserID;
      $Username = $this->User->Name;
      
      $this->_SetBreadcrumbs(T('Activity'), UserUrl($this->User, '', 'activity'));
      
      $this->SetTabView('Activity');
      $Comment = $this->Form->GetFormValue('Comment');
      
      // Load data to display
      $this->ProfileUserID = $this->User->UserID;
      $Limit = 30;

      $NotifyUserIDs = array(ActivityModel::NOTIFY_PUBLIC);
      if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage'))
         $NotifyUserIDs[] = ActivityModel::NOTIFY_MODS;

      $Activities = $this->ActivityModel->GetWhere(
         array('ActivityUserID' => $UserID, 'NotifyUserID' => $NotifyUserIDs), 
         $Offset, $Limit)->ResultArray();
      $this->ActivityModel->JoinComments($Activities);
      $this->SetData('Activities', $Activities);
      if (count($Activities) > 0) {
         $LastActivity = $Activities[0];
         $LastModifiedDate = Gdn_Format::ToTimestamp($this->User->DateUpdated);
         $LastActivityDate = Gdn_Format::ToTimestamp($LastActivity['DateInserted']);
         if ($LastModifiedDate < $LastActivityDate)
            $LastModifiedDate = $LastActivityDate;

         // Make sure to only query this page if the user has no new activity since the requesting browser last saw it.
         $this->SetLastModified($LastModifiedDate);
      }

      // Set the canonical Url.
      if (is_numeric($this->User->Name) || Gdn_Format::Url($this->User->Name) != strtolower($this->User->Name)) {
         $this->CanonicalUrl(Url('profile/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name), TRUE));
      } else {
         $this->CanonicalUrl(Url('profile/'.strtolower($this->User->Name), TRUE));
      }
      
      $this->Render();
   }
993896
function getViajesExtranjeros (senador, periodo, incluyeSenador) {
  let url = URL_VIAJES_INTERNACIONALES.replace(/:year:/, periodo)

  return scraperjs.StaticScraper.create()
    .get(url)
    .catch(ex => {
      console.log('Some srioues problem happened!\n\n\n')
      return new Promise()
    })
    .scrape($ => {
      const nombre = senador.nombre.split(',')[1].split(' ')[1]
      const apellido = senador.nombre.split(',')[0].split(' ')[0]

      const preResults = $('#main tbody tr:not(:first-child)').filter((i, el) => {
        const _apellido = removeAccent($(el).find('td:nth-child(2)').text().trim())
        const _nombre = removeAccent($(el).find('td:nth-child(4)').text().trim())
        return _nombre.indexOf(removeAccent(nombre).toUpperCase()) > -1 && _apellido.indexOf(removeAccent(apellido).toUpperCase()) > -1
      })

      const results = preResults.map(function () {
        const rubro = $(this).find('td:nth-child(1)').text().trim()
        const dateStr = $(this).find('td:nth-child(5)').text().split('-')
        const month = parseInt(dateStr[1])
        const day = parseInt(dateStr[0])
        const year = parseInt(dateStr[2])
        const fecha = new Date(year, month - 1, day)
        const pais = $(this).find('td:nth-child(6)').text().trim()
        const viatico = parseInt($(this).find('td:nth-child(7)').text().trim())
        const motivo = $(this).find('td:nth-child(8)').text().trim()
        return {
          rubro,
          fecha,
          pais,
          viatico,
          motivo
        }
      }).get()
      return incluyeSenador ? Object.assign(senador, { internacionales: results }) : results
    })
}
1347577
private static PeriodFormatter toFormatter(List<Object> elementPairs, boolean notPrinter, boolean notParser) {
        if (notPrinter && notParser) {
            throw new IllegalStateException("Builder has created neither a printer nor a parser");
        }
        int size = elementPairs.size();
        if (size >= 2 && elementPairs.get(0) instanceof Separator) {
            Separator sep = (Separator) elementPairs.get(0);
            if (sep.iAfterParser == null && sep.iAfterPrinter == null) {
                PeriodFormatter f = toFormatter(elementPairs.subList(2, size), notPrinter, notParser);
                sep = sep.finish(f.getPrinter(), f.getParser());
                return new PeriodFormatter(sep, sep);
            }
        }
        Object[] comp = createComposite(elementPairs);
        if (notPrinter) {
            return new PeriodFormatter(null, (PeriodParser) comp[1]);
        } else if (notParser) {
            return new PeriodFormatter((PeriodPrinter) comp[0], null);
        } else {
            return new PeriodFormatter((PeriodPrinter) comp[0], (PeriodParser) comp[1]);
        }
    }
732391
public function onUserActivationPost(UserActivationEvent $e) 
    {
        $password = $e->getParam('password');
        $email = $e->getParam('to');
        $siteUrl = $e->getParam('siteurl');
        $loginUri = $this->getModuleOptions()->getLoginUri();

        // something got really wrong if we get here...
        if(null === $email || null === $password) { 
        	return;
        }
        
        $transport = $this->getServiceLocator()->get('mailer.mail.transport.smtp');
        $message = $this->getServiceLocator()->get('mailer.mail.message.useractivation');
        $message->configure(array(
            'to' => $email,
            'siteurl' => $siteUrl,
            'loginurl' => $siteUrl . $loginUri, 
            'password' => $password,
        	'cdnurl' => $this->getModuleOptions()->getCdnUrl(),
            'siteName' => $this->getModuleOptions()->getSiteName()
        ));
        $transport->send($message);
    }
134558
public function findUserOrdersForCurrentMonth($locale, UserInterface $user)
    {
        try {
            $qb = $this->getOrderQuery($locale)
                ->andWhere('status.id >= :statusId')
                ->andWhere('o.changed >= :currentMonth')
                ->andWhere('o.creator = :user')
                ->setParameter('statusId', OrderStatus::STATUS_CONFIRMED)
                ->setParameter('currentMonth', date('Y-m-01 0:00:00'))
                ->setParameter('user', $user)
                ->orderBy('o.created', 'ASC');

            return $qb->getQuery()->getResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
97989
public function publishPeriodically($interval, Message $message, callable $generator)
    {
        if (!$this->isConnected) {
            return new RejectedPromise(new \LogicException('The client is not connected.'));
        }

        $deferred = new Deferred();

        $this->timer[] = $this->loop->addPeriodicTimer(
            $interval,
            function () use ($message, $generator, $deferred) {
                $this->publish($message->withPayload($generator($message->getTopic())))->then(
                    function ($value) use ($deferred) {
                        $deferred->notify($value);
                    },
                    function (\Exception $e) use ($deferred) {
                        $deferred->reject($e);
                    }
                );
            }
        );

        return $deferred->promise();
    }
280975
public static function transform_standard_log_record_for_userid($record, $userid) {

        // Restore the event to try to get the name, description and other field.
        $restoredevent = static::restore_event_from_standard_record($record);
        if ($restoredevent) {
            $name = $restoredevent->get_name();
            $description = $restoredevent->get_description();
            $other = $restoredevent->other;

        } else {
            $name = $record->eventname;
            $description = "Unknown event ({$name})";
            $other = \tool_log\helper\reader::decode_other($record->other);
        }

        $realuserid = $record->realuserid;
        $isauthor = $record->userid == $userid;
        $isrelated = $record->relateduserid == $userid;
        $isrealuser = $realuserid == $userid;
        $ismasqueraded = $realuserid !== null && $record->userid != $realuserid;
        $ismasquerading = $isrealuser && !$isauthor;
        $isanonymous = $record->anonymous;

        $data = [
            'name' => $name,
            'description' => $description,
            'timecreated' => transform::datetime($record->timecreated),
            'origin' => static::transform_origin($record->origin),
            'ip' => $isauthor ? $record->ip : '',
            'other' => $other ? $other : []
        ];

        if ($isanonymous) {
            $data['action_was_done_anonymously'] = transform::yesno($isanonymous);
        }
        if ($isauthor || !$isanonymous) {
            $data['authorid'] = transform::user($record->userid);
            $data['author_of_the_action_was_you'] = transform::yesno($isauthor);
        }

        if ($record->relateduserid) {
            $data['relateduserid'] = transform::user($record->relateduserid);
            $data['related_user_was_you'] = transform::yesno($isrelated);
        }

        if ($ismasqueraded) {
            $data['author_of_the_action_was_masqueraded'] = transform::yesno(true);
            if ($ismasquerading || !$isanonymous) {
                $data['masqueradinguserid'] = transform::user($realuserid);
                $data['masquerading_user_was_you'] = transform::yesno($ismasquerading);
            }
        }

        return $data;
    }