function getBiographicalFeature(User $user, $feature)
{
    switch ($feature) {
        case "name":
            $feat_str = $user->getName("%f %l");
            break;
        case "group":
            $feat_str = $user->getGroup();
            break;
        case "role":
            $feat_str = $user->getRole();
            break;
        case "photo":
            $official_photo = UserPhoto::get($user->getID(), UserPhoto::OFFICIAL);
            $feat_str = $official_photo->getFilename();
            break;
        case "organisation":
            $organisation = $user->getOrganisation();
            $feat_str = $organisation->getTitle();
            break;
        case "email":
            $feat_str = $user->getEmail();
            break;
        case "email_alt":
            $feat_str = $user->getEmailAlternate();
            break;
        case "address":
            $address = $user->getAddress();
            $postcode = $user->getPostalCode();
            $city = $user->getCity();
            $province = $user->getProvince();
            $prov_name = $province->getName();
            $country = $user->getCountry();
            $country_name = $country->getName();
            $feat_str = html_encode($address) . "<br />" . html_encode($city);
            if ($prov_name) {
                $feat_str .= ", " . html_encode($prov_name);
            }
            $feat_str .= "<br />";
            $feat_str .= html_encode($country_name);
            if ($postcode) {
                $feat_str .= ", " . html_encode($postcode);
            }
            break;
        case "phone":
            $feat_str = $user->getTelephone();
            break;
        case "fax":
            $feat_str = $user->getFax();
            break;
        default:
            Zend_Debug::dump($feature);
            return;
    }
    return $feat_str;
}
//Checking for user logged in or not
if (isset($_REQUEST['submit'])) {
    extract($_REQUEST);
    $user = new User();
    $user->setName($_POST['name']);
    $user->setSecName($_POST['secname']);
    $user->setAdress($_POST['adress']);
    $user->setCity($_POST['city']);
    $user->setEmail($_POST['email']);
    $user->setPasswd($_POST['passwd']);
    $user->setJbg($_POST['jbg']);
    $user->setPhone($_POST['phone']);
    $user->setMphone($_POST['mphone']);
    $user->setImageUrl($_POST['image_url']);
    $signup = new LoginDAO();
    $register = $signup->reg_user($user->getName(), $user->getSecName(), $user->getAdress(), $user->getCity(), $user->getEmail(), $user->getPasswd(), $user->getJbg(), $user->getPhone(), $user->getMphone(), $user->getImageUrl());
    if ($register) {
        //echo '<h3>Registration successful <a href="loginPage.php">Click here</a> to login</h3>';
        echo "Proverite Vaš email i potvrdite registraciju!";
        $rowreg = $register->fetch_assoc();
        $enabled = $rowreg['enabled'];
        $checkuser_id = $rowreg['checkuser_id'];
        $to_email = $rowreg['email'];
        $url_project = URL_PROJECT;
        $subject = "Prijava na Smart-Porudzbine";
        $foremail = "<html><head>\n                            <title>Prijava na Smart-Porudzbine</title>\n                            </head>\n                            <body>\n                            <p>Poštovani {$user->getName()},</p>\n                            <p>Prijavili ste se na Smart-Porudzbine aplikaciju koristeći - {$user->getEmail()}</p>\n                            <p>i sifru: - {$user->getPasswd()}</p>";
        $foremail .= "Proverite i <a href='{$url_project}/loginPage.php?cr={$checkuser_id}' style='color: #8b0000'>klikom na ovaj link POTVRDITE</a> registraciju!<br />";
        $foremail .= "Ako je u pitanju greška obrišite ovaj email,<br />";
        $foremail .= "ili možete da <a href='{$url_project}/loginPage.php?dr={$checkuser_id}' style='color: #8b0000'>klikom na ovaj link OTKAŽETE</a> registraciju.";
        $email = new EmailDAO();
        $regEmail = $email->sendEmail($foremail, $checkuser_id, $to_email, $subject);
/**
 * This displays a person's name, picture etc. including basic biographical information and assistant info if relevant
 * @param User $user
 */
function display_person(User $user)
{
    global $ENTRADA_ACL;
    $photos = $user->getPhotos();
    $user_id = $user->getID();
    $is_administrator = $ENTRADA_ACL->amIallowed('user', 'update');
    $prefix = $user->getPrefix();
    $firstname = $user->getFirstname();
    $lastname = $user->getLastname();
    $fullname = $user->getName("%f %l");
    $departments = $user->getDepartments();
    if (0 < count($departments)) {
        $dep_titles = array();
        foreach ($departments as $department) {
            $dep_titles[] = ucwords($department->getTitle());
        }
        $group_line = implode("<br />", $dep_titles);
    } else {
        $group = $user->getGroup();
        $role = $user->getRole();
        $group_line = ucwords($group . " > " . ($group == "student" ? "Class of " : "") . $role);
    }
    $privacy_level = $user->getPrivacyLevel();
    $organisation = $user->getOrganisation();
    $org_name = $organisation ? $organisation->getTitle() : "";
    $email = 1 < $privacy_level || $is_administrator ? $user->getEmail() : "";
    $email_alt = $user->getAlternateEmail();
    if (2 < $privacy_level || $is_administrator) {
        $show_address = true;
        $city = $user->getCity();
        $province = $user->getProvince();
        $prov_name = $province->getName();
        $country = $user->getCountry();
        $country_name = $country->getName();
        $phone = $user->getTelephone();
        $fax = $user->getFax();
        $address = $user->getAddress();
        $postcode = $user->getPostalCode();
        $office_hours = $user->getOfficeHours();
    }
    $assistants = $user->getAssistants();
    //there are 4 photo cases (at time of writing): no photos, official only, uploaded only, or both.
    //privacy options also need to be considered here.
    ob_start();
    ?>
	<div id="result-<?php 
    echo $user_id;
    ?>
" class="person-result">
		<div id="img-holder-<?php 
    echo $user_id;
    ?>
" class="img-holder">
		<?php 
    $num_photos = count($photos);
    if (0 === $num_photos) {
        echo display_photo_placeholder();
    } else {
        foreach ($photos as $photo) {
            echo display_photo($photo);
        }
        if (2 <= $num_photos) {
            $label = 0;
            foreach ($photos as $photo) {
                echo display_photo_link($photo, ++$label);
            }
        }
        echo display_zoom_controls($user_id);
    }
    ?>
		</div>
		<div class="person-data">
			<div class="basic">
				<span class="person-name"><?php 
    echo html_encode($fullname);
    ?>
</span>
				<span class="person-group"><?php 
    echo html_encode($group_line);
    ?>
</span>
				<span class="person-organisation"><?php 
    echo html_encode($org_name);
    ?>
</span>
				<div class="email-container">
				<?php 
    if ($email) {
        echo display_person_email($email);
        if ($email_alt) {
            echo display_person_email($email_alt);
        }
    }
    ?>
				</div>
			</div>
			<div class="address">
			<?php 
    if ($show_address) {
        if ($phone) {
            ?>
						<div>
							<span class="address-label">Telephone:</span>
							<span class="address-value"><?php 
            echo html_encode($phone);
            ?>
</span>
						</div>
						<?php 
        }
        if ($fax) {
            ?>
						<div>
							<span class="address-label">Fax:</span>
							<span class="address-value"><?php 
            echo html_encode($fax);
            ?>
</span>
						</div>
						<?php 
        }
        if ($address && $city) {
            ?>
						<div>
							<span class="address-label">Address:</span><br />
							<span class="address-value">
							<?php 
            echo html_encode($address) . "<br />" . html_encode($city);
            if ($prov_name) {
                echo ", " . html_encode($prov_name);
            }
            echo "<br />";
            echo html_encode($country_name);
            if ($postcode) {
                echo ", " . html_encode($postcode);
            }
            ?>
							</span>
						</div>
						<?php 
        }
        if ($office_hours) {
            ?>
						<div>
							<span class="address-label">Office Hours:</span>
							<span class="address-value"><?php 
            echo html_encode($office_hours);
            ?>
</span>
						</div>
						<?php 
        }
    }
    ?>
			</div>
			<div class="assistant"><?php 
    if (count($assistants) > 0) {
        ?>
				<span class="content-small">Administrative Assistants:</span>
				<ul class="assistant-list">
					<?php 
        foreach ($assistants as $assistant) {
            echo "<li>" . display_person_email($assistant->getEmail(), $assistant->getName("%f %l")) . "</li>";
        }
        ?>
				</ul><?php 
    }
    ?>
			</div>
		</div>
		<div></div>
		<div class="clearfix">&nbsp;</div>
	</div>

	<?php 
    return ob_get_clean();
}
 function ShowURL($params)
 {
     $tempUser = new User($params['CustomerID']);
     //Customer Information from CE
     $params['userID'] = "CE" . $tempUser->getId();
     $params['userEmail'] = $tempUser->getEmail();
     $params['userFirstName'] = $tempUser->getFirstName();
     $params['userLastName'] = $tempUser->getLastName();
     $params['userOrganization'] = $tempUser->getOrganization();
     $params['userAddress'] = $tempUser->getAddress();
     $params['userCity'] = $tempUser->getCity();
     $params['userState'] = $tempUser->getState();
     $params['userZipcode'] = $tempUser->getZipCode();
     $params['userCountry'] = $tempUser->getCountry();
     $params['userPhone'] = $tempUser->getPhone();
     // Get customer Authnet CIM profile
     $customerProfile = $this->getCustomerProfile($params);
     if ($customerProfile['error']) {
         return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
             <html xmlns="http://www.w3.org/1999/xhtml">
                 <head>
                     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                     <title>Untitled Document</title>
                 </head>
                 <body>' . $customerProfile['detail'] . '</body>
             </html>';
     }
     //Authorize.net CIM Credentials from CE plugin
     $myapilogin = $this->settings->get('plugin_authnetcim_Authorize.Net CIM API Login ID');
     $mYtRaNsaCTiOnKEy = $this->settings->get('plugin_authnetcim_Authorize.Net CIM Transaction Key');
     $sandbox = $this->settings->get('plugin_authnetcim_Authorize.Net CIM Test Mode');
     $USE_DEVELOPMENT_SERVER = $sandbox ? AuthnetCIM::USE_DEVELOPMENT_SERVER : AuthnetCIM::USE_PRODUCTION_SERVER;
     //Need to check to see if user is coming from signup
     if ($params['isSignup']) {
         // Actually handle the signup URL setting
         if ($this->settings->get('Signup Completion URL') != '') {
             $returnURL = $this->settings->get('Signup Completion URL') . '?success=1';
         } else {
             $returnURL = $params["clientExecURL"] . "/order.php?step=complete&pass=1";
         }
         $hosted_Profile_Page_Border_Visible = 'true';
     } else {
         $hosted_Profile_Page_Border_Visible = 'false';
         $returnURL = $params['returnURL'];
     }
     // Get the Hosted Profile Page
     $hosted_Profile_Return_Url_Text = 'Continue to confirmation page.';
     $hosted_Profile_Card_Code_Required = 'true';
     $hosted_Profile_Billing_Address_Required = 'true';
     try {
         $cim = new AuthnetCIM($myapilogin, $mYtRaNsaCTiOnKEy, $USE_DEVELOPMENT_SERVER);
         $cim->setParameter('customerProfileId', $customerProfile['profile_id']);
         if ($params['isSignup']) {
             $cim->setParameter('hostedProfileReturnUrl', $returnURL);
         } else {
             $cim->setParameter('hostedProfileIFrameCommunicatorUrl', $returnURL);
         }
         $cim->setParameter('hostedProfileReturnUrlText', $hosted_Profile_Return_Url_Text);
         $cim->setParameter('hostedProfilePageBorderVisible', $hosted_Profile_Page_Border_Visible);
         $cim->setParameter('hostedProfileCardCodeRequired', $hosted_Profile_Card_Code_Required);
         $cim->setParameter('hostedProfileBillingAddressRequired', $hosted_Profile_Billing_Address_Required);
         $cim->getHostedProfilePage();
         // Get the token for the profile
         if ($cim->isSuccessful()) {
             $profile_token = $cim->getProfileToken();
             return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                 <html xmlns="http://www.w3.org/1999/xhtml">
                     <body>
                         <form id="formAuthorizeNetPage" method="post" action="https://' . ($sandbox ? 'test' : 'secure') . '.authorize.net/profile/manage">
                             <input type="hidden" name="token" value="' . $profile_token . '"/>
                         </form>
                         <script type="text/javascript">
                             document.getElementById("formAuthorizeNetPage").submit();
                         </script>
                     </body>
                 </html>';
         } else {
             return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                 <html xmlns="http://www.w3.org/1999/xhtml">
                     <head>
                         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                         <title>Untitled Document</title>
                     </head>
                     <body>' . $cim->getResponseSummary() . '</body>
                 </html>';
         }
     } catch (AuthnetCIMException $e) {
         return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
             <html xmlns="http://www.w3.org/1999/xhtml">
                 <head>
                     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                     <title>Untitled Document</title>
                 </head>
                 <body>' . $e . '</body>
             </html>';
     }
 }