fixed not working export of huge number of contacts (memory and execution time limit reached) AND added a new configuration option to limit the maximum number of exported contacts for non admins

This commit is contained in:
Ralf Becker 2007-05-22 08:02:06 +00:00
parent 2c5582c15b
commit 452adb97ae
4 changed files with 22 additions and 2 deletions

View File

@ -41,6 +41,11 @@ class uicontacts extends bocontacts
var $private_addressbook = false;
var $org_views;
/**
* Addressbook configuration (stored as phpgwapi = general server config)
*
* @var array
*/
var $config;
/**
* Name(s) of the tabs in the edit dialog
@ -393,6 +398,7 @@ class uicontacts extends bocontacts
if ($use_all)
{
@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
$query['num_rows'] = -1; // all
$this->get_rows($query,$checked,$readonlys,true); // true = only return the id's
}
@ -424,6 +430,14 @@ class uicontacts extends bocontacts
$to_list = (int)substr($action,8);
$action = 'to_list';
}
// Security: stop non-admins to export more then the configured number of contacts
if (in_array($action,array('csv','vcard')) && (int)$this->config['contact_export_limit'] &&
!isset($GLOBALS['egw_info']['user']['apps']['admin']) && count($checked) > $this->config['contact_export_limit'])
{
$action_msg = lang('exported');
$failed = count($checked);
return false;
}
switch($action)
{
case 'csv':
@ -766,7 +780,7 @@ class uicontacts extends bocontacts
$wildcard = $query['advanced_search']['meth_select'];
unset($query['advanced_search']['meth_select']);
}
$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],false,
$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],$id_only,
$order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']);
// do we need the custom fields

View File

@ -167,6 +167,7 @@ home phone addressbook de Tel. privat
home state addressbook de Bundesland privat
home street addressbook de Straße privat
home zip code addressbook de PLZ privat
how many contacts should non-admins be able to export (empty = no limit) admin de Wieviele Kontakte sollen nicht-Adminstratoren exportieren können (leer = keine Begrenzung)
icon addressbook de Icon
if accounts are already in ldap admin de wenn die Benutzer bereits im LDAP sind
import addressbook de Import
@ -289,7 +290,7 @@ translation addressbook de
type addressbook de Typ
update a single entry by passing the fields. addressbook de Aktualisiert einen einzelnen Eintrag durch Übergabe seiner Felder.
upload or delete the photo addressbook de Foto hochladen oder löschen
url to link telephone numbers to (use %1 for the number) admin de URL mit denen Telefonnummern verlinkt werden sollen (%1 für die Nummber verwenden)
url to link telephone numbers to (use %1 for the number) admin de URL mit denen Telefonnummern verlinkt werden sollen (%1 als Platzhalter für die Nummer verwenden)
use an extra category tab? addressbook de Separaten Reiter für Kategorien verwenden?
use country list addressbook de Länderliste benutzen
use setup for a full account-migration admin de für eine komplette Benutzer Migration setup verwenden

View File

@ -167,6 +167,7 @@ home phone addressbook en Home Phone
home state addressbook en Home State
home street addressbook en Home Street
home zip code addressbook en Home ZIP Code
how many contacts should non-admins be able to export (empty = no limit) admin en How many contacts should non-admins be able to export (empty = no limit)
icon addressbook en Icon
if accounts are already in ldap admin en if accounts are already in LDAP
import addressbook en Import

View File

@ -46,6 +46,10 @@
</select>
</td>
</tr>
<tr class="row_off">
<td>&nbsp;<b>{lang_Security}</b>: {lang_How_many_contacts_should_non-admins_be_able_to_export_(empty_=_no_limit)}:</td>
<td><input name="newsettings[contact_export_limit]" value="{value_contact_export_limit}" size="5"></td>
</tr>
<tr class="th">
<td colspan="2">&nbsp;<b>{lang_Contact_repository}</b></td>
</tr>