27 error_reporting(E_ALL);
28 if ((php_sapi_name() !=
'cli')) trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
30 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
31 if (empty($SYSTEM_ROOT)) {
32 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
36 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
37 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
41 $DELETING_ASSET_TYPE = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'';
42 if (empty($DELETING_ASSET_TYPE)) {
43 echo
"ERROR: You need to supply an asset type code as the second argument\n";
47 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
48 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
52 echo
'Enter the root password for "'.SQ_CONF_SYSTEM_NAME.
'": ';
54 $root_password = rtrim(fgets(STDIN, 4094));
58 $root_user = &$GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
59 if (!$root_user->comparePassword($root_password)) {
60 echo
"ERROR: The root password entered was incorrect\n";
65 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
66 echo
"ERROR: Failed login in as root user\n";
71 $db = $GLOBALS[
'SQ_SYSTEM']->db;
73 $sql =
'SELECT assetid FROM sq_ast WHERE type_code = :type_code';
78 foreach($assets_of_type as $index => $val) {
82 if (!empty($assets_of_type)) {
83 $asset_ids_set =
'('.implode(
', ', $assets_of_type).
')';
84 $sql =
'DELETE FROM sq_ast_attr_val WHERE assetid in '.$asset_ids_set;
88 $sql =
'DELETE FROM sq_ast_lnk WHERE minorid in '.$asset_ids_set;
92 $sql =
'DELETE FROM sq_ast WHERE type_code = :type_code';
98 $sql =
'DELETE FROM sq_ast_attr WHERE type_code = :type_code OR owning_type_code = :owning_type_code';
104 $sql =
'DELETE FROM sq_ast_typ WHERE type_code = :type_code';
109 $sql =
'DELETE FROM sq_ast_typ_inhd WHERE type_code = :type_code';
114 assert_true(unlink(dirname(dirname(__FILE__)).
'/data/private/db/asset_types.inc'),
'failed removing asset_types.inc');