/** * Updates the involved Users of this object. * Currently this will be execution always after saving, maybe find a better way. * * Fast Hack!11! * * ToDo: - Make it more flexible! * - Make it faster! * - Missing Users which likes a comment */ public function updateInvolvedUsers() { // Collect User Ids $foundUsersIds = array(); $foundUsersIds[] = $this->created_by; if ($this->object_model != "Activity") { $comments = Comment::model()->findAllByAttributes(array('object_model' => $this->object_model, 'object_id' => $this->object_id)); foreach ($comments as $comment) { $foundUsersIds[] = $comment->created_by; // Comment Likes $likes = Like::model()->findAllByAttributes(array('object_model' => 'Comment', 'object_id' => $comment->id)); foreach ($likes as $like) { $foundUsersIds[] = $like->created_by; } } $likes = Like::model()->findAllByAttributes(array('object_model' => $this->object_model, 'object_id' => $this->object_id)); foreach ($likes as $like) { $foundUsersIds[] = $like->created_by; } } UserContent::model()->deleteAllByAttributes(array('object_model' => $this->object_model, 'object_id' => $this->object_id)); // Add currently involved users foreach (array_unique($foundUsersIds) as $userId) { $userContent = new UserContent(); $userContent->object_model = $this->object_model; $userContent->object_id = $this->object_id; $userContent->user_id = $userId; $userContent->save(); } // Rewrite! }
require_once 'class/info.class.php'; //Класс для получения различной информации require_once 'class/pagination.class.php'; //Пагинация Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem('templates/default/'); //Путь к шаблону $twig = new Twig_Environment($loader); //Инициализируем шаблонизатор //$info = new info(); $site = new siteFunctions(); $user = new UserFunctions(); //Функции юзеров $projectContent = new ProjectContent(); //Объявления $userContent = new UserContent(); //Пользователи $paginationManager = new paginations(); //Пагинация //Получаем все объявления и юзеров $projectContent->getAllAnnouncement(); //Объялвения $projectContent->getAllProjects(); //Проекты $userContent->getAllUser(); //пользователи //Получаем список всех стран мира //$info->getCountries(); $currentUserId = $user->user_id($_SESSION); //ID текущего пользователя $projectContent->getPageCount();