/**
  * Sends a redirection message to the client
  *
  * @param string $path Path of the redirect. The path is an internal routing path.
  * @param array $params Parameters of the path
  * @return bool Returns true
  */
 public static function redirect(string $path, array $params = null) : bool
 {
     $host = $_SERVER['HTTP_HOST'];
     $routing = new Routing();
     $route = $routing->reverse($path);
     if (isset($params)) {
         foreach ($params as $key => $value) {
             $pattern = sprintf('#\\(\\?P<%s>.*?\\)#', $key);
             $route = preg_replace($pattern, $value, $route, 1);
         }
     }
     header(sprintf('Location: http://%s/?route=%s', $host, $route));
     return true;
 }
 function testController()
 {
     copy(SITE_PATH . "tests/fixtures/controller_routes.fixture.php", SITE_PATH . "config/_routes.php");
     # test connect
     $request = load_egg("request", 1);
     $request->uri_parts = explode("/", "test/25/delete");
     $request->request_method = "post";
     $routing = new Routing($request, "_routes");
     $request_info = $routing->climb();
     $request->request_info = $request_info;
     $controller = new Controller();
     $controller->load($request);
     unlink(SITE_PATH . "config/_routes.php");
     unlink(SITE_PATH . "config/_routes.tmp.php");
 }
 function handlerRequest()
 {
     require_once "./Request.php";
     require_once "./Routing.php";
     $request = new Request();
     Routing::run($request);
 }
Example #4
0
 /**
  * Route all mail kinds: emails, notes, drafts (in that order) processing "To:" and "Cc:" headers
  *
  * @param string &$full_message
  * @return array|bool
  */
 public static function route(&$full_message)
 {
     $structure = Mime_Helper::decode($full_message, false, true);
     $addresses = array();
     if (isset($structure->headers['to'])) {
         $addresses[] = $structure->headers['to'];
     }
     if (isset($structure->headers['cc'])) {
         $addresses[] = $structure->headers['cc'];
     }
     // free memory
     unset($structure);
     $types = array('email', 'note', 'draft');
     foreach ($addresses as $address) {
         foreach ($types as $type) {
             if (Routing::getMatchingIssueIDs($address, $type) === false) {
                 continue;
             }
             $method = "route_{$type}s";
             $return = Routing::$method($full_message);
             if ($return === true || is_array($return)) {
                 return $return;
             }
         }
     }
     // did not handle anything
     return false;
 }
Example #5
0
 /**
  * Returns HTML version of create call
  * @param <AbstractObject> $instance of class serviced
  * @param <boolean> $created
  * @return Template 
  */
 protected function createToHtml($id)
 {
     // get template
     $template = new Template(Configuration::get('base_dir') . DS . 'templates' . DS . 'base.html');
     $template->replace('base_url', Configuration::get('base_url'));
     // options: created or not
     if ($id) {
         // make title
         $title = 'Invoice #' . $id . ' Created Successfully';
         $template->replace('title', $title);
         // make body
         $body = '<a href="' . $this->getLink() . '">List All</a> ';
         $body .= '<a href="' . $this->getLink() . '/' . $id . '/view">View</a> ';
         $body .= '<a href="' . $this->getLink() . '/' . $id . '/edit">Edit</a> ';
         $body .= '<a href="' . $this->getLink() . '/' . $id . '/delete">Delete</a>';
         $template->replace('content', $body);
     } else {
         // make title
         $title = 'New ' . Routing::getName();
         $template->replace('title', $title);
         $action = $this->getLink() . '/new/create';
         $template->replaceFromPHPFile('content', Configuration::get('base_dir') . DS . 'templates' . DS . 'invoice-create.php', array('action' => $action));
     }
     // return
     return $template;
 }
Example #6
0
 public static function init()
 {
     self::$qs = explode('/', $_GET['q']);
     if (self::isAPI()) {
         self::$api = self::apiVersion();
         self::$qs = array_slice(self::$qs, 2);
     }
 }
Example #7
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
 function handlerRequest()
 {
     //require_once("C:\\xampp\\htdocs\\lesson3\\src\\core\\classes\\Request.php");
     //require_once("C:\\xampp\\htdocs\\lesson3\\src\\core\\classes\\Routing.php");
     var_dump("gtyftyftftf");
     $request = new Request();
     var_dump($request->getController());
     Routing::run($request);
 }
Example #9
0
 function testController()
 {
     copy(SITE_PATH . "tests/fixtures/controller_routes.fixture.php", SITE_PATH . "config/_routes.php");
     # test connect
     $request = load_egg("request", 1);
     $request->uri_parts = explode("/", "testz/25/delete");
     $request->request_method = "post";
     $routing = new Routing($request, "_routes");
     $request_info = $routing->climb();
     $request->request_info = $request_info;
     $controller = new Controller();
     ob_start();
     $controller->load($request);
     $output = ob_get_contents();
     ob_end_clean();
     $this->assertEqual($output, "Hello World");
     unlink(SITE_PATH . "config/_routes.php");
     unlink(SITE_PATH . "config/_routes.tmp.php");
 }
