private function groupQuery() { set_time_limit(0); $exam_group = ExamGroup::model()->findByAttributes(array("update_time" => null)); $exam_groups = array($exam_group); if (!isset($exam_group)) { $degree_group = DegreeGroup::model()->findByAttributes(array("update_time" => null)); if (!isset($degree_group)) { $criteria = new CDbCriteria(); $criteria->limit = 3; $criteria->order = "update_time ASC"; $exam_groups = ExamGroup::model()->findAll($criteria); } } $fbController = new FbController(); foreach ($exam_groups as $eg) { if (isset($eg)) { $fbController->examin_exam_group($eg->eid); } } $degree_groups = array($degree_group); if (!isset($degree_group)) { $criteria = new CDbCriteria(); $criteria->limit = 3; $criteria->order = "update_time ASC"; $degree_groups = DegreeGroup::model()->findAll($criteria); } $fbController = new FbController(); foreach ($degree_groups as $dg) { if (isset($dg)) { $fbController->examin_degree_group($dg->cid); } } echo 'ENDED'; }
public function saveExamGroupInfo($data, $course_id) { $group = ExamGroup::model()->findByPk($data->getProperty('id')); if ($group == null) { $group = new ExamGroup(); } $course = new Courses(); $course = Courses::model()->findByPk($course_id); $group->eid = $data->getProperty('id'); $group->name = $data->getProperty('name'); //$datetime->add(new DateInterval('PT1H')); $group->email = $data->getProperty('email'); if (null != $data->getProperty('owner')) { $group->owner_id = $data->getProperty('owner')->getProperty('id'); $this->saveMemberInfo($data->getProperty('owner')); $this->saveGroupMember($data->getProperty('owner'), $data->getProperty('id'), 'Exam'); } $group->description = $data->getProperty('description'); $group->courses_id = $course_id; if (isset($course)) { $group->degree_id = $course->degree_id; } $degreeGroup = DegreeGroup::model()->findByAttributes(array('degree_id' => $course->degree_id)); if ($degreeGroup != null) { $group->degree_group_id = $degreeGroup->cid; } $group->save(); }
?> </label> <br> <label>Numero di foto nei post: <?php echo $n_total_photo_post_exam; ?> </label> <br> <label>Numero di foto nei commenti: <?php echo $n_total_photo_exam_comments; ?> </label> <?php } else { $ref_id = $group->eid; $exam = ExamGroup::model()->findByPk($ref_id); $posts_exam = FbPost::model()->findAllByAttributes(array('exam_group_id' => $ref_id)); $exam_member = MemberExamGroup::model()->findAllByAttributes(array('user_group_id' => $ref_id)); // array_push($total_post_exam, $posts_exam); $docs_exam = FbDoc::model()->findAllByAttributes(array('exam_group_id' => $ref_id)); $files_exam = FbFiles::model()->findAllByAttributes(array('exam_group_id' => $ref_id)); foreach ($posts_exam as $pe) { $posts_exam_like = LikeFbPost::model()->findAllByAttributes(array('ref_entity_id' => $pe->fbpid)); // array_push($total_posts_exam_like, $posts_exam_like); $n_total_post_exam_like += count($posts_exam_like); $photos_exam_post = PhotoFbPost::model()->findAllByAttributes(array('element_id' => $pe->fbpid)); // array_push($total_photo_post_exam, $photos_exam_post); $n_total_photo_post_exam += count($photos_exam_post); $comments = FbPostComment::model()->findAllByAttributes(array('ref_entity_id' => $pe->fbpid)); foreach ($comments as $c) { array_push($total_exam_post_comment, $c);
public function actionFillDb() { set_time_limit(0); ini_set('mysqli.reconnect', 'on'); ini_set('mysql.connect_timeout', 400); // foreach (glob("C:/Users/fabio/git/qea/webapp/protected/vendors/qea/qa-include/*.php") as $filename) // { // inclde $filename; // } $tag = ""; $criteria = new CDbCriteria(); $criteria->condition = "post_type_l1 like '%useful%' AND post_type_l3 like '%si%' "; // $criteria->condition = "fbpid = 143370932459708"; $posts = FbPost::model()->findAll($criteria); foreach ($posts as $p) { $blob_id = null; if ($this->addFakeName($p->author_id)) { $qa_user_id = $this->addAuthor($p->author_id); } if (is_array($qa_user_id)) { $qa_user_id = $qa_user_id[0]; } // $tag = str_replace("_baseline", "",$p->post_type_l2); // $tag = str_replace("_", "-",$p->post_type_l2); //categories if (isset($p->degree_group_id)) { $category_id = $this->setSecondLevelCategory($p->degree_group_id, 1); } else { if (isset($p->exam_group_id)) { $exam_group = ExamGroup::model()->findByPk($p->exam_group_id); $course = Courses::model()->findByPk($exam_group->courses_id); $parent = $this->setSecondLevelCategory($course->degree_id, 0); $category_id = $this->setThirdLevelCategory($course->name, $parent); // $exam_group = ExamGroup::model()->findByPk($p->exam_group_id); // $course = Courses::model()->findByPk($exam_group->courses_id); $tag = $course->name; $tag = str_replace(" ", "-", $tag); // $tag = $tag.","; } } $photo = PhotoFbPost::model()->findByAttributes(array('element_id' => $p->fbpid)); if (isset($photo)) { $photo->medium = str_replace("/" . $photo->fid . "jpeg", "", $photo->medium); $blob_id = qa_upload_file($photo->medium, $photo->fid . 'jpeg'); } $tag_hold = ""; $substrmessage = substr($p->message, 0, 50); if (is_int(strpos($substrmessage, "["))) { for ($i = strpos($substrmessage, "[") + 1; $i < strlen($p->message); $i++) { if ($p->message[$i] == "]") { break; } $tag_hold = $tag_hold . $p->message[$i]; } if ($tag == "") { $tag = str_replace(" ", "-", $tag_hold); } else { $tag = $tag . "," . str_replace(" ", "-", $tag_hold); } } $title = substr($p->message, 0, 100); $title = $title . "..."; //posts if (qa_post_check_by_fb_id($p->fbpid) == null) { if ($blob_id != null) { $p->message = '<p><img alt="" src="http://www.universitree.com/?qa=blob&qa_blobid=' . $blob_id['blobid'] . '" style="height:250px;"><br>' . $p->message . '</p>'; //RIVEDI $question_id = qa_post_create_with_data("Q", null, $title, $p->message, 'html', $p->created_time, $category_id, $tag, $qa_user_id); qa_post_set_hidden($question_id, true); } else { $question_id = qa_post_create_with_data("Q", null, $title, $p->message, '', $p->created_time, $category_id, $tag, $qa_user_id); } qa_post_create_fb_mapping($question_id, $p->fbpid); $this->addLikes($p->fbpid, $question_id); $this->addAnswer($p->fbpid, $question_id); // $this->deletePost($p->fbpid); } // $comments = FbPostComment::model()->findAllByAttributes(array("ref_entity_id" => $p->fbpid)); // foreach ($comments as $c){ // if($this->addFakeName($c->author_id)) // if(!$this->addAuthor($c->author_id)) // echo "problemi di inconsistenza nei commenti"; // } //inserire qui gli unset unset($blob_id); unset($qa_user_id); unset($category_id); unset($exam_group); unset($course); unset($photo); $p->post_type_l1 = "ut_base"; $p->save(); } //$this->deleteUselessPost(); }
public function deleteDegreeInfo() { die; $post = FbPost::model()->findAllByAttributes(array('exam_group_id' => '123811091057378')); foreach ($post as $p) { $comment = FbPostComment::model()->deleteAllByAttributes(array('ref_entity_id' => $p->fbpid)); $photo = PhotoFbPost::model()->deleteAllByAttributes(array('element_id' => $p->fbpid)); $like = LikeFbPost::model()->deleteAllByAttributes(array('ref_entity_id' => $p->fbpid)); } $doc = FbDoc::model()->deleteAllByAttributes(array('exam_group_id' => '123811091057378')); $files = FbFiles::model()->deleteAllByAttributes(array('exam_group_id' => '123811091057378')); $post = FbPost::model()->deleteAllByAttributes(array('exam_group_id' => '123811091057378')); $exam_group = ExamGroup::model()->deleteAllByAttributes(array('eid' => '123811091057378')); $connection = Yii::app()->db; $command = $connection->createCommand("SELECT * FROM member_exam_group where user_group_id = '123811091057378' and user_id not in (select user_id from member_exam_group where user_group_id != '123811091057378')and user_id not in (select user_id from qeanalysis.member_degree_group where user_group_id != '123811091057378')"); $row = $command->queryAll(); foreach ($row as $r) { $user_personal_info = UserPersonalInfo::model()->deleteByPk($r['user_id']); echo $r['user_id']; $user = User::model()->deleteByPk($r['user_id']); $member = MemberExamGroup::model()->deleteAllByAttributes(array('user_id' => $r['user_id'], 'user_group_id' => '123811091057378')); } // echo ' post: '. $post . ' user '. $user. ' personal info: '. $user_personal_info. ' '.$member ; }