Example #1
0
    public function __shutdown()
    {
        // Don't render the layout for json content
        if (Router::$extension == 'json') {
            $this->render['layout'] = false;
        }

        // Render the view
        $content = '';
        if ($this->render['view']) {
            Body::append(View::render($this->render['view']));
        }

        // Are we wrapping the view in a layout?
        if ($this->render['layout']) {
            $content = Body::content();
            Body::clear();
            Body::append(View::render("layouts/{$this->render['layout']}", array('content' => $content)));
        } else {
            Body::append($content);
        }

        // Set the X-Powered-By header and render the layout with the content
        header("X-Powered-By: Avalon/" . Kernel::version());
        print(Body::content());
    }
Example #2
0
 /**
  * Ticket task form bit.
  */
 public function action_form_bit()
 {
     $this->render['layout'] = false;
     // Task data
     $id = isset(Request::$request['id']) ? Request::$request['id'] : 0;
     $completed = isset(Request::$request['completed']) ? Request::$request['completed'] == "true" ? true : false : false;
     $task = isset(Request::$request['task']) ? Request::$request['task'] : '';
     return View::render('ticket_tasks/_form_bit', array('id' => $id, 'completed' => $completed, 'task' => $task));
 }
Example #3
0
 /**
  * Adds the question field to the register form.
  */
 public static function question_field()
 {
     // Get the questions
     $questions = json_decode(settings('security_questions'), true);
     // Get a random question
     $id = rand(0, count($questions) - 1);
     $question = $questions[$id];
     $_SESSION['question_id'] = $id;
     echo View::render('users/_question_field', array('question' => $question));
 }
Example #4
0
 /**
  * Edit tab.
  *
  * @param integer $id Tab ID
  */
 public function action_edit($id)
 {
     $tab = CustomTab::find($id);
     // Check if the form has been submitted.
     if (Request::method() == 'post') {
         $tab->set(array('label' => Request::post('label', $tab->label), 'url' => Request::post('url', $tab->url), 'groups' => implode(',', Request::post('groups', explode(',', $tab->groups))), 'display_order' => Request::post('display_order', $tab->display_order), 'project_id' => Request::post('project_id', $tab->project_id)));
         // Save and redirect
         if ($tab->save()) {
             Request::redirectTo('/admin/custom_tabs');
         }
     }
     View::set(compact('tab'));
 }
Example #5
0
 /**
  * Delete ticket update
  *
  * @param integer $id
  */
 public function action_delete($id)
 {
     // Get the ticket update
     $history = \traq\models\TicketHistory::find($id);
     // Delete the update
     $history->delete();
     // Is this an ajax request?
     if (Request::isAjax()) {
         // Render the view
         View::set('history', $history);
     } else {
         // Just redirect back to the ticket
         Request::redirectTo($history->ticket->href());
     }
 }
Example #6
0
 /**
  * Edit field page.
  *
  * @param integer $id
  */
 public function action_edit($id)
 {
     // Get field
     $field = CustomField::find($id);
     // Verify project
     if ($field->project_id != $this->project->id) {
         return $this->show_no_permission();
     }
     // Check if the form has been submitted
     if (Request::method() == 'post') {
         $data = array();
         // Loop over properties
         foreach (CustomField::properties() as $property) {
             // Check if it's set and not empty
             if (isset(Request::$post[$property])) {
                 $data[$property] = Request::$post[$property];
             }
         }
         if ($this->is_api) {
             $data['is_required'] = Request::post('is_required', $field->is_required);
             $data['multiple'] = Request::post('multiple', $field->multiple);
         } else {
             $data['is_required'] = Request::post('is_required', 0);
             $data['multiple'] = Request::post('multiple', 0);
         }
         // Set field properties
         $field->set($data);
         // Save and redirect
         if ($field->save()) {
             if ($this->is_api) {
                 return \API::response(1, array('field' => $field));
             } else {
                 Request::redirectTo($this->project->href('settings/custom_fields'));
             }
         }
     }
     // Send field object to view
     View::set(compact('field'));
 }
Example #7
0
 /**
  * Fetches all the data for the permission listing page.
  */
 private function permissions_for($type)
 {
     // Fetch groups, set permissions and actions arrays
     if ($type == 'usergroup') {
         $groups = Group::select()->where('is_admin', 1, '!=')->exec()->fetch_all();
         $groups = array_merge(array(new Group(array('id' => 0, 'name' => l('defaults')))), $groups);
     } elseif ($type == 'role') {
         $groups = ProjectRole::select()->custom_sql("WHERE project_id = 0 OR project_id = {$this->project->id}")->exec()->fetch_all();
         $groups = array_merge(array(new ProjectRole(array('id' => 0, 'name' => l('defaults'), 'project_id' => 0))), $groups);
     }
     $permissions = array();
     // Loop over the groups
     foreach ($groups as $group) {
         // Set the group array in the permissions array
         if (!isset($permissions[$group->id])) {
             $permissions[$group->id] = array();
         }
         // Loop over the permissions for the group
         foreach (Permission::get_permissions($this->project->id, $group->id, $type) as $action => $perm) {
             // Add the permission object to the permissions array
             $permissions[$group->id][$action] = $perm;
         }
     }
     // Send it all the to view.
     View::set('groups', $groups);
     View::set('permissions', $permissions);
     View::set('actions', permission_actions());
 }
Example #8
0
 /**
  * Display tabs
  */
 public static function display_tabs()
 {
     echo View::render('custom_tabs/tabs');
 }
Example #9
0
 /**
  * Used to create a blank question box.
  *
  * @return string
  */
 public function action_new_question()
 {
     $this->render['layout'] = false;
     return View::get('questions/_question', array('id' => time(), 'question' => array('question' => '', 'answers' => '')));
 }