Example #1
0
static void Ban_GetListBanners (MYSQL_RES **mysql_res,unsigned long NumRows)
  {
   MYSQL_ROW row;
   unsigned NumBan;
   struct Banner *Ban;

   /***** Get banners from database *****/
   if (NumRows) // Banners found...
     {
      Gbl.Banners.Num = (unsigned) NumRows;

      /***** Create list with banners *****/
      if ((Gbl.Banners.Lst = (struct Banner *)
			     calloc (NumRows,sizeof (struct Banner))) == NULL)
	 Lay_NotEnoughMemoryExit ();

      /***** Get the banners *****/
      for (NumBan = 0;
	   NumBan < Gbl.Banners.Num;
	   NumBan++)
	{
	 Ban = &(Gbl.Banners.Lst[NumBan]);

	 /* Get next banner */
	 row = mysql_fetch_row (*mysql_res);

	 /* Get banner code (row[0]) */
	 if ((Ban->BanCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
	    Lay_ShowErrorAndExit ("Wrong code of banner.");

	 /* Get if banner is hidden (row[1]) */
	 Ban->Hidden = (row[1][0] == 'Y');

	 /* Get the short name of the banner (row[2]) */
	 Str_Copy (Ban->ShrtName,row[2],
		   Ban_MAX_BYTES_SHRT_NAME);

	 /* Get the full name of the banner (row[3]) */
	 Str_Copy (Ban->FullName,row[3],
		   Ban_MAX_BYTES_FULL_NAME);

	 /* Get the image of the banner (row[4]) */
	 Str_Copy (Ban->Img,row[4],
		   Ban_MAX_BYTES_IMAGE);

	 /* Get the URL of the banner (row[5]) */
	 Str_Copy (Ban->WWW,row[5],
		   Cns_MAX_BYTES_WWW);
	}
     }
   else
      Gbl.Banners.Num = 0;

   /***** Free structure that stores the query result *****/
   DB_FreeMySQLResult (mysql_res);
  }
Example #2
0
static void Not_GetDataAndShowNotice (long NotCod,bool ICanEditNotices)
  {
   char Query[512];
   MYSQL_RES *mysql_res;
   MYSQL_ROW row;
   char Content[Cns_MAX_BYTES_TEXT+1];
   time_t TimeUTC;
   long UsrCod;
   unsigned UnsignedNum;
   Not_Status_t Status;

   /***** Get notice data from database *****/
   sprintf (Query,"SELECT UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
		  " FROM notices"
		  " WHERE NotCod='%ld' AND CrsCod='%ld'",
	    NotCod,
	    Gbl.CurrentCrs.Crs.CrsCod);
   if (DB_QuerySELECT (Query,&mysql_res,"can not get notice from database"))
     {
      row = mysql_fetch_row (mysql_res);

      /* Get creation time (row[0] holds the UTC date-time) */
      TimeUTC = Dat_GetUNIXTimeFromStr (row[0]);

      /* Get user code (row[1]) */
      UsrCod = Str_ConvertStrCodToLongCod (row[1]);

      /* Get the content (row[2]) and insert links*/
      strncpy (Content,row[2],Cns_MAX_BYTES_TEXT);
      Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
			    Not_MaxCharsURLOnScreen[Not_LIST_FULL_NOTICES]);

      /* Get status of the notice (row[3]) */
      Status = Not_OBSOLETE_NOTICE;
      if (sscanf (row[3],"%u",&UnsignedNum) == 1)
	 if (UnsignedNum < Not_NUM_STATUS)
	   Status = (Not_Status_t) UnsignedNum;

      /***** Draw the notice *****/
      Not_DrawANotice (Not_LIST_FULL_NOTICES,
		       NotCod,
		       TimeUTC,Content,UsrCod,Status,
		       ICanEditNotices);
     }

   /***** Free structure that stores the query result *****/
   DB_FreeMySQLResult (&mysql_res);
  }
Example #3
0
void Ban_GetDataOfBannerByCod (struct Banner *Ban)
  {
   MYSQL_RES *mysql_res;
   MYSQL_ROW row;
   unsigned long NumRows;

   /***** Clear data *****/
   Ban->Hidden = false;
   Ban->ShrtName[0] = Ban->FullName[0] = Ban->Img[0] = Ban->WWW[0] = '\0';

   /***** Check if banner code is correct *****/
   if (Ban->BanCod > 0)
     {
      /***** Get data of a banner from database *****/
      NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a banner",
				"SELECT Hidden,ShortName,FullName,Img,WWW"
			        " FROM banners WHERE BanCod=%ld",
			        Ban->BanCod);
      if (NumRows) // Banner found...
        {
         /* Get row */
         row = mysql_fetch_row (mysql_res);

         /* Get if the banner is hidden (row[0]) */
         Ban->Hidden = (row[0][0] == 'Y');

         /* Get the short name of the banner (row[1]) */
         Str_Copy (Ban->ShrtName,row[1],
                   Ban_MAX_BYTES_SHRT_NAME);

         /* Get the full name of the banner (row[2]) */
         Str_Copy (Ban->FullName,row[2],
                   Ban_MAX_BYTES_FULL_NAME);

         /* Get the image of the banner (row[3]) */
         Str_Copy (Ban->Img,row[3],
                   Ban_MAX_BYTES_IMAGE);

         /* Get the URL of the banner (row[4]) */
         Str_Copy (Ban->WWW,row[4],
                   Cns_MAX_BYTES_WWW);
        }

      /***** Free structure that stores the query result *****/
      DB_FreeMySQLResult (&mysql_res);
     }
  }
