当前位置: 首页>>代码示例>>PHP>>正文


PHP dol_copy函数代码示例

本文整理汇总了PHP中dol_copy函数的典型用法代码示例。如果您正苦于以下问题:PHP dol_copy函数的具体用法?PHP dol_copy怎么用?PHP dol_copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dol_copy函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  *		Function called when module is enabled.
  *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  *		It also creates data directories.
  *      @return     int             1 if OK, 0 if KO
  */
 function init()
 {
     global $db, $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $dirodt = DOL_DATA_ROOT . '/produit';
     dol_mkdir($dirodt);
     dol_copy(dol_buildpath('/pos/frontend/img/noimage.jpg', 0), $dirodt . '/noimage.jpg', 0, 0);
     if (empty($conf->global->POS_TICKET) && empty($conf->global->POS_FACTURE)) {
         dolibarr_set_const($db, "POS_FACTURE", '1', 'chaine', 0, '', $conf->entity);
     }
     if (empty($conf->global->POS_MAX_TTC)) {
         dolibarr_set_const($db, "POS_MAX_TTC", '100', 'chaine', 0, '', $conf->entity);
     }
     $sql = array();
     $result = $this->load_tables();
     return $this->_init($sql);
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:23,代码来源:modPos.class.php

示例2: createFromClone


//.........这里部分代码省略.........
     if ($result < 0) {
         $this->error = $clone_task->error;
         $error++;
     }
     // End
     if (!$error) {
         $clone_task_id = $clone_task->id;
         $clone_task_ref = $clone_task->ref;
         //Note Update
         if (!$clone_note) {
             $clone_task->note_private = '';
             $clone_task->note_public = '';
         } else {
             $this->db->begin();
             $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public');
             if ($res < 0) {
                 $this->error .= $clone_task->error;
                 $error++;
                 $this->db->rollback();
             } else {
                 $this->db->commit();
             }
             $this->db->begin();
             $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private');
             if ($res < 0) {
                 $this->error .= $clone_task->error;
                 $error++;
                 $this->db->rollback();
             } else {
                 $this->db->commit();
             }
         }
         //Duplicate file
         if ($clone_file) {
             require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
             //retreive project origin ref to know folder to copy
             $projectstatic = new Project($this->db);
             $projectstatic->fetch($ori_project_id);
             $ori_project_ref = $projectstatic->ref;
             if ($ori_project_id != $project_id) {
                 $projectstatic->fetch($project_id);
                 $clone_project_ref = $projectstatic->ref;
             } else {
                 $clone_project_ref = $ori_project_ref;
             }
             $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref) . "/" . dol_sanitizeFileName($clone_task_ref);
             $ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref) . "/" . dol_sanitizeFileName($fromid);
             $filearray = dol_dir_list($ori_task_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', '', SORT_ASC, 1);
             foreach ($filearray as $key => $file) {
                 if (!file_exists($clone_task_dir)) {
                     if (dol_mkdir($clone_task_dir) < 0) {
                         $this->error .= $langs->trans('ErrorInternalErrorDetected') . ':dol_mkdir';
                         $error++;
                     }
                 }
                 $rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'], 0, 1);
                 if (is_numeric($rescopy) && $rescopy < 0) {
                     $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name']);
                     $error++;
                 }
             }
         }
         // clone affectation
         if ($clone_affectation) {
             $origin_task = new Task($this->db);
             $origin_task->fetch($fromid);
             foreach (array('internal', 'external') as $source) {
                 $tab = $origin_task->liste_contact(-1, $source);
                 $num = count($tab);
                 $i = 0;
                 while ($i < $num) {
                     $clone_task->add_contact($tab[$i]['id'], $tab[$i]['code'], $tab[$i]['source']);
                     if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
                         $langs->load("errors");
                         $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
                         $error++;
                     } else {
                         if ($clone_task->error != '') {
                             $this->error .= $clone_task->error;
                             $error++;
                         }
                     }
                     $i++;
                 }
             }
         }
         if ($clone_time) {
             //TODO clone time of affectation
         }
     }
     unset($clone_task->context['createfromclone']);
     if (!$error) {
         $this->db->commit();
         return $clone_task_id;
     } else {
         $this->db->rollback();
         dol_syslog(get_class($this) . "::createFromClone nbError: " . $error . " error : " . $this->error, LOG_ERR);
         return -1;
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:task.class.php

示例3: init

 /**
  *		Function called when module is enabled.
  *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  *		It also creates data directories
  *
  *      @param      string	$options    Options when enabling module ('', 'noboxes')
  *      @return     int             	1 if OK, 0 if KO
  */
 function init($options = '')
 {
     global $conf, $langs;
     // Permissions
     $this->remove($options);
     //ODT template
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $dirodt = DOL_DATA_ROOT . '/doctemplates/orders';
     dol_mkdir($dirodt);
     $src = DOL_DOCUMENT_ROOT . '/install/doctemplates/orders/template_order.odt';
     $dest = $dirodt . '/template_order.odt';
     $result = dol_copy($src, $dest, 0, 0);
     if ($result < 0) {
         $langs->load("errors");
         $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
         return 0;
     }
     $sql = array("DELETE FROM " . MAIN_DB_PREFIX . "document_model WHERE nom = '" . $this->const[0][2] . "' AND entity = " . $conf->entity, "INSERT INTO " . MAIN_DB_PREFIX . "document_model (nom, type, entity) VALUES('" . $this->const[0][2] . "','order'," . $conf->entity . ")");
     return $this->_init($sql, $options);
 }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:28,代码来源:modCommande.class.php

示例4:

						$existt=dol_is_file($filetarget);
						if (! $existt)
						{
							dol_mkdir($dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos');

							print "  &nbsp; &nbsp; &nbsp; -> Copy file ".$filetotest." -> ".$filetarget."<br>\n";
							dol_copy($filetotest, $filetarget, '', 0);
						}

						$existtt=dol_is_file($filetargetsmall);
						if (! $existtt)
						{
							dol_mkdir($dolibarr_main_data_root.'/societe/'.$obj->rowid.'/logos/thumbs');

							print "  &nbsp; &nbsp; &nbsp; -> Copy file ".$filetotestsmall." -> ".$filetargetsmall."<br>\n";
							dol_copy($filetotestsmall, $filetargetsmall, '', 0);
						}
					}
				}

				$i++;
			}
		}
		else
		{
			$ok=0;
			dol_print_error($db);
		}
	//}
}
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:30,代码来源:repair.php