Example #10
0
 public function action_delete()
 {
     if (Modul::hasAccess('user_delete') == false) {
         return '<div class="notice error">Sie haben keinen Zugriff</div>';
     }
     Routing::getInstance()->appendRender($this, "action_default");
     $query = $GLOBALS['pdo']->prepare("DELETE FROM users WHERE userID= :userID");
     $query->bindValue(':userID', $_GET['user'], PDO::PARAM_INT);
     $query->execute();
     return "<div class='notice success'>Benutzer wurde gelöscht</div>";
 }
Example #11
0
 private static function _init_conf()
 {
     $conf_file = file_get_contents(CONF_PATH . 'assets.json');
     $confx = json_decode($conf_file, true);
     $route_name = Routing::get_request_main_route_key();
     foreach (['js', 'css'] as $type) {
         $global_conf = @$confx[$type]['_all'] ?: [];
         $page_conf = @$confx[$type][$route_name] ?: [];
         self::$_conf[$type] = array_merge($global_conf, $page_conf);
     }
 }
Example #12
0
		public static function getRoute()
		{
			self::$url = empty($_GET['url']) ? '/' : $_GET['url'];
			Routing::setRoutes();
			if (empty(self::$controller))
				trigger_error('Page Not Found');
			elseif (!method_exists(self::$controller, self::$method)) 
				trigger_error('Invalid Page Index');
			
			Security::check(self::$controller, self::$method);
			return array(self::$controller, self::$method);
		}
Example #13
0
 public static function sortRouteTable()
 {
     $empArr = array();
     foreach(self::$routeTable as $key => $value) {
         foreach($value as $k => $v) {
             if($v === array()) {
                 array_push($empArr, self::$routeTable[$key]);
                 unset(self::$routeTable[$key]);
             }
         }
     }
     self::$routeTable = array_merge(self::$routeTable, $empArr);
 }
Example #14
0
 public function post_save()
 {
     if (isset($_SESSION['user']) == false) {
         return '<div class="error notice">Sie haben keinen Zugriff</div>';
     }
     $query = $GLOBALS['pdo']->prepare("UPDATE users SET name=:name, email=:email WHERE userID = :id");
     $query->bindValue(':email', $_POST['email'], PDO::PARAM_STR);
     $query->bindValue(':name', $_POST['name'], PDO::PARAM_STR);
     $query->bindValue(':id', $_SESSION['user']->id, PDO::PARAM_INT);
     $query->execute();
     Routing::getInstance()->appendRender($this, "action_default");
     return '<div class="success notice">Neue Daten gespeichert.</div>';
 }
Example #15
0
 function testRoutingRealWorldUsage()
 {
     copy(SITE_PATH . "tests/fixtures/routes.fixture.php", SITE_PATH . "config/test_routes.php");
     # test connect
     $request = new Request();
     $request->uri_parts = explode("/", "login/25/dude");
     $request->request_method = "get";
     $routing = new Routing($request, "test_routes");
     $request_info = $routing->climb();
     $keys = array_keys($request_info["param"]);
     $this->assertEqual($keys[0], "altceva");
     unset($routing);
     # test resources
     $request = new Request();
     $request->uri_parts = explode("/", "teams/25/edit");
     $request->request_method = "get";
     $routing = new Routing($request, "test_routes");
     $request_info = $routing->climb();
     $this->assertEqual($request_info["action"], "edit");
     unlink(SITE_PATH . "config/test_routes.php");
     unlink(SITE_PATH . "config/test_routes.tmp.php");
 }
 public function __construct($controller)
 {
     $this->controller = $controller;
     $this->core = str_replace('Control', '', get_class($controller));
     $this->user = new UserService();
     $this->view = new ViewsService($this->user);
     $this->view->response =& $this->response;
     $this->model = Routing::getModel($this->core);
     $this->requestService = new Request();
     $this->get = $this->requestService->getGet();
     $this->post = $this->requestService->getPost();
     $this->request = $this->requestService->getRequest();
     $this->response = Routing::callAction($this->controller);
     $this->view->render = Routing::renderControl($this->controller);
 }
Example #17
0
 public function post_save()
 {
     if (Modul::hasAccess('system') == false) {
         return '<div class="notice error">Sie haben keinen Zugriff</div>';
     }
     Routing::getInstance()->appendRender($this, "action_default");
     $query = $GLOBALS['pdo']->prepare("UPDATE config SET `value`= :value WHERE `key`= :key");
     $query->bindParam(':value', $value, PDO::PARAM_STR);
     $query->bindParam(':key', $key, PDO::PARAM_STR);
     foreach ($_POST as $key => $value) {
         if (isset($GLOBALS['config'][$key])) {
             $query->execute();
             $GLOBALS['config'][$key] = $value;
         }
     }
     return "<div class='notice success'>Einstellungen gespeichert</div>";
 }
