Esempio n. 1
0
 /**
  * Synchronizes new participant entries from calendar to hookup
  *
  * @param \Symfony\Component\EventDispatcher\Event $event
  * @throws \Exception
  */
 public function sync_participant_calendar(\Symfony\Component\EventDispatcher\Event $event)
 {
     $sql_data = $event['sql_ary'];
     $post_id = (int) $sql_data['POST_ID'];
     // Retrieve Hookup for that post:
     $sql = 'SELECT p.topic_id, t.forum_id, t.topic_first_post_id FROM ' . POSTS_TABLE . ' p LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id WHERE post_id = ' . $post_id;
     $result = $this->db->sql_query($sql);
     $row = $this->db->sql_fetchrow($result);
     $this->db->sql_freeresult($result);
     if (!$row || !$this->hookup->load_hookup($row['topic_id'])) {
         throw new \Exception('Loading topic or hookup failed. Post ID: ' . $post_id);
     }
     if (!$this->hookup->hookup_enabled || $post_id != $row['topic_first_post_id']) {
         // Don't sync if the hookup is disabled or the event is not linked to the first post of the topic
         return;
     }
     // Do not enter, if the user is not permitted to use the hookup
     // Ignore permissions, if called for user_id different from current user
     if ($event['user_id'] == $this->user->data['user_id'] && !$this->auth->acl_get('f_hookup', $row['forum_id'])) {
         return;
     }
     // Don't sync if no activedate is set
     if (!$this->hookup->hookup_active_date) {
         return;
     }
     $this->hookup->add_user($sql_data['USER_ID'], $sql_data['COMMENTS']);
     $this->hookup->set_user_date($sql_data['USER_ID'], $this->hookup->hookup_active_date, $this->part_ary_inv[$sql_data['PARTICIPANTS']]);
     $this->hookup->submit(false);
 }
 public function activedate_set($event)
 {
     $topic_data = $event['topic_data'];
     $first_post = intval($topic_data['topic_first_post_id']);
     if (0 == $event['active_date']) {
         // Reset
         $sql = 'SELECT event_id FROM ' . $this->cal_table . ' WHERE post_id = ' . $first_post;
         $result = $this->db->sql_query_limit($sql, 1);
         $event_id = $this->db->sql_fetchfield('event_id');
         $this->db->sql_freeresult($result);
         if (!$event_id) {
             // No event entered, simply skip
             return;
         }
         $sql = 'DELETE FROM ' . $this->cal_table . ' WHERE event_id = ' . $event_id;
         $this->db->sql_query($sql);
         $sql = 'DELETE FROM ' . $this->cal_event_table . ' WHERE id = ' . $event_id;
         $this->db->sql_query($sql);
         $sql = 'DELETE FROM ' . $this->cal_participants_table . ' WHERE post_id = ' . $first_post;
         $this->db->sql_query($sql);
     } else {
         // Copy Date & entries
         if ($this->hookup->topic_id != $event['topic_id']) {
             if ($this->hookup->topic_id != 0) {
                 $this->hookup = new hookup();
             }
             $this->hookup->load_hookup($event['topic_id']);
         }
         //TODO Fortsetzen
     }
 }
Esempio n. 3
0
 public function find_users_for_notification($notification_data, $options = array())
 {
     $options = array_merge(array('ignore_users' => array()), $options);
     // We usually wish to notify the users who are listed in a hookup:
     if (!$this->hookup->topic_id == $notification_data['topic_id']) {
         if ($this->hookup->topic_id) {
             // If we are actually using the hookup for some other topic, this will ensure we don't break its use - stupid bugs
             $this->hookup = clone $this->hookup;
         }
         $this->hookup->load_hookup($notification_data['topic_id']);
     }
     $users = array_keys($this->hookup->hookup_users);
     if (empty($users)) {
         // Maybe the data was entered by someone else?
         return array();
     }
     $users = array_unique($users);
     return $this->check_user_notification_options($users, $options);
 }
Esempio n. 4
0
 /**
  * Displays hookup data in posting.php
  *
  * @param unknown $event
  */
 public function posting_display_template($event)
 {
     // Check permissions
     if (!$this->auth->acl_get('f_hookup', $event['forum_id']) && !$this->auth->acl_get('m_edit', $event['forum_id'])) {
         return;
     }
     // Check for first post
     if (isset($event['post_data']['topic_first_post_id']) && (!isset($event['post_data']['post_id']) || $event['post_data']['topic_first_post_id'] != $event['post_data']['post_id'])) {
         return;
     }
     $this->user->add_lang_ext('gn36/hookup', 'hookup');
     if (isset($event['topic_id']) && $event['topic_id']) {
         $this->hookup->load_hookup($event['topic_id']);
     }
     $is_inactive = !empty($this->hookup->hookup_users) || !empty($this->hookup->hookup_dates);
     $is_inactive = $is_inactive && $this->hookup->hookup_enabled == false;
     $this->template->assign_vars(array('S_HOOKUP_ALLOWED' => true, 'S_TOPIC_HAS_HOOKUP' => $this->hookup->hookup_enabled, 'S_TOPIC_HAS_INACTIVE_HOOKUP' => $is_inactive, 'S_HOOKUP_CHECKED' => $this->hookup->hookup_enabled ? "checked='checked'" : '', 'S_HOOKUP_SELF_INVITE_CHECKED' => $this->hookup->hookup_self_invite ? "checked='checked'" : '', 'S_HOOKUP_AUTORESET_CHECKED' => $this->hookup->hookup_autoreset ? "checked='checked'" : ''));
 }
Esempio n. 5
0
 /**
  * Process status changes
  * @param \phpbb\event\data $event
  * @param bool $is_member
  */
 protected function process_status($event, $is_member)
 {
     $availables = $this->request->variable('available', array(0 => 0));
     if (!$this->request->is_set_post('available')) {
         return array();
     }
     if (!$is_member) {
         return array($this->user->lang('NO_HOOKUP_MEMBER'));
     }
     foreach ($availables as $date_id => $available) {
         //ignore HOOKUP_UNSET and other invalid values
         if (!is_numeric($date_id) || !isset($this->hookup->hookup_dates[$date_id]) || !in_array($available, array(hookup::HOOKUP_YES, hookup::HOOKUP_NO, hookup::HOOKUP_MAYBE))) {
             continue;
         }
         $this->hookup->set_user_date($this->user->data['user_id'], $date_id, $available);
     }
     $this->hookup->update_available_sums();
     $this->hookup->set_user_data($this->user->data['user_id'], 0, $this->request->variable('comment', '', true));
     return array();
 }
Esempio n. 6
0
 /**
  * Delete the hookup which belongs to the topic by deleting all parts.
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function delete_topic($event)
 {
     $this->hookup->delete_in_db($event['topic_ids'], false);
 }
 /**
  * Move the hookup to a new topic if necessary or merge it if one already exists
  *
  * @param unknown $event
  */
 public function move_posts($event)
 {
     // parameters: src_topic_ids, dest_topic_ids
     $this->hookup->merge_in_db($event['topic_ids'], $event['topic_id']);
 }