/** * Same function than javascript unescape() function but in PHP. * * @param string $source String to decode * @return string Unescaped string */ function jsUnEscape($source) { $decodedStr = ""; $pos = 0; $len = strlen($source); while ($pos < $len) { $charAt = substr($source, $pos, 1); if ($charAt == '%') { $pos++; $charAt = substr($source, $pos, 1); if ($charAt == 'u') { // we got a unicode character $pos++; $unicodeHexVal = substr($source, $pos, 4); $unicode = hexdec($unicodeHexVal); $entity = "&#" . $unicode . ';'; $decodedStr .= utf8_encode($entity); $pos += 4; } else { // we have an escaped ascii character $hexVal = substr($source, $pos, 2); $decodedStr .= chr(hexdec($hexVal)); $pos += 2; } } else { $decodedStr .= $charAt; $pos++; } } return dol_html_entity_decode($decodedStr, ENT_COMPAT); }
/** Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone * @param int $project_id Id of project to attach clone task * @param int $parent_task_id Id of task to attach clone task * @param bool $clone_change_dt recalculate date of task regarding new project start date * @param bool $clone_affectation clone affectation of project * @param bool $clone_time clone time of project * @param bool $clone_file clone file of project * @param bool $clone_note clone note of project * @param bool $clone_prog clone progress of project * @return int New id of clone */ function createFromClone($fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false) { global $user, $langs, $conf; $error = 0; //Use 00:00 of today if time is use on task. $now = dol_mktime(0, 0, 0, dol_print_date(dol_now(), '%m'), dol_print_date(dol_now(), '%d'), dol_print_date(dol_now(), '%Y')); $datec = $now; $clone_task = new Task($this->db); $origin_task = new Task($this->db); $clone_task->context['createfromclone'] = 'createfromclone'; $this->db->begin(); // Load source object $clone_task->fetch($fromid); $origin_task->fetch($fromid); $defaultref = ''; $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) { require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php'; $modTask = new $obj(); $defaultref = $modTask->getNextValue(0, $clone_task); } $ori_project_id = $clone_task->fk_project; $clone_task->id = 0; $clone_task->ref = $defaultref; $clone_task->fk_project = $project_id; $clone_task->fk_task_parent = $parent_task_id; $clone_task->date_c = $datec; $clone_task->planned_workload = $origin_task->planned_workload; $clone_task->rang = $origin_task->rang; //Manage Task Date if ($clone_change_dt) { $projectstatic = new Project($this->db); $projectstatic->fetch($ori_project_id); //Origin project strat date $orign_project_dt_start = $projectstatic->date_start; //Calcultate new task start date with difference between origin proj start date and origin task start date if (!empty($clone_task->date_start)) { $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start; } //Calcultate new task end date with difference between origin proj end date and origin task end date if (!empty($clone_task->date_end)) { $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start; } } if (!$clone_prog) { $clone_task->progress = 0; } // Create clone $result = $clone_task->create($user); // Other options 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; } }
/** * Return line description translated in outputlangs and encoded into htmlentities and with <br> * * @param Object $object Object * @param int $i Current line number (0 = first line, 1 = second line, ...) * @param Translate $outputlangs Object langs for output * @param int $hideref Hide reference * @param int $hidedesc Hide description * @param int $issupplierline Is it a line for a supplier object ? * @return string String with line */ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { global $db, $conf, $langs; $idprod = !empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false; $label = !empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : ''); $desc = !empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : ''); $ref_supplier = !empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : ''); // TODO Not yet saved for supplier invoices, only supplier orders $note = !empty($object->lines[$i]->note) ? $object->lines[$i]->note : ''; $dbatch = !empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false; if ($issupplierline) { $prodser = new ProductFournisseur($db); } else { $prodser = new Product($db); } if ($idprod) { $prodser->fetch($idprod); // If a predefined product and multilang and on other lang, we renamed label with label translated if (!empty($conf->global->MAIN_MULTILANGS) && $outputlangs->defaultlang != $langs->defaultlang) { $translatealsoifmodified = !empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED); // By default if value was modified manually, we keep it (no translation because we don't have it) // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion). // Set label // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; $textwasmodified = $label == $prodser->label; if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) { $label = $prodser->multilangs[$outputlangs->defaultlang]["label"]; } // Set desc // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no $textwasmodified = false; if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) { $textwasmodified = strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false; } else { $textwasmodified = $desc == $prodser->description; } if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) { $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"]; } // Set note $textwasmodified = $note == $prodser->note; if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) { $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } } // Description short of product line $libelleproduitservice = $label; // Description long of product line if (!empty($desc) && $desc != $label) { if ($libelleproduitservice && empty($hidedesc)) { $libelleproduitservice .= '__N__'; } if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source); } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source); // Add date of deposit if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { echo ' (' . dol_print_date($discount->datec, 'day', '', $outputlangs) . ')'; } } else { if ($idprod) { if (empty($hidedesc)) { $libelleproduitservice .= $desc; } } else { $libelleproduitservice .= $desc; } } } // If line linked to a product if ($idprod) { // We add ref if ($prodser->ref) { $prefix_prodserv = ""; $ref_prodserv = ""; if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { if ($prodser->isService()) { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service") . " "; } else { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product") . " "; } } if (empty($hideref)) { if ($issupplierline) { $ref_prodserv = $prodser->ref . ($ref_supplier ? ' (' . $outputlangs->transnoentitiesnoconv("SupplierRef") . ' ' . $ref_supplier . ')' : ''); } else { $ref_prodserv = $prodser->ref; } // Show local ref only if (!empty($libelleproduitservice)) { $ref_prodserv .= " - "; } } $libelleproduitservice = $prefix_prodserv . $ref_prodserv . $libelleproduitservice; } } // Add an additional description for the category products if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $categstatic = new Categorie($db); // recovering the list of all the categories linked to product $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT); foreach ($tblcateg as $cate) { // Adding the descriptions if they are filled $desccateg = $cate->add_description; if ($desccateg) { $libelleproduitservice .= '__N__' . $desccateg; } } } if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) { $format = 'day'; // Show duration if exists if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { $period = '(' . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)) . ')'; } if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) { $period = '(' . $outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)) . ')'; } if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) { $period = '(' . $outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)) . ')'; } //print '>'.$outputlangs->charset_output.','.$period; $libelleproduitservice .= "__N__" . $period; //print $libelleproduitservice; } if ($dbatch) { $format = 'day'; foreach ($dbatch as $detail) { $dte = array(); if ($detail->eatby) { $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs)); } if ($detail->sellby) { $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs)); } if ($detail->batch) { $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch); } $dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->dluo_qty); $libelleproduitservice .= "__N__ " . implode($dte, "-"); } } // Now we convert \n into br if (dol_textishtml($libelleproduitservice)) { $libelleproduitservice = preg_replace('/__N__/', '<br>', $libelleproduitservice); } else { $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice); } $libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1); return $libelleproduitservice; }
$socid = $user->societe_id; } $result = restrictedArea($user, 'contrat', $id); $object = new Contrat($db); $object->fetch($id, $ref); /******************************************************************************/ /* Actions */ /******************************************************************************/ if ($action == 'setnote_public' && $user->rights->contrat->creer) { $result = $object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_public')), ENT_QUOTES), '_public'); if ($result < 0) { dol_print_error($db, $object->error); } } else { if ($action == 'setnote_private' && $user->rights->contrat->creer) { $result = $object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_private')), ENT_QUOTES), '_private'); if ($result < 0) { dol_print_error($db, $object->error); } } } /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ llxHeader(); $form = new Form($db); if ($id > 0 || !empty($ref)) { dol_htmloutput_mesg($mesg); $object->fetch_thirdparty(); $head = contract_prepare_head($object); $hselected = 2;
/** * Get object from database * * @param int $rowid Id of emailing * @return int <0 if KO, >0 if OK */ function fetch($rowid) { global $conf; $sql = "SELECT m.rowid, m.titre, m.sujet, m.body, m.bgcolor, m.bgimage"; $sql .= ", m.email_from, m.email_replyto, m.email_errorsto"; $sql .= ", m.statut, m.nbemail"; $sql .= ", m.fk_user_creat, m.fk_user_valid"; $sql .= ", m.date_creat"; $sql .= ", m.date_valid"; $sql .= ", m.date_envoi"; $sql .= ", m.extraparams"; $sql .= " FROM " . MAIN_DB_PREFIX . "mailing as m"; $sql .= " WHERE m.rowid = " . $rowid; dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->ref = $obj->rowid; $this->statut = $obj->statut; $this->nbemail = $obj->nbemail; $this->titre = $obj->titre; $this->sujet = $obj->sujet; if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) { $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401); } else { $this->body = $obj->body; } $this->bgcolor = $obj->bgcolor; $this->bgimage = $obj->bgimage; $this->email_from = $obj->email_from; $this->email_replyto = $obj->email_replyto; $this->email_errorsto = $obj->email_errorsto; $this->user_creat = $obj->fk_user_creat; $this->user_valid = $obj->fk_user_valid; $this->date_creat = $this->db->jdate($obj->date_creat); $this->date_valid = $this->db->jdate($obj->date_valid); $this->date_envoi = $this->db->jdate($obj->date_envoi); $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; } else { dol_syslog(get_class($this) . "::fetch Erreur -1"); return -1; } } else { dol_syslog(get_class($this) . "::fetch Erreur -2"); return -2; } }
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('usercard', 'globalcard')); /******************************************************************************/ /* Actions */ /******************************************************************************/ $parameters = array('id' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } if (empty($reshook)) { if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) { $db->begin(); $res = $object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES)); if ($res < 0) { $mesg = '<div class="error">' . $adh->error . '</div>'; $db->rollback(); } else { $db->commit(); } } } /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ llxHeader(); $form = new Form($db); if ($id) { $head = user_prepare_head($object);
/** * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone * @param bool $clone_contact clone contact of project * @param bool $clone_task clone task of project * @param bool $clone_project_file clone file of project * @param bool $clone_task_file clone file of task (if task are copied) * @param bool $clone_note clone note of project * @param bool $notrigger no trigger flag * @return int New id of clone */ function createFromClone($fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $notrigger = 0) { global $user, $langs, $conf; $error = 0; dol_syslog("createFromClone clone_contact=" . $clone_contact . " clone_task=" . $clone_task . " clone_project_file=" . $clone_project_file . " clone_note=" . $clone_note); $now = dol_mktime(0, 0, 0, idate('m', dol_now()), idate('d', dol_now()), idate('Y', dol_now())); $clone_project = new Project($this->db); $clone_project->context['createfromclone'] = 'createfromclone'; $this->db->begin(); // Load source object $clone_project->fetch($fromid); $clone_project->fetch_thirdparty(); $orign_dt_start = $clone_project->date_start; $orign_project_ref = $clone_project->ref; $clone_project->id = 0; $clone_project->date_start = $now; if (!empty($clone_project->date_end)) { $clone_project->date_end = $clone_project->date_end + ($now - $orign_dt_start); } $clone_project->datec = $now; if (!$clone_note) { $clone_project->note_private = ''; $clone_project->note_public = ''; } //Generate next ref $defaultref = ''; $obj = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; if (!empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/" . $conf->global->PROJECT_ADDON . ".php")) { require_once DOL_DOCUMENT_ROOT . "/core/modules/project/" . $conf->global->PROJECT_ADDON . '.php'; $modProject = new $obj(); $defaultref = $modProject->getNextValue(is_object($clone_project->thirdparty) ? $clone_project->thirdparty->id : 0, $clone_project); } if (is_numeric($defaultref) && $defaultref <= 0) { $defaultref = ''; } $clone_project->ref = $defaultref; // Create clone $result = $clone_project->create($user, $notrigger); // Other options if ($result < 0) { $this->error .= $clone_project->error; $error++; } if (!$error) { //Get the new project id $clone_project_id = $clone_project->id; //Note Update if (!$clone_note) { $clone_project->note_private = ''; $clone_project->note_public = ''; } else { $this->db->begin(); $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_public, ENT_QUOTES), '_public'); if ($res < 0) { $this->error .= $clone_project->error; $error++; $this->db->rollback(); } else { $this->db->commit(); } $this->db->begin(); $res = $clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES), '_private'); 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; } }
$socid = 0; if ($user->societe_id > 0) { $socid = $user->societe_id; } $feature2 = $socid && $user->rights->user->self->creer ? '' : 'user'; if ($user->id == $id) { $feature2 = ''; } // A user can always read its own card $result = restrictedArea($user, 'user', $id, '&user', $feature2); /******************************************************************************/ /* Actions */ /******************************************************************************/ if ($action == 'update' && $user->rights->user->user->creer && !$_POST["cancel"]) { $db->begin(); $res = $fuser->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); if ($res < 0) { $mesg = '<div class="error">' . $adh->error . '</div>'; $db->rollback(); } else { $db->commit(); } } /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ llxHeader(); $form = new Form($db); if ($id) { $head = user_prepare_head($fuser); $title = $langs->trans("User");
if (!empty($_POST["fromname"])) { $email_from = $_POST["fromname"] . ' '; } if (!empty($_POST["frommail"])) { $email_from .= '<' . $_POST["frommail"] . '>'; } $errors_to = $_POST["errorstomail"]; $sendto = $_POST["sendto"]; $sendtocc = $_POST["sendtocc"]; $sendtoccc = $_POST["sendtoccc"]; $subject = $_POST['subject']; $body = $_POST['message']; $deliveryreceipt = $_POST["deliveryreceipt"]; //Check if we have to decode HTML if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401))) { $body = dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401); } // Create form object include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $attachedfiles = $formmail->get_attached_files(); $filepath = $attachedfiles['paths']; $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; if (empty($_POST["frommail"])) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")), 'errors'); $action = 'test'; $error++; } if (empty($sendto)) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTo")), 'errors');
/** * This function is called to decode a string with HTML entities (it decodes entities tags) * @param stringhtml stringhtml * @param pagecodeto Encoding of input string * @return string decodestring */ function dol_entity_decode($stringhtml, $pagecodeto = 'UTF-8') { $ret = dol_html_entity_decode($stringhtml, ENT_COMPAT, $pagecodeto); return $ret; }
} $adht->update($user); header("Location: " . $_SERVER["PHP_SELF"] . "?rowid=" . $_POST["rowid"]); exit; } } if ($action == 'delete' && $user->rights->adherent->configurer) { $adht = new AdherentType($db); $adht->delete($rowid); header("Location: " . $_SERVER["PHP_SELF"]); exit; } if ($action == 'commentaire' && $user->rights->adherent->configurer) { $don = new Don($db); $don->fetch($rowid); $don->update_note(dol_html_entity_decode(GETPOST('commentaire'), ENT_QUOTES)); } /* * View */ llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); $form = new Form($db); // Liste of members type if (!$rowid && $action != 'create' && $action != 'edit') { print_fiche_titre($langs->trans("MembersTypes")); $sql = "SELECT d.rowid, d.libelle, d.cotisation, d.vote"; $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as d"; $sql .= " WHERE d.entity IN (" . getEntity() . ")"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result);
/** * Function to convert a HTML string into an ODT string * * @param string $value String to convert */ public function htmlToUTFAndPreOdf($value) { // We decode into utf8, entities $value = dol_html_entity_decode($value, ENT_QUOTES); // We convert html tags $ishtml = dol_textishtml($value); if ($ishtml) { // If string is "MYPODUCT - Desc <strong>bold</strong> with é accent<br />\n<br />\nUn texto en español ?" // Result after clean must be "MYPODUCT - Desc bold with é accent\n\nUn texto en español ?" // We want to ignore \n and we want all <br> to be \n $value = preg_replace('/(\\r\\n|\\r|\\n)/i', '', $value); $value = preg_replace('/<br>/i', "\n", $value); $value = preg_replace('/<br\\s+[^<>\\/]*>/i', "\n", $value); $value = preg_replace('/<br\\s+[^<>\\/]*\\/>/i', "\n", $value); //$value=preg_replace('/<strong>/','__lt__text:p text:style-name=__quot__bold__quot____gt__',$value); //$value=preg_replace('/<\/strong>/','__lt__/text:p__gt__',$value); $value = dol_string_nohtmltag($value, 0); } return $value; }
/** * This function is called to decode a HTML string (it decodes entities and br tags) * * @param string $stringtodecode String to decode * @param string $pagecodeto Page code for result * @return string String decoded */ function dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto = 'UTF-8') { $ret = dol_html_entity_decode($stringtodecode, ENT_COMPAT, $pagecodeto); $ret = preg_replace('/' . "\r\n" . '<br(\\s[\\sa-zA-Z_="]*)?\\/?>/i', "<br>", $ret); $ret = preg_replace('/<br(\\s[\\sa-zA-Z_="]*)?\\/?>' . "\r\n" . '/i', "\r\n", $ret); $ret = preg_replace('/<br(\\s[\\sa-zA-Z_="]*)?\\/?>' . "\n" . '/i', "\n", $ret); $ret = preg_replace('/<br(\\s[\\sa-zA-Z_="]*)?\\/?>/i', "\n", $ret); return $ret; }