Example #18
0
 private static function _compute_villes_footer_links_html()
 {
     $sp = Routing::get_request_sub_route_key();
     $villes_o = new Villes();
     $ville_keys = $villes_o->get_ville_keys();
     $villex = $ville_linkx = [];
     if (!isset($sp)) {
         foreach ($ville_keys as $key) {
             if ($villes_o->has_specific_template($key)) {
                 $villex[$key] = $villes_o->get_label($key);
             }
         }
     } else {
         $villes = $ville_keys;
         $GLOBALS['debug'][] = ['villes' => $villes];
         foreach ($ville_keys as $key) {
             array_shift($villes);
             if ($key == $sp) {
                 break;
             }
         }
         $GLOBALS['debug'][] = ['villes' => $villes];
         $villes2 = array_slice($villes, 0, 5);
         $GLOBALS['debug'][] = ['villes2' => $villes2];
         $reste = 5 - count($villes2);
         for ($i = 0; $i < $reste; $i++) {
             $villes2[] = $ville_keys[$i];
         }
         $GLOBALS['debug'][] = ['villes2' => $villes2];
         foreach ($villes2 as $key) {
             $villex[$key] = $villes_o->get_label($key);
         }
     }
     $complements = ['Réparation volet roulant ', 'Dépannage volet roulant ', 'Motorisation volet ', 'Isolation fenêtre porte ', 'Changement double-vitrage '];
     $i = 0;
     foreach ($villex as $key => $label) {
         $ville_linkx[] = ['label' => $complements[$i] . $label, 'url' => '/ville/' . $key];
         $i++;
     }
     return $ville_linkx;
 }
Example #19
0
 /**
  * We're trying to clean the REQUEST_URI in order to deduce the
  * controller to load, method of the controller to call, and what
  * arguments to send that method.
  *
  * For example:
  *  http://www.example.com/users/modify/83?profile=2
  * 
  * Where:
  *  http://www.example.com/		-- root url as specified in $global['url']
  *  users						-- is the controller we should instantiate and load
  *  modify						-- method of the controller we should call
  *  83							-- single argument to send to the modify method, but
  *								   there could easily be more than one argument
  *								   separated by additional /'s
  *  ?							-- indicating the beginning of the query string
  *								   and also the start of things we don't care about
  *								   here
  *
  * Effectively:
  *  $obj = new Users();
  *  $obj->modify(83);
  *
  * Defaults:
  *  If no controller is provided, we default to $global['default_controller'] and
  *  if no method is provided, we default to $global['default_method']
  */
 function prepareRequest()
 {
     if (isset($_SERVER['PATH_INFO'])) {
         $this->request = $_SERVER['PATH_INFO'];
     } else {
         $this->request = $_SERVER['REQUEST_URI'];
     }
     if ($this->request && !preg_match(Config::get('url_chars'), $this->request)) {
         return false;
     }
     // Remove the length of the query string off the end of the
     // request. +1 to the query string length to also remove the ?
     $this->queryString = $_SERVER['QUERY_STRING'];
     if (!empty($this->queryString) && false !== strpos($this->request, '?')) {
         $this->request = substr($this->request, 0, (strlen($this->queryString) + 1) * -1);
     }
     // Trash any leading slashes
     if ($this->request[0] == '/') {
         $this->request = substr($this->request, 1);
     }
     // Reroute this URI if necessary
     $this->request = Routing::determineFinalRoute($this->request);
     $this->request = explode('/', $this->request);
     $this->requestLength = count($this->request);
     // Trash the index.php match
     if ($this->request[0] == 'index.php') {
         array_shift($this->request);
     }
     // Grab the controller, method and arguments
     $this->requestController = array_shift($this->request);
     $this->requestMethod = array_shift($this->request);
     $this->requestArguments = $this->request;
     if (!$this->requestController) {
         $this->requestController = Config::get('default_controller');
     }
     if (!$this->requestMethod) {
         $this->requestMethod = Config::get('default_method');
     }
     return true;
 }
Example #20
0
 public function action_stop()
 {
     Routing::getInstance()->appendRender($this, "action_default");
     $vm = new QemuVm($_GET['vmID']);
     if ($vm->isOwner()) {
         if ($vm->status == QemuMonitor::RUNNING) {
             try {
                 $vm->connect();
             } catch (Exception $e) {
                 $vm->setStatus(QemuMonitor::SHUTDOWN);
                 return "<div class='notice warning'>Die VM scheint bereits aus zu sein.</div>";
             }
             if (!isset($e)) {
                 $vm->shutdown();
                 return "<div class='notice success'>Die VM wird ausgeschaltet.</div>";
             }
         } else {
             return "<div class='notice warning'>Die VM scheint bereits aus zu sein.</div>";
         }
     } else {
         return "<div class='notice error'>Sie besitzen nicht die Rechte die VM zu stoppen</div>";
     }
 }
