@@ -51,42 +51,42 @@ |
||
51 | 51 | * @param integer $readonly Select is read only or not |
52 | 52 | * @return string HTML select field |
53 | 53 | */ |
54 | - function select_typejob($htmlname,$selected=0,$readonly=0) |
|
54 | + function select_typejob($htmlname, $selected = 0, $readonly = 0) |
|
55 | 55 | { |
56 | 56 | global $langs; |
57 | 57 | |
58 | 58 | $langs->load('cron@cron'); |
59 | 59 | if (!empty($readonly)) { |
60 | - if ($selected=='command') { |
|
61 | - $out= $langs->trans('CronType_command'); |
|
62 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
63 | - $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
64 | - $out.='</SELECT>'; |
|
65 | - } elseif ($selected=='method') { |
|
66 | - $out= $langs->trans('CronType_method'); |
|
67 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
68 | - $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
69 | - $out.='</SELECT>'; |
|
60 | + if ($selected == 'command') { |
|
61 | + $out = $langs->trans('CronType_command'); |
|
62 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
63 | + $out .= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
64 | + $out .= '</SELECT>'; |
|
65 | + } elseif ($selected == 'method') { |
|
66 | + $out = $langs->trans('CronType_method'); |
|
67 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
68 | + $out .= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
69 | + $out .= '</SELECT>'; |
|
70 | 70 | } |
71 | - }else { |
|
71 | + } else { |
|
72 | 72 | |
73 | - $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
73 | + $out = '<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
74 | 74 | |
75 | - if ($selected=='command') { |
|
76 | - $selected_attr=' selected '; |
|
75 | + if ($selected == 'command') { |
|
76 | + $selected_attr = ' selected '; |
|
77 | 77 | } else { |
78 | - $selected_attr=''; |
|
78 | + $selected_attr = ''; |
|
79 | 79 | } |
80 | - $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
80 | + $out .= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
81 | 81 | |
82 | - if ($selected=='method') { |
|
83 | - $selected_attr=' selected '; |
|
82 | + if ($selected == 'method') { |
|
83 | + $selected_attr = ' selected '; |
|
84 | 84 | } else { |
85 | - $selected_attr=''; |
|
85 | + $selected_attr = ''; |
|
86 | 86 | } |
87 | - $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
87 | + $out .= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
88 | 88 | |
89 | - $out.='</SELECT>'; |
|
89 | + $out .= '</SELECT>'; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $out; |
@@ -68,7 +68,7 @@ |
||
68 | 68 | $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
69 | 69 | $out.='</SELECT>'; |
70 | 70 | } |
71 | - }else { |
|
71 | + } else { |
|
72 | 72 | |
73 | 73 | $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
74 | 74 |
@@ -41,102 +41,102 @@ |
||
41 | 41 | $this->db = $db; |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Return combo list of differents status of a proposal |
|
46 | - * Values are id of table c_propalst |
|
47 | - * |
|
48 | - * @param string $selected Preselected value |
|
49 | - * @param int $short Use short labels |
|
50 | - * @param int $excludedraft 0=All status, 1=Exclude draft status |
|
51 | - * @param int $showempty 1=Add empty line |
|
52 | - * @param string $mode 'customer', 'supplier' |
|
53 | - * @param string $htmlname Name of select field |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - function selectProposalStatus($selected='',$short=0, $excludedraft=0, $showempty=1, $mode='customer',$htmlname='propal_statut') |
|
57 | - { |
|
58 | - global $langs; |
|
44 | + /** |
|
45 | + * Return combo list of differents status of a proposal |
|
46 | + * Values are id of table c_propalst |
|
47 | + * |
|
48 | + * @param string $selected Preselected value |
|
49 | + * @param int $short Use short labels |
|
50 | + * @param int $excludedraft 0=All status, 1=Exclude draft status |
|
51 | + * @param int $showempty 1=Add empty line |
|
52 | + * @param string $mode 'customer', 'supplier' |
|
53 | + * @param string $htmlname Name of select field |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + function selectProposalStatus($selected='',$short=0, $excludedraft=0, $showempty=1, $mode='customer',$htmlname='propal_statut') |
|
57 | + { |
|
58 | + global $langs; |
|
59 | 59 | |
60 | - $prefix=''; |
|
61 | - $listofstatus=array(); |
|
62 | - if ($mode == 'supplier') |
|
63 | - { |
|
64 | - $prefix='SupplierProposalStatus'; |
|
60 | + $prefix=''; |
|
61 | + $listofstatus=array(); |
|
62 | + if ($mode == 'supplier') |
|
63 | + { |
|
64 | + $prefix='SupplierProposalStatus'; |
|
65 | 65 | |
66 | - $langs->load("supplier_proposal"); |
|
67 | - $listofstatus=array( |
|
68 | - 0=>array('id'=>0, 'code'=>'PR_DRAFT'), |
|
69 | - 1=>array('id'=>1, 'code'=>'PR_OPEN'), |
|
70 | - 2=>array('id'=>2, 'code'=>'PR_SIGNED'), |
|
71 | - 3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'), |
|
72 | - 4=>array('id'=>4, 'code'=>'PR_CLOSED') |
|
73 | - ); |
|
74 | - } |
|
75 | - else |
|
76 | - { |
|
77 | - $prefix="PropalStatus"; |
|
66 | + $langs->load("supplier_proposal"); |
|
67 | + $listofstatus=array( |
|
68 | + 0=>array('id'=>0, 'code'=>'PR_DRAFT'), |
|
69 | + 1=>array('id'=>1, 'code'=>'PR_OPEN'), |
|
70 | + 2=>array('id'=>2, 'code'=>'PR_SIGNED'), |
|
71 | + 3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'), |
|
72 | + 4=>array('id'=>4, 'code'=>'PR_CLOSED') |
|
73 | + ); |
|
74 | + } |
|
75 | + else |
|
76 | + { |
|
77 | + $prefix="PropalStatus"; |
|
78 | 78 | |
79 | - $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst"; |
|
80 | - $sql .= " WHERE active = 1"; |
|
81 | - dol_syslog(get_class($this)."::selectProposalStatus", LOG_DEBUG); |
|
82 | - $resql=$this->db->query($sql); |
|
83 | - if ($resql) |
|
84 | - { |
|
85 | - $num = $this->db->num_rows($resql); |
|
86 | - $i = 0; |
|
87 | - if ($num) |
|
88 | - { |
|
89 | - while ($i < $num) |
|
90 | - { |
|
91 | - $obj = $this->db->fetch_object($resql); |
|
92 | - $listofstatus[$obj->id]=array('id'=>$obj->id,'code'=>$obj->code,'label'=>$obj->label); |
|
93 | - $i++; |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - else |
|
98 | - { |
|
99 | - dol_print_error($this->db); |
|
100 | - } |
|
101 | - } |
|
79 | + $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst"; |
|
80 | + $sql .= " WHERE active = 1"; |
|
81 | + dol_syslog(get_class($this)."::selectProposalStatus", LOG_DEBUG); |
|
82 | + $resql=$this->db->query($sql); |
|
83 | + if ($resql) |
|
84 | + { |
|
85 | + $num = $this->db->num_rows($resql); |
|
86 | + $i = 0; |
|
87 | + if ($num) |
|
88 | + { |
|
89 | + while ($i < $num) |
|
90 | + { |
|
91 | + $obj = $this->db->fetch_object($resql); |
|
92 | + $listofstatus[$obj->id]=array('id'=>$obj->id,'code'=>$obj->code,'label'=>$obj->label); |
|
93 | + $i++; |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + else |
|
98 | + { |
|
99 | + dol_print_error($this->db); |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - print '<select class="flat" name="'.$htmlname.'">'; |
|
104 | - if ($showempty) print '<option value="-1"> </option>'; |
|
103 | + print '<select class="flat" name="'.$htmlname.'">'; |
|
104 | + if ($showempty) print '<option value="-1"> </option>'; |
|
105 | 105 | |
106 | - foreach($listofstatus as $key => $obj) |
|
107 | - { |
|
108 | - if ($excludedraft) |
|
109 | - { |
|
106 | + foreach($listofstatus as $key => $obj) |
|
107 | + { |
|
108 | + if ($excludedraft) |
|
109 | + { |
|
110 | 110 | if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT') |
111 | 111 | { |
112 | 112 | $i++; |
113 | 113 | continue; |
114 | 114 | } |
115 | - } |
|
116 | - if ($selected != '' && $selected == $obj['id']) |
|
117 | - { |
|
118 | - print '<option value="'.$obj['id'].'" selected>'; |
|
119 | - } |
|
120 | - else |
|
121 | - { |
|
122 | - print '<option value="'.$obj['id'].'">'; |
|
123 | - } |
|
124 | - $key=$obj['code']; |
|
125 | - if ($langs->trans($prefix.$key.($short?'Short':'')) != $prefix.$key.($short?'Short':'')) |
|
126 | - { |
|
127 | - print $langs->trans($prefix.$key.($short?'Short':'')); |
|
128 | - } |
|
129 | - else |
|
115 | + } |
|
116 | + if ($selected != '' && $selected == $obj['id']) |
|
117 | + { |
|
118 | + print '<option value="'.$obj['id'].'" selected>'; |
|
119 | + } |
|
120 | + else |
|
130 | 121 | { |
131 | - $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); |
|
132 | - if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']]; |
|
122 | + print '<option value="'.$obj['id'].'">'; |
|
123 | + } |
|
124 | + $key=$obj['code']; |
|
125 | + if ($langs->trans($prefix.$key.($short?'Short':'')) != $prefix.$key.($short?'Short':'')) |
|
126 | + { |
|
127 | + print $langs->trans($prefix.$key.($short?'Short':'')); |
|
128 | + } |
|
129 | + else |
|
130 | + { |
|
131 | + $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); |
|
132 | + if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']]; |
|
133 | 133 | |
134 | - print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']); |
|
135 | - } |
|
136 | - print '</option>'; |
|
137 | - $i++; |
|
138 | - } |
|
139 | - print '</select>'; |
|
140 | - } |
|
134 | + print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']); |
|
135 | + } |
|
136 | + print '</option>'; |
|
137 | + $i++; |
|
138 | + } |
|
139 | + print '</select>'; |
|
140 | + } |
|
141 | 141 | } |
142 | 142 |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | * @param string $htmlname Name of select field |
54 | 54 | * @return void |
55 | 55 | */ |
56 | - function selectProposalStatus($selected='',$short=0, $excludedraft=0, $showempty=1, $mode='customer',$htmlname='propal_statut') |
|
56 | + function selectProposalStatus($selected = '', $short = 0, $excludedraft = 0, $showempty = 1, $mode = 'customer', $htmlname = 'propal_statut') |
|
57 | 57 | { |
58 | 58 | global $langs; |
59 | 59 | |
60 | - $prefix=''; |
|
61 | - $listofstatus=array(); |
|
60 | + $prefix = ''; |
|
61 | + $listofstatus = array(); |
|
62 | 62 | if ($mode == 'supplier') |
63 | 63 | { |
64 | - $prefix='SupplierProposalStatus'; |
|
64 | + $prefix = 'SupplierProposalStatus'; |
|
65 | 65 | |
66 | 66 | $langs->load("supplier_proposal"); |
67 | - $listofstatus=array( |
|
67 | + $listofstatus = array( |
|
68 | 68 | 0=>array('id'=>0, 'code'=>'PR_DRAFT'), |
69 | 69 | 1=>array('id'=>1, 'code'=>'PR_OPEN'), |
70 | 70 | 2=>array('id'=>2, 'code'=>'PR_SIGNED'), |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | } |
75 | 75 | else |
76 | 76 | { |
77 | - $prefix="PropalStatus"; |
|
77 | + $prefix = "PropalStatus"; |
|
78 | 78 | |
79 | 79 | $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst"; |
80 | 80 | $sql .= " WHERE active = 1"; |
81 | 81 | dol_syslog(get_class($this)."::selectProposalStatus", LOG_DEBUG); |
82 | - $resql=$this->db->query($sql); |
|
82 | + $resql = $this->db->query($sql); |
|
83 | 83 | if ($resql) |
84 | 84 | { |
85 | 85 | $num = $this->db->num_rows($resql); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | while ($i < $num) |
90 | 90 | { |
91 | 91 | $obj = $this->db->fetch_object($resql); |
92 | - $listofstatus[$obj->id]=array('id'=>$obj->id,'code'=>$obj->code,'label'=>$obj->label); |
|
92 | + $listofstatus[$obj->id] = array('id'=>$obj->id, 'code'=>$obj->code, 'label'=>$obj->label); |
|
93 | 93 | $i++; |
94 | 94 | } |
95 | 95 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | print '<select class="flat" name="'.$htmlname.'">'; |
104 | 104 | if ($showempty) print '<option value="-1"> </option>'; |
105 | 105 | |
106 | - foreach($listofstatus as $key => $obj) |
|
106 | + foreach ($listofstatus as $key => $obj) |
|
107 | 107 | { |
108 | 108 | if ($excludedraft) |
109 | 109 | { |
@@ -121,17 +121,17 @@ discard block |
||
121 | 121 | { |
122 | 122 | print '<option value="'.$obj['id'].'">'; |
123 | 123 | } |
124 | - $key=$obj['code']; |
|
125 | - if ($langs->trans($prefix.$key.($short?'Short':'')) != $prefix.$key.($short?'Short':'')) |
|
124 | + $key = $obj['code']; |
|
125 | + if ($langs->trans($prefix.$key.($short ? 'Short' : '')) != $prefix.$key.($short ? 'Short' : '')) |
|
126 | 126 | { |
127 | - print $langs->trans($prefix.$key.($short?'Short':'')); |
|
127 | + print $langs->trans($prefix.$key.($short ? 'Short' : '')); |
|
128 | 128 | } |
129 | 129 | else |
130 | 130 | { |
131 | - $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); |
|
132 | - if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']]; |
|
131 | + $conv_to_new_code = array('PR_DRAFT'=>'Draft', 'PR_OPEN'=>'Validated', 'PR_CLOSED'=>'Closed', 'PR_SIGNED'=>'Signed', 'PR_NOTSIGNED'=>'NotSigned', 'PR_FAC'=>'Billed'); |
|
132 | + if (!empty($conv_to_new_code[$obj['code']])) $key = $conv_to_new_code[$obj['code']]; |
|
133 | 133 | |
134 | - print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']); |
|
134 | + print ($langs->trans($prefix.$key.($short ? 'Short' : '')) != $prefix.$key.($short ? 'Short' : '')) ? $langs->trans($prefix.$key.($short ? 'Short' : '')) : ($obj['label'] ? $obj['label'] : $obj['code']); |
|
135 | 135 | } |
136 | 136 | print '</option>'; |
137 | 137 | $i++; |
@@ -71,8 +71,7 @@ discard block |
||
71 | 71 | 3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'), |
72 | 72 | 4=>array('id'=>4, 'code'=>'PR_CLOSED') |
73 | 73 | ); |
74 | - } |
|
75 | - else |
|
74 | + } else |
|
76 | 75 | { |
77 | 76 | $prefix="PropalStatus"; |
78 | 77 | |
@@ -93,15 +92,16 @@ discard block |
||
93 | 92 | $i++; |
94 | 93 | } |
95 | 94 | } |
96 | - } |
|
97 | - else |
|
95 | + } else |
|
98 | 96 | { |
99 | 97 | dol_print_error($this->db); |
100 | 98 | } |
101 | 99 | } |
102 | 100 | |
103 | 101 | print '<select class="flat" name="'.$htmlname.'">'; |
104 | - if ($showempty) print '<option value="-1"> </option>'; |
|
102 | + if ($showempty) { |
|
103 | + print '<option value="-1"> </option>'; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | foreach($listofstatus as $key => $obj) |
107 | 107 | { |
@@ -116,8 +116,7 @@ discard block |
||
116 | 116 | if ($selected != '' && $selected == $obj['id']) |
117 | 117 | { |
118 | 118 | print '<option value="'.$obj['id'].'" selected>'; |
119 | - } |
|
120 | - else |
|
119 | + } else |
|
121 | 120 | { |
122 | 121 | print '<option value="'.$obj['id'].'">'; |
123 | 122 | } |
@@ -125,11 +124,12 @@ discard block |
||
125 | 124 | if ($langs->trans($prefix.$key.($short?'Short':'')) != $prefix.$key.($short?'Short':'')) |
126 | 125 | { |
127 | 126 | print $langs->trans($prefix.$key.($short?'Short':'')); |
128 | - } |
|
129 | - else |
|
127 | + } else |
|
130 | 128 | { |
131 | 129 | $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); |
132 | - if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']]; |
|
130 | + if (! empty($conv_to_new_code[$obj['code']])) { |
|
131 | + $key=$conv_to_new_code[$obj['code']]; |
|
132 | + } |
|
133 | 133 | |
134 | 134 | print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']); |
135 | 135 | } |
@@ -26,112 +26,112 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class SimpleOpenID |
28 | 28 | { |
29 | - var $openid_url_identity; |
|
30 | - var $URLs = array(); |
|
31 | - var $error = array(); |
|
32 | - var $fields = array( |
|
29 | + var $openid_url_identity; |
|
30 | + var $URLs = array(); |
|
31 | + var $error = array(); |
|
32 | + var $fields = array( |
|
33 | 33 | 'required' => array(), |
34 | 34 | 'optional' => array(), |
35 | - ); |
|
36 | - |
|
37 | - /** |
|
38 | - * Constructor |
|
39 | - */ |
|
40 | - function __construct() |
|
41 | - { |
|
42 | - if (!function_exists('curl_exec')) |
|
43 | - { |
|
44 | - die('Error: Class SimpleOpenID requires curl extension to work'); |
|
45 | - } |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * SetOpenIDServer |
|
50 | - * |
|
51 | - * @param string $a Server |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - function SetOpenIDServer($a) |
|
55 | - { |
|
56 | - $this->URLs['openid_server'] = $a; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * SetOpenIDServer |
|
61 | - * |
|
62 | - * @param string $a Server |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - function SetTrustRoot($a) |
|
66 | - { |
|
67 | - $this->URLs['trust_root'] = $a; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * SetOpenIDServer |
|
72 | - * |
|
73 | - * @param string $a Server |
|
74 | - * @return void |
|
75 | - */ |
|
76 | - function SetCancelURL($a) |
|
77 | - { |
|
78 | - $this->URLs['cancel'] = $a; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * SetApprovedURL |
|
83 | - * |
|
84 | - * @param string $a Server |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - function SetApprovedURL($a) |
|
88 | - { |
|
89 | - $this->URLs['approved'] = $a; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * SetRequiredFields |
|
94 | - * |
|
95 | - * @param string $a Server |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - function SetRequiredFields($a) |
|
99 | - { |
|
100 | - if (is_array($a)){ |
|
101 | - $this->fields['required'] = $a; |
|
102 | - }else{ |
|
103 | - $this->fields['required'][] = $a; |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * SetOptionalFields |
|
109 | - * |
|
110 | - * @param string $a Server |
|
111 | - * @return void |
|
112 | - */ |
|
113 | - function SetOptionalFields($a) |
|
114 | - { |
|
115 | - if (is_array($a)){ |
|
116 | - $this->fields['optional'] = $a; |
|
117 | - }else{ |
|
118 | - $this->fields['optional'][] = $a; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * SetIdentity |
|
124 | - * |
|
125 | - * @param string $a Server |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - function SetIdentity($a) |
|
129 | - { // Set Identity URL |
|
130 | - if ((stripos($a, 'http://') === false) |
|
131 | - && (stripos($a, 'https://') === false)){ |
|
132 | - $a = 'http://'.$a; |
|
133 | - } |
|
134 | - /* |
|
35 | + ); |
|
36 | + |
|
37 | + /** |
|
38 | + * Constructor |
|
39 | + */ |
|
40 | + function __construct() |
|
41 | + { |
|
42 | + if (!function_exists('curl_exec')) |
|
43 | + { |
|
44 | + die('Error: Class SimpleOpenID requires curl extension to work'); |
|
45 | + } |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * SetOpenIDServer |
|
50 | + * |
|
51 | + * @param string $a Server |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + function SetOpenIDServer($a) |
|
55 | + { |
|
56 | + $this->URLs['openid_server'] = $a; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * SetOpenIDServer |
|
61 | + * |
|
62 | + * @param string $a Server |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + function SetTrustRoot($a) |
|
66 | + { |
|
67 | + $this->URLs['trust_root'] = $a; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * SetOpenIDServer |
|
72 | + * |
|
73 | + * @param string $a Server |
|
74 | + * @return void |
|
75 | + */ |
|
76 | + function SetCancelURL($a) |
|
77 | + { |
|
78 | + $this->URLs['cancel'] = $a; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * SetApprovedURL |
|
83 | + * |
|
84 | + * @param string $a Server |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + function SetApprovedURL($a) |
|
88 | + { |
|
89 | + $this->URLs['approved'] = $a; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * SetRequiredFields |
|
94 | + * |
|
95 | + * @param string $a Server |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + function SetRequiredFields($a) |
|
99 | + { |
|
100 | + if (is_array($a)){ |
|
101 | + $this->fields['required'] = $a; |
|
102 | + }else{ |
|
103 | + $this->fields['required'][] = $a; |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * SetOptionalFields |
|
109 | + * |
|
110 | + * @param string $a Server |
|
111 | + * @return void |
|
112 | + */ |
|
113 | + function SetOptionalFields($a) |
|
114 | + { |
|
115 | + if (is_array($a)){ |
|
116 | + $this->fields['optional'] = $a; |
|
117 | + }else{ |
|
118 | + $this->fields['optional'][] = $a; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * SetIdentity |
|
124 | + * |
|
125 | + * @param string $a Server |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + function SetIdentity($a) |
|
129 | + { // Set Identity URL |
|
130 | + if ((stripos($a, 'http://') === false) |
|
131 | + && (stripos($a, 'https://') === false)){ |
|
132 | + $a = 'http://'.$a; |
|
133 | + } |
|
134 | + /* |
|
135 | 135 | $u = parse_url(trim($a)); |
136 | 136 | if (!isset($u['path'])){ |
137 | 137 | $u['path'] = '/'; |
@@ -144,341 +144,341 @@ discard block |
||
144 | 144 | $identity = $u['scheme'] . '://' . $u['host'] . $u['path']; |
145 | 145 | } |
146 | 146 | //*/ |
147 | - $this->openid_url_identity = $a; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * GetIdentity |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - function GetIdentity() |
|
156 | - { // Get Identity |
|
157 | - return $this->openid_url_identity; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * SetOpenIDServer |
|
162 | - * |
|
163 | - * @return void |
|
164 | - */ |
|
165 | - function GetError() |
|
166 | - { |
|
167 | - $e = $this->error; |
|
168 | - return array('code'=>$e[0],'description'=>$e[1]); |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * ErrorStore |
|
173 | - * |
|
174 | - * @param string $code Code |
|
175 | - * @param string $desc Description |
|
176 | - * @return void |
|
177 | - */ |
|
178 | - function ErrorStore($code, $desc = null) |
|
179 | - { |
|
180 | - $errs['OPENID_NOSERVERSFOUND'] = 'Cannot find OpenID Server TAG on Identity page.'; |
|
181 | - if ($desc == null){ |
|
182 | - $desc = $errs[$code]; |
|
183 | - } |
|
184 | - $this->error = array($code,$desc); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * IsError |
|
189 | - * |
|
190 | - * @return boolean |
|
191 | - */ |
|
192 | - function IsError() |
|
193 | - { |
|
194 | - if (count($this->error) > 0) |
|
195 | - { |
|
196 | - return true; |
|
197 | - } |
|
198 | - else |
|
199 | - { |
|
200 | - return false; |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * splitResponse |
|
206 | - * |
|
207 | - * @param string $response Server |
|
208 | - * @return void |
|
209 | - */ |
|
210 | - function splitResponse($response) |
|
211 | - { |
|
212 | - $r = array(); |
|
213 | - $response = explode("\n", $response); |
|
214 | - foreach($response as $line) { |
|
215 | - $line = trim($line); |
|
216 | - if ($line != "") { |
|
217 | - list($key, $value) = explode(":", $line, 2); |
|
218 | - $r[trim($key)] = trim($value); |
|
219 | - } |
|
220 | - } |
|
221 | - return $r; |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * OpenID_Standarize |
|
226 | - * |
|
227 | - * @param string $openid_identity Server |
|
228 | - * @return string |
|
229 | - */ |
|
230 | - function OpenID_Standarize($openid_identity = null) |
|
231 | - { |
|
232 | - if ($openid_identity === null) |
|
233 | - $openid_identity = $this->openid_url_identity; |
|
234 | - |
|
235 | - $u = parse_url(strtolower(trim($openid_identity))); |
|
236 | - |
|
237 | - if (!isset($u['path']) || ($u['path'] == '/')) { |
|
238 | - $u['path'] = ''; |
|
239 | - } |
|
240 | - if(substr($u['path'],-1,1) == '/'){ |
|
241 | - $u['path'] = substr($u['path'], 0, strlen($u['path'])-1); |
|
242 | - } |
|
243 | - if (isset($u['query'])){ // If there is a query string, then use identity as is |
|
244 | - return $u['host'] . $u['path'] . '?' . $u['query']; |
|
245 | - }else{ |
|
246 | - return $u['host'] . $u['path']; |
|
247 | - } |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * array2url |
|
252 | - * |
|
253 | - * @param array $arr An array |
|
254 | - * @return false|string false if KO, string of url if OK |
|
255 | - */ |
|
256 | - function array2url($arr) |
|
257 | - { // converts associated array to URL Query String |
|
258 | - if (!is_array($arr)){ |
|
259 | - return false; |
|
260 | - } |
|
261 | - $query = ''; |
|
262 | - foreach($arr as $key => $value){ |
|
263 | - $query .= $key . "=" . $value . "&"; |
|
264 | - } |
|
265 | - return $query; |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * FSOCK_Request |
|
270 | - * |
|
271 | - * @param string $url URL |
|
272 | - * @param string $method Method |
|
273 | - * @param string $params Params |
|
274 | - * @return boolean|unknown |
|
275 | - */ |
|
276 | - function FSOCK_Request($url, $method="GET", $params = "") |
|
277 | - { |
|
278 | - $fp = fsockopen("ssl://www.myopenid.com", 443, $errno, $errstr, 3); // Connection timeout is 3 seconds |
|
279 | - if (!$fp) { |
|
280 | - $this->ErrorStore('OPENID_SOCKETERROR', $errstr); |
|
281 | - return false; |
|
282 | - } else { |
|
283 | - $request = $method . " /server HTTP/1.0\r\n"; |
|
284 | - $request .= "User-Agent: Dolibarr\r\n"; |
|
285 | - $request .= "Connection: close\r\n\r\n"; |
|
286 | - fwrite($fp, $request); |
|
287 | - stream_set_timeout($fp, 4); // Connection response timeout is 4 seconds |
|
288 | - $res = fread($fp, 2000); |
|
289 | - $info = stream_get_meta_data($fp); |
|
290 | - fclose($fp); |
|
291 | - |
|
292 | - if ($info['timed_out']) { |
|
293 | - $this->ErrorStore('OPENID_SOCKETTIMEOUT'); |
|
294 | - } else { |
|
295 | - return $res; |
|
296 | - } |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * CURL_Request |
|
302 | - * |
|
303 | - * @param string $url URL |
|
304 | - * @param string $method Method |
|
305 | - * @param string $params Params |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - function CURL_Request($url, $method="GET", $params = "") |
|
309 | - { // Remember, SSL MUST BE SUPPORTED |
|
310 | - if (is_array($params)) $params = $this->array2url($params); |
|
311 | - |
|
312 | - $curl = curl_init($url . ($method == "GET" && $params != "" ? "?" . $params : "")); |
|
313 | - @curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
|
314 | - curl_setopt($curl, CURLOPT_HEADER, false); |
|
315 | - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
|
316 | - curl_setopt($curl, CURLOPT_HTTPGET, ($method == "GET")); |
|
317 | - curl_setopt($curl, CURLOPT_POST, ($method == "POST")); |
|
318 | - if ($method == "POST") curl_setopt($curl, CURLOPT_POSTFIELDS, $params); |
|
319 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
320 | - $response = curl_exec($curl); |
|
321 | - |
|
322 | - if (curl_errno($curl) == 0){ |
|
323 | - $response; |
|
324 | - }else{ |
|
325 | - $this->ErrorStore('OPENID_CURL', curl_error($curl)); |
|
326 | - } |
|
327 | - return $response; |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * HTML2OpenIDServer |
|
332 | - * |
|
333 | - * @param string $content Content |
|
334 | - * @return array Array of servers |
|
335 | - */ |
|
336 | - function HTML2OpenIDServer($content) |
|
337 | - { |
|
338 | - $get = array(); |
|
339 | - |
|
340 | - // Get details of their OpenID server and (optional) delegate |
|
341 | - preg_match_all('/<link[^>]*rel=[\'"]openid.server[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*\/?>/i', $content, $matches1); |
|
342 | - preg_match_all('/<link[^>]*href=\'"([^\'"]+)[\'"][^>]*rel=[\'"]openid.server[\'"][^>]*\/?>/i', $content, $matches2); |
|
343 | - $servers = array_merge($matches1[1], $matches2[1]); |
|
344 | - |
|
345 | - preg_match_all('/<link[^>]*rel=[\'"]openid.delegate[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*\/?>/i', $content, $matches1); |
|
346 | - |
|
347 | - preg_match_all('/<link[^>]*href=[\'"]([^\'"]+)[\'"][^>]*rel=[\'"]openid.delegate[\'"][^>]*\/?>/i', $content, $matches2); |
|
348 | - |
|
349 | - $delegates = array_merge($matches1[1], $matches2[1]); |
|
350 | - |
|
351 | - $ret = array($servers, $delegates); |
|
352 | - return $ret; |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Get openid server |
|
358 | - * |
|
359 | - * @param string $url Url to found endpoint |
|
360 | - * @return string Endpoint |
|
361 | - */ |
|
362 | - function GetOpenIDServer($url='') |
|
363 | - { |
|
364 | - global $conf; |
|
147 | + $this->openid_url_identity = $a; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * GetIdentity |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + function GetIdentity() |
|
156 | + { // Get Identity |
|
157 | + return $this->openid_url_identity; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * SetOpenIDServer |
|
162 | + * |
|
163 | + * @return void |
|
164 | + */ |
|
165 | + function GetError() |
|
166 | + { |
|
167 | + $e = $this->error; |
|
168 | + return array('code'=>$e[0],'description'=>$e[1]); |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * ErrorStore |
|
173 | + * |
|
174 | + * @param string $code Code |
|
175 | + * @param string $desc Description |
|
176 | + * @return void |
|
177 | + */ |
|
178 | + function ErrorStore($code, $desc = null) |
|
179 | + { |
|
180 | + $errs['OPENID_NOSERVERSFOUND'] = 'Cannot find OpenID Server TAG on Identity page.'; |
|
181 | + if ($desc == null){ |
|
182 | + $desc = $errs[$code]; |
|
183 | + } |
|
184 | + $this->error = array($code,$desc); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * IsError |
|
189 | + * |
|
190 | + * @return boolean |
|
191 | + */ |
|
192 | + function IsError() |
|
193 | + { |
|
194 | + if (count($this->error) > 0) |
|
195 | + { |
|
196 | + return true; |
|
197 | + } |
|
198 | + else |
|
199 | + { |
|
200 | + return false; |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * splitResponse |
|
206 | + * |
|
207 | + * @param string $response Server |
|
208 | + * @return void |
|
209 | + */ |
|
210 | + function splitResponse($response) |
|
211 | + { |
|
212 | + $r = array(); |
|
213 | + $response = explode("\n", $response); |
|
214 | + foreach($response as $line) { |
|
215 | + $line = trim($line); |
|
216 | + if ($line != "") { |
|
217 | + list($key, $value) = explode(":", $line, 2); |
|
218 | + $r[trim($key)] = trim($value); |
|
219 | + } |
|
220 | + } |
|
221 | + return $r; |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * OpenID_Standarize |
|
226 | + * |
|
227 | + * @param string $openid_identity Server |
|
228 | + * @return string |
|
229 | + */ |
|
230 | + function OpenID_Standarize($openid_identity = null) |
|
231 | + { |
|
232 | + if ($openid_identity === null) |
|
233 | + $openid_identity = $this->openid_url_identity; |
|
234 | + |
|
235 | + $u = parse_url(strtolower(trim($openid_identity))); |
|
236 | + |
|
237 | + if (!isset($u['path']) || ($u['path'] == '/')) { |
|
238 | + $u['path'] = ''; |
|
239 | + } |
|
240 | + if(substr($u['path'],-1,1) == '/'){ |
|
241 | + $u['path'] = substr($u['path'], 0, strlen($u['path'])-1); |
|
242 | + } |
|
243 | + if (isset($u['query'])){ // If there is a query string, then use identity as is |
|
244 | + return $u['host'] . $u['path'] . '?' . $u['query']; |
|
245 | + }else{ |
|
246 | + return $u['host'] . $u['path']; |
|
247 | + } |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * array2url |
|
252 | + * |
|
253 | + * @param array $arr An array |
|
254 | + * @return false|string false if KO, string of url if OK |
|
255 | + */ |
|
256 | + function array2url($arr) |
|
257 | + { // converts associated array to URL Query String |
|
258 | + if (!is_array($arr)){ |
|
259 | + return false; |
|
260 | + } |
|
261 | + $query = ''; |
|
262 | + foreach($arr as $key => $value){ |
|
263 | + $query .= $key . "=" . $value . "&"; |
|
264 | + } |
|
265 | + return $query; |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * FSOCK_Request |
|
270 | + * |
|
271 | + * @param string $url URL |
|
272 | + * @param string $method Method |
|
273 | + * @param string $params Params |
|
274 | + * @return boolean|unknown |
|
275 | + */ |
|
276 | + function FSOCK_Request($url, $method="GET", $params = "") |
|
277 | + { |
|
278 | + $fp = fsockopen("ssl://www.myopenid.com", 443, $errno, $errstr, 3); // Connection timeout is 3 seconds |
|
279 | + if (!$fp) { |
|
280 | + $this->ErrorStore('OPENID_SOCKETERROR', $errstr); |
|
281 | + return false; |
|
282 | + } else { |
|
283 | + $request = $method . " /server HTTP/1.0\r\n"; |
|
284 | + $request .= "User-Agent: Dolibarr\r\n"; |
|
285 | + $request .= "Connection: close\r\n\r\n"; |
|
286 | + fwrite($fp, $request); |
|
287 | + stream_set_timeout($fp, 4); // Connection response timeout is 4 seconds |
|
288 | + $res = fread($fp, 2000); |
|
289 | + $info = stream_get_meta_data($fp); |
|
290 | + fclose($fp); |
|
291 | + |
|
292 | + if ($info['timed_out']) { |
|
293 | + $this->ErrorStore('OPENID_SOCKETTIMEOUT'); |
|
294 | + } else { |
|
295 | + return $res; |
|
296 | + } |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * CURL_Request |
|
302 | + * |
|
303 | + * @param string $url URL |
|
304 | + * @param string $method Method |
|
305 | + * @param string $params Params |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + function CURL_Request($url, $method="GET", $params = "") |
|
309 | + { // Remember, SSL MUST BE SUPPORTED |
|
310 | + if (is_array($params)) $params = $this->array2url($params); |
|
311 | + |
|
312 | + $curl = curl_init($url . ($method == "GET" && $params != "" ? "?" . $params : "")); |
|
313 | + @curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
|
314 | + curl_setopt($curl, CURLOPT_HEADER, false); |
|
315 | + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
|
316 | + curl_setopt($curl, CURLOPT_HTTPGET, ($method == "GET")); |
|
317 | + curl_setopt($curl, CURLOPT_POST, ($method == "POST")); |
|
318 | + if ($method == "POST") curl_setopt($curl, CURLOPT_POSTFIELDS, $params); |
|
319 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
320 | + $response = curl_exec($curl); |
|
321 | + |
|
322 | + if (curl_errno($curl) == 0){ |
|
323 | + $response; |
|
324 | + }else{ |
|
325 | + $this->ErrorStore('OPENID_CURL', curl_error($curl)); |
|
326 | + } |
|
327 | + return $response; |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * HTML2OpenIDServer |
|
332 | + * |
|
333 | + * @param string $content Content |
|
334 | + * @return array Array of servers |
|
335 | + */ |
|
336 | + function HTML2OpenIDServer($content) |
|
337 | + { |
|
338 | + $get = array(); |
|
339 | + |
|
340 | + // Get details of their OpenID server and (optional) delegate |
|
341 | + preg_match_all('/<link[^>]*rel=[\'"]openid.server[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*\/?>/i', $content, $matches1); |
|
342 | + preg_match_all('/<link[^>]*href=\'"([^\'"]+)[\'"][^>]*rel=[\'"]openid.server[\'"][^>]*\/?>/i', $content, $matches2); |
|
343 | + $servers = array_merge($matches1[1], $matches2[1]); |
|
344 | + |
|
345 | + preg_match_all('/<link[^>]*rel=[\'"]openid.delegate[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*\/?>/i', $content, $matches1); |
|
346 | + |
|
347 | + preg_match_all('/<link[^>]*href=[\'"]([^\'"]+)[\'"][^>]*rel=[\'"]openid.delegate[\'"][^>]*\/?>/i', $content, $matches2); |
|
348 | + |
|
349 | + $delegates = array_merge($matches1[1], $matches2[1]); |
|
350 | + |
|
351 | + $ret = array($servers, $delegates); |
|
352 | + return $ret; |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Get openid server |
|
358 | + * |
|
359 | + * @param string $url Url to found endpoint |
|
360 | + * @return string Endpoint |
|
361 | + */ |
|
362 | + function GetOpenIDServer($url='') |
|
363 | + { |
|
364 | + global $conf; |
|
365 | 365 | |
366 | 366 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
367 | 367 | if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
368 | 368 | |
369 | - $response = getURLContent($url); |
|
370 | - |
|
371 | - list($servers, $delegates) = $this->HTML2OpenIDServer($response); |
|
372 | - if (count($servers) == 0){ |
|
373 | - $this->ErrorStore('OPENID_NOSERVERSFOUND'); |
|
374 | - return false; |
|
375 | - } |
|
376 | - if (isset($delegates[0]) |
|
377 | - && ($delegates[0] != "")){ |
|
378 | - $this->SetIdentity($delegates[0]); |
|
379 | - } |
|
380 | - $this->SetOpenIDServer($servers[0]); |
|
381 | - return $servers[0]; |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * GetRedirectURL |
|
386 | - * |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - function GetRedirectURL() |
|
390 | - { |
|
391 | - $params = array(); |
|
392 | - $params['openid.return_to'] = urlencode($this->URLs['approved']); |
|
393 | - $params['openid.mode'] = 'checkid_setup'; |
|
394 | - $params['openid.identity'] = urlencode($this->openid_url_identity); |
|
395 | - $params['openid.trust_root'] = urlencode($this->URLs['trust_root']); |
|
396 | - |
|
397 | - if (isset($this->fields['required']) |
|
398 | - && (count($this->fields['required']) > 0)) { |
|
399 | - $params['openid.sreg.required'] = implode(',',$this->fields['required']); |
|
400 | - } |
|
401 | - if (isset($this->fields['optional']) |
|
402 | - && (count($this->fields['optional']) > 0)) { |
|
403 | - $params['openid.sreg.optional'] = implode(',',$this->fields['optional']); |
|
404 | - } |
|
405 | - return $this->URLs['openid_server'] . "?". $this->array2url($params); |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * Redirect |
|
410 | - * |
|
411 | - * @return void |
|
412 | - */ |
|
413 | - function Redirect() |
|
414 | - { |
|
415 | - $redirect_to = $this->GetRedirectURL(); |
|
416 | - if (headers_sent()) |
|
417 | - { // Use JavaScript to redirect if content has been previously sent (not recommended, but safe) |
|
418 | - echo '<script language="JavaScript" type="text/javascript">window.location=\''; |
|
419 | - echo $redirect_to; |
|
420 | - echo '\';</script>'; |
|
421 | - } |
|
422 | - else |
|
423 | - { // Default Header Redirect |
|
424 | - header('Location: ' . $redirect_to); |
|
425 | - } |
|
426 | - } |
|
427 | - |
|
428 | - /** |
|
429 | - * ValidateWithServer |
|
430 | - * |
|
431 | - * @return boolean |
|
432 | - */ |
|
433 | - function ValidateWithServer() |
|
434 | - { |
|
435 | - $params = array( |
|
369 | + $response = getURLContent($url); |
|
370 | + |
|
371 | + list($servers, $delegates) = $this->HTML2OpenIDServer($response); |
|
372 | + if (count($servers) == 0){ |
|
373 | + $this->ErrorStore('OPENID_NOSERVERSFOUND'); |
|
374 | + return false; |
|
375 | + } |
|
376 | + if (isset($delegates[0]) |
|
377 | + && ($delegates[0] != "")){ |
|
378 | + $this->SetIdentity($delegates[0]); |
|
379 | + } |
|
380 | + $this->SetOpenIDServer($servers[0]); |
|
381 | + return $servers[0]; |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * GetRedirectURL |
|
386 | + * |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + function GetRedirectURL() |
|
390 | + { |
|
391 | + $params = array(); |
|
392 | + $params['openid.return_to'] = urlencode($this->URLs['approved']); |
|
393 | + $params['openid.mode'] = 'checkid_setup'; |
|
394 | + $params['openid.identity'] = urlencode($this->openid_url_identity); |
|
395 | + $params['openid.trust_root'] = urlencode($this->URLs['trust_root']); |
|
396 | + |
|
397 | + if (isset($this->fields['required']) |
|
398 | + && (count($this->fields['required']) > 0)) { |
|
399 | + $params['openid.sreg.required'] = implode(',',$this->fields['required']); |
|
400 | + } |
|
401 | + if (isset($this->fields['optional']) |
|
402 | + && (count($this->fields['optional']) > 0)) { |
|
403 | + $params['openid.sreg.optional'] = implode(',',$this->fields['optional']); |
|
404 | + } |
|
405 | + return $this->URLs['openid_server'] . "?". $this->array2url($params); |
|
406 | + } |
|
407 | + |
|
408 | + /** |
|
409 | + * Redirect |
|
410 | + * |
|
411 | + * @return void |
|
412 | + */ |
|
413 | + function Redirect() |
|
414 | + { |
|
415 | + $redirect_to = $this->GetRedirectURL(); |
|
416 | + if (headers_sent()) |
|
417 | + { // Use JavaScript to redirect if content has been previously sent (not recommended, but safe) |
|
418 | + echo '<script language="JavaScript" type="text/javascript">window.location=\''; |
|
419 | + echo $redirect_to; |
|
420 | + echo '\';</script>'; |
|
421 | + } |
|
422 | + else |
|
423 | + { // Default Header Redirect |
|
424 | + header('Location: ' . $redirect_to); |
|
425 | + } |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * ValidateWithServer |
|
430 | + * |
|
431 | + * @return boolean |
|
432 | + */ |
|
433 | + function ValidateWithServer() |
|
434 | + { |
|
435 | + $params = array( |
|
436 | 436 | 'openid.assoc_handle' => urlencode($_GET['openid_assoc_handle']), |
437 | 437 | 'openid.signed' => urlencode($_GET['openid_signed']), |
438 | 438 | 'openid.sig' => urlencode($_GET['openid_sig']) |
439 | - ); |
|
440 | - // Send only required parameters to confirm validity |
|
441 | - $arr_signed = explode(",",str_replace('sreg.','sreg_',$_GET['openid_signed'])); |
|
442 | - $num = count($arr_signed); |
|
443 | - for ($i = 0; $i < $num; $i++) |
|
444 | - { |
|
445 | - $s = str_replace('sreg_','sreg.', $arr_signed[$i]); |
|
446 | - $c = $_GET['openid_' . $arr_signed[$i]]; |
|
447 | - // if ($c != ""){ |
|
448 | - $params['openid.' . $s] = urlencode($c); |
|
449 | - // } |
|
450 | - } |
|
451 | - $params['openid.mode'] = "check_authentication"; |
|
452 | - |
|
453 | - $openid_server = $this->GetOpenIDServer(); |
|
454 | - if ($openid_server == false) |
|
455 | - { |
|
456 | - return false; |
|
457 | - } |
|
458 | - $response = $this->CURL_Request($openid_server,'POST',$params); |
|
459 | - $data = $this->splitResponse($response); |
|
460 | - if ($data['is_valid'] == "true") |
|
461 | - { |
|
462 | - return true; |
|
463 | - } |
|
464 | - else |
|
465 | - { |
|
466 | - return false; |
|
467 | - } |
|
468 | - } |
|
469 | - |
|
470 | - |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * Get XRDS response and set possible servers. |
|
475 | - * |
|
476 | - * @param string $url Url of endpoint to request |
|
477 | - * @return string First endpoint OpenID server found. False if it failed to found. |
|
478 | - */ |
|
479 | - function sendDiscoveryRequestToGetXRDS($url='') |
|
480 | - { |
|
481 | - global $conf; |
|
439 | + ); |
|
440 | + // Send only required parameters to confirm validity |
|
441 | + $arr_signed = explode(",",str_replace('sreg.','sreg_',$_GET['openid_signed'])); |
|
442 | + $num = count($arr_signed); |
|
443 | + for ($i = 0; $i < $num; $i++) |
|
444 | + { |
|
445 | + $s = str_replace('sreg_','sreg.', $arr_signed[$i]); |
|
446 | + $c = $_GET['openid_' . $arr_signed[$i]]; |
|
447 | + // if ($c != ""){ |
|
448 | + $params['openid.' . $s] = urlencode($c); |
|
449 | + // } |
|
450 | + } |
|
451 | + $params['openid.mode'] = "check_authentication"; |
|
452 | + |
|
453 | + $openid_server = $this->GetOpenIDServer(); |
|
454 | + if ($openid_server == false) |
|
455 | + { |
|
456 | + return false; |
|
457 | + } |
|
458 | + $response = $this->CURL_Request($openid_server,'POST',$params); |
|
459 | + $data = $this->splitResponse($response); |
|
460 | + if ($data['is_valid'] == "true") |
|
461 | + { |
|
462 | + return true; |
|
463 | + } |
|
464 | + else |
|
465 | + { |
|
466 | + return false; |
|
467 | + } |
|
468 | + } |
|
469 | + |
|
470 | + |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * Get XRDS response and set possible servers. |
|
475 | + * |
|
476 | + * @param string $url Url of endpoint to request |
|
477 | + * @return string First endpoint OpenID server found. False if it failed to found. |
|
478 | + */ |
|
479 | + function sendDiscoveryRequestToGetXRDS($url='') |
|
480 | + { |
|
481 | + global $conf; |
|
482 | 482 | |
483 | 483 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
484 | 484 | if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); |
487 | 487 | |
488 | 488 | $addheaders=array('Accept: application/xrds+xml'); |
489 | - $response = getURLContent($url, 'GET', '', 1, $addheaders); |
|
489 | + $response = getURLContent($url, 'GET', '', 1, $addheaders); |
|
490 | 490 | /* response should like this: |
491 | 491 | <?xml version="1.0" encoding="UTF-8"?> |
492 | 492 | <xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)"> |
@@ -502,24 +502,24 @@ discard block |
||
502 | 502 | */ |
503 | 503 | $content=$response['content']; |
504 | 504 | |
505 | - $server=''; |
|
506 | - if (preg_match('/'.preg_quote('<URI>','/').'(.*)'.preg_quote('</URI>','/').'/is', $content, $reg)) |
|
507 | - { |
|
508 | - $server=$reg[1]; |
|
509 | - } |
|
510 | - |
|
511 | - if (empty($server)) |
|
512 | - { |
|
513 | - $this->ErrorStore('OPENID_NOSERVERSFOUND'); |
|
514 | - return false; |
|
515 | - } |
|
516 | - else |
|
517 | - { |
|
518 | - dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); |
|
519 | - $this->SetOpenIDServer($server); |
|
520 | - return $server; |
|
521 | - } |
|
522 | - } |
|
505 | + $server=''; |
|
506 | + if (preg_match('/'.preg_quote('<URI>','/').'(.*)'.preg_quote('</URI>','/').'/is', $content, $reg)) |
|
507 | + { |
|
508 | + $server=$reg[1]; |
|
509 | + } |
|
510 | + |
|
511 | + if (empty($server)) |
|
512 | + { |
|
513 | + $this->ErrorStore('OPENID_NOSERVERSFOUND'); |
|
514 | + return false; |
|
515 | + } |
|
516 | + else |
|
517 | + { |
|
518 | + dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); |
|
519 | + $this->SetOpenIDServer($server); |
|
520 | + return $server; |
|
521 | + } |
|
522 | + } |
|
523 | 523 | |
524 | 524 | } |
525 | 525 |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | */ |
98 | 98 | function SetRequiredFields($a) |
99 | 99 | { |
100 | - if (is_array($a)){ |
|
100 | + if (is_array($a)) { |
|
101 | 101 | $this->fields['required'] = $a; |
102 | - }else{ |
|
102 | + } else { |
|
103 | 103 | $this->fields['required'][] = $a; |
104 | 104 | } |
105 | 105 | } |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | function SetOptionalFields($a) |
114 | 114 | { |
115 | - if (is_array($a)){ |
|
115 | + if (is_array($a)) { |
|
116 | 116 | $this->fields['optional'] = $a; |
117 | - }else{ |
|
117 | + } else { |
|
118 | 118 | $this->fields['optional'][] = $a; |
119 | 119 | } |
120 | 120 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | function SetIdentity($a) |
129 | 129 | { // Set Identity URL |
130 | 130 | if ((stripos($a, 'http://') === false) |
131 | - && (stripos($a, 'https://') === false)){ |
|
131 | + && (stripos($a, 'https://') === false)) { |
|
132 | 132 | $a = 'http://'.$a; |
133 | 133 | } |
134 | 134 | /* |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | function GetError() |
166 | 166 | { |
167 | 167 | $e = $this->error; |
168 | - return array('code'=>$e[0],'description'=>$e[1]); |
|
168 | + return array('code'=>$e[0], 'description'=>$e[1]); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | function ErrorStore($code, $desc = null) |
179 | 179 | { |
180 | 180 | $errs['OPENID_NOSERVERSFOUND'] = 'Cannot find OpenID Server TAG on Identity page.'; |
181 | - if ($desc == null){ |
|
181 | + if ($desc == null) { |
|
182 | 182 | $desc = $errs[$code]; |
183 | 183 | } |
184 | - $this->error = array($code,$desc); |
|
184 | + $this->error = array($code, $desc); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | { |
212 | 212 | $r = array(); |
213 | 213 | $response = explode("\n", $response); |
214 | - foreach($response as $line) { |
|
214 | + foreach ($response as $line) { |
|
215 | 215 | $line = trim($line); |
216 | 216 | if ($line != "") { |
217 | 217 | list($key, $value) = explode(":", $line, 2); |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | if (!isset($u['path']) || ($u['path'] == '/')) { |
238 | 238 | $u['path'] = ''; |
239 | 239 | } |
240 | - if(substr($u['path'],-1,1) == '/'){ |
|
241 | - $u['path'] = substr($u['path'], 0, strlen($u['path'])-1); |
|
240 | + if (substr($u['path'], -1, 1) == '/') { |
|
241 | + $u['path'] = substr($u['path'], 0, strlen($u['path']) - 1); |
|
242 | 242 | } |
243 | - if (isset($u['query'])){ // If there is a query string, then use identity as is |
|
244 | - return $u['host'] . $u['path'] . '?' . $u['query']; |
|
245 | - }else{ |
|
246 | - return $u['host'] . $u['path']; |
|
243 | + if (isset($u['query'])) { // If there is a query string, then use identity as is |
|
244 | + return $u['host'].$u['path'].'?'.$u['query']; |
|
245 | + } else { |
|
246 | + return $u['host'].$u['path']; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | */ |
256 | 256 | function array2url($arr) |
257 | 257 | { // converts associated array to URL Query String |
258 | - if (!is_array($arr)){ |
|
258 | + if (!is_array($arr)) { |
|
259 | 259 | return false; |
260 | 260 | } |
261 | 261 | $query = ''; |
262 | - foreach($arr as $key => $value){ |
|
263 | - $query .= $key . "=" . $value . "&"; |
|
262 | + foreach ($arr as $key => $value) { |
|
263 | + $query .= $key."=".$value."&"; |
|
264 | 264 | } |
265 | 265 | return $query; |
266 | 266 | } |
@@ -273,14 +273,14 @@ discard block |
||
273 | 273 | * @param string $params Params |
274 | 274 | * @return boolean|unknown |
275 | 275 | */ |
276 | - function FSOCK_Request($url, $method="GET", $params = "") |
|
276 | + function FSOCK_Request($url, $method = "GET", $params = "") |
|
277 | 277 | { |
278 | 278 | $fp = fsockopen("ssl://www.myopenid.com", 443, $errno, $errstr, 3); // Connection timeout is 3 seconds |
279 | 279 | if (!$fp) { |
280 | 280 | $this->ErrorStore('OPENID_SOCKETERROR', $errstr); |
281 | 281 | return false; |
282 | 282 | } else { |
283 | - $request = $method . " /server HTTP/1.0\r\n"; |
|
283 | + $request = $method." /server HTTP/1.0\r\n"; |
|
284 | 284 | $request .= "User-Agent: Dolibarr\r\n"; |
285 | 285 | $request .= "Connection: close\r\n\r\n"; |
286 | 286 | fwrite($fp, $request); |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | * @param string $params Params |
306 | 306 | * @return string |
307 | 307 | */ |
308 | - function CURL_Request($url, $method="GET", $params = "") |
|
308 | + function CURL_Request($url, $method = "GET", $params = "") |
|
309 | 309 | { // Remember, SSL MUST BE SUPPORTED |
310 | 310 | if (is_array($params)) $params = $this->array2url($params); |
311 | 311 | |
312 | - $curl = curl_init($url . ($method == "GET" && $params != "" ? "?" . $params : "")); |
|
312 | + $curl = curl_init($url.($method == "GET" && $params != "" ? "?".$params : "")); |
|
313 | 313 | @curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
314 | 314 | curl_setopt($curl, CURLOPT_HEADER, false); |
315 | 315 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
320 | 320 | $response = curl_exec($curl); |
321 | 321 | |
322 | - if (curl_errno($curl) == 0){ |
|
322 | + if (curl_errno($curl) == 0) { |
|
323 | 323 | $response; |
324 | - }else{ |
|
324 | + } else { |
|
325 | 325 | $this->ErrorStore('OPENID_CURL', curl_error($curl)); |
326 | 326 | } |
327 | 327 | return $response; |
@@ -359,22 +359,22 @@ discard block |
||
359 | 359 | * @param string $url Url to found endpoint |
360 | 360 | * @return string Endpoint |
361 | 361 | */ |
362 | - function GetOpenIDServer($url='') |
|
362 | + function GetOpenIDServer($url = '') |
|
363 | 363 | { |
364 | 364 | global $conf; |
365 | 365 | |
366 | 366 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
367 | - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
367 | + if (empty($url)) $url = $conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
368 | 368 | |
369 | 369 | $response = getURLContent($url); |
370 | 370 | |
371 | 371 | list($servers, $delegates) = $this->HTML2OpenIDServer($response); |
372 | - if (count($servers) == 0){ |
|
372 | + if (count($servers) == 0) { |
|
373 | 373 | $this->ErrorStore('OPENID_NOSERVERSFOUND'); |
374 | 374 | return false; |
375 | 375 | } |
376 | 376 | if (isset($delegates[0]) |
377 | - && ($delegates[0] != "")){ |
|
377 | + && ($delegates[0] != "")) { |
|
378 | 378 | $this->SetIdentity($delegates[0]); |
379 | 379 | } |
380 | 380 | $this->SetOpenIDServer($servers[0]); |
@@ -396,13 +396,13 @@ discard block |
||
396 | 396 | |
397 | 397 | if (isset($this->fields['required']) |
398 | 398 | && (count($this->fields['required']) > 0)) { |
399 | - $params['openid.sreg.required'] = implode(',',$this->fields['required']); |
|
399 | + $params['openid.sreg.required'] = implode(',', $this->fields['required']); |
|
400 | 400 | } |
401 | 401 | if (isset($this->fields['optional']) |
402 | 402 | && (count($this->fields['optional']) > 0)) { |
403 | - $params['openid.sreg.optional'] = implode(',',$this->fields['optional']); |
|
403 | + $params['openid.sreg.optional'] = implode(',', $this->fields['optional']); |
|
404 | 404 | } |
405 | - return $this->URLs['openid_server'] . "?". $this->array2url($params); |
|
405 | + return $this->URLs['openid_server']."?".$this->array2url($params); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | } |
422 | 422 | else |
423 | 423 | { // Default Header Redirect |
424 | - header('Location: ' . $redirect_to); |
|
424 | + header('Location: '.$redirect_to); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
@@ -438,14 +438,14 @@ discard block |
||
438 | 438 | 'openid.sig' => urlencode($_GET['openid_sig']) |
439 | 439 | ); |
440 | 440 | // Send only required parameters to confirm validity |
441 | - $arr_signed = explode(",",str_replace('sreg.','sreg_',$_GET['openid_signed'])); |
|
441 | + $arr_signed = explode(",", str_replace('sreg.', 'sreg_', $_GET['openid_signed'])); |
|
442 | 442 | $num = count($arr_signed); |
443 | 443 | for ($i = 0; $i < $num; $i++) |
444 | 444 | { |
445 | - $s = str_replace('sreg_','sreg.', $arr_signed[$i]); |
|
446 | - $c = $_GET['openid_' . $arr_signed[$i]]; |
|
445 | + $s = str_replace('sreg_', 'sreg.', $arr_signed[$i]); |
|
446 | + $c = $_GET['openid_'.$arr_signed[$i]]; |
|
447 | 447 | // if ($c != ""){ |
448 | - $params['openid.' . $s] = urlencode($c); |
|
448 | + $params['openid.'.$s] = urlencode($c); |
|
449 | 449 | // } |
450 | 450 | } |
451 | 451 | $params['openid.mode'] = "check_authentication"; |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | { |
456 | 456 | return false; |
457 | 457 | } |
458 | - $response = $this->CURL_Request($openid_server,'POST',$params); |
|
458 | + $response = $this->CURL_Request($openid_server, 'POST', $params); |
|
459 | 459 | $data = $this->splitResponse($response); |
460 | 460 | if ($data['is_valid'] == "true") |
461 | 461 | { |
@@ -476,16 +476,16 @@ discard block |
||
476 | 476 | * @param string $url Url of endpoint to request |
477 | 477 | * @return string First endpoint OpenID server found. False if it failed to found. |
478 | 478 | */ |
479 | - function sendDiscoveryRequestToGetXRDS($url='') |
|
479 | + function sendDiscoveryRequestToGetXRDS($url = '') |
|
480 | 480 | { |
481 | 481 | global $conf; |
482 | 482 | |
483 | 483 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
484 | - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
484 | + if (empty($url)) $url = $conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
485 | 485 | |
486 | 486 | dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); |
487 | 487 | |
488 | - $addheaders=array('Accept: application/xrds+xml'); |
|
488 | + $addheaders = array('Accept: application/xrds+xml'); |
|
489 | 489 | $response = getURLContent($url, 'GET', '', 1, $addheaders); |
490 | 490 | /* response should like this: |
491 | 491 | <?xml version="1.0" encoding="UTF-8"?> |
@@ -500,12 +500,12 @@ discard block |
||
500 | 500 | </XRD> |
501 | 501 | </xrds:XRDS> |
502 | 502 | */ |
503 | - $content=$response['content']; |
|
503 | + $content = $response['content']; |
|
504 | 504 | |
505 | - $server=''; |
|
506 | - if (preg_match('/'.preg_quote('<URI>','/').'(.*)'.preg_quote('</URI>','/').'/is', $content, $reg)) |
|
505 | + $server = ''; |
|
506 | + if (preg_match('/'.preg_quote('<URI>', '/').'(.*)'.preg_quote('</URI>', '/').'/is', $content, $reg)) |
|
507 | 507 | { |
508 | - $server=$reg[1]; |
|
508 | + $server = $reg[1]; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | if (empty($server)) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | if (is_array($a)){ |
101 | 101 | $this->fields['required'] = $a; |
102 | - }else{ |
|
102 | + } else{ |
|
103 | 103 | $this->fields['required'][] = $a; |
104 | 104 | } |
105 | 105 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | if (is_array($a)){ |
116 | 116 | $this->fields['optional'] = $a; |
117 | - }else{ |
|
117 | + } else{ |
|
118 | 118 | $this->fields['optional'][] = $a; |
119 | 119 | } |
120 | 120 | } |
@@ -194,8 +194,7 @@ discard block |
||
194 | 194 | if (count($this->error) > 0) |
195 | 195 | { |
196 | 196 | return true; |
197 | - } |
|
198 | - else |
|
197 | + } else |
|
199 | 198 | { |
200 | 199 | return false; |
201 | 200 | } |
@@ -229,8 +228,9 @@ discard block |
||
229 | 228 | */ |
230 | 229 | function OpenID_Standarize($openid_identity = null) |
231 | 230 | { |
232 | - if ($openid_identity === null) |
|
233 | - $openid_identity = $this->openid_url_identity; |
|
231 | + if ($openid_identity === null) { |
|
232 | + $openid_identity = $this->openid_url_identity; |
|
233 | + } |
|
234 | 234 | |
235 | 235 | $u = parse_url(strtolower(trim($openid_identity))); |
236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | if (isset($u['query'])){ // If there is a query string, then use identity as is |
244 | 244 | return $u['host'] . $u['path'] . '?' . $u['query']; |
245 | - }else{ |
|
245 | + } else{ |
|
246 | 246 | return $u['host'] . $u['path']; |
247 | 247 | } |
248 | 248 | } |
@@ -307,7 +307,9 @@ discard block |
||
307 | 307 | */ |
308 | 308 | function CURL_Request($url, $method="GET", $params = "") |
309 | 309 | { // Remember, SSL MUST BE SUPPORTED |
310 | - if (is_array($params)) $params = $this->array2url($params); |
|
310 | + if (is_array($params)) { |
|
311 | + $params = $this->array2url($params); |
|
312 | + } |
|
311 | 313 | |
312 | 314 | $curl = curl_init($url . ($method == "GET" && $params != "" ? "?" . $params : "")); |
313 | 315 | @curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
@@ -315,13 +317,15 @@ discard block |
||
315 | 317 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
316 | 318 | curl_setopt($curl, CURLOPT_HTTPGET, ($method == "GET")); |
317 | 319 | curl_setopt($curl, CURLOPT_POST, ($method == "POST")); |
318 | - if ($method == "POST") curl_setopt($curl, CURLOPT_POSTFIELDS, $params); |
|
320 | + if ($method == "POST") { |
|
321 | + curl_setopt($curl, CURLOPT_POSTFIELDS, $params); |
|
322 | + } |
|
319 | 323 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
320 | 324 | $response = curl_exec($curl); |
321 | 325 | |
322 | 326 | if (curl_errno($curl) == 0){ |
323 | 327 | $response; |
324 | - }else{ |
|
328 | + } else{ |
|
325 | 329 | $this->ErrorStore('OPENID_CURL', curl_error($curl)); |
326 | 330 | } |
327 | 331 | return $response; |
@@ -364,7 +368,9 @@ discard block |
||
364 | 368 | global $conf; |
365 | 369 | |
366 | 370 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
367 | - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
371 | + if (empty($url)) { |
|
372 | + $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
373 | + } |
|
368 | 374 | |
369 | 375 | $response = getURLContent($url); |
370 | 376 | |
@@ -418,8 +424,7 @@ discard block |
||
418 | 424 | echo '<script language="JavaScript" type="text/javascript">window.location=\''; |
419 | 425 | echo $redirect_to; |
420 | 426 | echo '\';</script>'; |
421 | - } |
|
422 | - else |
|
427 | + } else |
|
423 | 428 | { // Default Header Redirect |
424 | 429 | header('Location: ' . $redirect_to); |
425 | 430 | } |
@@ -460,8 +465,7 @@ discard block |
||
460 | 465 | if ($data['is_valid'] == "true") |
461 | 466 | { |
462 | 467 | return true; |
463 | - } |
|
464 | - else |
|
468 | + } else |
|
465 | 469 | { |
466 | 470 | return false; |
467 | 471 | } |
@@ -481,7 +485,9 @@ discard block |
||
481 | 485 | global $conf; |
482 | 486 | |
483 | 487 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
484 | - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
488 | + if (empty($url)) { |
|
489 | + $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
490 | + } |
|
485 | 491 | |
486 | 492 | dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); |
487 | 493 | |
@@ -512,8 +518,7 @@ discard block |
||
512 | 518 | { |
513 | 519 | $this->ErrorStore('OPENID_NOSERVERSFOUND'); |
514 | 520 | return false; |
515 | - } |
|
516 | - else |
|
521 | + } else |
|
517 | 522 | { |
518 | 523 | dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); |
519 | 524 | $this->SetOpenIDServer($server); |
@@ -113,15 +113,19 @@ discard block |
||
113 | 113 | dol_syslog("AntiVir::dol_avscan_file Result return_var=".$return_var." output=".join(',',$output)); |
114 | 114 | |
115 | 115 | $returncodevirus=1; |
116 | - if ($return_var == $returncodevirus) // Virus found |
|
116 | + if ($return_var == $returncodevirus) { |
|
117 | + // Virus found |
|
117 | 118 | { |
118 | 119 | $this->errors=$output; |
120 | + } |
|
119 | 121 | return -99; |
120 | 122 | } |
121 | 123 | |
122 | - if ($return_var > 0) // If other error |
|
124 | + if ($return_var > 0) { |
|
125 | + // If other error |
|
123 | 126 | { |
124 | 127 | $this->errors=$output; |
128 | + } |
|
125 | 129 | return -98; |
126 | 130 | } |
127 | 131 | |
@@ -157,10 +161,14 @@ discard block |
||
157 | 161 | $param=preg_replace('/%maxfilesize/',$maxfilesize,$param); |
158 | 162 | $param=preg_replace('/%file/',trim($file),$param); |
159 | 163 | |
160 | - if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM)) |
|
161 | - $param=$param." ".escapeshellarg(trim($file)); |
|
164 | + if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM)) { |
|
165 | + $param=$param." ".escapeshellarg(trim($file)); |
|
166 | + } |
|
162 | 167 | |
163 | - if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails. |
|
168 | + if (preg_match("/\s/",$command)) { |
|
169 | + $command=escapeshellarg($command); |
|
170 | + } |
|
171 | + // Use quotes on command. Using escapeshellcmd fails. |
|
164 | 172 | |
165 | 173 | $ret=$command.' '.$param; |
166 | 174 | //$ret=$command.' '.$param.' 2>&1'; |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | |
63 | 63 | if (preg_match('/\.virus$/i', $file)) |
64 | 64 | { |
65 | - $this->errors='File has an extension saying file is a virus'; |
|
66 | - return -97; |
|
65 | + $this->errors='File has an extension saying file is a virus'; |
|
66 | + return -97; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | $fullcommand=$this->getCliCommand($file); |
70 | 70 | //$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"'; |
71 | - $fullcommand.=' 2>&1'; // This is to get error output |
|
71 | + $fullcommand.=' 2>&1'; // This is to get error output |
|
72 | 72 | |
73 | 73 | $output=array(); |
74 | 74 | $return_var=0; |
75 | - $safemode=ini_get("safe_mode"); |
|
75 | + $safemode=ini_get("safe_mode"); |
|
76 | 76 | // Create a clean fullcommand |
77 | 77 | dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode?"on":"off")); |
78 | 78 | // Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL% |
79 | 79 | $lastline=exec($fullcommand, $output, $return_var); |
80 | 80 | |
81 | - //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; |
|
81 | + //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; |
|
82 | 82 | |
83 | 83 | /* |
84 | 84 | $outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id(); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | $ret=$command.' '.$param; |
166 | 166 | //$ret=$command.' '.$param.' 2>&1'; |
167 | - //print "xx".$ret."xx";exit; |
|
167 | + //print "xx".$ret."xx";exit; |
|
168 | 168 | |
169 | 169 | return $ret; |
170 | 170 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | function __construct($db) |
45 | 45 | { |
46 | - $this->db=$db; |
|
46 | + $this->db = $db; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | |
63 | 63 | if (preg_match('/\.virus$/i', $file)) |
64 | 64 | { |
65 | - $this->errors='File has an extension saying file is a virus'; |
|
65 | + $this->errors = 'File has an extension saying file is a virus'; |
|
66 | 66 | return -97; |
67 | 67 | } |
68 | 68 | |
69 | - $fullcommand=$this->getCliCommand($file); |
|
69 | + $fullcommand = $this->getCliCommand($file); |
|
70 | 70 | //$fullcommand='"c:\Program Files (x86)\ClamWin\bin\clamscan.exe" --database="C:\Program Files (x86)\ClamWin\lib" "c:\temp\aaa.txt"'; |
71 | - $fullcommand.=' 2>&1'; // This is to get error output |
|
71 | + $fullcommand .= ' 2>&1'; // This is to get error output |
|
72 | 72 | |
73 | - $output=array(); |
|
74 | - $return_var=0; |
|
75 | - $safemode=ini_get("safe_mode"); |
|
73 | + $output = array(); |
|
74 | + $return_var = 0; |
|
75 | + $safemode = ini_get("safe_mode"); |
|
76 | 76 | // Create a clean fullcommand |
77 | - dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode?"on":"off")); |
|
77 | + dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode ? "on" : "off")); |
|
78 | 78 | // Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL% |
79 | - $lastline=exec($fullcommand, $output, $return_var); |
|
79 | + $lastline = exec($fullcommand, $output, $return_var); |
|
80 | 80 | |
81 | 81 | //print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit; |
82 | 82 | |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | } |
111 | 111 | */ |
112 | 112 | |
113 | - dol_syslog("AntiVir::dol_avscan_file Result return_var=".$return_var." output=".join(',',$output)); |
|
113 | + dol_syslog("AntiVir::dol_avscan_file Result return_var=".$return_var." output=".join(',', $output)); |
|
114 | 114 | |
115 | - $returncodevirus=1; |
|
115 | + $returncodevirus = 1; |
|
116 | 116 | if ($return_var == $returncodevirus) // Virus found |
117 | 117 | { |
118 | - $this->errors=$output; |
|
118 | + $this->errors = $output; |
|
119 | 119 | return -99; |
120 | 120 | } |
121 | 121 | |
122 | 122 | if ($return_var > 0) // If other error |
123 | 123 | { |
124 | - $this->errors=$output; |
|
124 | + $this->errors = $output; |
|
125 | 125 | return -98; |
126 | 126 | } |
127 | 127 | |
@@ -141,28 +141,28 @@ discard block |
||
141 | 141 | { |
142 | 142 | global $conf; |
143 | 143 | |
144 | - $maxreclevel = 5 ; // maximal recursion level |
|
145 | - $maxfiles = 1000; // maximal number of files to be scanned within archive |
|
146 | - $maxratio = 200; // maximal compression ratio |
|
147 | - $bz2archivememlim = 0; // limit memory usage for bzip2 (0/1) |
|
148 | - $maxfilesize = 10485760; // archived files larger than this value (in bytes) will not be scanned |
|
144 | + $maxreclevel = 5; // maximal recursion level |
|
145 | + $maxfiles = 1000; // maximal number of files to be scanned within archive |
|
146 | + $maxratio = 200; // maximal compression ratio |
|
147 | + $bz2archivememlim = 0; // limit memory usage for bzip2 (0/1) |
|
148 | + $maxfilesize = 10485760; // archived files larger than this value (in bytes) will not be scanned |
|
149 | 149 | |
150 | - $command=$conf->global->MAIN_ANTIVIRUS_COMMAND; |
|
151 | - $param=$conf->global->MAIN_ANTIVIRUS_PARAM; |
|
150 | + $command = $conf->global->MAIN_ANTIVIRUS_COMMAND; |
|
151 | + $param = $conf->global->MAIN_ANTIVIRUS_PARAM; |
|
152 | 152 | |
153 | - $param=preg_replace('/%maxreclevel/',$maxreclevel,$param); |
|
154 | - $param=preg_replace('/%maxfiles/',$maxfiles,$param); |
|
155 | - $param=preg_replace('/%maxratio/',$maxratio,$param); |
|
156 | - $param=preg_replace('/%bz2archivememlim/',$bz2archivememlim,$param); |
|
157 | - $param=preg_replace('/%maxfilesize/',$maxfilesize,$param); |
|
158 | - $param=preg_replace('/%file/',trim($file),$param); |
|
153 | + $param = preg_replace('/%maxreclevel/', $maxreclevel, $param); |
|
154 | + $param = preg_replace('/%maxfiles/', $maxfiles, $param); |
|
155 | + $param = preg_replace('/%maxratio/', $maxratio, $param); |
|
156 | + $param = preg_replace('/%bz2archivememlim/', $bz2archivememlim, $param); |
|
157 | + $param = preg_replace('/%maxfilesize/', $maxfilesize, $param); |
|
158 | + $param = preg_replace('/%file/', trim($file), $param); |
|
159 | 159 | |
160 | - if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM)) |
|
161 | - $param=$param." ".escapeshellarg(trim($file)); |
|
160 | + if (!preg_match('/%file/', $conf->global->MAIN_ANTIVIRUS_PARAM)) |
|
161 | + $param = $param." ".escapeshellarg(trim($file)); |
|
162 | 162 | |
163 | - if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails. |
|
163 | + if (preg_match("/\s/", $command)) $command = escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails. |
|
164 | 164 | |
165 | - $ret=$command.' '.$param; |
|
165 | + $ret = $command.' '.$param; |
|
166 | 166 | //$ret=$command.' '.$param.' 2>&1'; |
167 | 167 | //print "xx".$ret."xx";exit; |
168 | 168 |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | { |
46 | 46 | if ($type == 'country') |
47 | 47 | { |
48 | - // geoip may have been already included with PEAR |
|
49 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoip.inc'; |
|
48 | + // geoip may have been already included with PEAR |
|
49 | + if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoip.inc'; |
|
50 | 50 | } |
51 | 51 | else if ($type == 'city') |
52 | 52 | { |
53 | - // geoip may have been already included with PEAR |
|
54 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoipcity.inc'; |
|
53 | + // geoip may have been already included with PEAR |
|
54 | + if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoipcity.inc'; |
|
55 | 55 | } |
56 | 56 | else { print 'ErrorBadParameterInConstructor'; return 0; } |
57 | 57 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | } |
77 | 77 | else |
78 | 78 | { |
79 | - $this->gi = 'NOGI'; // We are using embedded php geoip functions |
|
80 | - //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); |
|
81 | - //print geoip_database_info(); |
|
79 | + $this->gi = 'NOGI'; // We are using embedded php geoip functions |
|
80 | + //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); |
|
81 | + //print geoip_database_info(); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | } |
97 | 97 | if ($this->gi == 'NOGI') |
98 | 98 | { |
99 | - // geoip_country_code_by_addr does not exists |
|
100 | - return strtolower(geoip_country_code_by_name($ip)); |
|
99 | + // geoip_country_code_by_addr does not exists |
|
100 | + return strtolower(geoip_country_code_by_name($ip)); |
|
101 | 101 | } |
102 | 102 | else |
103 | 103 | { |
104 | - if (! function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
105 | - return strtolower(geoip_country_code_by_addr($this->gi, $ip)); |
|
104 | + if (! function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
105 | + return strtolower(geoip_country_code_by_addr($this->gi, $ip)); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | function getVersion() |
130 | 130 | { |
131 | - if ($this->gi == 'NOGI') return geoip_database_info(); |
|
131 | + if ($this->gi == 'NOGI') return geoip_database_info(); |
|
132 | 132 | return 'Not available (not using PHP internal geo functions)'; |
133 | 133 | } |
134 | 134 | |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | */ |
140 | 140 | function close() |
141 | 141 | { |
142 | - if (function_exists('geoip_close')) // With some geoip with PEAR, geoip_close function may not exists |
|
143 | - { |
|
144 | - geoip_close($this->gi); |
|
145 | - } |
|
142 | + if (function_exists('geoip_close')) // With some geoip with PEAR, geoip_close function may not exists |
|
143 | + { |
|
144 | + geoip_close($this->gi); |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | } |
@@ -41,42 +41,42 @@ discard block |
||
41 | 41 | * @param string $type 'country' or 'city' |
42 | 42 | * @param string $datfile Data file |
43 | 43 | */ |
44 | - function __construct($type,$datfile) |
|
44 | + function __construct($type, $datfile) |
|
45 | 45 | { |
46 | 46 | if ($type == 'country') |
47 | 47 | { |
48 | 48 | // geoip may have been already included with PEAR |
49 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoip.inc'; |
|
49 | + if (!function_exists('geoip_country_code_by_name')) $res = include_once GEOIP_PATH.'geoip.inc'; |
|
50 | 50 | } |
51 | 51 | else if ($type == 'city') |
52 | 52 | { |
53 | 53 | // geoip may have been already included with PEAR |
54 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoipcity.inc'; |
|
54 | + if (!function_exists('geoip_country_code_by_name')) $res = include_once GEOIP_PATH.'geoipcity.inc'; |
|
55 | 55 | } |
56 | 56 | else { print 'ErrorBadParameterInConstructor'; return 0; } |
57 | 57 | |
58 | 58 | // Here, function exists (embedded into PHP or exists because we made include) |
59 | 59 | if (empty($type) || empty($datfile)) |
60 | 60 | { |
61 | - $this->errorlabel='Constructor was called with no datafile parameter'; |
|
61 | + $this->errorlabel = 'Constructor was called with no datafile parameter'; |
|
62 | 62 | dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); |
63 | 63 | return 0; |
64 | 64 | } |
65 | - if (! file_exists($datfile) || ! is_readable($datfile)) |
|
65 | + if (!file_exists($datfile) || !is_readable($datfile)) |
|
66 | 66 | { |
67 | - $this->error='ErrorGeoIPClassNotInitialized'; |
|
68 | - $this->errorlabel="Datafile ".$datfile." not found"; |
|
67 | + $this->error = 'ErrorGeoIPClassNotInitialized'; |
|
68 | + $this->errorlabel = "Datafile ".$datfile." not found"; |
|
69 | 69 | dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR); |
70 | 70 | return 0; |
71 | 71 | } |
72 | 72 | |
73 | 73 | if (function_exists('geoip_open')) |
74 | 74 | { |
75 | - $this->gi = geoip_open($datfile,GEOIP_STANDARD); |
|
75 | + $this->gi = geoip_open($datfile, GEOIP_STANDARD); |
|
76 | 76 | } |
77 | 77 | else |
78 | 78 | { |
79 | - $this->gi = 'NOGI'; // We are using embedded php geoip functions |
|
79 | + $this->gi = 'NOGI'; // We are using embedded php geoip functions |
|
80 | 80 | //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); |
81 | 81 | //print geoip_database_info(); |
82 | 82 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | else |
103 | 103 | { |
104 | - if (! function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
104 | + if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
105 | 105 | return strtolower(geoip_country_code_by_addr($this->gi, $ip)); |
106 | 106 | } |
107 | 107 | } |
@@ -46,14 +46,16 @@ discard block |
||
46 | 46 | if ($type == 'country') |
47 | 47 | { |
48 | 48 | // geoip may have been already included with PEAR |
49 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoip.inc'; |
|
50 | - } |
|
51 | - else if ($type == 'city') |
|
49 | + if (! function_exists('geoip_country_code_by_name')) { |
|
50 | + $res=include_once GEOIP_PATH.'geoip.inc'; |
|
51 | + } |
|
52 | + } else if ($type == 'city') |
|
52 | 53 | { |
53 | 54 | // geoip may have been already included with PEAR |
54 | - if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoipcity.inc'; |
|
55 | - } |
|
56 | - else { print 'ErrorBadParameterInConstructor'; return 0; } |
|
55 | + if (! function_exists('geoip_country_code_by_name')) { |
|
56 | + $res=include_once GEOIP_PATH.'geoipcity.inc'; |
|
57 | + } |
|
58 | + } else { print 'ErrorBadParameterInConstructor'; return 0; } |
|
57 | 59 | |
58 | 60 | // Here, function exists (embedded into PHP or exists because we made include) |
59 | 61 | if (empty($type) || empty($datfile)) |
@@ -73,8 +75,7 @@ discard block |
||
73 | 75 | if (function_exists('geoip_open')) |
74 | 76 | { |
75 | 77 | $this->gi = geoip_open($datfile,GEOIP_STANDARD); |
76 | - } |
|
77 | - else |
|
78 | + } else |
|
78 | 79 | { |
79 | 80 | $this->gi = 'NOGI'; // We are using embedded php geoip functions |
80 | 81 | //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); |
@@ -98,10 +99,11 @@ discard block |
||
98 | 99 | { |
99 | 100 | // geoip_country_code_by_addr does not exists |
100 | 101 | return strtolower(geoip_country_code_by_name($ip)); |
101 | - } |
|
102 | - else |
|
102 | + } else |
|
103 | 103 | { |
104 | - if (! function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
104 | + if (! function_exists('geoip_country_code_by_addr')) { |
|
105 | + return strtolower(geoip_country_code_by_name($this->gi, $ip)); |
|
106 | + } |
|
105 | 107 | return strtolower(geoip_country_code_by_addr($this->gi, $ip)); |
106 | 108 | } |
107 | 109 | } |
@@ -128,7 +130,9 @@ discard block |
||
128 | 130 | */ |
129 | 131 | function getVersion() |
130 | 132 | { |
131 | - if ($this->gi == 'NOGI') return geoip_database_info(); |
|
133 | + if ($this->gi == 'NOGI') { |
|
134 | + return geoip_database_info(); |
|
135 | + } |
|
132 | 136 | return 'Not available (not using PHP internal geo functions)'; |
133 | 137 | } |
134 | 138 | |
@@ -139,9 +143,11 @@ discard block |
||
139 | 143 | */ |
140 | 144 | function close() |
141 | 145 | { |
142 | - if (function_exists('geoip_close')) // With some geoip with PEAR, geoip_close function may not exists |
|
146 | + if (function_exists('geoip_close')) { |
|
147 | + // With some geoip with PEAR, geoip_close function may not exists |
|
143 | 148 | { |
144 | 149 | geoip_close($this->gi); |
145 | 150 | } |
151 | + } |
|
146 | 152 | } |
147 | 153 | } |
@@ -32,38 +32,38 @@ discard block |
||
32 | 32 | { |
33 | 33 | |
34 | 34 | /** |
35 | - * Return combo list of differents status of a orders |
|
36 | - * |
|
37 | - * @param string $selected Preselected value |
|
38 | - * @param int $short Use short labels |
|
39 | - * @param string $hmlname Name of HTML select element |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') |
|
43 | - { |
|
44 | - $options = array(); |
|
45 | - |
|
46 | - // 7 is same label than 6. 8 does not exists (billed is another field) |
|
47 | - $statustohow = array( |
|
48 | - '0' => '0', |
|
49 | - '1' => '1', |
|
50 | - '2' => '2', |
|
51 | - '3' => '3', |
|
52 | - '4' => '4', |
|
53 | - '5' => '5', |
|
54 | - '6' => '6,7', |
|
55 | - '9' => '9' |
|
56 | - ); |
|
57 | - |
|
58 | - $tmpsupplierorder = new CommandeFournisseur($this->db); |
|
59 | - |
|
60 | - foreach ($statustohow as $key => $value) { |
|
61 | - $tmpsupplierorder->statut = $key; |
|
62 | - $options[$value] = $tmpsupplierorder->getLibStatut($short); |
|
63 | - } |
|
64 | - |
|
65 | - print Form::selectarray($hmlname, $options, $selected, 1); |
|
66 | - } |
|
35 | + * Return combo list of differents status of a orders |
|
36 | + * |
|
37 | + * @param string $selected Preselected value |
|
38 | + * @param int $short Use short labels |
|
39 | + * @param string $hmlname Name of HTML select element |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') |
|
43 | + { |
|
44 | + $options = array(); |
|
45 | + |
|
46 | + // 7 is same label than 6. 8 does not exists (billed is another field) |
|
47 | + $statustohow = array( |
|
48 | + '0' => '0', |
|
49 | + '1' => '1', |
|
50 | + '2' => '2', |
|
51 | + '3' => '3', |
|
52 | + '4' => '4', |
|
53 | + '5' => '5', |
|
54 | + '6' => '6,7', |
|
55 | + '9' => '9' |
|
56 | + ); |
|
57 | + |
|
58 | + $tmpsupplierorder = new CommandeFournisseur($this->db); |
|
59 | + |
|
60 | + foreach ($statustohow as $key => $value) { |
|
61 | + $tmpsupplierorder->statut = $key; |
|
62 | + $options[$value] = $tmpsupplierorder->getLibStatut($short); |
|
63 | + } |
|
64 | + |
|
65 | + print Form::selectarray($hmlname, $options, $selected, 1); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Return list of input method (mode used to receive order, like order received by email, fax, online) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | global $langs; |
80 | 80 | |
81 | - $listofmethods=array(); |
|
81 | + $listofmethods=array(); |
|
82 | 82 | |
83 | 83 | $sql = "SELECT rowid, code, libelle as label"; |
84 | 84 | $sql.= " FROM ".MAIN_DB_PREFIX."c_input_method"; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File of predefined functions for HTML forms for order module |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Class to manage HTML output components for orders |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param string $hmlname Name of HTML select element |
40 | 40 | * @return void |
41 | 41 | */ |
42 | - public function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') |
|
42 | + public function selectSupplierOrderStatus($selected = '', $short = 0, $hmlname = 'order_status') |
|
43 | 43 | { |
44 | 44 | $options = array(); |
45 | 45 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @param int $addempty 0=list with no empty value, 1=list with empty value |
75 | 75 | * @return array Tableau des sources de commandes |
76 | 76 | */ |
77 | - public function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) |
|
77 | + public function selectInputMethod($selected = '', $htmlname = 'source_id', $addempty = 0) |
|
78 | 78 | { |
79 | 79 | global $langs; |
80 | 80 | |
81 | - $listofmethods=array(); |
|
81 | + $listofmethods = array(); |
|
82 | 82 | |
83 | 83 | $sql = "SELECT rowid, code, libelle as label"; |
84 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_input_method"; |
|
85 | - $sql.= " WHERE active = 1"; |
|
84 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method"; |
|
85 | + $sql .= " WHERE active = 1"; |
|
86 | 86 | |
87 | 87 | dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG); |
88 | - $resql=$this->db->query($sql); |
|
88 | + $resql = $this->db->query($sql); |
|
89 | 89 | |
90 | 90 | if (!$resql) { |
91 | 91 | dol_print_error($this->db); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label; |
97 | 97 | } |
98 | 98 | |
99 | - print Form::selectarray($htmlname,$listofmethods,$selected,$addempty); |
|
99 | + print Form::selectarray($htmlname, $listofmethods, $selected, $addempty); |
|
100 | 100 | |
101 | 101 | return 1; |
102 | 102 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | var $eventstolog=array( |
53 | 53 | array('id'=>'USER_LOGIN', 'test'=>1), |
54 | 54 | array('id'=>'USER_LOGIN_FAILED', 'test'=>1), |
55 | - array('id'=>'USER_LOGOUT', 'test'=>1), |
|
55 | + array('id'=>'USER_LOGOUT', 'test'=>1), |
|
56 | 56 | array('id'=>'USER_CREATE', 'test'=>1), |
57 | 57 | array('id'=>'USER_MODIFY', 'test'=>1), |
58 | 58 | array('id'=>'USER_NEW_PASSWORD', 'test'=>1), |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | |
267 | 267 | /** |
268 | - * Initialise an instance with random values. |
|
269 | - * Used to build previews or test instances. |
|
270 | - * id must be 0 if object instance is a specimen. |
|
271 | - * |
|
272 | - * @return void |
|
268 | + * Initialise an instance with random values. |
|
269 | + * Used to build previews or test instances. |
|
270 | + * id must be 0 if object instance is a specimen. |
|
271 | + * |
|
272 | + * @return void |
|
273 | 273 | */ |
274 | 274 | function initAsSpecimen() |
275 | 275 | { |
@@ -141,8 +141,7 @@ discard block |
||
141 | 141 | { |
142 | 142 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events"); |
143 | 143 | return $this->id; |
144 | - } |
|
145 | - else |
|
144 | + } else |
|
146 | 145 | { |
147 | 146 | $this->error="Error ".$this->db->lasterror(); |
148 | 147 | return -1; |
@@ -230,8 +229,7 @@ discard block |
||
230 | 229 | $this->db->free($resql); |
231 | 230 | |
232 | 231 | return 1; |
233 | - } |
|
234 | - else |
|
232 | + } else |
|
235 | 233 | { |
236 | 234 | $this->error="Error ".$this->db->lasterror(); |
237 | 235 | return -1; |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | class Events // extends CommonObject |
36 | 36 | { |
37 | - public $element='events'; //!< Id that identify managed objects |
|
38 | - public $table_element='events'; //!< Name of table without prefix where object is stored |
|
37 | + public $element = 'events'; //!< Id that identify managed objects |
|
38 | + public $table_element = 'events'; //!< Name of table without prefix where object is stored |
|
39 | 39 | |
40 | 40 | var $id; |
41 | 41 | var $db; |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | var $description; |
50 | 50 | |
51 | 51 | // List of all Audit/Security events supported by triggers |
52 | - var $eventstolog=array( |
|
53 | - array('id'=>'USER_LOGIN', 'test'=>1), |
|
54 | - array('id'=>'USER_LOGIN_FAILED', 'test'=>1), |
|
55 | - array('id'=>'USER_LOGOUT', 'test'=>1), |
|
56 | - array('id'=>'USER_CREATE', 'test'=>1), |
|
57 | - array('id'=>'USER_MODIFY', 'test'=>1), |
|
58 | - array('id'=>'USER_NEW_PASSWORD', 'test'=>1), |
|
59 | - array('id'=>'USER_ENABLEDISABLE', 'test'=>1), |
|
60 | - array('id'=>'USER_DELETE', 'test'=>1), |
|
52 | + var $eventstolog = array( |
|
53 | + array('id'=>'USER_LOGIN', 'test'=>1), |
|
54 | + array('id'=>'USER_LOGIN_FAILED', 'test'=>1), |
|
55 | + array('id'=>'USER_LOGOUT', 'test'=>1), |
|
56 | + array('id'=>'USER_CREATE', 'test'=>1), |
|
57 | + array('id'=>'USER_MODIFY', 'test'=>1), |
|
58 | + array('id'=>'USER_NEW_PASSWORD', 'test'=>1), |
|
59 | + array('id'=>'USER_ENABLEDISABLE', 'test'=>1), |
|
60 | + array('id'=>'USER_DELETE', 'test'=>1), |
|
61 | 61 | /* array('id'=>'USER_SETINGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY |
62 | 62 | array('id'=>'USER_REMOVEFROMGROUP', 'test'=>1), deprecated. Replace with USER_MODIFY */ |
63 | - array('id'=>'GROUP_CREATE', 'test'=>1), |
|
64 | - array('id'=>'GROUP_MODIFY', 'test'=>1), |
|
65 | - array('id'=>'GROUP_DELETE', 'test'=>1), |
|
63 | + array('id'=>'GROUP_CREATE', 'test'=>1), |
|
64 | + array('id'=>'GROUP_MODIFY', 'test'=>1), |
|
65 | + array('id'=>'GROUP_DELETE', 'test'=>1), |
|
66 | 66 | /* array('id'=>'ACTION_CREATE', 'test'=>$conf->societe->enabled), |
67 | 67 | array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled), |
68 | 68 | array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled), |
@@ -111,32 +111,32 @@ discard block |
||
111 | 111 | global $conf, $langs; |
112 | 112 | |
113 | 113 | // Clean parameters |
114 | - $this->description=trim($this->description); |
|
114 | + $this->description = trim($this->description); |
|
115 | 115 | |
116 | 116 | // Check parameters |
117 | - if (empty($this->description)) { $this->error='ErrorBadValueForParameterCreateEventDesc'; return -1; } |
|
117 | + if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; } |
|
118 | 118 | |
119 | 119 | // Insert request |
120 | 120 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."events("; |
121 | - $sql.= "type,"; |
|
122 | - $sql.= "entity,"; |
|
123 | - $sql.= "ip,"; |
|
124 | - $sql.= "user_agent,"; |
|
125 | - $sql.= "dateevent,"; |
|
126 | - $sql.= "fk_user,"; |
|
127 | - $sql.= "description"; |
|
128 | - $sql.= ") VALUES ("; |
|
129 | - $sql.= " '".$this->db->escape($this->type)."',"; |
|
130 | - $sql.= " ".$conf->entity.","; |
|
131 | - $sql.= " '".$this->db->escape($_SERVER['REMOTE_ADDR'])."',"; |
|
132 | - $sql.= " ".($_SERVER['HTTP_USER_AGENT']?"'".$this->db->escape(dol_trunc($_SERVER['HTTP_USER_AGENT'],250))."'":'NULL').","; |
|
133 | - $sql.= " '".$this->db->idate($this->dateevent)."',"; |
|
134 | - $sql.= " ".($user->id?"'".$this->db->escape($user->id)."'":'NULL').","; |
|
135 | - $sql.= " '".$this->db->escape(dol_trunc($this->description,250))."'"; |
|
136 | - $sql.= ")"; |
|
121 | + $sql .= "type,"; |
|
122 | + $sql .= "entity,"; |
|
123 | + $sql .= "ip,"; |
|
124 | + $sql .= "user_agent,"; |
|
125 | + $sql .= "dateevent,"; |
|
126 | + $sql .= "fk_user,"; |
|
127 | + $sql .= "description"; |
|
128 | + $sql .= ") VALUES ("; |
|
129 | + $sql .= " '".$this->db->escape($this->type)."',"; |
|
130 | + $sql .= " ".$conf->entity.","; |
|
131 | + $sql .= " '".$this->db->escape($_SERVER['REMOTE_ADDR'])."',"; |
|
132 | + $sql .= " ".($_SERVER['HTTP_USER_AGENT'] ? "'".$this->db->escape(dol_trunc($_SERVER['HTTP_USER_AGENT'], 250))."'" : 'NULL').","; |
|
133 | + $sql .= " '".$this->db->idate($this->dateevent)."',"; |
|
134 | + $sql .= " ".($user->id ? "'".$this->db->escape($user->id)."'" : 'NULL').","; |
|
135 | + $sql .= " '".$this->db->escape(dol_trunc($this->description, 250))."'"; |
|
136 | + $sql .= ")"; |
|
137 | 137 | |
138 | 138 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
139 | - $resql=$this->db->query($sql); |
|
139 | + $resql = $this->db->query($sql); |
|
140 | 140 | if ($resql) |
141 | 141 | { |
142 | 142 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events"); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
147 | - $this->error="Error ".$this->db->lasterror(); |
|
147 | + $this->error = "Error ".$this->db->lasterror(); |
|
148 | 148 | return -1; |
149 | 149 | } |
150 | 150 | } |
@@ -157,30 +157,30 @@ discard block |
||
157 | 157 | * @param int $notrigger 0=no, 1=yes (no update trigger) |
158 | 158 | * @return int <0 if KO, >0 if OK |
159 | 159 | */ |
160 | - function update($user=null, $notrigger=0) |
|
160 | + function update($user = null, $notrigger = 0) |
|
161 | 161 | { |
162 | 162 | global $conf, $langs; |
163 | 163 | |
164 | 164 | // Clean parameters |
165 | - $this->id=trim($this->id); |
|
166 | - $this->type=trim($this->type); |
|
167 | - $this->description=trim($this->description); |
|
165 | + $this->id = trim($this->id); |
|
166 | + $this->type = trim($this->type); |
|
167 | + $this->description = trim($this->description); |
|
168 | 168 | |
169 | 169 | // Check parameters |
170 | 170 | // Put here code to add control on parameters values |
171 | 171 | |
172 | 172 | // Update request |
173 | 173 | $sql = "UPDATE ".MAIN_DB_PREFIX."events SET"; |
174 | - $sql.= " type='".$this->db->escape($this->type)."',"; |
|
175 | - $sql.= " dateevent='".$this->db->idate($this->dateevent)."',"; |
|
176 | - $sql.= " description='".$this->db->escape($this->description)."'"; |
|
177 | - $sql.= " WHERE rowid=".$this->id; |
|
174 | + $sql .= " type='".$this->db->escape($this->type)."',"; |
|
175 | + $sql .= " dateevent='".$this->db->idate($this->dateevent)."',"; |
|
176 | + $sql .= " description='".$this->db->escape($this->description)."'"; |
|
177 | + $sql .= " WHERE rowid=".$this->id; |
|
178 | 178 | |
179 | 179 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
180 | 180 | $resql = $this->db->query($sql); |
181 | - if (! $resql) |
|
181 | + if (!$resql) |
|
182 | 182 | { |
183 | - $this->error="Error ".$this->db->lasterror(); |
|
183 | + $this->error = "Error ".$this->db->lasterror(); |
|
184 | 184 | return -1; |
185 | 185 | } |
186 | 186 | return 1; |
@@ -194,31 +194,31 @@ discard block |
||
194 | 194 | * @param User $user User that load |
195 | 195 | * @return int <0 if KO, >0 if OK |
196 | 196 | */ |
197 | - function fetch($id, $user=null) |
|
197 | + function fetch($id, $user = null) |
|
198 | 198 | { |
199 | 199 | global $langs; |
200 | 200 | |
201 | 201 | $sql = "SELECT"; |
202 | - $sql.= " t.rowid,"; |
|
203 | - $sql.= " t.tms,"; |
|
204 | - $sql.= " t.type,"; |
|
205 | - $sql.= " t.entity,"; |
|
206 | - $sql.= " t.dateevent,"; |
|
207 | - $sql.= " t.description,"; |
|
208 | - $sql.= " t.ip,"; |
|
209 | - $sql.= " t.user_agent"; |
|
210 | - $sql.= " FROM ".MAIN_DB_PREFIX."events as t"; |
|
211 | - $sql.= " WHERE t.rowid = ".$id; |
|
202 | + $sql .= " t.rowid,"; |
|
203 | + $sql .= " t.tms,"; |
|
204 | + $sql .= " t.type,"; |
|
205 | + $sql .= " t.entity,"; |
|
206 | + $sql .= " t.dateevent,"; |
|
207 | + $sql .= " t.description,"; |
|
208 | + $sql .= " t.ip,"; |
|
209 | + $sql .= " t.user_agent"; |
|
210 | + $sql .= " FROM ".MAIN_DB_PREFIX."events as t"; |
|
211 | + $sql .= " WHERE t.rowid = ".$id; |
|
212 | 212 | |
213 | 213 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
214 | - $resql=$this->db->query($sql); |
|
214 | + $resql = $this->db->query($sql); |
|
215 | 215 | if ($resql) |
216 | 216 | { |
217 | 217 | if ($this->db->num_rows($resql)) |
218 | 218 | { |
219 | 219 | $obj = $this->db->fetch_object($resql); |
220 | 220 | |
221 | - $this->id = $obj->rowid; |
|
221 | + $this->id = $obj->rowid; |
|
222 | 222 | $this->tms = $this->db->jdate($obj->tms); |
223 | 223 | $this->type = $obj->type; |
224 | 224 | $this->entity = $obj->entity; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | else |
235 | 235 | { |
236 | - $this->error="Error ".$this->db->lasterror(); |
|
236 | + $this->error = "Error ".$this->db->lasterror(); |
|
237 | 237 | return -1; |
238 | 238 | } |
239 | 239 | } |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | global $conf, $langs; |
251 | 251 | |
252 | 252 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."events"; |
253 | - $sql.= " WHERE rowid=".$this->id; |
|
253 | + $sql .= " WHERE rowid=".$this->id; |
|
254 | 254 | |
255 | 255 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
256 | 256 | $resql = $this->db->query($sql); |
257 | - if (! $resql) |
|
257 | + if (!$resql) |
|
258 | 258 | { |
259 | - $this->error="Error ".$this->db->lasterror(); |
|
259 | + $this->error = "Error ".$this->db->lasterror(); |
|
260 | 260 | return -1; |
261 | 261 | } |
262 | 262 | |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function initAsSpecimen() |
275 | 275 | { |
276 | - $this->id=0; |
|
276 | + $this->id = 0; |
|
277 | 277 | |
278 | - $this->tms=time(); |
|
279 | - $this->type=''; |
|
280 | - $this->dateevent=time(); |
|
281 | - $this->description='This is a specimen event'; |
|
278 | + $this->tms = time(); |
|
279 | + $this->type = ''; |
|
280 | + $this->dateevent = time(); |
|
281 | + $this->description = 'This is a specimen event'; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | } |
@@ -28,94 +28,94 @@ |
||
28 | 28 | */ |
29 | 29 | class Menu |
30 | 30 | { |
31 | - var $liste; |
|
31 | + var $liste; |
|
32 | 32 | |
33 | - /** |
|
33 | + /** |
|
34 | 34 | * Constructor |
35 | - */ |
|
36 | - function __construct() |
|
37 | - { |
|
38 | - $this->liste = array(); |
|
39 | - } |
|
35 | + */ |
|
36 | + function __construct() |
|
37 | + { |
|
38 | + $this->liste = array(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Clear property ->liste |
|
43 | - * |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - function clear() |
|
47 | - { |
|
48 | - $this->liste = array(); |
|
49 | - } |
|
41 | + /** |
|
42 | + * Clear property ->liste |
|
43 | + * |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + function clear() |
|
47 | + { |
|
48 | + $this->liste = array(); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Add a menu entry into this->liste (at end) |
|
53 | - * |
|
54 | - * @param string $url Url to follow on click (does not include DOL_URL_ROOT) |
|
55 | - * @param string $titre Label of menu to add |
|
56 | - * @param integer $level Level of menu to add |
|
57 | - * @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey) |
|
58 | - * @param string $target Target link |
|
59 | - * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) |
|
60 | - * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) |
|
61 | - * @param int $position Position (not used yet) |
|
62 | - * @param string $id Id |
|
63 | - * @param string $idsel Id sel |
|
64 | - * @param string $classname Class name |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') |
|
68 | - { |
|
69 | - $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname); |
|
70 | - } |
|
51 | + /** |
|
52 | + * Add a menu entry into this->liste (at end) |
|
53 | + * |
|
54 | + * @param string $url Url to follow on click (does not include DOL_URL_ROOT) |
|
55 | + * @param string $titre Label of menu to add |
|
56 | + * @param integer $level Level of menu to add |
|
57 | + * @param int $enabled Menu active or not (0=Not active, 1=Active, 2=Active but grey) |
|
58 | + * @param string $target Target link |
|
59 | + * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) |
|
60 | + * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) |
|
61 | + * @param int $position Position (not used yet) |
|
62 | + * @param string $id Id |
|
63 | + * @param string $idsel Id sel |
|
64 | + * @param string $classname Class name |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') |
|
68 | + { |
|
69 | + $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Insert a menu entry into this->liste |
|
74 | - * |
|
75 | - * @param int $idafter Array key after which inserting new entry |
|
76 | - * @param string $url Url to follow on click |
|
77 | - * @param string $titre Label of menu to add |
|
78 | - * @param integer $level Level of menu to add |
|
79 | - * @param int $enabled Menu active or not |
|
80 | - * @param string $target Target link |
|
81 | - * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) |
|
82 | - * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) |
|
83 | - * @param int $position Position (not used yet) |
|
84 | - * @param string $id Id |
|
85 | - * @param string $idsel Id sel |
|
86 | - * @param string $classname Class name |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') |
|
90 | - { |
|
91 | - $array_start = array_slice($this->liste,0,($idafter+1)); |
|
92 | - $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname)); |
|
93 | - $array_end = array_slice($this->liste,($idafter+1)); |
|
94 | - $this->liste=array_merge($array_start,$array_new,$array_end); |
|
95 | - } |
|
72 | + /** |
|
73 | + * Insert a menu entry into this->liste |
|
74 | + * |
|
75 | + * @param int $idafter Array key after which inserting new entry |
|
76 | + * @param string $url Url to follow on click |
|
77 | + * @param string $titre Label of menu to add |
|
78 | + * @param integer $level Level of menu to add |
|
79 | + * @param int $enabled Menu active or not |
|
80 | + * @param string $target Target link |
|
81 | + * @param string $mainmenu Main menu ('home', 'companies', 'products', ...) |
|
82 | + * @param string $leftmenu Left menu ('setup', 'system', 'admintools', ...) |
|
83 | + * @param int $position Position (not used yet) |
|
84 | + * @param string $id Id |
|
85 | + * @param string $idsel Id sel |
|
86 | + * @param string $classname Class name |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') |
|
90 | + { |
|
91 | + $array_start = array_slice($this->liste,0,($idafter+1)); |
|
92 | + $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname)); |
|
93 | + $array_end = array_slice($this->liste,($idafter+1)); |
|
94 | + $this->liste=array_merge($array_start,$array_new,$array_end); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Remove a menu entry from this->liste |
|
99 | - * |
|
100 | - * @return void |
|
101 | - */ |
|
102 | - function remove_last() |
|
103 | - { |
|
104 | - if (count($this->liste) > 1) array_pop($this->liste); |
|
105 | - } |
|
97 | + /** |
|
98 | + * Remove a menu entry from this->liste |
|
99 | + * |
|
100 | + * @return void |
|
101 | + */ |
|
102 | + function remove_last() |
|
103 | + { |
|
104 | + if (count($this->liste) > 1) array_pop($this->liste); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Return number of visible entries (gray or not) |
|
109 | - * |
|
110 | - * @return int Number of visible (gray or not) menu entries |
|
111 | - */ |
|
112 | - function getNbOfVisibleMenuEntries() |
|
113 | - { |
|
114 | - $nb=0; |
|
115 | - foreach($this->liste as $val) |
|
116 | - { |
|
117 | - if (! empty($val['enabled'])) $nb++; |
|
118 | - } |
|
119 | - return $nb; |
|
120 | - } |
|
107 | + /** |
|
108 | + * Return number of visible entries (gray or not) |
|
109 | + * |
|
110 | + * @return int Number of visible (gray or not) menu entries |
|
111 | + */ |
|
112 | + function getNbOfVisibleMenuEntries() |
|
113 | + { |
|
114 | + $nb=0; |
|
115 | + foreach($this->liste as $val) |
|
116 | + { |
|
117 | + if (! empty($val['enabled'])) $nb++; |
|
118 | + } |
|
119 | + return $nb; |
|
120 | + } |
|
121 | 121 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param string $classname Class name |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - function add($url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') |
|
67 | + function add($url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '') |
|
68 | 68 | { |
69 | - $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname); |
|
69 | + $this->liste[] = array('url'=>$url, 'titre'=>$titre, 'level'=>$level, 'enabled'=>$enabled, 'target'=>$target, 'mainmenu'=>$mainmenu, 'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | * @param string $classname Class name |
87 | 87 | * @return void |
88 | 88 | */ |
89 | - function insert($idafter, $url, $titre, $level=0, $enabled=1, $target='',$mainmenu='',$leftmenu='',$position=0, $id='', $idsel='', $classname='') |
|
89 | + function insert($idafter, $url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '') |
|
90 | 90 | { |
91 | - $array_start = array_slice($this->liste,0,($idafter+1)); |
|
92 | - $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname)); |
|
93 | - $array_end = array_slice($this->liste,($idafter+1)); |
|
94 | - $this->liste=array_merge($array_start,$array_new,$array_end); |
|
91 | + $array_start = array_slice($this->liste, 0, ($idafter + 1)); |
|
92 | + $array_new = array(0=>array('url'=>$url, 'titre'=>$titre, 'level'=>$level, 'enabled'=>$enabled, 'target'=>$target, 'mainmenu'=>$mainmenu, 'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname)); |
|
93 | + $array_end = array_slice($this->liste, ($idafter + 1)); |
|
94 | + $this->liste = array_merge($array_start, $array_new, $array_end); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function getNbOfVisibleMenuEntries() |
113 | 113 | { |
114 | - $nb=0; |
|
115 | - foreach($this->liste as $val) |
|
114 | + $nb = 0; |
|
115 | + foreach ($this->liste as $val) |
|
116 | 116 | { |
117 | - if (! empty($val['enabled'])) $nb++; |
|
117 | + if (!empty($val['enabled'])) $nb++; |
|
118 | 118 | } |
119 | 119 | return $nb; |
120 | 120 | } |
@@ -101,7 +101,9 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function remove_last() |
103 | 103 | { |
104 | - if (count($this->liste) > 1) array_pop($this->liste); |
|
104 | + if (count($this->liste) > 1) { |
|
105 | + array_pop($this->liste); |
|
106 | + } |
|
105 | 107 | } |
106 | 108 | |
107 | 109 | /** |
@@ -114,7 +116,9 @@ discard block |
||
114 | 116 | $nb=0; |
115 | 117 | foreach($this->liste as $val) |
116 | 118 | { |
117 | - if (! empty($val['enabled'])) $nb++; |
|
119 | + if (! empty($val['enabled'])) { |
|
120 | + $nb++; |
|
121 | + } |
|
118 | 122 | } |
119 | 123 | return $nb; |
120 | 124 | } |
@@ -144,7 +144,7 @@ |
||
144 | 144 | * @param int $nbPointilles Nb pointilles |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15) |
|
147 | + function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15) |
|
148 | 148 | { |
149 | 149 | $pdf->SetLineWidth($epaisseur); |
150 | 150 | $length=abs($x1-$x2); |
@@ -62,23 +62,23 @@ discard block |
||
62 | 62 | abstract class CommonStickerGenerator |
63 | 63 | { |
64 | 64 | |
65 | - public $code; // Code of format |
|
66 | - public $format; // Array with informations |
|
65 | + public $code; // Code of format |
|
66 | + public $format; // Array with informations |
|
67 | 67 | |
68 | 68 | // protected |
69 | - var $_Avery_Name = ''; // Nom du format de l'etiquette |
|
70 | - var $_Margin_Left = 0; // Marge de gauche de l'etiquette |
|
71 | - var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette |
|
72 | - var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes |
|
73 | - var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes |
|
74 | - var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page |
|
75 | - var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page |
|
76 | - var $_Width = 0; // Largeur de chaque etiquette |
|
77 | - var $_Height = 0; // Hauteur de chaque etiquette |
|
78 | - var $_Char_Size = 10; // Hauteur des caracteres |
|
79 | - var $_Line_Height = 10; // Hauteur par defaut d'une ligne |
|
80 | - var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values |
|
81 | - var $_Metric_Doc = 'mm'; // Type of metric for the doc.. |
|
69 | + var $_Avery_Name = ''; // Nom du format de l'etiquette |
|
70 | + var $_Margin_Left = 0; // Marge de gauche de l'etiquette |
|
71 | + var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette |
|
72 | + var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes |
|
73 | + var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes |
|
74 | + var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page |
|
75 | + var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page |
|
76 | + var $_Width = 0; // Largeur de chaque etiquette |
|
77 | + var $_Height = 0; // Hauteur de chaque etiquette |
|
78 | + var $_Char_Size = 10; // Hauteur des caracteres |
|
79 | + var $_Line_Height = 10; // Hauteur par defaut d'une ligne |
|
80 | + var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values |
|
81 | + var $_Metric_Doc = 'mm'; // Type of metric for the doc.. |
|
82 | 82 | var $_COUNTX = 1; |
83 | 83 | var $_COUNTY = 1; |
84 | 84 | var $_First = 1; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @param string $outputdir Output directory for pdf file |
104 | 104 | * @return int 1=OK, 0=KO |
105 | 105 | */ |
106 | - abstract function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir=''); |
|
106 | + abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param array $param Associative array containing label content and optional parameters |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - abstract function addSticker(&$pdf,$outputlangs,$param); |
|
116 | + abstract function addSticker(&$pdf, $outputlangs, $param); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Methode qui permet de modifier la taille des caracteres |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | * @param int $pt point |
124 | 124 | * @return void |
125 | 125 | */ |
126 | - function Set_Char_Size(&$pdf,$pt) |
|
126 | + function Set_Char_Size(&$pdf, $pt) |
|
127 | 127 | { |
128 | 128 | if ($pt > 3) { |
129 | 129 | $this->_Char_Size = $pt; |
130 | 130 | $this->_Line_Height = $this->_Get_Height_Chars($pt); |
131 | - $pdf->SetFont('','',$pt); |
|
131 | + $pdf->SetFont('', '', $pt); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -144,30 +144,30 @@ discard block |
||
144 | 144 | * @param int $nbPointilles Nb pointilles |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15) |
|
147 | + function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) |
|
148 | 148 | { |
149 | 149 | $pdf->SetLineWidth($epaisseur); |
150 | - $length=abs($x1-$x2); |
|
151 | - $hauteur=abs($y1-$y2); |
|
152 | - if($length>$hauteur) { |
|
153 | - $Pointilles=($length/$nbPointilles)/2; // taille des pointilles |
|
150 | + $length = abs($x1 - $x2); |
|
151 | + $hauteur = abs($y1 - $y2); |
|
152 | + if ($length > $hauteur) { |
|
153 | + $Pointilles = ($length / $nbPointilles) / 2; // taille des pointilles |
|
154 | 154 | } |
155 | 155 | else { |
156 | - $Pointilles=($hauteur/$nbPointilles)/2; |
|
156 | + $Pointilles = ($hauteur / $nbPointilles) / 2; |
|
157 | 157 | } |
158 | - for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { |
|
159 | - for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
160 | - if($j<=($x2-1)) { |
|
161 | - $pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point |
|
162 | - $pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point |
|
158 | + for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) { |
|
159 | + for ($j = $i; $j <= ($i + $Pointilles); $j++) { |
|
160 | + if ($j <= ($x2 - 1)) { |
|
161 | + $pdf->Line($j, $y1, $j + 1, $y1); // on trace le pointill? du haut, point par point |
|
162 | + $pdf->Line($j, $y2, $j + 1, $y2); // on trace le pointill? du bas, point par point |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | - for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) { |
|
167 | - for($j=$i;$j<=($i+$Pointilles);$j++) { |
|
168 | - if($j<=($y2-1)) { |
|
169 | - $pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point |
|
170 | - $pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point |
|
166 | + for ($i = $y1; $i <= $y2; $i += $Pointilles + $Pointilles) { |
|
167 | + for ($j = $i; $j <= ($i + $Pointilles); $j++) { |
|
168 | + if ($j <= ($y2 - 1)) { |
|
169 | + $pdf->Line($x1, $j, $x1, $j + 1); // on trace le pointill? du haut, point par point |
|
170 | + $pdf->Line($x2, $j, $x2, $j + 1); // on trace le pointill? du bas, point par point |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -185,26 +185,26 @@ discard block |
||
185 | 185 | * @param int $taille Size |
186 | 186 | * @return void |
187 | 187 | */ |
188 | - function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4) |
|
188 | + function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) |
|
189 | 189 | { |
190 | - $pdf->SetDrawColor(192,192,192); |
|
190 | + $pdf->SetDrawColor(192, 192, 192); |
|
191 | 191 | |
192 | 192 | $pdf->SetLineWidth($epaisseur); |
193 | - $lg=$taille/2; |
|
193 | + $lg = $taille / 2; |
|
194 | 194 | // croix haut gauche |
195 | - $pdf->Line($x1,$y1-$lg,$x1,$y1+$lg); |
|
196 | - $pdf->Line($x1-$lg,$y1,$x1+$lg,$y1); |
|
195 | + $pdf->Line($x1, $y1 - $lg, $x1, $y1 + $lg); |
|
196 | + $pdf->Line($x1 - $lg, $y1, $x1 + $lg, $y1); |
|
197 | 197 | // croix bas gauche |
198 | - $pdf->Line($x1,$y2-$lg,$x1,$y2+$lg); |
|
199 | - $pdf->Line($x1-$lg,$y2,$x1+$lg,$y2); |
|
198 | + $pdf->Line($x1, $y2 - $lg, $x1, $y2 + $lg); |
|
199 | + $pdf->Line($x1 - $lg, $y2, $x1 + $lg, $y2); |
|
200 | 200 | // croix haut droit |
201 | - $pdf->Line($x2,$y1-$lg,$x2,$y1+$lg); |
|
202 | - $pdf->Line($x2-$lg,$y1,$x2+$lg,$y1); |
|
201 | + $pdf->Line($x2, $y1 - $lg, $x2, $y1 + $lg); |
|
202 | + $pdf->Line($x2 - $lg, $y1, $x2 + $lg, $y1); |
|
203 | 203 | // croix bas droit |
204 | - $pdf->Line($x2,$y2-$lg,$x2,$y2+$lg); |
|
205 | - $pdf->Line($x2-$lg,$y2,$x2+$lg,$y2); |
|
204 | + $pdf->Line($x2, $y2 - $lg, $x2, $y2 + $lg); |
|
205 | + $pdf->Line($x2 - $lg, $y2, $x2 + $lg, $y2); |
|
206 | 206 | |
207 | - $pdf->SetDrawColor(0,0,0); |
|
207 | + $pdf->SetDrawColor(0, 0, 0); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param string $dest to |
217 | 217 | * @return float value value after conversion |
218 | 218 | */ |
219 | - function _Convert_Metric ($value, $src, $dest) |
|
219 | + function _Convert_Metric($value, $src, $dest) |
|
220 | 220 | { |
221 | 221 | if ($src != $dest) { |
222 | 222 | $tab['in'] = 39.37008; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | function _Set_Format(&$pdf, $format) |
255 | 255 | { |
256 | - $this->_Metric = $format['metric']; |
|
256 | + $this->_Metric = $format['metric']; |
|
257 | 257 | $this->_Avery_Name = $format['name']; |
258 | 258 | $this->_Avery_Code = $format['code']; |
259 | 259 | $this->_Margin_Left = $this->_Convert_Metric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc); |
@@ -151,8 +151,7 @@ |
||
151 | 151 | $hauteur=abs($y1-$y2); |
152 | 152 | if($length>$hauteur) { |
153 | 153 | $Pointilles=($length/$nbPointilles)/2; // taille des pointilles |
154 | - } |
|
155 | - else { |
|
154 | + } else { |
|
156 | 155 | $Pointilles=($hauteur/$nbPointilles)/2; |
157 | 156 | } |
158 | 157 | for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { |