[feladat @ 107]
authorrejo
Thu, 03 Jan 2008 20:27:47 +0000
changeset 60 6ffacb626294
parent 59 11804f18dfc7
child 61 d015f5c9b308
[feladat @ 107] Fixing ticket:17 (zone listing and count in user management screen incomplete).
docs/template.pot
inc/record.inc.php
locale/en_EN/LC_MESSAGES/en.po
locale/nl_NL/LC_MESSAGES/messages.mo
locale/nl_NL/LC_MESSAGES/nl.po
users.php
--- a/docs/template.pot	Wed Jan 02 22:24:32 2008 +0000
+++ b/docs/template.pot	Thu Jan 03 20:27:47 2008 +0000
@@ -16,6 +16,22 @@
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+#: users.php:110
+msgid "Users may only change some of the records of zones marked with an (*)."
+msgstr ""
+
+#: users.php:77
+msgid "access"
+msgstr ""
+
+#: users.php:78
+msgid "owner"
+msgstr ""
+
+#: edit.php:9
+msgid "No records where selected to assign an sub-owner."
+msgstr ""
+
 #: add_record.php:16
 msgid "Add record to zone"
 msgstr ""
--- a/inc/record.inc.php	Wed Jan 02 22:24:32 2008 +0000
+++ b/inc/record.inc.php	Thu Jan 03 20:27:47 2008 +0000
@@ -675,19 +675,78 @@
 	global $db;
 	if (is_numeric($id))
 	{
-		$result = $db->query("SELECT domains.id AS domain_id, domains.name AS name FROM domains LEFT JOIN zones ON domains.id=zones.domain_id WHERE owner=$id");
+		$a_zones = array();
+
+		// Check for zones the user has full access for (the 
+		// user is owner of the zone.
+
+		$res_full = $db->query("SELECT 
+					domains.id AS domain_id, 
+					domains.name AS name 
+					FROM domains 
+					LEFT JOIN zones ON domains.id=zones.domain_id 
+					WHERE owner=$id"); 
+		
+		// Process the output.
 
-		$ret = array();
+		$numrows = $res_full->numRows();
+		$i=1;
+		if ($numrows > 0) 
+		{
+			$andnot=" AND NOT domains.id IN (";
+			while($r = $res_full->fetchRow()) {
+				
+				// Create array of zone id's and name's the owner
+				// has full access to.
+
+				$a_zones[] = array(
+				"id"            =>              $r["domain_id"],
+				"name"          =>              $r["name"],
+				"partial"	=>		"0"
+				);
 
-		// Put all the information in a big array.
-		while ($r = $result->fetchRow())
+				// Create AND NOT for query of zones the user has 
+				// only partial access to. In that query we just 
+				// want to see the zones he has not full access to 
+				// as well.
+
+				$andnot.=$r["domain_id"];
+				if ($i < $numrows) {
+					$andnot.=",";
+					$i++;
+				}
+
+			}
+			$andnot.=")";
+		}
+		else
 		{
-			$ret[] = array(
+			$andnot="";
+		}
+
+		// Check for zones the user has partial access only to.
+
+		$res_partial = $db->query("SELECT DISTINCT 
+					records.domain_id, 
+					domains.name 
+					FROM records, record_owners, domains 
+					WHERE record_owners.user_id = '".$id."' 
+					AND records.id = record_owners.record_id 
+					AND domains.id = records.domain_id
+					".$andnot.";");
+		
+		// Add these zones to the array as well.
+
+		while ($r = $res_partial->fetchRow())
+		{
+			$a_zones[] = array(
 			"id"            =>              $r["domain_id"],
-			"name"          =>              $r["name"]
+			"name"          =>              $r["name"],
+			"partial"	=>		"1"
 			);
 		}
-		return $ret;
+
+		return $a_zones;
 	}
 	else
 	{
--- a/locale/en_EN/LC_MESSAGES/en.po	Wed Jan 02 22:24:32 2008 +0000
+++ b/locale/en_EN/LC_MESSAGES/en.po	Thu Jan 03 20:27:47 2008 +0000
@@ -16,6 +16,18 @@
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+#: users.php:110
+msgid "Users may only change some of the records of zones marked with an (*)."
+msgstr ""
+
+#: users.php:77
+msgid "access"
+msgstr ""
+
+#: users.php:78
+msgid "owner"
+msgstr ""
+
 #: edit.php:9
 msgid "No records where selected to assign an sub-owner."
 msgstr ""
Binary file locale/nl_NL/LC_MESSAGES/messages.mo has changed
--- a/locale/nl_NL/LC_MESSAGES/nl.po	Wed Jan 02 22:24:32 2008 +0000
+++ b/locale/nl_NL/LC_MESSAGES/nl.po	Thu Jan 03 20:27:47 2008 +0000
@@ -16,6 +16,18 @@
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+#: users.php:110
+msgid "Users may only change some of the records of zones marked with an (*)."
+msgstr "Gebruikers kunnen slechts enkele records uit een zones gemarkeerd met een (*) wijzigen."
+
+#: users.php:77
+msgid "access"
+msgstr "toegangelijk"
+
+#: users.php:78
+msgid "owner"
+msgstr "eigenaar"
+
 #: edit.php:9
 msgid "No records where selected to assign an sub-owner."
 msgstr "Er waren geen records geselecteerd om toe te wijzen aan een beheerder."
--- a/users.php	Wed Jan 02 22:24:32 2008 +0000
+++ b/users.php	Thu Jan 03 20:27:47 2008 +0000
@@ -74,7 +74,8 @@
        <tr>
         <th>&nbsp;</th>
         <th><? echo _('Name'); ?></th>
-        <th><? echo _('Zones'); ?></th>
+        <th><? echo _('Zones'); ?> (<? echo _('access'); ?>)</th>
+        <th><? echo _('Zones'); ?> (<? echo _('owner'); ?>)</th>
         <th><? echo _('Zone list'); ?></th>
         <th><? echo _('Level'); ?></th>
         <th><? echo _('Status'); ?></th>
@@ -83,17 +84,19 @@
 $users = show_users('',ROWSTART,ROWAMOUNT);
 foreach ($users as $c)
 {
+        $domains = get_domains_from_userid($c["id"]);
+	$num_zones_access = count($domains);
 ?>
        <tr>
         <td class="n"><a href="delete_user.php?id=<? echo $c["id"] ?>"><img src="images/delete.gif" alt="[ <? echo _('Delete user'); ?> ]"></a></td>
         <td class="n"><a href="edit_user.php?id=<? echo $c["id"] ?>"><? echo $c["fullname"] ?></A> (<? echo $c["username"] ?>)</td>
+        <td class="n"><? echo $num_zones_access ?></td>
         <td class="n"><? echo $c["numdomains"] ?></td>
         <td class="n">
         <?
-        $domains = get_domains_from_userid($c["id"]);
         foreach ($domains as $d)
         {
-                ?><a href="delete_domain.php?id=<? echo $d["id"] ?>"><img src="images/delete.gif" alt="[ <? echo _('Delete domain'); ?> ]"></a>&nbsp;<a href="edit.php?id=<? echo $d["id"] ?>"><? echo $d["name"] ?></a><br><?
+                ?><a href="delete_domain.php?id=<? echo $d["id"] ?>"><img src="images/delete.gif" alt="[ <? echo _('Delete domain'); ?> ]"></a>&nbsp;<a href="edit.php?id=<? echo $d["id"] ?>"><? echo $d["name"] ?><? if ($d["partial"] == "1") { echo " *"; } ; ?></a><br><?
         }
         ?></td>
 	<td class="n"><? echo $c["level"] ?></td>
@@ -102,7 +105,9 @@
         print "\n";
 }
 ?>
+       
       </table>
+      <p><? echo _('Users may only change some of the records of zones marked with an (*).'); ?></p>
       <p><? echo _('Number of users') ;?>: <? echo count($users); ?>.</p>
       <div class="showmax">
 <?