removed mods directory from the ATutor codebase
[atutor.git] / mods / photo_album / include / data_func.php
diff --git a/mods/photo_album/include/data_func.php b/mods/photo_album/include/data_func.php
deleted file mode 100644 (file)
index 9358cb3..0000000
+++ /dev/null
@@ -1,699 +0,0 @@
-<?php\r
-/*==============================================================\r
-  Photo Album\r
- ==============================================================\r
-  Copyright (c) 2006 by Dylan Cheon & Kelvin Wong\r
-  Institute for Assistive Technology / University of Victoria\r
-  http://www.canassist.ca/                                    \r
-                                                               \r
-  This program is free software. You can redistribute it and/or\r
-  modify it under the terms of the GNU General Public License  \r
-  as published by the Free Software Foundation.                \r
- ==============================================================\r
- */\r
-// $Id:\r
-\r
-/**\r
- * @desc       This file defines all the functions that access the database.\r
- * @author     Dylan Cheon\r
- * @copyright  2006, Institute for Assistive Technology, University of Victoria \r
- * @link       http://www.canassist.ca/                                    \r
- * @license GNU\r
- */ \r
\r
-/** \r
- * @desc       This function returns all the image rows for the course id\r
- * @param      int             $course_id      course id\r
- * @return     Array   array which contains all the image rows (mysql source)\r
- */\r
- function get_all_images($course_id){\r
-   global $db;\r
-   $table=get_table_name(IMAGE);\r
-   $query="SELECT * FROM ".$table." WHERE course_id=".$course_id;\r
-   $result=mysql_query($query, $db);\r
-   return $result;\r
-}\r
-       \r
-/**\r
- * @desc       This function returns the image array which contains the image information\r
- * @param      int             $course_id              course_id\r
- * @param      int             $status                 image status\r
- * @param      int             $start_page             start page\r
- * @param      int             $display_limit  how many images should be displayed in the page\r
- * @param      boolean $my_pic                 if this value is true, it is set for my photo mode. Returns images for one user if enabled\r
- * @param      String  $login                  login name \r
- * @return     Array                                   the array which contains the data from database\r
- */ \r
-function get_image_array($state, $course_id, $image_status, $start_page, $display_limit, $login=''){\r
-        global $db;\r
-        $table=get_table_name(IMAGE);  \r
-        $start=($start_page-1)*$display_limit;  \r
-        $query;        $i=0;   $array;\r
-        switch ($state){\r
-                case MY_PIC:\r
-                       //$query="SELECT * FROM ".$table." WHERE course_id=".$course_id."  AND status=".$image_status." AND login='{$login}' ORDER BY image_id DESC LIMIT ".$start.", ".$display_limit;\r
-               // changes sorting to order from image_id\r
-               $query="SELECT * FROM ".$table." WHERE course_id=".$course_id."  AND status=".$image_status." AND login='{$login}' ORDER BY `order` ASC LIMIT ".$start.", ".$display_limit;\r
-                break;\r
-               default:\r
-                       //$query="SELECT * FROM ".$table." WHERE course_id=".$course_id."  AND status=".$image_status." ORDER BY image_id DESC LIMIT ".$start.", ".$display_limit;\r
-               // changes sorting to order from image_id\r
-               $query="SELECT * FROM ".$table." WHERE course_id=".$course_id."  AND status=".$image_status." ORDER BY `order` ASC LIMIT ".$start.", ".$display_limit;\r
-               break;\r
-        }\r
-\r
-        $result=mysql_query($query, $db);\r
-        while ($row=mysql_fetch_array($result)){\r
-               $array[$i]['title']=$row['title'];\r
-               $array[$i]['description']=$row['description'];          \r
-               $array[$i]['location']=$row['location'];\r
-               $array[$i]['date']=$row['date'];\r
-               $array[$i]['view_image_name']=$row['view_image_name'];\r
-               $array[$i]['course_id']=$row['course_id'];\r
-               $array[$i]['login']=$row['login'];\r
-               $array[$i]['image_id']=$row['image_id'];\r
-               $array[$i]['thumb_image_name']=$row['thumb_image_name'];\r
-               $array[$i]['alt']=$row['alt'];\r
-               $array[$i]['status']=$row['status'];    \r
-               // gg added image order to array        \r
-               $array[$i]['order']=$row['order'];                              \r
-               $array[$i]['link']=BASE_PATH.'view.php?image_id='.$row['image_id'];\r
-               $i++;\r
-        }\r
-        return $array;\r
-}      \r
-       \r
-\r
-/**\r
- * @desc       This function returns the comment array which contains the comment information\r
- * @param      int             $course_id              course id\r
- * @param      int             $status                 comment status\r
- * @param      int             $image_id               image id\r
- * @param      boolean $index_admin    if this is true, then it returns the comments for admin/instructor view page\r
- * @param      boolean $admin_request  if this is true, then it returns the comments for admin/instructor panel \r
- * @param      int             $display_limit  number of comments to be returned\r
- * @param      int             $start                  start page\r
- * @param      boolean $my_comment             my comment mode is enabled or not. Returns comments for one user if enabled\r
- * @return     Array   the array which contains the comment data from the database\r
- */ \r
-function get_comment_array($state, $course_id, $comment_status, $image_id=NOT_SET, $display_limit=NOT_SET, $start=NOT_SET){\r
-  global $db;\r
-  $table=get_table_name(COMMENT);\r
-  $start=($start-1)*$display_limit;     \r
-  $query;      $i=0;   $array;\r
-\r
-  switch ($state){\r
-         case ADMIN_VIEW:\r
-               $query="SELECT * FROM ".$table." WHERE course_id=".$course_id." AND image_id=".$image_id." ORDER BY date DESC";\r
-        break;\r
-        case ADMIN_PANEL:\r
-               $query="SELECT * FROM ".$table." WHERE course_id=".$course_id."  AND status=".$comment_status." ORDER BY date DESC LIMIT ".$start.", ".$display_limit;\r
-       break;\r
-       case MY_COMMENT:\r
-           $query="SELECT * FROM ".$table." WHERE course_id=".$course_id." AND status=".$comment_status." AND login='{$_SESSION['login']}' ORDER BY date DESC LIMIT ".$start.", ".$display_limit;\r
-       break;\r
-       case STUDENT:\r
-       $query="SELECT * FROM ".$table." WHERE course_id=".$course_id."  AND status=".$comment_status." AND image_id=".$image_id." ORDER BY date DESC";\r
-    break;\r
-  }\r
-  \r
-  $result=mysql_query($query, $db);\r
-  while ($row=mysql_fetch_array($result)){\r
-       $array[$i]['date']=$row['date'];\r
-       $array[$i]['course_id']=$row['course_id'];\r
-       $array[$i]['login']=$row['login'];\r
-       $array[$i]['image_id']=$row['image_id'];\r
-       $array[$i]['comment_id']=$row['comment_id'];\r
-       $array[$i]['comment']=$row['comment'];\r
-       $array[$i]['status']=$row['status'];\r
-       $i++;\r
-  }\r
-  return $array;\r
-}      \r
-       \r
-       \r
-       \r
-/**\r
- * @desc       This function stores the given image input data to the database\r
- * @param      int             $course_id                      course id\r
- * @param      String  $login                          login name\r
- * @param      String  $title                          title string\r
- * @param      String  $description            image description\r
- * @param      String  $view_image_name        view image file name\r
- * @param      String  $location                       location string\r
- * @param      String  $thumb_image_name       thumb image file name\r
- * @param      String  $alt                            alt string\r
- * @param      int             $status                         image status\r
- * @return     boolean                                         returns true if the given input data is stored in the database successfully\r
- */\r
-function store_image_in_database($course_id, $login, $title, $description, $view_image_name, $location, $thumb_image_name, $alt, $status){\r
-       global $db;\r
-       $table=get_table_name(IMAGE);\r
-       $success=false;\r
-       $query="INSERT INTO ".$table." SET course_id='{$course_id}', title='{$title}', description='{$description}', view_image_name='{$view_image_name}', location='{$location}', date=NOW(), login='{$login}', thumb_image_name='{$thumb_image_name}', alt='{$alt}', status='{$status}'";             \r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if (($count==1) && (!mysql_error())){\r
-               $success=true;\r
-       }\r
-       return $success;\r
-}              \r
-\r
-\r
-/**\r
- * @desc       This function stores the given comment input data to the database\r
- * @param      int             $course_id              course id\r
- * @param      String  $login                  login name\r
- * @param      String  $comment                user comment\r
- * @param      int             $image_id               image id\r
- * @param      int             $status                 comment status\r
- * @return     boolean                                 returns true if the given input data is stored in the database successfully\r
- */    \r
-function store_comment_in_database($course_id, $login, $comment, $image_id, $status){\r
-       global $db;\r
-       $table=get_table_name(COMMENT);\r
-       $success=false;\r
-       $query="INSERT INTO ".$table." SET course_id='{$course_id}', comment='{$comment}', date=NOW(), login='{$login}', status='{$status}', image_id='{$image_id}'";                           \r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count==1){ //should affect just one row\r
-               $success=true;\r
-       }\r
-       return $success;\r
-}              \r
-\r
-\r
-/**\r
- * @desc       This function updates the image data in the database\r
- * @param      int             $course_id                      course id\r
- * @param      String  $title                          title string\r
- * @param      String  $description            description\r
- * @param      String  $view_image_name        file name of the full size image \r
- * @param      String  $image_id                       image id\r
- * @param      String  $thumb_image_name       file name of the thumbnail image \r
- * @param      String  $alt                            alt string\r
- * @param      int             $status                         image status\r
- * @return     boolean                                         true if update finished successfully\r
- */\r
-function update_image_in_database($course_id, $title, $description, $view_image_name, $image_id, $thumb_image_name, $alt, $status){\r
-       global $db;\r
-       $table=get_table_name(IMAGE);\r
-       $query="UPDATE ".$table." SET title='{$title}', description='{$description}', thumb_image_name='{$thumb_image_name}', view_image_name='{$view_image_name}', date=NOW(), alt='{$alt}', status='{$status}' WHERE course_id='{$course_id}' AND image_id='{$image_id}'";    \r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count==1){ //should affect just one row\r
-               return true;\r
-       } else {\r
-               return false;\r
-       }                               \r
-}\r
-\r
-/**\r
- * @desc       This function updates the comment data in the database\r
- * @param      int             $course_id              course id\r
- * @param      String  $comment                comment string\r
- * @param      int             $image_id               image id\r
- * @param      int             $comment_id             comment id\r
- * @param      int             $status                 comment status\r
- * @return     boolean                                 true if update finished successfully\r
- */    \r
-function update_comment_in_database($course_id, $comment, $image_id, $comment_id,$status){\r
-       global $db;\r
-       $table=get_table_name(COMMENT);\r
-       $query="UPDATE ".$table." SET comment='{$comment}', status='{$status}', date=NOW() WHERE course_id='{$course_id}' AND image_id='{$image_id}' AND comment_id='{$comment_id}'";   \r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count==1){ //should affect just one row\r
-               return true;\r
-       } else {\r
-               return false;\r
-       }                               \r
-}\r
-       \r
-       \r
-/**\r
- * @desc       This function returns the complete data row from the database\r
- * @param      int             $choose                 choose to search either IMAGE and COMMENT data  \r
- * @param      int             $image_id               image id\r
- * @param      int             $course_id              course id\r
- * @param      int             $comment_id             comment id\r
- * @return     Array                                   the complete data row array\r
- */\r
-function get_single_data($choose, $image_id, $course_id, $comment_id=NOT_SET){\r
-       global $db;     $query;\r
-       $table=get_table_name($choose);\r
-       switch ($choose){\r
-               case IMAGE:\r
-                       $query="SELECT * FROM ".$table." WHERE course_id=".$course_id." AND image_id=".$image_id;\r
-               break;\r
-               case COMMENT:\r
-                       $query="SELECT * FROM ".$table." WHERE course_id=".$course_id." AND image_id=".$image_id." AND comment_id=".$comment_id;\r
-               break;\r
-       }\r
-       $result=mysql_query($query, $db);\r
-       $result=mysql_fetch_array($result);\r
-       return $result;\r
-}\r
-       \r
-\r
-/**\r
- * @desc       This function deletes the image.  Images and blogs which have the same course id and image id should also be deleted \r
- * @param      int             $image_id       image id\r
- * @param      int             $course_id      course id\r
- * @return     boolean                         returns true if deletion is successful\r
- */\r
-function delete_image($image_id, $course_id){\r
-       global $db;\r
-       $image_table=get_table_name(IMAGE);\r
-       $blog_table=get_table_name(COMMENT);\r
-       $delete_image_query="DELETE FROM ".$image_table." WHERE course_id=".$course_id." AND image_id=".$image_id;\r
-       $image_query="SELECT view_image_name, location, thumb_image_name FROM ".$image_table." WHERE course_id=".$course_id." AND image_id=".$image_id;\r
-       $blog_query="DELETE FROM ".$blog_table." WHERE course_id=".$course_id." AND image_id=".$image_id;       \r
-       \r
-       $image_array=mysql_query($image_query, $db);    \r
-       delete_image_files($image_array);               //delete the physical image file\r
-       mysql_query($blog_query, $db);                  //deletes comments\r
-       mysql_query($delete_image_query, $db);  //deletes the images from database\r
-       $count=mysql_affected_rows();\r
-       if ($count ==1){        //should be one image\r
-               return true;\r
-       } else {\r
-               return false;\r
-       }\r
-}\r
-               \r
-       \r
-       \r
-/**\r
- * @desc       This function deletes the given blog comment \r
- * @param      int             $image_id               image id\r
- * @param      int             $course_id              course id\r
- * @param      int             $comment_id             comment id\r
- * @return     boolean                                 returns true if deletion is completed.  \r
- */\r
-function delete_blog($image_id, $course_id, $comment_id){\r
-       global $db;\r
-       $table=get_table_name(COMMENT);\r
-       $query="DELETE FROM ".$table." WHERE course_id=".$course_id." AND image_id=".$image_id." AND comment_id=".$comment_id;\r
-       mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count==1){ //should be only one comment\r
-               return true;\r
-       } else {\r
-               return false;\r
-       }\r
-}\r
-       \r
-       \r
-       \r
-/**\r
- * @desc       This function returns the table name from the database based on a switch variable\r
- * @param      int             $choose         choose either IMAGE, COMMENT or CONFIG\r
- * @return     String                          table name as a string\r
- */\r
-function get_table_name($choose){\r
-       $table_name;\r
-       switch ($choose){\r
-               case IMAGE:\r
-                       $table_name=TABLE_PREFIX.'pa_image';\r
-               break;\r
-               case COMMENT:\r
-                       $table_name=TABLE_PREFIX.'pa_comment';\r
-               break;\r
-               case CONFIG:\r
-                       $table_name=TABLE_PREFIX.'pa_config';\r
-               break;\r
-       }\r
-       return $table_name;\r
-}\r
-       \r
-       \r
-       \r
-/**\r
- * @desc       This function returns the total number of course images\r
- * @param      int                     $course_id              course id\r
- * @param      int                     $status                 image status\r
- * @param      boolean         $mypic                  mypic mode enabled or not. Returns number for one user if enabled\r
- * @return     int                                                     the total number of images\r
- */\r
-function get_total_image_number($state, $course_id, $status){\r
-       global $db;\r
-       $table=get_table_name(IMAGE);\r
-       switch ($state){\r
-               case MY_PIC:\r
-                       $query="SELECT image_id FROM ".$table." WHERE course_id=".$course_id." AND status=".$status." AND login='{$_SESSION['login']}'";\r
-               break;\r
-               default:\r
-                       $query="SELECT image_id FROM ".$table." WHERE course_id=".$course_id." AND status=".$status;\r
-               break;\r
-       }\r
-       \r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       return $count;\r
-}\r
-\r
-/**\r
- * @desc       This function returns the total number of comments\r
- * @param      int             $course_id              course id\r
- * @param      int             $status                 comment status\r
- * @param      boolean $my_comment             mycomment mode is enabled or not. Returns number for one user if enabled\r
- * @param      int             $image_id               image id\r
- * @return     int                                             the total number of comments\r
- */    \r
-function get_total_comment_number($state, $course_id, $status, $image_id=NOT_SET){\r
-       global $db;\r
-       $table=get_table_name(COMMENT);\r
-       switch ($state){\r
-               case MY_COMMENT:\r
-                       $login=$_SESSION['login'];\r
-                       $query="SELECT comment_id FROM ".$table." WHERE course_id=".$course_id." AND status=".$status." AND login='{$login}'"; \r
-               break;\r
-               case ADMIN_PANEL:\r
-                       $query="SELECT comment_id FROM ".$table." WHERE course_id=".$course_id." AND status=".$status;\r
-               break;\r
-               default:        \r
-                 $query="SELECT comment_id FROM ".$table." WHERE course_id=".$course_id." AND image_id=".$image_id." AND status=".$status;\r
-               break;\r
-       }\r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       return $count;\r
-}\r
-\r
-       \r
-       \r
-/**\r
- * @desc       This function returns the last page number to be used for the page table \r
- * @param      int             $display_limit          how many should be displayed in the page\r
- * @param      int             $total                          total number\r
- * @return     int                                                     last page number\r
- */\r
-function get_last_page($display_limit, $total){\r
-       $total=doubleval($total);\r
-       $last_page;     \r
-       if ($total < $display_limit){\r
-               $last_page=FIRST_PAGE;\r
-       } else {\r
-               $last_page=ceil($total/$display_limit);\r
-               $last_page=intval($last_page);\r
-       }               \r
-       return $last_page;\r
-}\r
-       \r
-       \r
-/**\r
- * @desc       This function returns the full name of the member.  The return string syntax is => (First_name)? First_name.Last_name_initial : Anonymous\r
- * @param      String  $login  login name string\r
- * @return     String                  the full name of the member\r
- */\r
-function get_member_name($login){\r
-       global $db;\r
-       $query="SELECT last_name, first_name FROM ".TABLE_PREFIX."members WHERE login='{$login}'";\r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count == 1) {      //in this case, the login is instructor or student\r
-               $result=mysql_fetch_array($result);\r
-               if (empty($result['first_name'])){\r
-                       $name=_AT('anonymous');\r
-               } else if (empty($result['last_name'])){\r
-                       $name=$result['first_name'];\r
-               } else {\r
-                       $temp=substr($result['last_name'], 0, 1);\r
-                       $name=$result['first_name'].'.'.$temp;\r
-               }\r
-               return $name;\r
-       }  else if ($count==0){ //found nobody, check if the user is administrator\r
-               $query="SELECT login FROM ".TABLE_PREFIX."admins WHERE login='{$login}'";\r
-               $result=mysql_query($query, $db);\r
-               $count=mysql_affected_rows();\r
-               if ($count==1){ //admin is detected\r
-                 return _AT('pa_tag_administrator');\r
-               }\r
-       }\r
-}\r
-       \r
-       \r
-       \r
-/**\r
- * @desc       This pagination function returns an array which has the start and end information to be used \r
- * @param      int             $display_limit  maximum number of images displayed in the page\r
- * @param      int             $page_limit             maximum number of pages displayed in the page\r
- * @param      int             $course_id              course id\r
- * @param      int             $current                current page \r
- * @param      int             $last_page              last_page number\r
- * @return     Array                                   array contains the start and end information for page table\r
- */\r
-function get_page_array($display_limit, $page_limit, $current, $last_page){\r
-       $start=1;       \r
-       if ($last_page <= ($start+$page_limit-1)){     //initialize the end variable if the last page is less than start+display-1\r
-               $end=$last_page;\r
-       } else {\r
-               $end=$start+$page_limit-1;\r
-       }\r
-       \r
-       $process=true;\r
-       while ($process==true){\r
-               if (($current >= $start) && ($current <= $end)){\r
-                       $array['start']=$start;\r
-                       $array['end']=$end;\r
-                       $process=false;\r
-               } else {\r
-                       $start=$end+1;\r
-                       $end=$start+$page_limit-1;\r
-                       if ($end > $last_page){\r
-                               $end=$last_page;\r
-                       }\r
-               }\r
-       }\r
-       $array['last_page']=$last_page;\r
-       $array['previous']=$current-1;\r
-       $array['next']=$current+1;\r
-       $array['current']=$current;\r
-       return $array;\r
-}\r
-\r
-               \r
-/**\r
- * @desc       This function checks if the image exists in the database\r
- * @param      int     $image_id       image id\r
- * @param      int     $course_id      course id\r
- * @return     boolean                 it returns true if the image exists in database.  Otherwise, it returns false\r
- */\r
-function image_exist($image_id, $course_id){\r
-       global $db;\r
-       $table_name=get_table_name(IMAGE);\r
-       $query="SELECT * FROM ".$table_name." WHERE course_id=".$course_id." AND image_id=".$image_id;\r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count == 1){       // there should be only 1 image\r
-               return true;\r
-       } else {\r
-               return false;\r
-       }\r
-}      \r
-\r
-\r
-/**\r
- * @desc       This function checks if the comment exists in the database\r
- * @param      int     $comment_id             comment id\r
- * @param      int     $course_id              course id\r
- * @return     boolean                         returns true if the comment exists in database.  Otherwise, it returns false\r
- */\r
-function comment_exist($comment_id, $course_id){\r
-       global $db;\r
-       $table_name=get_table_name(COMMENT);\r
-       $query="SELECT * FROM ".$table_name." WHERE course_id=".$course_id." AND comment_id=".$comment_id;\r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count == 1){       //there should be only 1 comment\r
-               return true;\r
-       } else {\r
-               return false;\r
-       }  \r
-}      \r
-\r
-\r
-/**\r
- * @desc       This function returns an array which has a list of the courses\r
- * @return     Array   array which contains title and course_id\r
- */\r
-function get_course_list(){\r
-       global $db;\r
-       $table=TABLE_PREFIX.'courses';\r
-       $query="SELECT course_id, title FROM ".$table." ORDER BY created_date";\r
-       $result=mysql_query($query, $db);\r
-       $i=0;\r
-       while($row=mysql_fetch_array($result)){\r
-               $array[$i]['title']=$row['title'];\r
-               $array[$i]['id']=$row['course_id'];\r
-               $i++;\r
-       }\r
-       return $array;\r
-}\r
-\r
-\r
-/**\r
- * @desc       This function returns the course title \r
- * @param      int             $course_id      course id\r
- * @return     String                          course title    \r
- */\r
-function get_course_title($course_id){\r
-  global $db;\r
-  $table=TABLE_PREFIX.'courses';\r
-  $query="SELECT title FROM ".$table." WHERE course_id=".$course_id;\r
-  $result=mysql_query($query, $db);\r
-  $result=mysql_fetch_array($result);\r
-  return $result['title'];      \r
-}\r
-\r
-\r
-/**\r
- * @desc       This function checks if the course exists or not \r
- * @param      int     $course_id      course id\r
- * @return     Boolean                 true if exist\r
- */    \r
-function course_exist($id){\r
-  global $db;\r
-  $table=TABLE_PREFIX.'courses';\r
-  $query="SELECT course_id FROM ".$table." WHERE course_id='{$id}'";\r
-  $result=mysql_query($query, $db);\r
-  $count=mysql_affected_rows();\r
-  if ($count==1){ // It should affect only one record\r
-    return true;\r
-  } else {\r
-    return false;   \r
-  }\r
-}\r
-\r
-\r
-/**\r
- * @desc       This function checks whether the given input belongs to the user\r
- * @param      int             $choose         IMAGE or COMMENT to choose\r
- * @param      int             $image_id       image id\r
- * @param      int             $course_id      course id\r
- * @param      int             $comment_id     comment_id\r
- * @return     Boolean                         true if the input belongs to the user\r
- */    \r
-function user_own($choose, $image_id, $course_id, $comment_id=NOT_SET){\r
-       global $db;\r
-       $bool=false;\r
-       $table=get_table_name($choose);\r
-       switch ($choose){\r
-               case IMAGE:\r
-                       $query="SELECT login FROM ".$table." WHERE course_id=".$course_id." AND image_id=".$image_id;\r
-               break;\r
-               case COMMENT:\r
-                       $query="SELECT login FROM ".$table." WHERE course_id=".$course_id." AND image_id=".$image_id." AND comment_id=".$comment_id;\r
-               break;\r
-       }               \r
-       $result=mysql_query($query, $db);\r
-       $result=mysql_fetch_array($result);\r
-       $count=mysql_affected_rows();\r
-       if (is_admin_for_course()){\r
-               $bool=true;\r
-       } else if ($count!=1) {  //there should be only one owner \r
-               global $msg;\r
-               $msg->addError('pa_func_user_own');\r
-               redirect('index.php');\r
-       } else {\r
-               if ($result['login']==$_SESSION['login']){\r
-                       $bool=true;\r
-               }\r
-       } \r
-       return $bool;\r
-}\r
-\r
-\r
-/**\r
- * @desc       This function changes the image status\r
- * @param      int     $image_id               image id\r
- * @param      int     $course_id              course id\r
- * @param      int     $status                 image status, APPROVED, DISAPPROVED or POSTED_NEW\r
- */    \r
-function modify_image_status($image_id, $course_id, $status){\r
-  If (($status==APPROVED || $status==DISAPPROVED || $status==POSTED_NEW) && image_exist($image_id, $course_id)){\r
-       global $db;\r
-       $table=get_table_name(IMAGE);     \r
-       $query="UPDATE ".$table." SET status=".$status." WHERE image_id=".$image_id." AND course_id=".$course_id;\r
-       $result=mysql_query($query, $db);\r
-  }\r
-}\r
-\r
-\r
-/**\r
- * @desc       This function changes the comment status\r
- * @param      int             $comment_id             comment id      \r
- * @param      int             $course_id              course id\r
- * @param      int             $status                 comment status, APPROVED, DISAPPROVED or POSTED_NEW\r
- */    \r
-function modify_comment_status($comment_id, $course_id, $status){\r
-  if (($status==APPROVED || $status==DISAPPROVED || $status==POSTED_NEW) && comment_exist($comment_id, $course_id)){\r
-       global $db;\r
-       $table=get_table_name(COMMENT);\r
-       $query="UPDATE ".$table." SET status=".$status." WHERE course_id=".$course_id." AND comment_id=".$comment_id;\r
-       $result=mysql_query($query, $db);     \r
-  }\r
-}\r
-\r
-\r
-/**\r
- * @desc       This function returns the moderation status for the course. If unmoderated, the course adds user submissions immediately\r
- * @param      int     $course_id      course_id\r
- * @return     int                             moderation status for the course, ENABLED or DISABLED\r
- */\r
-function get_config_mode($course_id){\r
-  global $db;\r
-  $table=get_table_name(CONFIG);\r
-  $query="SELECT status FROM ".$table." WHERE course_id=".$course_id;\r
-  $result=mysql_query($query, $db);\r
-  $count=mysql_affected_rows();\r
\r
-  if ($count==1){      //should be one configuration for the course\r
-       $result=mysql_fetch_array($result);\r
-       return $result['status'];  \r
-  } else {     //configuration does not exist, so make one\r
-    $query="INSERT INTO ".$table." SET course_id=".$course_id.", status=".CONFIG_DISABLED.", date=NOW()";\r
-    mysql_query($query, $db);\r
-    return CONFIG_DISABLED;\r
-  }\r
-}\r
-\r
-\r
-/**\r
- * @desc       This function modifies the moderation status\r
- * @param      int     $course_id      course id\r
- * @param      int     $status         moderation status\r
- */\r
-function modify_config_mode($course_id, $status){\r
-  global $db;\r
-  $table=get_table_name(CONFIG);\r
-  $query="UPDATE ".$table." SET status=".$status." WHERE course_id=".$course_id;\r
-  mysql_query($query, $db);      \r
-}\r
-\r
-\r
-/*\r
- * @desc       This function returns the maximum file size for the course\r
- * @param      int     $course_id      course id\r
- * @return     int                     max_file_size\r
- */\r
-function get_max_file_size($course_id){\r
-       global $db;\r
-       $query="SELECT max_file_size FROM ".TABLE_PREFIX."courses WHERE course_id=".$course_id;\r
-       $result=mysql_query($query, $db);\r
-       $count=mysql_affected_rows();\r
-       if ($count==1){\r
-               $result=mysql_fetch_array($result);\r
-               if ($result['max_file_size']>0){\r
-                       return $result['max_file_size'];\r
-               } else {\r
-                       return NOT_SET;\r
-               }\r
-       } else {\r
-               return NOT_SET;\r
-       }\r
-}\r
-\r
-\r
-?>\r