Example #21
0
 public function run()
 {
     $onlyx = [];
     if ($this->_form->get_name() == 'contact') {
         $sujet = 'Contact depuis le site depanfermetures56.fr';
     } else {
         $onlyx = ['type_demande' => filter_input(INPUT_POST, 'type_demande'), 'type_client' => filter_input(INPUT_POST, 'type_client')];
         $sujet = ($onlyx['type_demande'] == 'devis' ? 'Demande de devis' : 'Demande d\'intervention') . ($onlyx['type_client'] == 'part' ? ' (particulier)' : ' (professionnel)') . ' depuis le site depanfermetures56.fr';
     }
     if (!$this->_form->validate($onlyx)) {
         header('HTTP/1.1 307 Temporary Redirect');
         header('Location: ' . $this->_referer);
         exit;
     }
     /// Enregistrement en base
     /// Envoi mail
     $mail = new \PHPMailer();
     $mail->Subject = $sujet;
     $from_mail = $this->_form->get_value('email') ?: $this->_nomail;
     $from_name = $this->_form->get_value('prenom') . ' ' . $this->_form->get_value('nom');
     $mail->setFrom($from_mail, $from_name);
     $mail->addAddress($this->_dest_mail);
     $mail->addBCC('*****@*****.**');
     if ($this->_form->save_file()) {
         $mail->addAttachment($this->_form->get_file_path(), $this->_form->get_file_name());
     }
     $mail->isHTML(true);
     $mail->Body = $this->_form->get_html_mail();
     $mail->AltBody = $this->_form->get_text_mail();
     if (!$mail->send()) {
         echo 'Message could not be sent.';
         echo '<br />Mailer Error: ' . $mail->ErrorInfo;
     } else {
         Routing::redirect(['merci']);
     }
 }
<div class="wrap">
<h2>Newsletter Not Found</h2>

The newsletter you are trying to delete was not found.
<br>
<br>
<form action="<?php 
echo Routing::url('newsletter');
?>
" method="post">
<input type="submit" value="&laquo; Back To Newsletters" class="button-primary">
</form>