Example #4
0
void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
  {
   MYSQL_RES *mysql_res;
   MYSQL_ROW row;
   Net_WebsAndSocialNetworks_t NumURL;
   char URL[Cns_MAX_BYTES_WWW + 1];

   /***** Start container *****/
   fprintf (Gbl.F.Out,"<div class=\"REC_WEBS\">");

   /***** Show link to public profile *****/
   Net_ShowAWebOrSocialNet (Prf_GetURLPublicProfile (URL,UsrDat->Nickname),
                            "swad64x64.png",Cfg_PLATFORM_SHORT_NAME);

   /***** Show the rest of webs / social networks *****/
   for (NumURL = (Net_WebsAndSocialNetworks_t) 0;
	NumURL < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
	NumURL++)
     {
      /***** Check if exists the web / social network for this user *****/
      if (DB_QuerySELECT (&mysql_res,"can not get user's web / social network",
	                  "SELECT URL FROM usr_webs"
			  " WHERE UsrCod=%ld AND Web='%s'",
			  UsrDat->UsrCod,Net_WebsAndSocialNetworksDB[NumURL]))
	{
	 /* Get URL */
	 row = mysql_fetch_row (mysql_res);
	 Str_Copy (URL,row[0],
	           Cns_MAX_BYTES_WWW);

	 /* Show the web / social network */
	 Net_ShowAWebOrSocialNet (URL,
	                          Net_WebsAndSocialNetworksIcons[NumURL],
	                          Net_WebsAndSocialNetworksTitle[NumURL]);
	}

      /***** Free structure that stores the query result *****/
      DB_FreeMySQLResult (&mysql_res);
     }

   /***** End container *****/
   fprintf (Gbl.F.Out,"</div>");
  }
