@@ -19,7 +19,6 @@ |
||
| 19 | 19 | use Luracast\Restler\Restler; |
| 20 | 20 | use Luracast\Restler\RestException; |
| 21 | 21 | use Luracast\Restler\Defaults; |
| 22 | -use Luracast\Restler\Format\UploadFormat; |
|
| 23 | 22 | |
| 24 | 23 | require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; |
| 25 | 24 | |
@@ -29,52 +29,52 @@ discard block |
||
| 29 | 29 | class DolibarrApi |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var DoliDb $db Database object |
|
| 34 | - */ |
|
| 35 | - static protected $db; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var Restler $r Restler object |
|
| 39 | - */ |
|
| 40 | - var $r; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Constructor |
|
| 44 | - * |
|
| 45 | - * @param DoliDb $db Database handler |
|
| 46 | - * @param string $cachedir Cache dir |
|
| 47 | - * @param boolean $refreshCache Update cache |
|
| 48 | - */ |
|
| 49 | - function __construct($db, $cachedir='', $refreshCache=false) |
|
| 50 | - { |
|
| 51 | - global $conf, $dolibarr_main_url_root; |
|
| 32 | + /** |
|
| 33 | + * @var DoliDb $db Database object |
|
| 34 | + */ |
|
| 35 | + static protected $db; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var Restler $r Restler object |
|
| 39 | + */ |
|
| 40 | + var $r; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Constructor |
|
| 44 | + * |
|
| 45 | + * @param DoliDb $db Database handler |
|
| 46 | + * @param string $cachedir Cache dir |
|
| 47 | + * @param boolean $refreshCache Update cache |
|
| 48 | + */ |
|
| 49 | + function __construct($db, $cachedir='', $refreshCache=false) |
|
| 50 | + { |
|
| 51 | + global $conf, $dolibarr_main_url_root; |
|
| 52 | 52 | |
| 53 | - if (empty($cachedir)) $cachedir = $conf->api->dir_temp; |
|
| 54 | - Defaults::$cacheDirectory = $cachedir; |
|
| 53 | + if (empty($cachedir)) $cachedir = $conf->api->dir_temp; |
|
| 54 | + Defaults::$cacheDirectory = $cachedir; |
|
| 55 | 55 | |
| 56 | - $this->db = $db; |
|
| 57 | - $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); |
|
| 58 | - $this->r = new Restler($production_mode, $refreshCache); |
|
| 56 | + $this->db = $db; |
|
| 57 | + $production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true ); |
|
| 58 | + $this->r = new Restler($production_mode, $refreshCache); |
|
| 59 | 59 | |
| 60 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
| 61 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 60 | + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
| 61 | + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
| 62 | 62 | |
| 63 | - $urlwithouturlrootautodetect=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim(DOL_MAIN_URL_ROOT)); |
|
| 64 | - $urlwithrootautodetect=$urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url |
|
| 63 | + $urlwithouturlrootautodetect=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim(DOL_MAIN_URL_ROOT)); |
|
| 64 | + $urlwithrootautodetect=$urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url |
|
| 65 | 65 | |
| 66 | - $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); |
|
| 67 | - $this->r->setAPIVersion(1); |
|
| 68 | - } |
|
| 66 | + $this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect); |
|
| 67 | + $this->r->setAPIVersion(1); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Executed method when API is called without parameter |
|
| 72 | - * |
|
| 73 | - * Display a short message an return a http code 200 |
|
| 74 | - * |
|
| 75 | - * @return array |
|
| 76 | - */ |
|
| 77 | - /* Disabled, most APIs does not share same signature for method index |
|
| 70 | + /** |
|
| 71 | + * Executed method when API is called without parameter |
|
| 72 | + * |
|
| 73 | + * Display a short message an return a http code 200 |
|
| 74 | + * |
|
| 75 | + * @return array |
|
| 76 | + */ |
|
| 77 | + /* Disabled, most APIs does not share same signature for method index |
|
| 78 | 78 | function index() |
| 79 | 79 | { |
| 80 | 80 | return array( |
@@ -86,81 +86,81 @@ discard block |
||
| 86 | 86 | }*/ |
| 87 | 87 | |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Clean sensible object datas |
|
| 91 | - * |
|
| 92 | - * @param object $object Object to clean |
|
| 93 | - * @return array Array of cleaned object properties |
|
| 94 | - */ |
|
| 95 | - function _cleanObjectDatas($object) { |
|
| 96 | - |
|
| 97 | - // Remove $db object property for object |
|
| 98 | - unset($object->db); |
|
| 99 | - |
|
| 100 | - // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses |
|
| 101 | - unset($object->linkedObjects); |
|
| 102 | - |
|
| 103 | - unset($object->lines); // should be ->lines |
|
| 104 | - |
|
| 105 | - unset($object->fields); |
|
| 106 | - |
|
| 107 | - unset($object->oldline); |
|
| 108 | - |
|
| 109 | - unset($object->error); |
|
| 110 | - unset($object->errors); |
|
| 111 | - |
|
| 112 | - unset($object->ref_previous); |
|
| 113 | - unset($object->ref_next); |
|
| 114 | - unset($object->ref_int); |
|
| 115 | - |
|
| 116 | - unset($object->projet); // Should be fk_project |
|
| 117 | - unset($object->project); // Should be fk_project |
|
| 118 | - unset($object->author); // Should be fk_user_author |
|
| 119 | - unset($object->timespent_old_duration); |
|
| 120 | - unset($object->timespent_id); |
|
| 121 | - unset($object->timespent_duration); |
|
| 122 | - unset($object->timespent_date); |
|
| 123 | - unset($object->timespent_datehour); |
|
| 124 | - unset($object->timespent_withhour); |
|
| 125 | - unset($object->timespent_fk_user); |
|
| 126 | - unset($object->timespent_note); |
|
| 127 | - |
|
| 128 | - unset($object->statuts); |
|
| 129 | - unset($object->statuts_short); |
|
| 130 | - unset($object->statuts_logo); |
|
| 131 | - unset($object->statuts_long); |
|
| 132 | - |
|
| 133 | - unset($object->element); |
|
| 134 | - unset($object->fk_element); |
|
| 135 | - unset($object->table_element); |
|
| 136 | - unset($object->table_element_line); |
|
| 137 | - unset($object->picto); |
|
| 138 | - |
|
| 139 | - unset($object->skip_update_total); |
|
| 140 | - unset($object->context); |
|
| 141 | - |
|
| 142 | - // Remove the $oldcopy property because it is not supported by the JSON |
|
| 143 | - // encoder. The following error is generated when trying to serialize |
|
| 144 | - // it: "Error encoding/decoding JSON: Type is not supported" |
|
| 145 | - // Note: Event if this property was correctly handled by the JSON |
|
| 146 | - // encoder, it should be ignored because keeping it would let the API |
|
| 147 | - // have a very strange behavior: calling PUT and then GET on the same |
|
| 148 | - // resource would give different results: |
|
| 149 | - // PUT /objects/{id} -> returns object with oldcopy = previous version of the object |
|
| 150 | - // GET /objects/{id} -> returns object with oldcopy empty |
|
| 151 | - unset($object->oldcopy); |
|
| 152 | - |
|
| 153 | - // If object has lines, remove $db property |
|
| 154 | - if(isset($object->lines) && count($object->lines) > 0) { |
|
| 155 | - $nboflines = count($object->lines); |
|
| 156 | - for ($i=0; $i < $nboflines; $i++) |
|
| 157 | - { |
|
| 158 | - $this->_cleanObjectDatas($object->lines[$i]); |
|
| 159 | - } |
|
| 160 | - } |
|
| 89 | + /** |
|
| 90 | + * Clean sensible object datas |
|
| 91 | + * |
|
| 92 | + * @param object $object Object to clean |
|
| 93 | + * @return array Array of cleaned object properties |
|
| 94 | + */ |
|
| 95 | + function _cleanObjectDatas($object) { |
|
| 96 | + |
|
| 97 | + // Remove $db object property for object |
|
| 98 | + unset($object->db); |
|
| 99 | + |
|
| 100 | + // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses |
|
| 101 | + unset($object->linkedObjects); |
|
| 102 | + |
|
| 103 | + unset($object->lines); // should be ->lines |
|
| 104 | + |
|
| 105 | + unset($object->fields); |
|
| 106 | + |
|
| 107 | + unset($object->oldline); |
|
| 108 | + |
|
| 109 | + unset($object->error); |
|
| 110 | + unset($object->errors); |
|
| 111 | + |
|
| 112 | + unset($object->ref_previous); |
|
| 113 | + unset($object->ref_next); |
|
| 114 | + unset($object->ref_int); |
|
| 115 | + |
|
| 116 | + unset($object->projet); // Should be fk_project |
|
| 117 | + unset($object->project); // Should be fk_project |
|
| 118 | + unset($object->author); // Should be fk_user_author |
|
| 119 | + unset($object->timespent_old_duration); |
|
| 120 | + unset($object->timespent_id); |
|
| 121 | + unset($object->timespent_duration); |
|
| 122 | + unset($object->timespent_date); |
|
| 123 | + unset($object->timespent_datehour); |
|
| 124 | + unset($object->timespent_withhour); |
|
| 125 | + unset($object->timespent_fk_user); |
|
| 126 | + unset($object->timespent_note); |
|
| 127 | + |
|
| 128 | + unset($object->statuts); |
|
| 129 | + unset($object->statuts_short); |
|
| 130 | + unset($object->statuts_logo); |
|
| 131 | + unset($object->statuts_long); |
|
| 132 | + |
|
| 133 | + unset($object->element); |
|
| 134 | + unset($object->fk_element); |
|
| 135 | + unset($object->table_element); |
|
| 136 | + unset($object->table_element_line); |
|
| 137 | + unset($object->picto); |
|
| 138 | + |
|
| 139 | + unset($object->skip_update_total); |
|
| 140 | + unset($object->context); |
|
| 141 | + |
|
| 142 | + // Remove the $oldcopy property because it is not supported by the JSON |
|
| 143 | + // encoder. The following error is generated when trying to serialize |
|
| 144 | + // it: "Error encoding/decoding JSON: Type is not supported" |
|
| 145 | + // Note: Event if this property was correctly handled by the JSON |
|
| 146 | + // encoder, it should be ignored because keeping it would let the API |
|
| 147 | + // have a very strange behavior: calling PUT and then GET on the same |
|
| 148 | + // resource would give different results: |
|
| 149 | + // PUT /objects/{id} -> returns object with oldcopy = previous version of the object |
|
| 150 | + // GET /objects/{id} -> returns object with oldcopy empty |
|
| 151 | + unset($object->oldcopy); |
|
| 152 | + |
|
| 153 | + // If object has lines, remove $db property |
|
| 154 | + if(isset($object->lines) && count($object->lines) > 0) { |
|
| 155 | + $nboflines = count($object->lines); |
|
| 156 | + for ($i=0; $i < $nboflines; $i++) |
|
| 157 | + { |
|
| 158 | + $this->_cleanObjectDatas($object->lines[$i]); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - // If object has linked objects, remove $db property |
|
| 163 | - /* |
|
| 162 | + // If object has linked objects, remove $db property |
|
| 163 | + /* |
|
| 164 | 164 | if(isset($object->linkedObjects) && count($object->linkedObjects) > 0) { |
| 165 | 165 | foreach($object->linkedObjects as $type_object => $linked_object) { |
| 166 | 166 | foreach($linked_object as $object2clean) { |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | }*/ |
| 171 | 171 | |
| 172 | 172 | return $object; |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Check user access to a resource |
@@ -212,25 +212,25 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | function _checkFilters($sqlfilters) |
| 214 | 214 | { |
| 215 | - //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 216 | - //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); |
|
| 217 | - $tmp=$sqlfilters; |
|
| 218 | - $ok=0; |
|
| 219 | - $i=0; $nb=count($tmp); |
|
| 220 | - $counter=0; |
|
| 221 | - while ($i < $nb) |
|
| 222 | - { |
|
| 223 | - if ($tmp[$i]=='(') $counter++; |
|
| 224 | - if ($tmp[$i]==')') $counter--; |
|
| 225 | - if ($counter < 0) |
|
| 226 | - { |
|
| 227 | - $error="Bad sqlfilters=".$sqlfilters; |
|
| 228 | - dol_syslog($error, LOG_WARNING); |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - $i++; |
|
| 232 | - } |
|
| 233 | - return true; |
|
| 215 | + //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; |
|
| 216 | + //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); |
|
| 217 | + $tmp=$sqlfilters; |
|
| 218 | + $ok=0; |
|
| 219 | + $i=0; $nb=count($tmp); |
|
| 220 | + $counter=0; |
|
| 221 | + while ($i < $nb) |
|
| 222 | + { |
|
| 223 | + if ($tmp[$i]=='(') $counter++; |
|
| 224 | + if ($tmp[$i]==')') $counter--; |
|
| 225 | + if ($counter < 0) |
|
| 226 | + { |
|
| 227 | + $error="Bad sqlfilters=".$sqlfilters; |
|
| 228 | + dol_syslog($error, LOG_WARNING); |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + $i++; |
|
| 232 | + } |
|
| 233 | + return true; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -241,22 +241,22 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | static function _forge_criteria_callback($matches) |
| 243 | 243 | { |
| 244 | - global $db; |
|
| 245 | - |
|
| 246 | - //dol_syslog("Convert matches ".$matches[1]); |
|
| 247 | - if (empty($matches[1])) return ''; |
|
| 248 | - $tmp=explode(':',$matches[1]); |
|
| 249 | - if (count($tmp) < 3) return ''; |
|
| 250 | - |
|
| 251 | - $tmpescaped=$tmp[2]; |
|
| 252 | - if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) |
|
| 253 | - { |
|
| 254 | - $tmpescaped = "'".$db->escape($regbis[1])."'"; |
|
| 255 | - } |
|
| 256 | - else |
|
| 257 | - { |
|
| 258 | - $tmpescaped = $db->escape($tmpescaped); |
|
| 259 | - } |
|
| 260 | - return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; |
|
| 244 | + global $db; |
|
| 245 | + |
|
| 246 | + //dol_syslog("Convert matches ".$matches[1]); |
|
| 247 | + if (empty($matches[1])) return ''; |
|
| 248 | + $tmp=explode(':',$matches[1]); |
|
| 249 | + if (count($tmp) < 3) return ''; |
|
| 250 | + |
|
| 251 | + $tmpescaped=$tmp[2]; |
|
| 252 | + if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) |
|
| 253 | + { |
|
| 254 | + $tmpescaped = "'".$db->escape($regbis[1])."'"; |
|
| 255 | + } |
|
| 256 | + else |
|
| 257 | + { |
|
| 258 | + $tmpescaped = $db->escape($tmpescaped); |
|
| 259 | + } |
|
| 260 | + return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped; |
|
| 261 | 261 | } |
| 262 | 262 | } |
@@ -18,7 +18,6 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | use Luracast\Restler\RestException; |
| 21 | -use Luracast\Restler\Format\UploadFormat; |
|
| 22 | 21 | |
| 23 | 22 | |
| 24 | 23 | require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; |
@@ -33,49 +33,49 @@ discard block |
||
| 33 | 33 | class Documents extends DolibarrApi |
| 34 | 34 | { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object |
|
| 38 | - */ |
|
| 39 | - static $DOCUMENT_FIELDS = array( |
|
| 40 | - 'modulepart' |
|
| 41 | - ); |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Constructor |
|
| 45 | - */ |
|
| 46 | - function __construct() |
|
| 47 | - { |
|
| 48 | - global $db; |
|
| 49 | - $this->db = $db; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download |
|
| 55 | - * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). |
|
| 56 | - * |
|
| 57 | - * @param string $module_part Name of module or area concerned by file download ('facture', ...) |
|
| 58 | - * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) |
|
| 59 | - * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. |
|
| 60 | - * Also, note that setting this to 1 nead write access on object. |
|
| 61 | - * @return array List of documents |
|
| 62 | - * |
|
| 63 | - * @throws 500 |
|
| 64 | - * @throws 501 |
|
| 65 | - * @throws 400 |
|
| 66 | - * @throws 401 |
|
| 67 | - * @throws 200 |
|
| 68 | - */ |
|
| 69 | - public function index($module_part, $original_file='', $regeneratedoc=0) |
|
| 70 | - { |
|
| 36 | + /** |
|
| 37 | + * @var array $DOCUMENT_FIELDS Mandatory fields, checked when create and update object |
|
| 38 | + */ |
|
| 39 | + static $DOCUMENT_FIELDS = array( |
|
| 40 | + 'modulepart' |
|
| 41 | + ); |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Constructor |
|
| 45 | + */ |
|
| 46 | + function __construct() |
|
| 47 | + { |
|
| 48 | + global $db; |
|
| 49 | + $this->db = $db; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download |
|
| 55 | + * a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie). |
|
| 56 | + * |
|
| 57 | + * @param string $module_part Name of module or area concerned by file download ('facture', ...) |
|
| 58 | + * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) |
|
| 59 | + * @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases. |
|
| 60 | + * Also, note that setting this to 1 nead write access on object. |
|
| 61 | + * @return array List of documents |
|
| 62 | + * |
|
| 63 | + * @throws 500 |
|
| 64 | + * @throws 501 |
|
| 65 | + * @throws 400 |
|
| 66 | + * @throws 401 |
|
| 67 | + * @throws 200 |
|
| 68 | + */ |
|
| 69 | + public function index($module_part, $original_file='', $regeneratedoc=0) |
|
| 70 | + { |
|
| 71 | 71 | global $conf; |
| 72 | 72 | |
| 73 | 73 | if (empty($module_part)) { |
| 74 | - throw new RestException(400, 'bad value for parameter modulepart'); |
|
| 74 | + throw new RestException(400, 'bad value for parameter modulepart'); |
|
| 75 | + } |
|
| 76 | + if (empty($original_file)) { |
|
| 77 | + throw new RestException(400, 'bad value for parameter ref or subdir'); |
|
| 75 | 78 | } |
| 76 | - if (empty($original_file)) { |
|
| 77 | - throw new RestException(400, 'bad value for parameter ref or subdir'); |
|
| 78 | - } |
|
| 79 | 79 | |
| 80 | 80 | //--- Finds and returns the document |
| 81 | 81 | $entity=$conf->entity; |
@@ -87,94 +87,94 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) |
| 89 | 89 | { |
| 90 | - throw new RestException(401); |
|
| 90 | + throw new RestException(401); |
|
| 91 | + } |
|
| 92 | + if (!$accessallowed) { |
|
| 93 | + throw new RestException(401); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // --- Generates the document |
|
| 97 | + if ($regeneratedoc) |
|
| 98 | + { |
|
| 99 | + $hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1; |
|
| 100 | + $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; |
|
| 101 | + $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; |
|
| 102 | + |
|
| 103 | + if ($module_part == 'facture' || $module_part == 'invoice') |
|
| 104 | + { |
|
| 105 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 106 | + $this->invoice = new Facture($this->db); |
|
| 107 | + $result = $this->invoice->fetch(0, $ref); |
|
| 108 | + if( ! $result ) { |
|
| 109 | + throw new RestException(404, 'Invoice not found'); |
|
| 110 | + } |
|
| 111 | + $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 112 | + if( $result <= 0 ) { |
|
| 113 | + throw new RestException(500, 'Error generating document'); |
|
| 114 | + } |
|
| 115 | + } |
|
| 91 | 116 | } |
| 92 | - if (!$accessallowed) { |
|
| 93 | - throw new RestException(401); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // --- Generates the document |
|
| 97 | - if ($regeneratedoc) |
|
| 98 | - { |
|
| 99 | - $hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1; |
|
| 100 | - $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; |
|
| 101 | - $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; |
|
| 102 | - |
|
| 103 | - if ($module_part == 'facture' || $module_part == 'invoice') |
|
| 104 | - { |
|
| 105 | - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
|
| 106 | - $this->invoice = new Facture($this->db); |
|
| 107 | - $result = $this->invoice->fetch(0, $ref); |
|
| 108 | - if( ! $result ) { |
|
| 109 | - throw new RestException(404, 'Invoice not found'); |
|
| 110 | - } |
|
| 111 | - $result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 112 | - if( $result <= 0 ) { |
|
| 113 | - throw new RestException(500, 'Error generating document'); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | 117 | |
| 118 | 118 | $filename = basename($original_file); |
| 119 | 119 | $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset |
| 120 | 120 | |
| 121 | 121 | if (! file_exists($original_file_osencoded)) |
| 122 | 122 | { |
| 123 | - throw new RestException(404, 'File not found'); |
|
| 123 | + throw new RestException(404, 'File not found'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $file_content=file_get_contents($original_file_osencoded); |
| 127 | - return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Return a document. |
|
| 133 | - * |
|
| 134 | - * @param int $id ID of document |
|
| 135 | - * @return array Array with data of file |
|
| 136 | - * |
|
| 137 | - * @throws RestException |
|
| 138 | - */ |
|
| 139 | - /* |
|
| 127 | + return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' ); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Return a document. |
|
| 133 | + * |
|
| 134 | + * @param int $id ID of document |
|
| 135 | + * @return array Array with data of file |
|
| 136 | + * |
|
| 137 | + * @throws RestException |
|
| 138 | + */ |
|
| 139 | + /* |
|
| 140 | 140 | public function get($id) { |
| 141 | 141 | return array('note'=>'xxx'); |
| 142 | 142 | }*/ |
| 143 | 143 | |
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Push a file. |
|
| 147 | - * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
| 148 | - * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
| 149 | - * |
|
| 150 | - * @param string $filename Name of file to create ('FA1705-0123') |
|
| 151 | - * @param string $modulepart Name of module or area concerned by file upload ('facture', ...) |
|
| 152 | - * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) |
|
| 153 | - * @param string $subdir Subdirectory (Only if ref not provided) |
|
| 154 | - * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) |
|
| 155 | - * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) |
|
| 156 | - * @param int $overwriteifexists Overwrite file if exists (1 by default) |
|
| 157 | - * @return bool State of copy |
|
| 158 | - * @throws RestException |
|
| 159 | - */ |
|
| 160 | - public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) |
|
| 161 | - { |
|
| 162 | - global $db, $conf; |
|
| 163 | - |
|
| 164 | - /*var_dump($modulepart); |
|
| 145 | + /** |
|
| 146 | + * Push a file. |
|
| 147 | + * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
| 148 | + * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. |
|
| 149 | + * |
|
| 150 | + * @param string $filename Name of file to create ('FA1705-0123') |
|
| 151 | + * @param string $modulepart Name of module or area concerned by file upload ('facture', ...) |
|
| 152 | + * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) |
|
| 153 | + * @param string $subdir Subdirectory (Only if ref not provided) |
|
| 154 | + * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) |
|
| 155 | + * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) |
|
| 156 | + * @param int $overwriteifexists Overwrite file if exists (1 by default) |
|
| 157 | + * @return bool State of copy |
|
| 158 | + * @throws RestException |
|
| 159 | + */ |
|
| 160 | + public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) |
|
| 161 | + { |
|
| 162 | + global $db, $conf; |
|
| 163 | + |
|
| 164 | + /*var_dump($modulepart); |
|
| 165 | 165 | var_dump($filename); |
| 166 | 166 | var_dump($filecontent); |
| 167 | 167 | exit;*/ |
| 168 | 168 | |
| 169 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 169 | + require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 170 | 170 | |
| 171 | - if (!DolibarrApiAccess::$user->rights->ecm->upload) { |
|
| 172 | - throw new RestException(401); |
|
| 173 | - } |
|
| 171 | + if (!DolibarrApiAccess::$user->rights->ecm->upload) { |
|
| 172 | + throw new RestException(401); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - $newfilecontent = ''; |
|
| 176 | - if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
| 177 | - if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
| 175 | + $newfilecontent = ''; |
|
| 176 | + if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
| 177 | + if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
| 178 | 178 | |
| 179 | 179 | $original_file = dol_sanitizeFileName($filename); |
| 180 | 180 | |
@@ -183,37 +183,37 @@ discard block |
||
| 183 | 183 | $entity = $user->entity; |
| 184 | 184 | if ($ref) |
| 185 | 185 | { |
| 186 | - if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
| 187 | - { |
|
| 188 | - $modulepart='facture'; |
|
| 189 | - $object=new Facture($db); |
|
| 190 | - $result = $object->fetch('', $ref); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - if (! ($object->id > 0)) |
|
| 194 | - { |
|
| 195 | - throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); |
|
| 199 | - $upload_dir = $tmp['original_file']; |
|
| 200 | - |
|
| 201 | - if (empty($upload_dir) || $upload_dir == '/') |
|
| 202 | - { |
|
| 203 | - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
| 204 | - } |
|
| 186 | + if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
| 187 | + { |
|
| 188 | + $modulepart='facture'; |
|
| 189 | + $object=new Facture($db); |
|
| 190 | + $result = $object->fetch('', $ref); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + if (! ($object->id > 0)) |
|
| 194 | + { |
|
| 195 | + throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found."); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + $tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write'); |
|
| 199 | + $upload_dir = $tmp['original_file']; |
|
| 200 | + |
|
| 201 | + if (empty($upload_dir) || $upload_dir == '/') |
|
| 202 | + { |
|
| 203 | + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
| 204 | + } |
|
| 205 | 205 | } |
| 206 | 206 | else |
| 207 | 207 | { |
| 208 | - if ($modulepart == 'invoice') $modulepart ='facture'; |
|
| 208 | + if ($modulepart == 'invoice') $modulepart ='facture'; |
|
| 209 | 209 | |
| 210 | - $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); |
|
| 211 | - $upload_dir = $tmp['original_file']; |
|
| 210 | + $tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write'); |
|
| 211 | + $upload_dir = $tmp['original_file']; |
|
| 212 | 212 | |
| 213 | - if (empty($upload_dir) || $upload_dir == '/') |
|
| 214 | - { |
|
| 215 | - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
| 216 | - } |
|
| 213 | + if (empty($upload_dir) || $upload_dir == '/') |
|
| 214 | + { |
|
| 215 | + throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
|
| 216 | + } |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
@@ -223,46 +223,46 @@ discard block |
||
| 223 | 223 | $destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file; |
| 224 | 224 | dol_delete_file($destfiletmp); |
| 225 | 225 | |
| 226 | - if (!dol_is_dir($upload_dir)) { |
|
| 227 | - throw new RestException(401,'Directory not exists : '.$upload_dir); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - if (! $overwriteifexists && dol_is_file($destfile)) |
|
| 231 | - { |
|
| 232 | - throw new RestException(500, "File with name '".$original_file."' already exists."); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - $fhandle = @fopen($destfiletmp, 'w'); |
|
| 236 | - if ($fhandle) |
|
| 237 | - { |
|
| 238 | - $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
|
| 239 | - fclose($fhandle); |
|
| 240 | - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
|
| 241 | - } |
|
| 242 | - else |
|
| 243 | - { |
|
| 244 | - throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); |
|
| 248 | - |
|
| 249 | - return $result; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Validate fields before create or update object |
|
| 254 | - * |
|
| 255 | - * @param array $data Array with data to verify |
|
| 256 | - * @return array |
|
| 257 | - * @throws RestException |
|
| 258 | - */ |
|
| 259 | - function _validate_file($data) { |
|
| 260 | - $result = array(); |
|
| 261 | - foreach (Documents::$DOCUMENT_FIELDS as $field) { |
|
| 262 | - if (!isset($data[$field])) |
|
| 263 | - throw new RestException(400, "$field field missing"); |
|
| 264 | - $result[$field] = $data[$field]; |
|
| 265 | - } |
|
| 266 | - return $result; |
|
| 267 | - } |
|
| 226 | + if (!dol_is_dir($upload_dir)) { |
|
| 227 | + throw new RestException(401,'Directory not exists : '.$upload_dir); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + if (! $overwriteifexists && dol_is_file($destfile)) |
|
| 231 | + { |
|
| 232 | + throw new RestException(500, "File with name '".$original_file."' already exists."); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + $fhandle = @fopen($destfiletmp, 'w'); |
|
| 236 | + if ($fhandle) |
|
| 237 | + { |
|
| 238 | + $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
|
| 239 | + fclose($fhandle); |
|
| 240 | + @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
|
| 241 | + } |
|
| 242 | + else |
|
| 243 | + { |
|
| 244 | + throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); |
|
| 248 | + |
|
| 249 | + return $result; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Validate fields before create or update object |
|
| 254 | + * |
|
| 255 | + * @param array $data Array with data to verify |
|
| 256 | + * @return array |
|
| 257 | + * @throws RestException |
|
| 258 | + */ |
|
| 259 | + function _validate_file($data) { |
|
| 260 | + $result = array(); |
|
| 261 | + foreach (Documents::$DOCUMENT_FIELDS as $field) { |
|
| 262 | + if (!isset($data[$field])) |
|
| 263 | + throw new RestException(400, "$field field missing"); |
|
| 264 | + $result[$field] = $data[$field]; |
|
| 265 | + } |
|
| 266 | + return $result; |
|
| 267 | + } |
|
| 268 | 268 | } |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | // Complete long filename |
| 109 | 109 | foreach ($filters as $key => $value) |
| 110 | 110 | { |
| 111 | - //if ($key == 'notolderthan') $filename.='-notolderthan'.$value; This filter key is already added before and does not need to be in filename |
|
| 111 | + //if ($key == 'notolderthan') $filename.='-notolderthan'.$value; This filter key is already added before and does not need to be in filename |
|
| 112 | 112 | if ($key == 'year') $filename.='-year'.$value; |
| 113 | - if ($key == 'id') $filename.='-id'.$value; |
|
| 114 | - if ($key == 'idfrom') $filename.='-idfrom'.$value; |
|
| 115 | - if ($key == 'idto') $filename.='-idto'.$value; |
|
| 116 | - if ($key == 'project') $filename.='-project'.$value; |
|
| 113 | + if ($key == 'id') $filename.='-id'.$value; |
|
| 114 | + if ($key == 'idfrom') $filename.='-idfrom'.$value; |
|
| 115 | + if ($key == 'idto') $filename.='-idto'.$value; |
|
| 116 | + if ($key == 'project') $filename.='-project'.$value; |
|
| 117 | 117 | if ($key == 'logina') $filename.='-logina'.$value; // Author |
| 118 | 118 | if ($key == 'logint') $filename.='-logint'.$value; // Assigned to |
| 119 | 119 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $langs->load("main"); |
| 128 | 128 | $langs->load("errors"); |
| 129 | 129 | llxHeaderVierge(); |
| 130 | - print '<div class="error">'.$langs->trans("ErrorWrongValueForParameterX",'format').'</div>'; |
|
| 130 | + print '<div class="error">'.$langs->trans("ErrorWrongValueForParameterX",'format').'</div>'; |
|
| 131 | 131 | llxFooterVierge(); |
| 132 | 132 | exit; |
| 133 | 133 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $result=readfile($outputfile); |
| 163 | 163 | if (! $result) print 'File '.$outputfile.' was empty.'; |
| 164 | 164 | |
| 165 | - //header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); |
|
| 165 | + //header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); |
|
| 166 | 166 | exit; |
| 167 | 167 | } |
| 168 | 168 | else |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | */ |
| 153 | 153 | function llxFooterVierge() |
| 154 | 154 | { |
| 155 | - printCommonFooter('public'); |
|
| 155 | + printCommonFooter('public'); |
|
| 156 | 156 | |
| 157 | 157 | print "</body>\n"; |
| 158 | 158 | print "</html>\n"; |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | header("Content-type: text/html; charset=".$conf->file->character_set_client); |
| 60 | 60 | print "<html>\n"; |
| 61 | - print "<head>\n"; |
|
| 62 | - print "<title>".$title."</title>\n"; |
|
| 63 | - if ($head) print $head."\n"; |
|
| 64 | - print "</head>\n"; |
|
| 61 | + print "<head>\n"; |
|
| 62 | + print "<title>".$title."</title>\n"; |
|
| 63 | + if ($head) print $head."\n"; |
|
| 64 | + print "</head>\n"; |
|
| 65 | 65 | print '<body class="public_body">'."\n"; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function llxFooterVierge() |
| 74 | 74 | { |
| 75 | - printCommonFooter('public'); |
|
| 75 | + printCommonFooter('public'); |
|
| 76 | 76 | |
| 77 | - print "</body>\n"; |
|
| 77 | + print "</body>\n"; |
|
| 78 | 78 | print "</html>\n"; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | |
| 78 | 78 | $resql=$db->query($sql); |
| 79 | 79 | |
| 80 | - //Update status communication of contact prospect |
|
| 80 | + //Update status communication of contact prospect |
|
| 81 | 81 | $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE fk_stcomm != -1 AND rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; |
| 82 | 82 | dol_syslog("public/emailing/mailing-read.php : Mail read contact : ".$sql, LOG_DEBUG); |
| 83 | 83 | |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | $resql=$db->query($sql); |
| 88 | 88 | if (! $resql) dol_print_error($db); |
| 89 | 89 | |
| 90 | - // Update status communication of contact prospect |
|
| 90 | + // Update status communication of contact prospect |
|
| 91 | 91 | $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag = '".$db->escape($tag)."' AND source_type='contact' AND source_id is not null)"; |
| 92 | 92 | dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG); |
| 93 | 93 | |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | $appli=constant('DOL_APPLICATION_TITLE'); |
| 141 | 141 | if (! empty($conf->global->MAIN_APPLICATION_TITLE)) |
| 142 | 142 | { |
| 143 | - $appli=$conf->global->MAIN_APPLICATION_TITLE; |
|
| 144 | - if (preg_match('/\d\.\d/', $appli)) |
|
| 145 | - { |
|
| 146 | - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core |
|
| 147 | - } |
|
| 148 | - else $appli.=" ".DOL_VERSION; |
|
| 143 | + $appli=$conf->global->MAIN_APPLICATION_TITLE; |
|
| 144 | + if (preg_match('/\d\.\d/', $appli)) |
|
| 145 | + { |
|
| 146 | + if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core |
|
| 147 | + } |
|
| 148 | + else $appli.=" ".DOL_VERSION; |
|
| 149 | 149 | } |
| 150 | 150 | else $appli.=" ".DOL_VERSION; |
| 151 | 151 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | } |
| 168 | 168 | $content.="<br>\n"; |
| 169 | 169 | $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":<br>\n"; |
| 170 | - $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."<br>\n"; |
|
| 170 | + $content.=$langs->transnoentitiesnoconv("OnlinePaymentSystem").': '.$paymentmethod."<br>\n"; |
|
| 171 | 171 | $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."<br>\n"; |
| 172 | 172 | $content.="tag=".$fulltag."<br>\n"; |
| 173 | 173 | |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-foundation.jpg', |
| 99 | 99 | 'url'=>$url |
| 100 | 100 | ), |
| 101 | - // All demo profile |
|
| 102 | - array('default'=>'0', 'key'=>'profdemoall','label'=>'ChooseYourDemoProfilMore', |
|
| 101 | + // All demo profile |
|
| 102 | + array('default'=>'0', 'key'=>'profdemoall','label'=>'ChooseYourDemoProfilMore', |
|
| 103 | 103 | 'disablemodules'=>'adherent,don,externalsite,mailmanspip', |
| 104 | - //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot9.png' |
|
| 104 | + //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot9.png' |
|
| 105 | 105 | 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-all.jpg' |
| 106 | - ) |
|
| 106 | + ) |
|
| 107 | 107 | ); |
| 108 | 108 | |
| 109 | 109 | |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | // Not visible |
| 114 | 114 | $alwayshiddencheckedmodules=array('accounting','api','barcode','bookmark','clicktodial','comptabilite','cron','document','domain','externalrss','externalsite','fckeditor','geoipmaxmind','gravatar','label','ldap', |
| 115 | 115 | 'mailmanspip','notification','oauth','syslog','user','webservices', |
| 116 | - // Extended modules |
|
| 117 | - 'memcached','numberwords','zipautofillfr'); |
|
| 116 | + // Extended modules |
|
| 117 | + 'memcached','numberwords','zipautofillfr'); |
|
| 118 | 118 | $alwayshiddenuncheckedmodules=array('ftp','hrm','webservicesclient','websites', |
| 119 | - // Extended modules |
|
| 120 | - 'awstats','bittorrent','bootstrap','cabinetmed','cmcic','concatpdf','customfield','deplacement','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','multicompany','nltechno','numberingpack','openstreetmap', |
|
| 121 | - 'ovh','phenix','phpsysinfo','pibarcode','postnuke','selectbank','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail'); |
|
| 119 | + // Extended modules |
|
| 120 | + 'awstats','bittorrent','bootstrap','cabinetmed','cmcic','concatpdf','customfield','deplacement','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','multicompany','nltechno','numberingpack','openstreetmap', |
|
| 121 | + 'ovh','phenix','phpsysinfo','pibarcode','postnuke','selectbank','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail'); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Search modules |
@@ -139,61 +139,61 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | foreach ($modulesdir as $dir) |
| 141 | 141 | { |
| 142 | - // Charge tableaux modules, nom, numero, orders depuis repertoire dir |
|
| 143 | - $handle=@opendir($dir); |
|
| 144 | - if (is_resource($handle)) |
|
| 145 | - { |
|
| 146 | - while (($file = readdir($handle))!==false) |
|
| 147 | - { |
|
| 148 | - //print "$i ".$file."\n<br>"; |
|
| 149 | - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') |
|
| 150 | - { |
|
| 151 | - $modName = substr($file, 0, dol_strlen($file) - 10); |
|
| 152 | - |
|
| 153 | - if ($modName) |
|
| 154 | - { |
|
| 155 | - try |
|
| 156 | - { |
|
| 157 | - include_once $dir.$file; |
|
| 158 | - $objMod = new $modName($db); |
|
| 159 | - |
|
| 160 | - if ($objMod->numero > 0) |
|
| 161 | - { |
|
| 162 | - $j = $objMod->numero; |
|
| 163 | - } |
|
| 164 | - else |
|
| 165 | - { |
|
| 166 | - $j = 1000 + $i; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - $modulequalified=1; |
|
| 170 | - |
|
| 171 | - // We discard modules according to features level (PS: if module is activated we always show it) |
|
| 172 | - $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod))); |
|
| 173 | - if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->$const_name)) $modulequalified=0; |
|
| 174 | - if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && empty($conf->global->$const_name)) $modulequalified=0; |
|
| 175 | - |
|
| 176 | - if ($modulequalified) |
|
| 177 | - { |
|
| 178 | - $modules[$i] = $objMod; |
|
| 179 | - $filename[$i]= $modName; |
|
| 180 | - $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module |
|
| 181 | - //print "x".$modName." ".$orders[$i]."\n<br>"; |
|
| 182 | - if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories |
|
| 183 | - else $categ[$objMod->special]=1; |
|
| 184 | - $dirmod[$i] = $dirroot; |
|
| 185 | - $j++; |
|
| 186 | - $i++; |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - catch(Exception $e) |
|
| 190 | - { |
|
| 191 | - dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 142 | + // Charge tableaux modules, nom, numero, orders depuis repertoire dir |
|
| 143 | + $handle=@opendir($dir); |
|
| 144 | + if (is_resource($handle)) |
|
| 145 | + { |
|
| 146 | + while (($file = readdir($handle))!==false) |
|
| 147 | + { |
|
| 148 | + //print "$i ".$file."\n<br>"; |
|
| 149 | + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') |
|
| 150 | + { |
|
| 151 | + $modName = substr($file, 0, dol_strlen($file) - 10); |
|
| 152 | + |
|
| 153 | + if ($modName) |
|
| 154 | + { |
|
| 155 | + try |
|
| 156 | + { |
|
| 157 | + include_once $dir.$file; |
|
| 158 | + $objMod = new $modName($db); |
|
| 159 | + |
|
| 160 | + if ($objMod->numero > 0) |
|
| 161 | + { |
|
| 162 | + $j = $objMod->numero; |
|
| 163 | + } |
|
| 164 | + else |
|
| 165 | + { |
|
| 166 | + $j = 1000 + $i; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + $modulequalified=1; |
|
| 170 | + |
|
| 171 | + // We discard modules according to features level (PS: if module is activated we always show it) |
|
| 172 | + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod))); |
|
| 173 | + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->$const_name)) $modulequalified=0; |
|
| 174 | + if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && empty($conf->global->$const_name)) $modulequalified=0; |
|
| 175 | + |
|
| 176 | + if ($modulequalified) |
|
| 177 | + { |
|
| 178 | + $modules[$i] = $objMod; |
|
| 179 | + $filename[$i]= $modName; |
|
| 180 | + $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module |
|
| 181 | + //print "x".$modName." ".$orders[$i]."\n<br>"; |
|
| 182 | + if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories |
|
| 183 | + else $categ[$objMod->special]=1; |
|
| 184 | + $dirmod[$i] = $dirroot; |
|
| 185 | + $j++; |
|
| 186 | + $i++; |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + catch(Exception $e) |
|
| 190 | + { |
|
| 191 | + dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | asort($orders); |
@@ -211,32 +211,32 @@ discard block |
||
| 211 | 211 | // If we disable modules using a profile choice |
| 212 | 212 | if (GETPOST("demochoice")) |
| 213 | 213 | { |
| 214 | - foreach ($demoprofiles as $profilearray) |
|
| 215 | - { |
|
| 216 | - if ($profilearray['key'] == GETPOST("demochoice")) |
|
| 217 | - { |
|
| 218 | - $disablestring=$profilearray['disablemodules']; |
|
| 219 | - break; |
|
| 220 | - } |
|
| 221 | - } |
|
| 214 | + foreach ($demoprofiles as $profilearray) |
|
| 215 | + { |
|
| 216 | + if ($profilearray['key'] == GETPOST("demochoice")) |
|
| 217 | + { |
|
| 218 | + $disablestring=$profilearray['disablemodules']; |
|
| 219 | + break; |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | 222 | } |
| 223 | 223 | // If we disable modules using personalized list |
| 224 | 224 | foreach($modules as $val) |
| 225 | 225 | { |
| 226 | - $modulekeyname=strtolower($val->name); |
|
| 227 | - if (empty($_POST[$modulekeyname]) && empty($val->always_enabled) && ! in_array($modulekeyname,$alwayscheckedmodules)) |
|
| 228 | - { |
|
| 229 | - $disablestring.=$modulekeyname.','; |
|
| 230 | - if ($modulekeyname=='propale') $disablestring.='propal,'; |
|
| 231 | - } |
|
| 226 | + $modulekeyname=strtolower($val->name); |
|
| 227 | + if (empty($_POST[$modulekeyname]) && empty($val->always_enabled) && ! in_array($modulekeyname,$alwayscheckedmodules)) |
|
| 228 | + { |
|
| 229 | + $disablestring.=$modulekeyname.','; |
|
| 230 | + if ($modulekeyname=='propale') $disablestring.='propal,'; |
|
| 231 | + } |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - // Do redirect to login page |
|
| 234 | + // Do redirect to login page |
|
| 235 | 235 | if ($disablestring) |
| 236 | 236 | { |
| 237 | 237 | if (GETPOST('urlfrom')) $url.=(preg_match('/\?/',$url)?'&':'?').'urlfrom='.urlencode(GETPOST('urlfrom','alpha')); |
| 238 | 238 | $url.=(preg_match('/\?/',$url)?'&':'?').'disablemodules='.$disablestring; |
| 239 | - //var_dump($url);exit; |
|
| 239 | + //var_dump($url);exit; |
|
| 240 | 240 | header("Location: ".$url); |
| 241 | 241 | exit; |
| 242 | 242 | } |
@@ -304,49 +304,49 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | if ($profilearray['default'] >= 0) |
| 306 | 306 | { |
| 307 | - //print $profilearray['lang']; |
|
| 308 | - if (! empty($profilearray['lang'])) $langs->load($profilearray['lang']); |
|
| 307 | + //print $profilearray['lang']; |
|
| 308 | + if (! empty($profilearray['lang'])) $langs->load($profilearray['lang']); |
|
| 309 | 309 | |
| 310 | 310 | $url=$_SERVER["PHP_SELF"].'?action=gotodemo'; |
| 311 | 311 | $urlwithmod=$url.'&demochoice='.$profilearray['key']; |
| 312 | 312 | // Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr' |
| 313 | 313 | //print "xx".$_SERVER["PHP_SELF"].' '.DOL_URL_ROOT.'<br>'; |
| 314 | 314 | |
| 315 | - $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]); |
|
| 315 | + $urlfrom=preg_replace('/^'.preg_quote(DOL_URL_ROOT,'/').'/i','',$_SERVER["PHP_SELF"]); |
|
| 316 | 316 | //print $urlfrom; |
| 317 | 317 | |
| 318 | 318 | if (! empty($profilearray['url'])) |
| 319 | 319 | { |
| 320 | - $urlwithmod=$profilearray['url']; |
|
| 321 | - $urlwithmod=$urlwithmod.(preg_match('/\?/',$urlwithmod)?'&':'?').'urlfrom='.urlencode($urlfrom); |
|
| 322 | - if (! empty($profilearray['disablemodules'])) |
|
| 323 | - { |
|
| 324 | - $urlwithmod=$urlwithmod.(preg_match('/\?/',$urlwithmod)?'&':'?').'disablemodules='.$profilearray['disablemodules']; |
|
| 325 | - } |
|
| 320 | + $urlwithmod=$profilearray['url']; |
|
| 321 | + $urlwithmod=$urlwithmod.(preg_match('/\?/',$urlwithmod)?'&':'?').'urlfrom='.urlencode($urlfrom); |
|
| 322 | + if (! empty($profilearray['disablemodules'])) |
|
| 323 | + { |
|
| 324 | + $urlwithmod=$urlwithmod.(preg_match('/\?/',$urlwithmod)?'&':'?').'disablemodules='.$profilearray['disablemodules']; |
|
| 325 | + } |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | if (empty($profilearray['url'])) |
| 329 | 329 | { |
| 330 | - print '<div class="clearboth"></div>'; |
|
| 330 | + print '<div class="clearboth"></div>'; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | print '<form method="POST" class="valigntop inline-block" name="form'.$profilearray['key'].'" action="'.$_SERVER["PHP_SELF"].'#a1'.$profilearray['key'].'">'."\n"; |
| 334 | 334 | print '<input type="hidden" name="action" value="gotodemo">'."\n"; |
| 335 | - print '<input type="hidden" name="urlfrom" value="'.dol_escape_htmltag($urlfrom).'">'."\n"; |
|
| 336 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n"; |
|
| 337 | - print '<input type="hidden" name="username" value="demo">'."\n"; |
|
| 338 | - print '<input type="hidden" name="dol_hide_topmenu" value="'.$conf->dol_hide_topmenu.'">'."\n"; |
|
| 339 | - print '<input type="hidden" name="dol_hide_leftmenu" value="'.$conf->dol_hide_leftmenu.'">'."\n"; |
|
| 340 | - print '<input type="hidden" name="dol_optimize_smallscreen" value="'.$conf->dol_optimize_smallscreen.'">'."\n"; |
|
| 341 | - print '<input type="hidden" name="dol_no_mouse_hover" value="'.$conf->dol_no_mouse_hover.'">'."\n"; |
|
| 342 | - print '<input type="hidden" name="dol_use_jmobile" value="'.$conf->dol_use_jmobile.'">'."\n"; |
|
| 335 | + print '<input type="hidden" name="urlfrom" value="'.dol_escape_htmltag($urlfrom).'">'."\n"; |
|
| 336 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n"; |
|
| 337 | + print '<input type="hidden" name="username" value="demo">'."\n"; |
|
| 338 | + print '<input type="hidden" name="dol_hide_topmenu" value="'.$conf->dol_hide_topmenu.'">'."\n"; |
|
| 339 | + print '<input type="hidden" name="dol_hide_leftmenu" value="'.$conf->dol_hide_leftmenu.'">'."\n"; |
|
| 340 | + print '<input type="hidden" name="dol_optimize_smallscreen" value="'.$conf->dol_optimize_smallscreen.'">'."\n"; |
|
| 341 | + print '<input type="hidden" name="dol_no_mouse_hover" value="'.$conf->dol_no_mouse_hover.'">'."\n"; |
|
| 342 | + print '<input type="hidden" name="dol_use_jmobile" value="'.$conf->dol_use_jmobile.'">'."\n"; |
|
| 343 | 343 | |
| 344 | - print '<div summary="Dolibarr online demonstration for profile '.$profilearray['label'].'" class="center inline-block CTable CTableRow'.($i%2==0?'1':'0').'" style="width: 346px;">'."\n"; |
|
| 344 | + print '<div summary="Dolibarr online demonstration for profile '.$profilearray['label'].'" class="center inline-block CTable CTableRow'.($i%2==0?'1':'0').'" style="width: 346px;">'."\n"; |
|
| 345 | 345 | |
| 346 | 346 | |
| 347 | - print '<div id="a1'.$profilearray['key'].'" class="demobox '.(empty($profilearray['url'])?'modulelineshow cursorpointer':'nomodulelines').'">'; |
|
| 347 | + print '<div id="a1'.$profilearray['key'].'" class="demobox '.(empty($profilearray['url'])?'modulelineshow cursorpointer':'nomodulelines').'">'; |
|
| 348 | 348 | |
| 349 | - print '<a href="'.$urlwithmod.'" class="'.(empty($profilearray['url'])?'modulelineshow':'nomodulelines').'">'; |
|
| 349 | + print '<a href="'.$urlwithmod.'" class="'.(empty($profilearray['url'])?'modulelineshow':'nomodulelines').'">'; |
|
| 350 | 350 | print '<div style="padding: 10px;">'; |
| 351 | 351 | |
| 352 | 352 | print '<img class="demothumb" src="'.$profilearray['icon'].'" alt="Demo '.$profilearray['label'].'">'; |
@@ -354,69 +354,69 @@ discard block |
||
| 354 | 354 | print '<div class="clearboth"></div>'; |
| 355 | 355 | |
| 356 | 356 | print '<div class="demothumbtext">'; |
| 357 | - print $langs->trans($profilearray['label']); |
|
| 358 | - print '</div>'; |
|
| 357 | + print $langs->trans($profilearray['label']); |
|
| 358 | + print '</div>'; |
|
| 359 | 359 | |
| 360 | - print '</div>'; |
|
| 361 | - print '</a>'; |
|
| 360 | + print '</div>'; |
|
| 361 | + print '</a>'; |
|
| 362 | 362 | |
| 363 | 363 | |
| 364 | - // Modules (a profile you must choose modules) |
|
| 365 | - if (empty($profilearray['url'])) |
|
| 366 | - { |
|
| 367 | - print '<div id="tr1'.$profilearray['key'].'" class="moduleline hidden" style="margin-left: 8px; margin-right: 8px; text-align: justify; font-size:14px; line-height: 130%; padding-bottom: 8px">'; |
|
| 368 | - |
|
| 369 | - print $langs->trans("ThisIsListOfModules").'<br><br>'; |
|
| 370 | - |
|
| 371 | - print '<div class="csscolumns">'; |
|
| 372 | - |
|
| 373 | - $listofdisabledmodules=explode(',',$profilearray['disablemodules']); |
|
| 374 | - $j=0; |
|
| 375 | - $nbcolsmod=empty($conf->dol_optimize_smallscreen)?4:3; |
|
| 376 | - //var_dump($modules); |
|
| 377 | - foreach($orders as $index => $key) // Loop on qualified (enabled) modules |
|
| 378 | - { |
|
| 379 | - //print $index.' '.$key; |
|
| 380 | - $val = $modules[$index]; |
|
| 381 | - $modulekeyname=strtolower($val->name); |
|
| 382 | - |
|
| 383 | - $modulequalified=1; |
|
| 384 | - if (! empty($val->always_enabled) || in_array($modulekeyname,$alwayshiddenuncheckedmodules)) $modulequalified=0; |
|
| 385 | - if ($val->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0; |
|
| 386 | - if ($val->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0; |
|
| 387 | - if (! $modulequalified) continue; |
|
| 388 | - |
|
| 389 | - if (in_array($modulekeyname,$alwayshiddencheckedmodules)) |
|
| 390 | - { |
|
| 391 | - print "\n".'<!-- Module '.$modulekeyname.' hidden and always checked -->'; |
|
| 392 | - print '<input type="hidden" name="'.$modulekeyname.'" value="1">'; |
|
| 393 | - } |
|
| 394 | - else |
|
| 395 | - { |
|
| 396 | - $modulo=($j % $nbcolsmod); |
|
| 397 | - //if ($modulo == 0) print '<tr>'; |
|
| 398 | - print '<!-- id='.$val->numero.' -->'; |
|
| 399 | - print '<div class="nowrap">'; |
|
| 400 | - print '<input type="checkbox" class="checkbox" name="'.$modulekeyname.'" value="1"'; |
|
| 401 | - if (in_array($modulekeyname,$alwaysuncheckedmodules)) print ' disabled'; |
|
| 402 | - if (! in_array($modulekeyname,$alwaysuncheckedmodules) && (! in_array($modulekeyname,$listofdisabledmodules) || in_array($modulekeyname,$alwayscheckedmodules))) print ' checked'; |
|
| 403 | - print '> <div class="inline-block demomaxoveflow">'.$val->getName().'</div><br>'; |
|
| 404 | - print '</div>'; |
|
| 405 | - //if ($modulo == ($nbcolsmod - 1)) print '</tr>'; |
|
| 406 | - $j++; |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - print '</div>'; |
|
| 411 | - |
|
| 412 | - print '<br><div class="center">'; |
|
| 413 | - print '<input type="submit" value=" '.$langs->trans("Start").' " class="button">'; |
|
| 414 | - print '</div>'; |
|
| 415 | - |
|
| 416 | - print '</div>'; |
|
| 417 | - } |
|
| 364 | + // Modules (a profile you must choose modules) |
|
| 365 | + if (empty($profilearray['url'])) |
|
| 366 | + { |
|
| 367 | + print '<div id="tr1'.$profilearray['key'].'" class="moduleline hidden" style="margin-left: 8px; margin-right: 8px; text-align: justify; font-size:14px; line-height: 130%; padding-bottom: 8px">'; |
|
| 368 | + |
|
| 369 | + print $langs->trans("ThisIsListOfModules").'<br><br>'; |
|
| 370 | + |
|
| 371 | + print '<div class="csscolumns">'; |
|
| 372 | + |
|
| 373 | + $listofdisabledmodules=explode(',',$profilearray['disablemodules']); |
|
| 374 | + $j=0; |
|
| 375 | + $nbcolsmod=empty($conf->dol_optimize_smallscreen)?4:3; |
|
| 376 | + //var_dump($modules); |
|
| 377 | + foreach($orders as $index => $key) // Loop on qualified (enabled) modules |
|
| 378 | + { |
|
| 379 | + //print $index.' '.$key; |
|
| 380 | + $val = $modules[$index]; |
|
| 381 | + $modulekeyname=strtolower($val->name); |
|
| 382 | + |
|
| 383 | + $modulequalified=1; |
|
| 384 | + if (! empty($val->always_enabled) || in_array($modulekeyname,$alwayshiddenuncheckedmodules)) $modulequalified=0; |
|
| 385 | + if ($val->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0; |
|
| 386 | + if ($val->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0; |
|
| 387 | + if (! $modulequalified) continue; |
|
| 388 | + |
|
| 389 | + if (in_array($modulekeyname,$alwayshiddencheckedmodules)) |
|
| 390 | + { |
|
| 391 | + print "\n".'<!-- Module '.$modulekeyname.' hidden and always checked -->'; |
|
| 392 | + print '<input type="hidden" name="'.$modulekeyname.'" value="1">'; |
|
| 393 | + } |
|
| 394 | + else |
|
| 395 | + { |
|
| 396 | + $modulo=($j % $nbcolsmod); |
|
| 397 | + //if ($modulo == 0) print '<tr>'; |
|
| 398 | + print '<!-- id='.$val->numero.' -->'; |
|
| 399 | + print '<div class="nowrap">'; |
|
| 400 | + print '<input type="checkbox" class="checkbox" name="'.$modulekeyname.'" value="1"'; |
|
| 401 | + if (in_array($modulekeyname,$alwaysuncheckedmodules)) print ' disabled'; |
|
| 402 | + if (! in_array($modulekeyname,$alwaysuncheckedmodules) && (! in_array($modulekeyname,$listofdisabledmodules) || in_array($modulekeyname,$alwayscheckedmodules))) print ' checked'; |
|
| 403 | + print '> <div class="inline-block demomaxoveflow">'.$val->getName().'</div><br>'; |
|
| 404 | + print '</div>'; |
|
| 405 | + //if ($modulo == ($nbcolsmod - 1)) print '</tr>'; |
|
| 406 | + $j++; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + print '</div>'; |
|
| 411 | + |
|
| 412 | + print '<br><div class="center">'; |
|
| 413 | + print '<input type="submit" value=" '.$langs->trans("Start").' " class="button">'; |
|
| 414 | + print '</div>'; |
|
| 415 | + |
|
| 416 | + print '</div>'; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - print '</div></div>'; |
|
| 419 | + print '</div></div>'; |
|
| 420 | 420 | print '</form>'."\n"; |
| 421 | 421 | |
| 422 | 422 | $i++; |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function llxHeaderVierge($title, $head = "") |
| 467 | 467 | { |
| 468 | - global $user, $conf, $langs; |
|
| 468 | + global $user, $conf, $langs; |
|
| 469 | 469 | |
| 470 | - top_httphead(); |
|
| 470 | + top_httphead(); |
|
| 471 | 471 | |
| 472 | - top_htmlhead($head,$title,0,0,array(),array('public/demo/demo.css')); |
|
| 472 | + top_htmlhead($head,$title,0,0,array(),array('public/demo/demo.css')); |
|
| 473 | 473 | |
| 474 | - print '<body class="demobody"><div class="demobackgrounddiv">'."\n"; |
|
| 474 | + print '<body class="demobody"><div class="demobackgrounddiv">'."\n"; |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | */ |
| 482 | 482 | function llxFooterVierge() |
| 483 | 483 | { |
| 484 | - printCommonFooter('public'); |
|
| 484 | + printCommonFooter('public'); |
|
| 485 | 485 | |
| 486 | - print "\n"; |
|
| 487 | - print "</div></body>\n"; |
|
| 488 | - print "</html>\n"; |
|
| 486 | + print "\n"; |
|
| 487 | + print "</div></body>\n"; |
|
| 488 | + print "</html>\n"; |
|
| 489 | 489 | } |
| 490 | 490 | |