Source for file contact.class.php

Documentation is available at contact.class.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @subpackage Contact
  5. @copyright  Refer to copyright.php
  6. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  7. @author Mambo Foundation Inc see README.php
  8. */ 
  9.  
  10. /** ensure this file is being included by a parent file */
  11. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  12.  
  13. include_once$mosConfig_absolute_path .'/includes/vcard.class.php' );
  14.     
  15. class mosContact extends mosDBTable {
  16.     /** @var int Primary key */
  17.     var $id=null;
  18.     /** @var string */
  19.     var $name=null;
  20.     /** @var string */
  21.     var $con_position=null;
  22.     /** @var string */
  23.     var $address=null;
  24.     /** @var string */
  25.     var $suburb=null;
  26.     /** @var string */
  27.     var $state=null;
  28.     /** @var string */
  29.     var $country=null;
  30.     /** @var string */
  31.     var $postcode=null;
  32.     /** @var string */
  33.     var $telephone=null;
  34.     /** @var string */
  35.     var $fax=null;
  36.     /** @var string */
  37.     var $misc=null;
  38.     /** @var string */
  39.     var $image=null;
  40.     /** @var string */
  41.     var $imagepos=null;
  42.     /** @var string */
  43.     var $email_to=null;
  44.     /** @var int */
  45.     var $default_con=null;
  46.     /** @var int */
  47.     var $published=null;
  48.     /** @var int */
  49.     var $checked_out=null;
  50.     /** @var datetime */
  51.     var $checked_out_time=null;
  52.     /** @var int */
  53.     var $ordering=null;
  54.     /** @var string */
  55.     var $params=null;
  56.     /** @var int A link to a registered user */
  57.     var $user_id=null;
  58.     /** @var int A link to a category */
  59.     var $catid=null;
  60.     /** @var int */
  61.     var $access=null;
  62.  
  63.     /**
  64.     * @param database A database connector object
  65.     */
  66.     function mosContact({
  67.         $database mamboDatabase::getInstance();
  68.         $this->mosDBTable'#__contact_details''id'$database );
  69.     }
  70.  
  71.     function check({
  72.         $this->default_con = intval$this->default_con );
  73.         return true;
  74.     }
  75.     
  76.     function &getCategories ($user{
  77.         static $contact_cats '';
  78.         if (!is_array($contact_cats)) {
  79.             $database mamboDatabase::getInstance();
  80.             /* Query to retrieve all categories that belong under the contacts section and that are published. */
  81.             $query "SELECT *, COUNT(a.id) AS numlinks, MIN(a.id) as minimum"
  82.             . "\n FROM #__categories AS cc"
  83.             . "\n LEFT JOIN #__contact_details AS a ON a.catid = cc.id"
  84.             . "\n WHERE a.published='1'"
  85.             . "\n AND cc.section='com_contact_details'"
  86.             . "\n AND cc.published='1'"
  87.             . "\n AND a.access <= '"$user->gid ."'"
  88.             . "\n AND cc.access <= '"$user->gid ."'"
  89.             . "\n GROUP BY cc.id"
  90.             . "\n ORDER BY cc.ordering"
  91.             ;
  92.             $database->setQuery$query );
  93.             $contact_cats $database->loadObjectList();
  94.             if (!$contact_cats$contact_cats array();
  95.         }
  96.         return $contact_cats;
  97.     }
  98.     
  99.     function &getContacts ($catid$user{
  100.         $database mamboDatabase::getInstance();
  101.         $query "SELECT *"
  102.         . "\n FROM #__contact_details"
  103.         . "\n WHERE catid = '"$catid."'"
  104.          . "\n AND published='1'"
  105.          . "\n AND access <= '"$user->gid ."'"
  106.         . "\n ORDER BY ordering"
  107.         ;
  108.         $contacts $database->doSQLget($query'mosContact');
  109.         return $contacts;
  110.     }
  111. }
  112.  
  113. /**
  114. @package Mambo
  115. *  class needed to extend vcard class and to correct minor errors
  116. */
  117. class MambovCard extends vCard {
  118.  
  119.     // needed to fix bug in vcard class
  120.     function setName$family=''$first=''$additional=''$prefix=''$suffix='' {
  121.         $this->properties["N"]     "$family;$first;$additional;$prefix;$suffix";
  122.         $this->setFormattedNametrim"$prefix $first $additional $family $suffix) );
  123.     }
  124.  
  125.     // needed to fix bug in vcard class
  126.     function setAddress$postoffice=''$extended=''$street=''$city=''$region=''$zip=''$country=''$type='HOME;POSTAL' {
  127.         // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
  128.         $key     'ADR';
  129.         if $type != '' {
  130.             $key    .= ';'$type;
  131.         }
  132.         $key.= ';ENCODING=QUOTED-PRINTABLE';
  133.         $this->properties[$keyencode$extended .';'encode$street .';'encode$city .';'encode$region.';'encode$zip .';'encode$country );
  134.     }
  135.  
  136.     // added ability to set filename
  137.     function setFilename$filename {
  138.         $this->filename = $filename .'.vcf';
  139.     }    
  140.  
  141.     // added ability to set position/title
  142.     function setTitle$title {
  143.         $title     trim$title );
  144.         $this->properties['TITLE']     $title;
  145.     }
  146.  
  147.     // added ability to set organisation/company
  148.     function setOrg$org {
  149.         $org     trim$org );
  150.         $this->properties['ORG']     $org;
  151.     }
  152.  
  153.     function getVCard$sitename {
  154.         $text     "BEGIN:VCARD\r\n";
  155.         $text     .= "VERSION:2.1\r\n";
  156.         foreach$this->properties as $key => $value {
  157.             $text    .= "$key:$value\r\n";
  158.         }
  159.         $text    .= "REV:" .date("Y-m-d"."T"date("H:i:s")"Z\r\n";
  160.         $text    .= "MAILER: ".sprintf(T_('Mambo vCard for %s'),$sitename."\r\n";
  161.         $text    .= "END:VCARD\r\n";
  162.         return $text;
  163.     }
  164.     
  165. }
  166.  
  167. ?>

Documentation generated on Mon, 05 May 2008 16:18:08 +0400 by phpDocumentor 1.4.0