Additionally, in DBEngine. class.php there is some scripting that pulls information from the database. However, it only pulls from the resources table. I need to pull the 'scheduletitle' from the schedules table and get it to show up in the column on the page that allows admin to edit user permissions. Should I create a whole new mysql query and then how do I make the admin template pull the information from a different query. I'm reading tutorials and trying to work through it on my own, but any help would be appreciated. Once I figure it all out I will post the code.
What I intend to do is add to the mod posted by Pete
http://php.brickhost.com/forums/index.php?topic=3238.0 that will also display a column with the schedule name. We use one install for people in several buildings and only want users to have permission to use resources in their buildings. This will make it easier for admin to give permission to users based on which schedule they use.
Has anyone put anything together something that would allow admin to assign permissions to groups of users en masse?
Here is the current code:
From DBEngine.class.php
/**
* Get associative array with machID, resource name, and status
* This function loops through all resources
* and constructs an associative array with the
* resource's machID, name and status as
* $array[x] => ('machid' => 'this_resource_id', 'name' => 'Resource Name', 'status' => 'a')
* @param none
* @return array of machID, resource name, status
*/
function get_mach_ids($scheduleid = null) {
$return = array();
$values = array();
$sql = 'SELECT machid, name, scheduleid, location, status, approval, min_notice_time, max_notice_time FROM ' . $this->get_table('resources');
if ($scheduleid != null) {
$sql .= ' WHERE scheduleid = ?';
$values = array($scheduleid);
}
$sql .= ' ORDER BY location';
$result = $this->db->query($sql, $values);
$this->check_for_error($result);
if ($result->numRows() <= 0) {
$this->err_msg = translate('No resources in the database.');
return false;
}
while ($rs = $result->fetchRow()) {
$return[] = $this->cleanRow($rs);
}
$result->free();
return $return;
}
From admin.template.php
/**
* Interface for managing user training
* Provide interface for viewing and managing
* user training information
* @param object $user User object of user to manage
* @param array $rs list of resources
*/
function print_manage_perms(&$user, $rs, $err) {
global $link;
if (!$user->is_valid()) {
CmnFns::do_error_box($user->get_error() . '<br /><a href="' . $_SERVER['PHP_SELF'] . '?tool=users">' . translate('Back') . '</a>', '', false);
return;
}
echo '<h3>' . $user->get_name() . '</h3>';
?>
<form name="train" method="post" action="admin_update.php">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="tableBorder">
<table cellspacing="1" cellpadding="2" border="0" width="100%">
<tr class="rowHeaders">
<td width="240"><?php echo translate('Resource Name')?></td>
<td width="70"><?php echo translate('Schedule')?></td>
<td width="240"><?php echo translate('Location')?></td>
<td width="60"><?php echo translate('Allowed')?></td>
</tr>
<?php
if (!$rs) echo '<tr class="cellColor0" style="text-align: center;"><td colspan="2">' . $err . '</td></tr>';
for ($i = 0; is_array($rs) && $i < count($rs); $i++) {
echo '<tr class="cellColor"><td>' . $rs[$i]['name'] . '</td><td>'. $rs[$i]['scheduleid'] . '</td><td>' . $rs[$i]['location']
. '<td style="text-align: center;">'
. '<input type="checkbox" name="machid[]" value="' . $rs[$i]['machid'] . '"';
if ($user->has_perm($rs[$i]['machid']))
echo ' checked="checked"';
echo '/></td></tr>';
}
// Close off tables/forms. Print buttons and hidden field
?>
<tr class="cellColor1">
<td> </td>
<td style="text-align: center;">
</td><td style="text-align: center;"><input type="checkbox" name="checkAll" onclick="checkAllBoxes(this);" />
</td>
</tr>
</table>
<input type="hidden" name="memberid" value="<?php echo $user->get_id()?>" />
<p style="padding-top: 5px; padding-bottom: 5px;"><input type="checkbox" name="notify_user" value="true" /><?php echo translate('Notify user')?></p>
<?php echo submit_button(translate('Save')) . hidden_fn('editPerms')?>
<input type="button" name="cancel" value="<?php echo translate('Manage Users')?>" class="button" onclick="document.location='<?php echo $_SERVER['PHP_SELF']?>?tool=users';" />
</form>
<?php
}
I am trying to get the "Schedule" column that is currently populated with 'scheduleid' to be populated with 'schedule title' instead.