Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Stardog committed Apr 5, 2017
1 parent 4329da0 commit 6179b92
Show file tree
Hide file tree
Showing 344 changed files with 205,777 additions and 5,975 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.babelrc
/.idea/
/nbproject/private/
/node_modules/
/conf/defines.php
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"space-before-function-paren" : false
}
122 changes: 122 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
* @author Matthew McNaney <mcnaneym at appstate dot edu>
*/

namespace properties;

use properties\Factory\NavBar;

require_once PHPWS_SOURCE_DIR . 'src/Module.php';
require_once PHPWS_SOURCE_DIR . 'mod/properties/conf/system_defines.php';
require_once PHPWS_SOURCE_DIR . 'mod/properties/conf/defines.php';

class Module extends \Canopy\Module implements \Canopy\SettingDefaults
{

public function __construct()
{
parent::__construct();
$this->setTitle('properties');
$this->setProperName('Properties');
spl_autoload_register('\properties\Module::autoloader', true, true);
}

public function getSettingDefaults()
{
$settings['approval_email'] = '';
$settings['our_email'] = '';
$settings['our_phone'] = null;
$settings['our_name'] = null;
$settings['front_buttons'] = 1;
return $settings;
}

public function getController(\Canopy\Request $request)
{
try {
$controller = new Controller\Controller($this, $request);
return $controller;
} catch (\Exception $e) {
if (PROPERTIES_FRIENDLY_ERRORS && $request->isGet() && !$request->isAjax()) {
return $this->friendlyController();
}
throw $e;
}
}

private function friendlyController()
{
$error_controller = new Controller\FriendlyError($this);
return $error_controller;
}

public function afterRun(\Canopy\Request $request,
\Canopy\Response $response)
{
if ($request->isGet() && !$request->isAjax()) {
\properties\Factory\NavBar::view($request);
}
}

public function runTime(\Canopy\Request $request)
{
if ($request->isGet() && !$request->isAjax()) {
if (\phpws\PHPWS_Core::atHome() && \phpws2\Settings::get('properties', 'front_buttons')) {
\Layout::add($this->home());
}
if (!preg_match('/^properties/', \Canopy\Server::getCurrentUrl())) {
if (!\Current_User::isLogged()) {
$auth = \Current_User::getAuthorization();
if (!empty($auth->login_link)) {
$url = $auth->login_link;
} else {
$url = 'index.php?module=users&action=user&command=login_page';
}
NavBar::addItem("<a href='$url'>Sign in</a>");
}
\properties\Factory\NavBar::view($request);
}
}
}

public static function autoloader($class_name)
{
static $not_found = array();

if (strpos($class_name, 'properties') !== 0) {
return;
}

if (isset($not_found[$class_name])) {
return;
}
$class_array = explode('\\', $class_name);
array_shift($class_array);
$class_dir = implode('/', $class_array);

$class_path = PHPWS_SOURCE_DIR . 'mod/properties/class/' . $class_dir . '.php';
if (is_file($class_path)) {
require_once $class_path;
return true;
} else {
$not_found[] = $class_name;
return false;
}
}

public function home()
{
$template = new \phpws2\Template();
$template->setModuleTemplate('properties', 'home.html');
return $template->get();
}

}
25 changes: 12 additions & 13 deletions boost/boost.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* See docs/AUTHORS and docs/COPYRIGHT for relevant info.
*
Expand All @@ -13,18 +14,16 @@
* GNU General Public License for more details.
*
*
* @version $Id$
* @author Matthew McNaney <mcnaney at gmail dot com>
* @package
* @author Matthew McNaney <[email protected]>
* @license http://opensource.org/licenses/gpl-3.0.html
*/
$proper_name = 'Properties';
$version = '1.4.2';
$register = false;
$unregister = false;
$import_sql = true;
$version_http = 'http://phpwebsite.appstate.edu/downloads/modules/properties/check.xml';
$about = false;
$priority = 50;
$dependency = false;
$image_dir = true;
$proper_name = 'Properties';
$version = '2.0.0';
$register = false;
$unregister = false;
$import_sql = false;
$version_http = '';
$about = false;
$priority = 50;
$dependency = false;
$image_dir = true;
16 changes: 9 additions & 7 deletions boost/controlpanel.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* See docs/AUTHORS and docs/COPYRIGHT for relevant info.
*
Expand All @@ -14,13 +15,14 @@
*
*
* @version $Id$
* @author Matthew McNaney <mcnaney at gmail dot com>
* @author Matthew McNaney <[email protected]>
* @package
* @license http://opensource.org/licenses/gpl-3.0.html
*/
$link[] = array('label' => 'Properties',
'restricted' => TRUE,
'url' => 'index.php?module=properties&amp;aop=get',
'description' => dgettext('Properties', 'Manage off-campus properties.'),
'image' => 'properties.gif',
'tab' => 'content');
$link[] = array(
'label' => 'Properties',
'restricted' => TRUE,
'url' => 'properties/',
'description' => 'Properties', 'Manage off-campus properties.',
'image' => 'properties.gif',
'tab' => 'content');
14 changes: 14 additions & 0 deletions boost/dependency.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<dependency>
<module>
<title>core</title>
<properName>phpWebSite Core</properName>
<version>2.10.0</version>
<url>http://github.com/AppStateESS/phpwebsite/</url>
</module>
</dependency>
68 changes: 68 additions & 0 deletions boost/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/**
* @author Matthew McNaney <mcnaneym at appstate dot edu>
*/
function properties_install(&$content)
{
$db = \phpws2\Database::getDB();
$db->begin();

try {
$manager = new \properties\Resource\Manager;
$manager->createTable($db);
$manager_tbl = $db->buildTable($manager->getTable());
$manager_id = $manager_tbl->getDataType('id');

$property = new \properties\Resource\Property;
$property->createTable($db);
$property_tbl = $db->buildTable($property->getTable());
$property_id = $property_tbl->getDataType('id');
$cid = $property_tbl->getDataType('contact_id');
$property_index = new \phpws2\Database\ForeignKey($cid, $manager_id);
$property_index->add();

$photo = new \properties\Resource\Photo;
$photo->createTable($db);
$photo_tbl = $db->buildTable($photo->getTable());
$pid = $photo_tbl->getDataType('pid');
$photo_index = new \phpws2\Database\ForeignKey($pid, $property_id);
$photo_index->add();

$sublease = new \properties\Resource\Sublease;
$sublease->createTable($db);
$sub_table = $db->buildTable($sublease->getTable());
$sublease_id = $sub_table->getDataType('id');
$user_id = $sub_table->getDataType('user_id');
$sublease_index = new \phpws2\Database\Unique($user_id);
$sublease_index->add();

$subphoto = new \properties\Resource\SubleasePhoto;
$subphoto->createTable($db);
$subphoto_tbl = $db->buildTable($subphoto->getTable());
$sid = $subphoto_tbl->getDataType('sid');
$photo_index = new \phpws2\Database\ForeignKey($sid, $sublease_id);
$photo_index->add();

$db = \phpws2\Database::getDB();
$tbl = $db->buildTable('prop_inquiry');
$tbl->addDataType('contact_id', 'int');
$tbl->addDataType('inquiry_date', 'int');
$tbl->addDataType('inquiry_type', 'varchar')->setSize('20');
$tbl->create();
} catch (\Exception $e) {
\phpws2\Error::log($e);
$db->buildTable($manager->getTable())->drop(true);
$db->buildTable($property->getTable())->drop(true);
$db->buildTable($photo->getTable())->drop(true);
$db->buildTable($sublease->getTable())->drop(true);
$db->buildTable($subphoto->getTable())->drop(true);

$db->rollback();
throw $e;
}
$db->commit();

$content[] = 'Tables created';
return true;
}
Loading

0 comments on commit 6179b92

Please sign in to comment.