Jump to content

Recommended Posts

Posted

Hi All is there a way to delete screenshots? I have tried to delete them from the Root directory but opnlt end up with a blank space in place of the Pic.

Can some one help??

  • Moderators
Posted

Give me a few, I'll create a delete function to simpilot's screenshot center. I'll be posting it in the code spinets.

  • Moderators
Posted

Ok, I'm stuck now, lol. I'm missing something and I can't get it out of my head, lol.

Screenshot.php In the beginning of the php file

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

Screenshot.php

 public function delete_screenshot() 
 {

        ScreenshotsData::delete_screenshot($id);

        }


ScreenshotData.class.php

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

       DB::query($query);
   }

screenshot_large.tpl

<a href="<?php echo SITE_URL ?>/index.php/Screenshots/delete_screenshot?id='"><b>Delete Screenshot</b></a>

When I click on the delete button, it goes to that url...

/index.php/Screenshots/delete_screenshot?id='

If anyone can help out here, and tell me what I did wrong. Still a noob.

Posted

Hey Vansers!

You have some errors here :( In ScreenshotData.class.php use this function:

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

       DB::query($query);
   }

The change is to

id='$_GET[id]'

Now instead of

<a href="<?php echo SITE_URL ?>/index.php/Screenshots/delete_screenshot?id='"><b>Delete Screenshot</b></a>

Use this:

<a href="<?php echo SITE_URL ?>/index.php/Screenshots/delete_screenshot?id=<?php echo $screenshot->id; ?>"><b>Delete Screenshot</b></a>

Actually you miss the call for the photo's ID which is:

<?php echo $screenshot->id; ?>

I also suggest you to use this:

                    <?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 {} ?>

With the above only the Admins have the rights to delete a photo ;)

Regards,

  • Like 1
  • Moderators
Posted

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!

I DO NOT TAKE ANY CREIDT FROM simpilot's Screenshot Moudle!

  • 1 month later...
  • 4 weeks later...
Posted

Hi,

I used this code and i cant get it working my screenshot center is all working but i can see the delete button ?

any help would be great

Nathan

Hi Nathan

Sorry for bumping such an old topic (again) but was just wondering if you got this to work at all yet?

I can see a delete button, you have to click full size on the picture.

But not sure if anyone knows, when I click that all that happens is I get sent to a page with an error on it :blink:

Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Screenshots::delete_screenshot' was given in /home/chitchat/public_html/palmair/core/classes/MainController.class.php on line 218

This SHOULD be line 218 if I counted correctly:

		$ret = call_user_func_array(array($$ModuleName, $call_function), CodonRewrite::$params);

Anyone have any ideas :S

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...