Exemple #1
0
 public function index()
 {
     $this->setPageTitle(OW::getLanguage()->text('contactus', 'index_page_title'));
     $this->setPageHeading(OW::getLanguage()->text('contactus', 'index_page_heading'));
     $contactEmails = array();
     $contacts = CONTACTUS_BOL_Service::getInstance()->getDepartmentList();
     foreach ($contacts as $contact) {
         /* @var $contact CONTACTUS_BOL_Department */
         $contactEmails[$contact->id]['label'] = CONTACTUS_BOL_Service::getInstance()->getDepartmentLabel($contact->id);
         $contactEmails[$contact->id]['email'] = $contact->email;
     }
     $form = new Form('contact_form');
     $fieldTo = new Selectbox('to');
     foreach ($contactEmails as $id => $value) {
         $fieldTo->addOption($id, $value['label']);
     }
     $fieldTo->setRequired();
     $fieldTo->setHasInvitation(false);
     $fieldTo->setLabel($this->text('contactus', 'form_label_to'));
     $form->addElement($fieldTo);
     $fieldFrom = new TextField('from');
     $fieldFrom->setLabel($this->text('contactus', 'form_label_from'));
     $fieldFrom->setRequired();
     $fieldFrom->addValidator(new EmailValidator());
     if (ow::getUser()->isAuthenticated()) {
         $fieldFrom->setValue(OW::getUser()->getEmail());
     }
     $form->addElement($fieldFrom);
     $fieldSubject = new TextField('subject');
     $fieldSubject->setLabel($this->text('contactus', 'form_label_subject'));
     $fieldSubject->setRequired();
     $form->addElement($fieldSubject);
     $fieldMessage = new Textarea('message');
     $fieldMessage->setLabel($this->text('contactus', 'form_label_message'));
     $fieldMessage->setRequired();
     $form->addElement($fieldMessage);
     $fieldCaptcha = new CaptchaField('captcha');
     $fieldCaptcha->setLabel($this->text('contactus', 'form_label_captcha'));
     $form->addElement($fieldCaptcha);
     $submit = new Submit('send');
     $submit->setValue($this->text('contactus', 'form_label_submit'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             if (!array_key_exists($data['to'], $contactEmails)) {
                 OW::getFeedback()->error($this->text('contactus', 'no_department'));
                 return;
             }
             $mail = OW::getMailer()->createMail();
             $mail->addRecipientEmail($contactEmails[$data['to']]['email']);
             $mail->setSender($data['from']);
             $mail->setSenderSuffix(false);
             $mail->setSubject($data['subject']);
             $mail->setTextContent($data['message']);
             OW::getMailer()->addToQueue($mail);
             OW::getSession()->set('contactus.dept', $contactEmails[$data['to']]['label']);
             $this->redirectToAction('sent');
         }
     }
 }
Exemple #2
0
 public function getPhotoList($params)
 {
     $listType = $params['listType'];
     $page = !empty($params['offset']) ? abs((int) $params['offset']) : 1;
     $idList = !empty($params['idList']) ? $params['idList'] : array();
     $photosPerPage = (int) OW::getConfig()->getValue('photo', 'photos_per_page');
     switch ($listType) {
         case 'albumPhotos':
             $photos = $this->photoService->findPhotoListByAlbumId($params['albumId'], $page, $photosPerPage, $idList);
             break;
         case 'userPhotos':
             $photos = $this->photoService->findPhotoListByUserId($params['userId'], $page, $photosPerPage, $idList);
             break;
         case 'tag':
             $tags = BOL_TagDao::getInstance()->findTagsByLabel(array(ltrim($params['searchVal'], '#')));
             if (empty($tags)) {
                 $photos = array();
                 break;
             }
             $params['id'] = $tags[0]->id;
         case 'hash':
             $photos = $this->photoService->findTaggedPhotosByTagId($params['id'], $page, $photosPerPage);
             break;
         case 'user':
             $photos = $this->photoService->findPhotoListByUserId($params['id'], $page, $photosPerPage);
             break;
         case 'desc':
             $photos = $this->photoService->findPhotoListByDesc($params['searchVal'], $params['id'], $page, $photosPerPage);
             break;
         case 'latest':
         case 'featured':
         case 'toprated':
         case 'most_discussed':
             $photos = $this->photoService->findPhotoListByUserId(ow::getUser()->getId(), $page, $photosPerPage, $idList);
             // $photos = $this->photoService->findPhotoList($listType, $page, $photosPerPage);
             break;
         default:
             $event = new OW_Event('photo.getPhotosByListType', array('listType' => $listType, 'page' => $page, 'photosPerPage' => $photosPerPage), array());
             OW::getEventManager()->trigger($event);
             $photos = $event->getData();
             break;
     }
     return $this->generatePhotoList($photos);
 }