예제 #1
0
	}

  	// Force l'affichage de la progression
	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);
				}
			}
		}
예제 #2
0
 /**
  *  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;
         }
     }
 }
예제 #3
0
				$buffer=trim($buffer);
				if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')	// For Mysql 5.5+, we must replace type=innodb
				{
					$buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer);
				}

				//print "<tr><td>Creation de la table $name/td>";
				$requestnb++;
				if ($conf->file->character_set_client == "UTF-8")
				{
					$buffer=utf8_encode($buffer);
				}

				dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
				$resql=$db->query($buffer,0,'dml');
				if ($resql)
				{
					// print "<td>OK requete ==== $buffer</td></tr>";
					$db->free($resql);
				}
				else
				{
					if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
					$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
					{
						//print "<td>Deja existante</td></tr>";
					}
					else
					{
						print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name);
예제 #4
0
 /**
  *   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();
     }
 }
예제 #5
0
 /**
  *  Return nb of links
  *
  *  @param  DoliDb  $db         Database handler
  *  @param  string  $objecttype Type of the associated object in dolibarr
  *  @param  int     $objectid   Id of the associated object in dolibarr
  *  @return int                 Nb of links, -1 if error
  **/
 public static function count($db, $objecttype, $objectid)
 {
     global $conf;
     $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "links";
     $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid;
     if ($conf->entity != 0) {
         $sql .= " AND entity = " . $conf->entity;
     }
     $resql = $db->query($sql);
     if ($resql) {
         $obj = $db->fetch_object($resql);
         if ($obj) {
             return $obj->nb;
         }
     }
     return -1;
 }