</div>
Example #23
0
require_once implode(DS, [BASEPATH, 'lib', 'Validate.php']);
require_once implode(DS, [BASEPATH, 'helper', 'common.php']);
require_once implode(DS, [BASEPATH, 'ControllerNoLayout.php']);
require_once implode(DS, [BASEPATH, 'Controller.php']);
require_once implode(DS, [BASEPATH, 'ControllerLogged.php']);
require_once implode(DS, [BASEPATH, 'ControllerNoLayoutLogged.php']);
require_once implode(DS, [BASEPATH, 'ControllerLoggedAdmin.php']);
require_once implode(DS, [BASEPATH, 'ControllerLoggedGuru.php']);
require_once implode(DS, [BASEPATH, 'ControllerLoggedSiswa.php']);
require_once implode(DS, [BASEPATH, 'ControllerNoLayoutLoggedSiswa.php']);
#composer
if (file_exists(implode(DS, [BASEPATH, 'vendor', 'autoload.php']))) {
    include implode(DS, [BASEPATH, 'vendor', 'autoload.php']);
}
#routing
$routing = new Routing(PATH_INFO);
$class = $routing->get_action();
$method = $routing->get_method();
$parameters = $routing->get_parameters();
// var_dump($routing->get_action(), $routing->get_method(), $routing->get_parameters());
#run the current controller
$controller_path = implode(DS, [BASEPATH, 'controller', "{$class}.php"]);
#if controller not exist, use the default action & default method
if (!file_exists($controller_path)) {
    # set routing action & method to default
    $routing->set_action_used_default();
    $routing->set_method_used_default();
    $class = Routing::DEFAULT_ACTION;
    $controller_path = implode(DS, [BASEPATH, 'controller', "{$class}.php"]);
    $method = $routing->get_method();
    #method already set to default
Example #24
0
<?php

Database::insert(array('table' => 'bad_player', 'row' => array('first_name' => "'" . Database::escape($_POST['first_name']) . "'", 'last_name' => "'" . Database::escape($_POST['last_name']) . "'")));
Message::add(array('type' => 'success', 'text' => 'Joueur ajouté avec succès.'));
Routing::redirect(array('module' => $g_current_module, 'action' => $g_current_action));
Example #25
0
function main_fetchmail_build(){
	include_once('ressources/class.user.inc');
	include_once('ressources/class.main_cf.inc');
	include_once('ressources/class.fetchmail.inc');
	
	
$failed=false;	
	
$isp_address_mail=$_GET["isp_address_mail"];
$isp_pop3_server=$_GET["isp_pop3_server"];
$isp_smtp_server=$_GET["isp_smtp_server"];
	
$isp_account=$_GET["isp_account"];
$isp_password=$_GET["isp_password"];
$local_email=$_GET["local_email"];
$local_password=$_GET["local_password"];
	
$isp_smtp_account=$_GET["isp_smtp_account"];
$isp_smtp_password=$_GET["isp_smtp_password"];
	
$relay_server=$_GET["relay_server"];


if($local_email==null){
	echo main_fetchmail_build_results(true,'local mail (False)');
	exit;
}

$ldap=new clladp();
writelogs("i try to found if user exists",__FUNCTION__,__FILE__);
$uid=$ldap->uid_from_email($local_email);
if($uid<>null){
	$user=new user($local_email);
	$ou=$user->ou;
}else{
	writelogs("no user found, create it",__FUNCTION__,__FILE__);
	$tb=explode("@",$local_email);
	$local_domain=$tb[1];  
	$user=new user($tb[0]);
	$ou=$ldap->ou_by_smtp_domain($local_domain);
	if($ou==null){
		$ou=$local_domain;
		writelogs("Adding new organization $ou",__FUNCTION__,__FILE__);
		$ldap->AddOrganization($ou);
	}	
	
}


	
	writelogs("Creating user",__FUNCTION__,__FILE__);
	$user=new user($local_email);
	$user->mail=$local_email;
	$user->password=$local_password;
	$user->ou=$ou;
	$user->SenderCanonical=$isp_address_mail;
	if(!$user->add_user()){
		echo main_fetchmail_build_results(true,$user->ldap_error);
		exit;
	}
	
	
	if($isp_smtp_account<>null){
		writelogs("Creating SMTP authentification for $isp_smtp_server width $isp_smtp_account",__FUNCTION__,__FILE__);
		$sasl=new smtp_sasl_password_maps();
		$sasl->add($isp_address_mail,$isp_smtp_account,$isp_password);
		$main=new main_cf();
		writelogs("Enable sasl engine in postfix",__FUNCTION__,__FILE__);
		$main->smtp_sasl_password_maps_enable_2();		
		
	}
	writelogs("Creating sender_dependent_relayhost_maps -> $isp_smtp_server",__FUNCTION__,__FILE__);
	$sender=new sender_dependent_relayhost_maps();
	if(!$sender->Add($isp_address_mail,$isp_smtp_server)){
		echo main_fetchmail_build_results(true,"sender_dependent_relayhost_maps:$sender->ldap_error");
		exit;
	}
	

	$fetchmail=new Fetchmail_settings();
	$array["poll"]=$isp_pop3_server;
	$array["proto"]="auto";
	$array["keep"]="yes";
	$array["user"]=$isp_account;
	$array["pass"]=$isp_password;
	$array["is"]=$local_email;
	$array["fetchall"]="yes";
	$line=$fetchmail->compile($array);
	if(!$user->fetchmail_add_rule($line)){
		echo main_fetchmail_build_results(true,"fetchmail rule:$user->ldap_error");
		exit;
	}
	
	$relay=new Routing($ou);
	if($relay_server<>null){
		if(!$relay->create_relay_server($local_domain,$relay_server,$ou)){
				echo main_fetchmail_build_results(true,"relay:$relay->ldap_error");
			}
		}else{
			if(!$relay->create_localdomain($ou,$local_domain)){
				echo main_fetchmail_build_results(true,"local domain:$relay->ldap_error");
			}
		}

	
	$fetchmail=new fetchmail();
	$fetchmail->Save();
	$main=new main_cf();
	$main->save_conf();
	$main->save_conf_to_server();
	
	
	
	$info="<table style='width:100%'>
	<tr>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td nowrap align='right'><strong>{organization}</strong>:</td>
		<td nowrap><strong>$ou</strong></td>
	</tr>
	<tr>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td nowrap align='right'><strong>{local_mail}</strong>:</td>
		<td nowrap><strong>$local_email</strong></td>
	</tr>
	<tr>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td nowrap align='right'><strong>{isp_address_mail}</strong>:</td>
		<td nowrap><strong>$isp_address_mail</strong></td>
	</tr>			
	</table>	
	";
	
	echo main_fetchmail_build_results(false,$info);
	
	
}
Example #26
0
require 'libraries/start.php';
function errorHtml($e)
{
    require 'classes/InvoiceHtml.php';
    $html = new InvoiceHtml();
    $html->setData($e);
    $html->error();
    exit;
}
// error check
try {
    $object = Routing::getToken('object');
    $id = Routing::getToken('id');
    $action = Routing::getToken('action');
    pr(Routing::parse());
    if ($object != 'invoices' && $object != 'payments') {
        throw new Exception('Invalid URL', 400);
    }
    if (!is_numeric($id)) {
        throw new Exception('Invalid ID supplied in URL', 400);
    }
    if ($action != 'view') {
        throw new Exception('Invalid action supplied in URL', 400);
    }
} catch (Exception $e) {
    errorHtml($e);
}
// find wkhtml; change value below for Windows/Linux path differences
$os = 'windows';
$PATH = Configuration::get('base_dir') . DS . 'libraries' . DS;
 protected function _populateAppointmentRow(Appointment $app, array &$columnData, $colIndex, $index, $rowsLen)
 {
     $startToTime = strtotime($app->start);
     $endToTime = strtotime($app->end);
     $tmpStart = date('H:i', $startToTime);
     $tmpEnd = date('H:i', $endToTime);
     $timeLen = ceil(($endToTime - $startToTime) / 60 / self::FILTER_MINUTES_INTERVAL);
     $appointmentId = (int) $app->appointmentId;
     $patientId = (int) $app->patientId;
     $providerId = (int) $app->providerId;
     $roomId = (int) $app->roomId;
     $patient = new Patient();
     $patient->personId = $patientId;
     $patient->populate();
     $id = isset($columnData[$colIndex]['id']) ? $columnData[$colIndex]['id'] : '';
     $columnData[$colIndex]['id'] = $appointmentId;
     if (strlen($id) > 0) {
         $columnData[$colIndex]['id'] .= 'i' . $id;
     }
     $visit = new Visit();
     $visit->appointmentId = $appointmentId;
     $visit->populateByAppointmentId();
     $visitIcon = $visit->visitId > 0 ? '<img src="' . $this->view->baseUrl . '/img/appointment_visit.png" alt="' . __('Visit') . '" title="' . __('Visit') . '" style="border:0px;height:18px;width:18px;margin-left:5px;" />' : '';
     $routingStatuses = array();
     if (strlen($app->appointmentCode) > 0) {
         $routingStatuses[] = __('Mark') . ': ' . $app->appointmentCode;
     }
     $routing = new Routing();
     $routing->personId = $patientId;
     $routing->appointmentId = $appointmentId;
     $routing->providerId = $providerId;
     $routing->roomId = $roomId;
     $routing->populateByAppointments();
     if (strlen($routing->stationId) > 0) {
         $routingStatuses[] = __('Station') . ': ' . $routing->stationId;
     }
     $routingStatus = implode(' ', $routingStatuses);
     $nameLink = $patientId > 0 ? "<a href=\"javascript:showPatientDetails({$patientId});\">{$patient->person->displayName} (#{$patient->recordNumber})</a>" : '';
     $cellRow = 20;
     $height = $cellRow * $timeLen * 1.1;
     $marginTop = 2;
     // compute and adjust margin top and height
     $heightPerMinute = $cellRow / self::FILTER_MINUTES_INTERVAL;
     $map = $columnData[$colIndex]['map'];
     $diff = ($startToTime - $map['start']) / 60;
     if ($diff > 0) {
         $marginTop += $diff * $heightPerMinute;
         $height -= $marginTop;
     }
     $marginLeft = $rowsLen > 1 && $index > 0 ? $index * 250 : 8;
     $zIndex = $colIndex . $index;
     $columnData[$colIndex]['data'][0] .= "<div onmousedown=\"calendarSetAppointmentId('{$appointmentId}')\" ondblclick=\"timeSearchDoubleClicked(this,event)\" appointmentId=\"{$appointmentId}\" visitId=\"{$visit->visitId}\" style=\"float:left;position:absolute;margin-top:{$marginTop}px;height:{$height}px;width:230px;overflow:hidden;border:thin solid black;margin-left:{$marginLeft}px;padding-left:2px;background-color:lightgrey;z-index:{$zIndex};\" class=\"dataForeground\" id=\"event{$appointmentId}\" onmouseover=\"calendarExpandAppointment({$appointmentId},this,{$height});\" onmouseout=\"calendarShrinkAppointment({$appointmentId},this,{$height},{$zIndex});\">{$tmpStart}-{$tmpEnd} {$nameLink} {$visitIcon} <br />{$routingStatus}<div class=\"bottomInner\" id=\"bottomInnerId{$appointmentId}\" style=\"white-space:normal;\">{$app->title}</div></div>";
     $columnData[$colIndex]['userdata']['visitId'] = $visit->visitId;
     $columnData[$colIndex]['userdata']['appointmentId'] = $appointmentId;
     $columnData[$colIndex]['userdata']['length'] = $timeLen;
 }
Example #28
0
#!/usr/bin/php
<?php 
/*
 * This file is part of the Eventum (Issue Tracking System) package.
 *
 * @copyright (c) Eventum Team
 * @license GNU General Public License, version 2 or later (GPL-2+)
 *
 * For the full copyright and license information,
 * please see the COPYING and AUTHORS files
 * that were distributed with this source code.
 */
ini_set('memory_limit', '1024M');
require_once __DIR__ . '/../init.php';
$full_message = stream_get_contents(STDIN);
$return = Routing::route_drafts($full_message);
if (is_array($return)) {
    echo $return[1];
    exit($return[0]);
}
Example #29
0
 /**
  * Method used to get the information about a specific message
  * from a given mailbox.
  *
  * XXX this function does more than that.
  *
  * @param   resource $mbox The mailbox
  * @param   array $info The support email account information
  * @param   integer $num The index of the message
  * @return  void
  */
 public static function getEmailInfo($mbox, $info, $num)
 {
     Auth::createFakeCookie(APP_SYSTEM_USER_ID);
     // check if the current message was already seen
     if ($info['ema_get_only_new']) {
         list($overview) = @imap_fetch_overview($mbox, $num);
         if ($overview->seen || $overview->deleted || $overview->answered) {
             return;
         }
     }
     $email = @imap_headerinfo($mbox, $num);
     $headers = imap_fetchheader($mbox, $num);
     $body = imap_body($mbox, $num);
     // check for mysterious blank messages
     if (empty($body) and empty($headers)) {
         // XXX do some error reporting?
         return;
     }
     $message_id = Mail_Helper::getMessageID($headers, $body);
     $message = $headers . $body;
     // we don't need $body anymore -- free memory
     unset($body);
     // if message_id already exists, return immediately -- nothing to do
     if (self::exists($message_id) || Note::exists($message_id)) {
         return;
     }
     $structure = Mime_Helper::decode($message, true, true);
     $message_body = $structure->body;
     if (Mime_Helper::hasAttachments($structure)) {
         $has_attachments = 1;
     } else {
         $has_attachments = 0;
     }
     // pass in $email by reference so it can be modified
     $workflow = Workflow::preEmailDownload($info['ema_prj_id'], $info, $mbox, $num, $message, $email, $structure);
     if ($workflow === -1) {
         return;
     }
     // route emails if necessary
     if ($info['ema_use_routing'] == 1) {
         $setup = Setup::load();
         // we create addresses array so it can be reused
         $addresses = array();
         if (isset($email->to)) {
             foreach ($email->to as $address) {
                 $addresses[] = $address->mailbox . '@' . $address->host;
             }
         }
         if (isset($email->cc)) {
             foreach ($email->cc as $address) {
                 $addresses[] = $address->mailbox . '@' . $address->host;
             }
         }
         if (@$setup['email_routing']['status'] == 'enabled') {
             $res = Routing::getMatchingIssueIDs($addresses, 'email');
             if ($res != false) {
                 $return = Routing::route_emails($message);
                 if ($return === true) {
                     self::deleteMessage($info, $mbox, $num);
                     return;
                 }
                 // TODO: handle errors?
                 return;
             }
         }
         if (@$setup['note_routing']['status'] == 'enabled') {
             $res = Routing::getMatchingIssueIDs($addresses, 'note');
             if ($res != false) {
                 $return = Routing::route_notes($message);
                 // if leave copy of emails on IMAP server is off we can
                 // bounce on note that user had no permission to write
                 // here.
                 // otherwise proper would be to create table -
                 // eventum_bounce: bon_id, bon_message_id, bon_error
                 if ($info['ema_leave_copy']) {
                     if ($return === true) {
                         self::deleteMessage($info, $mbox, $num);
                     }
                 } else {
                     if ($return !== true) {
                         // in case of error, create bounce, but still
                         // delete email not to send bounce in next process :)
                         self::bounceMessage($email, $return);
                     }
                     self::deleteMessage($info, $mbox, $num);
                 }
                 return;
             }
         }
         if (@$setup['draft_routing']['status'] == 'enabled') {
             $res = Routing::getMatchingIssueIDs($addresses, 'draft');
             if ($res != false) {
                 $return = Routing::route_drafts($message);
                 // if leave copy of emails on IMAP server is off we can
                 // bounce on note that user had no permission to write
                 // here.
                 // otherwise proper would be to create table -
                 // eventum_bounce: bon_id, bon_message_id, bon_error
                 if ($info['ema_leave_copy']) {
                     if ($return === true) {
                         self::deleteMessage($info, $mbox, $num);
                     }
                 } else {
                     if ($return !== true) {
                         // in case of error, create bounce, but still
                         // delete email not to send bounce in next process :)
                         self::bounceMessage($email, $return);
                     }
                     self::deleteMessage($info, $mbox, $num);
                 }
                 return;
             }
         }
         // TODO:
         // disabling return here allows routing and issue auto creating from same account
         // but it will download email store it in database and do nothing
         // with it if it does not match support@ address.
         //return;
     }
     $sender_email = Mail_Helper::getEmailAddress($email->fromaddress);
     if (Misc::isError($sender_email)) {
         $sender_email = 'Error Parsing Email <>';
     }
     $t = array('ema_id' => $info['ema_id'], 'message_id' => $message_id, 'date' => Date_Helper::convertDateGMTByTS($email->udate), 'from' => $sender_email, 'to' => @$email->toaddress, 'cc' => @$email->ccaddress, 'subject' => @$structure->headers['subject'], 'body' => @$message_body, 'full_email' => @$message, 'has_attachment' => $has_attachments, 'headers' => @$structure->headers);
     $subject = Mime_Helper::decodeQuotedPrintable(@$structure->headers['subject']);
     $should_create_array = self::createIssueFromEmail($info, $headers, $message_body, $t['date'], $sender_email, $subject, $t['to'], $t['cc']);
     $should_create_issue = $should_create_array['should_create_issue'];
     if (!empty($should_create_array['issue_id'])) {
         $t['issue_id'] = $should_create_array['issue_id'];
         // figure out if we should change to a different email account
         $iss_prj_id = Issue::getProjectID($t['issue_id']);
         if ($info['ema_prj_id'] != $iss_prj_id) {
             $new_ema_id = Email_Account::getEmailAccount($iss_prj_id);
             if (!empty($new_ema_id)) {
                 $t['ema_id'] = $new_ema_id;
             }
         }
     }
     if (!empty($should_create_array['customer_id'])) {
         $t['customer_id'] = $should_create_array['customer_id'];
     }
     if (empty($t['issue_id'])) {
         $t['issue_id'] = 0;
     } else {
         $prj_id = Issue::getProjectID($t['issue_id']);
         Auth::createFakeCookie(APP_SYSTEM_USER_ID, $prj_id);
     }
     if ($should_create_array['type'] == 'note') {
         // assume that this is not a valid note
         $res = -1;
         if ($t['issue_id'] != 0) {
             // check if this is valid user
             $usr_id = User::getUserIDByEmail($sender_email);
             if (!empty($usr_id)) {
                 $role_id = User::getRoleByUser($usr_id, $prj_id);
                 if ($role_id > User::getRoleID('Customer')) {
                     // actually a valid user so insert the note
                     Auth::createFakeCookie($usr_id, $prj_id);
                     $users = Project::getUserEmailAssocList($prj_id, 'active', User::getRoleID('Customer'));
                     $user_emails = array_map(function ($s) {
                         return strtolower($s);
                     }, array_values($users));
                     $users = array_flip($users);
                     $addresses = array();
                     $to_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['to']);
                     if (count($to_addresses)) {
                         $addresses = $to_addresses;
                     }
                     $cc_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['cc']);
                     if (count($cc_addresses)) {
                         $addresses = array_merge($addresses, $cc_addresses);
                     }
                     $cc_users = array();
                     foreach ($addresses as $email) {
                         if (in_array(strtolower($email), $user_emails)) {
                             $cc_users[] = $users[strtolower($email)];
                         }
                     }
                     // XXX FIXME, this is not nice thing to do
                     $_POST = array('title' => Mail_Helper::removeExcessRe($t['subject']), 'note' => $t['body'], 'note_cc' => $cc_users, 'add_extra_recipients' => 'yes', 'message_id' => $t['message_id'], 'parent_id' => $should_create_array['parent_id']);
                     $res = Note::insertFromPost($usr_id, $t['issue_id']);
                     // need to handle attachments coming from notes as well
                     if ($res != -1) {
                         Support::extractAttachments($t['issue_id'], $structure, true, $res);
                     }
                 }
             }
         }
     } else {
         // check if we need to block this email
         if ($should_create_issue == true || !self::blockEmailIfNeeded($t)) {
             if (!empty($t['issue_id'])) {
                 list($t['full_email'], $t['headers']) = Mail_Helper::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], 'email');
             }
             // make variable available for workflow to be able to detect whether this email created new issue
             $t['should_create_issue'] = $should_create_array['should_create_issue'];
             $res = self::insertEmail($t, $structure, $sup_id);
             if ($res != -1) {
                 // only extract the attachments from the email if we are associating the email to an issue
                 if (!empty($t['issue_id'])) {
                     self::extractAttachments($t['issue_id'], $structure);
                     // notifications about new emails are always external
                     $internal_only = false;
                     $assignee_only = false;
                     // special case when emails are bounced back, so we don't want a notification to customers about those
                     if (Notification::isBounceMessage($sender_email)) {
                         // broadcast this email only to the assignees for this issue
                         $internal_only = true;
                         $assignee_only = true;
                     } elseif ($should_create_issue == true) {
                         // if a new issue was created, only send a copy of the email to the assignee (if any), don't resend to the original TO/CC list
                         $assignee_only = true;
                         $internal_only = true;
                     }
                     if (Workflow::shouldAutoAddToNotificationList($info['ema_prj_id'])) {
                         self::addExtraRecipientsToNotificationList($info['ema_prj_id'], $t, $should_create_issue);
                     }
                     if (self::isAllowedToEmail($t['issue_id'], $sender_email)) {
                         Notification::notifyNewEmail(Auth::getUserID(), $t['issue_id'], $t, $internal_only, $assignee_only, '', $sup_id);
                     }
                     // try to get usr_id of sender, if not, use system account
                     $addr = Mail_Helper::getEmailAddress($structure->headers['from']);
                     if (Misc::isError($addr)) {
                         // XXX should we log or is this expected?
                         Error_Handler::logError(array($addr->getMessage() . " addr: {$addr}", $addr->getDebugInfo()), __FILE__, __LINE__);
                         $usr_id = APP_SYSTEM_USER_ID;
                     } else {
                         $usr_id = User::getUserIDByEmail($addr);
                         if (!$usr_id) {
                             $usr_id = APP_SYSTEM_USER_ID;
                         }
                     }
                     // mark this issue as updated
                     if (!empty($t['customer_id']) && $t['customer_id'] != 'NULL' && (empty($usr_id) || User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer'))) {
                         Issue::markAsUpdated($t['issue_id'], 'customer action');
                     } else {
                         if (!empty($usr_id) && User::getRoleByUser($usr_id, $prj_id) > User::getRoleID('Customer')) {
                             Issue::markAsUpdated($t['issue_id'], 'staff response');
                         } else {
                             Issue::markAsUpdated($t['issue_id'], 'user response');
                         }
                     }
                     // log routed email
                     History::add($t['issue_id'], $usr_id, 'email_routed', 'Email routed from {from}', array('from' => $structure->headers['from']));
                 }
             }
         } else {
             $res = 1;
         }
     }
     if ($res > 0) {
         // need to delete the message from the server?
         if (!$info['ema_leave_copy']) {
             @imap_delete($mbox, $num);
         } else {
             // mark the message as already read
             @imap_setflag_full($mbox, $num, '\\Seen');
         }
     }
 }
Example #30
0
<?php 
if (count($rows) > 0) {
    ?>

  <table class="table table-hover">
    <thead>
    <tr>
      <!-- <th>ID</th> -->
      <th>Prénom</th>
      <th>Nom</th>
    </tr>
    </thead>
    <tbody>
  <?php 
    foreach ($rows as $row) {
        echo '<tr class="clickable" data-href="' . Routing::getUrlFor(array('module' => $module_code, 'action' => 'detail', 'id' => $row['id'])) . '">
        <!-- <td class="text-right">' . $row['id'] . '</td> -->
        <td>' . $row['first_name'] . '</td>
        <td>' . $row['last_name'] . '</td>
      </tr>' . "\n";
    }
    ?>
    </tbody>
  </table>
  
  <?php 
} else {
    ?>
  <p class="message text-info bg-info">Aucun joueur</p>
  <?php 
}