Example #1
0
<?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;
    }
Example #2
0
<?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'];