Skip to content

Commit

Permalink
added categories & widgets to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bnvk committed May 27, 2011
1 parent 614748a commit c7eefa6
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 68 deletions.
15 changes: 5 additions & 10 deletions config/events.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Social Igniter : Events Module : Config
* Name: Social Igniter : Events : Config
* Author: Brennan Novak
* [email protected]
* @brennannovak
*
* Created by Brennan Novak
*
* Project: http://social-igniter.com
* Source: http://github.com/social-igniter/module-blog
*
* Created: 06-10-2010
* Source: http://github.com/socialigniter/events
*
* Description: basic blog and admin functionality module for Social Igniter
* Description: Config for Events App for Social Igniter
*/

// Events Settings
$config['events'] = 'events/';
$config['events_path'] = 'events/';
$config['url_style_events'] = array(
'all' => '2010 / 01 / 01 / name-of-event',
'month' => '2010 / 01 / name-of-event',
'year' => '2010 / name-of-event',
'events' => 'events / name-of-event'
);
);
27 changes: 27 additions & 0 deletions config/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Social Igniter : Events : Install
* Author: Brennan Novak
* [email protected]
* @brennannovak
*
* Created: Brennan Novak
*
* Project: http://social-igniter.com/
* Source: http://github.com/socialigniter/events
*
* Description: Install values for Events App for Social Igniter
*/
/* Settings */
$config['events_settings']['widgets'] = 'TRUE';
$config['events_settings']['categories'] = 'TRUE';
$config['events_settings']['enabled'] = 'TRUE';
$config['events_settings']['create_permission'] = '3';
$config['events_settings']['publish_permission']= '2';
$config['events_settings']['manage_permission'] = '2';
$config['events_settings']['date_style'] = 'DIGITS';
$config['events_settings']['categories_display']= 'yes';
$config['events_settings']['start_day'] = 'sunday';
$config['events_settings']['default_access'] = 'E';
$config['events_settings']['comments_per_page'] = '5';
$config['events_settings']['comments_allow'] = 'no';
25 changes: 25 additions & 0 deletions config/widgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name: Social Igniter : Events : Widgets
* Author: Brennan Novak
* [email protected]
* @brennannovak
*
* Project: http://social-igniter.com
* Source: http://github.com/socialigniter/events
*
* Description: Widgets for the Events App for Social Igniter
*/

$config['events_widgets'][] = array(
'regions' => array('sidebar', 'content'),
'widget' => array(
'module' => 'events',
'name' => 'Upcoming Events',
'method' => 'run',
'path' => 'widgets_upcoming_events',
'multiple' => 'FALSE',
'order' => '1',
'content' => ''
)
);
68 changes: 22 additions & 46 deletions controllers/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ function __construct()
{
parent::__construct();
}


/* GET types */
function recent_get()
{
$categories = $this->categories_model->get_timeline();

if($categories)
{
$this->response($categories, 200);
}

else
{
$this->response(array('error' => 'Could not find any categories'), 404);
}
}

function search_get()
{
Expand All @@ -32,21 +15,21 @@ function search_get()

if($categories)
{
$this->response($categories, 200);
$message = array('status' => 'success', 'message' => 'Events found', 'data' => $categories);
}
else
{
$this->response(array('error' => 'Could not find any '.$search_by.' categories for '.$search_for), 404);
$message = array('status' => 'error', 'message' => 'Could not find any '.$search_by.' events for '.$search_for);
}
}

$this->response($message, 200);
}

/* POST types */
function create_post()
{
$user_id = $this->session->userdata('user_id');

$access = $this->social_igniter->has_access_to_create('category', $user_id);
$access = $this->social_auth->has_access_to_create('category', $user_id);

if ($access)
{
Expand All @@ -63,7 +46,6 @@ function create_post()
// Insert
$category = $this->categories_model->add_category($category_data);


// FOR EVENTS TABLE
$source = 'web'; // SHOULD BE site_title_url ??? better for decentralized social network?
Expand Down Expand Up @@ -92,49 +74,45 @@ function create_post()
'frequency' => ''
);

echo $this->events_model->add_event($event_data);
$event = $this->events_model->add_event($event_data);


if ($category)
if ($event)
{
$message = array('status' => 'success', 'data' => $category);
$response = 200;
$message = array('status' => 'success', 'message' => 'Your event was created', 'data' => $event);
}
else
{
$message = array('status' => 'error', 'message' => 'Oops unable to add your category');
$response = 400;
$message = array('status' => 'error', 'message' => 'Oops unable to add your event');
}
}
else
{
$message = array('status' => 'error', 'message' => 'Oops unable to add your category');
$response = 400;
$message = array('status' => 'error', 'message' => 'Oops unable to add your event');
}

$this->response($message, $response); // 200 being the HTTP response code
$this->response($message, 200);
}

