public function save($id = null)
 {
     if ($this->perm->can_create == 'y') {
         if ($_POST) {
             $save = new Network();
             if ($_POST['id'] == '') {
                 $show_no = $this->db->query("SELECT MAX(show_no)show_no FROM acm_network")->result();
                 $_POST['show_no'] = @$show_no[0]->show_no < 1 ? 1 : $show_no[0]->show_no + 1;
                 $_POST['created_by'] = $this->user->id;
             } else {
                 $_POST['updated_by'] = $this->user->id;
             }
             $save->from_array($_POST);
             $save->save();
             $action = $_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
             save_logs($this->menu_id, $action, @$save->id, $action . ' ' . $save->title . ' Network');
         }
     }
     redirect("admin/networks");
 }
Exemple #2
0
 /**
  * get the details of mother network
  * @access public.
  * @param array of parameters 
  * format of $params
  * @return mother network details
  */
 public static function get_mothership_info()
 {
     Logger::log("[ Enter: function Network::get_mothership_info] \n");
     $sql = " SELECT * FROM {networks} WHERE is_active = 1 AND type = " . MOTHER_NETWORK_TYPE;
     $network = Dal::query_one_assoc($sql);
     if (empty($network)) {
         throw new PAException(MOTHER_NETWORK_NOT_DEFINED, "Configuration error: Mother network not configured.");
     }
     // we ned to set the network owner proprly
     // as it is set to 0 by default, which is not actually true
     if ($network['owner_id'] < 1) {
         // we use id = 1 for now as it seems there is no way to set it
         $network['owner_id'] = 1;
     }
     return Network::from_array($network);
     Logger::log("[ Exit: function Network::get_mothership_info] \n");
 }