Exemple #1
0
 /**
  * When checking all Event models make sure there is a UUID if not create one
  */
 public function checkDatabase()
 {
     if (empty($this->uuid)) {
         $this->uuid = \GO\Base\Util\UUID::create('event', $this->id);
     }
     //in some cases on old databases the repeat_end_time is set but the UNTIL property in the rrule is not. We correct that here.
     if ($this->repeat_end_time > 0 && strpos($this->rrule, 'UNTIL=') === false) {
         $rrule = new \GO\Base\Util\Icalendar\Rrule();
         $rrule->readIcalendarRruleString($this->start_time, $this->rrule);
         $rrule->until = $this->repeat_end_time;
         $this->rrule = $rrule->createRrule();
     }
     parent::checkDatabase();
 }
Exemple #2
0
 protected function afterDbInsert()
 {
     if (empty($this->uuid)) {
         $this->uuid = \GO\Base\Util\UUID::create('task', $this->id);
         return true;
     } else {
         return false;
     }
 }
Exemple #3
0
 /**
  * Get this task as a VObject. This can be turned into a vcard file data.
  * 
  * @return Sabre_VObject_Component 
  */
 public function toVObject()
 {
     $e = new Sabre\VObject\Component\VCard();
     $e->prodid = '-//Intermesh//NONSGML Group-Office ' . \GO::config()->version . '//EN';
     if (empty($this->uuid)) {
         $this->uuid = \GO\Base\Util\UUID::create('contact', $this->id);
         $this->save(true);
     }
     $e->uid = $this->uuid;
     $e->add('N', array($this->last_name, $this->first_name, $this->middle_name, $this->title, $this->suffix));
     $e->add('FN', $this->name);
     if (!empty($this->email)) {
         //			$p = new Sabre\VObject\Property('EMAIL',$this->email);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','INTERNET'));
         //			$e->add($p);
         $e->add('email', $this->email, array('type' => array('INTERNET')));
     }
     if (!empty($this->email2)) {
         //			$p = new Sabre\VObject\Property('EMAIL',$this->email2);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','HOME,INTERNET'));
         //			$e->add($p);
         $e->add('email', $this->email2, array('type' => array('HOME', 'INTERNET')));
     }
     if (!empty($this->email3)) {
         //			$p = new Sabre\VObject\Property('EMAIL',$this->email3);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','WORK,INTERNET'));
         //			$e->add($p);
         $e->add('email', $this->email3, array('type' => array('WORK', 'INTERNET')));
     }
     if (!empty($this->function)) {
         $e->add('TITLE', $this->function);
     }
     if (!empty($this->home_phone)) {
         //			$p = new Sabre\VObject\Property('TEL',$this->home_phone);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','HOME,VOICE'));
         //			$e->add($p);
         $e->add('TEL', $this->home_phone, array('type' => array('HOME', 'VOICE')));
     }
     if (!empty($this->work_phone)) {
         //			$p = new Sabre\VObject\Property('TEL',$this->work_phone);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','WORK,VOICE'));
         //			$e->add($p);
         $e->add('TEL', $this->work_phone, array('type' => array('WORK', 'VOICE')));
     }
     if (!empty($this->work_fax)) {
         //			$p = new Sabre\VObject\Property('TEL',$this->work_fax);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','WORK,FAX'));
         //			$e->add($p);
         $e->add('TEL', $this->work_fax, array('type' => array('WORK', 'FAX')));
     }
     if (!empty($this->fax)) {
         //			$p = new Sabre\VObject\Property('TEL',$this->fax);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','HOME,FAX'));
         //			$e->add($p);
         $e->add('TEL', $this->fax, array('type' => array('HOME', 'FAX')));
     }
     if (!empty($this->cellular)) {
         //			$p = new Sabre\VObject\Property('TEL',$this->cellular);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','CELL,VOICE'));
         //			$e->add($p);
         $e->add('TEL', $this->cellular, array('type' => array('CELL', 'VOICE')));
     }
     if (!empty($this->cellular2)) {
         //			$p = new Sabre\VObject\Property('TEL',$this->cellular2);
         //			$p->add(new \GO\Base\VObject\Parameter('TYPE','CELL,VOICE'));
         //			$e->add($p);
         $e->add('TEL', $this->cellular2, array('type' => array('CELL', 'VOICE')));
     }
     if (!empty($this->birthday)) {
         $e->add('BDAY', $this->birthday);
     }
     if (!empty($this->homepage)) {
         $e->add('URL', $this->homepage);
     }
     if (!empty($this->company)) {
         //			$e->add('ORG',$this->company->name,$this->department,$this->company->name2);
         //			$p = new Sabre\VObject\Property('ADR',';;'.$this->company->address.' '.$this->company->address_no,
         //				$this->company->city,$this->company->state,$this->company->zip,$this->company->country);
         //			$p->add('TYPE','WORK');
         //			$e->add($p);
         $e->add('ORG', array($this->company->name, $this->department, $this->company->name2));
         $e->add('ADR', array('', '', $this->company->address . ' ' . $this->company->address_no, $this->company->city, $this->company->state, $this->company->zip, $this->company->country), array('type' => 'WORK'));
         //			$p = new Sabre\VObject\Property('ADR',';;'.$this->company->post_address.' '.$this->company->post_address_no,
         //				$this->company->post_city,$this->company->post_state,$this->company->post_zip,$this->company->post_country);
         //			$e->add($p);
         $e->add('ADR', array('', '', $this->company->post_address . ' ' . $this->company->post_address_no, $this->company->post_city, $this->company->post_state, $this->company->post_zip, $this->company->post_country), array('type' => 'WORK'));
     }
     //		$p = new Sabre\VObject\Property('ADR',';;'.$this->address.' '.$this->address_no,
     //			$this->city,$this->state,$this->zip,$this->country);
     //		$p->add('TYPE','HOME');
     //		$e->add($p);
     //
     $e->add('ADR', array('', '', $this->address . ' ' . $this->address_no, $this->city, $this->state, $this->zip, $this->country), array('type' => 'HOME'));
     if (!empty($this->comment)) {
         $e->note = $this->comment;
     }
     //		$mtimeDateTime = new \DateTime('@'.$this->mtime);
     //		$rev = new Sabre_VObject_Element_DateTime('LAST-MODIFIED');
     //		$rev->setDateTime($mtimeDateTime, Sabre_VObject_Element_DateTime::UTC);
     //		$e->add($rev);
     $e->rev = gmdate("Y-m-d\\TH:m:s\\Z", $this->mtime);
     if ($this->getPhotoFile()->exists()) {
         $e->add('photo', $this->getPhotoFile()->getContents(), array('type' => 'JPEG', 'encoding' => 'b'));
     }
     //		$propModels = $this->vcardProperties->fetchAll(PDO::FETCH_ASSOC);
     //
     //		foreach ($propModels as $propModel) {
     //			$p = new Sabre\VObject\Property($propModel['name'],$propModel['value']);
     //			if(!empty($propModel['parameters'])){
     //				$paramStrings = explode(';',$propModel['parameters']);
     //				foreach ($paramStrings as $paramString) {
     //					if(!empty($paramString)){
     //						$paramStringArr = explode('=',$paramString);
     //
     //						$param = new \GO\Base\VObject\Parameter($paramStringArr[0]);
     //						if (!empty($paramStringArr[1]))
     //							$param->getValue() = $paramStringArr[1];
     //						$p->add($param);
     //					}
     //				}
     //			}
     //			$e->add($p);
     //		}
     return $e;
 }