Esempio n. 1
0
 /**
  * Sets the status for a given set of nodes.
  * Used for actions on list nodes or specific given nodes in a tree.
  * $_POST['status'] can be 0 ('draft'), 1 (pending), 2 (published)
  */
 public static function nodes_set_nodes_status()
 {
     parent::$json_data += array('updated_nodes' => array());
     if (!empty($_POST['nodes_to_update']) && is_array($_POST['nodes_to_update']) && isset($_POST['status'])) {
         $nodes_to_update = $_POST['nodes_to_update'];
         $cascading_nodes = !empty($_POST['cascading_nodes']) ? $_POST['cascading_nodes'] : array();
         $tree = new ApmTreeData();
         //Load wp data because we already know it will only apply
         //to $nodes_to_update and not all nodes :
         $nodes_to_update = $tree->load_specific_nodes($nodes_to_update, $cascading_nodes);
         $tree->update_nodes_status($_POST['status']);
         $nodes_list = $tree->get_ready_to_display_nodes();
         parent::$json_data['updated_nodes'] = $nodes_to_update;
         parent::$json_data['nodes_html'] = self::get_html_tree($nodes_list, true);
     }
     parent::send_json();
 }