예제 #1
0
 /**
  *  Show linked object block.
  *
  *  @param	CommonObject	$object		Object we want to show links to
  *  @return	int							<0 if KO, >0 if OK
  */
 function showLinkedObjectBlock($object)
 {
     global $conf, $langs, $hookmanager;
     global $bc;
     $object->fetchObjectLinked();
     // Bypass the default method
     $hookmanager->initHooks(array('commonobject'));
     $parameters = array();
     $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action);
     // Note that $action and $object may have been modified by hook
     if (empty($reshook)) {
         $num = count($object->linkedObjects);
         foreach ($object->linkedObjects as $objecttype => $objects) {
             $tplpath = $element = $subelement = $objecttype;
             if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
                 $element = $regs[1];
                 $subelement = $regs[2];
                 $tplpath = $element . '/' . $subelement;
             }
             // To work with non standard path
             if ($objecttype == 'facture') {
                 $tplpath = 'compta/' . $element;
                 if (empty($conf->facture->enabled)) {
                     continue;
                 }
                 // Do not show if module disabled
             } else {
                 if ($objecttype == 'propal') {
                     $tplpath = 'comm/' . $element;
                     if (empty($conf->propal->enabled)) {
                         continue;
                     }
                     // Do not show if module disabled
                 } else {
                     if ($objecttype == 'supplier_proposal') {
                         $tplpath = 'comm/' . $element;
                         if (empty($conf->supplier_proposal->enabled)) {
                             continue;
                         }
                         // Do not show if module disabled
                     } else {
                         if ($objecttype == 'shipping' || $objecttype == 'shipment') {
                             $tplpath = 'expedition';
                             if (empty($conf->expedition->enabled)) {
                                 continue;
                             }
                             // Do not show if module disabled
                         } else {
                             if ($objecttype == 'delivery') {
                                 $tplpath = 'livraison';
                                 if (empty($conf->expedition->enabled)) {
                                     continue;
                                 }
                                 // Do not show if module disabled
                             } else {
                                 if ($objecttype == 'invoice_supplier') {
                                     $tplpath = 'fourn/facture';
                                 } else {
                                     if ($objecttype == 'order_supplier') {
                                         $tplpath = 'fourn/commande';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             global $linkedObjectBlock;
             $linkedObjectBlock = $objects;
             // Output template part (modules that overwrite templates must declare this into descriptor)
             $dirtpls = array_merge($conf->modules_parts['tpl'], array('/' . $tplpath . '/tpl'));
             foreach ($dirtpls as $reldir) {
                 $res = @(include dol_buildpath($reldir . '/linkedobjectblock.tpl.php'));
                 if ($res) {
                     break;
                 }
             }
         }
         return $num;
     }
 }