コード例 #1
0
ファイル: discussion.php プロジェクト: Aetasiric/Garden
    echo $this->Form->DropDown('CategoryID', $this->CategoryData, array('TextField' => 'Name', 'ValueField' => 'CategoryID'));
    echo '</div>';
}
echo $this->Form->TextBox('Body', array('MultiLine' => TRUE));
$Options = '';
// If the user has any of the following permissions (regardless of junction), show the options
// Note: I need to validate that they have permission in the specified category on the back-end
// TODO: hide these boxes depending on which category is selected in the dropdown above.
if ($Session->CheckPermission('Vanilla.Discussions.Announce')) {
    $Options .= '<li>' . $this->Form->CheckBox('Announce', GDN::Translate('Announce this discussion'), array('value' => '1')) . '</li>';
}
if ($Session->CheckPermission('Vanilla.Discussions.Close')) {
    $Options .= '<li>' . $this->Form->CheckBox('Closed', GDN::Translate('Close this discussion'), array('value' => '1')) . '</li>';
}
if ($Session->CheckPermission('Vanilla.Discussions.Sink')) {
    $Options .= '<li>' . $this->Form->CheckBox('Sink', GDN::Translate('Sink this discussion'), array('value' => '1')) . '</li>';
}
if ($Options != '') {
    echo '<ul class="PostOptions">' . $Options . '</ul>';
}
echo $this->Form->Button(property_exists($this, 'Discussion') ? 'Save' : 'Post Discussion');
if (!property_exists($this, 'Discussion') || !is_object($this->Discussion) || property_exists($this, 'Draft') && is_object($this->Draft)) {
    echo $this->Form->Button('Save Draft');
}
echo $this->Form->Button('Preview');
$this->FireEvent('AfterFormButtons');
echo Anchor(Gdn::Translate('Cancel'), $CancelUrl, 'Cancel');
echo $this->Form->Close();
?>
</div>
コード例 #2
0
ファイル: default.php プロジェクト: ru4/arabbnota
 public function Base_Render_Before(&$Sender)
 {
     $Session = Gdn::Session();
     $dblink = mysql_connect(C('Database.Host'), C('Database.User'), C('Database.Password'), FALSE, 128);
     if (!$dblink) {
         mysql_close($dblink);
         return;
     }
     mysql_select_db(C('Database.Name'));
     $check = mysql_query("SELECT * FROM GDN_Shoutbox;");
     //Check if table exists, create if table doesnt exist.
     if (!$check) {
         mysql_query("CREATE TABLE GDN_Shoutbox (EntryID int(255)AUTO_INCREMENT, PRIMARY KEY(EntryID), Username varchar(256), data varchar(256));", $dblink);
         $check = mysql_query("SELECT * FROM GDN_Shoutbox;");
         if (!$check) {
             //Maybe wrong password for mysql db? dunno...
             return;
         }
     }
     if (isset($_GET["clearall"]) && $_GET["clearall"] == "1") {
         if (!$Session->CheckPermission('Plugins.Van2Shout.Delete')) {
             return;
         }
         $mysqlcmd = mysql_query("DELETE FROM GDN_Shoutbox;", $dblink);
         if (!$mysqlcmd) {
             mysql_close($dblink);
             return;
         }
         $mysqlcmd = mysql_query("INSERT INTO GDN_Shoutbox (Username, data) values ('System', '" . GDN::Translate('Database has been cleared') . "');", $dblink);
         if (!$mysqlcmd) {
             mysql_close($dblink);
             return;
         }
     }
     if (isset($_GET["msg"])) {
         $Session = Gdn::Session();
         if ($_GET["msg"] == "") {
             return;
         }
         if (!$Session->CheckPermission('Plugins.Van2Shout.Post')) {
             return;
         }
         if ($Session->User->Name == "") {
             $username = "******";
         } else {
             $username = $Session->User->Name;
         }
         if (strlen($_GET['msg']) > 150) {
             return;
         }
         $filtered = wordwrap(htmlspecialchars(str_replace("'", "\\'", $_GET['msg'])), 30, " ", true);
         $message = preg_replace('/(http|ftp)+(s)?:(\\/\\/)((\\w|\\.)+)(\\/)?(\\S+)?/i', '<a href="\\0" target="blank">\\0</a>', $filtered);
         $mysqlcmd = mysql_query("INSERT INTO GDN_Shoutbox (Username, data) values ('" . $username . "','" . $message . "');", $dblink);
         if (!$mysqlcmd) {
             mysql_close($dblink);
             return;
         }
     }
     if (isset($_GET["rm"])) {
         $Session = Gdn::Session();
         if (!$Session->CheckPermission('Plugins.Van2Shout.Delete')) {
             return;
         }
         $mysqlcmd = mysql_query("DELETE FROM GDN_Shoutbox WHERE EntryID = " . $_GET['rm'] . ";", $dblink);
         if (!mysqlcmd) {
             mysql_close($dblink);
             return;
         }
     }
     mysql_close($dblink);
     include_once PATH_PLUGINS . DS . 'Van2Shout' . DS . 'class.van2shoutmodule.php';
     $Van2ShoutModule = new Van2ShoutModule($Sender);
     $Sender->AddModule($Van2ShoutModule);
     $Sender->AddJsFile("/plugins/Van2Shout/van2shout.js");
     $Sender->AddDefinition('user', $Session->User->Name);
     $webroot = Gdn::Request()->Webroot();
     if ($webroot == "") {
         $webroot = "/";
     }
     if (substr($webroot, 0, 1) != "/" && $webroot != "/") {
         $webroot = "/" . $webroot;
     }
     if (substr($webroot, 0, strlen($webroot)) != "/" && $webroot != "/") {
         $webroot = $webroot . "/";
     }
     $Sender->AddDefinition('Van2ShoutRootpath', $webroot);
 }