linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file class.yellowpages.php

Documentation is available at class.yellowpages.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage yellowpages
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Yellowpages Management
  10.  */
  11.  
  12. class yellowpages {
  13.   /* @param
  14.    * */
  15.   var $TDB_YELLOWPAGES = T_YELLOWPAGES// nom de la table.
  16.   var $ID;
  17.   var $NAME;
  18.   var $ACTIVITY;
  19.   var $THEME;
  20.   var $STREET;
  21.   var $POSTAL_CODE;
  22.   var $CITY;
  23.   var $COUNTRY;
  24.   var $PHONE;
  25.   var $FAX;
  26.   var $EMAIL;
  27.   var $WEBSITE;
  28.   var $DATE_CREA;
  29.   var $LAST_MODIFY;
  30.   var $STATUT;
  31.  
  32.   /**
  33.    * yellowpages::CheckDataIntegrity()
  34.    * Vérification des données d'une entreprise
  35.    *
  36.    * @access public
  37.    * @param array $table_yp : contient les composants d'une entreprise
  38.    * @return boolean si ok renvoie true sinon message d'erreurs (string)
  39.    */
  40.   function CheckDataIntegrity($table)
  41.   {
  42.     $notname _t('yp','object_notname');
  43.     $notactivity _t('yp','object_notactivity');
  44.     $notstreet _t('yp','object_notstreet');
  45.     $notpostal_code _t('yp','object_notpostal_code');
  46.     $notcity _t('yp','object_notcity');
  47.     //$notcountry = _t('yp','object_notcountry');
  48.     $notemail _t('yp','object_notemail');
  49.     $notphone _t('yp','object_notphone');
  50.     $notfax _t('yp','object_notfax');
  51.  
  52.     if (strlen($table[0]2return $notname;
  53.     if (strlen($table[1]2return $notactivity;
  54.     if (strlen($table[3]2return $notstreet;
  55.     if (strlen($table[4]2return $notpostal_code;
  56.     if (strlen($table[5]2return $notcity;
  57.     //if (strlen($table[6]) < 2) return $notcountry;
  58.  
  59.     $testmail $this->_checkEmailValidity($table[9]);
  60.     if ($testmail != 1return $notemail;
  61.  
  62.     if (trim($table[7]!= '' && !is_numeric($table[7])) return $notphone;
  63.     if (trim($table[8]!= '' && !is_numeric($table[8])) return $notfax;
  64.     return true;
  65.   }
  66.  
  67.   /**
  68.    * yellowpages::_checkEmailValidity()
  69.    * Vérification de la grammaire du mail
  70.    *
  71.    * @access private
  72.    * @param string $email 
  73.    * @return int 1 ou 0
  74.    */
  75.   function _checkEmailValidity($email)
  76.   {
  77.     $email strtolower($email);
  78.     if (strlen($email|| !ereg("@"$email|| preg_match_all("/([^a-zA-Z0-9_\@\.\-])/i"$email$trouve|| !preg_match("/^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$/i"$email)) {
  79.       return 0;
  80.     }
  81.     return 1;
  82.   }
  83.  
  84.   /**
  85.    * yellowpages::AddYellowPages()
  86.    * Ajout d'une nouvelle entreprise dans l'annuaire
  87.    *
  88.    * @access public
  89.    * @param array $table contient les composants d'une organisation
  90.    * @param object $sql_object 
  91.    * @return integer $last_id
  92.    */
  93.   function AddYellowPages($table$sql_object)
  94.   {
  95.     $table=$sql_object->DBescape($table);
  96.  
  97.     $this->NAME = strip_input($table[0]);
  98.     $this->ACTIVITY = strip_input($table[1]);
  99.     $this->THEME = $table[2];
  100.     $this->STREET = strip_input($table[3]);
  101.     $this->POSTAL_CODE = strip_input($table[4]);
  102.     $this->CITY = strip_input($table[5]);
  103.     $this->COUNTRY = strip_input($table[6]);
  104.     $this->PHONE = strip_input($table[7]);
  105.     $this->FAX = strip_input($table[8]);
  106.     $this->EMAIL = strip_input($table[9]);
  107.     $this->WEBSITE = strip_input($table[10]);
  108.  
  109.     if ($table[11!= ''{
  110.       $table[11strtoupper($table[11]);
  111.       switch ($table[11]{
  112.         case 'P':
  113.           $this->STATUT = $table[11];
  114.           break;
  115.         case 'AA':
  116.           $this->STATUT = $table[11];
  117.           break;
  118.         case 'D':
  119.           $this->STATUT = $table[11];
  120.           break;
  121.         default:
  122.           $this->STATUT = 'AA';
  123.           break;
  124.       }
  125.     else $this->STATUT = 'AA';
  126.  
  127.     $requete "INSERT INTO " $this->TDB_YELLOWPAGES . " (yellowp_name, yellowp_activity, yellowp_theme, yellowp_street, " "yellowp_postal_code, yellowp_city, yellowp_country, yellowp_phone, yellowp_fax, yellowp_email, " "yellowp_website,  yellowp_statut, yellowp_date_crea) " "VALUES('" $this->NAME . "', '" $this->ACTIVITY . "', " $this->THEME . ", '" $this->STREET . "', '" $this->POSTAL_CODE . "', '" $this->CITY . "', '" $this->COUNTRY . "', '" $this->PHONE . "', '" $this->FAX . "', '" $this->EMAIL . "', '" $this->WEBSITE . "', '" $this->STATUT . "', NOW());";
  128.     $last_id $sql_object->DBInsert ($requete1);
  129.     return $last_id;
  130.   }
  131.  
  132.   /**
  133.    * yellowpages::StateYellowPages()
  134.    * modification du statut d'une organisation
  135.    *
  136.    * @access public
  137.    * @param int $ID identifiant de l'organisation
  138.    * @param string $state (facultatif) 'P' Public/'D' Draft/'AA' AdminArchive/'PA' PublicArchive
  139.    * @param object $sql_object 
  140.    * @return bool $result
  141.    */
  142.  
  143.   function StateYellowPages($ID$state$sql_object)
  144.   {
  145.     if (is_numeric($ID)) {
  146.       $this->ID = $ID;
  147.     }
  148.     $this->STATUT = $state;
  149.  
  150.     $requete "UPDATE  " $this->TDB_YELLOWPAGES . " set yellowp_statut='" $this->STATUT . "' WHERE yellowp_id=" $this->ID . ";";
  151.     $result $sql_object->DBQuery($requete);
  152.     return $result;
  153.   }
  154.  
  155.  
  156.   /*
  157.    * yellowpages::DeleteYellowPages()
  158.    * suppression d'une organisatione
  159.    *
  160.    * @access public
  161.    * @param int $ID identifiant de l'organisation
  162.    * @param object $sql_object
  163.    * @return bool $result
  164.    */
  165.   function DeleteYellowPages($ID$sql_object)
  166.   {
  167.     $this->ID = $ID;
  168.     $requete "UPDATE " $this->TDB_YELLOWPAGES . " SET yellowp_statut='E', yellowp_last_modify = NOW() WHERE yellowp_id=" $this->ID . ";";
  169.     $result $sql_object->DBQuery ($requete);
  170.     return $result;
  171.   }
  172.  
  173.   /**
  174.    * yellowpages::ModifyYellowPages()
  175.    * modification d'une organisation
  176.    *
  177.    * @access public
  178.    * @param int $ID identifiant de l'organisation
  179.    * @param array $table contient les composants d'une entreprise
  180.    * @param object $sql_object 
  181.    * @return bool $result
  182.    */
  183.   function ModifyYellowPages($ID$table$sql_object)
  184.   {
  185.     $table=$sql_object->DBescape($table);
  186.  
  187.     $this->ID = $ID;
  188.     $this->NAME = strip_input($table[0]);
  189.     $this->ACTIVITY = strip_input($table[1]);
  190.     $this->THEME = $table[2];
  191.     $this->STREET = strip_input($table[3]);
  192.     $this->POSTAL_CODE = strip_input($table[4]);
  193.     $this->CITY = strip_input($table[5]);
  194.     $this->COUNTRY = strip_input($table[6]);
  195.     $this->PHONE = strip_input($table[7]);
  196.     $this->FAX = strip_input($table[8]);
  197.     $this->EMAIL = strip_input($table[9]);
  198.     $this->WEBSITE = strip_input($table[10]);
  199.  
  200.     if ($table[11!= ''{
  201.       $table[11]=strtoupper($table[11]);
  202.       switch ($table[11]{
  203.         case 'P':
  204.           $this->STATUT = $table[11];
  205.           break;
  206.         case 'AA':
  207.           $this->STATUT = $table[11];
  208.           break;
  209.         case 'D':
  210.           $this->STATUT = $table[11];
  211.           break;
  212.         default:
  213.           $this->STATUT = 'AA';
  214.           break;
  215.       }
  216.     else $this->STATUT = 'AA';
  217.  
  218.     $requete "UPDATE  " $this->TDB_YELLOWPAGES . " set yellowp_name='" $this->NAME . "', yellowp_activity='" $this->ACTIVITY . "' , yellowp_theme=" $this->THEME . ", yellowp_street='" $this->STREET . "', yellowp_postal_code='" $this->POSTAL_CODE . "', yellowp_city='" $this->CITY . "', yellowp_country='" $this->COUNTRY . "', yellowp_phone='" $this->PHONE . "', yellowp_fax='" $this->FAX . "', yellowp_email='" $this->EMAIL . "', yellowp_website='" $this->WEBSITE . "', yellowp_statut='" $this->STATUT . "', yellowp_last_modify = NOW() WHERE yellowp_id=" $this->ID . ";";
  219.  
  220.     $result $sql_object->DBQuery($requete);
  221.  
  222.     return $result;
  223.   }
  224.  
  225.  
  226. }
  227.  
  228. ?>

Documentation generated on Fri, 16 Oct 2009 09:30:46 +0200 by phpDocumentor 1.4.1