Ejemplo n.º 1
0
        if (is_numeric($CountNotifications) && $CountNotifications > 0) {
            $Name .= ' <span class="Alert">' . $CountNotifications . '</span>';
        }
        if (urlencode($Session->User->Name) == $Session->User->Name) {
            $ProfileSlug = $Session->User->Name;
        } else {
            $ProfileSlug = $Session->UserID . '/' . urlencode($Session->User->Name);
        }
        $this->Menu->AddLink('User', T('Profile'), '/profile/' . $ProfileSlug, array('Garden.SignIn.Allow'), array('class' => 'UserNotifications'));
        //$this->Menu->AddLink('SignOut', T('Sign Out'), SignOutUrl(), FALSE, array('class' => 'NonTab SignOut'));
    } else {
        $Attribs = array();
        if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE) {
            $Attribs['class'] = 'SignInPopup';
        }
        $this->Menu->AddLink('Entry', T('Sign In'), SignInUrl($this->SelfUrl), FALSE, array('class' => 'NonTab'), $Attribs);
    }
    echo $this->Menu->ToString();
}
?>
    </div>
  </div>
  <div id="Body">
    <div class="Row">
      <div class="Column PanelColumn" id="Panel">
         <?php 
$this->AddModule('MeModule');
?>
         <?php 
$this->RenderAsset('Panel');
?>
Ejemplo n.º 2
0
    function WriteEmbedCommentForm()
    {
        $Session = Gdn::Session();
        $Controller = Gdn::Controller();
        $Discussion = $Controller->Data('Discussion');
        if ($Discussion && $Discussion->Closed == '1') {
            ?>
   <div class="Foot Closed">
      <div class="Note Closed"><?php 
            echo T('This discussion has been closed.');
            ?>
</div>
   </div>
   <?php 
        } else {
            ?>
   <h2><?php 
            echo T('Leave a comment');
            ?>
</h2>
   <div class="MessageForm CommentForm EmbedCommentForm">
      <?php 
            echo $Controller->Form->Open();
            echo $Controller->Form->Errors();
            echo Wrap($Controller->Form->TextBox('Body', array('MultiLine' => TRUE)), 'div', array('class' => 'TextBoxWrapper'));
            echo "<div class=\"Buttons\">\n";
            $AllowSigninPopup = C('Garden.SignIn.Popup');
            $Attributes = array('tabindex' => '-1');
            $ReturnUrl = Gdn::Request()->PathAndQuery();
            if ($Session->IsValid()) {
                $AuthenticationUrl = Gdn::Authenticator()->SignOutUrl($ReturnUrl);
                echo Wrap(sprintf(T('Commenting as %1$s (%2$s)', 'Commenting as %1$s <span class="SignOutWrap">(%2$s)</span>'), Gdn_Format::Text($Session->User->Name), Anchor(T('Sign Out'), $AuthenticationUrl, 'SignOut', $Attributes)), 'div', array('class' => 'Author'));
                echo $Controller->Form->Button('Post Comment', array('class' => 'Button CommentButton'));
            } else {
                $AuthenticationUrl = SignInUrl($ReturnUrl);
                if ($AllowSigninPopup) {
                    $CssClass = 'SignInPopup Button Stash';
                } else {
                    $CssClass = 'Button Stash';
                }
                echo Anchor(T('Comment As ...'), $AuthenticationUrl, $CssClass, $Attributes);
            }
            echo "</div>\n";
            echo $Controller->Form->Close();
            ?>
   </div>
   <?php 
        }
    }
Ejemplo n.º 3
0
echo t('Howdy, Stranger!');
?>
</h4>

    <p><?php 
echo t($this->MessageCode, $this->MessageDefault);
?>
</p>

    <p><?php 
$this->fireEvent('BeforeSignInButton');
?>
</p>

    <?php 
