Jump to content

simpilot's Screenshot Module - Delete Function


Kyle

Recommended Posts

  • Moderators

I DO NOT TAKE ANY CREDIT FROM SIMPILOT'S SCREENSHOT MODULE!

This is a new function to delete the screenshot.

Ok, here's how to add the delete function to simpilot's screenshot.

1) Back up your files!!!

2) Go to core/modules/screenshots/screenshots.php and go to the following line....

       if($this->post->action == 'reject_screenshot') {
           $this->reject_screenshot();
       }
       }

And Replace with this...

       if($this->post->action == 'reject_screenshot') {
           $this->reject_screenshot();
       }
	if($this->post->action == 'delete_screenshot') {
       $this->delete_screenshot();
       }
       }

3) Go to the following lines....

  protected function reject_screenshot() {
       $id = DB::escape($this->post->id);
       ScreenshotsData::reject_screenshot($id);
       header('Location: '.url('/Screenshots/approval_list'));
   }

Add After the code......

public function delete_screenshot() 
 {
	ScreenshotsData::delete_screenshot($id);		//We need the screenshot id so the function can know which id to delete from the DB
       header('Location: '.url('/Screenshots/')); 		//We don't want to show the URL delete link, so it will go to Screenshots

	$this->set('message', 'Screenshot Deleted!'); 	//Let them know that the screeshot is deleted.
       $this->render('core_success.tpl');				//It will show the green bar on top of the page

    }

4) Go to core/common/ScreenshotsData.class.php and go to the following lines...

   public function reject_screenshot($id) {
       $upd = "UPDATE screenshots SET file_approved='2' WHERE id='$id'";

       DB::query($upd);
   }

Add After the line.............

       public function delete_screenshot($id) {
               $query = "DELETE FROM screenshots
                   WHERE id='$_GET[id]'";

       DB::query($query);
   }

5) Go to screenshots_large.tpl and go to the following lines......

           <td align="center"><b>Views:</b> <?php echo $screenshot->views; ?></td>
           <td>
               <!-- <form><input class="mail" type="button" value="Back To Gallery" onClick="history.go(-1);return true;"> </form> -->

Then add after the lines....

    <?php if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
                       { ?><a href="<?php echo SITE_URL ?>/index.php/Screenshots/delete_screenshot?id=<?php echo $screenshot->id; ?>"><b>Delete Screenshot</b></a><?php } else {} ?>

THEN! TA-DA. You now have a delete function!

Big Thanks to dimitris for helping out to fix the errors!

Link to comment
Share on other sites

Hi all! I took the code a step further to give pilots the ability to delete their own photos :)

At screenshots_large.tpl add the following lines, to allow a pilot to delete his own screenshot.

        	<?php if((PilotData::GetPilotData(Auth::$userinfo->pilotid))==$pilot)
                   	{ ?>        	
                   	<input onclick="location.href='<?php echo SITE_URL ?>/index.php/Screenshots/delete_screenshot?id=<?php echo $screenshot->id; ?>'" type="button" value="Delete Screenshot" />
<?php } else { } ?>

Make sure you have this line at the file. (Standard by simpilot, but who knows ;) )

$pilot = PilotData::getPilotData($screenshot->pilot_id);

Between the last 2 { } you can echo a message like:

<?php } else { echo "You have no rights to delete this screenshot!";  } ?>

Regards,

  • Like 1
Link to comment
Share on other sites

  • 8 months later...
  • 2 weeks later...
  • Administrators

He has this up on github now.

The best way is to fork his repository for this; this creates a copy of it under your account. Then you clone it to your computer, make the changes, commit and push. Then those changes are in your repository.

After that, you can do a pull request, and Dave can look through the commit and see if it's acceptable, and then the changes will merge into his master copy.

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

That was brought up once before in the Obsess Blue thread. Basically, you just find

<img src="<?php echo SITE_URL; ?>/pics/<?php echo $screenshot->file_name; ?>" style="max-width: 940px" alt="<?php echo $screenshot->file_description; ?>" />

Change the 940 until you get the size that you want it to be. And this is in the screenshot_large.tpl file.

Also, you are going to want to get in to your screenshot_viewer.tpl file and find

if ($tiles == '4') { echo '</tr>'; $tiles=0; }
}

Change the 4 to a 3 and that will take the fourth pic from the right and make it a 3 pic row instead of 4. Then it will all fit nicely on your page. (this is your main gallery index page when you first click to go to the gallery)

Also, if you have not done so yet, I recommend fixing the pagination at the bottom of the gallery so it does not list your pages like

1

2

3

Next

If you apply the code change, it will show the pagination as 1 2 3 next

http://forum.phpvms.net/index.php?app=core&module=search&do=search&fromMainBar=1

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...