/**
  * Checks if a user has the right to edit a medium, or if he/ she already
  * edited the medium before.
  *
  * @param int $id
  * @param string $which
  * @param string $filename
  * @return boolean
  * @access public
  */
 function isEdited($id, $which, $filename = '')
 {
     $db =& zmgDatabase::getDBO();
     $table = zmgFactory::getConfig()->getTableName('editmon');
     $today = time() + intval(zmgEnv::getSessionLifetime());
     $sid = md5(zmgEnv::getSessionToken());
     switch ($which) {
         case 'comment':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND comment_time > '{$now}' AND " . "object_id = " . zmgSQLEscape($id));
             break;
         case 'vote':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND vote_time > '{$now}' AND " . "object_id = " . zmgSQLEscape($id));
             break;
         case 'pass':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND pass_time > '{$now}' AND " . "object_id = " . zmgSQLEscape($id));
             break;
         case 'lightbox':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND lightbox_time > '{$now}' AND " . "lightbox_file = '" . zmgSQLEscape($filename) . "'");
             break;
     }
     $result = $db->query();
     if (mysql_num_rows($result) > 0) {
         return true;
     } else {
         return false;
     }
 }