예제 #1
0
 /**
  * Constructor. Sets resource object and the database table. Also sets a list of use templates with fields.
  */
 public function __construct()
 {
     $this->setResource('Daiquiri_Model_Resource_Table');
     $this->getResource()->setTablename('Core_Templates');
     $this->templates = array('auth.register' => array('firstname', 'lastname', 'username', 'link'), 'auth.forgotPassword' => array('firstname', 'lastname', 'username', 'link'), 'auth.validate' => array('firstname', 'lastname', 'username', 'link'), 'auth.confirm' => array('firstname', 'lastname', 'username', 'manager', 'id'), 'auth.reject' => array('firstname', 'lastname', 'username', 'manager', 'id'), 'auth.activate' => array('firstname', 'lastname', 'username', 'id'), 'notification.changePassword' => array('firstname', 'lastname', 'username', 'id'), 'notification.updateUser' => array('firstname', 'lastname', 'username', 'id'), 'contact.submit_user' => array('firstname', 'lastname', 'username'), 'contact.submit_support' => array('firstname', 'lastname', 'username', 'email', 'category', 'subject', 'message', 'link'), 'contact.respond' => array('subject', 'body'), 'query.plan' => array('firstname', 'lastname', 'email', 'sql', 'plan', 'message'), 'meetings.validate' => array('meeting', 'firstname', 'lastname', 'link'));
     if (in_array('meetings', Daiquiri_Config::getInstance()->getApplication()->resources->modules->toArray())) {
         $participantDetailKeysModel = new Meetings_Model_ParticipantDetailKeys();
         $contributionTypesModel = new Meetings_Model_ContributionTypes();
         $this->templates['meetings.register'] = array_merge(array('meeting', 'firstname', 'lastname', 'affiliation', 'email', 'arrival', 'departure'), $participantDetailKeysModel->getResource()->fetchValues('key'));
         foreach ($contributionTypesModel->getResource()->fetchValues('contribution_type') as $contribution_type) {
             $this->templates['meetings.register'][] = $contribution_type . '_title';
             $this->templates['meetings.register'][] = $contribution_type . '_abstract';
         }
     }
 }
예제 #2
0
파일: Init.php 프로젝트: vrtulka23/daiquiri
 /**
  * Initializes the database with the init data for the meetings module.
  */
 public function init()
 {
     // create contribution types
     $meetingsContributionTypeModel = new Meetings_Model_ContributionTypes();
     if ($meetingsContributionTypeModel->getResource()->countRows() == 0) {
         foreach ($this->_init->options['init']['meetings']['contributionTypes'] as $contributionType) {
             $a = array('contribution_type' => $contributionType);
             $r = $meetingsContributionTypeModel->create($a);
             $this->_check($r, $a);
         }
     }
     // create participant detail keys
     $meetingsParticipantDetailKeyModel = new Meetings_Model_ParticipantDetailKeys();
     if ($meetingsParticipantDetailKeyModel->getResource()->countRows() == 0) {
         foreach ($this->_init->options['init']['meetings']['participantDetailKeys'] as $a) {
             $a['type_id'] = array_search($a['type'], Meetings_Model_ParticipantDetailKeys::$types);
             unset($a['type']);
             $r = $meetingsParticipantDetailKeyModel->create($a);
             $this->_check($r, $a);
         }
     }
     // create participant status
     $meetingsParticipantStatusModel = new Meetings_Model_ParticipantStatus();
     if ($meetingsParticipantStatusModel->getResource()->countRows() == 0) {
         foreach ($this->_init->options['init']['meetings']['participantStatus'] as $participantStatus) {
             $a = array('status' => $participantStatus);
             $r = $meetingsParticipantStatusModel->create($a);
             $this->_check($r, $a);
         }
     }
     // create meetings
     $meetingsMeetingModel = new Meetings_Model_Meetings();
     if ($meetingsMeetingModel->getResource()->countRows() == 0) {
         foreach ($this->_init->options['init']['meetings']['meetings'] as $a) {
             $a['contribution_type_id'] = array();
             foreach ($a['contribution_types'] as $contribution_type) {
                 $id = $meetingsContributionTypeModel->getResource()->fetchId(array('where' => array('`contribution_type` = ?' => $contribution_type)));
                 $a['contribution_type_id'][] = $id;
             }
             unset($a['contribution_types']);
             $a['participant_detail_key_id'] = array();
             foreach ($a['participant_detail_keys'] as $participant_detail_key) {
                 $id = $meetingsParticipantDetailKeyModel->getResource()->fetchId(array('where' => array('`key` = ?' => $participant_detail_key)));
                 $a['participant_detail_key_id'][] = $id;
             }
             unset($a['participant_detail_keys']);
             $r = $meetingsMeetingModel->create($a);
             $this->_check($r, $a);
         }
     }
     // create participants
     $meetingsParticipantsModel = new Meetings_Model_Participants();
     if ($meetingsParticipantsModel->getResource()->countRows() == 0) {
         $participantStatusIds = array_flip($meetingsParticipantStatusModel->getResource()->fetchValues('status'));
         foreach ($this->_init->options['init']['meetings']['participants'] as $a) {
             $slug = $a['meeting_slug'];
             unset($a['meeting_slug']);
             $a['status_id'] = $participantStatusIds[$a['status']];
             unset($a['status']);
             $r = $meetingsParticipantsModel->create($slug, $a);
             $this->_check($r, $a);
         }
     }
 }
예제 #3
0
 /**
  * Updates an meeting.
  * @param int $id id of the meeting
  * @param array $formParams
  * @return array $response
  */
 public function update($id, array $formParams = array())
 {
     // get meeting from teh database
     $entry = $this->getResource()->fetchRow($id);
     if (empty($entry)) {
         throw new Daiquiri_Exception_NotFound();
     }
     // get models
     $contributionTypeModel = new Meetings_Model_ContributionTypes();
     $participantDetailKeysModel = new Meetings_Model_ParticipantDetailKeys();
     // get roles
     $roles = array_merge(array(0 => 'not published'), Daiquiri_Auth::getInstance()->getRoles());
     // create the form object
     $form = new Meetings_Form_Meetings(array('submit' => 'Update meeting', 'contributionTypes' => $contributionTypeModel->getResource()->fetchValues('contribution_type'), 'participantDetailKeys' => $participantDetailKeysModel->getResource()->fetchValues('key'), 'roles' => $roles, 'entry' => $entry));
     // valiadate the form if POST
     if (!empty($formParams)) {
         if ($form->isValid($formParams)) {
             // get the form values
             $values = $form->getValues();
             // store the values in the database
             $this->getResource()->updateRow($id, $values);
             return array('status' => 'ok');
         } else {
             return $this->getModelHelper('CRUD')->validationErrorResponse($form);
         }
     }
     return array('form' => $form, 'status' => 'form');
 }