[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gallery-checkins
Subject:    [Gallery-checkins] CVS: gallery2/modules/core/classes GalleryItemHelper.class,1.12,1.13 GalleryPermi
From:       Bharat Mediratta <bharat () users ! sourceforge ! net>
Date:       2003-03-24 5:17:16
[Download RAW message or body]

Update of /cvsroot/gallery/gallery2/modules/core/classes
In directory sc8-pr-cvs1:/tmp/cvs-serv26863a/modules/core/classes

Modified Files:
	GalleryItemHelper.class GalleryPermissionMap.class 
Log Message:
Change GalleryItemHelper API calls to no longer require the user id.  We
hard code the active user id instead.  This simplifies the UI and removes
an ability that we never used.


Index: GalleryItemHelper.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryItemHelper.class,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- GalleryItemHelper.class	12 Mar 2003 11:20:20 -0000	1.12
+++ GalleryItemHelper.class	24 Mar 2003 05:17:13 -0000	1.13
@@ -63,7 +63,7 @@
      *               int a count
      * @static
      */
-    function getChildCounts($itemIds, $userId) {
+    function getChildCounts($itemIds) {
 	global $gallery;
 
 	if (empty($itemIds)) {
@@ -103,8 +103,8 @@
           [GalleryChildEntity::parentId]
         ';
 	$data = $itemIds;
-	$data[] = $userId;
-	$data[] = $userId;
+	$data[] = $gallery->getActiveUserId();
+	$data[] = $gallery->getActiveUserId();
 	$data[] = $storage->convertIntToBits($permissionBits);
 	$data[] = $storage->convertIntToBits(0);
 
@@ -199,17 +199,16 @@
      * @return object GalleryStatus a status code
      * @static
      */
-    function studyPermissions($itemIds, $userId) {
+    function studyPermissions($itemIds) {
 
-	list ($ret, $permissionsTable) =
-	    GalleryPermissionMap::fetchPermissionsForItems($itemIds, $userId);
+	list ($ret, $permissionsTable) = GalleryPermissionMap::fetchPermissionsForItems($itemIds);
 	if ($ret->isError()) {
 	    return $ret->wrap(__FILE__, __LINE__);
 	}
 
 	/* Cache the permissions */
 	foreach ($permissionsTable as $itemId => $permissions) {
-	    $cacheKey = "GalleryItemHelper::getPermissions($itemId,$userId)";
+	    $cacheKey = "GalleryItemHelper::getPermissions($itemId)";
 	    GalleryDataCache::put($cacheKey, $permissions);
 	}
 	    
@@ -220,17 +219,15 @@
      * Return all the permissions that the given user has for the given item.
      *
      * @return array object GalleryStatus a status code
-     *               boolean true if yes
+     *               array (perm1, perm2)
      * @static
      */
-    function getPermissions($itemId, $userId) {
-
-	$cacheKey = "GalleryItemHelper::getPermissions($itemId,$userId)";
+    function getPermissions($itemId) {
+	$cacheKey = "GalleryItemHelper::getPermissions($itemId)";
 	if (GalleryDataCache::containsKey($cacheKey)) {
 	    $permissions = GalleryDataCache::get($cacheKey);
 	} else {
-	    list ($ret, $permissionsTable) =
-		GalleryPermissionMap::fetchPermissionsForItems(array($itemId), $userId);
+	    list ($ret, $permissionsTable) = GalleryPermissionMap::fetchPermissionsForItems(array($itemId));
 	    if ($ret->isError()) {
 		return array($ret->wrap(__FILE__, __LINE__), null);
 	    }
@@ -266,7 +263,7 @@
 
 	if (!isset($instance)) {
 	    /* No? Try the major type only */
-	    $mimeType = substr(0, strcspn($mimeType, '/')) . '/*';
+	    $mimeType = substr($mimeType, 0, strpos($mimeType, '/')) . '/*';
 	    list ($ret, $instance) = GalleryFactory::newInstanceByHint('GalleryItem', $mimeType);
 	    if ($ret->isError()) {
 		return array($ret->wrap(__FILE__, __LINE__), null);

Index: GalleryPermissionMap.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryPermissionMap.class,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- GalleryPermissionMap.class	22 Mar 2003 23:23:03 -0000	1.22
+++ GalleryPermissionMap.class	24 Mar 2003 05:17:13 -0000	1.23
@@ -396,12 +396,11 @@
      * Return a list of permissions for the given items
      *
      * @param array int GalleryItem ids
-     * @param int a user id
      * @return array object GalleryStatus a status code
      *               array (id => array(array(permission.id => 1, ...), ...)
      * @static
      */
-    function fetchPermissionsForItems($itemIds, $userId) {
+    function fetchPermissionsForItems($itemIds) {
 	global $gallery;
 
 	if (!is_array($itemIds) || empty($itemIds)) {
@@ -429,8 +428,8 @@
           [GalleryPermissionMap::itemId]
         ';
 	$data = $itemIds;
-	$data[] = $userId;
-	$data[] = $userId;
+	$data[] = $gallery->getActiveUserId();
+	$data[] = $gallery->getActiveUserId();
 
 	list($ret, $searchResults) = $gallery->search($query, $data);
 	if ($ret->isError()) {



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
__[ g a l l e r y - c h e c k i n s ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic