Merge commit 'upstream/master'
This commit is contained in:
commit
0b3caa67a3
96
modules/contactowner/controllers/admin_contactowner.php
Normal file
96
modules/contactowner/controllers/admin_contactowner.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
class Admin_ContactOwner_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
// Generate a new admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_contactowner.html");
|
||||
$view->content->contactowner_form = $this->_get_admin_form();
|
||||
print $view;
|
||||
}
|
||||
|
||||
public function saveprefs() {
|
||||
// Prevent Cross Site Request Forgery
|
||||
access::verify_csrf();
|
||||
|
||||
// Figure out which boxes where checked
|
||||
$linkOptions_array = Input::instance()->post("ContactOwnerLinkTypes");
|
||||
$ownerLink = false;
|
||||
$userLink = false;
|
||||
for ($i = 0; $i < count($linkOptions_array); $i++) {
|
||||
if ($linkOptions_array[$i] == "ContactOwner") {
|
||||
$ownerLink = true;
|
||||
}
|
||||
if ($linkOptions_array[$i] == "ContactUser") {
|
||||
$userLink = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out the values of the text boxes
|
||||
$str_contactbutton = Input::instance()->post("owner_button_text");
|
||||
$str_contactemail = Input::instance()->post("owner_email");
|
||||
$str_contactname = Input::instance()->post("owner_name");
|
||||
|
||||
// Save Settings.
|
||||
module::set_var("contactowner", "contact_owner_link", $ownerLink);
|
||||
module::set_var("contactowner", "contact_user_link", $userLink);
|
||||
module::set_var("contactowner", "contact_button_text", $str_contactbutton);
|
||||
module::set_var("contactowner", "contact_owner_email", $str_contactemail );
|
||||
module::set_var("contactowner", "contact_owner_name", $str_contactname );
|
||||
message::success(t("Your Settings Have Been Saved."));
|
||||
|
||||
// Load Admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_contactowner.html");
|
||||
$view->content->contactowner_form = $this->_get_admin_form();
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function _get_admin_form() {
|
||||
// Make a new Form.
|
||||
$form = new Forge("admin/contactowner/saveprefs", "", "post",
|
||||
array("id" => "gContactOwnerAdminForm"));
|
||||
|
||||
// Make an array for the different types of link codes.
|
||||
$add_contactlinks = $form->group("contactOwnerLinks");
|
||||
$linkOptions["ContactOwner"] = array("Display Contact Site Owner Link",
|
||||
module::get_var("contactowner", "contact_owner_link"));
|
||||
$linkOptions["ContactUser"] = array("Display Contact Item Owner Link",
|
||||
module::get_var("contactowner", "contact_user_link"));
|
||||
|
||||
// Turn the array into a series of checkboxes.
|
||||
$add_contactlinks->checklist("ContactOwnerLinkTypes")
|
||||
->options($linkOptions);
|
||||
|
||||
// Set up some text boxes for the site owners Name, email and the
|
||||
// text for the contact link.
|
||||
$add_contacts = $form->group("contactOwner");
|
||||
$add_contacts->input("owner_button_text")->label(t("Contact Owner Link Text"))->value(module::get_var("contactowner", "contact_button_text"));
|
||||
$add_contacts->input("owner_email")->label(t("Owner Email Address"))->value(module::get_var("contactowner", "contact_owner_email"));
|
||||
$add_contacts->input("owner_name")->label(t("Owner Name"))->value(module::get_var("contactowner", "contact_owner_name"));
|
||||
|
||||
// Add a save button to the form.
|
||||
$add_contacts->submit("SaveSettings")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
}
|
||||
}
|
129
modules/contactowner/controllers/contactowner.php
Normal file
129
modules/contactowner/controllers/contactowner.php
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class ContactOwner_Controller extends Controller {
|
||||
public function emailowner() {
|
||||
// Display a form that a vistor can use to contact the site owner.
|
||||
|
||||
// If this page is disabled, show a 404 error.
|
||||
if (module::get_var("contactowner", "contact_owner_link") != true) {
|
||||
kohana::show_404();
|
||||
}
|
||||
|
||||
// Make a new form with a couple of text boxes.
|
||||
$form = new Forge("contactowner/sendemail", "", "post",
|
||||
array("id" => "gContactOwnerSendForm"));
|
||||
$sendmail_fields = $form->group("contactOwner");
|
||||
$sendmail_fields->input("email_to")->label(t("To:"))->value(module::get_var("contactowner", "contact_owner_name"));
|
||||
$sendmail_fields->input("email_from")->label(t("From:"))->value(user::active()->email);
|
||||
$sendmail_fields->input("email_subject")->label(t("Subject:"))->value("");
|
||||
$sendmail_fields->textarea("email_body")->label(t("Message:"))->value("");
|
||||
$sendmail_fields->hidden("email_to_id")->value("-1");
|
||||
|
||||
// Add a save button to the form.
|
||||
$sendmail_fields->submit("SendMessage")->value(t("Send"));
|
||||
|
||||
// Set up and display the actual page.
|
||||
$template = new Theme_View("page.html", "Contact");
|
||||
$template->content = new View("contactowner_emailform.html");
|
||||
$template->content->sendmail_form = $form;
|
||||
print $template;
|
||||
}
|
||||
|
||||
public function emailid($user_id) {
|
||||
// Display a form that a vistor can use to contact a registered user.
|
||||
|
||||
// If this page is disabled, show a 404 error.
|
||||
if (module::get_var("contactowner", "contact_user_link") != true) {
|
||||
kohana::show_404();
|
||||
}
|
||||
|
||||
// Locate the record for the user specified by $user_id,
|
||||
// use this to determine the user's name.
|
||||
$userDetails = ORM::factory("user")
|
||||
->where("id", $user_id)
|
||||
->find_all();
|
||||
|
||||
// Make a new form with a couple of text boxes.
|
||||
$form = new Forge("contactowner/sendemail", "", "post",
|
||||
array("id" => "gContactOwnerSendForm"));
|
||||
$sendmail_fields = $form->group("contactOwner");
|
||||
$sendmail_fields->input("email_to")->label(t("To:"))->value($userDetails[0]->name);
|
||||
$sendmail_fields->input("email_from")->label(t("From:"))->value(user::active()->email);
|
||||
$sendmail_fields->input("email_subject")->label(t("Subject:"))->value("");
|
||||
$sendmail_fields->textarea("email_body")->label(t("Message:"))->value("");
|
||||
$sendmail_fields->hidden("email_to_id")->value($user_id);
|
||||
|
||||
// Add a save button to the form.
|
||||
$sendmail_fields->submit("SendMessage")->value(t("Send"));
|
||||
|
||||
// Set up and display the actual page.
|
||||
$template = new Theme_View("page.html", "Contact");
|
||||
$template->content = new View("contactowner_emailform.html");
|
||||
$template->content->sendmail_form = $form;
|
||||
print $template;
|
||||
}
|
||||
|
||||
public function sendemail() {
|
||||
// Process the data from the form into an email,
|
||||
// then send the email.
|
||||
|
||||
// Copy the data from the email from into a couple of variables.
|
||||
$str_emailsubject = Input::instance()->post("email_subject");
|
||||
$str_emailtoid = Input::instance()->post("email_to_id");
|
||||
$str_emailfrom = Input::instance()->post("email_from");
|
||||
$str_emailbody = Input::instance()->post("email_body");
|
||||
|
||||
// Add in some <br> tags to the message body where ever there are line breaks.
|
||||
$str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
|
||||
|
||||
// Gallery's Sendmail library doesn't allow for custom from addresses,
|
||||
// so add the from email to the beginning of the message body instead.
|
||||
$str_emailbody = "Message Sent From " . $str_emailfrom . "\r\n\r\n<br/><br/>" . $str_emailbody;
|
||||
|
||||
// Figure out where the email is going to.
|
||||
$str_emailto = "";
|
||||
if ($str_emailtoid == -1) {
|
||||
// If the email id is "-1" send the message to a pre-determined
|
||||
// owner email address.
|
||||
$str_emailto = module::get_var("contactowner", "contact_owner_email");
|
||||
} else {
|
||||
// or else grab the email from the user table.
|
||||
$userDetails = ORM::factory("user")
|
||||
->where("id", $str_emailtoid)
|
||||
->find_all();
|
||||
$str_emailto = $userDetails[0]->email;
|
||||
}
|
||||
|
||||
// Send the email message.
|
||||
Sendmail::factory()
|
||||
->to($str_emailto)
|
||||
->subject($str_emailsubject)
|
||||
->header("Mime-Version", "1.0")
|
||||
->header("Content-type", "text/html; charset=utf-8")
|
||||
->message($str_emailbody)
|
||||
->send();
|
||||
|
||||
// Display a message telling the visitor that their email has been sent.
|
||||
$template = new Theme_View("page.html", "Contact");
|
||||
$template->content = new View("contactowner_emailform.html");
|
||||
$template->content->sendmail_form = t("Your Message Has Been Sent.");
|
||||
print $template;
|
||||
}
|
||||
}
|
23
modules/contactowner/helpers/contactowner_installer.php
Normal file
23
modules/contactowner/helpers/contactowner_installer.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class contactowner_installer {
|
||||
static function install() {
|
||||
module::set_version("contactowner", 1);
|
||||
}
|
||||
}
|
28
modules/contactowner/helpers/contactowner_menu.php
Normal file
28
modules/contactowner/helpers/contactowner_menu.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class contactowner_menu_Core {
|
||||
static function admin($menu, $theme) {
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("contactowner")
|
||||
->label(t("ContactOwner Settings"))
|
||||
->url(url::site("admin/contactowner")));
|
||||
}
|
||||
}
|
70
modules/contactowner/helpers/contactowner_theme.php
Normal file
70
modules/contactowner/helpers/contactowner_theme.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class contactowner_theme_Core {
|
||||
|
||||
static function sidebar_blocks($theme) {
|
||||
// Display links in the Gallery sidebar to allow a
|
||||
// visitor to send an email.
|
||||
|
||||
// Make sure the current page belongs to an item.
|
||||
if (!$theme->item()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Locate the record for the user that created the current item.
|
||||
// Their name will be displayed as part of the contact link.
|
||||
$userDetails = ORM::factory("user")
|
||||
->where("id", $theme->item->owner_id)
|
||||
->find_all();
|
||||
|
||||
// Create a new block to display the links in.
|
||||
$block = new Block();
|
||||
$block->css_id = "gContactOwner";
|
||||
$block->title = t("Contact:");
|
||||
$block->content = new View("contactowner_block.html");
|
||||
|
||||
// if $displayBlock is true, this block will be displayed,
|
||||
// if there aren't any links to put in the block for whatever reason
|
||||
// then $displayBlock will rename set to false and the
|
||||
// block will not be displayed.
|
||||
$displayBlock = false;
|
||||
|
||||
// Figure out if the contact item owner email link should be displayed.
|
||||
// only display it if the current owner has an email address and
|
||||
// the option for allowing item owners to be contacted is set to true.
|
||||
if ((count($userDetails) > 0) && ($userDetails[0]->email != "") &&
|
||||
(module::get_var("contactowner", "contact_user_link") == true)) {
|
||||
$block->content->userLink = "<a href=\"" . url::site("contactowner/emailid/" .
|
||||
$theme->item->owner_id) . "\">" . t("Contact") . " " . $userDetails[0]->name . "</a>";
|
||||
$displayBlock = true;
|
||||
}
|
||||
|
||||
// Figure out if the contact site owner link should be displayed.
|
||||
if (module::get_var("contactowner", "contact_owner_link")) {
|
||||
$block->content->ownerLink = "<a href=\"" . url::site("contactowner/emailowner") .
|
||||
"\">" . t(module::get_var("contactowner", "contact_button_text")) . "</a>";
|
||||
$displayBlock = true;
|
||||
}
|
||||
|
||||
if ($displayBlock) {
|
||||
return $block;
|
||||
}
|
||||
}
|
||||
}
|
3
modules/contactowner/module.info
Normal file
3
modules/contactowner/module.info
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = ContactOwner
|
||||
description = Allows visitors to send the website owner an email.
|
||||
version = 1
|
5
modules/contactowner/views/admin_contactowner.html.php
Normal file
5
modules/contactowner/views/admin_contactowner.html.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="gContactOwnerAdmin">
|
||||
<h2> <?= t("Contact Owner Settings") ?> </h2>
|
||||
<?= $contactowner_form ?>
|
||||
</div>
|
15
modules/contactowner/views/contactowner_block.html.php
Normal file
15
modules/contactowner/views/contactowner_block.html.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<ul id="gContactOwner">
|
||||
<? if ($ownerLink != "") { ?>
|
||||
<li style="clear: both;">
|
||||
<? print ($ownerLink); ?>
|
||||
</li>
|
||||
<? } ?>
|
||||
<? if ($userLink != "") { ?>
|
||||
<li style="clear: both;">
|
||||
<? print ($userLink); ?>
|
||||
</li>
|
||||
<? } ?>
|
||||
|
||||
</ul>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<?= $sendmail_form ?>
|
139
modules/latestupdates/controllers/latestupdates.php
Normal file
139
modules/latestupdates/controllers/latestupdates.php
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class latestupdates_Controller extends Controller {
|
||||
|
||||
public function albums($id) {
|
||||
// Figure out how many items to display on each page.
|
||||
$itemsPerPage = module::get_var("gallery", "page_size", 9);
|
||||
|
||||
// Figure out which page # the visitor is on and
|
||||
// don't allow the visitor to go below page 1.
|
||||
$page = $this->input->get("page", 1);
|
||||
if ($page < 1) {
|
||||
url::redirect("latestupdates/albums/{$item->id}");
|
||||
}
|
||||
|
||||
// First item to display.
|
||||
$offset = ($page - 1) * $itemsPerPage;
|
||||
|
||||
// Determine the total number of items,
|
||||
// for page numbering purposes.
|
||||
$count = ORM::factory("item", $id)
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->orderby("created", "DESC")
|
||||
->descendants()
|
||||
->count();
|
||||
|
||||
// Figure out what the highest page number is.
|
||||
$max_pages = ceil($count / $itemsPerPage);
|
||||
|
||||
// Don't let the visitor go past the last page.
|
||||
if ($max_pages && $page > $max_pages) {
|
||||
url::redirect("latestupdates/albums/{$item->id}?page=$max_pages");
|
||||
}
|
||||
|
||||
// Figure out which items to display on this page.
|
||||
$children = ORM::factory("item", $id)
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->orderby("created", "DESC")
|
||||
->limit($itemsPerPage)
|
||||
->offset($offset)
|
||||
->descendants();
|
||||
|
||||
// Set up the previous and next page buttons.
|
||||
if ($page > 1) {
|
||||
$previous_page = $page - 1;
|
||||
$view->previous_page_link = url::site("latestupdates/albums/{$item->id}?page={$previous_page}");
|
||||
}
|
||||
if ($page < $max_pages) {
|
||||
$next_page = $page + 1;
|
||||
$view->next_page_link = url::site("latestupdates/albums/{$item->id}?page={$next_page}");
|
||||
}
|
||||
|
||||
// Set up and display the actual page.
|
||||
$template = new Theme_View("page.html", "updates");
|
||||
$template->set_global("page_size", $itemsPerPage);
|
||||
$template->set_global("children_count", $count);
|
||||
$template->content = new View("updates.html");
|
||||
$template->content->items = $children;
|
||||
$template->content->q = count($children);
|
||||
print $template;
|
||||
}
|
||||
|
||||
public function updates() {
|
||||
// Figure out how many items to display on each page.
|
||||
$itemsPerPage = module::get_var("gallery", "page_size", 9);
|
||||
|
||||
// Figure out which page # the visitor is on and
|
||||
// don't allow the visitor to go below page 1.
|
||||
$page = $this->input->get("page", 1);
|
||||
if ($page < 1) {
|
||||
url::redirect("latestupdates/updates");
|
||||
}
|
||||
|
||||
// First item to display.
|
||||
$offset = ($page - 1) * $itemsPerPage;
|
||||
|
||||
// Determine the total number of items,
|
||||
// for page numbering purposes.
|
||||
$count = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->find_all()
|
||||
->count();
|
||||
|
||||
// Figure out what the highest page number is.
|
||||
$max_pages = ceil($count / $itemsPerPage);
|
||||
|
||||
// Don't let the visitor go past the last page.
|
||||
if ($max_pages && $page > $max_pages) {
|
||||
url::redirect("latestupdates/updates?page=$max_pages");
|
||||
}
|
||||
|
||||
// Figure out which items to display on this page.
|
||||
$items = ORM::factory("item")
|
||||
->viewable()
|
||||
->where("type !=", "album")
|
||||
->orderby("created", "DESC")
|
||||
->find_all($itemsPerPage, $offset);
|
||||
|
||||
// Set up the previous and next page buttons.
|
||||
if ($page > 1) {
|
||||
$previous_page = $page - 1;
|
||||
$view->previous_page_link = url::site("latestupdates/updates?page={$previous_page}");
|
||||
}
|
||||
if ($page < $max_pages) {
|
||||
$next_page = $page + 1;
|
||||
$view->next_page_link = url::site("latestupdates/updates?page={$next_page}");
|
||||
}
|
||||
|
||||
// Set up and display the actual page.
|
||||
$template = new Theme_View("page.html", "updates");
|
||||
$template->set_global("page_size", $itemsPerPage);
|
||||
$template->set_global("children_count", $count);
|
||||
$template->content = new View("updates.html");
|
||||
$template->content->items = $items;
|
||||
$template->content->q = count($items);
|
||||
print $template;
|
||||
}
|
||||
|
||||
}
|
31
modules/latestupdates/helpers/latestupdates_installer.php
Normal file
31
modules/latestupdates/helpers/latestupdates_installer.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class latestupdates_installer {
|
||||
static function install() {
|
||||
$version = module::get_version("latestupdates");
|
||||
if ($version == 0) {
|
||||
module::set_version("latestupdates", 1);
|
||||
}
|
||||
}
|
||||
|
||||
static function uninstall() {
|
||||
module::delete("latestupdates");
|
||||
}
|
||||
}
|
38
modules/latestupdates/helpers/latestupdates_theme.php
Normal file
38
modules/latestupdates/helpers/latestupdates_theme.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class latestupdates_theme_Core {
|
||||
|
||||
static function sidebar_blocks($theme) {
|
||||
if (!$theme->item()) {
|
||||
return;
|
||||
}
|
||||
$albumID = $theme->item->is_album() ? $theme->item->id : $theme->item->parent_id;
|
||||
|
||||
$block = new Block();
|
||||
$block->css_id = "gUpdates";
|
||||
$block->title = t("Updates");
|
||||
$block->content = new View("latestupdates_block.html");
|
||||
$block->content->updateLinks = array(
|
||||
t("Entire Gallery") => url::site("latestupdates/updates"),
|
||||
t("This Album") => url::site("latestupdates/albums/$albumID")
|
||||
);
|
||||
return $block;
|
||||
}
|
||||
}
|
3
modules/latestupdates/module.info
Normal file
3
modules/latestupdates/module.info
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = LatestUpdates
|
||||
description = Display recently uploaded photos and videos.
|
||||
version = 1
|
10
modules/latestupdates/views/latestupdates_block.html.php
Normal file
10
modules/latestupdates/views/latestupdates_block.html.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<ul id="gUpdates">
|
||||
<? foreach($updateLinks as $title => $url): ?>
|
||||
<li style="clear: both;">
|
||||
<a href="<?= $url ?>">
|
||||
<?= $title ?>
|
||||
</a>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
</ul>
|
33
modules/latestupdates/views/updates.html.php
Normal file
33
modules/latestupdates/views/updates.html.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<? // @todo Set hover on AlbumGrid list items ?>
|
||||
|
||||
<div id="gLatestUpdates">
|
||||
<h1><?= t("Latest Updates") ?></h1>
|
||||
<? array("term" => p::clean($q)) ?>
|
||||
<? if (count($items)): ?>
|
||||
<ul id="gAlbumGrid">
|
||||
<? foreach ($items as $item): ?>
|
||||
<? $item_class = "gPhoto"; ?>
|
||||
<? if ($item->is_album()): ?>
|
||||
<? $item_class = "gAlbum"; ?>
|
||||
<? endif ?>
|
||||
<li class="gItem <?= $item_class ?>">
|
||||
<a href="<?= url::site("items/$item->id") ?>">
|
||||
<?= $item->thumb_img() ?>
|
||||
<p>
|
||||
<?= p::clean($item->title) ?>
|
||||
</p>
|
||||
<div>
|
||||
<?= p::clean($item->description) ?>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<? endforeach ?>
|
||||
</ul>
|
||||
<?= $theme->pager() ?>
|
||||
|
||||
<? else: ?>
|
||||
<p><?= t("There are no items to display.") ?></p>
|
||||
|
||||
<? endif; ?>
|
||||
</div>
|
93
modules/phpmailer/controllers/admin_phpmailer.php
Normal file
93
modules/phpmailer/controllers/admin_phpmailer.php
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
class Admin_PHPMailer_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
// Generate a new admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_phpmailer.html");
|
||||
$view->content->phpmailer_form = $this->_get_admin_form();
|
||||
print $view;
|
||||
}
|
||||
|
||||
public function saveprefs() {
|
||||
// Prevent Cross Site Request Forgery
|
||||
access::verify_csrf();
|
||||
|
||||
// Figure out the values of the text boxes
|
||||
$str_phpmailer_path = Input::instance()->post("phpmailer_path");
|
||||
$str_phpmailer_from_addr = Input::instance()->post("phpmailer_from_address");
|
||||
$str_phpmailer_from_name = Input::instance()->post("phpmailer_from_name");
|
||||
$str_smtp_server = Input::instance()->post("phpmailer_smtp_server");
|
||||
$str_smtp_login = Input::instance()->post("phpmailer_smtp_login");
|
||||
$str_smtp_pass = Input::instance()->post("phpmailer_smtp_password");
|
||||
|
||||
// Save Settings.
|
||||
module::set_var("phpmailer", "phpmailer_path", $str_phpmailer_path);
|
||||
module::set_var("phpmailer", "phpmailer_from_address", $str_phpmailer_from_addr);
|
||||
module::set_var("phpmailer", "phpmailer_from_name", $str_phpmailer_from_name);
|
||||
module::set_var("phpmailer", "smtp_server", $str_smtp_server);
|
||||
module::set_var("phpmailer", "smtp_login", $str_smtp_login);
|
||||
module::set_var("phpmailer", "smtp_password", $str_smtp_pass);
|
||||
message::success(t("Your Settings Have Been Saved."));
|
||||
|
||||
// Load Admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_phpmailer.html");
|
||||
$view->content->phpmailer_form = $this->_get_admin_form();
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function _get_admin_form() {
|
||||
// Make a new Form.
|
||||
$form = new Forge("admin/phpmailer/saveprefs", "", "post",
|
||||
array("id" => "gPHPMailerAdminForm"));
|
||||
|
||||
// Create the input boxes for the PHPMailer Settings
|
||||
$phpmailerGroup = $form->group("PHPMailerSettings");
|
||||
$phpmailerGroup->input("phpmailer_path")
|
||||
->label(t("Location of PHPMailer Class"))
|
||||
->value(module::get_var("phpmailer", "phpmailer_path"));
|
||||
$phpmailerGroup->input("phpmailer_from_address")
|
||||
->label(t("From Email Address"))
|
||||
->value(module::get_var("phpmailer", "phpmailer_from_address"));
|
||||
$phpmailerGroup->input("phpmailer_from_name")
|
||||
->label(t("From Name"))
|
||||
->value(module::get_var("phpmailer", "phpmailer_from_name"));
|
||||
|
||||
// Create the input boxes for the SMTP server settings
|
||||
$phpmailerSMTP = $form->group("PHPMailerSMTPSettings");
|
||||
$phpmailerSMTP->input("phpmailer_smtp_server")
|
||||
->label(t("SMTP Server Address"))
|
||||
->value(module::get_var("phpmailer", "smtp_server"));
|
||||
$phpmailerSMTP->input("phpmailer_smtp_login")
|
||||
->label(t("SMTP Login Name"))
|
||||
->value(module::get_var("phpmailer", "smtp_login"));
|
||||
$phpmailerSMTP->input("phpmailer_smtp_password")
|
||||
->label(t("SMTP Password"))
|
||||
->value(module::get_var("phpmailer", "smtp_password"));
|
||||
|
||||
// Add a save button to the form.
|
||||
$form->submit("SaveSettings")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
}
|
||||
}
|
27
modules/phpmailer/helpers/phpmailer_installer.php
Normal file
27
modules/phpmailer/helpers/phpmailer_installer.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class phpmailer_installer {
|
||||
static function install() {
|
||||
module::set_version("phpmailer", 1);
|
||||
}
|
||||
|
||||
static function uninstall() {
|
||||
module::delete("phpmailer");
|
||||
}
|
||||
}
|
28
modules/phpmailer/helpers/phpmailer_menu.php
Normal file
28
modules/phpmailer/helpers/phpmailer_menu.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class phpmailer_menu_Core {
|
||||
static function admin($menu, $theme) {
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("phpmailer")
|
||||
->label(t("PHPMailer Settings"))
|
||||
->url(url::site("admin/phpmailer")));
|
||||
}
|
||||
}
|
126
modules/phpmailer/libraries/Sendmail.php
Normal file
126
modules/phpmailer/libraries/Sendmail.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class Sendmail_Core {
|
||||
protected $to;
|
||||
protected $subject;
|
||||
protected $message;
|
||||
protected $headers;
|
||||
protected $line_length = 70;
|
||||
protected $header_separator = "\r\n";
|
||||
|
||||
/**
|
||||
* Return an instance of Sendmail
|
||||
* @chainable
|
||||
*/
|
||||
static function factory() {
|
||||
return new Sendmail();
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->headers = array();
|
||||
$config = Kohana::config("sendmail");
|
||||
foreach ($config as $key => $value) {
|
||||
$this->$key($value);
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __call($key, $value) {
|
||||
switch ($key) {
|
||||
case "to":
|
||||
$this->to = is_array($value[0]) ? $value[0] : array($value[0]);
|
||||
break;
|
||||
case "header":
|
||||
if (count($value) != 2) {
|
||||
throw new Exception("@todo INVALID_HEADER_PARAMETERS");
|
||||
}
|
||||
$this->headers[$value[0]] = $value[1];
|
||||
break;
|
||||
case "from":
|
||||
$this->headers["From"] = $value[0];
|
||||
break;
|
||||
case "reply_to":
|
||||
$this->headers["Reply-To"] = $value[0];
|
||||
break;
|
||||
default:
|
||||
$this->$key = $value[0];
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function send() {
|
||||
if (empty($this->to)) {
|
||||
throw new Exception("@todo TO_IS_REQUIRED_FOR_MAIL");
|
||||
}
|
||||
$to = implode(", ", $this->to);
|
||||
$headers = array();
|
||||
foreach ($this->headers as $key => $value) {
|
||||
$key = ucfirst($key);
|
||||
$headers[] = "$key: $value";
|
||||
}
|
||||
|
||||
// The docs say headers should be separated by \r\n, but occasionaly that doesn't work and you
|
||||
// need to use a single \n. This can be set in config/sendmail.php
|
||||
$headers = implode($this->header_separator, $headers);
|
||||
$message = wordwrap($this->message, $this->line_length, "\n");
|
||||
if (!$this->mail($to, $this->subject, $message, $headers)) {
|
||||
Kohana::log("error", wordwrap("Sending mail failed:\nTo: $to\n $this->subject\n" .
|
||||
"Headers: $headers\n $this->message"));
|
||||
throw new Exception("@todo SEND_MAIL_FAILED");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function mail($to, $subject, $message, $headers) {
|
||||
// This function is completely different from the original
|
||||
// Gallery Sendmail script. Outside of this function,
|
||||
// no other changes were made.
|
||||
|
||||
require(module::get_var("phpmailer", "phpmailer_path"));
|
||||
$mail = new PHPMailer();
|
||||
|
||||
$mail->IsSMTP();
|
||||
$mail->Host = module::get_var("phpmailer", "smtp_server");
|
||||
|
||||
if (module::get_var("phpmailer", "smtp_login") != "") {
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = module::get_var("phpmailer", "smtp_login");
|
||||
$mail->Password = module::get_var("phpmailer", "smtp_password");
|
||||
} else {
|
||||
$mail->SMTPAuth = false;
|
||||
}
|
||||
|
||||
$mail->From = module::get_var("phpmailer", "phpmailer_from_address");
|
||||
$mail->FromName = module::get_var("phpmailer", "phpmailer_from_name");
|
||||
$mail->AddAddress($to);
|
||||
$mail->IsHTML(true);
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $message;
|
||||
|
||||
if ($mail->Send()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
3
modules/phpmailer/module.info
Normal file
3
modules/phpmailer/module.info
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = PHPMailer
|
||||
description = Use PHPMailer when sending email messages.
|
||||
version = 1
|
5
modules/phpmailer/views/admin_phpmailer.html.php
Normal file
5
modules/phpmailer/views/admin_phpmailer.html.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="gPHPMailerAdmin">
|
||||
<h2> <?= t("PHPMailer Settings") ?> </h2>
|
||||
<?= $phpmailer_form ?>
|
||||
</div>
|
Reference in New Issue
Block a user