| @@ -30,14 +30,12 @@ discard block | ||
| 30 | 30 | /** | 
| 31 | 31 | * Shows the contactform and stores the submitted data | 
| 32 | 32 | * | 
| 33 | - * @param array $content=null submitted eTemplate content | |
| 34 | - * @param int $addressbook=null int owner-id of addressbook to save contacts too | |
| 35 | - * @param array $fields=null field-names to show | |
| 36 | - * @param string $msg=null message to show after submitting the form | |
| 37 | - * @param string $email=null comma-separated email addresses | |
| 38 | - * @param string $tpl_name=null custom etemplate to use | |
| 39 | - * @param string $subject=null subject for email | |
| 40 | - * @param string $copytoreceiver=false send a copy of notification to receiver | |
| 33 | + * @param array $content submitted eTemplate content | |
| 34 | + * @param int $addressbook int owner-id of addressbook to save contacts too | |
| 35 | + * @param array $fields field-names to show | |
| 36 | + * @param string $tpl_name custom etemplate to use | |
| 37 | + * @param string $subject subject for email | |
| 38 | + * @param string $copytoreceiver send a copy of notification to receiver | |
| 41 | 39 | * @return string html content | 
| 42 | 40 | */ | 
| 43 | 41 | function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) | 
| @@ -49,13 +47,11 @@ discard block | ||
| 49 | 47 | * Shows the contactform and stores the submitted data ($content is a var parameter, eg. for extending classes) | 
| 50 | 48 | * | 
| 51 | 49 | * @param array &$content=null submitted eTemplate content | 
| 52 | - * @param int $addressbook=null int owner-id of addressbook to save contacts too | |
| 53 | - * @param array $fields=null field-names to show | |
| 54 | - * @param string $msg=null message to show after submitting the form | |
| 55 | - * @param string $email=null comma-separated email addresses | |
| 56 | - * @param string $tpl_name=null custom etemplate to use | |
| 57 | - * @param string $subject=null subject for email | |
| 58 | - * @param string $copytoreceiver=false send a copy of notification to receiver | |
| 50 | + * @param int $addressbook int owner-id of addressbook to save contacts too | |
| 51 | + * @param array $fields field-names to show | |
| 52 | + * @param string $tpl_name custom etemplate to use | |
| 53 | + * @param string $subject subject for email | |
| 54 | + * @param string $copytoreceiver send a copy of notification to receiver | |
| 59 | 55 | * @return string html content | 
| 60 | 56 | */ | 
| 61 | 57 | function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) | 
| @@ -61,30 +61,46 @@ discard block | ||
| 61 | 61 | function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) | 
| 62 | 62 |  	{ | 
| 63 | 63 |  		#error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n"); | 
| 64 | - if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name']; | |
| 64 | + if (empty($tpl_name) && !empty($content['tpl_form_name'])) | |
| 65 | +		{ | |
| 66 | + $tpl_name =$content['tpl_form_name']; | |
| 67 | + } | |
| 65 | 68 | $tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform'); | 
| 66 | 69 | // initializing some fields | 
| 67 | -		if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); | |
| 70 | + if (!$fields) | |
| 71 | +		{ | |
| 72 | +			$fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); | |
| 73 | + } | |
| 68 | 74 | $submitted = false; | 
| 69 | 75 | // check if submitted | 
| 70 | 76 | if (is_array($content)) | 
| 71 | 77 |  		{ | 
| 72 | - if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); | |
| 78 | + if (isset($_POST['g-recaptcha-response'])) | |
| 79 | +			{ | |
| 80 | + $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); | |
| 81 | + } | |
| 73 | 82 | $captcha = (isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || ($recaptcha && $recaptcha->success == false); | 
| 74 | 83 | if ($captcha || // no correct captcha OR | 
| 75 | 84 | (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and | 
| 76 | - !$GLOBALS['egw_info']['etemplate']['java_script'])) // javascript disabled) | |
| 85 | + !$GLOBALS['egw_info']['etemplate']['java_script'])) | |
| 86 | +			{ | |
| 87 | + // javascript disabled) | |
| 77 | 88 |  			{ | 
| 78 | 89 | $submitted = "truebutfalse"; | 
| 90 | + } | |
| 79 | 91 |  				$tpl->set_validation_error('captcha',lang('Wrong - try again ...')); | 
| 80 | 92 | } | 
| 81 | 93 | elseif ($content['submitit']) | 
| 82 | 94 |  			{ | 
| 83 | 95 | $submitted = true; | 
| 84 | 96 | $contact = new Api\Contacts(); | 
| 85 | - if ($content['owner']) // save the contact in the addressbook | |
| 97 | + if ($content['owner']) | |
| 98 | +				{ | |
| 99 | + // save the contact in the addressbook | |
| 86 | 100 |  				{ | 
| 87 | - $content['private'] = 0; // in case default_private is set | |
| 101 | + $content['private'] = 0; | |
| 102 | + } | |
| 103 | + // in case default_private is set | |
| 88 | 104 | if (($id = $contact->save($content))) | 
| 89 | 105 |  					{ | 
| 90 | 106 | // check for fileuploads and attach the found files | 
| @@ -141,9 +157,12 @@ discard block | ||
| 141 | 157 | $custom = 1; | 
| 142 | 158 | foreach($fields as $name) | 
| 143 | 159 |  			{ | 
| 144 | - if ($name[0] == '#') // custom field | |
| 160 | + if ($name[0] == '#') | |
| 161 | +				{ | |
| 162 | + // custom field | |
| 145 | 163 |  				{ | 
| 146 | 164 | static $contact; | 
| 165 | + } | |
| 147 | 166 | if (is_null($contact)) | 
| 148 | 167 |  					{ | 
| 149 | 168 | $contact = new Api\Contacts(); | 
| @@ -174,12 +193,19 @@ discard block | ||
| 174 | 193 | unset($content['submitit']); | 
| 175 | 194 | $custom = 1; | 
| 176 | 195 | // fieldnames are "defined" by the commit attempt, that way, we do not have to remember them | 
| 177 | -			foreach($content as $name => $value) { | |
| 196 | + foreach($content as $name => $value) | |
| 197 | +			{ | |
| 178 | 198 | $preserv[$name]=$value; | 
| 179 | - if ($name[0] == '#') // custom field | |
| 199 | + if ($name[0] == '#') | |
| 200 | +				{ | |
| 201 | + // custom field | |
| 180 | 202 |  				{ | 
| 181 | 203 | static $contact; | 
| 182 | - if (is_null($contact)) $contact = new Api\Contacts(); | |
| 204 | + } | |
| 205 | + if (is_null($contact)) | |
| 206 | +					{ | |
| 207 | + $contact = new Api\Contacts(); | |
| 208 | + } | |
| 183 | 209 | $content['show']['custom'.$custom] = true; | 
| 184 | 210 | $content['customfield'][$custom] = $name; | 
| 185 | 211 | $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; | 
| @@ -202,16 +228,26 @@ discard block | ||
| 202 | 228 | } | 
| 203 | 229 | $content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']; | 
| 204 | 230 | |
| 205 | - if ($addressbook) $preserv['owner'] = $addressbook; | |
| 206 | - if ($msg) $preserv['msg'] = $msg; | |
| 231 | + if ($addressbook) | |
| 232 | +		{ | |
| 233 | + $preserv['owner'] = $addressbook; | |
| 234 | + } | |
| 235 | + if ($msg) | |
| 236 | +		{ | |
| 237 | + $preserv['msg'] = $msg; | |
| 238 | + } | |
| 207 | 239 | if (!sitemgr_module::get_recaptcha()) | 
| 208 | 240 |  		{ | 
| 209 | 241 | // a simple calculation captcha | 
| 210 | 242 | $num1 = rand(1,99); | 
| 211 | 243 | $num2 = rand(1,99); | 
| 212 | - if ($num2 > $num1) // keep the result positive | |
| 244 | + if ($num2 > $num1) | |
| 245 | +			{ | |
| 246 | + // keep the result positive | |
| 213 | 247 |  			{ | 
| 214 | - $n = $num1; $num1 = $num2; $num2 = $n; | |
| 248 | + $n = $num1; | |
| 249 | + } | |
| 250 | + $num1 = $num2; $num2 = $n; | |
| 215 | 251 | } | 
| 216 | 252 |  			if (in_array('captcha',$fields)) | 
| 217 | 253 |  			{ | 
| @@ -36,7 +36,7 @@ | ||
| 36 | 36 | /** | 
| 37 | 37 | * Exports records as defined in $_definition | 
| 38 | 38 | * | 
| 39 | - * @param egw_record $_definition | |
| 39 | + * @param importexport_definition $_definition | |
| 40 | 40 | */ | 
| 41 | 41 |  	public function export( $_stream, importexport_definition $_definition) { | 
| 42 | 42 | |
| @@ -38,7 +38,8 @@ discard block | ||
| 38 | 38 | * | 
| 39 | 39 | * @param egw_record $_definition | 
| 40 | 40 | */ | 
| 41 | -	public function export( $_stream, importexport_definition $_definition) { | |
| 41 | + public function export( $_stream, importexport_definition $_definition) | |
| 42 | +	{ | |
| 42 | 43 | |
| 43 | 44 | $options = $_definition->plugin_options; | 
| 44 | 45 | $this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options); | 
| @@ -48,8 +49,13 @@ discard block | ||
| 48 | 49 | // Addressbook defines its own export imits | 
| 49 | 50 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); | 
| 50 | 51 | $export_limit = Api\Storage\Merge::getExportLimit($app='addressbook'); | 
| 51 | - if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all | |
| 52 | -		if($export_limit == 'no' && !$limit_exception) { | |
| 52 | + if (!$limit_exception) | |
| 53 | +		{ | |
| 54 | + $export_object->export_limit = $export_limit; | |
| 55 | + } | |
| 56 | + // we may not need that after all | |
| 57 | + if($export_limit == 'no' && !$limit_exception) | |
| 58 | +		{ | |
| 53 | 59 | return; | 
| 54 | 60 | } | 
| 55 | 61 | |
| @@ -57,18 +63,24 @@ discard block | ||
| 57 | 63 | $old_app = $GLOBALS['egw_info']['flags']['currentapp']; | 
| 58 | 64 | $GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; | 
| 59 | 65 | |
| 60 | -		if ($options['selection'] == 'search') { | |
| 66 | + if ($options['selection'] == 'search') | |
| 67 | +		{ | |
| 61 | 68 | // uicontacts selection with checkbox 'use_all' | 
| 62 | 69 |  			$query = Api\Cache::getSession('addressbook', 'index'); | 
| 63 | 70 | $query['num_rows'] = -1; // all | 
| 64 | 71 | $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session | 
| 65 | 72 | $query['order'] = 'contact_id'; | 
| 66 | -			if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; | |
| 73 | +			if(!array_key_exists('filter',$query)) | |
| 74 | +			{ | |
| 75 | + $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; | |
| 76 | + } | |
| 67 | 77 | $readonlys = null; | 
| 68 | 78 | $this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids | 
| 69 | 79 | } | 
| 70 | -		elseif ( $options['selection'] == 'all' ) { | |
| 71 | -			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) { | |
| 80 | + elseif ( $options['selection'] == 'all' ) | |
| 81 | +		{ | |
| 82 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) | |
| 83 | +			{ | |
| 72 | 84 | $col_filter['account_id'] = null; | 
| 73 | 85 | } | 
| 74 | 86 |  			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter); | 
| @@ -107,11 +119,20 @@ discard block | ||
| 107 | 119 | $field = 'contact_'.$field; | 
| 108 | 120 | } | 
| 109 | 121 | $query['col_filter'][$field] = $value; | 
| 110 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; | |
| 122 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) | |
| 123 | +				{ | |
| 124 | + continue; | |
| 125 | + } | |
| 111 | 126 | |
| 112 | 127 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) | 
| 113 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; | |
| 114 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; | |
| 128 | + if($value['from']) | |
| 129 | +				{ | |
| 130 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; | |
| 131 | + } | |
| 132 | + if($value['to']) | |
| 133 | +				{ | |
| 134 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; | |
| 135 | + } | |
| 115 | 136 | unset($query['col_filter'][$field]); | 
| 116 | 137 | } | 
| 117 | 138 |  			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']); | 
| @@ -126,29 +147,36 @@ discard block | ||
| 126 | 147 | } | 
| 127 | 148 | $GLOBALS['egw_info']['flags']['currentapp'] = $old_app; | 
| 128 | 149 | |
| 129 | -		if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { | |
| 150 | + if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) | |
| 151 | +		{ | |
| 130 | 152 | $selection = array_slice($selection, 0, $export_limit); | 
| 131 | 153 | } | 
| 132 | 154 | |
| 133 | -		if($options['explode_multiselects']) { | |
| 155 | + if($options['explode_multiselects']) | |
| 156 | +		{ | |
| 134 | 157 |  			$customfields = Api\Storage\Customfields::get('addressbook'); | 
| 135 | 158 | $additional_fields = array(); | 
| 136 | 159 |  			$cat_obj = new Api\Categories('', 'addressbook'); | 
| 137 | -			foreach($options['explode_multiselects'] as $field => $explode) { | |
| 138 | -				switch($explode['explode']) { | |
| 160 | + foreach($options['explode_multiselects'] as $field => $explode) | |
| 161 | +			{ | |
| 162 | + switch($explode['explode']) | |
| 163 | +				{ | |
| 139 | 164 | case self::MAIN_CATS: | 
| 140 | 165 |  						$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true); | 
| 141 | -						foreach($cats as $settings) { | |
| 166 | + foreach($cats as $settings) | |
| 167 | +						{ | |
| 142 | 168 | $additional_fields[$field][$settings['id']] = array( | 
| 143 | 169 | 'count' => 0, | 
| 144 | 170 | 'label' => $settings['name'], | 
| 145 | 171 | 'subs' => array(), | 
| 146 | 172 | ); | 
| 147 | 173 | $subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']); | 
| 148 | -							foreach($subs as $sub) { | |
| 174 | + foreach($subs as $sub) | |
| 175 | +							{ | |
| 149 | 176 | $name = $sub['name']; | 
| 150 | 177 | $path = $sub; | 
| 151 | -								while($path['parent'] != $settings['id']) { | |
| 178 | + while($path['parent'] != $settings['id']) | |
| 179 | +								{ | |
| 152 | 180 | $path = $cat_obj->read($path['parent']); | 
| 153 | 181 | $name = $path['name'] . '/' . $name; | 
| 154 | 182 | } | 
| @@ -158,10 +186,12 @@ discard block | ||
| 158 | 186 | break; | 
| 159 | 187 | case self::EACH_CAT: | 
| 160 | 188 |  						$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true); | 
| 161 | -						foreach($cats as $settings) { | |
| 189 | + foreach($cats as $settings) | |
| 190 | +						{ | |
| 162 | 191 | $name = $settings['name']; | 
| 163 | 192 | $path = $settings; | 
| 164 | -							while($path['level'] != 0) { | |
| 193 | + while($path['level'] != 0) | |
| 194 | +							{ | |
| 165 | 195 | $path = $cat_obj->read($path['parent']); | 
| 166 | 196 | $name = $path['name'] . '/' . $name; | 
| 167 | 197 | } | 
| @@ -174,7 +204,8 @@ discard block | ||
| 174 | 204 | case self::EXPLODE: | 
| 175 | 205 | // Only works for custom fields | 
| 176 | 206 | $index = substr($field, 1); | 
| 177 | -						foreach($customfields[$index]['values'] as $key => $value) { | |
| 207 | + foreach($customfields[$index]['values'] as $key => $value) | |
| 208 | +						{ | |
| 178 | 209 | $additional_fields[$field][$key] = array( | 
| 179 | 210 | 'count' => 0, | 
| 180 | 211 | 'label' => $customfields[$index]['label'] . ': ' . $value, | 
| @@ -185,30 +216,47 @@ discard block | ||
| 185 | 216 | } | 
| 186 | 217 | |
| 187 | 218 | // Check records to see if additional fields are actually used | 
| 188 | -			foreach ($selection as $_contact) { | |
| 189 | -				if(is_array($_contact) && array_key_exists('photo', $_contact)) { | |
| 219 | + foreach ($selection as $_contact) | |
| 220 | +			{ | |
| 221 | +				if(is_array($_contact) && array_key_exists('photo', $_contact)) | |
| 222 | +				{ | |
| 190 | 223 | unset($_contact['photo']); | 
| 191 | 224 | } | 
| 192 | -				if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { | |
| 225 | + if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) | |
| 226 | +				{ | |
| 193 | 227 | $_contact = $_contact['id']; | 
| 194 | 228 | } | 
| 195 | -				if(is_array($_contact) && $_contact['id']) { | |
| 229 | + if(is_array($_contact) && $_contact['id']) | |
| 230 | +				{ | |
| 196 | 231 | $contact = new addressbook_egw_record(); | 
| 197 | 232 | $contact->set_record($_contact); | 
| 198 | -				} else { | |
| 233 | + } | |
| 234 | + else | |
| 235 | +				{ | |
| 199 | 236 | $contact = new addressbook_egw_record($_contact); | 
| 200 | 237 | } | 
| 201 | -				foreach($additional_fields as $field => &$values) { | |
| 202 | - if(!$contact->$field) continue; | |
| 203 | -					foreach($values as $value => &$settings) { | |
| 204 | -						if(!is_array($contact->$field)) { | |
| 238 | + foreach($additional_fields as $field => &$values) | |
| 239 | +				{ | |
| 240 | + if(!$contact->$field) | |
| 241 | +					{ | |
| 242 | + continue; | |
| 243 | + } | |
| 244 | + foreach($values as $value => &$settings) | |
| 245 | +					{ | |
| 246 | + if(!is_array($contact->$field)) | |
| 247 | +						{ | |
| 205 | 248 |  							$contact->$field = explode(',', $contact->$field); | 
| 206 | 249 | } | 
| 207 | -						if(is_array($contact->$field) && in_array($value, $contact->$field)) { | |
| 250 | + if(is_array($contact->$field) && in_array($value, $contact->$field)) | |
| 251 | +						{ | |
| 208 | 252 | $settings['count']++; | 
| 209 | -						} elseif($contact->$field == $value) { | |
| 253 | + } | |
| 254 | + elseif($contact->$field == $value) | |
| 255 | +						{ | |
| 210 | 256 | $settings['count']++; | 
| 211 | -						} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) { | |
| 257 | + } | |
| 258 | + elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) | |
| 259 | +						{ | |
| 212 | 260 | $settings['count']++; | 
| 213 | 261 | } | 
| 214 | 262 | } | 
| @@ -220,21 +268,27 @@ discard block | ||
| 220 | 268 | unset($settings); | 
| 221 | 269 | |
| 222 | 270 | // Add additional columns | 
| 223 | -			foreach($additional_fields as $field => $additional_values) { | |
| 271 | + foreach($additional_fields as $field => $additional_values) | |
| 272 | +			{ | |
| 224 | 273 | // Remove original | 
| 225 | 274 | unset($options['mapping'][$field]); | 
| 226 | 275 | // Add exploded | 
| 227 | 276 | $field_count = 0; | 
| 228 | -				foreach($additional_values as $value => $settings) { | |
| 229 | -					if($settings['count'] > 0) { | |
| 277 | + foreach($additional_values as $value => $settings) | |
| 278 | +				{ | |
| 279 | + if($settings['count'] > 0) | |
| 280 | +					{ | |
| 230 | 281 | $field_count += $settings['count']; | 
| 231 | 282 | $options['mapping'][$field.'-'.$value] = $settings['label']; | 
| 232 | 283 | } | 
| 233 | 284 | } | 
| 234 | -				if($field_count > 0) { | |
| 285 | + if($field_count > 0) | |
| 286 | +				{ | |
| 235 | 287 | // Set some options for converting | 
| 236 | 288 | $options['explode_multiselects'][$field]['values'] = $additional_values; | 
| 237 | -				} else { | |
| 289 | + } | |
| 290 | + else | |
| 291 | +				{ | |
| 238 | 292 | // Don't need this anymore | 
| 239 | 293 | unset($options['explode_multiselects'][$field]); | 
| 240 | 294 | } | 
| @@ -263,17 +317,23 @@ discard block | ||
| 263 | 317 | |
| 264 | 318 | // $options['selection'] is array of identifiers as this plugin doesn't | 
| 265 | 319 | // support other selectors atm. | 
| 266 | -		foreach ($selection as $_contact) { | |
| 267 | -			if(is_array($_contact) && array_key_exists('photo', $_contact)) { | |
| 320 | + foreach ($selection as $_contact) | |
| 321 | +		{ | |
| 322 | +			if(is_array($_contact) && array_key_exists('photo', $_contact)) | |
| 323 | +			{ | |
| 268 | 324 | unset($_contact['photo']); | 
| 269 | 325 | } | 
| 270 | -			if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { | |
| 326 | + if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) | |
| 327 | +			{ | |
| 271 | 328 | $_contact = $_contact['id']; | 
| 272 | 329 | } | 
| 273 | -			if(is_array($_contact) && $_contact['id']) { | |
| 330 | + if(is_array($_contact) && $_contact['id']) | |
| 331 | +			{ | |
| 274 | 332 | $contact = new addressbook_egw_record(); | 
| 275 | 333 | $contact->set_record($_contact); | 
| 276 | -			} else { | |
| 334 | + } | |
| 335 | + else | |
| 336 | +			{ | |
| 277 | 337 | $contact = new addressbook_egw_record($_contact); | 
| 278 | 338 | } | 
| 279 | 339 | |
| @@ -286,12 +346,19 @@ discard block | ||
| 286 | 346 | } | 
| 287 | 347 | // Some conversion | 
| 288 | 348 | $this->convert($contact, $options); | 
| 289 | -			if($options['convert']) { | |
| 349 | + if($options['convert']) | |
| 350 | +			{ | |
| 290 | 351 | importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects); | 
| 291 | -			} else { | |
| 352 | + } | |
| 353 | + else | |
| 354 | +			{ | |
| 292 | 355 | // Implode arrays, so they don't say 'Array' | 
| 293 | -				foreach($contact->get_record_array() as $key => $value) { | |
| 294 | -					if(is_array($value)) $contact->$key = implode(',', $value); | |
| 356 | + foreach($contact->get_record_array() as $key => $value) | |
| 357 | +				{ | |
| 358 | + if(is_array($value)) | |
| 359 | +					{ | |
| 360 | +						$contact->$key = implode(',', $value); | |
| 361 | + } | |
| 295 | 362 | } | 
| 296 | 363 | } | 
| 297 | 364 | |
| @@ -306,7 +373,8 @@ discard block | ||
| 306 | 373 | * | 
| 307 | 374 | * @return string name | 
| 308 | 375 | */ | 
| 309 | -	public static function get_name() { | |
| 376 | + public static function get_name() | |
| 377 | +	{ | |
| 310 | 378 |  		return lang('Addressbook CSV export'); | 
| 311 | 379 | } | 
| 312 | 380 | |
| @@ -315,7 +383,8 @@ discard block | ||
| 315 | 383 | * | 
| 316 | 384 | * @return string descriprion | 
| 317 | 385 | */ | 
| 318 | -	public static function get_description() { | |
| 386 | + public static function get_description() | |
| 387 | +	{ | |
| 319 | 388 |  		return lang("Exports contacts from your Addressbook into a CSV File."); | 
| 320 | 389 | } | 
| 321 | 390 | |
| @@ -324,11 +393,13 @@ discard block | ||
| 324 | 393 | * | 
| 325 | 394 | * @return string suffix | 
| 326 | 395 | */ | 
| 327 | -	public static function get_filesuffix() { | |
| 396 | + public static function get_filesuffix() | |
| 397 | +	{ | |
| 328 | 398 | return 'csv'; | 
| 329 | 399 | } | 
| 330 | 400 | |
| 331 | -	public static function get_mimetype() { | |
| 401 | + public static function get_mimetype() | |
| 402 | +	{ | |
| 332 | 403 | return 'text/csv'; | 
| 333 | 404 | } | 
| 334 | 405 | |
| @@ -351,14 +422,16 @@ discard block | ||
| 351 | 422 | * | 
| 352 | 423 | * @return string html | 
| 353 | 424 | */ | 
| 354 | -	public function get_options_etpl() { | |
| 425 | + public function get_options_etpl() | |
| 426 | +	{ | |
| 355 | 427 | } | 
| 356 | 428 | |
| 357 | 429 | /** | 
| 358 | 430 | * returns slectors of this plugin via xajax | 
| 359 | 431 | * | 
| 360 | 432 | */ | 
| 361 | -	public function get_selectors_etpl() { | |
| 433 | + public function get_selectors_etpl() | |
| 434 | +	{ | |
| 362 | 435 | return array( | 
| 363 | 436 | 'name' => 'importexport.export_csv_selectors', | 
| 364 | 437 | ); | 
| @@ -369,9 +442,11 @@ discard block | ||
| 369 | 442 | * | 
| 370 | 443 | * Dates, times, user IDs, category IDs | 
| 371 | 444 | */ | 
| 372 | -	public static function convert(addressbook_egw_record &$record, $options) { | |
| 445 | + public static function convert(addressbook_egw_record &$record, $options) | |
| 446 | +	{ | |
| 373 | 447 | |
| 374 | -		if ($record->tel_prefer) { | |
| 448 | + if ($record->tel_prefer) | |
| 449 | +		{ | |
| 375 | 450 | $field = $record->tel_prefer; | 
| 376 | 451 | $record->tel_prefer = $record->$field; | 
| 377 | 452 | } | 
| @@ -380,33 +455,52 @@ discard block | ||
| 380 | 455 |  		{ | 
| 381 | 456 | return; | 
| 382 | 457 | } | 
| 383 | -		foreach((array)$options['explode_multiselects'] as $field => $explode_settings) { | |
| 384 | -			if(!is_array($record->$field)) $record->$field = explode(',', $record->$field); | |
| 385 | -			foreach((array)$explode_settings['values'] as $value => $settings) { | |
| 458 | + foreach((array)$options['explode_multiselects'] as $field => $explode_settings) | |
| 459 | +		{ | |
| 460 | + if(!is_array($record->$field)) | |
| 461 | +			{ | |
| 462 | +				$record->$field = explode(',', $record->$field); | |
| 463 | + } | |
| 464 | + foreach((array)$explode_settings['values'] as $value => $settings) | |
| 465 | +			{ | |
| 386 | 466 | $field_name = "$field-$value"; | 
| 387 | 467 | $record->$field_name = array(); | 
| 388 | -				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) { | |
| 389 | -					if($explode_settings['explode'] != self::MAIN_CATS) { | |
| 468 | + if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) | |
| 469 | +				{ | |
| 470 | + if($explode_settings['explode'] != self::MAIN_CATS) | |
| 471 | +					{ | |
| 390 | 472 |  						$record->$field_name = $options['convert'] ? lang('Yes') : true; | 
| 391 | -					} elseif($options['convert']) { | |
| 473 | + } | |
| 474 | + elseif($options['convert']) | |
| 475 | +					{ | |
| 392 | 476 | // 3 part assign due to magic get method | 
| 393 | 477 | $record_value = $record->$field_name; | 
| 394 | 478 | $record_value[] = $settings['label']; | 
| 395 | 479 | $record->$field_name = $record_value; | 
| 396 | -					} else { | |
| 480 | + } | |
| 481 | + else | |
| 482 | +					{ | |
| 397 | 483 | $record->$field_name = $value; | 
| 398 | 484 | } | 
| 399 | 485 | } | 
| 400 | -				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) { | |
| 486 | + if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) | |
| 487 | +				{ | |
| 401 | 488 | // 3 part assign due to magic get method | 
| 402 | 489 | $record_value = $record->$field_name; | 
| 403 | - if(!is_array($record_value)) $record_value = array($record_value); | |
| 404 | -					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) { | |
| 490 | + if(!is_array($record_value)) | |
| 491 | +					{ | |
| 492 | + $record_value = array($record_value); | |
| 493 | + } | |
| 494 | + foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) | |
| 495 | +					{ | |
| 405 | 496 | $record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id; | 
| 406 | 497 | } | 
| 407 | 498 | $record->$field_name = $record_value; | 
| 408 | 499 | } | 
| 409 | - if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); | |
| 500 | + if(is_array($record->$field_name)) | |
| 501 | +				{ | |
| 502 | + $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); | |
| 503 | + } | |
| 410 | 504 | } | 
| 411 | 505 | } | 
| 412 | 506 | } | 
| @@ -436,12 +530,15 @@ discard block | ||
| 436 | 530 | * Adjust automatically generated filter fields | 
| 437 | 531 | */ | 
| 438 | 532 | public function get_filter_fields(Array &$filters) | 
| 439 | -    { | |
| 533 | +	{ | |
| 440 | 534 | unset($filters['last_event']); | 
| 441 | 535 | unset($filters['next_event']); | 
| 442 | 536 | foreach($filters as $field_name => &$settings) | 
| 443 | 537 |  		{ | 
| 444 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; | |
| 538 | + if($this->selects[$field_name]) | |
| 539 | +			{ | |
| 540 | + $settings['values'] = $this->selects[$field_name]; | |
| 541 | + } | |
| 445 | 542 | } | 
| 446 | 543 | $filters['owner'] = array( | 
| 447 | 544 | 'name' => 'owner', | 
| @@ -79,8 +79,6 @@ | ||
| 79 | 79 | * Here we need to handle any incoming data. Setup is done in the constructor, | 
| 80 | 80 | * output is handled by parent. | 
| 81 | 81 | * | 
| 82 | - * @param type $id | |
| 83 | - * @param Etemplate $etemplate | |
| 84 | 82 | */ | 
| 85 | 83 | public static function process($values = array()) | 
| 86 | 84 |  	{ | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | * @param array &$files | 
| 107 | 107 | * @param int $user account_id | 
| 108 | 108 | * @param string $id ='' | 
| 109 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') | |
| 109 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') | |
| 110 | 110 | */ | 
| 111 | 111 | function propfind($path,&$options,&$files,$user,$id='') | 
| 112 | 112 |  	{ | 
| @@ -188,7 +188,7 @@ discard block | ||
| 188 | 188 | * | 
| 189 | 189 | * @param string $path | 
| 190 | 190 | * @param array& $filter | 
| 191 | - * @param array|boolean $start =false false=return all or array(start,num) | |
| 191 | + * @param integer[] $start =false false=return all or array(start,num) | |
| 192 | 192 | * @return array with "files" array with values for keys path and props | 
| 193 | 193 | */ | 
| 194 | 194 | function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true) | 
| @@ -539,7 +539,7 @@ discard block | ||
| 539 | 539 | * @param array &$options | 
| 540 | 540 | * @param int $id | 
| 541 | 541 | * @param int $user =null account_id | 
| 542 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') | |
| 542 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') | |
| 543 | 543 | */ | 
| 544 | 544 | function get(&$options,$id,$user=null) | 
| 545 | 545 |  	{ | 
| @@ -566,7 +566,7 @@ discard block | ||
| 566 | 566 | * @param int $id | 
| 567 | 567 | * @param int $user =null account_id of owner, default null | 
| 568 | 568 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) | 
| 569 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') | |
| 569 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') | |
| 570 | 570 | */ | 
| 571 | 571 | function put(&$options,$id,$user=null,$prefix=null) | 
| 572 | 572 |  	{ | 
| @@ -1024,7 +1024,7 @@ discard block | ||
| 1024 | 1024 | * | 
| 1025 | 1025 | * @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE | 
| 1026 | 1026 | * @param array|int $contact contact-array or id | 
| 1027 | - * @return boolean null if entry does not exist, false if no access, true if access permitted | |
| 1027 | + * @return null|boolean null if entry does not exist, false if no access, true if access permitted | |
| 1028 | 1028 | */ | 
| 1029 | 1029 | function check_access($acl,$contact) | 
| 1030 | 1030 |  	{ | 
| @@ -85,7 +85,10 @@ discard block | ||
| 85 | 85 | self::$path_attr = 'carddav_name'; | 
| 86 | 86 | self::$path_extension = ''; | 
| 87 | 87 | } | 
| 88 | -		if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); | |
| 88 | + if ($this->debug) | |
| 89 | +		{ | |
| 90 | +			error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); | |
| 91 | + } | |
| 89 | 92 | |
| 90 | 93 | $this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; | 
| 91 | 94 |  		$this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array(); | 
| @@ -123,7 +126,10 @@ discard block | ||
| 123 | 126 | $filter['owner'] = $user; | 
| 124 | 127 | } | 
| 125 | 128 | // should we hide the accounts addressbook | 
| 126 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; | |
| 129 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) | |
| 130 | +		{ | |
| 131 | + $filter['account_id'] = null; | |
| 132 | + } | |
| 127 | 133 | |
| 128 | 134 | // process REPORT filters or multiget href's | 
| 129 | 135 | $nresults = null; | 
| @@ -131,9 +137,16 @@ discard block | ||
| 131 | 137 |  		{ | 
| 132 | 138 | return false; | 
| 133 | 139 | } | 
| 134 | - if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback | |
| 140 | + if ($id) | |
| 141 | +		{ | |
| 142 | + $path = dirname($path).'/'; | |
| 143 | + } | |
| 144 | + // carddav_name get's added anyway in the callback | |
| 135 | 145 | |
| 136 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); | |
| 146 | + if ($this->debug) | |
| 147 | +		{ | |
| 148 | + error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); | |
| 149 | + } | |
| 137 | 150 | |
| 138 | 151 | // check if we have to return the full contact data or just the etag's | 
| 139 | 152 | if (!($filter['address_data'] = $options['props'] == 'all' && | 
| @@ -218,16 +231,25 @@ discard block | ||
| 218 | 231 | |
| 219 | 232 | if (isset($filter[self::$path_attr])) | 
| 220 | 233 |  		{ | 
| 221 | - if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr]; | |
| 234 | + if (!is_array($filter[self::$path_attr])) | |
| 235 | +			{ | |
| 236 | + $filter[self::$path_attr] = (array)$filter[self::$path_attr]; | |
| 237 | + } | |
| 222 | 238 | $requested_multiget_ids =& $filter[self::$path_attr]; | 
| 223 | 239 | } | 
| 224 | 240 | |
| 225 | 241 | $files = array(); | 
| 226 | 242 | // we query etag and modified, as LDAP does not have the strong sql etag | 
| 227 | 243 |  		$cols = array('id','uid','etag','modified','n_fn'); | 
| 228 | - if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr; | |
| 244 | + if (!in_array(self::$path_attr,$cols)) | |
| 245 | +		{ | |
| 246 | + $cols[] = self::$path_attr; | |
| 247 | + } | |
| 229 | 248 | // we need tid for sync-collection report | 
| 230 | -		if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid'; | |
| 249 | +		if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) | |
| 250 | +		{ | |
| 251 | + $cols[] = 'tid'; | |
| 252 | + } | |
| 231 | 253 | if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter))) | 
| 232 | 254 |  		{ | 
| 233 | 255 | foreach($contacts as &$contact) | 
| @@ -271,7 +293,10 @@ discard block | ||
| 271 | 293 |  			{ | 
| 272 | 294 | $accounts_filter = $filter_in; | 
| 273 | 295 | $accounts_filter['owner'] = '0'; | 
| 274 | - if ($sync_collection_report) $token_was = $this->sync_collection_token; | |
| 296 | + if ($sync_collection_report) | |
| 297 | +				{ | |
| 298 | + $token_was = $this->sync_collection_token; | |
| 299 | + } | |
| 275 | 300 | self::$path_attr = 'id'; | 
| 276 | 301 | self::$path_extension = '.vcf'; | 
| 277 | 302 | $files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false)); | 
| @@ -292,18 +317,27 @@ discard block | ||
| 292 | 317 | if ($sync_collection_report) | 
| 293 | 318 |  				{ | 
| 294 | 319 |  					list(,$sync_token) = explode('>', $filter[0]); | 
| 295 | - if ((int)$sync_token) $where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token); | |
| 320 | + if ((int)$sync_token) | |
| 321 | +					{ | |
| 322 | + $where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token); | |
| 323 | + } | |
| 296 | 324 | } | 
| 297 | - if (isset($filter[self::$path_attr])) // multiget report? | |
| 325 | + if (isset($filter[self::$path_attr])) | |
| 326 | +				{ | |
| 327 | + // multiget report? | |
| 298 | 328 |  				{ | 
| 299 | 329 | $where['list_'.self::$path_attr] = $filter[self::$path_attr]; | 
| 300 | 330 | } | 
| 331 | + } | |
| 301 | 332 |  				//error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where)); | 
| 302 | - if ($where['id'] && ($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! | |
| 333 | + if ($where['id'] && ($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) | |
| 334 | +				{ | |
| 335 | + // limit to contacts in same AB! | |
| 303 | 336 |  				{ | 
| 304 | 337 | foreach($lists as $list) | 
| 305 | 338 |  					{ | 
| 306 | 339 | $list[self::$path_attr] = $list['list_carddav_name']; | 
| 340 | + } | |
| 307 | 341 | $etag = $list['list_id'].':'.$list['list_etag']; | 
| 308 | 342 | // for all-in-one addressbook, add selected ABs to etag | 
| 309 | 343 | if (isset($filter['owner']) && is_array($filter['owner'])) | 
| @@ -347,7 +381,10 @@ discard block | ||
| 347 | 381 | } | 
| 348 | 382 | } | 
| 349 | 383 | |
| 350 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); | |
| 384 | + if ($this->debug) | |
| 385 | +		{ | |
| 386 | + error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); | |
| 387 | + } | |
| 351 | 388 | return $files; | 
| 352 | 389 | } | 
| 353 | 390 | |
| @@ -387,7 +424,11 @@ discard block | ||
| 387 | 424 | $matches = $prop_test = $column = null; | 
| 388 | 425 | foreach($options['filters'] as $n => $filter) | 
| 389 | 426 |  			{ | 
| 390 | - if (!is_int($n)) continue; // eg. attributes of filter xml element | |
| 427 | + if (!is_int($n)) | |
| 428 | +				{ | |
| 429 | + continue; | |
| 430 | + } | |
| 431 | + // eg. attributes of filter xml element | |
| 391 | 432 | |
| 392 | 433 | switch((string)$filter['name']) | 
| 393 | 434 |  				{ | 
| @@ -395,19 +436,28 @@ discard block | ||
| 395 | 436 |  						$this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); | 
| 396 | 437 | break; | 
| 397 | 438 | case 'prop-filter': // can be multiple prop-filter, see example | 
| 398 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); | |
| 439 | + if ($matches) | |
| 440 | +						{ | |
| 441 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); | |
| 442 | + } | |
| 399 | 443 | $matches = array(); | 
| 400 | 444 | $prop_filter = strtoupper($filter['attrs']['name']); | 
| 401 | 445 | $prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof'; | 
| 402 | - if ($this->debug > 1) error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); | |
| 446 | + if ($this->debug > 1) | |
| 447 | +						{ | |
| 448 | + error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); | |
| 449 | + } | |
| 403 | 450 | break; | 
| 404 | 451 | case 'is-not-defined': | 
| 405 | 452 |  						$matches[] = '('.$column."='' OR ".$column.' IS NULL)'; | 
| 406 | 453 | break; | 
| 407 | 454 | case 'text-match': // prop-filter can have multiple text-match, see example | 
| 408 | - if (!isset($this->filter_prop2cal[$prop_filter])) // eg. not existing NICKNAME in EGroupware | |
| 455 | + if (!isset($this->filter_prop2cal[$prop_filter])) | |
| 456 | +						{ | |
| 457 | + // eg. not existing NICKNAME in EGroupware | |
| 409 | 458 |  						{ | 
| 410 | 459 |  							if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored"); | 
| 460 | + } | |
| 411 | 461 | $column = false; // to ignore following data too | 
| 412 | 462 | } | 
| 413 | 463 | else | 
| @@ -420,8 +470,14 @@ discard block | ||
| 420 | 470 | break; | 
| 421 | 471 | } | 
| 422 | 472 | $column = $this->filter_prop2cal[strtoupper($prop_filter)]; | 
| 423 | - if (strpos($column, '_') === false) $column = 'contact_'.$column; | |
| 424 | - if (!isset($filters['order'])) $filters['order'] = $column; | |
| 473 | + if (strpos($column, '_') === false) | |
| 474 | +							{ | |
| 475 | + $column = 'contact_'.$column; | |
| 476 | + } | |
| 477 | + if (!isset($filters['order'])) | |
| 478 | +							{ | |
| 479 | + $filters['order'] = $column; | |
| 480 | + } | |
| 425 | 481 | $match_type = $filter['attrs']['match-type']; | 
| 426 | 482 | $negate_condition = isset($filter['attrs']['negate-condition']) && $filter['attrs']['negate-condition'] == 'yes'; | 
| 427 | 483 | } | 
| @@ -429,9 +485,12 @@ discard block | ||
| 429 | 485 | case '': // data of text-match element | 
| 430 | 486 | if (isset($filter['data']) && isset($column)) | 
| 431 | 487 |  						{ | 
| 432 | - if ($column) // false for properties not known to EGroupware | |
| 488 | + if ($column) | |
| 489 | +							{ | |
| 490 | + // false for properties not known to EGroupware | |
| 433 | 491 |  							{ | 
| 434 | 492 |  								$value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']); | 
| 493 | + } | |
| 435 | 494 | switch($match_type) | 
| 436 | 495 |  								{ | 
| 437 | 496 | case 'equals': | 
| @@ -450,7 +509,10 @@ discard block | ||
| 450 | 509 | } | 
| 451 | 510 | $matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter; | 
| 452 | 511 | |
| 453 | -								if ($this->debug > 1) error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); | |
| 512 | + if ($this->debug > 1) | |
| 513 | +								{ | |
| 514 | +									error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); | |
| 515 | + } | |
| 454 | 516 | } | 
| 455 | 517 | unset($column); | 
| 456 | 518 | break; | 
| @@ -461,11 +523,17 @@ discard block | ||
| 461 | 523 | break; | 
| 462 | 524 | } | 
| 463 | 525 | } | 
| 464 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); | |
| 526 | + if ($matches) | |
| 527 | +			{ | |
| 528 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); | |
| 529 | + } | |
| 465 | 530 | if ($prop_filters) | 
| 466 | 531 |  			{ | 
| 467 | 532 |  				$filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))'; | 
| 468 | - if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); | |
| 533 | + if ($this->debug) | |
| 534 | +				{ | |
| 535 | + error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); | |
| 536 | + } | |
| 469 | 537 | } | 
| 470 | 538 | } | 
| 471 | 539 | // parse limit from $options['other'] | 
| @@ -522,8 +590,14 @@ discard block | ||
| 522 | 590 | } | 
| 523 | 591 | } | 
| 524 | 592 | } | 
| 525 | - if ($ids) $filters[self::$path_attr] = $ids; | |
| 526 | -			if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); | |
| 593 | + if ($ids) | |
| 594 | +			{ | |
| 595 | + $filters[self::$path_attr] = $ids; | |
| 596 | + } | |
| 597 | + if ($this->debug) | |
| 598 | +			{ | |
| 599 | +				error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); | |
| 600 | + } | |
| 527 | 601 | } | 
| 528 | 602 | elseif ($id) | 
| 529 | 603 |  		{ | 
| @@ -570,12 +644,18 @@ discard block | ||
| 570 | 644 | */ | 
| 571 | 645 | function put(&$options,$id,$user=null,$prefix=null) | 
| 572 | 646 |  	{ | 
| 573 | -		if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)"); | |
| 647 | + if ($this->debug) | |
| 648 | +		{ | |
| 649 | +			error_log(__METHOD__.'('.array2string($options).",$id,$user)"); | |
| 650 | + } | |
| 574 | 651 | |
| 575 | 652 |  		$oldContact = $this->_common_get_put_delete('PUT',$options,$id); | 
| 576 | 653 | if (!is_null($oldContact) && !is_array($oldContact)) | 
| 577 | 654 |  		{ | 
| 578 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); | |
| 655 | + if ($this->debug) | |
| 656 | +			{ | |
| 657 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); | |
| 658 | + } | |
| 579 | 659 | return $oldContact; | 
| 580 | 660 | } | 
| 581 | 661 | |
| @@ -666,15 +746,24 @@ discard block | ||
| 666 | 746 | // done here again, as _common_get_put_delete knows nothing about default addressbooks... | 
| 667 | 747 | if (!($this->bo->grants[$contact['owner']] & Acl::ADD)) | 
| 668 | 748 |  			{ | 
| 669 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); | |
| 749 | + if ($this->debug) | |
| 750 | +				{ | |
| 751 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); | |
| 752 | + } | |
| 670 | 753 | return '403 Forbidden'; | 
| 671 | 754 | } | 
| 672 | 755 | } | 
| 673 | - if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match); | |
| 756 | + if ($this->http_if_match) | |
| 757 | +		{ | |
| 758 | + $contact['etag'] = self::etag2value($this->http_if_match); | |
| 759 | + } | |
| 674 | 760 | |
| 675 | 761 | if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact))) | 
| 676 | 762 |  		{ | 
| 677 | -			if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); | |
| 763 | + if ($this->debug) | |
| 764 | +			{ | |
| 765 | +				error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); | |
| 766 | + } | |
| 678 | 767 | if ($save_ok === 0) | 
| 679 | 768 |  			{ | 
| 680 | 769 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) | 
| @@ -703,7 +792,10 @@ discard block | ||
| 703 | 792 | // send evtl. necessary respose headers: Location, etag, ... | 
| 704 | 793 | $this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id'); | 
| 705 | 794 | |
| 706 | - if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); | |
| 795 | + if ($this->debug > 1) | |
| 796 | +		{ | |
| 797 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); | |
| 798 | + } | |
| 707 | 799 | return $retval; | 
| 708 | 800 | } | 
| 709 | 801 | |
| @@ -717,7 +809,10 @@ discard block | ||
| 717 | 809 | function save_group(array &$contact, $oldContact=null) | 
| 718 | 810 |  	{ | 
| 719 | 811 |  		$data = array('list_name' => $contact['n_fn']); | 
| 720 | - if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; | |
| 812 | + if (!isset($contact['owner'])) | |
| 813 | +		{ | |
| 814 | + $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; | |
| 815 | + } | |
| 721 | 816 |  		foreach(array('id','carddav_name','uid','owner') as $name) | 
| 722 | 817 |  		{ | 
| 723 | 818 | $data['list_'.$name] = $contact[$name]; | 
| @@ -769,13 +864,22 @@ discard block | ||
| 769 | 864 | } | 
| 770 | 865 | } | 
| 771 | 866 |  				//error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids)); | 
| 772 | - if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array()); | |
| 773 | - if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id); | |
| 867 | + if ($to_add_ids) | |
| 868 | +				{ | |
| 869 | + $this->bo->add2list($to_add_ids, $list_id, array()); | |
| 870 | + } | |
| 871 | + if ($to_delete_ids) | |
| 872 | +				{ | |
| 873 | + $this->bo->remove_from_list($to_delete_ids, $list_id); | |
| 874 | + } | |
| 774 | 875 | } | 
| 775 | 876 | // reread as update of list-members updates etag and modified | 
| 776 | 877 | $contact = $this->bo->read_list($list_id); | 
| 777 | 878 | } | 
| 778 | -		if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); | |
| 879 | + if ($this->debug > 1) | |
| 880 | +		{ | |
| 881 | +			error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); | |
| 882 | + } | |
| 779 | 883 | return $list_id; | 
| 780 | 884 | } | 
| 781 | 885 | |
| @@ -789,11 +893,17 @@ discard block | ||
| 789 | 893 | public function getctag($path,$user) | 
| 790 | 894 |  	{ | 
| 791 | 895 | static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested | 
| 792 | - if (isset($ctags[$path])) return $ctags[$path]; | |
| 896 | + if (isset($ctags[$path])) | |
| 897 | +		{ | |
| 898 | + return $ctags[$path]; | |
| 899 | + } | |
| 793 | 900 | |
| 794 | 901 | $user_in = $user; | 
| 795 | 902 | // not showing addressbook of a single user? | 
| 796 | - if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; | |
| 903 | + if (is_null($user) || $user === '' || $path == '/addressbook/') | |
| 904 | +		{ | |
| 905 | + $user = null; | |
| 906 | + } | |
| 797 | 907 | |
| 798 | 908 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too | 
| 799 | 909 |  		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) | 
| @@ -1006,16 +1116,22 @@ discard block | ||
| 1006 | 1116 |  				$contact['etag'] .= ':'.implode('-',$limit_in_ab); | 
| 1007 | 1117 | } | 
| 1008 | 1118 | } | 
| 1009 | - elseif($contact === array()) // not found from read_lists() | |
| 1119 | + elseif($contact === array()) | |
| 1120 | +		{ | |
| 1121 | + // not found from read_lists() | |
| 1010 | 1122 |  		{ | 
| 1011 | 1123 | $contact = null; | 
| 1012 | 1124 | } | 
| 1125 | + } | |
| 1013 | 1126 | |
| 1014 | 1127 | if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE) | 
| 1015 | 1128 |  		{ | 
| 1016 | 1129 | $contact = null; // handle deleted events, as not existing (404 Not Found) | 
| 1017 | 1130 | } | 
| 1018 | -		if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); | |
| 1131 | + if ($this->debug > 1) | |
| 1132 | +		{ | |
| 1133 | +			error_log(__METHOD__."('$id') returning ".array2string($contact)); | |
| 1134 | + } | |
| 1019 | 1135 | return $contact; | 
| 1020 | 1136 | } | 
| 1021 | 1137 | |
| @@ -1045,7 +1161,10 @@ discard block | ||
| 1045 | 1161 | // remove add and delete grants for accounts (for admins too) | 
| 1046 | 1162 | // as accounts can not be created as contacts, they eg. need further data | 
| 1047 | 1163 | // and admins might not recognice they delete an account incl. its data | 
| 1048 | - if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); | |
| 1164 | + if (isset($grants[0])) | |
| 1165 | +		{ | |
| 1166 | + $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); | |
| 1167 | + } | |
| 1049 | 1168 | |
| 1050 | 1169 | return $grants; | 
| 1051 | 1170 | } | 
| @@ -1061,7 +1180,10 @@ discard block | ||
| 1061 | 1180 | $shared = array(); | 
| 1062 | 1181 | |
| 1063 | 1182 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks | 
| 1064 | -		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); | |
| 1183 | +		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) | |
| 1184 | +		{ | |
| 1185 | + return array(); | |
| 1186 | + } | |
| 1065 | 1187 | |
| 1066 | 1188 | // replace symbolic id's with real nummeric id's | 
| 1067 | 1189 | foreach(array( | 
| @@ -1128,7 +1250,11 @@ discard block | ||
| 1128 | 1250 | $user = $hook_data['account_id']; | 
| 1129 | 1251 | $addressbook_bo = new Api\Contacts(); | 
| 1130 | 1252 | $addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user); | 
| 1131 | - if ($user > 0) unset($addressbooks[$user]); // allways synced | |
| 1253 | + if ($user > 0) | |
| 1254 | +			{ | |
| 1255 | + unset($addressbooks[$user]); | |
| 1256 | + } | |
| 1257 | + // allways synced | |
| 1132 | 1258 | unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now | 
| 1133 | 1259 | } | 
| 1134 | 1260 | |
| @@ -44,9 +44,7 @@ discard block | ||
| 44 | 44 | |
| 45 | 45 | /** | 
| 46 | 46 | * imports entries according to given definition object. | 
| 47 | - * @param resource $_stream | |
| 48 | - * @param string $_charset | |
| 49 | - * @param definition $_definition | |
| 47 | + * @param importexport_definition $_definition | |
| 50 | 48 | */ | 
| 51 | 49 |  	public function init(importexport_definition &$_definition ) { | 
| 52 | 50 | |
| @@ -84,7 +82,7 @@ discard block | ||
| 84 | 82 | * | 
| 85 | 83 | * Updates the count of actions taken | 
| 86 | 84 | * | 
| 87 | - * @return boolean success | |
| 85 | + * @return null|boolean success | |
| 88 | 86 | */ | 
| 89 | 87 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) | 
| 90 | 88 |  	{ | 
| @@ -15,7 +15,8 @@ discard block | ||
| 15 | 15 | /** | 
| 16 | 16 | * class import_csv for addressbook | 
| 17 | 17 | */ | 
| 18 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv  { | |
| 18 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv | |
| 19 | +{ | |
| 19 | 20 | |
| 20 | 21 | /** | 
| 21 | 22 | * conditions for actions | 
| @@ -48,7 +49,8 @@ discard block | ||
| 48 | 49 | * @param string $_charset | 
| 49 | 50 | * @param definition $_definition | 
| 50 | 51 | */ | 
| 51 | -	public function init(importexport_definition &$_definition ) { | |
| 52 | + public function init(importexport_definition &$_definition ) | |
| 53 | +	{ | |
| 52 | 54 | |
| 53 | 55 | // fetch the addressbook bo | 
| 54 | 56 | $this->bocontacts = new Api\Contacts(); | 
| @@ -90,22 +92,29 @@ discard block | ||
| 90 | 92 |  	{ | 
| 91 | 93 | |
| 92 | 94 | // Set owner, unless it's supposed to come from CSV file | 
| 93 | -		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { | |
| 94 | -			if(!is_numeric($record->owner)) { | |
| 95 | + if($this->definition->plugin_options['owner_from_csv'] && $record->owner) | |
| 96 | +		{ | |
| 97 | + if(!is_numeric($record->owner)) | |
| 98 | +			{ | |
| 95 | 99 | // Automatically handle text owner without explicit translation | 
| 96 | 100 | $new_owner = importexport_helper_functions::account_name2id($record->owner); | 
| 97 | -				if($new_owner == '') { | |
| 101 | + if($new_owner == '') | |
| 102 | +				{ | |
| 98 | 103 | $this->errors[$import_csv->get_current_position()] = lang( | 
| 99 | 104 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', | 
| 100 | 105 | $record->owner, | 
| 101 | 106 | Api\Accounts::username($this->user) | 
| 102 | 107 | ); | 
| 103 | 108 | $record->owner = $this->user; | 
| 104 | -				} else { | |
| 109 | + } | |
| 110 | + else | |
| 111 | +				{ | |
| 105 | 112 | $record->owner = $new_owner; | 
| 106 | 113 | } | 
| 107 | 114 | } | 
| 108 | -		} else { | |
| 115 | + } | |
| 116 | + else | |
| 117 | +		{ | |
| 109 | 118 | $record->owner = $this->user; | 
| 110 | 119 | } | 
| 111 | 120 | |
| @@ -141,26 +150,41 @@ discard block | ||
| 141 | 150 | // Also handle categories in their own field | 
| 142 | 151 | $record_array = $record->get_record_array(); | 
| 143 | 152 | $more_categories = array(); | 
| 144 | -		foreach($this->definition->plugin_options['field_mapping'] as $field_name) { | |
| 153 | + foreach($this->definition->plugin_options['field_mapping'] as $field_name) | |
| 154 | +		{ | |
| 145 | 155 | if(!array_key_exists($field_name, $record_array) || | 
| 146 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; | |
| 156 | + substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') | |
| 157 | +			{ | |
| 158 | + continue; | |
| 159 | + } | |
| 147 | 160 |  			list(, $cat_id) = explode('-', $field_name); | 
| 148 | -			if(is_numeric($record->$field_name) && $record->$field_name != 1) { | |
| 161 | + if(is_numeric($record->$field_name) && $record->$field_name != 1) | |
| 162 | +			{ | |
| 149 | 163 | // Column has a single category ID | 
| 150 | 164 | $more_categories[] = $record->$field_name; | 
| 151 | - } elseif($record->$field_name == '1' || | |
| 152 | -				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { | |
| 165 | + } | |
| 166 | + elseif($record->$field_name == '1' || | |
| 167 | +				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) | |
| 168 | +			{ | |
| 153 | 169 |  				// Each category got its own column.  '1' is the database value, lang('yes') is the human value | 
| 154 | 170 | $more_categories[] = $cat_id; | 
| 155 | -			} else { | |
| 171 | + } | |
| 172 | + else | |
| 173 | +			{ | |
| 156 | 174 | // Text categories | 
| 157 | 175 |  				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); | 
| 158 | 176 | } | 
| 159 | 177 | } | 
| 160 | -		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); | |
| 178 | + if(count($more_categories) > 0) | |
| 179 | +		{ | |
| 180 | +			$record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); | |
| 181 | + } | |
| 161 | 182 | |
| 162 | 183 | // Private set but missing causes hidden entries | 
| 163 | -		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); | |
| 184 | +		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) | |
| 185 | +		{ | |
| 186 | + unset($record->private); | |
| 187 | + } | |
| 164 | 188 | |
| 165 | 189 | // Format birthday as backend requires - converter should give timestamp | 
| 166 | 190 | if($record->bday && is_numeric($record->bday)) | 
| @@ -169,17 +193,24 @@ discard block | ||
| 169 | 193 |  			$record->bday = $time->format('Y-m-d'); | 
| 170 | 194 | } | 
| 171 | 195 | |
| 172 | -		if ( $this->definition->plugin_options['conditions'] ) { | |
| 173 | -			foreach ( $this->definition->plugin_options['conditions'] as $condition ) { | |
| 196 | + if ( $this->definition->plugin_options['conditions'] ) | |
| 197 | +		{ | |
| 198 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) | |
| 199 | +			{ | |
| 174 | 200 | $contacts = array(); | 
| 175 | -				switch ( $condition['type'] ) { | |
| 201 | + switch ( $condition['type'] ) | |
| 202 | +				{ | |
| 176 | 203 | // exists | 
| 177 | 204 | case 'exists' : | 
| 178 | -						if($record_array[$condition['string']]) { | |
| 205 | + if($record_array[$condition['string']]) | |
| 206 | +						{ | |
| 179 | 207 | $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); | 
| 180 | 208 | // if we use account_id for the condition, we need to set the owner for filtering, as this | 
| 181 | 209 | // enables Api\Contacts\Storage to decide what backend is to be used | 
| 182 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; | |
| 210 | + if ($condition['string']=='account_id') | |
| 211 | +							{ | |
| 212 | + $searchcondition['owner']=0; | |
| 213 | + } | |
| 183 | 214 | $contacts = $this->bocontacts->search( | 
| 184 | 215 | //array( $condition['string'] => $record[$condition['string']],), | 
| 185 | 216 | '', | 
| @@ -188,19 +219,30 @@ discard block | ||
| 188 | 219 | $searchcondition | 
| 189 | 220 | ); | 
| 190 | 221 | } | 
| 191 | -						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { | |
| 222 | + if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) | |
| 223 | +						{ | |
| 192 | 224 | // apply action to all contacts matching this exists condition | 
| 193 | 225 | $action = $condition['true']; | 
| 194 | -							foreach ( (array)$contacts as $contact ) { | |
| 226 | + foreach ( (array)$contacts as $contact ) | |
| 227 | +							{ | |
| 195 | 228 | $record->id = $contact['id']; | 
| 196 | -								if ( $this->definition->plugin_options['update_cats'] == 'add' ) { | |
| 197 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); | |
| 198 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); | |
| 229 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) | |
| 230 | +								{ | |
| 231 | + if ( !is_array( $contact['cat_id'] ) ) | |
| 232 | +									{ | |
| 233 | + $contact['cat_id'] = explode( ',', $contact['cat_id'] ); | |
| 234 | + } | |
| 235 | + if ( !is_array( $record_array['cat_id'] ) ) | |
| 236 | +									{ | |
| 237 | + $record->cat_id = explode( ',', $record->cat_id ); | |
| 238 | + } | |
| 199 | 239 | $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); | 
| 200 | 240 | } | 
| 201 | 241 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); | 
| 202 | 242 | } | 
| 203 | -						} else { | |
| 243 | + } | |
| 244 | + else | |
| 245 | +						{ | |
| 204 | 246 | $action = $condition['false']; | 
| 205 | 247 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); | 
| 206 | 248 | } | 
| @@ -227,9 +269,14 @@ discard block | ||
| 227 | 269 |  						die('condition / action not supported!!!'); | 
| 228 | 270 | break; | 
| 229 | 271 | } | 
| 230 | - if ($action['stop']) break; | |
| 272 | + if ($action['stop']) | |
| 273 | +				{ | |
| 274 | + break; | |
| 275 | + } | |
| 231 | 276 | } | 
| 232 | -		} else { | |
| 277 | + } | |
| 278 | + else | |
| 279 | +		{ | |
| 233 | 280 | // unconditional insert | 
| 234 | 281 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); | 
| 235 | 282 | } | 
| @@ -243,15 +290,18 @@ discard block | ||
| 243 | 290 | * @param importexport_iface_egw_record $record contact data for the action | 
| 244 | 291 | * @return bool success or not | 
| 245 | 292 | */ | 
| 246 | -	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { | |
| 293 | + protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) | |
| 294 | +	{ | |
| 247 | 295 | $_data = $record->get_record_array(); | 
| 248 | -		switch ($_action) { | |
| 296 | + switch ($_action) | |
| 297 | +		{ | |
| 249 | 298 | case 'none' : | 
| 250 | 299 | return true; | 
| 251 | 300 | case 'delete': | 
| 252 | 301 | if($_data['id']) | 
| 253 | 302 |  				{ | 
| 254 | -					if ( $this->dry_run ) { | |
| 303 | + if ( $this->dry_run ) | |
| 304 | +					{ | |
| 255 | 305 | //print_r($_data); | 
| 256 | 306 | $this->results[$_action]++; | 
| 257 | 307 | return true; | 
| @@ -272,14 +322,20 @@ discard block | ||
| 272 | 322 | // Only update if there are changes | 
| 273 | 323 | $old = $this->bocontacts->read($_data['id']); | 
| 274 | 324 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. | 
| 275 | -				foreach(array('adr_one_', 'adr_two_') as $c_prefix) { | |
| 325 | +				foreach(array('adr_one_', 'adr_two_') as $c_prefix) | |
| 326 | +				{ | |
| 276 | 327 | if (strlen(trim($_data[$c_prefix.'countryname']))==2) | 
| 277 | - $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); | |
| 328 | +					{ | |
| 329 | + $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); | |
| 330 | + } | |
| 278 | 331 | } | 
| 279 | 332 | // Don't change a user account into a contact | 
| 280 | -				if($old['owner'] == 0) { | |
| 333 | + if($old['owner'] == 0) | |
| 334 | +				{ | |
| 281 | 335 | unset($_data['owner']); | 
| 282 | -				} elseif(!$this->definition->plugin_options['change_owner']) { | |
| 336 | + } | |
| 337 | + elseif(!$this->definition->plugin_options['change_owner']) | |
| 338 | +				{ | |
| 283 | 339 | // Don't change addressbook of an existing contact | 
| 284 | 340 | unset($_data['owner']); | 
| 285 | 341 | } | 
| @@ -287,9 +343,12 @@ discard block | ||
| 287 | 343 | // Merge to deal with fields not in import record | 
| 288 | 344 | $_data = array_merge($old, $_data); | 
| 289 | 345 | $changed = $this->tracking->changed_fields($_data, $old); | 
| 290 | -				if(count($changed) == 0) { | |
| 346 | + if(count($changed) == 0) | |
| 347 | +				{ | |
| 291 | 348 | return true; | 
| 292 | -				} else { | |
| 349 | + } | |
| 350 | + else | |
| 351 | +				{ | |
| 293 | 352 |  					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); | 
| 294 | 353 | } | 
| 295 | 354 | |
| @@ -298,24 +357,32 @@ discard block | ||
| 298 | 357 | |
| 299 | 358 | // Fall through | 
| 300 | 359 | case 'insert' : | 
| 301 | -				if($_action == 'insert') { | |
| 360 | + if($_action == 'insert') | |
| 361 | +				{ | |
| 302 | 362 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag | 
| 303 | 363 | unset($_data['id']); | 
| 304 | 364 | } | 
| 305 | -				if(!isset($_data['org_name'])) { | |
| 365 | + if(!isset($_data['org_name'])) | |
| 366 | +				{ | |
| 306 | 367 | // org_name is a trigger to update n_fileas | 
| 307 | 368 | $_data['org_name'] = ''; | 
| 308 | 369 | } | 
| 309 | 370 | |
| 310 | -				if ( $this->dry_run ) { | |
| 371 | + if ( $this->dry_run ) | |
| 372 | +				{ | |
| 311 | 373 | //print_r($_data); | 
| 312 | 374 | $this->results[$_action]++; | 
| 313 | 375 | return true; | 
| 314 | -				} else { | |
| 376 | + } | |
| 377 | + else | |
| 378 | +				{ | |
| 315 | 379 | $result = $this->bocontacts->save( $_data, $this->is_admin); | 
| 316 | -					if(!$result) { | |
| 380 | + if(!$result) | |
| 381 | +					{ | |
| 317 | 382 | $this->errors[$record_num] = $this->bocontacts->error; | 
| 318 | -					} else { | |
| 383 | + } | |
| 384 | + else | |
| 385 | +					{ | |
| 319 | 386 | $this->results[$_action]++; | 
| 320 | 387 | // This does nothing (yet?) but update the identifier | 
| 321 | 388 | $record->save($result); | 
| @@ -333,7 +400,8 @@ discard block | ||
| 333 | 400 | * | 
| 334 | 401 | * @return string name | 
| 335 | 402 | */ | 
| 336 | -	public static function get_name() { | |
| 403 | + public static function get_name() | |
| 404 | +	{ | |
| 337 | 405 |  		return lang('Addressbook CSV import'); | 
| 338 | 406 | } | 
| 339 | 407 | |
| @@ -342,7 +410,8 @@ discard block | ||
| 342 | 410 | * | 
| 343 | 411 | * @return string descriprion | 
| 344 | 412 | */ | 
| 345 | -	public static function get_description() { | |
| 413 | + public static function get_description() | |
| 414 | +	{ | |
| 346 | 415 |  		return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); | 
| 347 | 416 | } | 
| 348 | 417 | |
| @@ -351,7 +420,8 @@ discard block | ||
| 351 | 420 | * | 
| 352 | 421 | * @return string suffix (comma seperated) | 
| 353 | 422 | */ | 
| 354 | -	public static function get_filesuffix() { | |
| 423 | + public static function get_filesuffix() | |
| 424 | +	{ | |
| 355 | 425 | return 'csv'; | 
| 356 | 426 | } | 
| 357 | 427 | |
| @@ -367,7 +437,8 @@ discard block | ||
| 367 | 437 | * preserv => array, | 
| 368 | 438 | * ) | 
| 369 | 439 | */ | 
| 370 | -	public function get_options_etpl() { | |
| 440 | + public function get_options_etpl() | |
| 441 | +	{ | |
| 371 | 442 | // lets do it! | 
| 372 | 443 | } | 
| 373 | 444 | |
| @@ -376,7 +447,8 @@ discard block | ||
| 376 | 447 | * | 
| 377 | 448 | * @return string etemplate name | 
| 378 | 449 | */ | 
| 379 | -	public function get_selectors_etpl() { | |
| 450 | + public function get_selectors_etpl() | |
| 451 | +	{ | |
| 380 | 452 | // lets do it! | 
| 381 | 453 | } | 
| 382 | 454 | |
| @@ -388,7 +460,8 @@ discard block | ||
| 388 | 460 | * record_# => warning message | 
| 389 | 461 | * ) | 
| 390 | 462 | */ | 
| 391 | -        public function get_warnings() { | |
| 463 | + public function get_warnings() | |
| 464 | +        { | |
| 392 | 465 | return $this->warnings; | 
| 393 | 466 | } | 
| 394 | 467 | |
| @@ -400,7 +473,8 @@ discard block | ||
| 400 | 473 | * record_# => error message | 
| 401 | 474 | * ) | 
| 402 | 475 | */ | 
| 403 | -        public function get_errors() { | |
| 476 | + public function get_errors() | |
| 477 | +        { | |
| 404 | 478 | return $this->errors; | 
| 405 | 479 | } | 
| 406 | 480 | |
| @@ -412,7 +486,8 @@ discard block | ||
| 412 | 486 | * action => record count | 
| 413 | 487 | * ) | 
| 414 | 488 | */ | 
| 415 | -        public function get_results() { | |
| 489 | + public function get_results() | |
| 490 | +        { | |
| 416 | 491 | return $this->results; | 
| 417 | 492 | } | 
| 418 | 493 | } | 
| @@ -83,8 +83,7 @@ | ||
| 83 | 83 | /** | 
| 84 | 84 | * imports entries according to given definition object. | 
| 85 | 85 | * @param resource $_stream | 
| 86 | - * @param string $_charset | |
| 87 | - * @param definition $_definition | |
| 86 | + * @param importexport_definition $_definition | |
| 88 | 87 | */ | 
| 89 | 88 |  	public function import( $_stream, importexport_definition $_definition ) { | 
| 90 | 89 | $this->definition = $_definition; | 
| @@ -15,7 +15,8 @@ discard block | ||
| 15 | 15 | /** | 
| 16 | 16 | * Plugin to import vCard files | 
| 17 | 17 | */ | 
| 18 | -class addressbook_import_vcard implements importexport_iface_import_plugin  { | |
| 18 | +class addressbook_import_vcard implements importexport_iface_import_plugin | |
| 19 | +{ | |
| 19 | 20 | |
| 20 | 21 | private static $plugin_options = array( | 
| 21 | 22 | |
| @@ -86,7 +87,8 @@ discard block | ||
| 86 | 87 | * @param string $_charset | 
| 87 | 88 | * @param definition $_definition | 
| 88 | 89 | */ | 
| 89 | -	public function import( $_stream, importexport_definition $_definition ) { | |
| 90 | + public function import( $_stream, importexport_definition $_definition ) | |
| 91 | +	{ | |
| 90 | 92 | $this->definition = $_definition; | 
| 91 | 93 | |
| 92 | 94 | // user, is admin ? | 
| @@ -112,7 +114,10 @@ discard block | ||
| 112 | 114 | $this->bocontacts = new addressbook_vcal(); | 
| 113 | 115 | |
| 114 | 116 | $charset = $_definition->plugin_options['charset']; | 
| 115 | - if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; | |
| 117 | + if($charset == 'user') | |
| 118 | +		{ | |
| 119 | + $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; | |
| 120 | + } | |
| 116 | 121 | |
| 117 | 122 | // Start counting successes | 
| 118 | 123 | $this->current = 0; | 
| @@ -130,7 +135,8 @@ discard block | ||
| 130 | 135 | $contact_owner | 
| 131 | 136 | )); | 
| 132 | 137 | $contacts->next(); | 
| 133 | -		while($contacts->valid()) { | |
| 138 | + while($contacts->valid()) | |
| 139 | +		{ | |
| 134 | 140 | $this->current++; | 
| 135 | 141 | $contact = $contacts->current(); | 
| 136 | 142 | |
| @@ -142,7 +148,10 @@ discard block | ||
| 142 | 148 | $egw_record = new addressbook_egw_record(); | 
| 143 | 149 | $egw_record->set_record($contact); | 
| 144 | 150 | $this->preview_records[] = $egw_record; | 
| 145 | - if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) break; | |
| 151 | + if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) | |
| 152 | +				{ | |
| 153 | + break; | |
| 154 | + } | |
| 146 | 155 | } | 
| 147 | 156 | |
| 148 | 157 | $count++; | 
| @@ -158,7 +167,10 @@ discard block | ||
| 158 | 167 | public function _vcard($_vcard, $owner) | 
| 159 | 168 |  	{ | 
| 160 | 169 | $charset = $this->definition->plugin_options['charset']; | 
| 161 | - if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; | |
| 170 | + if($charset == 'user') | |
| 171 | +		{ | |
| 172 | + $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; | |
| 173 | + } | |
| 162 | 174 | $record = $this->bocontacts->vcardtoegw($_vcard,$charset); | 
| 163 | 175 | |
| 164 | 176 | $record['owner'] = $owner; | 
| @@ -194,8 +206,10 @@ discard block | ||
| 194 | 206 | * @param array $_data contact data for the action | 
| 195 | 207 | * @return bool success or not | 
| 196 | 208 | */ | 
| 197 | -	private function action ( $_action, $_data, $record_num = 0 ) { | |
| 198 | -		switch ($_action) { | |
| 209 | + private function action ( $_action, $_data, $record_num = 0 ) | |
| 210 | +	{ | |
| 211 | + switch ($_action) | |
| 212 | +		{ | |
| 199 | 213 | case 'none' : | 
| 200 | 214 | return true; | 
| 201 | 215 | case 'update' : | 
| @@ -210,9 +224,12 @@ discard block | ||
| 210 | 224 | } | 
| 211 | 225 | } | 
| 212 | 226 | // Don't change a user account into a contact | 
| 213 | -				if($old['owner'] == 0) { | |
| 227 | + if($old['owner'] == 0) | |
| 228 | +				{ | |
| 214 | 229 | unset($_data['owner']); | 
| 215 | -				} elseif(!$this->definition->plugin_options['change_owner']) { | |
| 230 | + } | |
| 231 | + elseif(!$this->definition->plugin_options['change_owner']) | |
| 232 | +				{ | |
| 216 | 233 | // Don't change addressbook of an existing contact | 
| 217 | 234 | unset($_data['owner']); | 
| 218 | 235 | } | 
| @@ -220,9 +237,12 @@ discard block | ||
| 220 | 237 | // Merge to deal with fields not in import record | 
| 221 | 238 | $_data = array_merge($old, $_data); | 
| 222 | 239 | $changed = $this->tracking->changed_fields($_data, $old); | 
| 223 | -				if(count($changed) == 0) { | |
| 240 | + if(count($changed) == 0) | |
| 241 | +				{ | |
| 224 | 242 | return true; | 
| 225 | -				} else { | |
| 243 | + } | |
| 244 | + else | |
| 245 | +				{ | |
| 226 | 246 |  					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); | 
| 227 | 247 | } | 
| 228 | 248 | |
| @@ -231,24 +251,32 @@ discard block | ||
| 231 | 251 | |
| 232 | 252 | // Fall through | 
| 233 | 253 | case 'insert' : | 
| 234 | -				if($_action == 'insert') { | |
| 254 | + if($_action == 'insert') | |
| 255 | +				{ | |
| 235 | 256 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag | 
| 236 | 257 | unset($_data['id']); | 
| 237 | 258 | } | 
| 238 | -				if(!isset($_data['org_name'])) { | |
| 259 | + if(!isset($_data['org_name'])) | |
| 260 | +				{ | |
| 239 | 261 | // org_name is a trigger to update n_fileas | 
| 240 | 262 | $_data['org_name'] = ''; | 
| 241 | 263 | } | 
| 242 | 264 | |
| 243 | -				if ( $this->dry_run ) { | |
| 265 | + if ( $this->dry_run ) | |
| 266 | +				{ | |
| 244 | 267 | //print_r($_data); | 
| 245 | 268 | $this->results[$_action]++; | 
| 246 | 269 | return true; | 
| 247 | -				} else { | |
| 270 | + } | |
| 271 | + else | |
| 272 | +				{ | |
| 248 | 273 | $result = $this->bocontacts->save( $_data, $this->is_admin); | 
| 249 | -					if(!$result) { | |
| 274 | + if(!$result) | |
| 275 | +					{ | |
| 250 | 276 | $this->errors[$record_num] = $this->bocontacts->error; | 
| 251 | -					} else { | |
| 277 | + } | |
| 278 | + else | |
| 279 | +					{ | |
| 252 | 280 | $this->results[$_action]++; | 
| 253 | 281 | } | 
| 254 | 282 | return $result; | 
| @@ -302,7 +330,8 @@ discard block | ||
| 302 | 330 | * | 
| 303 | 331 | * @return string name | 
| 304 | 332 | */ | 
| 305 | -	public static function get_name() { | |
| 333 | + public static function get_name() | |
| 334 | +	{ | |
| 306 | 335 |  		return lang('Addressbook vCard import'); | 
| 307 | 336 | } | 
| 308 | 337 | |
| @@ -311,7 +340,8 @@ discard block | ||
| 311 | 340 | * | 
| 312 | 341 | * @return string descriprion | 
| 313 | 342 | */ | 
| 314 | -	public static function get_description() { | |
| 343 | + public static function get_description() | |
| 344 | +	{ | |
| 315 | 345 |  		return lang("Imports contacts into your Addressbook from a vCard File. "); | 
| 316 | 346 | } | 
| 317 | 347 | |
| @@ -320,7 +350,8 @@ discard block | ||
| 320 | 350 | * | 
| 321 | 351 | * @return string suffix (comma seperated) | 
| 322 | 352 | */ | 
| 323 | -	public static function get_filesuffix() { | |
| 353 | + public static function get_filesuffix() | |
| 354 | +	{ | |
| 324 | 355 | return 'vcf'; | 
| 325 | 356 | } | 
| 326 | 357 | |
| @@ -336,7 +367,8 @@ discard block | ||
| 336 | 367 | * preserv => array, | 
| 337 | 368 | * ) | 
| 338 | 369 | */ | 
| 339 | -	public function get_options_etpl() { | |
| 370 | + public function get_options_etpl() | |
| 371 | +	{ | |
| 340 | 372 | // lets do it! | 
| 341 | 373 | } | 
| 342 | 374 | |
| @@ -345,7 +377,8 @@ discard block | ||
| 345 | 377 | * | 
| 346 | 378 | * @return string etemplate name | 
| 347 | 379 | */ | 
| 348 | -	public function get_selectors_etpl() { | |
| 380 | + public function get_selectors_etpl() | |
| 381 | +	{ | |
| 349 | 382 | // lets do it! | 
| 350 | 383 | } | 
| 351 | 384 | |
| @@ -357,7 +390,8 @@ discard block | ||
| 357 | 390 | * record_# => warning message | 
| 358 | 391 | * ) | 
| 359 | 392 | */ | 
| 360 | -        public function get_warnings() { | |
| 393 | + public function get_warnings() | |
| 394 | +        { | |
| 361 | 395 | return $this->warnings; | 
| 362 | 396 | } | 
| 363 | 397 | |
| @@ -369,7 +403,8 @@ discard block | ||
| 369 | 403 | * record_# => error message | 
| 370 | 404 | * ) | 
| 371 | 405 | */ | 
| 372 | -        public function get_errors() { | |
| 406 | + public function get_errors() | |
| 407 | +        { | |
| 373 | 408 | return $this->errors; | 
| 374 | 409 | } | 
| 375 | 410 | |
| @@ -381,7 +416,8 @@ discard block | ||
| 381 | 416 | * action => record count | 
| 382 | 417 | * ) | 
| 383 | 418 | */ | 
| 384 | -        public function get_results() { | |
| 419 | + public function get_results() | |
| 420 | +        { | |
| 385 | 421 | return $this->results; | 
| 386 | 422 | } | 
| 387 | 423 | } | 
| @@ -532,7 +532,6 @@ | ||
| 532 | 532 | /** | 
| 533 | 533 | * Read the IMAP ACLs | 
| 534 | 534 | * | 
| 535 | - * @param array $args admin-account[@domain],admin-password,accout_lid[,pw] | |
| 536 | 535 | * @return int 0 on success | 
| 537 | 536 | */ | 
| 538 | 537 | function do_subscribe_other($account_lid,$pw=null) | 
| @@ -17,10 +17,13 @@ discard block | ||
| 17 | 17 | |
| 18 | 18 | chdir(dirname(__FILE__)); // to enable our relative pathes to work | 
| 19 | 19 | |
| 20 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling admin-cli as web-page | |
| 20 | +if (php_sapi_name() !== 'cli') | |
| 21 | +{ | |
| 22 | + // security precaution: forbit calling admin-cli as web-page | |
| 21 | 23 |  { | 
| 22 | 24 |  	die('<h1>admin-cli.php must NOT be called as web-page --> exiting !!!</h1>'); | 
| 23 | 25 | } | 
| 26 | +} | |
| 24 | 27 |  elseif ($_SERVER['argc'] <= 1 || $_SERVER['argc'] == 2 && in_array($_SERVER['argv'][1], array('-h', '--help'))) | 
| 25 | 28 |  { | 
| 26 | 29 | usage(); | 
| @@ -92,13 +95,19 @@ discard block | ||
| 92 | 95 | foreach($arg0s as $arg) | 
| 93 | 96 |  			{ | 
| 94 | 97 |  				list($name,$value) = explode('=',$arg,2); | 
| 95 | -				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties | |
| 98 | +				if(property_exists('admin_cmd',$name)) | |
| 99 | +				{ | |
| 100 | + // dont allow to overwrite admin_cmd properties | |
| 96 | 101 |  				{ | 
| 97 | 102 |  					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90); | 
| 98 | 103 | } | 
| 99 | - if (substr($name,-1) == ']') // allow 1-dim. arrays | |
| 104 | + } | |
| 105 | + if (substr($name,-1) == ']') | |
| 106 | +				{ | |
| 107 | + // allow 1-dim. arrays | |
| 100 | 108 |  				{ | 
| 101 | 109 |  					list($name,$sub) = explode('[',substr($name,0,-1),2); | 
| 110 | + } | |
| 102 | 111 | $args[$name][$sub] = $value; | 
| 103 | 112 | } | 
| 104 | 113 | else | 
| @@ -183,7 +192,10 @@ discard block | ||
| 183 | 192 | if (!$dry_run) | 
| 184 | 193 |  		{ | 
| 185 | 194 | $url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache'; | 
| 186 | - if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; | |
| 195 | + if ($url[0] == '/') | |
| 196 | +			{ | |
| 197 | + $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; | |
| 198 | + } | |
| 187 | 199 | $data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1])); | 
| 188 | 200 |  			error_log("file_get_contents('$url') returned ".array2string($data)); | 
| 189 | 201 | if ($data && strpos($data, '"success"') !== false) | 
| @@ -225,10 +237,13 @@ discard block | ||
| 225 | 237 |  		echo lang("Wrong admin-account or -password !!!")."\n\n"; | 
| 226 | 238 |  		usage('',1); | 
| 227 | 239 | } | 
| 228 | - if (!$GLOBALS['egw_info']['user']['apps']['admin']) // will be tested by the header too, but whould give html error-message | |
| 240 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) | |
| 241 | +	{ | |
| 242 | + // will be tested by the header too, but whould give html error-message | |
| 229 | 243 |  	{ | 
| 230 | 244 |  		//fail(2,lang("Permission denied !!!")); | 
| 231 | 245 |  		echo lang("Permission denied !!!")."\n\n"; | 
| 246 | + } | |
| 232 | 247 |  		usage('',2); | 
| 233 | 248 | } | 
| 234 | 249 | return $sessionid; | 
| @@ -377,7 +392,11 @@ discard block | ||
| 377 | 392 | foreach($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : | 
| 378 | 393 | Api\Mail\Account::search($account_id, false) as $account) | 
| 379 | 394 |  	{ | 
| 380 | - if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts | |
| 395 | + if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) | |
| 396 | +		{ | |
| 397 | + continue; | |
| 398 | + } | |
| 399 | + // no need to waste time on personal accounts | |
| 381 | 400 | |
| 382 | 401 | $args = $arg0s; | 
| 383 | 402 |  		try { | 
| @@ -430,7 +449,10 @@ discard block | ||
| 430 | 449 | $identity['account_id'] = $account_id; // make this a personal identity for $account_id | 
| 431 | 450 | Api\Mail\Account::save_identity($identity); | 
| 432 | 451 | } | 
| 433 | -				if ($args) echo "Identity(s) for ".implode(', ', $args)." created.\n"; | |
| 452 | + if ($args) | |
| 453 | +				{ | |
| 454 | +					echo "Identity(s) for ".implode(', ', $args)." created.\n"; | |
| 455 | + } | |
| 434 | 456 | } | 
| 435 | 457 | } | 
| 436 | 458 |  		catch(\Exception $e) { | 
| @@ -456,7 +478,10 @@ discard block | ||
| 456 | 478 | */ | 
| 457 | 479 | function array_modify(&$arr, array &$mod) | 
| 458 | 480 |  { | 
| 459 | - if (!is_array($arr)) $arr = array(); | |
| 481 | + if (!is_array($arr)) | |
| 482 | +	{ | |
| 483 | + $arr = array(); | |
| 484 | + } | |
| 460 | 485 | |
| 461 | 486 | switch($mod[0][0]) | 
| 462 | 487 |  	{ | 
| @@ -512,10 +537,13 @@ discard block | ||
| 512 | 537 |  	try { | 
| 513 | 538 | admin_cmd::parse_account($account,false); | 
| 514 | 539 | |
| 515 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! | |
| 540 | + foreach($data as &$value) | |
| 541 | +		{ | |
| 542 | + // existing account --> empty values mean dont change, not set them empty! | |
| 516 | 543 |  		{ | 
| 517 | 544 | if ((string)$value === '') $value = null; | 
| 518 | 545 | } | 
| 546 | + } | |
| 519 | 547 | } | 
| 520 | 548 |  	catch (Exception $e) {	// new group | 
| 521 | 549 | unset($e); // not used | 
| @@ -557,9 +585,12 @@ discard block | ||
| 557 | 585 | if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' || | 
| 558 | 586 | empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') && | 
| 559 | 587 | $GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group | 
| 560 | - ($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/') // last argument start with a slash | |
| 588 | + ($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/') | |
| 589 | +	{ | |
| 590 | + // last argument start with a slash | |
| 561 | 591 |  	{ | 
| 562 | 592 | $data['loginshell'] = array_pop($args); | 
| 593 | + } | |
| 563 | 594 | $data['homedirectory'] = array_pop($args); | 
| 564 | 595 | } | 
| 565 | 596 | $data += array( | 
| @@ -577,10 +608,13 @@ discard block | ||
| 577 | 608 |  	try { | 
| 578 | 609 | admin_cmd::parse_account($account,true); | 
| 579 | 610 | |
| 580 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! | |
| 611 | + foreach($data as &$value) | |
| 612 | +		{ | |
| 613 | + // existing account --> empty values mean dont change, not set them empty! | |
| 581 | 614 |  		{ | 
| 582 | 615 | if ((string)$value === '') $value = null; | 
| 583 | 616 | } | 
| 617 | + } | |
| 584 | 618 | } | 
| 585 | 619 |  	catch (Exception $e) {	// new account | 
| 586 | 620 | unset($e); // not used | 
| @@ -621,7 +655,11 @@ discard block | ||
| 621 | 655 | */ | 
| 622 | 656 | function do_change_account_id($args) | 
| 623 | 657 |  { | 
| 624 | - if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1 | |
| 658 | + if (count($args) < 4) | |
| 659 | +	{ | |
| 660 | + usage(); | |
| 661 | + } | |
| 662 | + // 4 means at least user,pw,from1,to1 | |
| 625 | 663 | |
| 626 | 664 | $ids2change = array(); | 
| 627 | 665 | for($n = 2; $n < count($args); $n += 2) | 
| @@ -255,11 +255,10 @@ | ||
| 255 | 255 | * | 
| 256 | 256 | * @param type $action | 
| 257 | 257 | * @param type $checked | 
| 258 | - * @param type $use_all | |
| 259 | 258 | * @param type $success | 
| 260 | 259 | * @param int $failed | 
| 261 | 260 | * @param type $action_msg | 
| 262 | - * @return type number of failed | |
| 261 | + * @return boolean number of failed | |
| 263 | 262 | */ | 
| 264 | 263 | function action($action,$checked,&$success,&$failed,&$action_msg) | 
| 265 | 264 |  	{ | 
| @@ -67,9 +67,13 @@ discard block | ||
| 67 | 67 |  	{ | 
| 68 | 68 | $heartbeat_limit = Api\Session::heartbeat_limit(); | 
| 69 | 69 | |
| 70 | - if ($query['session_list']) // filter active sessions | |
| 70 | + if ($query['session_list']) | |
| 71 | +		{ | |
| 72 | + // filter active sessions | |
| 71 | 73 |  		{ | 
| 72 | - $query['col_filter']['lo'] = null; // not logged out | |
| 74 | + $query['col_filter']['lo'] = null; | |
| 75 | + } | |
| 76 | + // not logged out | |
| 73 | 77 | $query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']); | 
| 74 | 78 | switch((string)$query['session_list']) | 
| 75 | 79 |  			{ | 
| @@ -100,12 +104,16 @@ discard block | ||
| 100 | 104 |  			{ | 
| 101 | 105 | $row['sessionstatus'] = $row['session_php']; | 
| 102 | 106 | } | 
| 103 | -			if ($row['lo']) { | |
| 107 | + if ($row['lo']) | |
| 108 | +			{ | |
| 104 | 109 | $row['total'] = ($row['lo'] - $row['li']) / 60; | 
| 105 | 110 | $row['sessionstatus'] = 'logged out'; | 
| 106 | 111 | } | 
| 107 | 112 | // eg. for bad login or password | 
| 108 | -			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); | |
| 113 | + if (!$row['account_id']) | |
| 114 | +			{ | |
| 115 | +				$row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); | |
| 116 | + } | |
| 109 | 117 | |
| 110 | 118 | // do not allow to kill or select own session | 
| 111 | 119 | if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list']) | 
| @@ -142,7 +150,10 @@ discard block | ||
| 142 | 150 | function index(array $content=null, $msg='', $sessions_list=false) | 
| 143 | 151 |  	{ | 
| 144 | 152 | |
| 145 | - if (is_array($content)) $sessions_list = $content['nm']['session_list']; | |
| 153 | + if (is_array($content)) | |
| 154 | +		{ | |
| 155 | + $sessions_list = $content['nm']['session_list']; | |
| 156 | + } | |
| 146 | 157 | |
| 147 | 158 | // check if user has access to requested functionality | 
| 148 | 159 | if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin')) | 
| @@ -215,7 +226,8 @@ discard block | ||
| 215 | 226 | $success = $failed = $action = $action_msg = null; | 
| 216 | 227 | if ($this->action($content['nm']['action'],$content['nm']['selected'] | 
| 217 | 228 | ,$success,$failed,$action_msg,$msg)) | 
| 218 | -				{ // In case of action success | |
| 229 | +				{ | |
| 230 | +// In case of action success | |
| 219 | 231 | switch ($action_msg) | 
| 220 | 232 |  					{ | 
| 221 | 233 | case'deleted': | 
| @@ -225,12 +237,15 @@ discard block | ||
| 225 | 237 |  							$msg = lang('%1 sessions killed',$success); | 
| 226 | 238 | } | 
| 227 | 239 | } | 
| 228 | - elseif($failed) // In case of action failiure | |
| 240 | + elseif($failed) | |
| 241 | +				{ | |
| 242 | + // In case of action failiure | |
| 229 | 243 |  				{ | 
| 230 | 244 | switch ($action_msg) | 
| 231 | 245 |  					{ | 
| 232 | 246 | case'deleted': | 
| 233 | 247 |  							$msg = lang('Error deleting log entry!'); | 
| 248 | + } | |
| 234 | 249 | break; | 
| 235 | 250 | case'killed': | 
| 236 | 251 |  							$msg = lang('Permission denied!'); | 
| @@ -679,6 +679,8 @@ | ||
| 679 | 679 | * @param int &$failed number of failed actions (not enought permissions) | 
| 680 | 680 | * @param string &$action_msg translated verb for the actions, to be used in a message like '%1 entries deleted' | 
| 681 | 681 | * @param array $query get_rows parameter | 
| 682 | + * @param integer $success | |
| 683 | + * @param integer $failed | |
| 682 | 684 | * @return boolean true if all actions succeded, false otherwise | 
| 683 | 685 | */ | 
| 684 | 686 | function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg, array $query) | 
| @@ -150,8 +150,14 @@ discard block | ||
| 150 | 150 |  			{ | 
| 151 | 151 | case 'save': | 
| 152 | 152 | case 'apply': | 
| 153 | -					if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']); | |
| 154 | - if($content['owner'] == '') $content['owner'] = 0; | |
| 153 | + if(is_array($content['owner'])) | |
| 154 | +					{ | |
| 155 | +						$content['owner'] = implode(',',$content['owner']); | |
| 156 | + } | |
| 157 | + if($content['owner'] == '') | |
| 158 | +					{ | |
| 159 | + $content['owner'] = 0; | |
| 160 | + } | |
| 155 | 161 | if ($content['id'] && self::$acl_edit) | 
| 156 | 162 |  					{ | 
| 157 | 163 | |
| @@ -247,7 +253,10 @@ discard block | ||
| 247 | 253 | Framework::refresh_opener($msg, $this->appname, $content['id'], $change_color ? null : 'update', $refresh_app); | 
| 248 | 254 | } | 
| 249 | 255 | $content['msg'] = $msg; | 
| 250 | - if(!$content['appname']) $content['appname'] = $appname; | |
| 256 | + if(!$content['appname']) | |
| 257 | +		{ | |
| 258 | + $content['appname'] = $appname; | |
| 259 | + } | |
| 251 | 260 | if($content['data']['icon']) | 
| 252 | 261 |  		{ | 
| 253 | 262 | $content['icon_url'] = $content['base_url'] . $content['data']['icon']; | 
| @@ -302,7 +311,9 @@ discard block | ||
| 302 | 311 | // Allow admins access to all categories as parent | 
| 303 | 312 | $content['all_cats'] = 'all_no_acl'; | 
| 304 | 313 | $readonlys['owner'] = false; | 
| 305 | -		} else { | |
| 314 | + } | |
| 315 | + else | |
| 316 | +		{ | |
| 306 | 317 | $readonlys['owner'] = true; | 
| 307 | 318 | $readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id']; | 
| 308 | 319 | } | 
| @@ -313,7 +324,10 @@ discard block | ||
| 313 | 324 | $appname != $content['appname'] || // Can't edit a category from a different app | 
| 314 | 325 | ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']); | 
| 315 | 326 | // Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox | 
| 316 | -		if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']); | |
| 327 | + if (!is_array($content['owner'])) | |
| 328 | +		{ | |
| 329 | +			$content['owner'] = explode(',',$content['owner']); | |
| 330 | + } | |
| 317 | 331 |  		$tmpl = new Etemplate('admin.categories.edit'); | 
| 318 | 332 | $tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array( | 
| 319 | 333 | 'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname | 
| @@ -373,9 +387,15 @@ discard block | ||
| 373 | 387 |  		{ | 
| 374 | 388 | $globalcat = false; | 
| 375 | 389 | } | 
| 376 | - if ($globalcat && $query['filter']) $filter['access'] = 'public'; | |
| 390 | + if ($globalcat && $query['filter']) | |
| 391 | +		{ | |
| 392 | + $filter['access'] = 'public'; | |
| 393 | + } | |
| 377 | 394 | // new column-filter access has highest priority | 
| 378 | - if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access']; | |
| 395 | + if (!empty($query['col_filter']['access'])) | |
| 396 | +		{ | |
| 397 | + $filter['access'] = $query['col_filter']['access']; | |
| 398 | + } | |
| 379 | 399 | |
| 380 | 400 | Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query); | 
| 381 | 401 | |
| @@ -404,7 +424,10 @@ discard block | ||
| 404 | 424 | |
| 405 | 425 |  			$row['level_spacer'] = str_repeat('    ',$row['level']); | 
| 406 | 426 | |
| 407 | - if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']); | |
| 427 | + if ($row['data']['icon']) | |
| 428 | +			{ | |
| 429 | + $row['icon_url'] = self::icon_url($row['data']['icon']); | |
| 430 | + } | |
| 408 | 431 | |
| 409 | 432 | $row['subs'] = count($row['children']); | 
| 410 | 433 | |
| @@ -435,13 +458,19 @@ discard block | ||
| 435 | 458 | $readonlys['nm']["add[$row[id]]"] = !self::$acl_add_sub; | 
| 436 | 459 | $readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete; | 
| 437 | 460 | } | 
| 438 | - if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); | |
| 461 | + if (true) | |
| 462 | +		{ | |
| 463 | + $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); | |
| 464 | + } | |
| 439 | 465 | // make appname available for actions | 
| 440 | 466 | $rows['appname'] = $query['appname']; | 
| 441 | 467 | $rows['edit_link'] = $this->edit_link; | 
| 442 | 468 | |
| 443 | 469 | // disable access column for global Categories | 
| 444 | - if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true; | |
| 470 | + if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') | |
| 471 | +		{ | |
| 472 | + $rows['no_access'] = true; | |
| 473 | + } | |
| 445 | 474 | |
| 446 | 475 |  		$GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories'). | 
| 447 | 476 | ($query['appname'] != Categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : ''); | 
| @@ -458,11 +487,18 @@ discard block | ||
| 458 | 487 | public function index(array $content=null,$msg='') | 
| 459 | 488 |  	{ | 
| 460 | 489 | //_debug_array($_GET); | 
| 461 | -		if ($this->appname != 'admin') Api\Translation::add_app('admin');	// need admin translations | |
| 490 | + if ($this->appname != 'admin') | |
| 491 | +		{ | |
| 492 | +			Api\Translation::add_app('admin'); | |
| 493 | + } | |
| 494 | + // need admin translations | |
| 462 | 495 | |
| 463 | 496 | if(!isset($content)) | 
| 464 | 497 |  		{ | 
| 465 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; | |
| 498 | + if (isset($_GET['msg'])) | |
| 499 | +			{ | |
| 500 | + $msg = $_GET['msg']; | |
| 501 | + } | |
| 466 | 502 | |
| 467 | 503 | $appname = Categories::GLOBAL_APPNAME; | 
| 468 | 504 | foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) | 
| @@ -602,7 +638,8 @@ discard block | ||
| 602 | 638 | $readonlys['nm']['rows']['owner'] = true; | 
| 603 | 639 | $readonlys['nm']['col_filter']['owner'] = true; | 
| 604 | 640 | } | 
| 605 | -		if($appname == Categories::GLOBAL_APPNAME) { | |
| 641 | + if($appname == Categories::GLOBAL_APPNAME) | |
| 642 | +		{ | |
| 606 | 643 |  			$sel_options['app'] = array(''=>''); | 
| 607 | 644 | $readonlys['nm']['rows']['app'] = true; | 
| 608 | 645 | } | 
| @@ -620,7 +657,8 @@ discard block | ||
| 620 | 657 | )); | 
| 621 | 658 | } | 
| 622 | 659 | |
| 623 | -	protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) { | |
| 660 | + protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) | |
| 661 | +	{ | |
| 624 | 662 | |
| 625 | 663 | $actions = array( | 
| 626 | 664 | 'open' => array( // does edit if allowed, otherwise view | 
| @@ -731,11 +769,17 @@ discard block | ||
| 731 | 769 |  				list($add_remove, $ids_csv) = explode('_', $settings, 2); | 
| 732 | 770 |  				$ids = explode(',', $ids_csv); | 
| 733 | 771 | // Adding 'All users' removes all the others | 
| 734 | - if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT); | |
| 772 | + if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) | |
| 773 | +				{ | |
| 774 | + $ids = array(Categories::GLOBAL_ACCOUNT); | |
| 775 | + } | |
| 735 | 776 | |
| 736 | 777 | foreach($checked as $id) | 
| 737 | 778 |  				{ | 
| 738 | - if (!$data = $cats->read($id)) continue; | |
| 779 | + if (!$data = $cats->read($id)) | |
| 780 | +					{ | |
| 781 | + continue; | |
| 782 | + } | |
| 739 | 783 |  					$data['owner'] = explode(',',$data['owner']); | 
| 740 | 784 | if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0) | 
| 741 | 785 |  					{ | 
| @@ -775,7 +819,10 @@ discard block | ||
| 775 | 819 | continue; | 
| 776 | 820 | } | 
| 777 | 821 | // Skip apps that don't show in the app bar, they [usually] don't have Categories | 
| 778 | -			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue; | |
| 822 | +			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) | |
| 823 | +			{ | |
| 824 | + continue; | |
| 825 | + } | |
| 779 | 826 | if ($GLOBALS['egw_info']['user']['apps'][$app]) | 
| 780 | 827 |  			{ | 
| 781 | 828 | $apps[$app] = $data['title'] ? $data['title'] : lang($app); |