示例5: init

 /**
  *		Function called when module is enabled.
  *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
  *		It also creates data directories
  *
  *      @param      string	$options    Options when enabling module ('', 'noboxes')
  *      @return     int             	1 if OK, 0 if KO
  */
 function init($options = '')
 {
     global $conf, $langs;
     // We disable this to prevent pb of modules not correctly disabled
     //$this->remove($options);
     //ODT template
     $src = DOL_DOCUMENT_ROOT . '/install/doctemplates/thirdparties/template_thirdparty.odt';
     $dirodt = DOL_DATA_ROOT . '/doctemplates/thirdparties';
     $dest = $dirodt . '/template_thirdparty.odt';
     if (file_exists($src) && !file_exists($dest)) {
         require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
         dol_mkdir($dirodt);
         $result = dol_copy($src, $dest, 0, 0);
         if ($result < 0) {
             $langs->load("errors");
             $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
             return 0;
         }
     }
     $sql = array();
     return $this->_init($sql, $options);
 }
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:30,代码来源:modSociete.class.php

示例6: GETPOST

 // Table prefix
 $main_db_prefix = !empty($db_prefix) ? $db_prefix : 'llx_';
 // Force https
 $main_force_https = GETPOST("main_force_https") && (GETPOST("main_force_https") == "on" || GETPOST("main_force_https") == 1) ? '1' : '0';
 // Use alternative directory
 $main_use_alt_dir = GETPOST("main_use_alt_dir") && (GETPOST("main_use_alt_dir") == "on" || GETPOST("main_use_alt_dir") == 1) ? '' : '//';
 // Alternative root directory name
 $main_alt_dir_name = GETPOST("main_alt_dir_name") && GETPOST("main_alt_dir_name") != '' ? GETPOST("main_alt_dir_name") : 'custom';
 // Write conf file on disk
 if (!$error) {
     // Save old conf file on disk
     if (file_exists("{$conffile}")) {
         // We must ignore errors as an existing old file may already exists and not be replacable or
         // the installer (like for ubuntu) may not have permission to create another file than conf.php.
         // Also no other process must be able to read file or we expose the new file, so content with password.
         @dol_copy($conffile, $conffile . '.old', '0400');
     }
     $error += write_conf_file($conffile);
 }
 // Write main.inc.php and master.inc.php into documents/custom dir
 $error += write_main_file($main_data_dir . '/custom/main.inc.php', $main_dir);
 $error += write_master_file($main_data_dir . '/custom/master.inc.php', $main_dir);
 // Create database and admin user database
 if (!$error) {
     // We reload configuration file
     conf($dolibarr_main_document_root);
     print '<tr><td>';
     print $langs->trans("ConfFileReload");
     print '</td>';
     print '<td><img src="../theme/eldy/img/tick.png" alt="Ok"></td></tr>';
     $userroot = isset($_POST["db_user_root"]) ? $_POST["db_user_root"] : "";
开发者ID:Samara94,项目名称:dolibarr,代码行数:31,代码来源:step1.php

示例7: init

	/**
	 *  Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module.
	 *  Definit egalement les repertoires de donnees a creer pour ce module.
	 *	@param		options		Options when enabling module
	 */
	function init($options='')
	{
		global $conf;

		// Remove permissions and default values
		$this->remove($options);

		require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
		$dirodt=DOL_DATA_ROOT.'/doctemplates/invoices';
		create_exdir($dirodt);
		dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0);

		$sql = array(
			 "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
			 "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','invoice',".$conf->entity.")",
		);

		return $this->_init($sql,$options);
	}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:24,代码来源:modFacture.class.php

