Example #1
0
File: shout.php Project: anqqa/Anqh
 /**
  * Show shouts or shout
  */
 public function index()
 {
     $shout = new Shout_Model();
     $form_values = $shout->as_array();
     $form_errors = array();
     // Check post
     if (csrf::valid() && ($post = $this->input->post())) {
         $shout->author_id = $this->user->id;
         $shout->shout = $post['shout'];
         try {
             $shout->save();
             if (!request::is_ajax()) {
                 url::redirect(url::current());
             }
         } catch (ORM_Validation_Exception $e) {
             $form_errors = $e->validation->errors();
             $form_values = arr::overwrite($form_values, $post);
         }
     }
     $shouts = ORM::factory('shout')->find_all(10);
     $view = View_Mod::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => ORM::factory('shout')->has_access(Shout_Model::ACCESS_WRITE, $this->user), 'errors' => $form_errors, 'values' => $form_values));
     if (request::is_ajax()) {
         echo $view;
         return;
     }
     widget::add('main', $view);
 }
Example #2
0
File: FB.php Project: anqqa/Anqh
 /**
  * Initializes Facebook Connect
  */
 public static function init()
 {
     widget::add('foot', html::script(array('js/fbconnect.js', 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US')));
     widget::add('foot', html::script_source("FB.init('" . FB::$config['api_key'] . "');"));
     // Add logged in Facebook user id to session for easier access
     if ($logged_in = FB::instance()->get_loggedin_user()) {
         $_SESSION['fb_uid'] = $logged_in;
     }
 }
Example #3
0
File: roles.php Project: anqqa/Anqh
 /**
  * Single role view
  *
  * @param  string  $role_id
  * @param  string  $action
  */
 public function role($role_id, $action = null)
 {
     if ($action) {
         switch ($action) {
             // Delete role
             case 'delete':
                 $this->_role_delete($role_id);
                 return;
         }
     }
     $this->history = false;
     $role = new Role_Model((int) $role_id);
     $form_values = $role->as_array();
     $form_errors = $errors = array();
     // Check post
     if ($post = $this->input->post()) {
         $role->name = $post['name'];
         $role->description = $post['description'];
         try {
             $role->save();
             url::redirect('/roles');
         } catch (ORM_Validation_Exception $e) {
             $form_errors = $e->validation->errors();
         }
         $form_values = arr::overwrite($form_values, $post);
     }
     // show form
     if ($role->id) {
         $this->breadcrumb[] = html::anchor('role/' . url::title($role->id, $role->name), html::specialchars($role->name));
         $this->page_title = text::title($role->name);
         $this->page_actions[] = array('link' => 'role/' . url::title($role->id, $role->name) . '/delete', 'text' => __('Delete role'), 'class' => 'role-delete');
     } else {
         $this->page_title = __('Role');
     }
     if (empty($errors)) {
         widget::add('main', View_Mod::factory('roles/role_edit', array('values' => $form_values, 'errors' => $form_errors)));
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
 }
Example #4
0
File: index.php Project: anqqa/Anqh
 /**
  * Home page
  */
 public function index()
 {
     $this->page_title = __('Welcome to :site', array(':site' => Kohana::config('site.site_name')));
     // Display news feed
     $newsfeed = new NewsFeed($this->user);
     $newsfeed->max_items = 25;
     widget::add('main', View_Mod::factory('generic/newsfeed', array('newsfeed' => $newsfeed->as_array())));
     // Shout
     $shouts = ORM::factory('shout')->find_all(10);
     widget::add('side', View_Mod::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => ORM::factory('shout')->has_access(Shout_Model::ACCESS_WRITE, $this->user), 'errors' => array(), 'values' => array())));
     // Online
     $guests = Online_User_Model::get_guest_count();
     $online = Online_User_Model::find_online_users();
     $counts = array();
     if ($guests) {
         $counts[] = __2(':guests guest', ':guests guests', $guests, array(':guests' => $guests));
     }
     if (count($online)) {
         $counts[] = __2(':members member', ':members members', count($online), array(':members' => count($online)));
     }
     widget::add('side', View_Mod::factory('generic/users', array('mod_title' => __('Online') . ': ' . implode(', ', $counts), 'viewer' => $this->user, 'users' => $online)));
 }
Example #5
0
 public function index()
 {
     $error = array();
     $side_views = array();
     // New users
     $new_users = ORM::factory('user')->order_by('id', 'DESC')->limit(50)->find_all();
     $users = array();
     foreach ($new_users as $user) {
         $users[date('Y-m-d', strtotime($user->created))][] = $user;
     }
     try {
         $birthdays = Users::get_birthdays();
     } catch (Kohana_Exception $e) {
         $error[] = $e;
     }
     if (empty($error)) {
         $this->page_subtitle = __('Latest :users members', array(':users' => '<var>' . count($new_users) . '</var>'));
         widget::add('main', View_Mod::factory('member/members', array('users' => $users, 'type' => 'new')));
         widget::add('side', View_Mod::factory('member/birthdays_list', array('mod_class' => 'birthdays', 'birthdays' => $birthdays)));
     } else {
         $this->page_title .= ' ' . __('Uh oh.');
         widget::add('main', implode('<br />', $error));
     }
 }
Example #6
0
File: forum.php Project: anqqa/Anqh
 /**
  * Edit topic
  *
  * @param  mixed  $topic_id
  * @param  mixed  $area_id
  */
 public function _topic_edit($topic_id, $area_id = false)
 {
     $this->history = false;
     $errors = array();
     $forum_topic = new Forum_Topic_Model((int) $topic_id);
     $forum_area = $forum_topic->loaded() ? $forum_topic->forum_area : new Forum_Area_Model((int) $area_id);
     if ($forum_topic->loaded()) {
         // Editing topic
         $editing = true;
         if (!$forum_topic->has_access(Forum_Topic_Model::ACCESS_EDIT)) {
             url::back('forum');
         }
     } else {
         if ($forum_area->loaded()) {
             // New topic
             $editing = false;
             if (!$forum_area->has_access(Forum_Area_Model::ACCESS_WRITE)) {
                 url::back('forum');
             }
         } else {
             // New topic in unknown area
             $errors[] = __('Area :area or topic :topic not found', array(':area' => (int) $area_id, ':topic' => (int) $topic_id));
         }
     }
     if (empty($errors)) {
         $forum_post = new Forum_Post_Model((int) $forum_topic->first_post_id);
         $form_errors = array();
         $form_values_topic = $forum_topic->as_array();
         $form_values_post = $forum_post->as_array();
         $form_topics = false;
         // Bound area?
         if ($forum_area->is_type(Forum_Area_Model::TYPE_BIND)) {
             // Get bind config and load topics
             $bind = Forum_Area_Model::binds($forum_area->bind);
             if ($editing) {
                 // Can't edit bound topic
                 $form_topics = array($forum_topic->bind_id => $forum_topic->name);
             } else {
                 // Try to load options from configured model
                 try {
                     $bind_topics = ORM::factory($bind['model'])->find_bind_topics($forum_area->bind);
                     $form_topics = array(0 => __('Choose..')) + $bind_topics;
                 } catch (Kohana_Exception $e) {
                     $form_topics = array();
                 }
             }
         }
         // Admin actions
         if ($editing && $forum_topic->has_access(Forum_Topic_Model::ACCESS_DELETE)) {
             $this->page_actions[] = array('link' => url::model($forum_topic) . '/delete/?token=' . csrf::token(), 'text' => __('Delete topic'), 'class' => 'topic-delete');
         }
         // Check post
         if ($post = $this->input->post()) {
             $post['forum_area_id'] = $forum_area->id;
             $topic = $post;
             if (isset($bind_topics)) {
                 $topic['name'] = arr::get($bind_topics, (int) $topic['bind_id'], '');
             }
             $post_extra = $topic_extra = array('author_id' => $this->user->id, 'author_name' => $this->user->username);
             if ($editing) {
                 $post_extra['modifies'] = (int) $forum_post->modifies + 1;
                 $post_extra['modified'] = date::unix2sql(time());
             }
             $post_extra['author_ip'] = $this->input->ip_address();
             $post_extra['author_host'] = $this->input->host_name();
             // validate post first and save topic if ok
             if (csrf::valid() && $forum_post->validate($post, false, $post_extra) && $forum_topic->validate($topic, true, $topic_extra)) {
                 // post
                 $forum_post->forum_topic_id = $forum_topic->id;
                 $forum_post->save();
                 if (!$editing) {
                     // topic
                     $forum_topic->first_post_id = $forum_post->id;
                     $forum_topic->last_post_id = $forum_post->id;
                     $forum_topic->last_poster = $this->user->username;
                     $forum_topic->last_posted = date::unix2sql(time());
                     $forum_topic->posts = 1;
                     $forum_topic->save();
                     // area
                     $forum_area->last_topic_id = $forum_topic->id;
                     $forum_area->posts += 1;
                     $forum_area->topics += 1;
                     $forum_area->save();
                     // user
                     $this->user->posts += 1;
                     $this->user->save();
                     // News feed
                     newsfeeditem_forum::topic($this->user, $forum_topic);
                 }
                 // redirect back to topic
                 URL::redirect(url::model($forum_topic));
             } else {
                 $form_errors = array_merge($post->errors(), is_object($topic) ? $topic->errors() : array());
             }
             $form_values_topic = arr::overwrite($form_values_topic, is_object($topic) ? $topic->as_array() : $topic);
             $form_values_post = arr::overwrite($form_values_post, $post->as_array());
         }
     }
     // Show form
     if (empty($errors)) {
         $this->breadcrumb[] = html::anchor(url::model($forum_area), text::title($forum_area->name));
         $this->page_title = $editing ? text::title($forum_topic->name) : __('New topic');
         $this->page_subtitle = __('Area :area', array(':area' => html::anchor(url::model($forum_area), text::title($forum_area->name), array('title' => strip_tags($forum_area->description)))));
         widget::add('head', html::script(array('js/jquery.markitup.pack', 'js/markitup.bbcode')));
         widget::add('main', View_Mod::factory('forum/topic_edit', array('topic' => $form_values_topic, 'topics' => $form_topics, 'post' => $form_values_post, 'errors' => $form_errors)));
     } else {
         $this->_error(__('Error'), $errors);
     }
     $this->_side_views();
 }
Example #7
0
 /**
  * User profile
  */
 public function _view()
 {
     $this->tab_id = 'profile';
     $owner = $this->user && $this->member->id == $this->user->id;
     if ($owner && $this->user->newcomments) {
         $this->user->newcomments = 0;
         $this->user->save();
     }
     // Actions
     if ($this->member->has_access(User_Model::ACCESS_EDIT)) {
         $this->page_actions[] = array('link' => url::user($this->member) . '/edit', 'text' => __('Settings'), 'class' => 'settings');
     }
     // Picture
     widget::add('side', View_Mod::factory('member/member', array('mod_class' => 'member member-' . $this->member->id, 'user' => $this->member)));
     // Comments
     if ($this->member->has_access(User_Model::ACCESS_COMMENT)) {
         $comment = new User_Comment_Model();
         $form_values = $comment->as_array();
         $form_errors = array();
         // check post
         if (csrf::valid() && ($post = $this->input->post())) {
             $comment->user_id = $this->member->id;
             $comment->author_id = $this->user->id;
             $comment->comment = $post['comment'];
             if (isset($post['private'])) {
                 $comment->private = 1;
             }
             try {
                 $comment->save();
                 if (!$owner) {
                     $this->member->newcomments += 1;
                     $this->member->save();
                 }
                 $this->user->commentsleft += 1;
                 $this->user->save();
                 if (!request::is_ajax()) {
                     url::redirect(url::current());
                 }
             } catch (ORM_Validation_Exception $e) {
                 $form_errors = $e->validation->errors();
                 $form_values = arr::overwrite($form_values, $post);
             }
         }
         // Handle pagination
         $per_page = 25;
         $page_num = $this->uri->segment('page') ? $this->uri->segment('page') : 1;
         $page_offset = ($page_num - 1) * $per_page;
         $total_comments = $this->member->get_comment_count();
         $comments = $this->member->find_comments($page_num, $per_page, $this->user);
         $pagination = new Pagination(array('items_per_page' => $per_page, 'total_items' => $total_comments));
         $view = View::factory('generic/comments', array('delete' => '/member/comment/%d/delete/?token=' . csrf::token(), 'private' => '/member/comment/%d/private/?token=' . csrf::token(), 'comments' => $comments, 'errors' => $form_errors, 'values' => $form_values, 'pagination' => $pagination, 'user' => $this->user));
         if (request::is_ajax()) {
             echo $view;
             return;
         }
         widget::add('main', $view);
     }
     // Basic info
     $basic_info = array();
     if (!empty($this->member->name)) {
         $basic_info[__('Name')] = html::specialchars($this->member->name);
     }
     if (!empty($this->member->city_name)) {
         $basic_info[__('City')] = html::specialchars($this->member->city_name);
     }
     if (!empty($this->member->dob) && $this->member->dob != '0000-00-00') {
         $basic_info[__('Date of Birth')] = __(':dob (:years years)', array(':dob' => date::format('DMYYYY', $this->member->dob), ':years' => date::timespan(strtotime($this->member->dob), null, 'years')));
     }
     if (!empty($this->member->gender)) {
         $basic_info[__('Gender')] = $this->member->gender == 'm' ? __('Male') : __('Female');
     }
     if (!empty($this->member->latitude) && !empty($this->member->longitude)) {
         $basic_info[__('Location')] = $this->member->latitude . ', ' . $this->member->longitude;
         $basic_info[__('Location')] = html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide'))) . '<div id="map" style="display: none">' . __('Map loading') . '</div>';
         $map = new Gmap('map', array('ScrollWheelZoom' => true));
         $map->center($this->member->latitude, $this->member->longitude, 15)->controls('small')->types();
         $map->add_marker($this->member->latitude, $this->member->longitude, html::avatar($this->member->avatar, $this->member->username) . html::user($this->member));
         widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
         widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
     }
     // Site info
     $site_info = array(__('Registered') => date::format('DMYYYY_HM', $this->member->created) . ' [#' . $this->member->id . ']', __('Logins') => __(':logins (:ago ago)', array(':logins' => number_format($this->member->logins, 0), ':ago' => '<abbr title="' . date::format('DMYYYY_HM', $this->member->last_login) . '">' . date::timespan_short($this->member->last_login) . '</abbr>')), __('Posts') => number_format($this->member->posts, 0), __('Comments') => number_format($this->member->commentsleft, 0));
     // Initialize tabs
     $tabs = array('basic-info' => array('href' => '#basic-info', 'title' => __('Basic info'), 'tab' => new View('generic/list_info', array('id' => 'basic-info', 'title' => __('Basic info'), 'list' => $basic_info))), 'site-info' => array('href' => '#site-info', 'title' => __('Site info'), 'tab' => new View('generic/list_info', array('id' => 'site-info', 'title' => __('Site info'), 'list' => $site_info))));
     widget::add('side', View::factory('generic/tabs', array('id' => 'info-tab', 'tabs' => $tabs)));
     $this->_side_views();
 }
Example #8
0
    ?>

			</dl>
				<?php 
    if ($venue->latitude && $venue->longitude) {
        ?>
			<div id="map" style="display: none"><?php 
        echo __('Map loading');
        ?>
</div>
					<?php 
        $map = new Gmap('map', array('ScrollWheelZoom' => true));
        $map->center($venue->latitude, $venue->longitude, 15)->controls('small')->types();
        $map->add_marker($venue->latitude, $venue->longitude, '<strong>' . html::chars($venue->name) . '</strong><p>' . html::chars($venue->address) . '<br />' . html::chars($venue->zip) . ' ' . html::chars($venue->city_name) . '</p>');
        widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
        widget::add('foot', html::script_source("\$('.contact a[href=#map]').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
        ?>
				<?php 
    }
    ?>
			<?php 
}
?>

		</article>

		<?php 
if (count($venue->images->find_all()) > 1) {
    ?>
		<article class="pictures lightboxed">
			<header>
Example #9
0
File: blogs.php Project: anqqa/Anqh
 /**
  * Latest blog entries
  */
 public function latest()
 {
     // Actions
     if ($this->user) {
         $this->page_actions[] = array('link' => 'blog/add', 'text' => __('New blog entry'), 'class' => 'topic-add');
     }
     widget::add('main', View_Mod::factory('blog/entries', array('mod_class' => 'blogentries', 'entries' => ORM::factory('blog_entry')->find_latest(20))));
 }
Example #10
0
				<?php 
        echo form::checkbox(array('name' => 'filter[]', 'id' => 'all-' . $type), 'all', true);
        ?>
				<?php 
        echo form::label('all-' . $type, __('All'));
        ?>
			</li>
			<?php 
        foreach ($filter['filters'] as $key => $name) {
            ?>
			<li>
				<?php 
            echo form::checkbox(array('name' => 'filter[]', 'id' => $type . '-' . $key), $type . '-' . $key);
            ?>
				<?php 
            echo form::label($type . '-' . $key, $name);
            ?>
			</li>
			<?php 
        }
        ?>
		</ul>
	</fieldset>
	<?php 
    }
    ?>

<?php 
    echo form::close();
    widget::add('footer', html::script_source("\nfunction filters(all) {\n\tif (all) {\n\n\t\t// Open all\n\t\t\$('form.filters input').each(function() {\n\t\t\t\$('.' + this.id + ':hidden').slideDown('normal');\n\t\t});\n\n\t} else {\n\n\t\t// Filter individually\n\t\t\$('form.filters input').each(function() {\n\t\t\tif (\$(this).is(':checked')) {\n\t\t\t\t\$('.' + this.id + ':hidden').slideDown('normal');\n\t\t\t} else {\n\t\t\t\t\$('.' + this.id + ':visible').slideUp('normal');\n\t\t\t}\n\t\t});\n\n\t}\n}\n\n\$(function() {\n\n\t// Hook clicks\n\t\$('form.filters :checkbox').click(function() {\n\n\t\tvar checked = \$(this).is(':checked');\n\n\t\tif (\$(this).val() != 'all') {\n\n\t\t\t// Individual filters\n\t\t\tif (checked) {\n\n\t\t\t\t// Uncheck 'all'\n\t\t\t\t\$('form.filters input[value=\"all\"]').attr('checked', false);\n\n\t\t\t}\n\n\t\t\t// Check 'all' if no other filters\n\t\t\tif (\$('form.filters input[value!=\"all\"]').is(':checked') == false) {\n\t\t\t\t\$('form.filters input[value=\"all\"]').attr('checked', 'checked');\n\t\t\t\tfilters(true);\n\t\t\t} else {\n\t\t\t\tfilters();\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// All filters\n\t\t\tif (!checked) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t\$('form.filters input[value!=\"all\"]').attr('checked', false);\n\t\t\tfilters(checked);\n\n\t\t}\n\n\t});\n});\n"));
}
Example #11
0
 /**
  * Upcoming events
  */
 public function upcoming()
 {
     $this->breadcrumb[] = html::anchor('events/upcoming', __('Upcoming events'));
     $this->page_title = text::title(__('Upcoming events'));
     $this->tab_id = 'upcoming';
     // actions
     if ($this->visitor->logged_in(array('event', 'event admin', 'admin'))) {
         $this->page_actions[] = array('link' => 'event/add', 'text' => __('Add event'), 'class' => 'event-add');
     }
     // fetch events
     if ($this->country) {
         $country = ORM::factory('country', $this->country);
         $filter = array('events.country_id' => $country->id);
     } else {
         $filter = false;
     }
     $events = ORM::factory('event')->find_upcoming(25, $filter);
     if ($events->count()) {
         $this->page_subtitle = __2(':events event', ':events events', $events->count(), array(':events' => '<var>' . $events->count() . '</var>'));
         widget::add('main', View_Mod::factory('generic/filters', array('filters' => $this->_build_filters($events))));
         widget::add('main', View_Mod::factory('events/events', array('events' => $this->_build_events_list($events))));
     }
     $this->_side_views();
 }
Example #12
0
File: tags.php Project: anqqa/Anqh
 /**
  * Edit tag
  *
  * @param  integer|string  $tag_id
  * @param  integer|string  $group_id
  */
 public function _tag_edit($tag_id = false, $group_id = false)
 {
     $this->history = false;
     // for authenticated users only
     if (!$this->user) {
         url::redirect('/tags');
     }
     $errors = $form_errors = array();
     $tag = new Tag_Model((int) $tag_id);
     $form_values = $tag->get_defaults();
     // check post
     if (request::method() == 'post') {
         $post = $this->input->post();
         $extra = array('author_id' => $this->user->id);
         if ($tag->validate($post, true, $extra)) {
             url::redirect(url::model($tag));
         } else {
             $form_errors = $post->errors();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     // editing old?
     if ($tag_id) {
         $this->page_subtitle = __('Edit tag');
         $this->breadcrumb[] = html::anchor(url::model($tag->tag_group), $tag->tag_group->name);
         $this->breadcrumb[] = html::anchor(url::model($tag), $tag->name);
         if ($this->visitor->logged_in('admin')) {
             $this->page_actions[] = array('link' => url::model($tag) . '/delete', 'text' => __('Delete tag'), 'class' => 'tag-delete');
         }
         if (!$tag->id) {
             $errors = array('tags.error_tag_not_found');
         }
     } else {
         $this->page_subtitle = __('Add tag');
         if ($group_id) {
             $tag_group = new Tag_Group_Model((int) $group_id);
             $this->breadcrumb[] = html::anchor(url::model($tag_group), $tag_group->name);
             $this->breadcrumb[] = html::anchor(url::model($tag_group) . '/add', __('Add tag'));
             if ($tag_group->id) {
                 $form_values['tag_group_id'] = $tag_group->id;
             } else {
                 $errors = array('tags.error_tag_group_not_found');
             }
         }
     }
     // show form
     if (empty($errors)) {
         widget::add('main', View_Mod::factory('tags/tag_edit', array('values' => $form_values, 'errors' => $form_errors)));
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
     $this->_side_views();
 }
Example #13
0
 /**
  * Show error box
  *
  * @param string       $title
  * @param string|array $errors
  */
 public function _error($title = '', $errors = false)
 {
     $this->page_title = $title;
     widget::add('main', '<div class="error">' . (is_array($errors) ? implode('<br />', $errors) : $errors) . '</div>');
 }
Example #14
0
 /**
  * Edit venue
  *
  * @param  integer|string  $venue_id
  * @param  integer|string  $category_id
  */
 public function _venue_edit($venue_id = false, $category_id = false)
 {
     $this->history = false;
     $venue = new Venue_Model((int) $venue_id);
     // Check access
     if (!($venue->loaded() && $venue->has_access(Venue_Model::ACCESS_EDIT)) && !(!$venue->loaded() && $this->visitor->logged_in(array('admin', 'venue moderator', 'venue')))) {
         url::back('venues');
     }
     $errors = $form_errors = array();
     $form_values = $venue->as_array();
     // check post
     if (request::method() == 'post') {
         $post = array_merge($this->input->post(), $_FILES);
         $extra = array('author_id' => $this->user->id);
         // got address, get geocode
         if (!empty($post['address']) && !empty($post['city_name'])) {
             list($extra['latitude'], $extra['longitude']) = Gmap::address_to_ll(implode(', ', array($post['address'], $post['zip'], $post['city_name'])));
         }
         if (csrf::valid() && $venue->validate($post, true, $extra)) {
             // handle logo upload
             if (isset($post->logo) && empty($post->logo['error'])) {
                 $logo = Image_Model::factory('venues.logo', $post->logo, $this->user->id);
                 if ($logo->id) {
                     $venue->add($logo);
                     $venue->default_image_id = $logo->id;
                     $venue->save();
                 }
             }
             // handle picture uploads
             foreach (array($post->picture1, $post->picture2) as $picture) {
                 if (isset($picture) && empty($picture['error'])) {
                     $image = Image_Model::factory('venues.image', $picture, $this->user->id);
                     if ($image->id) {
                         $venue->add($image);
                         $venue->save();
                     }
                 }
             }
             // update tags
             $venue->remove(ORM::factory('tag'));
             if (!empty($post->tags)) {
                 foreach ($post->tags as $tag_id => $tag) {
                     $venue->add(ORM::factory('tag', $tag_id));
                 }
             }
             url::redirect(url::model($venue));
         } else {
             $form_errors = $post->errors();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     // editing old?
     if ($venue_id) {
         if ($venue->has_access(Venue_Model::ACCESS_DELETE)) {
             $this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name) . '/delete/?token=' . csrf::token(), 'text' => __('Delete venue'), 'class' => 'venue-delete');
         }
         $this->page_subtitle = __('Edit venue');
         if (!$venue->id) {
             $errors = array('venues.error_venue_not_found');
         } else {
             $venue_category = $venue->venue_category;
         }
     } else {
         $this->page_subtitle = __('Add venue');
         if ($category_id) {
             $venue_category = new Venue_Category_Model((int) $category_id);
             if ($venue_category->id) {
                 $form_values['venue_category_id'] = $venue_category->id;
             } else {
                 $errors = array('venues.error_venue_category_not_found');
             }
         }
     }
     $this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name), 'text' => __('Cancel'), 'class' => 'cancel');
     $this->breadcrumb[] = html::anchor('/venues/' . url::title($venue_category->id, $venue_category->name), $venue_category->name);
     if ($venue->id) {
         $this->breadcrumb[] = html::anchor('/venue/' . url::title($venue->id, $venue->name), $venue->name);
     }
     // show form
     if (empty($errors)) {
         $form = array();
         // tags
         if ($venue_category->tag_group_id) {
             $form['tags'] = $form_values['tags'] = array();
             foreach ($venue_category->tag_group->tags as $tag) {
                 $form['tags'][$tag->id] = $tag->name;
                 if ($venue->has($tag)) {
                     $form_values['tags'][$tag->id] = $tag->name;
                 }
             }
         }
         $venue_categories = ORM::factory('venue_category')->find_all()->select_list('id', 'name');
         $form['venue_category_id'] = $venue_categories;
         widget::add('main', View_Mod::factory('venues/venue_edit', array('form' => $form, 'values' => $form_values, 'errors' => $form_errors)));
         // city autocomplete
         $this->_autocomplete_city();
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
     $this->_side_views();
 }
Example #15
0
File: sign.php Project: anqqa/Anqh
 /**
  * Register with code
  *
  * @param  Invitation_Model  $invitation
  */
 public function _join(Invitation_Model $invitation)
 {
     $this->history = false;
     $user = new User_Model();
     $form_values = $user->as_array();
     $form_errors = array();
     // handle post
     if (request::method() == 'post') {
         $post = $this->input->post();
         $post['email'] = $invitation->email;
         $post['username_clean'] = utf8::clean($post['username']);
         if ($user->validate($post, false, null, null, array('rules' => 'register', 'callbacks' => 'register'))) {
             $invitation->delete();
             $user->add(ORM::factory('role', 'login'));
             $user->save();
             $this->visitor->login($user, $post->password);
             url::back();
         } else {
             $form_errors = $post->errors();
             $form_values = arr::overwrite($form_values, $post->as_array());
         }
     }
     widget::add('main', View::factory('member/signup', array('values' => $form_values, 'errors' => $form_errors, 'invitation' => $invitation)));
 }
Example #16
0
File: info.php Project: anqqa/Anqh
    ?>
</dd>
		<dd><?php 
    echo html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide')));
    ?>
</dd>
		<dd><div id="map" style="display: none"><?php 
    echo __('Map loading');
    ?>
</div></dd>
		<?php 
    $map = new Gmap('map', array('ScrollWheelZoom' => true));
    $map->center($user->latitude, $user->longitude, 15)->controls('small')->types('G_PHYSICAL_MAP', 'add');
    $map->add_marker($user->latitude, $user->longitude, '<strong>' . html::specialchars($user->username) . '</strong>');
    widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
    widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
    ?>
		<?php 
}
?>
	</dl>
</div>

<div id="site-info">
	<h4><?php 
echo __('Site Info');
?>
</h4>
	<dl>
		<dt><?php 
echo __('Registered');