* @author Cyberspace Networks <*****@*****.**>
* @license GNU General Public License
* @copyright Copyright (c) 2000-2014 Cyberspace Networks
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* The lastest version of Cyberspace Networks CoreSystem can be obtained from:
* http://developer.cyberspace-networks.com/
* For questions, help, comments, discussion, etc. please visit
* https://github.com/CyberspaceNetworks/CoreSystem
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
if (!empty($families[0])) {
    if (0) {
        // Testcode for on_same_family
        if (PA::$login_uid != PA::$page_uid) {
            require_once "api/CNEntity/CNFamilyTypedGroupEntity.php";
            echo "<pre>" . print_r(FamilyTypedGroupEntity::in_same_family(PA::$login_uid, PA::$page_uid), 1) . "</pre>";
        }
    }
    // end test code
    ?>
<div class="module_icon_list">
  <ul class="members">
  <?php 
    foreach ($families as $family) {
        ?>
    <li>
      <a href="<?php 
        echo PA::$url . PA_ROUTE_FAMILY . "/gid=" . $family['id'];
        ?>
">
        <?php 
 private function can_view_content($params, $type)
 {
     global $app;
     if (PAGE_USER_PUBLIC == $app->getRequestParam('page_id') && PA::$page_user->has_role_id(CHILD_MEMBER_ROLE)) {
         if (!empty(PA::$login_user)) {
             if (PA::$login_uid == PA::$page_uid) {
                 return true;
                 // page owner always should be able to view its own public page
             }
             $user_dob = PA::$page_user->get_profile_field(GENERAL, 'dob_year');
             $own_age = date('Y') - $user_dob;
             if ($own_age < CHILD_LOWER_AGES) {
                 // page owner is a child below the age
                 $is_in_family = FamilyTypedGroupEntity::in_same_family(PA::$login_uid, PA::$page_uid);
                 if (count($is_in_family) > 0) {
                     // so, check whether the visitor is a member of family
                     return true;
                 } else {
                     return false;
                 }
             } else {
                 return true;
                 // the child is over age - allow visitors to view page
             }
         } else {
             return false;
             // anonymous users should not be able to see a Child page
         }
     } else {
         $user_permiss = $this->get_available_permiss_by_type($params, 'user');
         if (in_array('view_content', $user_permiss)) {
             return true;
         }
         $group_permiss = $this->get_available_permiss_by_type($params, 'groups');
         if (in_array('view_content', $group_permiss)) {
             return true;
         }
         $network_permiss = $this->get_available_permiss_by_type($params, 'network');
         if (in_array('view_content', $network_permiss)) {
             return true;
         }
     }
     return false;
 }
 /** !!
  * Iterates over $this->profilefields, doing some data parsing
  *  and then saves it back.
  *
  * @param array $request_data POST/GET data of changed information.
  */
 private function handleEntity($request_data)
 {
     $this->err = '';
     // $data = $this->filter($request_data);
     $data = array();
     // use the profile_fields object for some processing
     foreach ($this->profilefields as $i => $d) {
         $k = $d['name'];
         switch ($d['type']) {
             case 'dateselect':
                 $day = @$request_data[$k . '_day'];
                 $month = @$request_data[$k . '_month'];
                 $year = @$request_data[$k . '_year'];
                 if ($day && $month && $year) {
                     $data[$k . '_day'] = $day;
                     $data[$k . '_month'] = $month;
                     $data[$k . '_year'] = $year;
                     $data[$k] = sprintf("%04d-%02d-%02d", $year, $month, $day);
                 }
                 break;
             default:
                 if (!empty($request_data[$k])) {
                     $data[$k] = $request_data[$k];
                 }
                 break;
         }
     }
     $data['type'] = 'family';
     $data['name'] = $request_data['groupname'];
     $data['group_id'] = $this->gid;
     if (empty($data['name'])) {
         $this->err .= __("Please supply a name.") . "<br/>";
     }
     if (empty($this->err)) {
         // sync it
         FamilyTypedGroupEntity::sync($data);
         if (empty($request_data['gid'])) {
             // also add the creator of this family as a parent!
             require_once "api/Entity/TypedGroupEntityRelation.php";
             try {
                 TypedGroupEntityRelation::set_relation(PA::$login_uid, $this->gid, 'parent');
             } catch (PAException $e) {
                 $error_msg = $e->getMessage();
             }
         }
     }
 }