Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7dafd607

Přidáno uživatelem Michal Kliment před více než 9 roky(ů)

Release 1.1.12

Zobrazit rozdíly:

application/controllers/comments.php
}
}
/**
* Handles relation between comment and other table in database, which has
* to contains column comments_thread_id.
*
* Adds new comment thread to type and foreign key.
*
* @author Michal Kliment
* @param string $type
* @param integer $fk_id
*/
public function add_thread($type = NULL, $fk_id = NULL)
{
// bad parameter
if (!$type || !$fk_id || !is_numeric($fk_id))
Controller::warning(PARAMETER);
// creates model name
$model = ucfirst($type) . '_Model';
// this model doesn't exist
if (!class_exists($model))
Controller::error(RECORD);
$object = new $model($fk_id);
// record doesn't exist or doesn't support comment thread
if (!$object->id || !$object->property_exists('comments_thread_id'))
Controller::error(RECORD);
// comment thread doesn't exist
if (!$object->comments_thread_id)
{
$comments_thread = new Comments_thread_Model();
$comments_thread->type = $type;
$comments_thread->save();
$object->comments_thread_id = $comments_thread->id;
$object->save();
}
$this->add($object->comments_thread_id);
}
/**
* Edits comment
*

Také k dispozici: Unified diff