public function pixlr ($query) { $info = Globals::user_info(); if (empty($info['username'])) { $info = Database::get_full_row('user', 0); } $this->user_id = $info['id']; $alias = Meta_Author::get_alias_by_name($info['username']); $image_data = file_get_contents($query['image']); $this->save($image_data, $alias); $this->redirect_address = '/gallery/author/'.$alias.'/'; }
protected function get_latest_art () { $latest_art_count = Config::settings('latest_art', 'count'); $latest = Database::get_table( 'art', array('id', 'user_id', 'name'), 'area != "deleted" order by date desc limit '.$latest_art_count ); $galleries = array(); $image_limit = Config::settings('latest_art', 'image_limit'); $galleries_limit =Config::settings('latest_art', 'galleries_limit'); foreach ($latest as $art) { if ( !empty($galleries[$art['user_id']]['images']) && count($galleries[$art['user_id']]['images']) >= $image_limit ) { continue; } $galleries[$art['user_id']]['images'][] = array( 'id' => $art['id'], 'name' => $art['name'], ); } $galleries = array_slice($galleries, 0, $galleries_limit, true); $users = Database::get_vector( 'user', array('id', 'username'), Database::array_in('id', $galleries), array_keys($galleries) ); foreach ($users as $id => $user) { $alias = Meta_Author::get_alias_by_name($user); $galleries[$id]['link'] = empty($alias) ? $user : $alias; $galleries[$id]['username'] = $user; } $this->items['new'] = $galleries; }
public function description ($query) { $params = array(); if (isset($query['meta']) && $query['meta'] == 'author' && isset($query['alias'])) { $params['type'] = 'author'; $params['id'] = $query['alias']; } elseif (isset($query['id'])) { $params['type'] = 'art'; $params['id'] = $query['id']; } else { return; } $text = Database::get_row( 'description', array('text', 'pretty_text'), 'type = ? and description_id = ?', $params ); if (!empty($text)) { $params = array_merge($params, $text); } if ($params['type'] == 'author') { $user = Meta_Author::get_data_by_alias((array) $params['id']); $user = current($user); $params['username'] = $user['name']; } else { $params['data'] = Database::get_full_row('art', $query['id']); $params['username'] = Database::get_field('user', 'username', $params['data']['user_id']); $params['alias'] = Meta_Author::get_alias_by_name($params['username']); $params['data']['weight'] = Transform_File::weight($params['data']['weight']); $params['data']['date'] = Transform_String::rudate(Database::date_to_unix($params['data']['date'])); } $params['can_edit'] = ($params['username'] == Globals::user_info('username')); return $params; }
protected function test_rights ($query) { if ($query['type'] == 'art') { $params = array( $query['id'], Globals::user_info('id') ); return Database::get_field('art', 'id', 'id = ? and user_id = ?', $params); } if ($query['type'] == 'author') { $user = Meta_Author::get_data_by_alias((array) $query['id']); if (empty($user)) { return false; } $user = current($user); return (Globals::user_info('username') == $user['name']); } }