protected function execute(InputInterface $input, OutputInterface $output) { $roles = Util::assumedRoles(); if (!$output->isQuiet()) { dump($roles); } return $roles; }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $effortOptions = $this->container->get('form_helper')->getProjectEffortMethodOptions(); $project = null; $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($builder) { $form = $event->getForm(); $data = $event->getData(); if ($data instanceof Entity\Project) { $project = $data; } }); $builder->add('name', Type\TextType::class, array('required' => true, 'label' => $this->translator->trans('backend.project.name')))->add('description', Type\TextareaType::class, array('required' => false, 'label' => $this->translator->trans('backend.project.description')))->add('startDate', Type\DateType::class, array('required' => true, 'label' => $this->translator->trans('backend.project.start_date'), 'placeholder' => array('year' => $this->translator->trans('backend.global.year'), 'month' => $this->translator->trans('backend.global.month'), 'day' => $this->translator->trans('backend.global.day')), 'format' => $project != null ? $project->getSettings()->getPHPDateFormat() : 'y-M-d', 'years' => Util::getYearstoForm(3)))->add('estimatedDate', Type\DateType::class, array('required' => false, 'label' => $this->translator->trans('backend.project.estimated_date'), 'placeholder' => array('year' => $this->translator->trans('backend.global.year'), 'month' => $this->translator->trans('backend.global.month'), 'day' => $this->translator->trans('backend.global.day')), 'format' => $project != null ? $project->getSettings()->getPHPDateFormat() : 'y-M-d', 'years' => Util::getYearstoForm(4)))->add('effortEstimationMethod', Type\ChoiceType::class, array('required' => true, 'label' => $this->translator->trans('backend.project.effort_method'), 'choices' => $effortOptions)); }
protected function execute(InputInterface $input, OutputInterface $output) { set_time_limit(0); ini_set('memory_limit', '-1'); $container = $this->getContainer(); $output->writeln("Looking for active Sprints..."); $em = $container->get('doctrine')->getManager(); //buscamos los Sprints activos $sprints = $em->getRepository('BackendBundle:Sprint')->findByStatus(null, Entity\Sprint::STATUS_IN_PROCESS); if (!empty($sprints)) { $output->writeln(count($sprints) . " Sprints found."); foreach ($sprints as $sprint) { //buscamos todos los items asociados al Sprint $search = array('sprint' => $sprint->getId()); $order = array('priority' => 'DESC'); $allSprintItems = $em->getRepository('BackendBundle:Item')->findBy($search, $order); $estimatedTime = 0; $workedTime = 0; $remainingTime = 0; //recorremos los items del Sprint para calcular los tiempos foreach ($allSprintItems as $item) { $estimatedTime += $item->getEstimatedHours(); $workedTime += $item->getWorkedHours(); if ($item->isActive() && $item->getEstimatedHours() > $item->getWorkedHours()) { $remainingTime += $item->getEstimatedHours() - $item->getWorkedHours(); } } $sprint->setEstimatedTime($estimatedTime); $sprint->setWorkedTime($workedTime); $sprint->setRemainingTime($remainingTime); $em->persist($sprint); $output->writeln("Estimated, worked and remaining time updated to " . $sprint->getName() . ' in Project ' . $sprint->getProject()->getName()); //verificamos si la fecha actual hace parte del Sprint para calcular el tiempo restante $searchSprintDay = array('date' => Util::getCurrentDate(), 'sprint' => $sprint->getId()); $sprintDay = $em->getRepository('BackendBundle:SprintDay')->findOneBy($searchSprintDay); if ($sprintDay) { $sprintDay->setRemainingWork($remainingTime); $em->persist($sprintDay); } } $em->flush(); } else { $output->writeln("No active Sprints found."); } }
/** * Permite verificar si el usuario logueado tiene un registro de tiempo * @author Cesar Giraldo <*****@*****.**> May 25 2016 * @return \BackendBundle\Entity\TimeTracking */ public function getActiveTimeTrack() { $user = $this->tokenStorage->getToken()->getUser(); if ($user) { $searchActive = array('user' => $user->getId(), 'endTime' => null); $order = array('date' => 'DESC', 'startTime' => 'DESC'); $timeTrack = $this->em->getRepository('BackendBundle:TimeTracking')->findOneBy($searchActive, $order); if (!$timeTrack instanceof Entity\TimeTracking) { $timeTrack = new Entity\TimeTracking(); $timeTrack->setUser($user); } else { $workedTime = $this->getSecondsBetweenDates($timeTrack->getStartTime(), Util::getCurrentDate()); $timeTrack->setWorkedTime($workedTime); } return $timeTrack; } return null; }
/** * Returns a list of links to model types' actions (Page types, User types, etc.) * By default, with no options specified, this returns a list of links to create any type of page (except core page). * * @param $model_name String The model name (can be lowercase, the Util class corrects it) * @param $action String The controller action * @param $options Array Various options that get passed to Util::list_types() and the key "link_options" can contain an array of options for the $this->html->link() * @return String HTML list of links * @see minerva\libraries\util\Util::list_types() */ public function link_types($model_name='Page', $action='create', $options=array()) { $options += array('exclude_minerva' => true, 'link_options' => array()); $libraries = Util::list_types($model_name, $options); $output = ''; (count($libraries) > 0) ? $output .= '<ul>':$output .= ''; foreach($libraries as $library) { if(substr($library, 0, 7) == 'minerva') { $model = $library; } else { $model = 'minerva\libraries\\' . $library; } $type = current(explode('\\', $library)); if(strtolower($type) == 'minerva') { $type = null; } $output .= '<li>' . $this->link($model::display_name(), '/' . Inflector::pluralize($model_name) . '/' . $action . '/' . $type, $options['link_options']) . '</li>'; } (count($libraries) > 0) ? $output .= '</ul>':$output .= ''; return $output; }
/** * Esta funcion permite rechazar una invitacion a un proyecto * @author Cesar Giraldo <*****@*****.**> 22/01/2016 * @param Request $request datos de la solicitud * @return JsonResponse JSON con mensaje de respuesta */ public function rejectAction(Request $request) { $em = $this->getDoctrine()->getManager(); $invitationId = $request->request->get('invitationId'); $response['result'] = "__OK__"; $response['msg'] = ""; $invitation = $em->getRepository('BackendBundle:ProjectInvitation')->find($invitationId); if (!$invitation || ($invitation && $invitation->getStatus() != Entity\ProjectInvitation::STATUS_ACTIVE || $invitation && $invitation->getUser()->getId() != $this->getUser()->getId())) { $response['result'] = "__KO__"; $response['msg'] = $this->get('translator')->trans('backend.project_invitation.invitation_not_found'); return new JsonResponse($response); } try { $invitation->setStatus(Entity\ProjectInvitation::STATUS_REJECTED); $invitation->setCanceledDate(Util::getCurrentDate()); $em->persist($invitation); $em->flush(); } catch (\Exception $exc) { $response['result'] = "__KO__"; $response['msg'] = $this->get('translator')->trans('backend.project_invitation.error_rejecting'); } return new JsonResponse($response); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->progress = new ProgressBar($output); $this->progress->setFormat('%message%'); $this->progress->start(); $this->progress->setMessage("Fetching assumed roles..."); $roles = Util::assumedRoles(); $regions = $this->getRegions(); $instances = $this->getInstancesData($regions); foreach ($roles as $role) { $c = $this->getCredentials($role); $credentials = new Credentials($c['AccessKeyId'], $c['SecretAccessKey'], $c['SessionToken'], $c['Expiration']); $instances = array_merge($instances, $this->getInstancesData($regions, $credentials)); } $this->progress->finish(); $this->progress->setMessage("Fetching regions..."); $output->writeln("\n"); if ($input->getOption('file') === FALSE) { $this->dumpTable($output, $instances); } else { $this->dumpToFile($input->getOption('file'), $instances); } }
private function doSomething(util\Util $oUtil) { echo "class SnsUtil-> " . $oUtil->doSomething() . "<br>"; echo "class SnsUtil-> " . $oUtil->doSomethingSUtil() . "<br>"; }
<?php use Controller\SessionManager; use Util\Util; use DTO\CommentForPrintOut; require_once 'classes/Util/Util.php'; Util::initRequest(); set_time_limit(0); if (isset($_POST['pageID']) && !empty($_POST['pageID']) && isset($_POST['pageCount'])) { $pageID = htmlentities($_POST['pageID'], ENT_QUOTES); $controller = \Controller\SessionManager::getController(); while (true) { $databaseCommentCount = $controller->getCommentCount($pageID); if ($_POST['pageCount'] < $databaseCommentCount) { $comment = $controller->getOneComment($pageID, $databaseCommentCount - $_POST['pageCount'] - 1); $editable = false; if ($controller->getNicknameByID(@$_SESSION[Util::USER_SESSION_NAME]) == $comment->getNickname()) { $editable = true; } $jsonComment = array("nickname" => $comment->getNickname(), "date" => $comment->getDate(), "commentMsg" => $comment->getCommentMsg(), "editable" => $editable); echo \json_encode($jsonComment); return; } \session_write_close(); \sleep(1); \session_start(); } SessionManager::storeController($controller); }
/** * Set Page initial status before persisting * @ORM\PrePersist */ public function setDefaults() { if ($this->getCreationDate() === null) { $this->setCreationDate(Util::getCurrentDate()); } if ($this->getStatus() === null) { $this->setStatus(self::STATUS_NEW); } if ($this->getWorkedHours() === null) { $this->setWorkedHours(0); } }
/** * Set Page initial status before persisting * @ORM\PrePersist */ public function setDefaults() { if ($this->getAssignationDate() === null) { $this->setAssignationDate(Util::getCurrentDate()); } }
/** * Set Page initial status before persisting * @ORM\PrePersist */ public function setDefaults() { if ($this->getDate() === null) { $this->setDate(Util::getCurrentDate()); } if ($this->getStartTime() === null) { $this->setStartTime(Util::getCurrentDate()); } if ($this->getStartTime() != null && $this->getEndTime() != null) { $startTime = $this->getStartTime(); $interval = $startTime->diff($this->getEndTime()); var_dump($interval->format("%H:%I:%S")); die; } }
/** * Esta funcion permite listar el Sprint Backlog de un sprint determinado * @author Cesar Giraldo <*****@*****.**> 28/01/2016 * @param Request $request * @param string $id identificador del proyecto * @param string $sprintId identificador del sprint * @return type */ public function sprintBacklogAction(Request $request, $id, $sprintId) { $em = $this->getDoctrine()->getManager(); $sprint = $em->getRepository('BackendBundle:Sprint')->find($sprintId); if (!$sprint || $sprint && $sprint->getProject()->getId() != $id) { $this->get('session')->getFlashBag()->add('messageError', $this->get('translator')->trans('backend.sprint.not_found_message')); return $this->redirectToRoute('backend_project_sprints', array('id' => $id)); } if (!$this->container->get('access_control')->isAllowedProject($id)) { $this->get('session')->getFlashBag()->add('messageError', $this->get('translator')->trans('backend.project.not_found_message')); return $this->redirectToRoute('backend_projects'); } $search = array('sprint' => $sprint->getId()); $order = array('priority' => 'DESC'); $allSprintItems = $em->getRepository('BackendBundle:Item')->findBy($search, $order); $estimatedTime = 0; $workedTime = 0; $remainingTime = 0; foreach ($allSprintItems as $item) { $estimatedTime += $item->getEstimatedHours(); $workedTime += $item->getWorkedHours(); if ($item->isActive() && $item->getEstimatedHours() > $item->getWorkedHours()) { $remainingTime += $item->getEstimatedHours() - $item->getWorkedHours(); } } $sprint->setEstimatedTime($estimatedTime); $sprint->setWorkedTime($workedTime); $sprint->setRemainingTime($remainingTime); $em->persist($sprint); //verificamos si el Sprint esta en proceso if ($sprint->getStatus() == Entity\Sprint::STATUS_IN_PROCESS) { //verificamos si la fecha actual hace parte del Sprint para calcular el tiempo restante $searchSprintDay = array('date' => Util::getCurrentDate(), 'sprint' => $sprintId); $sprintDay = $em->getRepository('BackendBundle:SprintDay')->findOneBy($searchSprintDay); if ($sprintDay) { $sprintDay->setRemainingWork($remainingTime); $em->persist($sprintDay); } } $em->flush(); $search['parent'] = NULL; $sprintBacklog = $em->getRepository('BackendBundle:Item')->findBy($search, $order); //logica para pintar la grafica Burdown del Sprint $days = $em->getRepository('BackendBundle:SprintDay')->findBy(array('sprint' => $sprintId), array('date' => 'ASC')); $sprintDays = count($days); $listDays = array(); for ($i = 0; $i < $sprintDays; $i++) { $listDays[$i] = $days[$i]->getDate()->format($sprint->getProject()->getSettings()->getPHPDateFormat()); } $estimatedTimePerDay = 0; $idealArray = array(); if ($sprintDays > 0 && $sprint->getEstimatedTime() > 0) { $estimatedTimePerDay = number_format($sprint->getEstimatedTime() / $sprintDays, 1); $idealArray = range(0, $sprint->getEstimatedTime() - 1, $estimatedTimePerDay); } $idealXArray = array(); foreach ($idealArray as $value) { $value = trim($value); $idealXArray[] = 'Day ' . $value; } //datos del avance del sprint $actualArray = array(); for ($i = 0; $i < $sprintDays; $i++) { $actualArray[$i] = $days[$i]->getRemainingWork(); } return $this->render('BackendBundle:Project/Sprint:backlog.html.twig', array('project' => $sprint->getProject(), 'sprint' => $sprint, 'sprintBacklog' => $sprintBacklog, 'menu' => self::MENU, 'idealXArray' => $idealXArray, 'idealArray' => array_reverse($idealArray), 'actualArray' => $actualArray, 'listDays' => $listDays)); }
/** * Set Page initial status before persisting * @ORM\PrePersist */ public function setDefaults() { if ($this->getCreationDate() === null) { $this->setCreationDate(Util::getCurrentDate()); } if ($this->getIsAccountConfirmed() === null) { $this->setIsAccountConfirmed(false); } }
/** * Set Page initial status before persisting * @ORM\PrePersist */ public function setDefaults() { if ($this->getDate() === null) { $this->setDate(Util::getCurrentDate()); } if ($this->getStatus() === null) { $this->setStatus(self::STATUS_ACTIVE); } }
/** * Generic create() action. * The trick here is that $this->calling_class and $this->calling_method will hold a string * reference for which extended class called this create() method. We need that in order to * get the proper records and access. */ public function create() { // get the "_type" ... page_type, user_type, or block_type $model = Inflector::classify(Inflector::singularize($this->request->params['controller'])); $modelClass = 'minerva\models\\'.$model; $x_type = strtolower($model) . '_type'; // or set it to "all" if there wasn't a param passed $type = ((isset($this->request->params[$x_type])) && (in_array($x_type, $this->library_fields))) ? $this->request->params[$x_type]:'all'; // this just checks access $this->getDocument(array('action' => $this->calling_method, 'request' => $this->request, 'find_type' => false)); // Get the model class we should be using for this (it could be an extended class from a library) $modelClass = $modelClass::getMinervaModel($model, $type); // Get the name for the page, so if another type library uses the "admin" (core) templates for this action, it will be shown $display_name = $modelClass::display_name(); // Lock the schema. We don't want any unwanted data passed to be saved $modelClass::meta('locked', true); // Get the fields so the view template can iterate through them and build the form $fields = $modelClass::schema(); // Don't need to have these fields in the form unset($fields['_id']); // If a page type was passed in the params, we'll need it to save to the page document. $fields[$x_type]['form']['value'] = ($type != 'all') ? $type:null; // If data was passed, set some more data and save if ($this->request->data) { $document = $modelClass::create(); $now = date('Y-m-d h:i:s'); $this->request->data['created'] = $now; $this->request->data['modified'] = $now; $this->request->data['url'] = Util::unique_url(array( 'url' => Inflector::slug($this->request->data['title']), 'model' => $modelClass )); $user = Auth::check('minerva_user'); if($user) { $this->request->data['owner_id'] = $user['_id']; } else { // TODO: possible for anonymous users to create things? do we need to put in any value here? $this->request->data['owner_id'] = ''; } // (note: this will only be useful for UsersController) if(($this->request->params['controller'] == 'users') && (isset($this->request->data['password']))) { $this->request->data['password'] = String::hash($this->request->data['password']); } // Save if($document->save($this->request->data)) { FlashMessage::set('The content has been created successfully.', array('options' => array('type' => 'success', 'pnotify_title' => 'Success', 'pnotify_opacity' => .8))); $this->redirect(array('controller' => $this->request->params['controller'], 'action' => 'index')); } else { FlashMessage::set('The content could not be saved, please try again.', array('options' => array('type' => 'error', 'pnotify_title' => 'Error', 'pnotify_opacity' => .8))); } } if(empty($document)) { $document = $modelClass::create(); // Create an empty page object } $this->set(compact('document', 'fields', 'display_name')); }
/** * Esta funcion permite eliminar una invitacion de un proyecto * @author Cesar Giraldo <*****@*****.**> 20/01/2016 * @param Request $request * @return JsonResponse */ public function deleteInvitationAction(Request $request) { $em = $this->getDoctrine()->getManager(); $invitationId = $request->request->get('invitationId'); $response['result'] = "__OK__"; $response['msg'] = ""; $invitation = $em->getRepository('BackendBundle:ProjectInvitation')->find($invitationId); if (!$invitation) { $response['result'] = "__KO__"; $response['msg'] = $this->get('translator')->trans('backend.project_invitation.not_found_message'); return new JsonResponse($response); } try { $invitation->setStatus(Entity\ProjectInvitation::STATUS_CANCELED); $invitation->setCanceledDate(Util::getCurrentDate()); $em->persist($invitation); $em->flush(); } catch (\Exception $exc) { $response['result'] = "__KO__"; $response['msg'] = $this->get('translator')->trans('backend.project_invitation.error_canceling'); } return new JsonResponse($response); }
/** * Permite iniciar un contador de tiempo para una tarea determinada * @author Cesar Giraldo <*****@*****.**> 06/04/2016 * @param Request $request * @return JsonResponse */ public function stopTimeAction(Request $request) { $response = array('result' => '__KO__', 'msg' => ''); $em = $this->getDoctrine()->getManager(); $timeTrackId = trim(strip_tags($request->request->get('timeId'))); if ($timeTrackId != '') { $timeTrack = $em->getRepository('BackendBundle:TimeTracking')->find($timeTrackId); if ($timeTrack instanceof Entity\TimeTracking && $this->container->get('access_control')->isAllowedProject($timeTrack->getProject()->getId())) { if (empty($timeTrack->getEndTime())) { $timeTrack->setEndTime(Util::getCurrentDate()); $workedTime = $this->container->get('time_tracker')->getSecondsBetweenDates($timeTrack->getStartTime(), $timeTrack->getEndTime()); $timeTrack->setWorkedTime($workedTime); $em->persist($timeTrack); $em->flush(); $response['result'] = '__OK__'; } else { $response['msg'] = $this->get('translator')->trans('backend.item.not_found_message') . "."; } } else { $response['msg'] = $this->get('translator')->trans('backend.item.not_found_message'); } } else { $response['msg'] = $this->get('translator')->trans('backend.item.not_found_message'); } return new JsonResponse($response); }