Example #5
0
unsigned Not_GetNumNoticesDeleted (Sco_Scope_t Scope,unsigned *NumNotif)
  {
   char Query[1024];
   MYSQL_RES *mysql_res;
   MYSQL_ROW row;
   unsigned NumNotices;

   /***** Get number of notices from database *****/
   switch (Scope)
     {
      case Sco_SCOPE_SYS:
         sprintf (Query,"SELECT COUNT(*),SUM(NumNotif)"
                        " FROM notices_deleted");
         break;
      case Sco_SCOPE_CTY:
         sprintf (Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
                        " FROM institutions,centres,degrees,courses,notices_deleted"
                        " WHERE institutions.CtyCod='%ld'"
                        " AND institutions.InsCod=centres.InsCod"
                        " AND centres.CtrCod=degrees.CtrCod"
                        " AND degrees.DegCod=courses.DegCod"
                        " AND courses.CrsCod=notices_deleted.CrsCod",
                  Gbl.CurrentCty.Cty.CtyCod);
         break;
      case Sco_SCOPE_INS:
         sprintf (Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
                        " FROM centres,degrees,courses,notices_deleted"
                        " WHERE centres.InsCod='%ld'"
                        " AND centres.CtrCod=degrees.CtrCod"
                        " AND degrees.DegCod=courses.DegCod"
                        " AND courses.CrsCod=notices_deleted.CrsCod",
                  Gbl.CurrentIns.Ins.InsCod);
         break;
      case Sco_SCOPE_CTR:
         sprintf (Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
                        " FROM degrees,courses,notices_deleted"
                        " WHERE degrees.CtrCod='%ld'"
                        " AND degrees.DegCod=courses.DegCod"
                        " AND courses.CrsCod=notices_deleted.CrsCod",
                  Gbl.CurrentCtr.Ctr.CtrCod);
         break;
      case Sco_SCOPE_DEG:
         sprintf (Query,"SELECT COUNT(*),SUM(notices_deleted.NumNotif)"
                        " FROM courses,notices_deleted"
                        " WHERE courses.DegCod='%ld'"
                        " AND courses.CrsCod=notices_deleted.CrsCod",
                  Gbl.CurrentDeg.Deg.DegCod);
         break;
      case Sco_SCOPE_CRS:
         sprintf (Query,"SELECT COUNT(*),SUM(NumNotif)"
                        " FROM notices_deleted"
                        " WHERE CrsCod='%ld'",
                  Gbl.CurrentCrs.Crs.CrsCod);
         break;
      default:
	 Lay_ShowErrorAndExit ("Wrong scope.");
	 break;
     }
   DB_QuerySELECT (Query,&mysql_res,"can not get number of deleted notices");

   /***** Get number of notices *****/
   row = mysql_fetch_row (mysql_res);
   if (sscanf (row[0],"%u",&NumNotices) != 1)
      Lay_ShowErrorAndExit ("Error when getting number of deleted notices.");

   /***** Get number of notifications by e-mail *****/
   if (row[1])
     {
      if (sscanf (row[1],"%u",NumNotif) != 1)
         Lay_ShowErrorAndExit ("Error when getting number of notifications of deleted notices.");
     }
   else
      *NumNotif = 0;

   /***** Free structure that stores the query result *****/
   DB_FreeMySQLResult (&mysql_res);

   return NumNotices;
  }