$signInUrl = SignInUrl($this->_Sender->SelfUrl);
if ($signInUrl) {
    echo '<div class="P">';
    echo anchor(t('Sign In'), SignInUrl($this->_Sender->SelfUrl), 'Button Primary' . (SignInPopup() ? ' SignInPopup' : ''), array('rel' => 'nofollow'));
    $Url = RegisterUrl($this->_Sender->SelfUrl);
    if (!empty($Url)) {
        echo ' ' . anchor(t('Register', t('Apply for Membership', 'Register')), $Url, 'Button ApplyButton', array('rel' => 'nofollow'));
    }
    echo '</div>';
}
?>
    <?php 
$this->fireEvent('AfterSignInButton');
?>
</div>
Ejemplo n.º 4
0
if (!$Editing && $Session->IsValid()) {
    echo Anchor(T('Preview'), '#', 'PreviewButton') . "\n";
    echo Anchor(T('Edit'), '#', 'WriteButton Hidden') . "\n";
    if ($NewOrDraft) {
        echo Anchor(T('Save Draft'), '#', 'DraftButton') . "\n";
    }
}
if ($Session->IsValid()) {
    echo $this->Form->Button($Editing ? 'Save Comment' : 'Post Comment', $ButtonOptions);
} else {
    $AllowSigninPopup = C('Garden.SignIn.Popup');
    $Attributes = array('tabindex' => '-1');
    if (!$AllowSigninPopup) {
        $Attributes['target'] = '_parent';
    }
    $AuthenticationUrl = SignInUrl($this->Data('ForeignUrl', '/'));
    $CssClass = 'Button Primary Stash';
    if ($AllowSigninPopup) {
        $CssClass .= ' SignInPopup';
    }
    echo Anchor(T('Comment As ...'), $AuthenticationUrl, $CssClass, $Attributes);
}
$this->FireEvent('AfterFormButtons');
echo "</div>\n";
echo $this->Form->Close();
//               echo '</div>';
?>
            </div>
         </div>
      </div>
   </div>
Ejemplo n.º 5
0
 /**
  * Approve a membership applicant.
  *
  * @param $UserID
  * @param $Email
  * @return bool
  * @throws Exception
  */
 public function approve($UserID, $Email)
 {
     $applicantRoleIDs = RoleModel::getDefaultRoles(RoleModel::TYPE_APPLICANT);
     // Make sure the $UserID is an applicant
     $RoleData = $this->getRoles($UserID);
     if ($RoleData->numRows() == 0) {
         throw new Exception(t('ErrorRecordNotFound'));
     } else {
         $AppRoles = $RoleData->result(DATASET_TYPE_ARRAY);
         $ApplicantFound = false;
         foreach ($AppRoles as $AppRole) {
             if (in_array(val('RoleID', $AppRole), $applicantRoleIDs)) {
                 $ApplicantFound = true;
             }
         }
     }
     if ($ApplicantFound) {
         // Retrieve the default role(s) for new users
         $RoleIDs = RoleModel::getDefaultRoles(RoleModel::TYPE_MEMBER);
         // Wipe out old & insert new roles for this user
         $this->saveRoles($UserID, $RoleIDs, false);
         // Send out a notification to the user
         $User = $this->getID($UserID);
         if ($User) {
             $Email->subject(sprintf(t('[%1$s] Membership Approved'), c('Garden.Title')));
             $Email->message(sprintf(t('EmailMembershipApproved'), $User->Name, ExternalUrl(SignInUrl())));
             $Email->to($User->Email);
             //$Email->from(c('Garden.SupportEmail'), c('Garden.SupportName'));
             $Email->send();
             // Report that the user was approved.
             $ActivityModel = new ActivityModel();
             $ActivityModel->save(array('ActivityUserID' => $UserID, 'ActivityType' => 'Registration', 'HeadlineFormat' => t('HeadlineFormat.Registration', '{ActivityUserID,You} joined.'), 'Story' => t('Welcome Aboard!')), false, array('GroupBy' => 'ActivityTypeID'));
             // Report the approval for moderators.
             $ActivityModel->save(array('ActivityType' => 'Registration', 'ActivityUserID' => Gdn::session()->UserID, 'RegardingUserID' => $UserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'HeadlineFormat' => t('HeadlineFormat.RegistrationApproval', '{ActivityUserID,user} approved the applications for {RegardingUserID,user}.')), false, array('GroupBy' => array('ActivityTypeID', 'ActivityUserID')));
             Gdn::userModel()->saveAttribute($UserID, 'ApprovedByUserID', Gdn::session()->UserID);
         }
     }
     return true;
 }
