123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- class Contact extends Entity{
- public $id,$label,$phone,$birth,$hour,$manager,$author,$address,$vehicle,$story,$storyShort,$login,$password,$icon,$mycheckbox1;
- protected $TABLE_NAME = 'plugin_contact';
- public $fields =
- array(
- 'id' => 'key',
- 'label' => 'string',
- 'phone' => 'string',
- 'birth' => 'date',
- 'hour' => 'date',
- 'manager'=> 'string',
- 'author' => 'string',
- 'address' => 'string',
- 'vehicle' => 'int',
- 'story' => 'longstring',
- 'storyShort' => 'longstring',
- 'login' => 'string',
- 'password' => 'string',
- 'icon'=>'string',
- 'mycheckbox1'=>'boolean'
- );
-
- function picture(){
- return $this->get_image();
- }
- function get_image($key=null){
- $finded = false;
- $image = array();
- $paths = array(
- 'jpg' => FILE_PATH.'contact'.SLASH.$this->id.'.jpg',
- 'png' => FILE_PATH.'contact'.SLASH.$this->id.'.png',
- 'jpeg' => FILE_PATH.'contact'.SLASH.$this->id.'.jpeg',
- );
- $image['url'] = $image['path'] = 'img'.SLASH.'default-avatar.png';
- foreach ($paths as $extension => $path) {
- if (file_exists( __ROOT__.$path) && !$finded) {
- $image['path'] = __ROOT__.$path;
- $finded = true;
- $image['url'] = 'action.php?action=contact_download_picture&contact='.$this->id.'&extension='.$extension;
- }
- }
- return isset($key) && isset($image[$key]) ? $image[$key] : $image['url'];
- }
- function documents(){
- $documents = array();
- foreach(glob(__ROOT__.FILE_PATH.'contact'.SLASH.'documents'.SLASH.$this->id.SLASH.'*.*') as $file){
- if(get_OS() === 'WIN') $file = utf8_encode($file);
- $documents[] = array(
- 'path' => 'contact'.SLASH.'documents'.SLASH.$this->id.SLASH.basename($file),
- 'url' => 'action.php?action=contact_download_document&path='.$this->id.SLASH.rawurlencode(basename($file)),
- 'name' => basename($file),
- 'icon' => getExtIcon(getExt($file))
- );
- }
- return $documents;
- }
- }
- ?>
|