Drush: commands/core/drupal/pm.inc Source File

  1. 7.x doxygen/html/pm_8inc_source.html
  2. master doxygen/html/pm_8inc_source.html
1 <?php
2 
3 /**
4  * Command callback. Disable one or more extensions.
5  */
6 function _drush_pm_disable($args) {
7  $extension_info = drush_get_extensions();
8 
9  // classify $args in themes, modules or unknown.
10  $modules = array();
11  $themes = array();
12  drush_pm_classify_extensions($args, $modules, $themes, $extension_info);
13  $extensions = array_merge($modules, $themes);
14  $unknown = array_diff($args, $extensions);
15 
16  // Discard and set an error for each unknown extension.
17  foreach ($unknown as $name) {
18  drush_log('DRUSH_PM_ENABLE_EXTENSION_NOT_FOUND', dt('!extension was not found and will not be disabled.', array('!extension' => $name)), 'warning');
19  }
20 
21  // Discard already disabled extensions.
22  foreach ($extensions as $name) {
23  if (!$extension_info[$name]->status) {
24  if ($extension_info[$name]->type == 'module') {
25  unset($modules[$name]);
26  }
27  else {
28  unset($themes[$name]);
29  }
30  drush_log(dt('!extension is already disabled.', array('!extension' => $name)), 'ok');
31  }
32  }
33 
34  // Discard default theme.
35  if (!empty($themes)) {
36  $default_theme = drush_theme_get_default();
37  if (in_array($default_theme, $themes)) {
38  unset($themes[$default_theme]);
39  drush_log(dt('!theme is the default theme and can\'t be disabled.', array('!theme' => $default_theme)), 'ok');
40  }
41  }
42 
43  if (!empty($modules)) {
44  // Add enabled dependents to the list of modules to disable.
45  $dependents = drush_module_dependents($modules, $extension_info);
46  $dependents = array_intersect($dependents, drush_module_list());
47  $modules = array_merge($modules, $dependents);
48 
49  // Discard required modules.
50  $required = drush_drupal_required_modules($extension_info);
51  foreach ($required as $module) {
52  if (isset($modules[$module])) {
53  unset($modules[$module]);
54  $info = $extension_info[$module]->info;
55  // No message for hidden modules.
56  if (!isset($info['hidden'])) {
57  $explanation = !empty($info['explanation']) ? ' ' . dt('Reason: !explanation', array('!explanation' => strip_tags($info['explanation']))) : '';
58  drush_log(dt('!module is a required module and can\'t be disabled.', array('!module' => $module)) . $explanation, 'ok');
59  }
60  }
61  }
62  }
63 
64  // Inform the user which extensions will finally be disabled.
65  $extensions = array_merge($modules, $themes);
66  if (empty($extensions)) {
67  return drush_log(dt('There were no extensions that could be disabled.'), 'ok');
68  }
69  else {
70  drush_print(dt('The following extensions will be disabled: !extensions', array('!extensions' => implode(', ', $extensions))));
71  if(!drush_confirm(dt('Do you really want to continue?'))) {
72  return drush_user_abort();
73  }
74  }
75 
76  // Disable themes.
77  if (!empty($themes)) {
78  drush_theme_disable($themes);
79  }
80 
81  // Disable modules and pass dependency validation in form submit.
82  if (!empty($modules)) {
83  drush_module_disable($modules);
84  }
85 
86  // Inform the user of final status.
87  $result_extensions = drush_get_named_extensions_list($extensions);
88  $problem_extensions = array();
89  foreach ($result_extensions as $extension) {
90  if (!$extension->status) {
91  drush_log(dt('!extension was disabled successfully.', array('!extension' => $extension->name)), 'ok');
92  }
93  else {
94  $problem_extensions[] = $extension->name;
95  }
96  }
97  if (!empty($problem_extensions)) {
98  return drush_set_error('DRUSH_PM_DISABLE_EXTENSION_ISSUE', dt('There was a problem disabling !extension.', array('!extension' => implode(',', $problem_extensions))));
99  }
100 }
101 
102 /**
103  * Command callback. Uninstall one or more modules.
104  * // TODO: Use drupal_execute on system_modules_uninstall_confirm_form so that input is validated.
105  */
106 function _drush_pm_uninstall($modules) {
107  drush_include_engine('drupal', 'environment');
108  $module_info = drush_get_modules();
109  $required = drush_drupal_required_modules($module_info);
110 
111  // Discards modules which are enabled, not found or already uninstalled.
112  foreach ($modules as $key => $module) {
113  if (!isset($module_info[$module])) {
114  // The module does not exist in the system.
115  unset($modules[$key]);
116  drush_log(dt('Module !module was not found and will not be uninstalled.', array('!module' => $module)), 'warning');
117  }
118  else if ($module_info[$module]->status) {
119  // The module is enabled.
120  unset($modules[$key]);
121  drush_log(dt('!module is not disabled. Use `pm-disable` command before `pm-uninstall`.', array('!module' => $module)), 'warning');
122  }
123  else if ($module_info[$module]->schema_version == -1) { // SCHEMA_UNINSTALLED
124  // The module is uninstalled.
125  unset($modules[$key]);
126  drush_log(dt('!module is already uninstalled.', array('!module' => $module)), 'ok');
127  }
128  else {
129  $dependents = array();
130  foreach (drush_module_dependents(array($module), $module_info) as $dependent) {
131  if (!in_array($dependent, $required) && ($module_info[$dependent]->schema_version != -1)) {
132  $dependents[] = $dependent;
133  }
134  }
135  if (count($dependents)) {
136  drush_log(dt('To uninstall !module, the following modules must be uninstalled first: !required', array('!module' => $module, '!required' => implode(', ', $dependents))), 'error');
137  unset($modules[$key]);
138  }
139  }
140  }
141 
142  // Inform the user which modules will finally be uninstalled.
143  if (empty($modules)) {
144  return drush_log(dt('There were no modules that could be uninstalled.'), 'ok');
145  }
146  else {
147  drush_print(dt('The following modules will be uninstalled: !modules', array('!modules' => implode(', ', $modules))));
148  if(!drush_confirm(dt('Do you really want to continue?'))) {
149  return drush_user_abort();
150  }
151  }
152 
153  // Disable the modules.
154  drush_module_uninstall($modules);
155 
156  // Inform the user of final status.
157  foreach ($modules as $module) {
158  drush_log(dt('!module was successfully uninstalled.', array('!module' => $module)), 'ok');
159  }
160 }
161 