Ejemplo n.º 6
0
   $this->AddDefinition('Vanilla_Comments_AutoRefresh', Gdn::Config('Vanilla.Comments.AutoRefresh', 0));
}

echo $this->Pager->ToString('more');

// Write out the comment form
if ($this->Discussion->Closed == '1') {
   ?>
   <div class="Foot Closed">
      <div class="Note Closed"><?php echo T('This discussion has been closed.'); ?></div>
      <?php echo Anchor(T('&larr; All Discussions'), 'discussions', 'TabLink'); ?>
   </div>
   <?php
} else if ($Session->IsValid() && $Session->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $this->Discussion->PermissionCategoryID)) {
   echo $this->FetchView('comment', 'post');
} else if ($Session->IsValid()) { ?>
   <div class="Foot Closed">
      <div class="Note Closed"><?php echo T('Commenting not allowed.'); ?></div>
      <?php echo Anchor(T('&larr; All Discussions'), 'discussions', 'TabLink'); ?>
   </div>
   <?php
} else {
   ?>
   <div class="Foot">
      <?php
      echo Anchor(T('Add a Comment'), SignInUrl($this->SelfUrl.(strpos($this->SelfUrl, '?') ? '&' : '?').'post#Form_Body'), 'TabLink'.(SignInPopup() ? ' SignInPopup' : ''));
      ?> 
   </div>
   <?php 
}
Ejemplo n.º 7
0
        $CSpam = $SpamCount > 0 ? ' ' . Wrap($SpamCount, 'span class="Alert"') : '';
        $CModeration = $ModerationCount > 0 ? ' ' . Wrap($ModerationCount, 'span class="Alert"') : '';
        echo Wrap(Anchor(Sprite('SpApplicants') . ' ' . T('Applicants') . $CApplicant, '/dashboard/user/applicants'), 'li');
        echo Wrap(Anchor(Sprite('SpSpam') . ' ' . T('Spam Queue') . $CSpam, '/dashboard/log/spam'), 'li');
        echo Wrap(Anchor(Sprite('SpMod') . ' ' . T('Moderation Queue') . $CModeration, '/dashboard/log/moderation'), 'li');
        echo Wrap(Anchor(Sprite('SpDashboard') . ' ' . T('Dashboard'), '/dashboard/settings'), 'li');
    }
    $this->FireEvent('FlyoutMenu');
    echo Wrap('<hr />', 'li');
    echo Wrap(Anchor(Sprite('SpSignOut') . ' ' . T('Sign Out'), SignOutUrl()), 'li');
    echo '</div>';
    echo '</span>';
    // Sign Out
    // echo Anchor(Sprite('SpSignOut', 'Sprite16').Wrap(T('Sign Out'), 'em'), SignOutUrl(), 'MeButton', array('title' => T('Sign Out')));
    echo '</div>';
    echo '</div>';
    echo '</div>';
} else {
    echo '<div class="MeBox MeBox-SignIn' . $CssClass . '">';
    echo '<div class="SignInLinks">';
    echo Anchor(T('Sign In'), SignInUrl($this->_Sender->SelfUrl), SignInPopup() ? ' SignInPopup' : '', array('rel' => 'nofollow'));
    $Url = RegisterUrl($this->_Sender->SelfUrl);
    if (!empty($Url)) {
        echo ' <span class="Bullet">•</span> ' . Anchor(T('Register'), $Url, 'ApplyButton', array('rel' => 'nofollow')) . ' ';
    }
    echo '</div>';
    echo ' <div class="SignInIcons">';
    $this->FireEvent('SignInIcons');
    echo '</div>';
    echo '</div>';
}
Ejemplo n.º 8
0
 public static function Link($Path, $Text = FALSE, $Format = NULL, $Options = array())
 {
     $Session = Gdn::Session();
     $Class = GetValue('class', $Options, '');
     $WithDomain = GetValue('WithDomain', $Options);
     $Target = GetValue('Target', $Options, '');
     if ($Target == 'current') {
         $Target = trim(Url('', TRUE), '/ ');
     }
     if (is_null($Format)) {
         $Format = '<a href="%url" class="%class">%text</a>';
     }
     switch ($Path) {
         case 'activity':
             TouchValue('Permissions', $Options, 'Garden.Activity.View');
             break;
         case 'category':
             $Breadcrumbs = Gdn::Controller()->Data('Breadcrumbs');
             if (is_array($Breadcrumbs) && count($Breadcrumbs) > 0) {
                 $Last = array_pop($Breadcrumbs);
                 $Path = GetValue('Url', $Last);
                 $DefaultText = GetValue('Name', $Last, T('Back'));
             } else {
                 $Path = '/';
                 $DefaultText = C('Garden.Title', T('Back'));
             }
             if (!$Text) {
                 $Text = $DefaultText;
             }
             break;
         case 'dashboard':
             $Path = 'dashboard/settings';
             TouchValue('Permissions', $Options, array('Garden.Settings.Manage', 'Garden.Settings.View'));
             if (!$Text) {
                 $Text = T('Dashboard');
             }
             break;
         case 'home':
             $Path = '/';
             if (!$Text) {
                 $Text = T('Home');
             }
             break;
         case 'inbox':
             $Path = 'messages/inbox';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('Inbox');
             }
             if ($Session->IsValid() && $Session->User->CountUnreadConversations) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountUnreadConversations . '</span>';
             }
             if (!$Session->IsValid()) {
                 $Text = FALSE;
             }
             break;
         case 'forumroot':
             $Route = Gdn::Router()->GetDestination('DefaultForumRoot');
             if (is_null($Route)) {
                 $Path = '/';
             } else {
                 $Path = CombinePaths(array('/', $Route));
             }
             break;
         case 'profile':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $Text = $Session->User->Name;
             }
             if ($Session->IsValid() && $Session->User->CountNotifications) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountNotifications . '</span>';
             }
             break;
         case 'user':
             $Path = 'profile';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $Text = $Session->User->Name;
             }
             break;
         case 'photo':
             $Path = 'profile';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $IsFullPath = strtolower(substr($Session->User->Photo, 0, 7)) == 'http://' || strtolower(substr($Session->User->Photo, 0, 8)) == 'https://';
                 $PhotoUrl = $IsFullPath ? $Session->User->Photo : Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'n%s'));
                 $Text = Img($PhotoUrl, array('alt' => htmlspecialchars($Session->User->Name)));
             }
             break;
         case 'drafts':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Drafts');
             }
             if ($Session->IsValid() && $Session->User->CountDrafts) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountDrafts . '</span>';
             }
             break;
         case 'discussions/bookmarked':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Bookmarks');
             }
             if ($Session->IsValid() && $Session->User->CountBookmarks) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Count">' . $Session->User->CountBookmarks . '</span>';
             }
             break;
         case 'discussions/mine':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Discussions');
             }
             if ($Session->IsValid() && $Session->User->CountDiscussions) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Count">' . $Session->User->CountDiscussions . '</span>';
             }
             break;
         case 'signin':
         case 'signinout':
             // The destination is the signin/signout toggle link.
             if ($Session->IsValid()) {
                 if (!$Text) {
                     $Text = T('Sign Out');
                 }
                 $Path = SignOutUrl($Target);
                 $Class = ConcatSep(' ', $Class, 'SignOut');
             } else {
                 if (!$Text) {
                     $Text = T('Sign In');
                 }
                 $Attribs = array();
                 $Path = SignInUrl($Target);
                 if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE) {
                     $Class = ConcatSep(' ', $Class, 'SignInPopup');
                 }
             }
             break;
     }
     if ($Text == FALSE && strpos($Format, '%text') !== FALSE) {
         return '';
     }
     if (GetValue('Permissions', $Options) && !$Session->CheckPermission($Options['Permissions'], FALSE)) {
         return '';
     }
     $Url = Gdn::Request()->Url($Path, $WithDomain);
     if ($TK = GetValue('TK', $Options)) {
         if (in_array($TK, array(1, 'true'))) {
             $TK = 'TransientKey';
         }
         $Url .= (strpos($Url, '?') === FALSE ? '?' : '&') . $TK . '=' . urlencode(Gdn::Session()->TransientKey());
     }
     if (strcasecmp(trim($Path, '/'), Gdn::Request()->Path()) == 0) {
         $Class = ConcatSep(' ', $Class, 'Selected');
     }
     // Build the final result.
     $Result = $Format;
     $Result = str_replace('%url', $Url, $Result);
     $Result = str_replace('%text', $Text, $Result);
     $Result = str_replace('%class', $Class, $Result);
     return $Result;
 }
 /**
  * Approve a membership applicant.
  */
 public function Approve($UserID, $Email)
 {
     $ApplicantRoleID = C('Garden.Registration.ApplicantRoleID', 0);
     // Make sure the $UserID is an applicant
     $RoleData = $this->GetRoles($UserID);
     if ($RoleData->NumRows() == 0) {
         throw new Exception(T('ErrorRecordNotFound'));
     } else {
         $AppRoles = $RoleData->Result(DATASET_TYPE_ARRAY);
         $ApplicantFound = FALSE;
         foreach ($AppRoles as $AppRole) {
             if (GetValue('RoleID', $AppRole) == $ApplicantRoleID) {
                 $ApplicantFound = TRUE;
             }
         }
     }
     if ($ApplicantFound) {
         // Retrieve the default role(s) for new users
         $RoleIDs = C('Garden.Registration.DefaultRoles', array(8));
         // Wipe out old & insert new roles for this user
         $this->SaveRoles($UserID, $RoleIDs, FALSE);
         // Send out a notification to the user
         $User = $this->GetID($UserID);
         if ($User) {
             $Email->Subject(sprintf(T('[%1$s] Membership Approved'), C('Garden.Title')));
             $Email->Message(sprintf(T('EmailMembershipApproved'), $User->Name, ExternalUrl(SignInUrl())));
             $Email->To($User->Email);
             //$Email->From(C('Garden.SupportEmail'), C('Garden.SupportName'));
             $Email->Send();
             // Report that the user was approved.
             $ActivityModel = new ActivityModel();
             $ActivityModel->Save(array('ActivityUserID' => $UserID, 'ActivityType' => 'Registration', 'HeadlineFormat' => T('HeadlineFormat.Registration', '{ActivityUserID,You} joined.'), 'Story' => T('Welcome Aboard!')), FALSE, array('GroupBy' => 'ActivityTypeID'));
             // Report the approval for moderators.
             $ActivityModel->Save(array('ActivityType' => 'Registration', 'ActivityUserID' => Gdn::Session()->UserID, 'RegardingUserID' => $UserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'HeadlineFormat' => T('HeadlineFormat.RegistrationApproval', '{ActivityUserID,user} approved the applications for {RegardingUserID,user}.')), FALSE, array('GroupBy' => array('ActivityTypeID', 'ActivityUserID')));
             Gdn::UserModel()->SaveAttribute($UserID, 'ApprovedByUserID', Gdn::Session()->UserID);
         }
     }
     return TRUE;
 }