Example #6
0
void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEditNotices)
  {
   extern const char *Txt_All_notices;
   extern const char *Txt_No_notices;
   char Query[512];
   MYSQL_RES *mysql_res;
   MYSQL_ROW row;
   char StrWidth[10+2+1];
   char PathRelRSSFile[PATH_MAX+1];
   long NotCod;
   unsigned long NumNot;
   unsigned long NumNotices;
   char Content[Cns_MAX_BYTES_TEXT+1];
   time_t TimeUTC;
   long UsrCod;
   unsigned UnsignedNum;
   Not_Status_t Status;

   /***** A course must be selected (Gbl.CurrentCrs.Crs.CrsCod > 0) *****/
   if (Gbl.CurrentCrs.Crs.CrsCod > 0)
     {
      /***** Get notices from database *****/
      switch (TypeNoticesListing)
	{
	 case Not_LIST_BRIEF_NOTICES:
	    sprintf (Query,"SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
			   " FROM notices"
			   " WHERE CrsCod='%ld' AND Status='%u'"
			   " ORDER BY CreatTime DESC",
		     Gbl.CurrentCrs.Crs.CrsCod,
		     (unsigned) Not_ACTIVE_NOTICE);
	    break;
	 case Not_LIST_FULL_NOTICES:
	    sprintf (Query,"SELECT NotCod,UNIX_TIMESTAMP(CreatTime) AS F,UsrCod,Content,Status"
			   " FROM notices"
			   " WHERE CrsCod='%ld'"
			   " ORDER BY CreatTime DESC",
		     Gbl.CurrentCrs.Crs.CrsCod);
	    break;
	}
      NumNotices = DB_QuerySELECT (Query,&mysql_res,"can not get notices from database");

      if (TypeNoticesListing == Not_LIST_FULL_NOTICES)
	{
	 if (NumNotices)
	   {
            /***** Start frame *****/
	    sprintf (StrWidth,"%upx",
		     Not_ContainerWidth[Not_LIST_FULL_NOTICES] + 50);
            Lay_StartRoundFrame (StrWidth,Txt_All_notices);
	   }
	 else
	    Lay_ShowAlert (Lay_INFO,Txt_No_notices);
	}

      /***** Link to RSS file *****/
      if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
	{
	 /* Create RSS file if not exists */
	 sprintf (PathRelRSSFile,"%s/%s/%ld/%s/%s",
		  Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,Gbl.CurrentCrs.Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
	 if (!Fil_CheckIfPathExists (PathRelRSSFile))
	    RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);

	 /* Put a link to the RSS file */
	 fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">"
			    "<a href=\"");
	 RSS_WriteRSSLink (Gbl.F.Out,Gbl.CurrentCrs.Crs.CrsCod);
	 fprintf (Gbl.F.Out,"\" target=\"_blank\">"
			    "<img src=\"%s/rss16x16.gif\""
			    " alt=\"RSS\" title=\"RSS\""
			    " class=\"ICON20x20\" />"
			    "</a>"
			    "</div>",
	          Gbl.Prefs.IconsURL);
	}

      /***** Show the notices *****/
      for (NumNot = 0;
	   NumNot < NumNotices;
	   NumNot++)
	{
	 row = mysql_fetch_row (mysql_res);

	 /* Get notice code (row[0]) */
	 if (sscanf (row[0],"%ld",&NotCod) != 1)
	    Lay_ShowErrorAndExit ("Wrong code of notice.");

	 /* Get creation time (row[1] holds the UTC date-time) */
	 TimeUTC = Dat_GetUNIXTimeFromStr (row[1]);

	 /* Get user code (row[2]) */
	 UsrCod = Str_ConvertStrCodToLongCod (row[2]);

	 /* Get the content (row[3]) and insert links */
	 strncpy (Content,row[3],Cns_MAX_BYTES_TEXT);
	 Str_InsertLinks (Content,Cns_MAX_BYTES_TEXT,
	                       Not_MaxCharsURLOnScreen[TypeNoticesListing]);
	 if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
            Str_LimitLengthHTMLStr (Content,Not_MAX_CHARS_ON_NOTICE);

	 /* Get status of the notice (row[4]) */
	 Status = Not_OBSOLETE_NOTICE;
	 if (sscanf (row[4],"%u",&UnsignedNum) == 1)
	    if (UnsignedNum < Not_NUM_STATUS)
	      Status = (Not_Status_t) UnsignedNum;

	 /* Draw the notice */
	 Not_DrawANotice (TypeNoticesListing,
	                  NotCod,
	                  TimeUTC,Content,UsrCod,Status,
	                  ICanEditNotices);
	}

      if (TypeNoticesListing == Not_LIST_FULL_NOTICES && NumNotices)
         /***** End frame *****/
	 Lay_EndRoundFrame ();

      /***** Free structure that stores the query result *****/
      DB_FreeMySQLResult (&mysql_res);

      /***** Mark possible notification as seen *****/
      Ntf_MarkNotifAsSeen (Ntf_EVENT_NOTICE,
	                   -1L,Gbl.CurrentCrs.Crs.CrsCod,
	                   Gbl.Usrs.Me.UsrDat.UsrCod);
     }
  }
