| [ Index ] |
PHP Cross Reference of Xoops v2.4.5 code documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Extended User Profile 4 * 5 * You may not change or alter any portion of this comment or credits 6 * of supporting developers from this source code or any supporting source code 7 * which is considered copyrighted (c) material of the original comment or credit authors. 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * 12 * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ 13 * @license http://www.fsf.org/copyleft/gpl.html GNU public license 14 * @package profile 15 * @since 2.3.0 16 * @author Jan Pedersen 17 * @author Taiwen Jiang <phppp@users.sourceforge.net> 18 * @version $Id: visibility.php 4361 2010-02-09 23:36:33Z trabis $ 19 */ 20 21 defined('XOOPS_ROOT_PATH') or die("XOOPS root path not defined"); 22 23 class ProfileVisibility extends XoopsObject 24 { 25 function __construct() 26 { 27 $this->initVar('field_id', XOBJ_DTYPE_INT); 28 $this->initVar('user_group', XOBJ_DTYPE_INT); 29 $this->initVar('profile_group', XOBJ_DTYPE_INT); 30 } 31 32 function ProfileVisibility() 33 { 34 $this->__construct(); 35 } 36 } 37 38 class ProfileVisibilityHandler extends XoopsPersistableObjectHandler 39 { 40 function ProfileVisibilityHandler(&$db) 41 { 42 $this->__construct($db); 43 } 44 45 function __construct(&$db) 46 { 47 parent::__construct($db, 'profile_visibility', 'profilevisibility', 'field_id'); 48 } 49 50 /** 51 * get all objects matching a condition 52 * 53 * @param object $criteria {@link CriteriaElement} to match 54 * @param array $fields variables to fetch 55 * @param bool $asObject flag indicating as object, otherwise as array 56 * @param bool $id_as_key use the ID as key for the array 57 * @return array of objects/array {@link XoopsObject} 58 */ 59 function &getAll($criteria = null) 60 { 61 $limit = null; 62 $start = null; 63 $sql = "SELECT * FROM `{$this->table}`"; 64 if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) { 65 $sql .= " " . $criteria->renderWhere(); 66 if ($groupby = $criteria->getGroupby()) { 67 $sql .= " " . $groupby; 68 } 69 if ($sort = $criteria->getSort()) { 70 $sql .= " ORDER BY {$sort} " . $criteria->getOrder(); 71 $orderSet = true; 72 } 73 $limit = $criteria->getLimit(); 74 $start = $criteria->getStart(); 75 } 76 if (empty($orderSet)) { 77 $sql .= " ORDER BY `{$this->keyName}` DESC"; 78 } 79 $result = $this->db->query($sql, $limit, $start); 80 $ret = array(); 81 while ($row = $this->db->fetchArray($result)) { 82 $ret[$row['field_id']][] = $row; 83 } 84 return $ret; 85 } 86 87 /** 88 * Get fields visible to the $user_groups on a $profile_groups profile 89 * 90 * @param array $profile_groups groups of the user to be accessed 91 * @param array $user_groups groups of the visitor, default as $GLOBALS['xoopsUser'] 92 * 93 * @return array 94 */ 95 function getVisibleFields($profile_groups, $user_groups = null) 96 { 97 $profile_groups[] = $user_groups[] = 0; 98 $sql = "SELECT field_id FROM {$this->table} WHERE profile_group IN (" . implode(',', $profile_groups) . ")"; 99 $sql .= " AND user_group IN (" . implode(',', $user_groups) . ")"; 100 $field_ids = array(); 101 if ($result = $this->db->query($sql)) { 102 while (list($field_id) = $this->db->fetchRow($result)) { 103 $field_ids[] = $field_id; 104 } 105 } 106 return $field_ids; 107 } 108 } 109 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Aug 1 01:39:09 2010 |