Changeset 534 for trunk/lib/ACL.inc.php
- Timestamp:
- Jul 27, 2015 7:56:08 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/ACL.inc.php
r506 r534 65 65 // Configure the cache object. 66 66 $this->cache = new Cache('acl'); 67 $this->cache->setParam(array('enabled' => true));68 67 69 68 // Get create tables config from global context. … … 101 100 102 101 if (isset($params) && is_array($params)) { 102 // Some params require special processing. Catch those in a loop and process individually. 103 foreach ($params as $key => $val) { 104 switch ($key) { 105 case 'enable_cache': 106 $this->cache->setParam(array('enabled' => $val)); 107 break; 108 } 109 110 } 111 unset($key, $value); 112 103 113 // Merge new parameters with old overriding only those passed. 104 114 $this->_params = array_merge($this->_params, $params); … … 675 685 676 686 $cache_hash = $aro . '|' . $aco . '|' . $axo; 677 if ( $this->cache->exists($cache_hash) && true === $this->getParam('enable_cache')) {687 if (true === $this->getParam('enable_cache') && $this->cache->exists($cache_hash)) { 678 688 // Access value is cached. 679 689 $access = $this->cache->get($cache_hash); … … 694 704 if (!list($access) = mysql_fetch_row($qid)) { 695 705 $this->cache->set($cache_hash, 'deny'); 696 $app->logMsg(sprintf('Access denied: %s -> %s -> %s (no records found).', $aro, $aco, $axo), LOG_ DEBUG, __FILE__, __LINE__);706 $app->logMsg(sprintf('Access denied: %s -> %s -> %s (no records found).', $aro, $aco, $axo), LOG_WARNING, __FILE__, __LINE__); 697 707 return false; 698 708 } … … 704 714 return true; 705 715 } else { 706 $app->logMsg(sprintf('Access denied: %s -> %s -> %s', $aro, $aco, $axo), LOG_ DEBUG, __FILE__, __LINE__);716 $app->logMsg(sprintf('Access denied: %s -> %s -> %s', $aro, $aco, $axo), LOG_NOTICE, __FILE__, __LINE__); 707 717 return false; 708 718 } … … 736 746 } 737 747 748 /* 749 * Returns an array of the specified object type starting specified root. 750 * 751 * @access public 752 * @param string $type Table to list, one of: aro, aco, or axo. 753 * @param string $root Root node from which to begin from. 754 * @return mixed Returns a multidimensional array of objects, or false on error. 755 * @author Quinn Comendant <quinn@strangecode.com> 756 * @version 1.0 757 * @since 17 Jun 2006 23:41:22 758 */ 759 function getList($type, $root=null) 760 { 761 $app =& App::getInstance(); 762 $db =& DB::getInstance(); 763 764 switch ($type) { 765 case 'aro' : 766 $tbl = 'aro_tbl'; 767 break; 768 case 'aco' : 769 $tbl = 'aco_tbl'; 770 break; 771 case 'axo' : 772 $tbl = 'axo_tbl'; 773 break; 774 default : 775 $app->logMsg(sprintf('Invalid access object type: %s', $type), LOG_ERR, __FILE__, __LINE__); 776 return false; 777 } 778 779 // By default start with the 'root' node. 780 $root = !isset($root) ? 'root' : $root; 781 782 // Retrieve the left and right value of the $root node. 783 $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($root) . "'"); 784 list($lft, $rgt) = mysql_fetch_row($qid); 785 786 $results = array(); 787 $depth = array(); 788 789 // Retrieve all descendants of the root node 790 $qid = $db->query("SELECT name, lft, rgt, added_datetime FROM $tbl WHERE lft BETWEEN $lft AND $rgt ORDER BY lft ASC"); 791 while (list($name, $lft, $rgt, $added_datetime) = mysql_fetch_row($qid)) { 792 // If the last element of $depth is less than the current rgt it means we finished with a set of children nodes. 793 while (sizeof($depth) > 0 && end($depth) < $rgt) { 794 array_pop($depth); 795 } 796 797 $results[] = array( 798 'name' => $name, 799 'added_datetime' => $added_datetime, 800 'depth' => sizeof($depth), 801 ); 802 803 // Add this node to the stack. 804 $depth[] = $rgt; 805 } 806 807 return $results; 808 } 809 738 810 } // End class.
Note: See TracChangeset
for help on using the changeset viewer.