http://www.fsf.org/ or write * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * */ /* ADMINISTRATION CLASS */ /** * Would you like to web administrate cmsdam psections, pubblishing, users, groups and so on? * This is the class you have to use. The same way you use templates to interact with cmsdam api, * you can use this class completely from your template to make a self made powerful administration * area of your cmsdam powered site!! Simple, quick and very scalable, or not?

* Class instance: $cms->admin * @author dAm2K (Dino Ciuffetti) <dam2k@users.sourceforge.net> */ class cmsdam_admin { /** * You should not use this variable from your section. * @access private */ var $conf; /** * You should not use this variable from your section. * @access private */ var $users; /** * You should not use this variable from your section. * @access private */ var $dbms; /** * You should not use this variable from your section. * @access private */ var $debug; /** * You should not use this variable from your section. * @access private */ var $logs; /** * TODO: Write documentation */ function create_admin_object($name, $description) { // Create a new administration object if ($name == "") { // Name cannot be empty! return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to execute the query $query = "insert into " . $this->dbms->DB_tbl_prefix . "admin_objects (id, name, description, creation_date) values (\"\", \"$name\", \"$description\", NOW())"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors return true; } return null; } return false; } /** * TODO: Write documentation */ function create_admin_property($name, $description) { // Create a new administration property if ($name == "") { // Name cannot be empty! return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to execute the query $query = "insert into " . $this->dbms->DB_tbl_prefix . "admin_properties (id, name, description, creation_date) values (\"\", \"$name\", \"$description\", NOW())"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors return true; } return null; } return false; } /** * TODO: Write documentation */ function create_admin_dynasect($name, $description, $section) { // Create a new administration dynasect if ($name == "") { // Name cannot be empty! return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to execute the query $query = "insert into " . $this->dbms->DB_tbl_prefix . "admin_dynasect (id, name, section, description, creation_date, user, phpsessid) values (\"\", \"$name\", \"$section\", \"$description\", NOW(), \"" . $this->users->logged_user ."\", \"" . session_id() . "\")"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors return true; } return null; } return false; } /** * TODO: Write documentation */ function attach_admin_objprop_to_dynasect ($dynasect_name, $object_name, $property_name) { if (($dynasect_name == "") || ($object_name == "") || ($property_name == "")) { // Name cannot be empty! return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB $dynasect_id = $this->get_admin_dynaid_by_name($dynasect_name); $object_id = $this->get_admin_objid_by_name($object_name); $property_id = $this->get_admin_propid_by_name($property_name); // Try to execute the query $query = "insert into " . $this->dbms->DB_tbl_prefix . "admin_rel_dynobjprop (id, admin_dynasect_id, admin_object_id, admin_property_id, creation_date, user, phpsessid) values (\"\", $dynasect_id, $object_id, $property_id, NOW(), \"". $this->users->logged_user ."\", \"" . session_id() . "\")"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors return true; } return null; } return false; } /** * TODO: Write documentation */ function fetch_attached_admin_objprop_to_dynasect ($dynasect_name = "") { if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB $dynasect_id = $this->get_admin_dynaid_by_name($dynasect_name); $object_id = $this->get_admin_objid_by_name($object_name); $property_id = $this->get_admin_propid_by_name($property_name); // Try to execute the query if ($dynasect_name == "") { $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_rel_dynobjprop"; } else { $dynasect_id = $this->get_admin_dynaid_by_name($dynasect_name); $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_rel_dynobjprop where admin_dynasect_id = \"$dynasect_id\""; } if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_array(); $rows_arr[$rows] = $data; } return $rows_arr; } } return null; } return false; } /** * TODO: Write documentation */ function delete_admin_object($name) { // Delete a new administration object if ($name == "") { // Name cannot be empty! return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to execute the query $query = "delete from " . $this->dbms->DB_tbl_prefix . "admin_objects where name = \"$name\""; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors return true; } return null; } return false; } /** * TODO: Write documentation */ function delete_admin_property($name) { // Delete a new administration property if ($name == "") { // Name cannot be empty! return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to execute the query $query = "delete from " . $this->dbms->DB_tbl_prefix . "admin_properties where name = \"$name\""; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors return true; } return null; } return false; } /** * TODO: Write documentation */ function delete_admin_dynasect($name) { // Delete a new administration dynasect if ($name == "") { // Name cannot be empty! return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to execute the query $query = "delete from " . $this->dbms->DB_tbl_prefix . "admin_dynasect where name = \"$name\""; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Query executed without errors return true; } return null; } return false; } /** * TODO: Write documentation */ function get_admin_dynaid_by_name($dynaname) { // dynasect id by name if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select id from " . $this->dbms->DB_tbl_prefix . "admin_dynasect where name = \"$dynaname\""; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); $data_id = $data[0]; } return $data_id; } return null; } } return false; } /** * TODO: Write documentation */ function get_admin_objid_by_name($objname) { // object id by name if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select id from " . $this->dbms->DB_tbl_prefix . "admin_objects where name = \"$objname\""; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); $data_id = $data[0]; } return $data_id; } return null; } } return false; } /** * TODO: Write documentation */ function get_admin_propid_by_name($propname) { // property id by name if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select id from " . $this->dbms->DB_tbl_prefix . "admin_properties where name = \"$propname\""; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); $data_id = $data[0]; } return $data_id; } return null; } } return false; } /** * TODO: Write documentation */ function admin_object_name_by_id($object_id) { // String with object names given the id if ($object_id <= 0) { // Parameter not valid return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select name from " . $this->dbms->DB_tbl_prefix . "admin_objects where id=$object_id"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); // Building the array $rows_arr[$rows] = $data[0]; } return $data[0]; } return null; } } return false; } /** * TODO: Write documentation */ function admin_dynasect_name_by_id($dynasect_id) { // String with dynasect names given the id if ($dynasect_id <= 0) { // Parameter not valid return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select name from " . $this->dbms->DB_tbl_prefix . "admin_dynasect where id=$dynasect_id"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); // Building the array $rows_arr[$rows] = $data[0]; } return $data[0]; } return null; } } return false; } /** * TODO: Write documentation */ function admin_property_name_by_id($property_id) { // String with property names given the id if ($property_id <= 0) { // Parameter not valid return false; } if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select name from " . $this->dbms->DB_tbl_prefix . "admin_properties where id=$property_id"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); // Building the array $rows_arr[$rows] = $data[0]; } return $data[0]; } return null; } } return false; } /** * TODO: Write documentation */ function list_admin_objects() { // Return an array with all administration objects if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select name from " . $this->dbms->DB_tbl_prefix . "admin_objects"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); // Building the array $rows_arr[$rows] = $data[0]; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function fetch_admin_objects() { // Return a multidimensional array with all administration objects if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the table $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_objects order by creation_date"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // data returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_array(); // Building the array $rows_arr[$rows] = $data; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function fetch_admin_properties() { // Return a multidimensional array with all administration objects if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_properties order by name"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_array(); // Building the array $rows_arr[$rows] = $data; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function list_admin_properties() { // Return an array with all administration objects if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select name from " . $this->dbms->DB_tbl_prefix . "admin_properties order by name"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); // Building the array $rows_arr[$rows] = $data[0]; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function list_admin_dynasects() { // Return an array with all administration objects if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select distinct name from " . $this->dbms->DB_tbl_prefix . "admin_dynasect order by name"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_row(); // Building the array $rows_arr[$rows] = $data[0]; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function fetch_admin_dynasect() { // Return a multidimensional array with all administration dynasect if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_dynasect order by name"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_array(); // Building the array $rows_arr[$rows] = $data; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function fetch_admin_obj_roles() { // Return a multidimensional array with all administration object roles if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_obj_roles order by name"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_array(); // Building the array $rows_arr[$rows] = $data; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function fetch_admin_prop_roles() { // Return a multidimensional array with all admin properties roles if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_prop_roles order by name"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_array(); // Building the array $rows_arr[$rows] = $data; } return $rows_arr; } return null; } } return false; } /** * TODO: Write documentation */ function fetch_admin_dyna_states() { if ($this->dbms->db_connected != 1) { // DB not connected $this->debug->debug_write(4, "DB not connected: " . $this->dbms->db_connected); $this->logs->log_note(4, "DB not connected: " . $this->dbms->db_connected); } else { // We are connected to the DB // Try to get data from the users table $query = "select * from " . $this->dbms->DB_tbl_prefix . "admin_dyna_states order by name"; if ($this->dbms->dbquery($query) == false) { // DB error return false; } else { // Users returned if ($this->dbms->dbnum_rows() > 0) { // There are users in the table for ($rows = 0; $rows < $this->dbms->dbnum_rows(); $rows++) { // Getting data from the database $data = $this->dbms->dbfetch_array(); // Building the array $rows_arr[$rows] = $data; } return $rows_arr; } return null; } } return false; } } ?>