/* PUT types */
function update_put()
function update_get()
{
$viewed = $this->social_tools->update_comment_viewed($this->get('id'));

if($viewed)
{
$this->response(array('status' => 'success', 'message' => 'Comment viewed'), 200);
$message = array('status' => 'success', 'message' => 'Comment viewed');
}
else
{
$this->response(array('status' => 'error', 'message' => 'Could not mark as viewed'), 404);
}
$message = array('status' => 'error', 'message' => 'Could not mark as viewed');
}

$this->response($message, 200);
}

/* DELETE types */
function destroy_delete()
function destroy_get()
{
// Make sure user has access to do this func
$access = $this->social_tools->has_access_to_modify('comment', $this->get('id'));
$access = $this->social_auth->has_access_to_modify('comment', $this->get('id'));

// Move this up to result of "user_has_access"
if ($access)
Expand All @@ -149,13 +127,11 @@ function destroy_delete()
// Update Content
$this->social_igniter->update_content_comments_count($this->get('id'));

$this->response(array('status' => 'success', 'message' => 'Comment deleted'), 200);
$message = array('status' => 'success', 'message' => 'Comment deleted');
}
else
{
$this->response(array('status' => 'error', 'message' => 'Could not delete that comment!'), 404);
}

$message = array('status' => 'error', 'message' => 'Could not delete that comment!');
}
}

}
4 changes: 2 additions & 2 deletions controllers/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function chooser()
}


function widgets_sidebar()
function widgets_upcoming_events()
{

$this->load->view('partials/widget_sidebar');
$this->load->view('widgets/upcoming_events');

}

Expand Down
17 changes: 11 additions & 6 deletions controllers/settings.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
class Settings extends Dashboard_Controller
{

function __construct()
{
parent::__construct();
Expand All @@ -10,14 +9,20 @@ function __construct()

$this->load->library('events_igniter');

$this->data['page_title'] = 'Settings';
$this->data['page_title'] = 'Events';
}

function index()
{
$this->data['sub_title'] = 'Events';
$this->render();
$this->data['sub_title'] = 'Settings';
$this->data['shared_ajax'] .= $this->load->view(config_item('dashboard_theme').'/partials/settings_modules_ajax.php', $this->data, true);
$this->render('dashboard_wide');
}



function widgets()
{
$this->data['sub_title'] = 'Widgets';

$this->render('dashboard_wide');
}
}
7 changes: 5 additions & 2 deletions install/DATABASE.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
INSERT INTO `content` VALUES('', 1, 0, 0, 'pages', 'page', '', 1, 5, 'Events', 'events', 'Your events go here', 'module_page', 'S', 'A', 0, NULL, NULL, NULL, 'P', '2010-07-17 00:00:00', '2010-08-18 23:50:56');

INSERT INTO `settings` VALUES(NULL, 1, 'events', 'widgets', 'TRUE');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'categories', 'TRUE');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'enabled', 'TRUE');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'create_permission', '3');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'publish_permission', '2');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'manage_permission', '2');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'date_style', 'DIGITS');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'categories_display', 'yes');
INSERT INTO `settings` VALUES(NULL, 1, 'events', 'start_day', 'sunday');
Expand Down
1 change: 0 additions & 1 deletion models/events_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function add_event($event_data)
'comments' => $event_data['comments'],
'geo_lat' => $event_data['geo_lat'],
'geo_long' => $event_data['geo_long'],
'geo_accuracy' => $event_data['geo_accuracy'],
'status' => $event_data['status'],
'created_at' => unix_to_mysql(now())
);
Expand Down
24 changes: 23 additions & 1 deletion views/settings/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
<form name="settings" method="post" action="<?= base_url() ?>settings/update" enctype="multipart/form-data">
<form name="settings_update" id="settings_update" method="post" action="<?= base_url() ?>api/settings/modify" enctype="multipart/form-data">
<div class="content_wrap_inner">

<div class="content_inner_top_right">
<h3>Module</h3>
<p><?= form_dropdown('enabled', config_item('enable_disable'), $settings['events']['enabled']) ?></p>
</div>

<h3>Permissions</h3>

<p>Create
<?= form_dropdown('create_permission', config_item('users_levels'), $settings['events']['create_permission']) ?>
</p>

<p>Publish
<?= form_dropdown('publish_permission', config_item('users_levels'), $settings['events']['publish_permission']) ?>
</p>

<p>Manage All
<?= form_dropdown('manage_permission', config_item('users_levels'), $settings['events']['manage_permission']) ?>
</p>

</div>

<span class="item_separator"></span>

<div class="content_wrap_inner">

<h3>Events</h3>

Expand Down Expand Up @@ -46,3 +66,5 @@

</div>
</form>

<?= $shared_ajax ?>
1 change: 1 addition & 0 deletions views/settings/widgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h3>Events Widgets</h3>
File renamed without changes.

0 comments on commit c7eefa6

Please sign in to comment.