Ejemplo n.º 10
0
 /**
  *
  *
  * @param SiteNavModule $sender
  */
 public function siteNavModule_all_handler($sender)
 {
     // Add a link to the community home.
     $sender->addLink('main.home', array('text' => t('Community Home'), 'url' => '/', 'icon' => icon('home'), 'sort' => -100));
     $sender->addGroup('etc', array('sort' => 100));
     if (Gdn::session()->isValid()) {
         // Switch between the full site and mobile.
         if (IsMobile()) {
             $sender->addLink('etc.nomobile', array('text' => t('Full Site'), 'url' => '/profile/nomobile', 'icon' => icon('resize-full'), 'sort' => 100));
         }
         $sender->addLink('etc.signout', array('text' => t('Sign Out'), 'url' => SignOutUrl(), 'icon' => icon('signout'), 'sort' => 100));
     } else {
         $sender->addLink('etc.signin', array('text' => t('Sign In'), 'url' => SignInUrl(), 'icon' => icon('signin'), 'sort' => 100));
     }
 }
Ejemplo n.º 11
0
    function writeEmbedCommentForm()
    {
        $Session = Gdn::session();
        $Controller = Gdn::controller();
        $Discussion = $Controller->data('Discussion');
        if ($Discussion && $Discussion->Closed == '1') {
            ?>
            <div class="Foot Closed">
                <div class="Note Closed"><?php 
            echo t('This discussion has been closed.');
            ?>
</div>
            </div>
        <?php 
        } else {
            ?>
            <h2><?php 
            echo t('Leave a comment');
            ?>
</h2>
            <div class="MessageForm CommentForm EmbedCommentForm">
                <?php 
            echo $Controller->Form->open(array('id' => 'Form_Comment'));
            echo $Controller->Form->errors();
            echo $Controller->Form->Hidden('Name');
            echo wrap($Controller->Form->textBox('Body', array('MultiLine' => TRUE)), 'div', array('class' => 'TextBoxWrapper'));
            echo "<div class=\"Buttons\">\n";
            $AllowSigninPopup = c('Garden.SignIn.Popup');
            $Attributes = array('tabindex' => '-1', 'target' => '_top');
            // If we aren't ajaxing this call then we need to target the url of the parent frame.
            $ReturnUrl = $Controller->data('ForeignSource.vanilla_url', Gdn::request()->PathAndQuery());
            if ($Session->isValid()) {
                $AuthenticationUrl = Gdn::authenticator()->SignOutUrl($ReturnUrl);
                echo wrap(sprintf(t('Commenting as %1$s (%2$s)', 'Commenting as %1$s <span class="SignOutWrap">(%2$s)</span>'), Gdn_Format::text($Session->User->Name), anchor(t('Sign Out'), $AuthenticationUrl, 'SignOut', $Attributes)), 'div', array('class' => 'Author'));
                echo $Controller->Form->button('Post Comment', array('class' => 'Button CommentButton'));
            } else {
                $AuthenticationUrl = url(SignInUrl($ReturnUrl), true);
                if ($AllowSigninPopup) {
                    $CssClass = 'SignInPopup Button Stash';
                } else {
                    $CssClass = 'Button Stash';
                }
                echo anchor(t('Comment As ...'), $AuthenticationUrl, $CssClass, $Attributes);
            }
            echo "</div>\n";
            echo $Controller->Form->close();
            ?>
            </div>
        <?php 
        }
    }
