$n_total_like_comments = 0; $n_total_exam_files = 0; $n_total_exam_docs = 0; if (is_a($group, 'DegreeGroup')) { $ref_id = $group->cid; $find_group = DegreeGroup::model()->findByPk($group->cid); $posts_degree = FbPost::model()->findAllByAttributes(array('degree_group_id' => $group->cid)); $docs_degree = FbDoc::model()->findAllByAttributes(array('degree_group_id' => $group->cid)); $files_degree = FbFiles::model()->findAllByAttributes(array('degree_group_id' => $group->cid)); foreach ($docs_degree as $doc) { $docs_like = LikeFbDoc::model()->findByAttributes(array('ref_entity_id' => $doc->fbdid)); $n_total_like_docs += count($docs_like); // array_push($total_like_docs_degree, $docs_like); } $exam_group_created = ExamGroup::model()->findAllByAttributes(array('degree_group_id' => $group->cid)); $member = MemberDegreeGroup::model()->findAllByAttributes(array('user_group_id' => $group->cid)); foreach ($posts_degree as $p) { $photos = PhotoFbPost::model()->findAllByAttributes(array('element_id' => $p->fbpid)); $n_photos_posts_degree += count($photos); // array_push($total_photos_degree_post, $photos); $like_post_degree = LikeFbPost::model()->findAllByAttributes(array('ref_entity_id' => $p->fbpid)); $n_like_post_degree += count($like_post_degree); // array_push($total_like_post_degree, $like_post_degree); $comments = FbPostComment::model()->findAllByAttributes(array('ref_entity_id' => $p->fbpid)); $n_comment_post_degree += count($comments); // array_push($total_degree_post_comment, $comments); foreach ($comments as $c) { $photo_comments_degree_posts = PhotoFbCommentPost::model()->findByAttributes(array('element_id' => $c->cid)); $n_photos_comment_degree += count($photo_comments_degree_posts); // array_push($total_photos_comment_degree, $photo_comments_degree_posts); $like_comment_degree = LikeFbCommentPost::model()->findAllByAttributes(array('ref_entity_id' => $c->cid));
public function saveMember($user_info, $group_id, $param) { if ($param == 'Degree') { $member = MemberDegreeGroup::model()->findByPk(array('user_id' => $user_info->getProperty('id'), 'user_group_id' => $group_id)); } else { if ($param == 'Exam') { $id = $user_info->getProperty('id'); $member = MemberExamGroup::model()->findByPk(array('user_id' => $id, 'user_group_id' => $group_id)); } } if ($member == null) { $class = new ReflectionClass('Member' . $param . 'Group'); $member = $class->newInstanceArgs(); } $member->user_id = $user_info->getProperty('id'); $member->user_group_id = $group_id; $member->validate(); $member->save(); }
public function groupInfo($id) { $comment_number = 0; $like_number = 0; $photo_number = 0; $type_group = ''; $group = ExamGroup::model()->findByPk($id); $criteria = new CDbCriteria(); $criteria->condition = 'created_time >= "2013-09-01 00:00:00" and created_time <= "2014-08-31 00:00:00"'; $criteria2 = new CDbCriteria(); $criteria2->condition = 'updated_time >= "2013-09-01 00:00:00" and updated_time <= "2014-08-31 00:00:00"'; if ($group == null) { $group = DegreeGroup::model()->findByPk($id); $type_group = 'degree'; $post = FbPost::model()->findAllByAttributes(array('degree_group_id' => $id), $criteria); $doc = FbDoc::model()->findAllByAttributes(array('degree_group_id' => $id), $criteria); $criteria2 = new CDbCriteria(); $criteria2->condition = 'updated_time >= "2013-09-01 00:00:00" and updated_time <= "2014-08-31 00:00:00"'; $files = FbFiles::model()->findAllByAttributes(array('degree_group_id' => $id), $criteria2); $member = MemberDegreeGroup::model()->findAllByAttributes(array('user_group_id' => $id)); } else { $type_group = 'exam'; $post = FbPost::model()->findAllByAttributes(array('exam_group_id' => $id), $criteria); $doc = FbDoc::model()->findAllByAttributes(array('exam_group_id' => $id), $criteria); $files = FbFiles::model()->findAllByAttributes(array('exam_group_id' => $id), $criteria2); $member = MemberExamGroup::model()->findAllByAttributes(array('user_group_id' => $id)); } $comment_like = 0; foreach ($post as $p) { $comment = FbPostComment::model()->findAllByAttributes(array('ref_entity_id' => $p->fbpid), $criteria); $comment_number += count($comment); if ($comment != null) { foreach ($comment as $c) { $comment_like += $c->like_count; } } $photo = PhotoFbPost::model()->findAllByAttributes(array('element_id' => $p->fbpid)); $photo_number += count($photo); $like = LikeFbPost::model()->findAllByAttributes(array('ref_entity_id' => $p->fbpid)); $like_number += count($like); } ?> <div class=".col-md-8" style="background-color: rgb(184, 181, 181)"> <table class="table table-bordered"> <thead> <tr> <th >Nome</th> <th>N. membri</th> <th>N. post</th> <th>N. Like ai post</th> <th>N. Commenti</th> <th>N. like commenti</th> <th>N. files</th> <th>N. docs</th> <th>N.photos post</th> </tr> </thead> <tbody> <tr> <td><?php echo $group->name; ?> </td> <td><?php echo count($member); ?> </td> <td><?php echo count($post); ?> </td> <td><?php echo $like_number; ?> </td> <td><?php echo $comment_number; ?> </td> <td><?php echo $comment_like; ?> </td> <td><?php echo count($files); ?> </td> <td><?php echo count($doc); ?> </td> <td><?php echo $photo_number; ?> </td> </tr> </tbody> </table> </div> <br> <?php }