<?php include_model('tag_alias'); class Tag extends ActiveRecord { function _construct() { $this->tag_type = (int) $this->tag_type; $this->type_name = $this->type_name($this->tag_type); $this->is_ambiguous = (bool) $this->is_ambiguous; } static function recalculate_post_count() { $sql = "UPDATE tags SET post_count = (SELECT COUNT(*) FROM posts_tags pt, posts p WHERE pt.tag_id = tags.id AND pt.post_id = p.id AND p.status <> 'deleted')"; db::execute_sql($sql); } function api_attributes() { return array('id' => $this->id, 'name' => $this->name, 'count' => $this->post_count, 'type' => $this->tag_type, 'ambiguous' => $this->is_ambiguous); } function to_xml($options = array()) { return to_xml($this->api_attributes(), "tag", array('skip_instruct' => true)); } function to_json($args = array()) { return to_json($this->api_attributes()); } static function batch_get_tag_types_for_posts($posts) { $tags = array();
<?php include_model('forum_post'); helper('avatar'); verify_method('post', array('only', 'create, destroy, update, stick, unstick, lock, unlock')); before_filter(array('only_user' => 40), 'only', 'stick, unstick, lock, unlock'); before_filter(array('only_user' => 10), 'only', 'destroy, update, edit, add, mark_all_read'); before_filter(array('post_only_user' => 10), 'only', 'create'); set_actions('stick', 'unstick', 'preview', 'new', 'create', 'destroy', 'edit', 'update', 'show', 'index', 'search', 'lock', 'unlock', 'mark_all_read');
<?php include_model('ban, tag, user_blacklisted_tag'); has_one('ban', array('foreign_key' => 'user_id')); has_one('user_blacklisted_tag'); belongs_to('avatar_post', array('model_name' => "Post", 'foreign_key' => 'avatar_post_id')); before('validation', 'commit_secondary_languages'); before('create', 'can_signup, set_role'); before('save', 'encrypt_password'); after('create', 'set_default_blacklisted_tags, increment_count'); after('save', 'commit_blacklists'); after('destroy', 'decrement_count'); validates(array('name' => array('length' => '2..20', 'format' => array('/\\A[^\\s;,]+\\Z/', 'on' => 'create', 'message' => 'cannot have whitespace, commas, or semicolons'), 'uniqueness' => array(true, 'on' => 'create')), 'password' => array('length' => array('>=5', 'if' => array('property_exists' => 'password')), 'confirmation' => true))); // # validates_format_of :name, :with => /^(Anonymous|[Aa]dministrator)/, :on => :create, :message => "this is a disallowed username" // m.after_save :update_cached_name if CONFIG["enable_caching"] // m.has_many :tag_subscriptions, :dependent => :delete_all, :order => "name" // m.validates_format_of :language, :with => /^([a-z\-]+)|$/ // m.validates_format_of :secondary_languages, :with => /^([a-z\-]+(,[a-z\0]+)*)?$/ class User extends ActiveRecord { static $current; function _construct() { if (isset($this->is_anonymous)) { return; } elseif (isset($this->id)) { $this->is_anonymous = false; } // if(CONFIG::show_samples) // $this->show_samples = false; }
* your Slim application now by passing an associative array * of setting names and values into the application constructor. */ $app = new \Slim\Slim(); /** * Step 3: Define the Slim application routes * * Here we define several Slim application routes that respond * to appropriate HTTP request methods. In this example, the second * argument for `Slim::get`, `Slim::post`, `Slim::put`, `Slim::patch`, and `Slim::delete` * is an anonymous function. */ // GET route $app->get('/user/:userid', function ($userid) use($app) { include_controller('user'); include_model('user'); $obj = new user(); $obj->getDetails($app, $userid); }); // POST route $app->post('/post', function () { echo 'This is a POST route'; }); // PUT route $app->put('/put', function () { echo 'This is a PUT route'; }); // PATCH route $app->patch('/patch', function () { echo 'This is a PATCH route'; });
<?php include_model('note, flagged_post_detail, post_votes, tag_implication'); belongs_to('user'); has_one('flag_detail', array('model_name' => "FlaggedPostDetail")); has_many('notes', array('order' => 'id DESC', 'conditions' => array('is_active = 1'))); before('save', 'commit_tags'); before('create', 'before_creation, set_index_timestamp'); after('create', 'after_creation'); after('delete', 'clear_avatars, give_favorites_to_parent'); has_many('comments', array('order' => "id")); // m.after_save :save_post_history // m.has_many :tag_history, :model_name => "PostTagHistory", :table_name => "post_tag_histories", :order => "id desc" // m.versioned :source, :default => "" // m.versioned :cached_tags /* Parent parameters */ after('save', 'update_parent'); // m.validate :validate_parent // m.versioned :parent_id, :default => nil has_many('children', array('model_name' => 'Post', 'order' => 'id', 'foreign_key' => 'parent_id', 'conditions' => array("status != 'deleted'"))); before('validation_on_create', 'download_source, ensure_tempfile_exists, determine_content_type, validate_content_type, generate_hash, set_image_dimensions, set_image_status, check_pending_count, generate_sample, generate_jpeg, generate_preview, move_file'); class Post extends ActiveRecord { function _construct() { $prefix = !CONFIG::download_filename_prefix ? null : CONFIG::download_filename_prefix . ' '; $abmd5 = substr($this->md5, 0, 2); if ($this->id) { $row = DB::select_row("u.name AS author, GROUP_CONCAT(CONCAT(t.name,':',t.tag_type) SEPARATOR ' ') AS cached_tags\n FROM posts p\n JOIN posts_tags pt ON p.id = pt.post_id\n JOIN tags t ON pt.tag_id = t.id\n JOIN users u ON p.user_id = u.id\n WHERE pt.post_id = " . $this->id); $this->cached_tags = $row['cached_tags']; $this->author = $row['author'];
<?php include_model('comment, note_version'); if (!empty(Request::$params->name)) { $user = User::find_by_name(Request::$params->name); } else { $user = User::find(Request::$params->id); } if (!$user) { return 404; } else { set_title($user->id == User::$current->id ? "My Profile" : $user->name . "'s Profile"); } if (User::is('>=40')) { // $user_ips = UserLog.find_by_sql("SELECT ul.ip_addr, ul.created_at FROM user_logs ul WHERE ul.user_id = #{@user.id} ORDER BY ul.created_at DESC") // $user_ips.map! { |ul| ul.ip_addr } // $user_ips.uniq! } $tag_types = CONFIG::$tag_types; foreach (array_keys($tag_types) as $k) { if (!preg_match('/^[A-Z]/', $k) || $k == 'General' || $k == 'Faults') { unset($tag_types[$k]); } } // $tag_types = array_filter(array_map(function($k){if (preg_match('/^[A-Z]/', $k) && $k != 'General' && $k != 'Faults') return $k;}, array_keys(CONFIG::$tag_types))); // vde($tag_types);
<?php if (!($forum_post = ForumPost::find(request::$params->id))) { return 404; } include_model('comment'); create_page_params(); set_title($forum_post->title); $children = ForumPost::find_all(array('order' => "id", 'per_page' => 30, 'conditions' => array("parent_id = ?", request::$params->id), 'page' => request::$params->page)); if (!User::$current->is_anonymous && User::$current->last_forum_topic_read_at < $forum_post->updated_at && $forum_post->updated_at < gmd_math('sub', 'T3S')) { User::$current->update_attribute('last_forum_topic_read_at', $forum_post->updated_at); } calc_pages(); respond_to_list($forum_post);