Ejemplo n.º 1
0
 /**
  * Sets the status for a given node and possibly its children if cascading is asked.
  * Used for actions on tree nodes, not list nodes.
  * $_POST['status'] can be 0 ('draft'), 1 (pending), 2 (published)
  */
 public static function nodes_set_node_status()
 {
     parent::$json_data += array('updated_node' => '', 'cascading' => 0, 'sub_tree' => '', 'sub_tree_nodes' => array());
     if (isset($_POST['root_node']) && is_numeric($_POST['root_node']) && isset($_POST['status'])) {
         $node_to_update = $_POST['root_node'];
         //TODO : can be optimized if no cascading
         $tree = new ApmTreeData();
         $tree->load_last_tree(true, false, false, $node_to_update);
         $cascading = isset($_POST['cascading']) && $_POST['cascading'] == 1;
         $tree->update_nodes_status($_POST['status'], $node_to_update, $cascading);
         $sub_tree_nodes = array();
         if ($cascading) {
             $sub_tree_nodes = $tree->get_ready_to_display_tree($node_to_update, false, false, false);
         } else {
             $sub_tree_nodes = array($tree->get_ready_to_display_node($node_to_update, false, false));
         }
         parent::$json_data['updated_node'] = $node_to_update;
         parent::$json_data['cascading'] = $cascading ? 1 : 0;
         parent::$json_data['sub_tree'] = self::get_html_tree($sub_tree_nodes);
         parent::$json_data['sub_tree_nodes'] = array_keys($sub_tree_nodes);
     }
     parent::send_json();
 }