function supprimerutilisateurAction() { $this->view->title = "Suppression d'un utilisateur"; $utilisateuradmin = new Utilisateur(); $utilisateur = new Utilisateur(); $avatar = new Avatar(); $objet = new LigneInventaire(); $compavatar = new AvatarCompetence(); $id = $this->_request->getParam('id'); $utilisateur = $utilisateur->findById($id); // L'admin ne peut pas supprimer son propre compte ! if ($utilisateuradmin->isAdmin($id)) { $this->_redirect('admin/utilisateur'); return; } if ($this->_request->isPost()) { $del = $this->_request->getPost('del'); if ($del == 'Oui' && $id > 0) { // Recuperation de tous les avatars de l'utilisateur $avatars = $avatar->findByUser($id); foreach ($avatars as $avatar) { // Recuperation des competences de chaque avatar $compavatars = $compavatar->findByIdAvatar($avatar->id_avatar); foreach ($compavatars as $compavatar) { $compavatar->delete('id_competence = ' . $compavatar->id_competence); } // Suppression des competences $compavatar = new AvatarCompetence(); // Recuperation des objets de chaque avatar $objets = $objet->findByIdAvatar($avatar->id_avatar); foreach ($objets as $objet) { $objet->delete('id_objet = ' . $objet->id_objet); } // Suppression des objets $objet = new LigneInventaire(); $avatar->delete('id_avatar = ' . $avatar->id_avatar); //Suppression de l'avatar } $utilisateur = new Utilisateur(); // Recuperation de tous les avatars du joueur $where = "id_utilisateur = " . $id; $utilisateur->delete($where); } $this->_redirect('admin/utilisateur'); return; } $this->view->utilisateur = $utilisateur; }
public static function getUploaded(Profile $target) { $avatar = new Avatar(); $avatar->profile_id = $target->id; $avatar->original = true; if (!$avatar->find(true)) { throw new NoAvatarException($target, $avatar); } if (!file_exists(Avatar::path($avatar->filename))) { // The delete call may be odd for, say, unmounted filesystems // that cause a file to currently not exist, but actually it does... $avatar->delete(); throw new NoAvatarException($target, $avatar); } return $avatar; }
/** * Delete attached avatars for this user from the database and filesystem. * This should be used instead of a batch delete() to ensure that files * get removed correctly. * * @param boolean $original true to delete only the original-size file * @return <type> */ function delete_avatars($original = true) { $avatar = new Avatar(); $avatar->profile_id = $this->id; $avatar->find(); while ($avatar->fetch()) { if ($avatar->original) { if ($original == false) { continue; } } $avatar->delete(); } return true; }
function supprimeravatarAction() { $this->view->title = "Suppression de l'avatar"; $avatar = new Avatar(); if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_Alpha'); $filter = new Zend_Filter_Alpha(); $id = (int) $this->_request->getPost('id'); $del = $filter->filter($this->_request->getPost('del')); if ($del == 'Oui' && $id > 0) { $where = $avatar->getAdapter()->quoteInto('id_avatar =?', $id); $rows_affected = $avatar->delete($where); $fichier = $_SERVER['DOCUMENT_ROOT'] . '/Magic_TA/public/images/avatar/' . $id . ".png"; unlink($fichier); } $this->_redirect('avatar/avatar'); } else { $id = (int) $this->_request->getParam('id'); $this->user = Zend_Auth::getInstance()->getIdentity(); if (avatarViolation($id, $this->user->id_utilisateur)) { $this->_redirect('avatar/avatar'); return; } if ($id > 0) { $this->view->avatar = $avatar->fetchRow('id_avatar=' . $id); if ($this->view->avatar->id_avatar > 0) { return; } else { $this->_redirect('avatar/avatar'); } } } }