public function onDeleteFolder($folderid) { # Permission $folderid = (int) $folderid; $user = GWF_Session::getUser(); if (false === ($folder = GWF_PMFolder::getByID($folderid)) || $folder->getVar('pmf_uid') !== $user->getID()) { return $this->module->error('err_folder_perm'); } # Delete PMs$result $count = 0; $pms = GDO::table('GWF_PM'); $uid = $user->getVar('user_id'); $fid = "{$folderid}"; $del = GWF_PM::OWNER_DELETED; if (false === ($result = $pms->update("pm_options=pm_options|{$del}", "pm_owner={$uid} AND pm_folder={$fid}"))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $count += $pms->affectedRows($result); // $del = GWF_PM::FROM_DELETED; // if (false === $pms->update("pm_options=pm_options|$del", "pm_from=$uid AND pm_from_folder=$fid")) { // return GWF_HTML::err('ERR_DATABASE', array( __FILE__, __LINE__)); // } // $count += $pms->affectedRows(); if ($folderid > 2) { # Delete Folder if (false === $folder->delete()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } # Done return $this->module->message('msg_folder_deleted', array($folder->display('pmf_name'), $count)); }
public function getFolder(GWF_User $user) { return GWF_PMFolder::getByID($this->getVar('pm_folder')); }
private function onMove($ids = NULL) { $ids = Common::getPost('pm'); if (!is_array($ids)) { return ''; } $user = GWF_Session::getUser(); if (false === ($folder = GWF_PMFolder::getByID(Common::getPost('folders')))) { return $this->module->error('err_folder'); } if ($folder->getVar('pmf_uid') !== $user->getID()) { return $this->module->error('err_folder'); } $count = 0; foreach ($ids as $id => $stub) { if (false === ($pm = GWF_PM::getByID($id))) { continue; } if (false === $pm->canRead($user)) { continue; } if (false === $pm->move($user, $folder)) { continue; } $count++; } $this->sanitize(); return $this->module->message('msg_moved', array($count)); }