示例8: createFromClone


//.........这里部分代码省略.........
             if ($res < 0) {
                 $this->error .= $clone_project->error;
                 $error++;
                 $this->db->rollback();
             } else {
                 $this->db->commit();
             }
         }
         //Duplicate contact
         if ($clone_contact) {
             $origin_project = new Project($this->db);
             $origin_project->fetch($fromid);
             foreach (array('internal', 'external') as $source) {
                 $tab = $origin_project->liste_contact(-1, $source);
                 foreach ($tab as $contacttoadd) {
                     $clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source'], $notrigger);
                     if ($clone_project->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
                         $langs->load("errors");
                         $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
                         $error++;
                     } else {
                         if ($clone_project->error != '') {
                             $this->error .= $clone_project->error;
                             $error++;
                         }
                     }
                 }
             }
         }
         //Duplicate file
         if ($clone_project_file) {
             require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
             $clone_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($defaultref);
             $ori_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($orign_project_ref);
             if (dol_mkdir($clone_project_dir) >= 0) {
                 $filearray = dol_dir_list($ori_project_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', '', SORT_ASC, 1);
                 foreach ($filearray as $key => $file) {
                     $rescopy = dol_copy($ori_project_dir . '/' . $file['name'], $clone_project_dir . '/' . $file['name'], 0, 1);
                     if (is_numeric($rescopy) && $rescopy < 0) {
                         $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_project_dir . '/' . $file['name'], $clone_project_dir . '/' . $file['name']);
                         $error++;
                     }
                 }
             } else {
                 $this->error .= $langs->trans('ErrorInternalErrorDetected') . ':dol_mkdir';
                 $error++;
             }
         }
         //Duplicate task
         if ($clone_task) {
             require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php';
             $taskstatic = new Task($this->db);
             // Security check
             $socid = 0;
             if ($user->societe_id > 0) {
                 $socid = $user->societe_id;
             }
             $tasksarray = $taskstatic->getTasksArray(0, 0, $fromid, $socid, 0);
             //manage new parent clone task id
             $tab_conv_child_parent = array();
             foreach ($tasksarray as $tasktoclone) {
                 $result_clone = $taskstatic->createFromClone($tasktoclone->id, $clone_project_id, $tasktoclone->fk_parent, true, true, false, $clone_task_file, true, false);
                 if ($result_clone <= 0) {
                     $this->error .= $result_clone->error;
                     $error++;
                 } else {
                     $new_task_id = $result_clone;
                     $taskstatic->fetch($tasktoclone->id);
                     //manage new parent clone task id
                     // if the current task has child we store the original task id and the equivalent clone task id
                     if ($taskstatic->hasChildren() && !array_key_exists($tasktoclone->id, $tab_conv_child_parent)) {
                         $tab_conv_child_parent[$tasktoclone->id] = $new_task_id;
                     }
                 }
             }
             //Parse all clone node to be sure to update new parent
             $tasksarray = $taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0);
             foreach ($tasksarray as $task_cloned) {
                 $taskstatic->fetch($task_cloned->id);
                 if ($taskstatic->fk_task_parent != 0) {
                     $taskstatic->fk_task_parent = $tab_conv_child_parent[$taskstatic->fk_task_parent];
                 }
                 $res = $taskstatic->update($user, $notrigger);
                 if ($result_clone <= 0) {
                     $this->error .= $taskstatic->error;
                     $error++;
                 }
             }
         }
     }
     unset($clone_project->context['createfromclone']);
     if (!$error) {
         $this->db->commit();
         return $clone_project_id;
     } else {
         $this->db->rollback();
         dol_syslog(get_class($this) . "::createFromClone nbError: " . $error . " error : " . $this->error, LOG_ERR);
         return -1;
     }
 }
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:101,代码来源:project.class.php