Ejemplo n.º 12
0
 public function SiteNavModule_all_handler($sender)
 {
     // Add a link to the community home.
     $sender->addLink('main.home', array('text' => t('Community Home'), 'url' => '/', 'icon' => icon('home'), 'sort' => -100));
     $sender->addGroup('etc', array('sort' => 100));
     if (Gdn::Session()->IsValid()) {
         $sender->addLink('etc.signout', array('text' => t('Sign Out'), 'url' => SignOutUrl(), 'icon' => icon('signout'), 'sort' => 100));
     } else {
         $sender->addLink('etc.signin', array('text' => t('Sign In'), 'url' => SignInUrl(), 'icon' => icon('signin'), 'sort' => 100));
     }
 }
Ejemplo n.º 13
0
?>
<div class="Box GuestBox">
   <h4><?php 
echo T('Howdy, Stranger!');
?>
</h4>
   <p><?php 
echo T($this->MessageCode, $this->MessageDefault);
?>
</p>
   <div class="GuestBox_cont">
   <?php 
$this->FireEvent('BeforeSignInButton');
?>
   
   <?php 
if (strcasecmp(C('Garden.Registration.Method'), 'Connect') != 0) {
    echo '<div class="P">';
    echo Anchor(T('Sign In'), SignInUrl($this->_Sender->SelfUrl), 'Button' . (SignInPopup() ? ' SignInPopup' : ''));
    $Url = RegisterUrl($this->_Sender->SelfUrl);
    if (!empty($Url)) {
        echo ' ' . Anchor(T('Apply for Membership'), $Url, 'Button ApplyButton');
    }
    echo '</div>';
}
?>
   <?php 
