/**
  * get the list of gallery items
  *
  * @param int $gid 
  * @return array
  * @author Andy Bennett
  */
 function get_list($gid)
 {
     $data = array('action' => 'list', 'name' => $this->name, 'role' => Steamauth::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     // which model are we using? one passed through or the default?
     $model = $this->model;
     $controller = Kohana::instance()->uri->segment(1);
     $tdata = array();
     $limit = 10;
     $where = null;
     if ($this->uri->segment(3)) {
         $where = array('gallery' => $gid);
     }
     // query the model
     $pagination = pagination_helper::get_pagination($limit, $model->get_total($where));
     $l = steamcore::array_object(array('limit' => $limit, 'offset' => $pagination->sql_offset()));
     $data['query'] = $model->get_list($where, $order = null, $limit = $l);
     $data['controller'] = $controller;
     $data['pagination'] = $pagination->render();
     // pass the order direction
     // $data['od'] = (!isset($lc->query_config->order_dir) || $lc->query_config->order_dir == 'DESC')?'ASC':'DESC';
     // merge any passed data and the data returned from the model
     $tdata = array_merge($tdata, $data);
     // return the result
     return $tdata;
 }
Esempio n. 2
0
 /**
  * constructor; set display template
  *
  * @author Andy Bennett
  */
 function __construct()
 {
     Acl::instance()->redirect(Steamauth::instance()->get_role(), 'edit', null, '../');
     parent::__construct();
     parent::init();
     $tpl = request::is_ajax() || isset($_GET['ajax']) ? 'template-ajax' : 'template-admin';
     Display::instance()->set_template($tpl);
 }
 /**
  * check acl (used by xsl)
  *
  * @param string $acl 
  * @return void
  * @author Andy Bennett
  */
 public static function check_acl($acl)
 {
     $acl = (string) $acl;
     // if no role is specified return true
     if (empty($acl)) {
         return true;
     }
     return Acl::instance()->check(Steamauth::instance()->get_role(), null, $acl);
 }
            ?>
				<div class="newline"></div>
			<?php 
        }
        ?>
			
			<div class="item status_<?php 
        echo $status;
        ?>
 showadmin" id="item_<?php 
        echo $row->gid;
        ?>
" >
				
				<?php 
        if (Acl::instance()->check(Steamauth::instance()->get_role(), null, 'edit')) {
            ?>
				<div class="adminbg" id="adminbg_<?php 
            echo $row->gid;
            ?>
"></div>
				<div class="admin_buttons hidebuttons" id="adminbuttons_<?php 
            echo $row->gid;
            ?>
">
					<?php 
            echo form::open('/' . $controller . '/delete', '');
            ?>
						<?php 
            echo form::hidden('form_id', $row->gid);
            ?>
 /**
  * replace {} placeholders in the form
  *
  * @return void
  * @author Andy Bennett
  */
 function replace_placeholders($form_data = array())
 {
     // first convert the form object back to a string
     $f = $this->form_xml_string;
     // first replace placeholders matching {form_XXXX} with input post data
     if (preg_match_all('/{form_([a-zA-Z0-9_-]+)}/', $f, $matches)) {
         for ($i = 0; $i < count($matches[1]); $i++) {
             $m = $matches[1][$i];
             $u = Kohana::instance()->input->post('form_' . $m);
             $v = $m !== false ? $u : '';
             $f = str_replace($matches[0][$i], $v, $f);
         }
     }
     // replace placeholders matching {user_XXXX} with data about the current user
     if (preg_match_all('/{user_([a-z0-9_-]+)}/', $f, $matches)) {
         for ($i = 0; $i < count($matches[1]); $i++) {
             $m = $matches[1][$i];
             $u = Steamauth::instance()->get_user_data();
             $v = isset($u->{$m}) ? $u->{$m} : '';
             $f = str_replace($matches[0][$i], $v, $f);
         }
     }
     // replace placeholders matching {uri_X} with data from the URI string
     if (preg_match_all('/{uri_([0-9]+)}/', $f, $matches)) {
         for ($i = 0; $i < count($matches[1]); $i++) {
             $m = (int) $matches[1][$i];
             $s = Kohana::instance()->uri->segment($m);
             $v = isset($s) ? $s : '';
             $f = str_replace($matches[0][$i], $v, $f);
         }
     }
     if (!isset($form_data['controller'])) {
         $form_data['controller'] = Kohana::instance()->uri->segment(1);
     }
     // finally replace any items from form_data
     foreach ($form_data as $k => $v) {
         if (is_string($v) || is_numeric($v)) {
             $f = str_replace('{' . $k . '}', htmlentities($v), $f);
         }
     }
     // now convert the string back to a simplexml object
     $this->form = simplexml_load_string($f);
 }
Esempio n. 6
0
 /**
  * return upload data
  *
  * @param string $field The field name to join to the uploads table on
  * @param integer $id - the id number of the row that references the upload -- in the join'd table, not the upload table!
  * @param boolean $override - override the status check
  * @return object - the upload data
  * @author Andy Bennett
  */
 function return_ul_data($field, $id, $override = 0)
 {
     $where = array('g.id' => $id);
     if (!Acl::instance()->check(Steamauth::instance()->get_role(), null, 'moderate') || $override) {
         $where['g.status'] = '1';
     }
     $this->db->select('u.*')->from('uploads AS u')->where($where);
     $this->db->join($this->table . ' AS g', 'u.id=g.' . $field);
     $query = $this->db->get();
     if ($query->count() == 0) {
         return false;
     }
     return $query->current();
 }
 /**
  * check for unique value in DB
  *
  * @param string $post 
  * @param string $data 
  * @return boolean
  * @author Andy Bennett
  */
 public static function check_unique($post, $data)
 {
     return Steamauth::instance()->get_model()->check_unique($post, $data);
 }
Esempio n. 8
0
 /**
  * activate a user
  *
  * @return void
  * @author Andy Bennett
  */
 public function activate()
 {
     Steamauth::instance()->activate();
 }
Esempio n. 9
0
 /**
  * set a value
  *
  * @return void
  * @author Andy Bennett
  */
 public function setvalue()
 {
     /*
     	TODO : KOHANAise, test this method
     */
     $data = array('action' => 'edit', 'name' => $this->name, 'role' => Steamauth::instance()->get_role());
     Event::run('steamcore.aclcheck', $data);
     $value = Kohana::instance()->input->post('value');
     $key = Kohana::instance()->input->post('key');
     $id = Kohana::instance()->input->post('form_id');
     if ($this->model->set_item_value($key, $value, $id)) {
         Event::run('steamcore.item_value_set', $action = $this->input->post('current'));
     } else {
         echo 'An error has occurred';
     }
 }
Esempio n. 10
0
 /**
  * return a table row
  *
  * @param object $qc - an object containing the parameters for the search, eg select, where, order
  * @return object - the table row
  * @author Andy Bennett
  */
 function get_db_row($where)
 {
     $this->db->select('u.*');
     $this->db->select($this->table . '.*');
     $this->db->from($this->table);
     $this->db->join('uploads AS u', 'gallery.upload = u.id');
     $this->db->where($where);
     if (!Acl::instance()->check(Steamauth::instance()->get_role(), null, 'moderate')) {
         $this->db->where('gallery.status', '1');
     }
     // group by gallery.id
     $this->db->groupby($this->table . '.id');
     $r = $this->db->get();
     if ($r->count() == 0) {
         return false;
     }
     return $r->current();
 }