summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 16dc9e5)
raw | patch | inline | side by side (parent: 16dc9e5)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jul 2010 09:34:45 +0000 (09:34 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jul 2010 09:34:45 +0000 (09:34 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19081 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/ldapmanager/addons/ldapmanager/class_import.inc | patch | blob | history |
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_import.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_import.inc
index 003f8028c26d7ff2a44799d22d15205272da751c..c8787ac522c8f8b8c4d9f94e79aa9c293da49d21 100644 (file)
class ldifimport extends plugin
{
- /* Definitions */
- var $plHeadline= "LDIF export";
- var $plDescription= "This does something";
- var $access= "";
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
- var $ui;
- var $view_logged = FALSE;
-
- function ldifimport (&$config, $dn= NULL)
- {
- /* Include config object */
- $this->config= &$config;
-
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","all/".get_class($this),$this->dn);
+ /* Definitions */
+ var $plHeadline= "LDIF export";
+ var $plDescription= "This does something";
+ var $access= "";
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+ var $ui;
+ var $view_logged = FALSE;
+
+ function ldifimport (&$config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= &$config;
+
+ $this->ui = get_userinfo();
}
- /* Set government mode */
- $smarty= get_smarty();
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
- // Get the LDAP link, to generate the Export
- $ldap = $this->config->get_ldap_link();
-
- $smarty->assign("LDIFError",FALSE);
- $smarty->assign("type",FALSE);
-
- /* Get acls */
- $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all");
-
- /* Import requested check file and acls */
- if((isset($_FILES['userfile']['name']))&&(isset($_POST['fileup']))){
-
- /* Check acls */
- if(!preg_match("/w/",$acl)){
- msg_dialog::display(_("Permission error"), _("You need full write access to the LDAP tree to import data!"), ERROR_DIALOG);
- }else{
-
- $smarty->assign("type","importfile");
- $handle = NULL;
-
- // Check if there is a file submitted
- if(!$_FILES['userfile']['size'] > 0 )
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
}
- // Is there a tmp file, which we can use ?
- elseif(!file_exists($_FILES['userfile']['tmp_name']))
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
-
- }
-
- // Can we open the tmp file, for reading
- elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r"))
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
- }
- else
- {
- // Everything just fine :)
- $str = "";
-
- // Reading content
- while(!feof($handle))
- {
- $str .= fread($handle,1024);
- }
- @fclose($handle);
-
- // Should we use Overwrite ?
- if(!empty($_POST['overwrite'])) $overwrite = true; else $overwrite = false;;
- if(!empty($_POST['cleanup'])) $cleanup = true; else $cleanup = false;
-
- $ErrorStr="";
- $check = $ldap->import_complete_ldif($str,$ErrorStr,$overwrite,$cleanup);
-
- if($check == INSERT_OK ){
- $smarty->assign("LDIFError",FALSE);
- } else {
- $smarty->assign("LDIFError",TRUE);
- }
-
- switch($check)
- {
- case INSERT_OK:
- break;
-
- case ALREADY_EXISTING_ENTRY:
- msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
- break;
-
- case UNKNOWN_TOKEN_IN_LDIF_FILE:
- msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
- break;
-
- default:
- msg_dialog::display(_("Internal error"), sprintf(_("Undefined flag %s!"), bold($check)), ERROR_DIALOG);
- break;
- }
+ /* Set government mode */
+ $smarty= get_smarty();
+
+ // Get the LDAP link, to generate the Export
+ $ldap = $this->config->get_ldap_link();
+
+ $smarty->assign("LDIFError",FALSE);
+ $smarty->assign("type",FALSE);
+
+ /* Get acls */
+ $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all");
+
+ /* Import requested check file and acls */
+ if((isset($_FILES['userfile']['name']))&&(isset($_POST['fileup']))){
+
+ /* Check acls */
+ if(!preg_match("/w/",$acl)){
+ msg_dialog::display(_("Permission error"), _("You need full write access to the LDAP tree to import data!"), ERROR_DIALOG);
+ }else{
+
+ $smarty->assign("type","importfile");
+ $handle = NULL;
+
+ // Check if there is a file submitted
+ if(!$_FILES['userfile']['size'] > 0 )
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+
+ // Is there a tmp file, which we can use ?
+ elseif(!file_exists($_FILES['userfile']['tmp_name']))
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+
+ }
+
+ // Can we open the tmp file, for reading
+ elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r"))
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+ else
+ {
+ // Everything just fine :)
+ $str = "";
+
+ // Reading content
+ while(!feof($handle))
+ {
+ $str .= fread($handle,1024);
+ }
+ @fclose($handle);
+
+ // Should we use Overwrite ?
+ if(!empty($_POST['overwrite'])) $overwrite = true; else $overwrite = false;;
+ if(!empty($_POST['cleanup'])) $cleanup = true; else $cleanup = false;
+
+ $ErrorStr="";
+ $check = $ldap->import_complete_ldif($str,$ErrorStr,$overwrite,$cleanup);
+
+ if($check == INSERT_OK ){
+ $smarty->assign("LDIFError",FALSE);
+ } else {
+ $smarty->assign("LDIFError",TRUE);
+ }
+
+ switch($check)
+ {
+ case INSERT_OK:
+ break;
+
+ case ALREADY_EXISTING_ENTRY:
+ msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
+ break;
+
+ case UNKNOWN_TOKEN_IN_LDIF_FILE:
+ msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
+ break;
+
+ default:
+ msg_dialog::display(_("Internal error"), sprintf(_("Undefined flag %s!"), bold($check)), ERROR_DIALOG);
+ break;
+ }
+ }
+ }
}
- }
+ return ($smarty->fetch (get_template_path('contentimport.tpl', TRUE)));
}
- return ($smarty->fetch (get_template_path('contentimport.tpl', TRUE)));
- }
}