$this->FireEvent('AfterSignInButton');
?>
   </div>
</div>
Ejemplo n.º 14
0
if (!$Editing && $Session->isValid()) {
    echo ' ' . anchor(t('Preview'), '#', 'Button PreviewButton') . "\n";
    echo ' ' . anchor(t('Edit'), '#', 'Button WriteButton Hidden') . "\n";
    if ($NewOrDraft) {
        echo ' ' . anchor(t('Save Draft'), '#', 'Button DraftButton') . "\n";
    }
}
if ($Session->isValid()) {
    echo $this->Form->button($Editing ? 'Save Comment' : 'Post Comment', $ButtonOptions);
} else {
    $AllowSigninPopup = c('Garden.SignIn.Popup');
    $Attributes = array('tabindex' => '-1');
    if (!$AllowSigninPopup) {
        $Attributes['target'] = '_parent';
    }
    $AuthenticationUrl = SignInUrl($this->SelfUrl);
    $CssClass = 'Button Primary Stash';
    if ($AllowSigninPopup) {
        $CssClass .= ' SignInPopup';
    }
    echo anchor(t('Comment As ...'), $AuthenticationUrl, $CssClass, $Attributes);
}
$this->fireEvent('AfterFormButtons');
echo "</div>\n";
echo $this->Form->close();
//               echo '</div>';
?>
                </div>
            </div>
        </div>
    </div>