Example #7
0
void Net_ShowWebAndSocialNetworksStats (void)
  {
   extern const char *Hlp_ANALYTICS_Figures_webs_social_networks;
   extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES];
   extern const char *Txt_Web_social_network;
   extern const char *Txt_No_of_users;
   extern const char *Txt_PERCENT_of_users;
   MYSQL_RES *mysql_res;
   MYSQL_ROW row;
   unsigned NumRows = 0;	// Initialized to avoid warning
   unsigned NumRow;
   Net_WebsAndSocialNetworks_t Web;
   char NetName[Net_MAX_BYTES_NETWORK_NAME + 1];
   unsigned NumUsrsTotal;
   unsigned NumUsrs;

   /***** Get total number of users in current scope *****/
   NumUsrsTotal = (Gbl.Scope.Current == Hie_SYS) ? Usr_GetTotalNumberOfUsersInPlatform () :
                                                         Usr_GetTotalNumberOfUsersInCourses (Gbl.Scope.Current,
                                                                                             1 << Rol_STD |
                                                                                             1 << Rol_NET |
                                                                                             1 << Rol_TCH);

   /***** Get number of users with a web / social network *****/
   switch (Gbl.Scope.Current)
     {
      case Hie_SYS:
         NumRows =
         (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
					       " with webs / social networks",
				    "SELECT Web,COUNT(*) AS N"
				    " FROM usr_webs"
				    " GROUP BY Web"
				    " ORDER BY N DESC,Web");
         break;
      case Hie_CTY:
         NumRows =
         (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
					       " with webs / social networks",
				    "SELECT usr_webs.Web,"
				    "COUNT(DISTINCT usr_webs.UsrCod) AS N"
				    " FROM institutions,centres,degrees,courses,crs_usr,usr_webs"
				    " WHERE institutions.CtyCod=%ld"
				    " AND institutions.InsCod=centres.InsCod"
				    " AND centres.CtrCod=degrees.CtrCod"
				    " AND degrees.DegCod=courses.DegCod"
				    " AND courses.CrsCod=crs_usr.CrsCod"
				    " AND crs_usr.UsrCod=usr_webs.UsrCod"
				    " GROUP BY usr_webs.Web"
				    " ORDER BY N DESC,usr_webs.Web",
				    Gbl.Hierarchy.Cty.CtyCod);
         break;
      case Hie_INS:
         NumRows =
         (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
					       " with webs / social networks",
				    "SELECT usr_webs.Web,"
				    "COUNT(DISTINCT usr_webs.UsrCod) AS N"
				    " FROM centres,degrees,courses,crs_usr,usr_webs"
				    " WHERE centres.InsCod=%ld"
				    " AND centres.CtrCod=degrees.CtrCod"
				    " AND degrees.DegCod=courses.DegCod"
				    " AND courses.CrsCod=crs_usr.CrsCod"
				    " AND crs_usr.UsrCod=usr_webs.UsrCod"
				    " GROUP BY usr_webs.Web"
				    " ORDER BY N DESC,usr_webs.Web",
				    Gbl.Hierarchy.Ins.InsCod);
         break;
      case Hie_CTR:
         NumRows =
         (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
					       " with webs / social networks",
				    "SELECT usr_webs.Web,"
				    "COUNT(DISTINCT usr_webs.UsrCod) AS N"
				    " FROM degrees,courses,crs_usr,usr_webs"
				    " WHERE degrees.CtrCod=%ld"
				    " AND degrees.DegCod=courses.DegCod"
				    " AND courses.CrsCod=crs_usr.CrsCod"
				    " AND crs_usr.UsrCod=usr_webs.UsrCod"
				    " GROUP BY usr_webs.Web"
				    " ORDER BY N DESC,usr_webs.Web",
				    Gbl.Hierarchy.Ctr.CtrCod);
         break;
      case Hie_DEG:
         NumRows =
         (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
					       " with webs / social networks",
				    "SELECT usr_webs.Web,"
				    "COUNT(DISTINCT usr_webs.UsrCod) AS N"
				    " FROM courses,crs_usr,usr_webs"
				    " WHERE courses.DegCod=%ld"
				    " AND courses.CrsCod=crs_usr.CrsCod"
				    " AND crs_usr.UsrCod=usr_webs.UsrCod"
				    " GROUP BY usr_webs.Web"
				    " ORDER BY N DESC,usr_webs.Web",
				    Gbl.Hierarchy.Deg.DegCod);
         break;
      case Hie_CRS:
         NumRows =
         (unsigned) DB_QuerySELECT (&mysql_res,"can not get number of users"
					       " with webs / social networks",
				    "SELECT usr_webs.Web,"
				    "COUNT(DISTINCT usr_webs.UsrCod) AS N"
				    " FROM crs_usr,usr_webs"
				    " WHERE crs_usr.CrsCod=%ld"
				    " AND crs_usr.UsrCod=usr_webs.UsrCod"
				    " GROUP BY usr_webs.Web"
				    " ORDER BY N DESC,usr_webs.Web",
				    Gbl.Hierarchy.Crs.CrsCod);
         break;
      default:
	 Lay_WrongScopeExit ();
	 break;
     }

   /***** Start box and table *****/
   Box_StartBoxTable (NULL,Txt_FIGURE_TYPES[Fig_SOCIAL_NETWORKS],NULL,
                      Hlp_ANALYTICS_Figures_webs_social_networks,Box_NOT_CLOSABLE,2);

   /***** Write heading *****/
   fprintf (Gbl.F.Out,"<tr>"
                      "<th class=\"LEFT_MIDDLE\">"
                      "%s"
                      "</th>"
                      "<th class=\"RIGHT_MIDDLE\">"
                      "%s"
                      "</th>"
                      "<th class=\"RIGHT_MIDDLE\">"
                      "%s"
                      "</th>"
                      "</tr>",
            Txt_Web_social_network,
            Txt_No_of_users,
            Txt_PERCENT_of_users);

   /***** For each web / social network... *****/
   for (NumRow = 0;
	NumRow < NumRows;
	NumRow++)
     {
      /* Get row */
      row = mysql_fetch_row (mysql_res);

      /* Get web / social network (row[0]) */
      Str_Copy (NetName,row[0],
                Net_MAX_BYTES_NETWORK_NAME);
      for (Web = (Net_WebsAndSocialNetworks_t) 0;
	   Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
	   Web++)
	 if (!strcmp (Net_WebsAndSocialNetworksDB[Web],NetName))
	    break;
      if (Web < Net_NUM_WEBS_AND_SOCIAL_NETWORKS)
	{
	 /* Get number of users (row[1]) */
	 if (sscanf (row[1],"%u",&NumUsrs) != 1)
	    Lay_ShowErrorAndExit ("Error when getting number of files.");

	 fprintf (Gbl.F.Out,"<tr>"
			    "<td class=\"DAT LEFT_MIDDLE\">"
			    "<img src=\"%s/%s\""
			    " alt=\"%s\" title=\"%s\""
                            " class=\"CONTEXT_ICO_16x16\""
			    " style=\"margin-right:6px;\" />"
			    "%s</td>"
			    "<td class=\"DAT RIGHT_MIDDLE\">"
			    "%u"
			    "</td>"
			    "<td class=\"DAT RIGHT_MIDDLE\">"
			    "%.2f%%"
			    "</td>"
			    "</tr>",
		  Cfg_URL_ICON_PUBLIC,Net_WebsAndSocialNetworksIcons[Web],
		  Net_WebsAndSocialNetworksTitle[Web],
		  Net_WebsAndSocialNetworksTitle[Web],
		  Net_WebsAndSocialNetworksTitle[Web],
		  NumUsrs,
		  NumUsrsTotal ? 100.0 * (float) NumUsrs / (float) NumUsrsTotal :
			         0.0);
	}
     }

   /***** End table and box *****/
   Box_EndBoxTable ();

   /***** Free structure that stores the query result *****/
   DB_FreeMySQLResult (&mysql_res);
  }
