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.   protected $dispatcher = null;
  32.  
  33.   public function __construct()
  34.   {
  35.     $this->dispatcher = $GLOBALS['dispatcher'];
  36.   }
  37.  
  38.   public function __call($method$arguments)
  39.   {
  40.     $event $this->dispatcher->notifyUntil(new sfEvent($this'yellowpages.extensible_function'array(
  41.       'method'    => $method,
  42.       'arguments' => $arguments
  43.     )));
  44.     if (!$event->isProcessed())
  45.     {
  46.       throw new Exception(sprintf('Call to undefined method %s::%s.'get_class($this)$method));
  47.     }
  48.  
  49.     return $event->getReturnValue();
  50.   }
  51.  
  52.   /**
  53.    * yellowpages::CheckDataIntegrity()
  54.    * Vérification des données d'une entreprise
  55.    *
  56.    * @access public
  57.    * @param array $table_yp : contient les composants d'une entreprise
  58.    * @return boolean si ok renvoie true sinon message d'erreurs (string)
  59.    */
  60.   function CheckDataIntegrity($table)
  61.   {
  62.     $notname _t('yp','object_notname');
  63.     $notactivity _t('yp','object_notactivity');
  64.     $notstreet _t('yp','object_notstreet');
  65.     $notpostal_code _t('yp','object_notpostal_code');
  66.     $notcity _t('yp','object_notcity');
  67.     //$notcountry = _t('yp','object_notcountry');
  68.     $notemail _t('yp','object_notemail');
  69.     $notphone _t('yp','object_notphone');
  70.     $notfax _t('yp','object_notfax');
  71.  
  72.     if (strlen($table[0]2return $notname;
  73.     if (strlen($table[1]2return $notactivity;
  74.     if (strlen($table[3]2return $notstreet;
  75.     if (strlen($table[4]2return $notpostal_code;
  76.     if (strlen($table[5]2return $notcity;
  77.     //if (strlen($table[6]) < 2) return $notcountry;
  78.  
  79.     $testmail $this->_checkEmailValidity($table[9]);
  80.     if ($testmail===falsereturn $notemail;
  81.  
  82.     if (trim($table[7]!= '' && !is_numeric($table[7])) return $notphone;
  83.     if (trim($table[8]!= '' && !is_numeric($table[8])) return $notfax;
  84.     return true;
  85.   }
  86.  
  87.   /**
  88.    * yellowpages::_checkEmailValidity()
  89.    * Vérification de la grammaire du mail
  90.    *
  91.    * @access private
  92.    * @param string $email 
  93.    * @return int 1 ou 0
  94.    */
  95.   function _checkEmailValidity($email)
  96.   {
  97.     return validEmail($email);
  98.   }
  99.  
  100.   /**
  101.    * yellowpages::AddYellowPages()
  102.    * Ajout d'une nouvelle entreprise dans l'annuaire
  103.    *
  104.    * @access public
  105.    * @param array $table contient les composants d'une organisation
  106.    * @param object $sql_object 
  107.    * @return integer $last_id
  108.    */
  109.   function AddYellowPages($table$sql_object)
  110.   {
  111.     $table=$sql_object->DBescape($table);
  112.  
  113.     $this->NAME = strip_input($table[0]);
  114.     $this->ACTIVITY = strip_input($table[1]);
  115.     $this->THEME = $table[2];
  116.     $this->STREET = strip_input($table[3]);
  117.     $this->POSTAL_CODE = strip_input($table[4]);
  118.     $this->CITY = strip_input($table[5]);
  119.     $this->COUNTRY = strip_input($table[6]);
  120.     $this->PHONE = strip_input($table[7]);
  121.     $this->FAX = strip_input($table[8]);
  122.     $this->EMAIL = strip_input($table[9]);
  123.     $this->WEBSITE = strip_input($table[10]);
  124.  
  125.     if ($table[11!= ''{
  126.       $table[11strtoupper($table[11]);
  127.       switch ($table[11]{
  128.         case 'P':
  129.           $this->STATUT = $table[11];
  130.           break;
  131.         case 'AA':
  132.           $this->STATUT = $table[11];
  133.           break;
  134.         case 'D':
  135.           $this->STATUT = $table[11];
  136.           break;
  137.         default:
  138.           $this->STATUT = 'AA';
  139.           break;
  140.       }
  141.     else $this->STATUT = 'AA';
  142.  
  143.     $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());";
  144.     $last_id $sql_object->DBInsert ($requete1);
  145.     return $last_id;
  146.   }
  147.  
  148.   /**
  149.    * yellowpages::StateYellowPages()
  150.    * modification du statut d'une organisation
  151.    *
  152.    * @access public
  153.    * @param int $ID identifiant de l'organisation
  154.    * @param string $state (facultatif) 'P' Public/'D' Draft/'AA' AdminArchive/'PA' PublicArchive
  155.    * @param object $sql_object 
  156.    * @return bool $result
  157.    */
  158.  
  159.   function StateYellowPages($ID$state$sql_object)
  160.   {
  161.     if (is_numeric($ID)) {
  162.       $this->ID = $ID;
  163.     }
  164.     $this->STATUT = $state;
  165.  
  166.     $requete "UPDATE  " $this->TDB_YELLOWPAGES . " set yellowp_statut='" $this->STATUT . "' WHERE yellowp_id=" $this->ID . ";";
  167.     $result $sql_object->DBQuery($requete);
  168.     return $result;
  169.   }
  170.  
  171.  
  172.   /*
  173.    * yellowpages::DeleteYellowPages()
  174.    * suppression d'une organisatione
  175.    *
  176.    * @access public
  177.    * @param int $ID identifiant de l'organisation
  178.    * @param object $sql_object
  179.    * @return bool $result
  180.    */
  181.   function DeleteYellowPages($ID$sql_object)
  182.   {
  183.     $this->ID = $ID;
  184.     $requete "UPDATE " $this->TDB_YELLOWPAGES . " SET yellowp_statut='E', yellowp_last_modify = NOW() WHERE yellowp_id=" $this->ID . ";";
  185.     $result $sql_object->DBQuery ($requete);
  186.     return $result;
  187.   }
  188.  
  189.   /**
  190.    * yellowpages::ModifyYellowPages()
  191.    * modification d'une organisation
  192.    *
  193.    * @access public
  194.    * @param int $ID identifiant de l'organisation
  195.    * @param array $table contient les composants d'une entreprise
  196.    * @param object $sql_object 
  197.    * @return bool $result
  198.    */
  199.   function ModifyYellowPages($ID$table$sql_object)
  200.   {
  201.     $table=$sql_object->DBescape($table);
  202.  
  203.     $this->ID = $ID;
  204.     $this->NAME = strip_input($table[0]);
  205.     $this->ACTIVITY = strip_input($table[1]);
  206.     $this->THEME = $table[2];
  207.     $this->STREET = strip_input($table[3]);
  208.     $this->POSTAL_CODE = strip_input($table[4]);
  209.     $this->CITY = strip_input($table[5]);
  210.     $this->COUNTRY = strip_input($table[6]);
  211.     $this->PHONE = strip_input($table[7]);
  212.     $this->FAX = strip_input($table[8]);
  213.     $this->EMAIL = strip_input($table[9]);
  214.     $this->WEBSITE = strip_input($table[10]);
  215.  
  216.     if ($table[11!= ''{
  217.       $table[11]=strtoupper($table[11]);
  218.       switch ($table[11]{
  219.         case 'P':
  220.           $this->STATUT = $table[11];
  221.           break;
  222.         case 'AA':
  223.           $this->STATUT = $table[11];
  224.           break;
  225.         case 'D':
  226.           $this->STATUT = $table[11];
  227.           break;
  228.         default:
  229.           $this->STATUT = 'AA';
  230.           break;
  231.       }
  232.     else $this->STATUT = 'AA';
  233.  
  234.     $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 . ";";
  235.  
  236.     $result $sql_object->DBQuery($requete);
  237.  
  238.     return $result;
  239.   }
  240.  
  241.  
  242. }
  243.  
  244. ?>

Documentation generated on Fri, 01 Apr 2011 09:29:45 +0200 by phpDocumentor 1.4.1