Ejemplo n.º 15
0
   /**
    * Approve a membership applicant.
    */
   public function Approve($UserID, $Email) {
      $ApplicantRoleID = C('Garden.Registration.ApplicantRoleID', 0);

      // Make sure the $UserID is an applicant
      $RoleData = $this->GetRoles($UserID);
      if ($RoleData->NumRows() == 0) {
         throw new Exception(T('ErrorRecordNotFound'));
      } else {
         $ApplicantFound = FALSE;
         foreach ($RoleData->Result() as $Role) {
            if ($Role->RoleID == $ApplicantRoleID)
               $ApplicantFound = TRUE;
         }
      }

      if ($ApplicantFound) {
         // Retrieve the default role(s) for new users
         $RoleIDs = Gdn::Config('Garden.Registration.DefaultRoles', array(8));

         // Wipe out old & insert new roles for this user
         $this->SaveRoles($UserID, $RoleIDs, FALSE);

         // Send out a notification to the user
         $User = $this->Get($UserID);
         if ($User) {
				$Email->Subject(sprintf(T('[%1$s] Membership Approved'), C('Garden.Title')));
				$Email->Message(sprintf(T('EmailMembershipApproved'), $User->Name, ExternalUrl(SignInUrl())));
				$Email->To($User->Email);
				//$Email->From(C('Garden.SupportEmail'), C('Garden.SupportName'));
				$Email->Send();
         }

         // Report that the user was approved
         $Session = Gdn::Session();
         AddActivity(
            $Session->UserID,
            'JoinApproved',
            T('Welcome Aboard!'),
            $UserID,
            '',
            FALSE
         );
      }
      return TRUE;
   }