示例9: init

    /**
     *      Function called when module is enabled.
     *      The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
     *      It also creates data directories.
     *      @return     int             1 if OK, 0 if KO
     */
	function init($options='')
	{
		global $conf;

		// We disable this to prevent pb of modules not correctly disabled
		//$this->remove($options);

		require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
		$dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties';
		create_exdir($dirodt);
		dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt',$dirodt.'/template_thirdparty.odt',0,0);

		$sql = array();

		return $this->_init($sql,$options);
	}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:22,代码来源:modSociete.class.php

示例10: dolCopyDir

/**
 * Copy a dir to another dir.
 *
 * @param	string	$srcfile			Source file (a directory)
 * @param	string	$destfile			Destination file (a directory)
 * @param	int		$newmask			Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
 * @param 	int		$overwriteifexists	Overwrite file if exists (1 by default)
 * @return	int							<0 if error, 0 if nothing done (dest dir already exists and overwriteifexists=0), >0 if OK
 * @see		dol_copy
 */
function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
{
    global $conf;
    $result = 0;
    dol_syslog("files.lib.php::dolCopyr srcfile=" . $srcfile . " destfile=" . $destfile . " newmask=" . $newmask . " overwriteifexists=" . $overwriteifexists);
    if (empty($srcfile) || empty($destfile)) {
        return -1;
    }
    $destexists = dol_is_dir($destfile);
    if (!$overwriteifexists && $destexists) {
        return 0;
    }
    $srcfile = dol_osencode($srcfile);
    $destfile = dol_osencode($destfile);
    // recursive function to copy
    // all subdirectories and contents:
    if (is_dir($srcfile)) {
        $dir_handle = opendir($srcfile);
        while ($file = readdir($dir_handle)) {
            if ($file != "." && $file != "..") {
                if (is_dir($srcfile . "/" . $file)) {
                    if (!is_dir($destfile . "/" . $file)) {
                        umask(0);
                        $dirmaskdec = octdec($newmask);
                        if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) {
                            $dirmaskdec = octdec($conf->global->MAIN_UMASK);
                        }
                        $dirmaskdec |= octdec('0200');
                        // Set w bit required to be able to create content for recursive subdirs files
                        dol_mkdir($destfile . "/" . $file, '', decoct($dirmaskdec));
                    }
                    $result = dolCopyDir($srcfile . "/" . $file, $destfile . "/" . $file, $newmask, $overwriteifexists);
                } else {
                    $result = dol_copy($srcfile . "/" . $file, $destfile . "/" . $file, $newmask, $overwriteifexists);
                }
                if ($result < 0) {
                    break;
                }
            }
        }
        closedir($dir_handle);
    } else {
        $result = dol_copy($srcfile, $destfile, $newmask, $overwriteifexists);
    }
    return $result;
}
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:56,代码来源:files.lib.php

示例11: testDolCopyMove

    /**
     * testDolCopyMove
     *
     * @return	int
     */
    public function testDolCopyMove()
    {
        global $conf,$user,$langs,$db;
        $conf=$this->savconf;
        $user=$this->savuser;
        $langs=$this->savlangs;
        $db=$this->savdb;

        $file=dirname(__FILE__).'/Example_import_company_1.csv';

        $result=dol_copy($file, '/adir/that/does/not/exists/file.csv');
        print __METHOD__." result=".$result."\n";
        $this->assertLessThan(0,$result);    // We should have error

        $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1);
        print __METHOD__." result=".$result."\n";
        $this->assertGreaterThanOrEqual(1,$result);    // Should be 1

        // Again to test with overwriting=0
        $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,0);
        print __METHOD__." result=".$result."\n";
        $this->assertEquals(0,$result);    // Should be 0

        // Again to test with overwriting=1
        $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1);
        print __METHOD__." result=".$result."\n";
        $this->assertGreaterThanOrEqual(1,$result);    // Should be 1

        // Again to test with overwriting=1
        $result=dol_move($conf->admin->dir_temp.'/file.csv',$conf->admin->dir_temp.'/file2.csv',0,1);
        print __METHOD__." result=".$result."\n";
        $this->assertTrue($result);

        $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv');
        print __METHOD__." result=".$result."\n";
        $this->assertTrue($result);

        // Again to test no erreor when deleteing a non existing file
        $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv');
        print __METHOD__." result=".$result."\n";
        $this->assertTrue($result);
    }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:47,代码来源:FilesLibTest.php


注:本文中的dol_copy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。