Example #1
0
  Plugin Barcode is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with Plugin Barcode. If not, see <http://www.gnu.org/licenses/>.

  ------------------------------------------------------------------------

  @package   Plugin Barcode
  @author    David Durieux
  @co-author
  @copyright Copyright (c) 2009-2013 Barcode plugin Development team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/barscode
  @since     2009

  ------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("profile", "r");
// Mainly usefull if not actived
Plugin::load('barcode', true);
$prof = new PluginBarcodeProfile();
if (isset($_POST["update_user_profile"])) {
    Session::checkRight("profile", "w");
    $prof->update($_POST);
    Html::back();
}
Example #2
0
function plugin_barcode_MassiveActionsProcess($data)
{
    global $CFG_GLPI;
    switch ($data['action']) {
        case 'plugin_barcode_barcode':
        case 'plugin_barcode_qrcode':
            $pbConfig = new PluginBarcodeConfig();
            $pbQRcode = new PluginBarcodeQRcode();
            $itemtype = $data['itemtype'];
            $item = new $itemtype();
            $rand = mt_rand();
            $number = 0;
            $codes = array();
            if ($data['eliminate'] > 0) {
                for ($nb = 0; $nb < $data['eliminate']; $nb++) {
                    $codes[] = '';
                }
            }
            if ($data['type'] == 'QRcode') {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        $filename = $pbQRcode->generateQRcode($itemtype, $key, $rand, $number, $data);
                        if ($filename) {
                            $codes[] = $filename;
                            $number++;
                        }
                    }
                }
            } else {
                foreach ($data['item'] as $key => $val) {
                    if ($val == 1) {
                        $item->getFromDB($key);
                        if ($item->isField('otherserial')) {
                            $codes[] = $item->getField('otherserial');
                        }
                    }
                }
            }
            if (count($codes) > 0) {
                $params['codes'] = $codes;
                $params['type'] = $data['type'];
                $params['size'] = $data['size'];
                $params['border'] = $data['border'];
                $params['orientation'] = $data['orientation'];
                $barcode = new PluginBarcodeBarcode();
                $file = $barcode->printPDF($params);
                $filePath = explode('/', $file);
                $filename = $filePath[count($filePath) - 1];
                $msg = "<a href='" . $CFG_GLPI['root_doc'] . '/plugins/barcode/front/send.php?file=' . urlencode($filename) . "'>" . __('Generated file', 'barcode') . "</a>";
                Session::addMessageAfterRedirect($msg);
                $pbQRcode->cleanQRcodefiles($rand, $number);
            }
            return true;
            break;
        case "plugin_barcode_allow":
            $profglpi = new Profile();
            $prof = new PluginBarcodeProfile();
            foreach ($data['item'] as $key => $val) {
                if ($profglpi->getFromDB($key) && $profglpi->fields['interface'] != 'helpdesk') {
                    if ($prof->getFromDB($key)) {
                        $prof->update(array('id' => $key, 'generate' => $data['generate'], 'config' => $data['config']));
                    } else {
                        if ($data['generate']) {
                            $prof->add(array('id' => $key, 'generate' => $data['generate']));
                        } else {
                            if ($data['config']) {
                                $prof->add(array('id' => $key, 'config' => $data['config']));
                            }
                        }
                    }
                }
            }
            break;
    }
}