root/modules/branches/2.4/featurecodeadmin/functions.inc.php

Revision 5262, 1.7 kB (checked in by p_lindheimer, 5 years ago)

- added featurecodeadmin_check_extensions() to supply feature codes to extension registry
- added checks for conflicts which are displayed in the featurecode panel after submitted
- added highlighting of conflicts with extenernal extnesions and between other feature codes

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php
2
3 function featurecodeadmin_update($req) {
4   foreach ($req as $key => $item) {
5     // Split up...
6     // 0 - action
7     // 1 - modulename
8     // 2 - featurename
9     $arr = explode("#", $key);
10     if (count($arr) == 3) {
11       $action = $arr[0];
12       $modulename = $arr[1];
13       $featurename = $arr[2];
14       $fieldvalue = $item;
15       
16       // Is there a more efficient way of doing this?
17       switch ($action)
18       {
19         case "ena":
20           $fcc = new featurecode($modulename, $featurename);
21           if ($fieldvalue == 1) {
22             $fcc->setEnabled(true);
23           } else {
24             $fcc->setEnabled(false);
25           }
26           $fcc->update();
27           break;
28         case "custom":
29           $fcc = new featurecode($modulename, $featurename);
30           if ($fieldvalue == $fcc->getDefault()) {
31             $fcc->setCode(''); // using default
32           } else {
33             $fcc->setCode($fieldvalue);
34           }
35           $fcc->update();
36           break;
37       }
38     }
39   }
40
41   needreload();
42 }
43
44 function featurecodeadmin_check_extensions($exten=true) {
45   $extenlist = array();
46   if (is_array($exten) && empty($exten)) {
47     return $extenlist;
48   }
49   $featurecodes = featurecodes_getAllFeaturesDetailed();
50
51   foreach ($featurecodes as $result) {
52     $thisexten = ($result['customcode'] != '')?$result['customcode']:$result['defaultcode'];
53
54     // Ignore disabled codes, and modules, and any exten not being requested unless all (true)
55     //
56     if (($result['featureenabled'] == 1) && ($result['moduleenabled'] == 1) && ($exten === true || in_array($thisexten, $exten))) {
57       $extenlist[$thisexten]['description'] = _("Featurecode: ").$result['featurename']." (".$result['modulename'].":".$result['featuredescription'].")";
58       $extenlist[$thisexten]['status'] = 'INUSE';
59       $extenlist[$thisexten]['edit_url'] = 'config.php?type=setup&display=featurecodeadmin';
60     }
61   }
62   return $extenlist;
63 }
64 ?>
Note: See TracBrowser for help on using the browser.