/**
 * $Id$
 *  
 * @category Forms
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$event_name = CValue::post("event_name");
$object_class = CValue::post("object_class");
$form_name = CValue::post("form_name");
$ids = CValue::post("ids");
CSessionHandler::writeClose();
//CExObject::$_load_lite = true;
$ex_class_event = new CExClassEvent();
$ds = $ex_class_event->getDS();
$group_id = CGroups::loadCurrent()->_id;
$where = array("ex_class_event.host_class" => $ds->prepare("=%", $object_class), "ex_class_event.event_name" => $ds->prepare("=%", $event_name), "ex_class.conditional" => $ds->prepare("=%", 0), $ds->prepare("ex_class.group_id = % OR ex_class.group_id IS NULL", $group_id));
$ljoin = array("ex_class" => "ex_class.ex_class_id = ex_class_event.ex_class_id");
/** @var CExClassEvent[] $ex_class_events */
$ex_class_events = $ex_class_event->loadList($where, null, null, null, $ljoin);
$ex_classes = array();
$ex_objects = array();
$count_available = count($ex_class_events);
foreach ($ex_class_events as $_ex_class_event) {
    $_ex_class = $_ex_class_event->loadRefExClass();
    $_ex_class->getFormulaField();
    $ex_classes[$_ex_class->_id] = $_ex_class;
Exemple #2
0
 /**
  * Send the request on the server
  *
  * @param String   $url  URL
  * @param String[] $post Parameters POST
  *
  * @return bool|string
  */
 static function serverCall($url, $post = null)
 {
     CSessionHandler::writeClose();
     global $rootName, $version;
     $session_name = preg_replace("/[^a-z0-9]/i", "", $rootName);
     $cookie = CValue::cookie($session_name);
     $result = array("code" => "", "body" => "");
     try {
         $http_client = new CHTTPClient($url);
         $http_client->setCookie("{$session_name}={$cookie}");
         $http_client->setUserAgent("Mediboard-" . $version["version"]);
         $http_client->setOption(CURLOPT_FOLLOWLOCATION, true);
         if ($post) {
             $request = $http_client->post(http_build_query($post));
         } else {
             $request = $http_client->get();
         }
     } catch (Exception $e) {
         CSessionHandler::start();
         $result["body"] = $e->getMessage();
         return $result;
     }
     CSessionHandler::start();
     $result["code"] = $http_client->last_information["http_code"];
     $result["body"] = $request;
     return $result;
 }
 /**
  * PDF conversion of a file
  *
  * @param string $file_path path to the file
  * @param string $pdf_path  path the pdf file
  *
  * @return bool
  */
 function convertToPDF($file_path = null, $pdf_path = null)
 {
     global $rootName;
     // Vérifier si openoffice est lancé
     if (!CFile::openofficeLaunched()) {
         return 0;
     }
     // Vérifier sa charge en mémoire
     CFile::openofficeOverload();
     if (!$file_path && !$pdf_path) {
         $file = new CFile();
         $file->setObject($this);
         $file->private = $this->private;
         $file->file_name = $this->file_name . ".pdf";
         $file->file_type = "application/pdf";
         $file->author_id = CAppUI::$user->_id;
         $file->fillFields();
         $file->updateFormFields();
         $file->forceDir();
         $save_name = $this->_file_path;
         if ($msg = $file->store()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
             return 0;
         }
         $file_path = $this->_file_path;
         $pdf_path = $file->_file_path;
     }
     // Requête post pour la conversion.
     // Cela permet de mettre un time limit afin de garder le contrôle de la conversion.
     ini_set("default_socket_timeout", 10);
     $fileContents = base64_encode(file_get_contents($file_path));
     $url = CAppUI::conf("base_url") . "/index.php?m=dPfiles&a=ajax_ooo_convert&suppressHeaders=1";
     $data = array("file_data" => $fileContents, "pdf_path" => $pdf_path);
     // Fermeture de la session afin d'écrire dans le fichier de session
     CSessionHandler::writeClose();
     // Le header Connection: close permet de forcer a couper la connexion lorsque la requête est effectuée
     $ctx = stream_context_create(array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded charset=UTF-8\r\n" . "Connection: close\r\n" . "Cookie: mediboard=" . session_id() . "\r\n", 'content' => http_build_query($data))));
     // La requête post réouvre la session
     $res = file_get_contents($url, false, $ctx);
     if (isset($file) && $res == 1) {
         $file->doc_size = filesize($pdf_path);
         if ($msg = $file->store()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
             return 0;
         }
     }
     // Si la conversion a échoué
     // on relance le service s'il ne répond plus.
     if ($res != 1) {
         CFile::openofficeOverload(1);
     }
     return $res;
 }
Exemple #4
0
 /**
  * Enable the current view to forced to slave based on a enslaving ratio
  *
  * @return void
  */
 static function enableSlave()
 {
     // Enslaved views are supposably session stallers so close session preventively
     CSessionHandler::writeClose();
     if (rand(0, 100) < CAppUI::conf("enslaving_ratio")) {
         self::enforceSlave();
         return;
     }
 }