/** * Fonction qui dit si cet utilisateur est un redacteur existant dans spip * @return int 1=existe, 0=n'existe pas, -1=erreur */ function is_in_spip() { if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP == 1 && defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' && defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' && defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' && defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '') { $query = "SELECT login FROM spip_auteurs WHERE login='******'"; $mydb = new DoliDb('mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT); if ($mydb->ok) { $result = $mydb->query($query); if ($result) { if ($mydb->num_rows($result)) { # nous avons au moins une reponse $mydb->close($result); return 1; } else { # nous n'avons pas de reponse => n'existe pas $mydb->close($result); return 0; } } else { # error $this->error = $mydb->error(); return -1; } } else { $this->error = "Echec de connexion avec les identifiants " . ADHERENT_SPIP_SERVEUR . " " . ADHERENT_SPIP_USER . " " . ADHERENT_SPIP_PASS . " " . ADHERENT_SPIP_DB; return -1; } } }
print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>'; flush(); /* * Delete duplicates in table categorie_association */ $couples=array(); $filles=array(); $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: search duplicate sql=".$sql); $resql = $db->query($sql); if ($resql) { $num=$db->num_rows($resql); while ($obj=$db->fetch_object($resql)) { if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). { if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) { $filles[$obj->fk_categorie_fille]=1; // Set record for this child $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); } } } dolibarr_install_syslog("upgrade: result is num=".$num." sizeof(couples)=".sizeof($couples)); // If there is duplicates couples or child with two parents
/** * Load all objects with filters * * @param DoliDb $db Database handler * @param int $socid Filter by thirdparty * @param int $fk_element Id of element action is linked to * @param string $elementtype Type of element action is linked to * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC * @return array or string Error string if KO, array with actions if OK */ static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = '', $sortorder = '') { global $conf, $langs; $resarray = array(); $sql = "SELECT a.id"; $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a"; $sql .= " WHERE a.entity IN (" . getEntity('actioncomm', 1) . ")"; if (!empty($socid)) { $sql .= " AND a.fk_soc = " . $socid; } if (!empty($elementtype)) { if ($elementtype == 'project') { $sql .= ' AND a.fk_project = ' . $fk_element; } else { $sql .= " AND a.fk_element = " . $fk_element . " AND a.elementtype = '" . $elementtype . "'"; } } if (!empty($filter)) { $sql .= $filter; } if ($sortorder && $sortfield) { $sql .= $db->order($sortfield, $sortorder); } dol_syslog(get_class() . "::getActions", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); $actioncommstatic = new ActionComm($db); $actioncommstatic->fetch($obj->id); $resarray[$i] = $actioncommstatic; } } $db->free($resql); return $resarray; } else { return $db->lasterror(); } }