Ejemplo n.º 1
0
 /**
  * displayNewUserHome 
  * 
  * @param  int  $userid 
  * 
  * @return boolean
  */
 function displayNewUserHome($userid)
 {
     include_once 'addressbook_class.php';
     $addressObj = new AddressBook($this->fcmsError, $this->fcmsDatabase, $this->fcmsUser);
     $userid = (int) $userid;
     $sql = "SELECT `id`\n                FROM `fcms_alerts` \n                WHERE `alert` = 'alert_new_user_home'\n                AND `user` = ? \n                AND `hide` = 1";
     $row = $this->fcmsDatabase->getRow($sql, $userid);
     if ($row === false) {
         $this->fcmsError->displayError();
         return false;
     }
     if (count($row) >= 1) {
         return false;
     }
     $sitename = getSiteName();
     $sitename = cleanOutput($sitename);
     $complete = 0;
     // social media
     $social = '<a href="settings.php?view=socialmedia">' . T_('Connect social media sites') . '</a>';
     if (userConnectedSocialMedia($userid)) {
         $social = '<span>' . T_('Connect social media sites') . '</span>';
         $complete++;
     }
     // add profile pic
     $profilePicture = '<span>' . T_('Add a Profile Picture') . '</span>';
     $complete++;
     $avatar = getCurrentAvatar($userid);
     $checkUploadsPath = 'uploads/avatar/no_avatar.jpg';
     if (defined('UPLOADS')) {
         $checkUploadsPath = 'file.php?a=no_avatar.jpg';
     }
     if ($avatar == $checkUploadsPath) {
         $profilePicture = '<a href="profile.php?view=picture">' . T_('Add a Profile Picture') . '</a>';
         $complete--;
     }
     // update contact info
     $address = '<a href="addressbook.php?cat=all&edit=' . $userid . '">' . T_('Add your Address/Contact information') . '</a>';
     if ($addressObj->userhasAddress($userid)) {
         $address = '<span>' . T_('Add your Address/Contact information') . '</span>';
         $complete++;
     }
     // vote
     $sql = "SELECT MAX(`id`) AS 'max'\n                FROM `fcms_polls`";
     $r = $this->fcmsDatabase->getRow($sql);
     if ($r === false) {
         $this->fcmsError->displayError();
         return;
     }
     $currentPoll = $r['max'];
     $sql = "SELECT `id`\n                FROM `fcms_poll_votes`\n                WHERE `user` = ?\n                AND `poll_id` = ?";
     $rows = $this->fcmsDatabase->getRows($sql, array($userid, $currentPoll));
     if ($rows === false) {
         $this->fcmsError->displayError();
         return;
     }
     $poll = '<a href="polls.php">' . T_('Vote on the Poll') . '</a>';
     if (count($rows) > 0) {
         $poll = '<span>' . T_('Vote on the Poll') . '</span>';
         $complete++;
     }
     $percent = $complete / 4 * 100;
     echo '
     <div id="alert_new_user_home" class="info-alert">
         <h2>' . T_('It looks like you\'re new here.') . '</h2>
         <p>' . T_('Complete the following list to get the most out of the site:') . '</p>
         <small>' . sprintf(T_('Your profile is %s complete.'), $percent) . '</small>
         <div id="progress"><div style="width: ' . $percent . '%"></div></div>
         <ol class="todo">
             <li>' . $social . '</a></li>
             <li>' . $profilePicture . '</a></li>
             <li>' . $address . '</li>
             <li>' . $poll . '</li>
         </ol>
         <p style="text-align:right"><a id="new_admin" href="?alert=alert_new_user_home">' . T_('Skip This and get right to the app.') . '</a></p>
     </div>';
     return true;
 }