EliteConf
 All Data Structures Namespaces Files Functions Variables Pages
PaperController.php
Go to the documentation of this file.
1 <?php
2 
7 class PaperController extends Controller {
8 
13  public $layout = '//layouts/column2';
14 
18  public function filters() {
19  return array(
20  'accessControl', // perform access control for CRUD operations
21  'postOnly + delete', // we only allow deletion via POST request
22  );
23  }
24 
30  public function accessRules() {
31  return array(
32  array('allow', // allow authenticated user to perform 'index' and 'view' actions
33  'actions' => array('index', 'view'),
34  'users' => array('@'),
35  ),
36  array('allow', // allow authenticated user to perform 'create' and 'update' actions
37  'actions' => array('create', 'update'),
38  'users' => array('@'),
39  ),
40  array('allow', // allow authenticated user to perform 'create' and 'update' actions
41  'actions' => array('abc'),
42  'users' => array('@'),
43  ),
44  array('allow', // allow authenticated user to perform 'create' and 'update' actions
45  'actions' => array('download'),
46  'users' => array('@'),
47  ),
48  array('allow', // allow authenticated user to perform 'create' and 'update' actions
49  'actions' => array('uploadPaper'),
50  'users' => array('@'),
51  ),
52  array('allow', // allow admin user to perform 'admin' and 'delete' actions
53  'actions' => array('admin', 'delete'),
54  'users' => array('admin'),
55  ),
56  array('deny', // deny all users
57  'users' => array('*'),
58  ),
59  );
60  }
61 
66  public function actionView($id) {
67  $this->render('view', array(
68  'model' => $this->loadModel($id),
69  ));
70  }
71 
76  public function actionCreate() {
77  $model = new Paper;
78 
79  // Uncomment the following line if AJAX validation is needed
80  // $this->performAjaxValidation($model);
81 
82  if (isset($_POST['Paper'])) {
83  $model->attributes = $_POST['Paper'];
84  if ($model->save())
85  $this->redirect(array('view', 'id' => $model->id));
86  }
87 
88  $this->render('create', array(
89  'model' => $model,
90  ));
91  }
92 
98  public function actionUpdate($id) {
99  $model = $this->loadModel($id);
100 
101  // Uncomment the following line if AJAX validation is needed
102  // $this->performAjaxValidation($model);
103 
104  if (isset($_POST['Paper'])) {
105  $model->attributes = $_POST['Paper'];
106  if ($model->save())
107  $this->redirect(array('view', 'id' => $model->id));
108  }
109 
110  $this->render('update', array(
111  'model' => $model,
112  ));
113  }
114 
120  public function actionDelete($id) {
121  $this->loadModel($id)->delete();
122 
123  // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
124  if (!isset($_GET['ajax']))
125  $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
126  }
127 
131  public function actionIndex() {
132  $dataProvider = new CActiveDataProvider('Paper');
133  $this->render('index', array(
134  'dataProvider' => $dataProvider,
135  ));
136  }
137 
141  public function actionAdmin() {
142  $model = new Paper('search');
143  $model->unsetAttributes(); // clear any default values
144  if (isset($_GET['Paper']))
145  $model->attributes = $_GET['Paper'];
146 
147  $this->render('admin', array(
148  'model' => $model,
149  ));
150  }
151 
157  public function loadModel($id) {
158  $model = Paper::model()->findByPk($id);
159  if ($model === null)
160  throw new CHttpException(404, 'The requested page does not exist.');
161  return $model;
162  }
163 
168  protected function performAjaxValidation($model) {
169  if (isset($_POST['ajax']) && $_POST['ajax'] === 'paper-form') {
170  echo CActiveForm::validate($model);
171  Yii::app()->end();
172  }
173  }
174 
175 
180  function actionUploadPaper() {
181 
182 //Yükleme yapılacak yolu alıyoruz.
183  $dir = Yii::getPathOfAlias('application.uploads');
184 //Yükleme dinleyici, sorunsuz yüklerse true olacaktır.
185  $uploaded = false;
186  $model = new Paper();
187  $command = Yii::app()->db->createCommand();
188  $uid = Yii::app()->user->id;
189 
190  if(isset($_POST['papname']) && $_POST['papname']!="")
191 {
192  //abstract upload
193  if(isset($_GET['va']) && $_GET['type']==0)
194  {
195  if (isset($_POST['Paper'])) {
196  $model->attributes = $_POST['Paper'];
197  $model->name = $_POST['papname'];
198  if(isset($_POST['abstract']))
199  {
200 
201  if(isset($_POST['long']) || isset($_POST['short']))
202  {
203 
204  if(isset($_POST['poster'])){
205  $model->poster=1;
206  }
207 
208  if(isset($_POST['abstract'])){
209  $model->abstract=1;
210  }
211 
212  if(isset($_POST['long'])){
213  $model->type="Long Paper";
214  }
215 
216  if(isset($_POST['short'])){
217  $model->type="Short Paper";
218  }
219 
220  //Upload modelindeki $file objesine gelen dosya eşitleniyor.
221  $file = CUploadedFile::getInstance($model, 'file');
222  if ($model->validate()) {
223  //Yükleme yapılan yer. getName ile dosya aynen adıyla kaydediliyor.
224  $uploaded = $file->saveAs($dir . '/' . $file->getName());
225  $model->save();
226 
227  $command->insert('conference_paper', array(
228  'paperid' => $model->id,
229  'conferenceid' => $_GET['va'],
230  ));
231 
232  $command->insert('paper_author', array(
233  'paperid' => $model->id,
234  'userid' => $uid,
235  ));
236 
237  }
238  }
239  //else echo "Please select paper type.";
240  }
241  //else echo "Please select if the paper is an abstract or final manuscript.";
242  }}
243 
244  //update paper
245  else if(isset($_GET['paperid']) && !(isset($_GET['type'])))
246  {
247  if (isset($_POST['Paper'])) {
248  $model->attributes = $_POST['Paper'];
249  $model->name = $_POST['papname'];
250  if(isset($_POST['final']))
251  {
252 
253  if(isset($_POST['long']) || isset($_POST['short']))
254  {
255 
256  if(isset($_POST['poster'])){
257  $model->poster=1;
258  }
259 
260  if(isset($_POST['abstract'])){
261  $model->abstract=1;
262  }
263 
264  if(isset($_POST['long'])){
265  $model->type="Long Paper";
266  }
267 
268  if(isset($_POST['short'])){
269  $model->type="Short Paper";
270  }
271 
272  //Upload modelindeki $file objesine gelen dosya eşitleniyor.
273  $file = CUploadedFile::getInstance($model, 'file');
274  if ($model->validate()) {
275  //Yükleme yapılan yer. getName ile dosya aynen adıyla kaydediliyor.
276  $uploaded = $file->saveAs($dir . '/' . $file->getName());
277  $model->save();
278 
279  $command->insert('paper_first_final', array(
280  'finalid' => $model->id,
281  'firstid' => $_GET['paperid'],
282  ));
283 
284  $command->insert('paper_author', array(
285  'paperid' => $model->id,
286  'userid' => $uid,
287  ));
288 
289  }
290  }
291  //else echo "Please select paper type.";
292  }
293  //else echo "Please select if the paper is an abstract or final manuscript.";
294  }}
295 
296  //first draft upload
297  else if(isset($_GET['paperid']) && $_GET['type']==1)
298  {
299  if (isset($_POST['Paper'])) {
300  $model->attributes = $_POST['Paper'];
301  $model->name = $_POST['papname'];
302  if(isset($_POST['first']))
303  {
304 
305  if(isset($_POST['long']) || isset($_POST['short']))
306  {
307 
308  if(isset($_POST['poster'])){
309  $model->poster=1;
310  }
311 
312  if(isset($_POST['abstract'])){
313  $model->abstract=1;
314  }
315 
316  if(isset($_POST['long'])){
317  $model->type="Long Paper";
318  }
319 
320  if(isset($_POST['short'])){
321  $model->type="Short Paper";
322  }
323 
324  //Upload modelindeki $file objesine gelen dosya eşitleniyor.
325  $file = CUploadedFile::getInstance($model, 'file');
326  if ($model->validate()) {
327  //Yükleme yapılan yer. getName ile dosya aynen adıyla kaydediliyor.
328  $uploaded = $file->saveAs($dir . '/' . $file->getName());
329  $model->save();
330 
331  $command->insert('paper_abstact_first', array(
332  'firstid' => $model->id,
333  'abstractid' => $_GET['paperid'],
334  ));
335 
336  $command->insert('paper_author', array(
337  'paperid' => $model->id,
338  'userid' => $uid,
339  ));
340 
341  }
342  }
343  //else echo "Please select paper type.";
344  }
345  //else echo "Please select if the paper is an abstract or final manuscript.";
346  }}
347 
348  else if(isset($_GET['paperid']) && $_GET['type']==2)
349  {
350  if (isset($_POST['Paper'])) {
351  $model->attributes = $_POST['Paper'];
352  $model->name = $_POST['papname'];
353  if(isset($_POST['final']))
354  {
355 
356  if(isset($_POST['long']) || isset($_POST['short']))
357  {
358 
359  if(isset($_POST['poster'])){
360  $model->poster=1;
361  }
362 
363  if(isset($_POST['abstract'])){
364  $model->abstract=1;
365  }
366 
367  if(isset($_POST['long'])){
368  $model->type="Long Paper";
369  }
370 
371  if(isset($_POST['short'])){
372  $model->type="Short Paper";
373  }
374 
375  //Upload modelindeki $file objesine gelen dosya eşitleniyor.
376  $file = CUploadedFile::getInstance($model, 'file');
377  if ($model->validate()) {
378  //Yükleme yapılan yer. getName ile dosya aynen adıyla kaydediliyor.
379  $uploaded = $file->saveAs($dir . '/' . $file->getName());
380  $model->save();
381 
382  $command->insert('paper_first_final', array(
383  'finalid' => $model->id,
384  'firstid' => $_GET['paperid'],
385  ));
386 
387  $command->insert('paper_author', array(
388  'paperid' => $model->id,
389  'userid' => $uid,
390  ));
391 
392  }
393  }
394  //else echo "Please select paper type.";
395  }
396  //else echo "Please select if the paper is an abstract or final manuscript.";
397  }}
398 }
399 
400 
401 
402  $this->render('UploadPaper', array(
403  'model' => $model,
404  'uploaded' => $uploaded,
405  'dir' => $dir,
406  ));
407 
408 
409  }
410 
411 
416  function actionDownload() {
417 
418  $model=$this->loadModel($_GET['id']);
419  $name = $model->paper_name;
420  $filecontent = file_get_contents(Yii::getPathOfAlias('application.uploads') .'/'. $name);
421  header("Content-Type: application/pdf");
422  header("Content-disposition: attachment; filename=$name");
423  header("Pragma: no-cache");
424  echo $filecontent;
425  exit;
426  }
427 
431  public function comments($paperid)
432  {
433 
435 
436  if(Yii::app()->user->id != NULL)
437  $usid = Yii::app()->user->id;
438  else
439  $usid = 0;
440 
441  //select all conferences that the user has admin as his user type
442  $comment = mysql_query("SELECT * FROM paper_comment WHERE paperid='$paperid'");
443 
444  if(mysql_num_rows($comment)!=0)
445  {
446  while($row = mysql_fetch_array($comment))
447  {
448 
449  $content = $row['content'];
450  $commentid = $row['comment_id'];
451  $referee = mysql_query("SELECT * FROM users WHERE userid IN (SELECT DISTINCT referee_id FROM referee_comment WHERE comment_id='$commentid')");
452 
453  while($row2 = mysql_fetch_array($referee))
454  {
455  $refereename = $row2['username'];
456 
457  echo "<b>" . $row2['firstname'] . " " . $row2['lastname'] . " : </b>" . $content . "<br><br>";
458 
459  }
460  }}
461  else echo "There are no comments for this paper.<br><br>";
462 
463  }
464 
468  public function view_evaluation($paperid)
469  {
470 
472 
473  if(Yii::app()->user->id != NULL)
474  $usid = Yii::app()->user->id;
475  else
476  $usid = 0;
477 
478  //select all conferences that the user has admin as his user type
479  $evaluation = mysql_query("SELECT * FROM paper_evaluation WHERE paper_id='$paperid'");
480 
481  if(mysql_num_rows($evaluation)!=0)
482  {
483  while($row = mysql_fetch_array($evaluation))
484  {
485 
486  $recommendation = $row['recommendation'];
487  $categorization = $row['categorization'];
488  $evaluationid = $row['evaluation_id'];
489  $referee = mysql_query("SELECT * FROM users WHERE userid IN (SELECT DISTINCT referee_id FROM paper_evaluation_referee WHERE evaluation_id='$evaluationid')");
490 
491  while($row2 = mysql_fetch_array($referee))
492  {
493  $refereename = $row2['username'];
494 
495  echo "<b><b>" . $row2['firstname'] . " " . $row2['lastname'] . " : </b></b><br>";
496  echo "<b>Recommendation : </b>" ; echo $this->recommendation($recommendation) . "<br>";
497  echo "<b>Categorization : </b>" ; echo $this->categorization($categorization) . "<br><br>";
498  }
499  }}
500  else echo "There are no evaluations for this paper.<br><br>";
501 
502  }
503 
504  public function recommendation($recommendation)
505  {
506  if($recommendation==0) echo "Reject";
507  else if($recommendation==1) echo "Probable Reject";
508  else if($recommendation==2) echo "Marginal Tend To Reject";
509  else if($recommendation==3) echo "Marginal Tend To Accept";
510  else if($recommendation==4) echo "Probable Accept";
511  else if($recommendation==5) echo "Accept";
512 
513  }
514 
515  public function categorization($categorization)
516  {
517  if($categorization==0) echo "Highly Theoretical";
518  else if($categorization==1) echo "Tends Towards Theoretical";
519  else if($categorization==2) echo "Balanced Theory And Practice";
520  else if($categorization==3) echo "Tends Towards Practical";
521  else if($categorization==4) echo "Highly Practical";
522 
523 
524  }
525 
529  public function adminFunctions()
530  {
531 
533 
534  if(Yii::app()->user->id != NULL)
535  $usid = Yii::app()->user->id;
536  else
537  $usid = 0;
538 
539  $paperid = $_GET['id'];
540 
541  $admin = mysql_query("SELECT * FROM conference_user_type WHERE userid='$usid' AND usertype=1 AND conferenceid IN
542  (SELECT conferenceid FROM conference_paper WHERE paperid='$paperid')");
543 
544  if(mysql_num_rows($admin)==0)
545  {
546 
547  }
548  else
549  {
550  echo "<a href=\" ./index.php?r=assignReferee/index&va=$paperid\">Assign Referee </a>";
551  echo "<br/>";
552 
553  }
554 
555  }
556 
560  public function isAdmin()
561  {
562 
564 
565  if(Yii::app()->user->id != NULL)
566  $usid = Yii::app()->user->id;
567  else
568  $usid = 0;
569 
570  $paperid = $_GET['id'];
571 
572  $admin = mysql_query("SELECT * FROM conference_user_type WHERE userid='$usid' AND usertype=1 AND conferenceid IN
573  (SELECT conferenceid FROM conference_paper WHERE paperid='$paperid')");
574 
575  if(mysql_num_rows($admin)==0)
576  {
577  echo "hidden";
578  }
579  else
580  {
581 
582  echo "visible";
583 
584  }
585 
586  }
587 
591  public function authorFunctions()
592  {
593 
595 
596  if(Yii::app()->user->id != NULL)
597  $usid = Yii::app()->user->id;
598  else
599  $usid = 0;
600 
601  $paperid = $_GET['id'];
602 
603  $author = mysql_query("SELECT * FROM paper_author WHERE userid='$usid' AND paperid='$paperid'");
604 
605  if(mysql_num_rows($author)==0)
606  {
607 
608  }
609  else
610  {
611  echo "<a href=\" ./index.php?r=paper/uploadPaper&paperid=$paperid\">Update Paper </a></br>";
612  echo "<a href=\" ./index.php?r=paper/uploadPaper&paperid=$paperid&type=1\">Upload First Draft </a></br>";
613  echo "<a href=\" ./index.php?r=paper/uploadPaper&paperid=$paperid&type=2\">Upload Final Manuscript </a></br>";
614  echo "<a href=\" ./index.php?r=paper_keyword&paperid=$paperid\">Update Paper Keywords </a>";
615 
616  echo "<br />";
617 
618  }
619 
620 
621 
622  }
623 
627  public function isAuthor()
628  {
629 
631 
632  if(Yii::app()->user->id != NULL)
633  $usid = Yii::app()->user->id;
634  else
635  $usid = 0;
636 
637  $paperid = $_GET['id'];
638 
639  $author = mysql_query("SELECT * FROM paper_author WHERE userid='$usid' AND paperid='$paperid'");
640 
641  if(mysql_num_rows($author)==0)
642  {
643  echo "hidden";
644  }
645  else
646  {
647 
648  echo "visible";
649 
650  }
651 
652  }
653 
654 
658  public function refereeFunctions()
659  {
660 
662 
663  if(Yii::app()->user->id != NULL)
664  $usid = Yii::app()->user->id;
665  else
666  $usid = 0;
667 
668  $paperid = $_GET['id'];
669 
670  $author = mysql_query("SELECT * FROM paper_referee WHERE userid='$usid' AND paperid='$paperid'");
671 
672  if(mysql_num_rows($author)==0)
673  {
674 
675  }
676  else
677  {
678  echo "<a href=\" ./index.php?r=evaluatePaper/index&va=$paperid\">Evaluate Paper </a>";
679  echo "<br />";
680 
681 
682  }
683 
684 
685 
686  }
687 
691  public function isReferee()
692  {
693 
695 
696  if(Yii::app()->user->id != NULL)
697  $usid = Yii::app()->user->id;
698  else
699  $usid = 0;
700 
701  $paperid = $_GET['id'];
702 
703  $author = mysql_query("SELECT * FROM paper_referee WHERE userid='$usid' AND paperid='$paperid'");
704 
705  if(mysql_num_rows($author)==0)
706  {
707  echo "hidden";
708  }
709  else
710  {
711 
712  echo "visible";
713 
714  }
715 
716  }
717 
718 
719 
720  public function viewTopics($paperid)
721  {
722 
724 
725  if(Yii::app()->user->id != NULL)
726  $usid = Yii::app()->user->id;
727  else
728  $usid = 0;
729 
730 
731 
732  $topicname = mysql_query("SELECT * FROM interests_topics WHERE id IN
733  (SELECT topicid FROM topic_subtopic WHERE subtopicid IN
734  (SELECT interest_id FROM paper_interest WHERE paper_id=$paperid))");
735 
736  $i=0;
737  while ($row4 = mysql_fetch_array($topicname))
738  {
739 
740  echo "<b>" . $row4['name'] . "</b><br>";
741  $topid = $row4['id'];
742 
743  $interest = mysql_query("SELECT * FROM interests_subtopics WHERE id IN
744  (SELECT subtopicid FROM topic_subtopic WHERE topicid=$topid AND subtopicid IN
745  (SELECT interest_id FROM paper_interest WHERE paper_id=$paperid))");
746 
747  while($row5 = mysql_fetch_array($interest))
748  {
749 
750  echo $row5['name'] . "<br>";
751 
752  }
753 
754  echo "<br>";
755  $i++;
756  }
757  /*
758  $interestname = mysql_query("SELECT name FROM interests_subtopics WHERE id IN (SELECT interestid FROM interest_user WHERE userid=$usid)");
759 
760  while ($row3 = mysql_fetch_array($interestname))
761  {
762 
763  echo $row3['name'] . "<br>";
764 
765  }
766  */
767  if($i==0) echo "This paper does not have any topics yet.";
768 
769  }
770 
771 }