function __construct()
 {
     $this->errors = array();
     $this->states = array_values(PA::getStatesList());
     $this->countries = array_values(PA::getCountryList());
     $this->api_call = false;
 }
 function __construct()
 {
     parent::__construct();
     $this->title = "Join " . PA::$site_name;
     $this->html_block_id = "RegisterModule";
     $this->states = array("-2" => '-Select-', "-1" => 'Other');
     $this->states = $this->states + array_values(PA::getStatesList());
     $this->countries = array("-1" => '-Select-');
     $this->countries = $this->countries + array_values(PA::getCountryList());
     /*    
         $this->states    = array_values(PA::getStatesList());
         $this->countries = array_values(PA::getCountryList());
         
         array_unshift($this->states, 'Other');
         array_unshift($this->states, '-Select-');
         array_unshift($this->countries, '-Select-');
     */
 }
      </div>
		<br style="clear:both" />
  <?php 
    foreach ($mod->profilefields as $i => $field) {
        switch ($field['type']) {
            case 'stateselect':
                $mod->dynFields->select($field['label'], $field['name'], PA::getStatesList());
                break;
            case 'industryselect':
                $mod->dynFields->select($field['label'], $field['name'], PA::$config->industries);
                break;
            case 'religionselect':
                $mod->dynFields->select($field['label'], $field['name'], PA::$config->religions);
                break;
            case 'countryselect':
                $mod->dynFields->select($field['label'], $field['name'], PA::getCountryList());
                break;
            case 'urltextfield':
                $mod->dynFields->textfield($field['label'], $field['name']);
                break;
            case 'textfield':
                $mod->dynFields->textfield($field['label'], $field['name']);
                break;
            case 'image':
                $mod->dynFields->image($field['label'], $field['name']);
                break;
            case 'dateselect':
                $mod->dynFields->dateselect($field['label'], $field['name']);
                break;
            default:
                echo print_r($field);
<div class="blog">
<?php 
if (!empty($atts['logo'])) {
	$img_info = uihelper_resize_img($atts['logo']['value'], 80, 34, "images/default_group.gif", NULL, RESIZE_FIT);
	echo '<img src="'.$img_info['url'].'" alt="Logo" '.$img_info['size_attr'].'"/>';
}
?>
<h1><a href="<?=PA::$url.PA_ROUTE_GROUP."/gid=".$entity->entity_id?>"><?= $atts['name']['value']?></a></h1>
<div style="overflow:auto;">
<?= $atts['slogan']['value']?>
</div>

<table>
<?php
$statesList = PA::getStatesList();
$countryList = PA::getCountryList();
foreach ($mod->profilefields as $i=>$field) {
	if ('logo' == $field['name']) continue;
	if ('slogan' == $field['name']) continue;
	
	
	$label = $field['label'];
	$attval = @$atts[$field['name']]['value'];
	switch ($field['type']) {
		case 'urltextfield':
			if (!empty($attval)) {
				$url = htmlspecialchars($attval);
				if (!preg_match("!^http(s)*://!", $url)) {
					$url = 'http://'.$url;
				}
				$value = '<a href="'.$url.'">'.$url.'</a>';
    echo _out($mod->err);
    echo '</div>';
}
foreach ($mod->profilefields as $i => $field) {
    switch ($field['type']) {
        case 'stateselect':
            $mod->dynFields->select($field['label'], $field['name'], array_values(PA::getStatesList()));
            break;
        case 'industryselect':
            $mod->dynFields->select($field['label'], $field['name'], PA::$config->industries);
            break;
        case 'religionselect':
            $mod->dynFields->select($field['label'], $field['name'], PA::$config->religions);
            break;
        case 'countryselect':
            $mod->dynFields->select($field['label'], $field['name'], array_values(PA::getCountryList()));
            break;
        case 'urltextfield':
            $mod->dynFields->textfield($field['label'], $field['name']);
            break;
        case 'textfield':
            $mod->dynFields->textfield($field['label'], $field['name']);
            break;
        case 'image':
            $mod->dynFields->image($field['label'], $field['name']);
            break;
        case 'dateselect':
            $mod->dynFields->dateselect($field['label'], $field['name']);
            break;
        default:
            echo print_r($field);
 private function handlePOST_addChild($request_data)
 {
     global $error_msg;
     $error = FALSE;
     $login_name = trim($_POST['login_name']);
     $first_name = stripslashes(trim($_POST['first_name']));
     $last_name = stripslashes(trim($_POST['last_name']));
     $email = trim($_POST['email']);
     $password = trim($_POST['password']);
     $use_parent_email = $_POST['use_parent_email'];
     //echo "<pre>".print_r($_POST, 1)."</pre>"; die();
     if (!isset($_POST['state'])) {
         if (isset($_POST['stateOther'])) {
             $_POST['state'] = $_POST['stateOther'];
         }
     }
     if (isset($_POST['stateOther'])) {
         unset($_POST['stateOther']);
     }
     $msg = NULL;
     if (!Validation::validate_email($email) && !empty($_POST['email'])) {
         $email_invalid = TRUE;
         $error = TRUE;
         $msg .= '<br> Email address is not valid';
     }
     if (User::user_exist($login_name)) {
         $msg = "Username {$login_name} is already taken";
         $error = TRUE;
     }
     if ($error == FALSE) {
         $newuser = new User();
         $newuser->login_name = $login_name;
         $newuser->password = $password;
         $newuser->first_name = $first_name;
         $newuser->last_name = $last_name;
         $newuser->email = $email;
         $newuser->is_active = ACTIVE;
         if (!empty($_FILES['userfile']['name'])) {
             $myUploadobj = new FileUploader();
             //creating instance of file.
             $image_type = 'image';
             $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, $image_type);
             if ($file == false) {
                 $msg = $myUploadobj->error;
                 $error = TRUE;
             } else {
                 $newuser->picture = $file;
             }
         }
         if ($error == FALSE) {
             try {
                 if ($use_parent_email) {
                     $newuser->save($check_unique_email = false);
                 } else {
                     $newuser->save($check_unique_email = true);
                 }
                 if (!empty($file)) {
                     Storage::link($file, array("role" => "avatar", "user" => $newuser->user_id));
                 }
                 // creating message basic folders
                 Message::create_basic_folders($newuser->user_id);
                 // adding default relation
                 if ($newuser->user_id != SUPER_USER_ID) {
                     User_Registration::add_default_relation($newuser->user_id, PA::$network_info);
                 }
                 // adding default media as well as album
                 User_Registration::add_default_media($newuser->user_id, '', PA::$network_info);
                 User_Registration::add_default_media($newuser->user_id, '_audio', PA::$network_info);
                 User_Registration::add_default_media($newuser->user_id, '_video', PA::$network_info);
                 User_Registration::add_default_blog($newuser->user_id);
                 //adding default link categories & links
                 User_Registration::add_default_links($newuser->user_id);
                 // code for adding default desktop image for user
                 $desk_img = uihelper_add_default_desktopimage($newuser->user_id);
                 if (empty($desk_img)) {
                     $desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
                     $rand_key = array_rand($desktop_images);
                     $desk_img = $desktop_images[$rand_key];
                 }
                 $states = array_values(PA::getStatesList());
                 $countries = array_values(PA::getCountryList());
                 $profile_keys = array('dob_day', 'dob_month', 'dob_year', 'homeAddress1', 'homeAddress2', 'city', 'state', 'country', 'postal_code', 'phone', 'use_parent_email');
                 $profile_data = array();
                 filter_all_post($_POST);
                 //filters all data of html
                 foreach ($profile_keys as $k => $pkey) {
                     if (!empty($_POST[$pkey])) {
                         if ($pkey == 'state' && $_POST[$pkey] >= 0) {
                             $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $states[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
                         } else {
                             if ($pkey == 'country' && $_POST[$pkey] >= 0) {
                                 $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $countries[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
                             } else {
                                 $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $_POST[$pkey], 'type' => GENERAL, 'perm' => 1);
                             }
                         }
                         $profile_data[] = $prof_rec;
                     }
                 }
                 $profile_data[] = array('uid' => $newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1);
                 //     echo "<pre>".print_r($profile_data,1)."</pre>";
                 $newuser->save_user_profile($profile_data, GENERAL);
                 //if new user is created in a network then he must set as a joined user
                 if (!empty(PA::$network_info)) {
                     $by_admin = true;
                     Network::join(PA::$network_info->network_id, $newuser->user_id, NETWORK_MEMBER, $by_admin);
                     // $by_admin = true overrides the
                     // user_waiting status if it would get set
                     // this is an admin action, so we want it to happen in any case
                 }
                 $user_joined = $this->family->join((int) $newuser->user_id, $newuser->email, null);
                 if ($user_joined) {
                     // deal with TypedGroup Relations
                     require_once "api/Entity/TypedGroupEntityRelation.php";
                     $type = 'child';
                     TypedGroupEntityRelation::set_relation($newuser->user_id, $this->family->collection_id, $type);
                     if ($type == 'child') {
                         // if user type == child remove LoginUser and GroupMember roles
                         $newuser->delete_user_role();
                         // then assign 'Child' role only
                         $_extra = serialize(array('user' => false, 'network' => false, 'groups' => array($this->family->collection_id)));
                         $user_roles[] = array('role_id' => CHILD_MEMBER_ROLE, 'extra' => $_extra);
                         $newuser->set_user_role($user_roles);
                     }
                 }
                 $msg = __("Child's account was successfully created");
             } catch (PAException $e) {
                 $msg = $e->message;
             }
         }
         // end if
     }
     //end if
     $error_msg = $msg;
 }