Exemplo n.º 1
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Profile();
         $model->model_uset_id = $this->user->user_id;
         if ($model->findByPk($id)) {
             $model->delete($id);
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('profile_not_deleted'));
         } else {
             $countE = AF::get($_POST, 'countE', 100000);
             if (count($modelsID) >= $countE) {
                 $link = AF::link(array('profiles' => 'view'));
                 Message::echoJsonRedirect($link);
             } else {
                 Message::echoJsonSuccess(__('profile_deleted'));
             }
         }
     }
     $this->redirect();
 }
Exemplo n.º 2
0
 */
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'y';
$longoptions = array('yes');
$helptext = <<<END_OF_HELP
clean_profiles.php [options]
Deletes all profile table entries where the profile does not occur in the
notice table, is not a group and is not a local user. Very MySQL specific I think.

WARNING: This has not been tested thoroughly. Maybe we've missed a table to compare somewhere.

  -y --yes      do not wait for confirmation

END_OF_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (!have_option('y', 'yes')) {
    print "About to delete profiles that we think are useless to save. Are you sure? [y/N] ";
    $response = fgets(STDIN);
    if (strtolower(trim($response)) != 'y') {
        print "Aborting.\n";
        exit(0);
    }
}
print "Deleting";
$profile = new Profile();
$profile->query('SELECT * FROM profile WHERE ' . 'NOT (SELECT COUNT(*) FROM notice WHERE profile_id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM user WHERE user.id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM user_group WHERE user_group.profile_id=profile.id) ' . 'AND NOT (SELECT COUNT(*) FROM subscription WHERE subscriber=profile.id OR subscribed=profile.id) ');
while ($profile->fetch()) {
    echo ' ' . $profile->getID() . ':' . $profile->getNickname();
    $profile->delete();
}
print "\nDONE.\n";
Exemplo n.º 3
0
<?php

/**
 * Created by PhpStorm.
 * User: OldManVin
 * Date: 1/22/2016
 * Time: 12:01 PM
 */
require_once "/etc/apache2/capstone-mysql/encrypted -config.php";
$pdo = connectToEncryptedMySQL("/ect/apache2/data-design/dfontaine1/ini");
require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "your-class-file.php";
//now use the PDO object normally
$tweet = new Profile(null, 1, "this is from php");
$tweet->insert($pdo);
$tweet->setProfile("now i change the message");
$tweet->update($pdo);
$tweet->delete($pdo);
Exemplo n.º 4
0
 /**
  * test creating a Profile and then deleting it
  **/
 public function testDeleteValidProfile()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("profile");
     // create a new Profile and insert to into mySQL
     $profile = new Profile(null, $this->VALID_ATHANDLE, $this->VALID_EMAIL, $this->VALID_PHONE);
     $profile->insert($this->getPDO());
     // delete the Profile from mySQL
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("profile"));
     $profile->delete($this->getPDO());
     // grab the data from mySQL and enforce the Profile does not exist
     $pdoProfile = Profile::getProfileByProfileId($this->getPDO(), $profile->getProfileId());
     $this->assertNull($pdoProfile);
     $this->assertSame($numRows, $this->getConnection()->getRowCount("profile"));
 }
Exemplo n.º 5
0
<?php

require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "profile.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/vhooker.ini");
$profile = new Profile(null, 1, "this is from PHP");
$profile->insert($pdo);
$profile->setProfile("now I changed the message");
$profile->update($pdo);
$profile->delete($pdo);
Exemplo n.º 6
0
*/
include '../inc/includes.php';
Session::checkRight("profile", READ);
if (!isset($_GET['id'])) {
    $_GET['id'] = "";
}
$prof = new Profile();
if (isset($_POST["add"])) {
    $prof->check(-1, CREATE, $_POST);
    $ID = $prof->add($_POST);
    // We need to redirect to form to enter rights
    Html::redirect($CFG_GLPI["root_doc"] . "/front/profile.form.php?id={$ID}");
} else {
    if (isset($_POST["purge"])) {
        $prof->check($_POST['id'], PURGE);
        if ($prof->delete($_POST, 1)) {
            $prof->redirectToList();
        } else {
            Html::back();
        }
    } else {
        if (isset($_POST["update"]) || isset($_POST["interface"])) {
            $prof->check($_POST['id'], UPDATE);
            $prof->update($_POST);
            Html::back();
        }
    }
}
Html::header(Profile::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "profile");
$prof->display(array('id' => $_GET["id"]));
Html::footer();
Exemplo n.º 7
0
*/
include '../inc/includes.php';
Session::checkRight("profile", "r");
if (!isset($_GET['id'])) {
    $_GET['id'] = "";
}
$prof = new Profile();
if (isset($_POST["add"])) {
    $prof->check(-1, 'w', $_POST);
    $ID = $prof->add($_POST);
    // We need to redirect to form to enter rights
    Html::redirect($CFG_GLPI["root_doc"] . "/front/profile.form.php?id={$ID}");
} else {
    if (isset($_POST["delete"])) {
        $prof->check($_POST['id'], 'd');
        if ($prof->delete($_POST)) {
            $prof->redirectToList();
        } else {
            Html::back();
        }
    } else {
        if (isset($_POST["update"]) || isset($_POST["interface"])) {
            $prof->check($_POST['id'], 'w');
            $prof->update($_POST);
            Html::back();
        }
    }
}
Html::header(Profile::getTypeName(2), $_SERVER['PHP_SELF'], "admin", "profile");
$prof->showForm($_GET["id"]);
Html::footer();
Exemplo n.º 8
0
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
checkRight("profile", "r");
if (!isset($_GET['id'])) {
    $_GET['id'] = "";
}
$prof = new Profile();
if (isset($_POST["add"])) {
    $prof->check(-1, 'w', $_POST);
    $ID = $prof->add($_POST);
    // We need to redirect to form to enter rights
    glpi_header($CFG_GLPI["root_doc"] . "/front/profile.form.php?id={$ID}");
} else {
    if (isset($_POST["delete"])) {
        $prof->check($_POST['id'], 'w');
        $prof->delete($_POST);
        $prof->redirectToList();
    } else {
        if (isset($_POST["update"]) || isset($_POST["interface"])) {
            $prof->check($_POST['id'], 'w');
            $prof->update($_POST);
            glpi_header($_SERVER['HTTP_REFERER']);
        }
    }
}
commonHeader($LANG['Menu'][35], $_SERVER['PHP_SELF'], "admin", "profile");
$prof->showForm($_GET["id"]);
commonFooter();