File

doxygen/html/pm_8inc_source.html
View source
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Drush: commands/core/drupal/pm.inc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Drush
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_afac61274991793aa7e9133a8f4f291e.html">commands</a></li><li class="navelem"><a class="el" href="dir_5762b63965e3a68a35f77c23b4dd4668.html">core</a></li><li class="navelem"><a class="el" href="dir_124c2f0cfa86b0affb712ae9b365039b.html">drupal</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">pm.inc</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;?php</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Command callback. Disable one or more extensions.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="keyword">function</span> _drush_pm_disable($args) {</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;  $extension_info = <a class="code" href="includes_2environment_8inc.html#a2f6ea049bc3f5361815aafe6f44a535d">drush_get_extensions</a>();</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;  <span class="comment">// classify $args in themes, modules or unknown.</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;  $modules = array();</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;  $themes = array();</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;  <a class="code" href="group__extensions.html#ga703ad4f08aba6c5246dad9407119cc17">drush_pm_classify_extensions</a>($args, $modules, $themes, $extension_info);</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;  $extensions = array_merge($modules, $themes);</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;  $unknown = array_diff($args, $extensions);</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;  <span class="comment">// Discard and set an error for each unknown extension.</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;  <span class="keywordflow">foreach</span> ($unknown as $name) {</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;    <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<span class="stringliteral">&#39;DRUSH_PM_ENABLE_EXTENSION_NOT_FOUND&#39;</span>, <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!extension was not found and will not be disabled.&#39;</span>, array(<span class="stringliteral">&#39;!extension&#39;</span> =&gt; $name)), <span class="stringliteral">&#39;warning&#39;</span>);</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;  }</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;  <span class="comment">// Discard already disabled extensions.</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;  <span class="keywordflow">foreach</span> ($extensions as $name) {</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    <span class="keywordflow">if</span> (!$extension_info[$name]-&gt;status) {</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;      <span class="keywordflow">if</span> ($extension_info[$name]-&gt;type == <span class="stringliteral">&#39;module&#39;</span>) {</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        unset($modules[$name]);</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;      }</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;      <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        unset($themes[$name]);</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;      }</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;      <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!extension is already disabled.&#39;</span>, array(<span class="stringliteral">&#39;!extension&#39;</span> =&gt; $name)), <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;    }</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;  }</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <span class="comment">// Discard default theme.</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;  <span class="keywordflow">if</span> (!empty($themes)) {</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    $default_theme = <a class="code" href="includes_2environment_8inc.html#a57dd90a056796e9c5cd43b9c0ddb8f3e">drush_theme_get_default</a>();</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <span class="keywordflow">if</span> (in_array($default_theme, $themes)) {</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;      unset($themes[$default_theme]);</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;      <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!theme is the default theme and can\&#39;t be disabled.&#39;</span>, array(<span class="stringliteral">&#39;!theme&#39;</span> =&gt; $default_theme)), <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    }</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;  }</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  <span class="keywordflow">if</span> (!empty($modules)) {</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <span class="comment">// Add enabled dependents to the list of modules to disable.</span></div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    $dependents = <a class="code" href="commands_2core_2drupal_2environment_8inc.html#a0f1f3aec07dd810ba186e3875002e9a6">drush_module_dependents</a>($modules, $extension_info);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    $dependents = array_intersect($dependents, <a class="code" href="commands_2core_2drupal_2environment_8inc.html#aa53b2f8e66f3d43eb5d1dc16c1d97f94">drush_module_list</a>());</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    $modules = array_merge($modules, $dependents);</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    <span class="comment">// Discard required modules.</span></div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    $required = drush_drupal_required_modules($extension_info);</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="keywordflow">foreach</span> ($required as $module) {</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;      <span class="keywordflow">if</span> (isset($modules[$module])) {</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        unset($modules[$module]);</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        $info = $extension_info[$module]-&gt;info;</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        <span class="comment">// No message for hidden modules.</span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        <span class="keywordflow">if</span> (!isset($info[<span class="stringliteral">&#39;hidden&#39;</span>])) {</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;          $explanation = !empty($info[<span class="stringliteral">&#39;explanation&#39;</span>]) ? <span class="charliteral">&#39; &#39;</span> . <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Reason: !explanation&#39;</span>, array(<span class="stringliteral">&#39;!explanation&#39;</span> =&gt; strip_tags($info[<span class="stringliteral">&#39;explanation&#39;</span>])))  : <span class="stringliteral">&#39;&#39;</span>;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;          <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!module is a required module and can\&#39;t be disabled.&#39;</span>, array(<span class="stringliteral">&#39;!module&#39;</span> =&gt; $module)) . $explanation, <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;        }</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;      }</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    }</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  }</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  <span class="comment">// Inform the user which extensions will finally be disabled.</span></div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;  $extensions = array_merge($modules, $themes);</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  <span class="keywordflow">if</span> (empty($extensions)) {</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;There were no extensions that could be disabled.&#39;</span>), <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  }</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;The following extensions will be disabled: !extensions&#39;</span>, array(<span class="stringliteral">&#39;!extensions&#39;</span> =&gt; implode(<span class="stringliteral">&#39;, &#39;</span>, $extensions))));</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="group__userinput.html#gaa4169b83ff9dc4222af95d376b21268b">drush_confirm</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Do you really want to continue?&#39;</span>))) {</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="group__errorhandling.html#ga366aaafdf8c774a58653c64a65b6d91c">drush_user_abort</a>();</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    }</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;  }</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;  <span class="comment">// Disable themes.</span></div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  <span class="keywordflow">if</span> (!empty($themes)) {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <a class="code" href="commands_2core_2drupal_2environment_8inc.html#a877e6dae2dc5b4ddd718f5a1ddb74cbc">drush_theme_disable</a>($themes);</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  }</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;  <span class="comment">// Disable modules and pass dependency validation in form submit.</span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;  <span class="keywordflow">if</span> (!empty($modules)) {</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <a class="code" href="commands_2core_2drupal_2environment_8inc.html#adb63382201b7c62d39825a77015cf2fc">drush_module_disable</a>($modules);</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  }</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;  <span class="comment">// Inform the user of final status.</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;  $result_extensions = <a class="code" href="commands_2core_2drupal_2environment_8inc.html#af33699eee70ef577f27d66c33f9f8a88">drush_get_named_extensions_list</a>($extensions);</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;  $problem_extensions = array();</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  <span class="keywordflow">foreach</span> ($result_extensions as $extension) {</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keywordflow">if</span> (!$extension-&gt;status) {</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;      <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!extension was disabled successfully.&#39;</span>, array(<span class="stringliteral">&#39;!extension&#39;</span> =&gt; $extension-&gt;name)), <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    }</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;      $problem_extensions[] = $extension-&gt;name;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    }</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;  }</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;  <span class="keywordflow">if</span> (!empty($problem_extensions)) {</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__errorhandling.html#ga23fe9e1e8c1e5ade39256106044b6da4">drush_set_error</a>(<span class="stringliteral">&#39;DRUSH_PM_DISABLE_EXTENSION_ISSUE&#39;</span>, <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;There was a problem disabling !extension.&#39;</span>, array(<span class="stringliteral">&#39;!extension&#39;</span> =&gt; implode(<span class="charliteral">&#39;,&#39;</span>, $problem_extensions))));</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;  }</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;}</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;<span class="comment"> * Command callback. Uninstall one or more modules.</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;<span class="comment"> * // TODO: Use drupal_execute on system_modules_uninstall_confirm_form so that input is validated.</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="keyword">function</span> _drush_pm_uninstall($modules) {</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;  <a class="code" href="engines_8inc.html#a91df31f18b0a1d05540ccaf85e6d9a88">drush_include_engine</a>(<span class="stringliteral">&#39;drupal&#39;</span>, <span class="stringliteral">&#39;environment&#39;</span>);</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;  $module_info = <a class="code" href="commands_2core_2drupal_2environment_8inc.html#a7bab407b662383206abfd7d40e129e10">drush_get_modules</a>();</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;  $required = drush_drupal_required_modules($module_info);</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;  <span class="comment">// Discards modules which are enabled, not found or already uninstalled.</span></div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  <span class="keywordflow">foreach</span> ($modules as $key =&gt; $module) {</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">if</span> (!isset($module_info[$module])) {</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;      <span class="comment">// The module does not exist in the system.</span></div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;      unset($modules[$key]);</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;      <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Module !module was not found and will not be uninstalled.&#39;</span>, array(<span class="stringliteral">&#39;!module&#39;</span> =&gt; $module)), <span class="stringliteral">&#39;warning&#39;</span>);</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    }</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="keywordflow">else</span> <span class="keywordflow">if</span> ($module_info[$module]-&gt;status) {</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;      <span class="comment">// The module is enabled.</span></div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;      unset($modules[$key]);</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;      <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!module is not disabled. Use `pm-disable` command before `pm-uninstall`.&#39;</span>, array(<span class="stringliteral">&#39;!module&#39;</span> =&gt; $module)), <span class="stringliteral">&#39;warning&#39;</span>);</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    }</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="keywordflow">else</span> <span class="keywordflow">if</span> ($module_info[$module]-&gt;schema_version == -1) { <span class="comment">// SCHEMA_UNINSTALLED</span></div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;      <span class="comment">// The module is uninstalled.</span></div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;      unset($modules[$key]);</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;      <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!module is already uninstalled.&#39;</span>, array(<span class="stringliteral">&#39;!module&#39;</span> =&gt; $module)), <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    }</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;      $dependents = array();</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;      <span class="keywordflow">foreach</span> (<a class="code" href="commands_2core_2drupal_2environment_8inc.html#a0f1f3aec07dd810ba186e3875002e9a6">drush_module_dependents</a>(array($module), $module_info) as $dependent) {</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;        <span class="keywordflow">if</span> (!in_array($dependent, $required) &amp;&amp; ($module_info[$dependent]-&gt;schema_version != -1)) {</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;          $dependents[] = $dependent;</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;        }</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;      }</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;      <span class="keywordflow">if</span> (count($dependents)) {</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;        <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;To uninstall !module, the following modules must be uninstalled first: !required&#39;</span>, array(<span class="stringliteral">&#39;!module&#39;</span> =&gt; $module, <span class="stringliteral">&#39;!required&#39;</span> =&gt; implode(<span class="stringliteral">&#39;, &#39;</span>, $dependents))), <span class="stringliteral">&#39;error&#39;</span>);</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        unset($modules[$key]);</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;      }</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    }</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;  }</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;  <span class="comment">// Inform the user which modules will finally be uninstalled.</span></div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;  <span class="keywordflow">if</span> (empty($modules)) {</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;There were no modules that could be uninstalled.&#39;</span>), <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;  }</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;The following modules will be uninstalled: !modules&#39;</span>, array(<span class="stringliteral">&#39;!modules&#39;</span> =&gt; implode(<span class="stringliteral">&#39;, &#39;</span>, $modules))));</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="group__userinput.html#gaa4169b83ff9dc4222af95d376b21268b">drush_confirm</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Do you really want to continue?&#39;</span>))) {</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="group__errorhandling.html#ga366aaafdf8c774a58653c64a65b6d91c">drush_user_abort</a>();</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    }</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;  }</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;  <span class="comment">// Disable the modules.</span></div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;  <a class="code" href="commands_2core_2drupal_2environment_8inc.html#a7d1f0d019005c0d633c8179e9be163cb">drush_module_uninstall</a>($modules);</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;  <span class="comment">// Inform the user of final status.</span></div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;  <span class="keywordflow">foreach</span> ($modules as $module) {</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    <a class="code" href="group__logging.html#gad820f489a93518301794ada4ff7816b6">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;!module was successfully uninstalled.&#39;</span>, array(<span class="stringliteral">&#39;!module&#39;</span> =&gt; $module)), <span class="stringliteral">&#39;ok&#39;</span>);</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;  }</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;}</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;</div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Oct 8 2014 09:04:53 for Drush by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.2
</small></address>
</body>
</html>