Ejemplo n.º 16
0
   public static function Link($Path, $Text = FALSE, $Format = '<a href="%url" class="%class">%text</a>', $Options = array()) {
      $Session = Gdn::Session();
      $Class = GetValue('class', $Options, '');
      $WithDomain = GetValue('WithDomain', $Options);
      $Target = GetValue('Target', $Options, '');

      switch ($Path) {
         case 'activity':
            TouchValue('Permissions', $Options, 'Garden.Activity.View');
            break;
         case 'dashboard':
            $Path = 'dashboard/settings';
            TouchValue('Permissions', $Options, 'Garden.Settings.Manage');
            if (!$Text)
               $Text = T('Dashboard');
            break;
         case 'inbox':
            $Path = 'messages/inbox';
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('Inbox');
            if ($Session->IsValid() && $Session->User->CountUnreadConversations) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Alert">'.$Session->User->CountUnreadConversations.'</span>';
            }
            break;
         case 'profile':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text && $Session->IsValid())
               $Text = $Session->User->Name;
            if ($Session->IsValid() && $Session->User->CountNotifications) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Alert">'.$Session->User->CountNotifications.'</span>';
            }
            break;
         case 'user':
            $Path = 'profile';
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text && $Session->IsValid())
               $Text = $Session->User->Name;

            break;
         case 'photo':
            $Path = 'profile';
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text && $Session->IsValid()) {
               $IsFullPath = strtolower(substr($Session->User->Photo, 0, 7)) == 'http://' || strtolower(substr($Session->User->Photo, 0, 8)) == 'https://';
               $PhotoUrl = ($IsFullPath) ? $Session->User->Photo : Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'n%s'));
               $Text = Img($PhotoUrl, array('alt' => htmlspecialchars($Session->User->Name)));
            }

            break;
         case 'drafts':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('My Drafts');
            if ($Session->IsValid() && $Session->User->CountDrafts) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Alert">'.$Session->User->CountDrafts.'</span>';
            }
            break;
         case 'discussions/bookmarked':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('My Bookmarks');
            if ($Session->IsValid() && $Session->User->CountBookmarks) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Count">'.$Session->User->CountBookmarks.'</span>';
            }
            break;
         case 'discussions/mine':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('My Discussions');
            if ($Session->IsValid() && $Session->User->CountDiscussions) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Count">'.$Session->User->CountDiscussions.'</span>';
            }
            break;
         case 'signin':
         case 'signinout':
            // The destination is the signin/signout toggle link.
            if ($Session->IsValid()) {
               if(!$Text)
                  $Text = T('Sign Out');
               $Path =  SignOutUrl($Target);
               $Class = ConcatSep(' ', $Class, 'SignOut');
            } else {
               if(!$Text)
                  $Text = T('Sign In');
               $Attribs = array();

               $Path = SignInUrl($Target);
               if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE)
                  $Class = ConcatSep(' ', $Class, 'SignInPopup');
            }
            break;
      }

      if (GetValue('Permissions', $Options) && !$Session->CheckPermission($Options['Permissions']))
         return '';

      $Url = Gdn::Request()->Url($Path, $WithDomain);

      if (strcasecmp(trim($Path, '/'), Gdn::Request()->Path()) == 0)
         $Class = ConcatSep(' ', $Class, 'Selected');

      // Build the final result.
      $Result = $Format;
      $Result = str_replace('%url', $Url, $Result);
      $Result = str_replace('%text', $Text, $Result);
      $Result = str_replace('%class', $Class, $Result);

      return $Result;
   }