Example #8
0
void Net_ShowFormMyWebsAndSocialNets (void)
  {
   extern const char *Hlp_PROFILE_Webs;
   extern const char *The_ClassFormInBox[The_NUM_THEMES];
   extern const char *Txt_Webs_social_networks;
   extern const char *Txt_Save_changes;
   MYSQL_RES *mysql_res;
   MYSQL_ROW row;
   Net_WebsAndSocialNetworks_t NumURL;
   char URL[Cns_MAX_BYTES_WWW + 1];
   char StrRecordWidth[10 + 1];

   /***** Start section *****/
   Lay_StartSection (Net_MY_WEBS_ID);

   /***** Start box *****/
   snprintf (StrRecordWidth,sizeof (StrRecordWidth),
	     "%upx",
	     Rec_RECORD_WIDTH);
   Box_StartBox (StrRecordWidth,Txt_Webs_social_networks,
	         Net_PutIconsWebsSocialNetworks,
                 Hlp_PROFILE_Webs,Box_NOT_CLOSABLE);

   /***** Start table *****/
   Tbl_StartTable (2);

   /***** Start form *****/
   Frm_StartFormAnchor (ActChgMyNet,Net_MY_WEBS_ID);

   /***** List webs and social networks *****/
   for (NumURL = (Net_WebsAndSocialNetworks_t) 0;
	NumURL < Net_NUM_WEBS_AND_SOCIAL_NETWORKS;
	NumURL++)
     {
      /***** Get user's web / social network from database *****/
      if (DB_QuerySELECT (&mysql_res,"can not get user's web / social network",
			  "SELECT URL FROM usr_webs"
			  " WHERE UsrCod=%ld AND Web='%s'",
			  Gbl.Usrs.Me.UsrDat.UsrCod,
			  Net_WebsAndSocialNetworksDB[NumURL]))
	{
	 /***** Read the data comunes a all the users *****/
	 row = mysql_fetch_row (mysql_res);

	 /* Get URL */
	 Str_Copy (URL,row[0],
	           Cns_MAX_BYTES_WWW);
	}
      else
	 URL[0] = '\0';

      /***** Free structure that stores the query result *****/
      DB_FreeMySQLResult (&mysql_res);

      /***** Row for this web / social network *****/
      fprintf (Gbl.F.Out,"<tr>"

			 "<td class=\"REC_C1_BOT LEFT_MIDDLE\">"
			 "<label for=\"URL%u\" class=\"%s\">"
			 "<img src=\"%s/%s\""
			 " alt=\"%s\" title=\"%s\""
                         " class=\"CONTEXT_ICO_16x16\""
			 " style=\"margin-right:6px;\" />"
			 "%s:"
			 "</label>"
			 "</td>"

			 "<td class=\"REC_C2_BOT LEFT_MIDDLE\">"
			 "<input type=\"url\" id=\"URL%u\" name=\"URL%u\""
			 " maxlength=\"%u\" value=\"%s\""
		         " class=\"REC_C2_BOT_INPUT\" />"
			 "</td>"

			 "</tr>",
	       (unsigned) NumURL,The_ClassFormInBox[Gbl.Prefs.Theme],
	       Cfg_URL_ICON_PUBLIC,Net_WebsAndSocialNetworksIcons[NumURL],
	       Net_WebsAndSocialNetworksTitle[NumURL],
	       Net_WebsAndSocialNetworksTitle[NumURL],
	       Net_WebsAndSocialNetworksTitle[NumURL],
	       (unsigned) NumURL,(unsigned) NumURL,
	       Cns_MAX_CHARS_WWW,URL);
     }

   /***** End table *****/
   Tbl_EndTable ();

   /***** Confirm button *****/
   Btn_PutConfirmButton (Txt_Save_changes);

   /***** End form *****/
   Frm_EndForm ();

   /***** End box *****/
   Box_EndBox ();

   /***** End section *****/
   Lay_EndSection ();
  }