Example #1
0
 public function getTranslateSlideRevision($user_id = false, $slide_revision_id = false, $start, $end, $keywords = '')
 {
     if ($user_id != false || $slide_revision_id != false) {
         $this->initConnection();
         $activities = array();
         $result = array();
         if ($user_id) {
             $user = new User();
             $user->id = $user_id;
             $user->getUsername();
             if (strlen($keywords)) {
                 $result = $this->dbQuery('SELECT * FROM slide_revision WHERE user_id=:user_id AND based_on IS NOT NULL AND translated_from_revision IS NULL AND MATCH (slide_revision.content) AGAINST (\'' . $keywords . '*\' IN BOOLEAN MODE)', array('user_id' => $user_id));
             } else {
                 $result = $this->dbQuery('SELECT * FROM slide_revision WHERE user_id=:user_id AND based_on IS NOT NULL AND translated_from_revision IS NULL AND timestamp >= "' . $start . '" AND timestamp < "' . $end . '"', array('user_id' => $user_id));
             }
             if (count($result)) {
                 foreach ($result as $row) {
                     $slide = new Slide();
                     $slide->createFromIDLite($row['id']);
                     $slide->title = $slide->getTitle();
                     if ($slide->title == "") {
                         $slide->title = "Untitled";
                     }
                     $slide->translator_id = $row['translator_id'];
                     $based_on = new Slide();
                     $based_on->id = $row['based_on'];
                     $based_on->translator_id = $based_on->getTranslatorId();
                     if ($slide->translator_id != $based_on->translator_id) {
                         $activity = new Activity($row['timestamp'], $user, 'translated_slide_revision', $slide);
                         $activities[] = $activity;
                     }
                 }
             }
             if (count($activities)) {
                 foreach ($activities as $activity) {
                     $this->activities[] = $activity;
                 }
             }
         }
     }
 }