Пример #1
0
 /**
  * Common handler for edit/create action.
  *
  * @return bool|JsonResponse Returns true if item was submitted.
  */
 protected function common_post()
 {
     // Load the message object
     $this->message->set_parent($this->faq)->set_auth(array('bbcode' => $this->auth->acl_get('u_titania_bbcode'), 'smilies' => $this->auth->acl_get('u_titania_smilies'), 'attachments' => true));
     // Submit check...handles running $this->faq->post_data() if required
     $submit = $this->message->submit_check();
     $error = $this->message->error;
     if ($this->message->is_plupload_request()) {
         return new JsonResponse($this->message->get_plupload_response_data());
     }
     if ($submit) {
         $error = array_merge($error, $this->faq->validate());
         if (($validate_form_key = $this->message->validate_form_key()) !== false) {
             $error[] = $validate_form_key;
         }
         if (empty($error)) {
             $this->faq->submit();
             $this->message->submit($this->id);
             return true;
         }
     }
     $this->template->assign_vars(array('S_EDIT' => true, 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false));
     $this->message->display();
     return false;
 }
Пример #2
0
        if (!phpbb::$auth->acl_get('u_titania_mod_faq_mod') && !phpbb::$auth->acl_get('u_titania_faq_' . $action) && !titania::$contrib->is_author && !titania::$contrib->is_active_coauthor) {
            titania::needs_auth();
        }
        // Load the message object
        $message = new titania_message($faq);
        $message->set_auth(array('bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'), 'smilies' => phpbb::$auth->acl_get('u_titania_smilies'), 'attachments' => true));
        // Submit check...handles running $faq->post_data() if required
        $submit = $message->submit_check();
        $error = array_merge($error, $message->error);
        if ($submit) {
            $error = array_merge($error, $faq->validate());
            if (($validate_form_key = $message->validate_form_key()) !== false) {
                $error[] = $validate_form_key;
            }
            if (!sizeof($error)) {
                $faq->submit();
                $message->submit($faq->faq_id);
                $sql = 'SELECT right_id FROM ' . TITANIA_CONTRIB_FAQ_TABLE . '
					WHERE contrib_id = ' . titania::$contrib->contrib_id . '
					ORDER BY right_id DESC LIMIT 1';
                $result = phpbb::$db->sql_query($sql);
                $right_id = (string) phpbb::$db->sql_fetchfield('right_id');
                phpbb::$db->sql_freeresult($result);
                // Update the faqs table
                $sql_ary = array('left_id' => $right_id + 1, 'right_id' => $right_id + 2);
                $sql = 'UPDATE ' . TITANIA_CONTRIB_FAQ_TABLE . ' SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE faq_id = ' . (int) $faq->faq_id;
                phpbb::$db->sql_query($sql);
                redirect($faq->get_url());
            }
        }