Esempio n. 1
0
 /**
  * AdminController::renderForm() override
  * @see AdminController::renderForm()
  */
 public function renderForm()
 {
     $current_profile = (int) $this->getCurrentProfileId();
     $profiles = Profile::getProfiles($this->context->language->id);
     $tabs = Tab::getTabs($this->context->language->id);
     $accesses = array();
     foreach ($profiles as $profile) {
         $accesses[$profile['id_profile']] = Profile::getProfileAccesses($profile['id_profile']);
     }
     // Deleted id_tab that do not have access
     foreach ($tabs as $key => $tab) {
         // Don't allow permissions for unnamed tabs (ie. AdminLogin)
         if (empty($tab['name'])) {
             unset($tabs[$key]);
         }
         foreach ($this->accesses_black_list as $id_tab) {
             if ($tab['id_tab'] == (int) $id_tab) {
                 unset($tabs[$key]);
             }
         }
     }
     $modules = array();
     foreach ($profiles as $profile) {
         $modules[$profile['id_profile']] = Module::getModulesAccessesByIdProfile($profile['id_profile']);
         uasort($modules[$profile['id_profile']], array($this, 'sortModuleByName'));
     }
     $this->fields_form = array('');
     $this->tpl_form_vars = array('profiles' => $profiles, 'accesses' => $accesses, 'id_tab_parentmodule' => (int) Tab::getIdFromClassName('AdminParentModules'), 'id_tab_module' => (int) Tab::getIdFromClassName('AdminModules'), 'tabs' => $this->displayTabs($tabs), 'current_profile' => (int) $current_profile, 'admin_profile' => (int) _PS_ADMIN_PROFILE_, 'access_edit' => $this->access('edit'), 'perms' => array('view', 'add', 'edit', 'delete'), 'modules' => $modules, 'link' => $this->context->link);
     return parent::renderForm();
 }
Esempio n. 2
0
    public function displayForm($isMainTab = true)
    {
        global $cookie, $currentIndex;
        parent::displayForm();
        $currentProfile = (int) $this->getCurrentProfileId();
        $tabs = Tab::getTabs($cookie->id_lang);
        $profiles = Profile::getProfiles((int) $cookie->id_lang);
        $accesses = Profile::getProfileAccesses((int) $currentProfile);
        echo '
		<script type="text/javascript">
			setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Update in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\'));
		</script>
		<div id="ajax_confirmation"></div>
		<table class="table" cellspacing="0">
			<tr>
				<th ' . ($currentProfile == (int) _PS_ADMIN_PROFILE_ ? 'colspan="6"' : '') . '>
					<select name="profile" onchange="redirect(\'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">';
        if ($profiles) {
            foreach ($profiles as $profile) {
                echo '<option value="' . (int) $profile['id_profile'] . '" ' . ((int) $profile['id_profile'] == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>';
            }
        }
        $tabsize = sizeof($tabs);
        foreach ($tabs as $tab) {
            if ($tab['id_tab'] > $tabsize) {
                $tabsize = $tab['id_tab'];
            }
        }
        echo '
					</select>
				</th>';
        if ($currentProfile != (int) _PS_ADMIN_PROFILE_) {
            echo '
				<th class="center">' . $this->l('View') . '<br /><input type="checkbox" name="1" id="viewall" onclick="ajax_power(this, \'view\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('Add') . '<br /><input type="checkbox" name="1" id="addall" onclick="ajax_power(this, \'add\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('Edit') . '<br /><input type="checkbox" name="1" id="editall" onclick="ajax_power(this, \'edit\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('Delete') . '<br /><input type="checkbox" name="1" id="deleteall" onclick="ajax_power(this, \'delete\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('All') . '<br /><input type="checkbox" name="1" id="allall" onclick="ajax_power(this, \'all\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
			</tr>';
        }
        if (!sizeof($tabs)) {
            echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>';
        } elseif ($currentProfile == (int) _PS_ADMIN_PROFILE_) {
            echo '<tr><td colspan="5">' . $this->l('Administrator permissions cannot be modified.') . '</td></tr>';
        } else {
            foreach ($tabs as $tab) {
                if (!$tab['id_parent'] or (int) $tab['id_parent'] == -1) {
                    $this->printTabAccess((int) $currentProfile, $tab, $accesses[$tab['id_tab']], false, $tabsize, sizeof($tabs));
                    foreach ($tabs as $child) {
                        if ($child['id_parent'] === $tab['id_tab']) {
                            if (isset($accesses[$child['id_tab']])) {
                                $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true, $tabsize, sizeof($tabs));
                            }
                        }
                    }
                }
            }
        }
        echo '</table>';
    }
Esempio n. 3
0
    public function displayForm($isMainTab = true)
    {
        global $cookie, $currentIndex;
        parent::displayForm();
        $currentProfile = (int) Tools::getValue('id_profile');
        if (!$currentProfile) {
            $currentProfile = 1;
        }
        $tabs = Tab::getTabs((int) $cookie->id_lang);
        $profiles = Profile::getProfiles((int) $cookie->id_lang);
        $permissions = Profile::getProfileAccesses((int) $currentProfile);
        echo '
		<form action="' . $currentIndex . '&submitAddPermissions=1&token=' . $this->token . '" id="form_permissions" method="post">
			<input type="hidden" name="id_profile" value="' . (int) $currentProfile . '" />
			<table class="table" cellspacing="0">
				<tr>
					<th ' . ($currentProfile == (int) _PS_ADMIN_PROFILE_ ? 'colspan="6"' : '') . '>' . $this->l('Profile') . '&nbsp;
						<select name="id_profile" onchange="window.location = \'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&id_profile=\'+this.options[this.selectedIndex].value;">';
        if ($profiles) {
            foreach ($profiles as $profile) {
                echo '<option value="' . (int) $profile['id_profile'] . '" ' . ((int) $profile['id_profile'] == $currentProfile ? 'selected="selected"' : '') . '>' . Tools::safeOutput($profile['name']) . '</option>';
            }
        }
        echo '
					</select>
				</th>';
        if ($currentProfile != (int) _PS_ADMIN_PROFILE_) {
            echo '
				<th class="center">' . $this->l('View') . '<br /><input type="checkbox" name="1" id="viewall" /></th>
				<th class="center">' . $this->l('Add') . '<br /><input type="checkbox" name="1" id="addall" /></th>
				<th class="center">' . $this->l('Edit') . '<br /><input type="checkbox" name="1" id="editall" /></th>
				<th class="center">' . $this->l('Delete') . '<br /><input type="checkbox" name="1" id="deleteall" /></th>
				<th class="center">' . $this->l('All') . '<br /><input type="checkbox" name="1" id="allall" /></th>
			</tr>';
        }
        if (!count($tabs)) {
            echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>';
        } elseif ($currentProfile == (int) _PS_ADMIN_PROFILE_) {
            echo '<tr><td colspan="5">' . $this->l('Administrator permissions cannot be modified.') . '</td></tr>';
        } else {
            foreach ($tabs as $tab) {
                if (!$tab['id_parent'] || (int) $tab['id_parent'] == -1) {
                    echo $this->printTabAccess((int) $currentProfile, $tab, isset($permissions[(int) $tab['id_tab']]) ? $permissions[(int) $tab['id_tab']] : 0, false);
                    foreach ($tabs as $child) {
                        if ($child['id_parent'] === $tab['id_tab']) {
                            echo $this->printTabAccess($currentProfile, $child, isset($permissions[(int) $child['id_tab']]) ? $permissions[(int) $child['id_tab']] : 0, true);
                        }
                    }
                }
            }
        }
        echo '</table>
			<p><input type="submit" value="' . $this->l('   Save   ') . '" name="submitAddPermissions" class="button" /></p>
		</form>
		<script type="text/javascript">managePermissions();</script>';
    }
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        $obj = $this->loadObject(true);
        $profiles = Profile::getProfiles(intval($cookie->id_lang));
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data" class="width2">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/nav-user.gif" />' . $this->l('Employees') . '</legend>
				<label>' . $this->l('Last name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('First name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('Password:'******' </label>
				<div class="margin-form">
					<input type="password" size="33" name="passwd" value="" /> <sup>*</sup>
					<p>' . ($obj->id ? $this->l('Leave blank if you do not want to change your password') : $this->l('Min. 8 characters; use only letters, numbers or') . ' -_') . '</p>
				</div>
				<label>' . $this->l('E-mail address:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="email" value="' . htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this employee to log in to this Back Office') . '</p>
				</div>
				<label>' . $this->l('Profile:') . ' </label>
				<div class="margin-form">
					<select name="id_profile">
						<option value="">---------</option>';
        /* Profile display */
        foreach ($profiles as $profile) {
            echo '
						<option value="' . $profile['id_profile'] . '"' . ($profile['id_profile'] === $this->getFieldValue($obj, 'id_profile') ? ' selected="selected"' : '') . '>' . $profile['name'] . '</option>';
        }
        echo '</select> <sup>*</sup>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
Esempio n. 5
0
 public static function print_profile_list()
 {
     $configuration = PS_CLI_CONFIGURE::getConfigurationInstance();
     $profiles = Profile::getProfiles($configuration->lang);
     $table = new cli\Table();
     $table->setHeaders(array('ID', 'Name'));
     foreach ($profiles as $profile) {
         $table->addRow(array($profile['id_profile'], $profile['name']));
     }
     $table->display();
     return true;
 }
Esempio n. 6
0
 private function createAdminTabs()
 {
     $langs = Language::getLanguages();
     $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     /*         * ** create tab publications *** */
     $tab0 = new Tab();
     $tab0->class_name = "AdminVideos";
     $tab0->module = "myvideo";
     $tab0->id_parent = 0;
     foreach ($langs as $l) {
         $tab0->name[$l['id_lang']] = $this->l('Videos');
     }
     $tab0->save();
     $blog_tab_id = $tab0->id;
     $tab1 = new Tab();
     $tab1->class_name = "AdminVideoCategory";
     $tab1->module = "myvideo";
     $tab1->id_parent = $blog_tab_id;
     foreach ($langs as $l) {
         $tab1->name[$l['id_lang']] = $this->l('Video Categories');
     }
     $tab1->save();
     /*         * ** create tab categories *** */
     $tab2 = new Tab();
     $tab2->class_name = "AdminVideo";
     $tab2->module = "myvideo";
     $tab2->id_parent = $blog_tab_id;
     foreach ($langs as $l) {
         $tab2->name[$l['id_lang']] = $this->l('Video');
     }
     $tab2->save();
     /*         * * RIGHTS MANAGEMENT ** */
     Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'access 
                                     WHERE `id_tab` = ' . (int) $tab0->id . ' 
                                         OR `id_tab` = ' . (int) $tab1->id . ' 
                                         OR `id_tab` = ' . (int) $tab2->id);
     Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'module_access WHERE `id_module` = ' . (int) $this->id);
     $profiles = Profile::getProfiles($id_lang);
     if (count($profiles)) {
         foreach ($profiles as $p) {
             Db::getInstance()->Execute('INSERT IGNORE INTO `' . _DB_PREFIX_ . 'access`(`id_profile`,`id_tab`,`view`,`add`,`edit`,`delete`) 
                                              VALUES (' . $p['id_profile'] . ', ' . (int) $tab0->id . ',1,1,1,1)');
             Db::getInstance()->Execute('INSERT IGNORE INTO `' . _DB_PREFIX_ . 'access`(`id_profile`,`id_tab`,`view`,`add`,`edit`,`delete`) 
                                              VALUES (' . $p['id_profile'] . ', ' . (int) $tab1->id . ',1,1,1,1)');
             Db::getInstance()->Execute('INSERT IGNORE INTO `' . _DB_PREFIX_ . 'access`(`id_profile`,`id_tab`,`view`,`add`,`edit`,`delete`) 
                                              VALUES (' . $p['id_profile'] . ', ' . (int) $tab2->id . ',1,1,1,1)');
             Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'module_access(`id_profile`, `id_module`, `configure`, `view`)
                                             VALUES (' . $p['id_profile'] . ',' . (int) $this->id . ',1,1)');
         }
     }
 }
Esempio n. 7
0
    public function displayForm($isMainTab = true)
    {
        global $cookie, $currentIndex;
        parent::displayForm();
        $currentProfile = intval($this->getCurrentProfileId());
        $tabs = Tab::getTabs($cookie->id_lang);
        $profiles = Profile::getProfiles(intval($cookie->id_lang));
        $accesses = Profile::getProfileAccesses(intval($currentProfile));
        echo '
		<script type="text/javascript">
			setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Updating in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\'));
		</script>
		<div id="ajax_confirmation"></div>
		<table class="table" cellspacing="0">
			<tr>
				<th>
					<select name="profile" onchange="redirect(\'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">';
        if ($profiles) {
            foreach ($profiles as $profile) {
                echo '<option value="' . intval($profile['id_profile']) . '" ' . (intval($profile['id_profile']) == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>';
            }
        }
        echo '
					</select>
				</th>
				<th>' . $this->l('View') . '</th>
				<th>' . $this->l('Add') . '</th>
				<th>' . $this->l('Edit') . '</th>
				<th>' . $this->l('Delete') . '</th>
			</tr>';
        if (!sizeof($tabs)) {
            echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>';
        } else {
            if ($currentProfile == intval(_PS_ADMIN_PROFILE_)) {
                echo '<tr><td colspan="5">' . $this->l('Administrator permissions can\'t be modified.') . '</td></tr>';
            } else {
                foreach ($tabs as $tab) {
                    if (!$tab['id_parent'] or intval($tab['id_parent']) == -1) {
                        $this->printTabAccess(intval($currentProfile), $tab, $accesses[$tab['id_tab']], false);
                        foreach ($tabs as $child) {
                            if ($child['id_parent'] === $tab['id_tab']) {
                                $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true);
                            }
                        }
                    }
                }
            }
        }
        echo '</table>';
    }
Esempio n. 8
0
 public function __construct()
 {
     global $cookie;
     $this->table = 'profile';
     $this->className = 'Profile';
     $this->lang = true;
     $this->edit = true;
     $this->delete = true;
     $this->fieldsDisplay = array('id_profile' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 200));
     $this->identifier = 'id_profile';
     $list_profile = array();
     foreach (Profile::getProfiles($cookie->id_lang) as $profil) {
         $list_profile[] = array('value' => $profil['id_profile'], 'name' => $profil['name']);
     }
     parent::__construct();
 }
    /**
     * AdminController::renderForm() override
     * @see AdminController::renderForm()
     */
    public function renderForm()
    {
        $current_profile = (int) $this->getCurrentProfileId();
        $profiles = Profile::getProfiles($this->context->language->id);
        $tabs = Tab::getTabs($this->context->language->id);
        $accesses = array();
        foreach ($profiles as $profile) {
            $accesses[$profile['id_profile']] = Profile::getProfileAccesses($profile['id_profile']);
        }
        // Deleted id_tab that do not have access
        foreach ($tabs as $key => $tab) {
            // Don't allow permissions for unnamed tabs (ie. AdminLogin)
            if (empty($tab['name'])) {
                unset($tabs[$key]);
            }
            foreach ($this->accesses_black_list as $id_tab) {
                if ($tab['id_tab'] == (int) $id_tab) {
                    unset($tabs[$key]);
                }
            }
        }
        $modules = array();
        foreach ($profiles as $profile) {
            $modules[$profile['id_profile']] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
				SELECT ma.`id_module`, m.`name`, ma.`view`, ma.`configure`, ma.`uninstall`
				FROM ' . _DB_PREFIX_ . 'module_access ma
				LEFT JOIN ' . _DB_PREFIX_ . 'module m
					ON ma.id_module = m.id_module
				WHERE id_profile = ' . (int) $profile['id_profile'] . '
				ORDER BY m.name
			');
            foreach ($modules[$profile['id_profile']] as $k => &$module) {
                $m = Module::getInstanceById($module['id_module']);
                // the following condition handles invalid modules
                if ($m) {
                    $module['name'] = $m->displayName;
                } else {
                    unset($modules[$profile['id_profile']][$k]);
                }
            }
            uasort($modules[$profile['id_profile']], array($this, 'sortModuleByName'));
        }
        $this->fields_form = array('');
        $this->tpl_form_vars = array('profiles' => $profiles, 'accesses' => $accesses, 'id_tab_parentmodule' => (int) Tab::getIdFromClassName('AdminParentModules'), 'id_tab_module' => (int) Tab::getIdFromClassName('AdminModules'), 'tabs' => $tabs, 'current_profile' => (int) $current_profile, 'admin_profile' => (int) _PS_ADMIN_PROFILE_, 'access_edit' => $this->tabAccess['edit'], 'perms' => array('view', 'add', 'edit', 'delete'), 'modules' => $modules, 'link' => $this->context->link);
        return parent::renderForm();
    }
Esempio n. 10
0
    function displayForm()
    {
        global $cookie, $currentIndex;
        $currentProfile = intval($this->getCurrentProfileId());
        $tabs = Tab::getTabs($cookie->id_lang);
        $profiles = Profile::getProfiles(intval($cookie->id_lang));
        $accesses = Profile::getProfileAccesses(intval($currentProfile));
        echo '
		<script type="text/javascript">
			setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Updating in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\'));
		</script>
		<div id="ajax_confirmation"></div>
		<table class="table" cellspacing="0">
			<tr>
				<th>
					<select name="profile" onchange="redirect(\'' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">';
        if ($profiles) {
            foreach ($profiles as $profile) {
                echo '<option value="' . intval($profile['id_profile']) . '" ' . (intval($profile['id_profile']) == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>';
            }
        }
        echo '
					</select>
				</th>
				<th>' . $this->l('View') . '</th>
				<th>' . $this->l('Add') . '</th>
				<th>' . $this->l('Edit') . '</th>
				<th>' . $this->l('Delete') . '</th>
			</tr>';
        if (!sizeof($tabs)) {
            echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>';
        } else {
            foreach ($tabs as $tab) {
                if (!$tab['id_parent'] or intval($tab['id_parent']) == -1) {
                    $this->printTabAccess(intval($currentProfile), $tab, $accesses[$tab['id_tab']], false);
                    foreach ($tabs as $child) {
                        if ($child['id_parent'] === $tab['id_tab']) {
                            $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true);
                        }
                    }
                }
            }
        }
        echo '</table>';
    }
 public function __construct()
 {
     $this->context = Context::getContext();
     $this->table = 'profile';
     $this->className = 'Profile';
     $this->multishop_context = Shop::CONTEXT_ALL;
     $this->lang = true;
     $this->addRowAction('edit');
     $this->addRowAction('delete');
     $this->addRowActionSkipList('delete', array(1));
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
     $this->fields_list = array('id_profile' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name')));
     $this->identifier = 'id_profile';
     $this->fields_form = array('legend' => array('title' => $this->l('Profile'), 'image' => '../img/admin/profiles.png'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 33, 'required' => true, 'lang' => true)), 'submit' => array('title' => $this->l('Save   '), 'class' => 'button'));
     $list_profile = array();
     foreach (Profile::getProfiles($this->context->language->id) as $profil) {
         $list_profile[] = array('value' => $profil['id_profile'], 'name' => $profil['name']);
     }
     parent::__construct();
 }
Esempio n. 12
0
 public function baseInit()
 {
     $groups = new Group();
     $group = $groups->getGroups();
     $profiles = new Profile();
     $profile = $profiles->getProfiles();
     foreach ($group as $single_group) {
         $group_arr[$single_group['id']] = $single_group['id'] . ' ' . $single_group['group_name'];
     }
     $this->addElement('Select', 'id_group', array('required' => false, 'label' => 'Assign to group:', 'MultiOptions' => $this->addClearStart($group_arr)));
     $resources = new LinkResource();
     $resource = $resources->getLinkResources();
     foreach ($resource as $single_resource) {
         $resource_arr[$single_resource['id']] = $single_resource['controller'] . ' ' . $single_resource['action'];
     }
     asort($resource_arr);
     $this->addElement('Select', 'id_resource', array('required' => false, 'label' => 'Assign link resource:', 'MultiOptions' => $this->addClearStart($resource_arr)));
     $this->submit();
     $this->cancel();
 }
Esempio n. 13
0
 public function __construct()
 {
     $this->bootstrap = true;
     $this->context = Context::getContext();
     $this->table = 'profile';
     $this->className = 'Profile';
     $this->multishop_context = Shop::CONTEXT_ALL;
     $this->lang = true;
     $this->addRowAction('edit');
     $this->addRowAction('delete');
     $this->addRowActionSkipList('delete', array(1));
     parent::__construct();
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
     $this->fields_list = array('id_profile' => array('title' => $this->trans('ID', array(), 'Admin.Global'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->trans('Name', array(), 'Admin.Global')));
     $this->identifier = 'id_profile';
     $this->fields_form = array('legend' => array('title' => $this->l('Profile'), 'icon' => 'icon-group'), 'input' => array(array('type' => 'text', 'label' => $this->trans('Name', array(), 'Admin.Global'), 'name' => 'name', 'required' => true, 'lang' => true)), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions')));
     $list_profile = array();
     foreach (Profile::getProfiles($this->context->language->id) as $profil) {
         $list_profile[] = array('value' => $profil['id_profile'], 'name' => $profil['name']);
     }
 }
Esempio n. 14
0
 public static function init_tab_prmission_for_existing_profiles($className, $view, $edit, $add, $delete)
 {
     global $cookie;
     ${${"GLOBALS"}["zkmomcrvsm"]} = Profile::getProfiles($cookie->id_lang);
     ${${"GLOBALS"}["jblygsl"]} = (int) Configuration::get("AGILE_MS_PROFILE_ID");
     foreach (${${"GLOBALS"}["zkmomcrvsm"]} as ${${"GLOBALS"}["nhhrclrvgrj"]}) {
         $lhvpuk = "add";
         ${"GLOBALS"}["grtbrbudoqu"] = "edit";
         if (${${"GLOBALS"}["nhhrclrvgrj"]}["id_profile"] == ${${"GLOBALS"}["jblygsl"]}) {
             continue;
         }
         ${"GLOBALS"}["mbtmuncpzf"] = "delete";
         self::update_access((int) ${${"GLOBALS"}["nhhrclrvgrj"]}["id_profile"], ${${"GLOBALS"}["diutbrwqqpqk"]}, ${${"GLOBALS"}["nrovpyoqoln"]}, ${${"GLOBALS"}["grtbrbudoqu"]}, ${$lhvpuk}, ${${"GLOBALS"}["mbtmuncpzf"]});
     }
 }
Esempio n. 15
0
 public static function init_tab_prmission_for_existing_profiles($className, $view, $edit, $add, $delete)
 {
     global $cookie;
     ${"GLOBALS"}["djxecd"] = "id_ams";
     ${${"GLOBALS"}["fwcnmhxwa"]} = Profile::getProfiles($cookie->id_lang);
     ${"GLOBALS"}["ailocd"] = "profile";
     ${${"GLOBALS"}["djxecd"]} = (int) Configuration::get("AGILE_MS_PROFILE_ID");
     foreach (${${"GLOBALS"}["fwcnmhxwa"]} as ${${"GLOBALS"}["ailocd"]}) {
         $jfwlxiaxopmn = "id_ams";
         ${"GLOBALS"}["ywmlojdahda"] = "delete";
         $vhqvolpk = "edit";
         $sjcgnjrvw = "add";
         ${"GLOBALS"}["wgbobhy"] = "profile";
         if (${${"GLOBALS"}["wgbobhy"]}["id_profile"] == ${$jfwlxiaxopmn}) {
             continue;
         }
         self::update_access((int) ${${"GLOBALS"}["nlnrowljdvsj"]}["id_profile"], ${${"GLOBALS"}["imkysutx"]}, ${${"GLOBALS"}["fciyknoqlv"]}, ${$vhqvolpk}, ${$sjcgnjrvw}, ${${"GLOBALS"}["ywmlojdahda"]});
     }
 }
Esempio n. 16
0
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $available_profiles = Profile::getProfiles($this->context->language->id);
     if ($obj->id_profile == _PS_ADMIN_PROFILE_ && $this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
         $this->errors[] = Tools::displayError('You cannot edit the SuperAdmin profile.');
         return parent::renderForm();
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Employees'), 'icon' => 'icon-user'), 'input' => array(array('type' => 'text', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => true), array('type' => 'text', 'label' => $this->l('Last Name'), 'name' => 'lastname', 'required' => true), array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'image' => ImageManager::thumbnail($obj->getImage(), $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 150, $this->imageType, true, true), 'col' => 6, 'value' => true, 'display_image' => true), array('type' => 'password', 'label' => $this->l('Password'), 'name' => 'passwd', 'required' => true, 'hint' => $obj->id ? $this->l('Leave this field blank if you do not want to change your password.') : $this->l('Minimum of eight characters.')), array('type' => 'text', 'label' => $this->l('Email address'), 'name' => 'email', 'required' => true, 'autocomplete' => false), array('type' => 'default_tab', 'label' => $this->l('Default page'), 'name' => 'default_tab', 'hint' => $this->l('This page will be displayed just after login.'), 'options' => $this->tabs_list), array('type' => 'select', 'label' => $this->l('Language'), 'name' => 'id_lang', 'required' => true, 'options' => array('query' => Language::getLanguages(false), 'id' => 'id_lang', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Theme'), 'name' => 'bo_theme_css', 'options' => array('query' => $this->themes, 'id' => 'id', 'name' => 'name'), 'onchange' => 'var value_array = $(this).val().split("|"); $("link").first().attr("href", "themes/" + value_array[0] + "/css/" + value_array[1]);', 'hint' => $this->l('Back Office theme.')), array('type' => 'radio', 'label' => $this->l('Admin menu orientation'), 'name' => 'bo_menu', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'bo_menu_on', 'value' => 0, 'label' => $this->l('Top')), array('id' => 'bo_menu_off', 'value' => 1, 'label' => $this->l('Left'))))));
     if ((int) $this->tabAccess['edit'] && !$this->restrict_edition) {
         $this->fields_form['input'][] = array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Allow or disallow this employee to log into the Admin panel.'));
         // if employee is not SuperAdmin (id_profile = 1), don't make it possible to select the admin profile
         if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
             foreach ($available_profiles as $i => $profile) {
                 if ($available_profiles[$i]['id_profile'] == _PS_ADMIN_PROFILE_) {
                     unset($available_profiles[$i]);
                     break;
                 }
             }
         }
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Permission profile'), 'name' => 'id_profile', 'required' => true, 'options' => array('query' => $available_profiles, 'id' => 'id_profile', 'name' => 'name', 'default' => array('value' => '', 'label' => $this->l('-- Choose --'))));
         if (Shop::isFeatureActive()) {
             $this->context->smarty->assign('_PS_ADMIN_PROFILE_', (int) _PS_ADMIN_PROFILE_);
             $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'hint' => $this->l('Select the shops the employee is allowed to access.'), 'name' => 'checkBoxShopAsso');
         }
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     $this->fields_value['passwd'] = false;
     $this->fields_value['bo_theme_css'] = $obj->bo_theme . '|' . $obj->bo_css;
     if (empty($obj->id)) {
         $this->fields_value['id_lang'] = $this->context->language->id;
     }
     return parent::renderForm();
 }
Esempio n. 17
0
    public function install()
    {
        if (!parent::install()) {
            return false;
        }
        if (!$this->registerHookByVersion()) {
            return false;
        }
        if (!file_exists(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE) || !($sql = file_get_contents(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE))) {
            return false;
        }
        $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
        $sql = preg_split("/;\\s*[\r\n]+/", $sql);
        foreach ($sql as $k => $query) {
            if (!empty($query)) {
                Db::getInstance()->execute(trim($query));
            }
        }
        $result = Db::getInstance()->getRow('
			SELECT id_tab
			FROM `' . _DB_PREFIX_ . 'tab`
			WHERE class_name="AdminMondialRelay"');
        if (!$result) {
            // AdminOrders id_tab
            $id_parent = _PS_VERSION_ < '1.5' ? 3 : 9;
            /*tab install */
            $result = Db::getInstance()->getRow('
				SELECT position
				FROM `' . _DB_PREFIX_ . 'tab`
				WHERE `id_parent` = ' . (int) $id_parent . '
				ORDER BY `' . _DB_PREFIX_ . 'tab`.`position` DESC');
            $pos = isset($result['position']) ? $result['position'] + 1 : 0;
            Db::getInstance()->execute('
				INSERT INTO ' . _DB_PREFIX_ . 'tab
				(id_parent, class_name, position, module)
				VALUES(' . (int) $id_parent . ', "AdminMondialRelay",  "' . (int) $pos . '", "mondialrelay")');
            $id_tab = Db::getInstance()->Insert_ID();
            $languages = Language::getLanguages(false);
            foreach ($languages as $language) {
                Db::getInstance()->execute('
				INSERT INTO ' . _DB_PREFIX_ . 'tab_lang
				(id_lang, id_tab, name)
				VALUES("' . (int) $language['id_lang'] . '", "' . (int) $id_tab . '", "Mondial Relay")');
            }
            $profiles = Profile::getProfiles(Configuration::get('PS_LANG_DEFAULT'));
            foreach ($profiles as $profile) {
                Db::getInstance()->execute('
				INSERT INTO ' . _DB_PREFIX_ . 'access
				(`id_profile`,`id_tab`,`view`,`add`,`edit`,`delete`)
				VALUES(' . $profile['id_profile'] . ', ' . (int) $id_tab . ', 1, 1, 1, 1)');
            }
            if (is_dir(_PS_MODULE_DIR_ . 'mondialrelay/')) {
                @copy(_PS_MODULE_DIR_ . 'mondialrelay/AdminMondialRelay.gif', _PS_IMG_DIR_ . '/AdminMondialRelay.gif');
            }
        }
        // If module isn't installed, set default value
        if (!Configuration::get('MONDIAL_RELAY')) {
            Configuration::updateValue('MONDIAL_RELAY', $this->version);
            Configuration::updateValue('MONDIAL_RELAY_SECURE_KEY', md5(time() . rand(0, 10)));
        } else {
            // Reactive transport if database wasn't remove at the last uninstall
            Db::getInstance()->execute('
				UPDATE `' . _DB_PREFIX_ . 'carrier` c, `' . _DB_PREFIX_ . 'mr_method` m
					SET c.`deleted` = 0, c.`active` = 1
					WHERE c.id_carrier = m.id_carrier');
        }
        return true;
    }
Esempio n. 18
0
 public static function init_tab_prmission_for_existing_profiles($className, $view, $edit, $add, $delete)
 {
     $bepluqri = "id_ams";
     ${"GLOBALS"}["npwtozs"] = "profiles";
     global $cookie;
     ${${"GLOBALS"}["npwtozs"]} = Profile::getProfiles($cookie->id_lang);
     ${$bepluqri} = (int) Configuration::get("AGILE_MS_PROFILE_ID");
     foreach (${${"GLOBALS"}["wywcawitcva"]} as ${${"GLOBALS"}["mleqkrb"]}) {
         ${"GLOBALS"}["tyiwnoyyiqc"] = "profile";
         ${"GLOBALS"}["oocsuph"] = "delete";
         ${"GLOBALS"}["ykvprjq"] = "add";
         ${"GLOBALS"}["vfbcwfq"] = "id_ams";
         ${"GLOBALS"}["fhtzbwe"] = "className";
         if (${${"GLOBALS"}["mleqkrb"]}["id_profile"] == ${${"GLOBALS"}["vfbcwfq"]}) {
             continue;
         }
         self::update_access((int) ${${"GLOBALS"}["tyiwnoyyiqc"]}["id_profile"], ${${"GLOBALS"}["fhtzbwe"]}, ${${"GLOBALS"}["qrwijdgnot"]}, ${${"GLOBALS"}["xkqtghm"]}, ${${"GLOBALS"}["ykvprjq"]}, ${${"GLOBALS"}["oocsuph"]});
     }
 }
Esempio n. 19
0
    public function install()
    {
        global $cookie;
        $name = "shipping";
        $title = "Mondial Relay API";
        if (!parent::install()) {
            return false;
        }
        Db::getInstance()->ExecuteS('SELECT `name` 
			FROM `' . _DB_PREFIX_ . 'hook` 
			WHERE `name` = \'' . $name . '\' 
			AND `title` = \'' . $title . '\'');
        if (!Db::getInstance()->NumRows()) {
            Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'hook 
			(name, title, description, position) 
			VALUES(\'' . $name . '\', \'' . $title . '\', NULL, 0)');
        }
        if (!$this->registerHookByVersion()) {
            return false;
        }
        if (!file_exists(self::$modulePath . self::INSTALL_SQL_FILE) || !($sql = file_get_contents(self::$modulePath . self::INSTALL_SQL_FILE))) {
            return false;
        }
        $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
        $sql = preg_split("/;\\s*[\r\n]+/", $sql);
        foreach ($sql as $k => $query) {
            if (!empty($query)) {
                Db::getInstance()->Execute(trim($query));
            }
        }
        $result = Db::getInstance()->getRow('
			SELECT id_tab  
			FROM `' . _DB_PREFIX_ . 'tab`
			WHERE class_name="AdminMondialRelay"');
        if (!$result) {
            /*tab install */
            $result = Db::getInstance()->getRow('
				SELECT position 
				FROM `' . _DB_PREFIX_ . 'tab` 
				WHERE `id_parent` = 3
				ORDER BY `' . _DB_PREFIX_ . 'tab`.`position` DESC');
            $pos = isset($result['position']) ? $result['position'] + 1 : 0;
            Db::getInstance()->Execute('
				INSERT INTO ' . _DB_PREFIX_ . 'tab 
				(id_parent, class_name, position, module) 
				VALUES(3, "AdminMondialRelay",  "' . (int) $pos . '", "mondialrelay")');
            $id_tab = Db::getInstance()->Insert_ID();
            $languages = Language::getLanguages();
            foreach ($languages as $language) {
                Db::getInstance()->Execute('
				INSERT INTO ' . _DB_PREFIX_ . 'tab_lang 
				(id_lang, id_tab, name) 
				VALUES("' . (int) $language['id_lang'] . '", "' . (int) $id_tab . '", "Mondial Relay")');
            }
            $profiles = Profile::getProfiles(Configuration::get('PS_LANG_DEFAULT'));
            foreach ($profiles as $profile) {
                Db::getInstance()->Execute('
				INSERT INTO ' . _DB_PREFIX_ . 'access 
				(`id_profile`,`id_tab`,`view`,`add`,`edit`,`delete`)
				VALUES(' . $profile['id_profile'] . ', ' . (int) $id_tab . ', 1, 1, 1, 1)');
            }
            @copy(_PS_MODULE_DIR_ . 'mondialrelay/AdminMondialRelay.gif', _PS_IMG_DIR_ . 't/AdminMondialRelay.gif');
        }
        Configuration::updateValue('MONDIAL_RELAY_1_4', '1');
        Configuration::updateValue('MONDIAL_RELAY_INSTALL_UPDATE_1', 1);
        Configuration::updateValue('MONDIAL_RELAY_ORDER_STATE', 3);
        Configuration::updateValue('MONDIAL_RELAY_SECURE_KEY', md5(time() . rand(0, 10)));
        Configuration::updateValue('MR_GOOGLE_MAP', '1');
        Configuration::updateValue('MR_ENSEIGNE_WEBSERVICE', '');
        Configuration::updateValue('MR_CODE_MARQUE', '');
        Configuration::updateValue('MR_KEY_WEBSERVICE', '');
        Configuration::updateValue('MR_LANGUAGE', '');
        Configuration::updateValue('MR_WEIGHT_COEF', '');
        Configuration::updateValue('PS_MR_SHOP_NAME', Configuration::get('PS_SHOP_NAME'));
        return true;
    }
Esempio n. 20
0
    public function install()
    {
        global $cookie;
        $name = "shipping";
        $title = "Mondial Relay API";
        if (!parent::install()) {
            return false;
        }
        Db::getInstance()->ExecuteS('SELECT `name` 
			FROM `' . _DB_PREFIX_ . 'hook` 
			WHERE `name` = \'' . $name . '\' 
			AND `title` = \'' . $title . '\'');
        if (!Db::getInstance()->NumRows()) {
            Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'hook 
			(name, title, description, position) 
			VALUES(\'' . $name . '\', \'' . $title . '\', NULL, 0)');
        }
        if (!$this->registerHookByVersion()) {
            return false;
        }
        if (!file_exists(self::$modulePath . self::INSTALL_SQL_FILE) || !($sql = file_get_contents(self::$modulePath . self::INSTALL_SQL_FILE))) {
            return false;
        }
        $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
        $sql = preg_split("/;\\s*[\r\n]+/", $sql);
        foreach ($sql as $k => $query) {
            if (!empty($query)) {
                Db::getInstance()->Execute(trim($query));
            }
        }
        $result = Db::getInstance()->getRow('
			SELECT id_tab  
			FROM `' . _DB_PREFIX_ . 'tab`
			WHERE class_name="AdminMondialRelay"');
        if (!$result) {
            // AdminOrders id_tab
            $id_parent = 3;
            /*tab install */
            $result = Db::getInstance()->getRow('
				SELECT position 
				FROM `' . _DB_PREFIX_ . 'tab` 
				WHERE `id_parent` = ' . (int) $id_parent . '
				ORDER BY `' . _DB_PREFIX_ . 'tab`.`position` DESC');
            $pos = isset($result['position']) ? $result['position'] + 1 : 0;
            Db::getInstance()->Execute('
				INSERT INTO ' . _DB_PREFIX_ . 'tab 
				(id_parent, class_name, position, module) 
				VALUES(' . (int) $id_parent . ', "AdminMondialRelay",  "' . (int) $pos . '", "mondialrelay")');
            $id_tab = Db::getInstance()->Insert_ID();
            $languages = Language::getLanguages();
            foreach ($languages as $language) {
                Db::getInstance()->Execute('
					INSERT INTO ' . _DB_PREFIX_ . 'tab_lang 
					(id_lang, id_tab, name) 
					VALUES("' . (int) $language['id_lang'] . '", "' . (int) $id_tab . '", "Mondial Relay")');
            }
            $profiles = Profile::getProfiles(Configuration::get('PS_LANG_DEFAULT'));
            foreach ($profiles as $profile) {
                Db::getInstance()->Execute('
					INSERT INTO ' . _DB_PREFIX_ . 'access 
					(`id_profile`,`id_tab`,`view`,`add`,`edit`,`delete`)
					VALUES(' . $profile['id_profile'] . ', ' . (int) $id_tab . ', 1, 1, 1, 1)');
            }
            @copy(_PS_MODULE_DIR_ . 'mondialrelay/AdminMondialRelay.gif', _PS_IMG_DIR_ . '/AdminMondialRelay.gif');
        }
        // If module isn't installed, set default value
        if (!Configuration::get('MONDIAL_RELAY')) {
            Configuration::updateValue('MONDIAL_RELAY', $this->version);
            Configuration::updateValue('MONDIAL_RELAY_ORDER_STATE', 3);
            Configuration::updateValue('MONDIAL_RELAY_SECURE_KEY', md5(time() . rand(0, 10)));
            Configuration::updateValue('MR_GOOGLE_MAP', '1');
            Configuration::updateValue('MR_ENSEIGNE_WEBSERVICE', '');
            Configuration::updateValue('MR_CODE_MARQUE', '');
            Configuration::updateValue('MR_KEY_WEBSERVICE', '');
            Configuration::updateValue('MR_LANGUAGE', '');
            Configuration::updateValue('MR_WEIGHT_COEF', '');
        } else {
            // Reactive transport if database wasn't remove at the last uninstall
            Db::getInstance()->Execute('
				UPDATE `' . _DB_PREFIX_ . 'carrier` c, `' . _DB_PREFIX_ . 'mr_method` m
					SET `deleted` = 0
					WHERE c.id_carrier = m.id_carrier');
            if (Configuration::get('MONDIAL_RELAY') < $this->version) {
            }
            // TODO : ADD upgrade process depending of the last and new version
        }
        return true;
    }
Esempio n. 21
0
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $profiles = Profile::getProfiles((int) $cookie->id_lang);
        echo '<script type="text/javascript" src="' . _PS_JS_DIR_ . '/jquery/jquery-colorpicker.js"></script>
		 	 <script type="text/javascript">
				var employeePage = true;
		 	 </script>


		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . ((int) $this->tabAccess['view'] ? '' : '&updateemployee&id_employee=' . (int) $obj->id) . '" method="post" enctype="multipart/form-data" autocomplete="off">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
		' . ((int) $this->tabAccess['view'] ? '' : '<input type="hidden" name="back" value="' . $currentIndex . '&token=' . $this->token . '&updateemployee&id_employee=' . (int) $obj->id . '" />') . '
			<fieldset class="width3"><legend><img src="../img/admin/nav-user.gif" />' . $this->l('Employees') . '</legend>
				<label>' . $this->l('Last name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="lastname" value="' . htmlentities($this->getFieldValue($obj, 'lastname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('First name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="firstname" value="' . htmlentities($this->getFieldValue($obj, 'firstname'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div>
				<label>' . $this->l('Password:'******' </label>
				<div class="margin-form">
					<input type="password" size="33" name="passwd" value="" /> <sup>*</sup>
					<p>' . ($obj->id ? $this->l('Leave blank if you do not want to change your password') : $this->l('Min. 8 characters; use only letters, numbers or') . ' -_') . '</p>
				</div>
				<label>' . $this->l('E-mail address:') . ' </label>
				<div class="margin-form">
					<input type="text" size="33" name="email" value="' . htmlentities($this->getFieldValue($obj, 'email'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</div><div class="clear">&nbsp;</div>
				<label>' . $this->l('Back office color:') . ' </label>
				<div class="margin-form">';
        // Note : width= fix Firefox 4 display bug related to colorpicker librarie
        echo '<input type="color" width="50px" data-hex="true" class="color mColorPickerInput" name="bo_color" value="' . htmlentities($this->getFieldValue($obj, 'bo_color'), ENT_COMPAT, 'UTF-8') . '" />
					<p>' . $this->l('Back office background will be displayed in this color. HTML colors only (e.g.,') . ' "lightblue", "#CC6600")</p>
				</div><div class="clear">&nbsp;</div>
				<label>' . $this->l('Language:') . ' </label>
				<div class="margin-form">
					<select name="id_lang">';
        foreach (Language::getLanguages() as $lang) {
            echo '		<option value="' . (int) $lang['id_lang'] . '" ' . ($this->getFieldValue($obj, 'id_lang') == $lang['id_lang'] ? 'selected="selected"' : '') . '>' . Tools::htmlentitiesUTF8($lang['name']) . '</option>';
        }
        echo '		</select> <sup>*</sup>
				</div><div class="clear">&nbsp;</div>
				<label>' . $this->l('Theme:') . ' </label>
				<div class="margin-form">
					<select name="bo_theme">';
        $path = dirname(__FILE__) . '/../themes/';
        foreach (scandir($path) as $theme) {
            if ($theme[0] != '.' and is_dir($path . $theme) and file_exists($path . $theme . '/admin.css')) {
                echo '	<option value="' . Tools::htmlentitiesUTF8($theme) . '" ' . ($this->getFieldValue($obj, 'bo_theme') == $theme ? 'selected="selected"' : '') . '>' . Tools::htmlentitiesUTF8($theme) . '</option>';
            }
        }
        echo '		</select> <sup>*</sup>
				</div>';
        if ((int) $this->tabAccess['edit']) {
            echo '<div class="clear">&nbsp;</div>
				<label>' . $this->l('UI mode:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="bo_uimode" id="uimode_on" value="hover" ' . ($this->getFieldValue($obj, 'bo_uimode') == 'hover' ? 'checked="checked" ' : '') . '/>
					<label class="t" for="uimode_on">' . $this->l('Hover on tabs') . '</label>
					<input type="radio" name="bo_uimode" id="uimode_off" value="click" ' . ($this->getFieldValue($obj, 'bo_uimode') == 'click' ? 'checked="checked" ' : '') . '/>
					<label class="t" for="uimode_off">' . $this->l('Click on tabs') . '</label>
				</div><div class="clear">&nbsp;</div>
				<label>' . $this->l('Show screencast:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="bo_show_screencast" id="bo_show_screencast_on" value="1" ' . ($this->getFieldValue($obj, 'bo_show_screencast') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="bo_show_screencast" id="bo_show_screencast_off" value="0" ' . (!$this->getFieldValue($obj, 'bo_show_screencast') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Show the welcome video on the dashbord of the back office') . '</p>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Allow or disallow this employee to log into this Back Office') . '</p>
				</div>
				<label>' . $this->l('Profile:') . ' </label>
				<div class="margin-form">
					<select name="id_profile">
						<option value="">' . $this->l('-- Choose --') . '</option>';
            foreach ($profiles as $profile) {
                echo '<option value="' . $profile['id_profile'] . '"' . ($profile['id_profile'] === $this->getFieldValue($obj, 'id_profile') ? ' selected="selected"' : '') . '>' . $profile['name'] . '</option>';
            }
            echo '</select> <sup>*</sup>
				</div>';
        }
        echo '<div class="clear">&nbsp;</div>
				<center>
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</center><div class="clear">&nbsp;</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
Esempio n. 22
0
 public static function init_tab_prmission_for_existing_profiles($className, $view, $edit, $add, $delete)
 {
     $bkkhbtrlv = "profile";
     $mrwenrw = "id_ams";
     $wbpmphl = "profiles";
     $nazrunpzj = "profiles";
     global $cookie;
     ${$nazrunpzj} = Profile::getProfiles($cookie->id_lang);
     ${$mrwenrw} = (int) Configuration::get("AGILE_MS_PROFILE_ID");
     foreach (${$wbpmphl} as ${$bkkhbtrlv}) {
         ${"GLOBALS"}["djscnxfdyyl"] = "id_ams";
         ${"GLOBALS"}["vfxonjkph"] = "profile";
         $cmqjmepz = "profile";
         $cyfubxyo = "delete";
         ${"GLOBALS"}["jniuvpvr"] = "add";
         ${"GLOBALS"}["olbjjiurn"] = "edit";
         if (${$cmqjmepz}["id_profile"] == ${${"GLOBALS"}["djscnxfdyyl"]}) {
             continue;
         }
         self::update_access((int) ${${"GLOBALS"}["vfxonjkph"]}["id_profile"], ${${"GLOBALS"}["xspxwwxt"]}, ${${"GLOBALS"}["tkgubpfd"]}, ${${"GLOBALS"}["olbjjiurn"]}, ${${"GLOBALS"}["jniuvpvr"]}, ${$cyfubxyo});
     }
 }
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $available_profiles = Profile::getProfiles($this->context->language->id);
     if ($obj->id_profile == _PS_ADMIN_PROFILE_ && $this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
         $this->errors[] = Tools::displayError('You cannot edit SuperAdmin profile.');
         return parent::renderForm();
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Employees'), 'image' => '../img/admin/nav-user.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('First name:'), 'name' => 'firstname', 'size' => 33, 'required' => true), array('type' => 'text', 'label' => $this->l('Last name:'), 'name' => 'lastname', 'size' => 33, 'required' => true), array('type' => 'password', 'label' => $this->l('Password:'******'name' => 'passwd', 'required' => true, 'size' => 33, 'desc' => $obj->id ? $this->l('Leave blank if you do not want to change your password') : $this->l('Min. 8 characters; use only letters, numbers or') . ' -_'), array('type' => 'text', 'label' => $this->l('E-mail address:'), 'name' => 'email', 'size' => 33, 'required' => true), array('type' => 'color', 'label' => $this->l('Admin panel color:'), 'name' => 'bo_color', 'class' => 'color mColorPickerInput', 'size' => 20, 'desc' => $this->l('Admin panel background will be displayed in this color. HTML colors only (e.g.') . ' "lightblue", "#CC6600")'), array('type' => 'default_tab', 'label' => $this->l('Default page:'), 'name' => 'default_tab', 'desc' => $this->l('This page will be displayed just after login'), 'options' => $this->tabs_list), array('type' => 'text', 'label' => $this->l('Back Office width:'), 'name' => 'bo_width', 'size' => 10, 'desc' => $this->l('Back Office width, in pixels. The value "0" means that the Back Office width will be flexible.')), array('type' => 'select', 'label' => $this->l('Language:'), 'name' => 'id_lang', 'required' => true, 'options' => array('query' => Language::getLanguages(), 'id' => 'id_lang', 'name' => 'name')), array('type' => 'select_theme', 'label' => $this->l('Theme:'), 'name' => 'bo_theme', 'options' => array('query' => $this->themes), 'desc' => $this->l('Back Office theme')), array('type' => 'radio', 'label' => $this->l('Show screencast at log in:'), 'name' => 'bo_show_screencast', 'desc' => $this->l('Display the welcome video in the Admin panel dashboard at log in'), 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'bo_show_screencast_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'bo_show_screencast_off', 'value' => 0, 'label' => $this->l('Disabled'))))));
     if ((int) $this->tabAccess['edit'] && !$this->restrict_edition) {
         $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Allow or disallow this employee to log into the Admin panel'));
         // if employee is not SuperAdmin (id_profile = 1), don't make it possible to select the admin profile
         if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
             foreach ($available_profiles as $i => $profile) {
                 if ($available_profiles[$i]['id_profile'] == _PS_ADMIN_PROFILE_) {
                     unset($available_profiles[$i]);
                     break;
                 }
             }
         }
         $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Profile:'), 'name' => 'id_profile', 'required' => true, 'options' => array('query' => $available_profiles, 'id' => 'id_profile', 'name' => 'name', 'default' => array('value' => '', 'label' => $this->l('-- Choose --'))));
         if (Shop::isFeatureActive()) {
             $this->context->smarty->assign('_PS_ADMIN_PROFILE_', (int) _PS_ADMIN_PROFILE_);
             $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'desc' => $this->l('Select the shops the employee is allowed to access'), 'name' => 'checkBoxShopAsso');
         }
     }
     $this->fields_form['submit'] = array('title' => $this->l('   Save   '), 'class' => 'button');
     $this->fields_value['passwd'] = false;
     if (empty($obj->id)) {
         $this->fields_value['id_lang'] = $this->context->language->id;
     }
     return parent::renderForm();
 }
    public function renderForm()
    {
        /** @var Employee $obj */
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $available_profiles = Profile::getProfiles($this->context->language->id);
        if ($obj->id_profile == _PS_ADMIN_PROFILE_ && $this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
            $this->errors[] = Tools::displayError('You cannot edit the SuperAdmin profile.');
            return parent::renderForm();
        }
        $this->fields_form = array('legend' => array('title' => $this->l('Employees'), 'icon' => 'icon-user'), 'input' => array(array('type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => true), array('type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('Last Name'), 'name' => 'lastname', 'required' => true), array('type' => 'html', 'name' => 'employee_avatar', 'html_content' => '<div id="employee-thumbnail"><a href="http://www.prestashop.com/forums/index.php?app=core&amp;module=usercp" target="_blank" style="background-image:url(' . $obj->getImage() . ')"></a></div>
					<div class="alert alert-info">' . sprintf($this->l('Your avatar in PrestaShop 1.6.x is your profile picture on %1$s. To change your avatar, log in to PrestaShop.com with your email %2$s and follow the on-screen instructions.'), '<a href="http://www.prestashop.com/forums/index.php?app=core&amp;module=usercp" class="alert-link" target="_blank">PrestaShop.com</a>', $obj->email) . '</div>'), array('type' => 'text', 'class' => 'fixed-width-xxl', 'prefix' => '<i class="icon-envelope-o"></i>', 'label' => $this->l('Email address'), 'name' => 'email', 'required' => true, 'autocomplete' => false)));
        if ($this->restrict_edition) {
            $this->fields_form['input'][] = array('type' => 'change-password', 'label' => $this->l('Password'), 'name' => 'passwd');
            if (Tab::checkTabRights(Tab::getIdFromClassName('AdminModulesController'))) {
                $this->fields_form['input'][] = array('type' => 'prestashop_addons', 'label' => 'PrestaShop Addons', 'name' => 'prestashop_addons');
            }
        } else {
            $this->fields_form['input'][] = array('type' => 'password', 'label' => $this->l('Password'), 'hint' => sprintf($this->l('Password should be at least %s characters long.'), Validate::ADMIN_PASSWORD_LENGTH), 'name' => 'passwd');
        }
        $this->fields_form['input'] = array_merge($this->fields_form['input'], array(array('type' => 'switch', 'label' => $this->l('Subscribe to PrestaShop newsletter'), 'name' => 'optin', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'optin_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'optin_off', 'value' => 0, 'label' => $this->l('No'))), 'hint' => $this->l('PrestaShop can provide you with guidance on a regular basis by sending you tips on how to optimize the management of your store which will help you grow your business. If you do not wish to receive these tips, you can disable this option.')), array('type' => 'default_tab', 'label' => $this->l('Default page'), 'name' => 'default_tab', 'hint' => $this->l('This page will be displayed just after login.'), 'options' => $this->tabs_list), array('type' => 'select', 'label' => $this->l('Language'), 'name' => 'id_lang', 'options' => array('query' => Language::getLanguages(false), 'id' => 'id_lang', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Theme'), 'name' => 'bo_theme_css', 'options' => array('query' => $this->themes, 'id' => 'id', 'name' => 'name'), 'onchange' => 'var value_array = $(this).val().split("|"); $("link").first().attr("href", "themes/" + value_array[0] + "/css/" + value_array[1]);', 'hint' => $this->l('Back office theme.')), array('type' => 'radio', 'label' => $this->l('Admin menu orientation'), 'name' => 'bo_menu', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'bo_menu_on', 'value' => 0, 'label' => $this->l('Top')), array('id' => 'bo_menu_off', 'value' => 1, 'label' => $this->l('Left'))))));
        if ((int) $this->tabAccess['edit'] && !$this->restrict_edition) {
            $this->fields_form['input'][] = array('type' => 'switch', 'label' => $this->l('Active'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Allow or disallow this employee to log into the Admin panel.'));
            // if employee is not SuperAdmin (id_profile = 1), don't make it possible to select the admin profile
            if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
                foreach ($available_profiles as $i => $profile) {
                    if ($available_profiles[$i]['id_profile'] == _PS_ADMIN_PROFILE_) {
                        unset($available_profiles[$i]);
                        break;
                    }
                }
            }
            $this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Permission profile'), 'name' => 'id_profile', 'required' => true, 'options' => array('query' => $available_profiles, 'id' => 'id_profile', 'name' => 'name', 'default' => array('value' => '', 'label' => $this->l('-- Choose --'))));
            if (Shop::isFeatureActive()) {
                $this->context->smarty->assign('_PS_ADMIN_PROFILE_', (int) _PS_ADMIN_PROFILE_);
                $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'hint' => $this->l('Select the shops the employee is allowed to access.'), 'name' => 'checkBoxShopAsso');
            }
        }
        $this->fields_form['submit'] = array('title' => $this->l('Save'));
        $this->fields_value['passwd'] = false;
        $this->fields_value['bo_theme_css'] = $obj->bo_theme . '|' . $obj->bo_css;
        if (empty($obj->id)) {
            $this->fields_value['id_lang'] = $this->context->language->id;
        }
        return parent::renderForm();
    }
Esempio n. 25
0
 public static function list_employees($lang = NULL)
 {
     // TODO: check if lang exists before using it
     if ($lang === NULL) {
         $lang = Configuration::get('PS_LANG_DEFAULT');
     }
     $profiles = Profile::getProfiles($lang);
     $table = new cli\Table();
     $table->setHeaders(array('ID', 'email', 'profile', 'First name', 'Last name', 'Active'));
     foreach ($profiles as $profile) {
         $employees = Employee::getEmployeesByProfile($profile['id_profile']);
         if (!$employees) {
             continue;
         }
         foreach ($employees as $employee) {
             //print_r($employee);
             $enabled = $employee['active'] == 1 ? 'Active' : 'Inactive';
             $table->addRow(array($employee['id_employee'], $employee['email'], $profile['name'], $employee['firstname'], $employee['lastname'], $enabled));
         }
     }
     $table->display();
 }
Esempio n. 26
0
 public function getConfigFieldsValuesAdmin()
 {
     global $cookie;
     $employee = $cookie->id_employee;
     $mess = DB::getInstance()->getValue('SELECT `notif_message` FROM `' . _DB_PREFIX_ . 'check_permission` WHERE `id_employe` = ' . $employee . '');
     $com = DB::getInstance()->getValue('SELECT `notif_commande` FROM `' . _DB_PREFIX_ . 'check_permission` WHERE `id_employe` = ' . $employee . '');
     $cus = DB::getInstance()->getValue('SELECT `notif_customer` FROM `' . _DB_PREFIX_ . 'check_permission` WHERE `id_employe` = ' . $employee . '');
     $ret = DB::getInstance()->getValue('SELECT `notif_retour` FROM `' . _DB_PREFIX_ . 'check_permission` WHERE `id_employe` = ' . $employee . '');
     $nots = DB::getInstance()->getValue('SELECT `notif_ots` FROM `' . _DB_PREFIX_ . 'check_permission` WHERE `id_employe` = ' . $employee . '');
     $time = DB::getInstance()->getValue('SELECT `time` FROM `' . _DB_PREFIX_ . 'check_permission` WHERE `id_employe` = ' . $employee . '');
     $ots = DB::getInstance()->getValue('SELECT `ots` FROM `' . _DB_PREFIX_ . 'check_permission` WHERE `id_employe` = ' . $employee . '');
     $config_fields = array('notif_message' => (bool) Tools::getValue('notif_message', $mess), 'notif_commande' => (bool) Tools::getValue('notif_commande', $com), 'notif_customer' => (bool) Tools::getValue('notif_customer', $cus), 'notif_retour' => (bool) Tools::getValue('notif_retour', $ret), 'notif_ots' => (bool) Tools::getValue('notif_ots', $nots), 'time' => (int) Tools::getValue('time', $time), 'ots' => (int) Tools::getValue('ots', $ots));
     //recuperer tous les profiles valables
     $all[] = Profile::getProfiles($this->context->language->id);
     $taille = count($all[0]);
     foreach ($all as $a) {
         for ($i = 0; $i <= $taille - 1; $i++) {
             $choices[] = array('name' => $a[$i]['name'], 'id_profile' => (int) $a[$i]['id_profile'], 'val' => (int) $a[$i]['id_profile']);
         }
     }
     $id_choices = array();
     foreach ($choices as $choice) {
         $id_choices[] = $choice['id_profile'];
     }
     //recupere le profile à l'aide de methode $_POST
     $id_choices_post = array();
     foreach ($id_choices as $id) {
         if (Tools::getValue('profile[]_' . (int) $id)) {
             $id_choices_post['profile[]_' . (int) $id] = true;
         }
     }
     //recuperer le profile à l'aide de la methode Configuration
     $id_choices_config = array();
     $actual_profiles = Db::getInstance()->getValue('SELECT `profile` FROM `' . _DB_PREFIX_ . 'check_profile`');
     if ($confs = $actual_profiles) {
         $confs = explode(";", $actual_profiles);
     } else {
         $confs = array();
     }
     foreach ($confs as $conf) {
         $id_choices_config['profile[]_' . (int) $conf] = true;
     }
     $config_fields = array_merge($config_fields, $id_choices_config);
     return $config_fields;
 }
 /**
  * @param Product $product
  * @throws Exception
  * @throws SmartyException
  */
 public function initFormInformations($employee)
 {
     if (!$this->default_form_language) {
         $this->getLanguages();
     }
     $data = $this->createTemplate($this->tpl_form);
     $available_profiles = Profile::getProfiles($this->context->language->id);
     // if employee is not SuperAdmin (id_profile = 1), don't make it possible to select the admin profile
     foreach ($available_profiles as $i => $profile) {
         if (!in_array($available_profiles[$i]['id_profile'], array(Configuration::get('APH_PROFILE_STORE_EMPLOYEE'), Configuration::get('APH_PROFILE_STORE_OWNER'), Configuration::get('APH_PROFILE_STORE_MANAGER')))) {
             unset($available_profiles[$i]);
         }
     }
     $shops = array();
     if (Configuration::get('PS_SHOP_DEFAULT') == Context::getContext()->shop->id) {
         //$_shops = Shop::getShops(true, null, true);
         $_shops = Shop::getCompleteListOfShopsID();
         foreach ($_shops as $id_shop) {
             if ($id_shop == Configuration::get('PS_SHOP_DEFAULT')) {
                 continue;
             }
             $shop = new Shop($id_shop);
             $shops[$id_shop] = $shop->name;
         }
         asort($shops);
     }
     $data->assign(array('id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'id_shop' => Context::getContext()->shop->id, 'profiles' => $available_profiles, 'languages' => $this->_languages, 'shops' => $shops, 'default_form_language' => $this->default_form_language));
     $employee_props = array('active');
     foreach ($employee_props as $prop) {
         $employee->{$prop} = $this->getFieldValue($employee, $prop);
     }
     $data->assign(array('ad' => dirname($_SERVER['PHP_SELF']), 'id_lang' => $this->context->language->id, 'dipendente' => $employee, 'token' => $this->token, 'link' => $this->context->link, 'display' => $this->display));
     $data->assign($this->tpl_form_vars);
     $this->tpl_form_vars['dipendente'] = $employee;
     $this->tpl_form_vars['custom_form'] = $data->fetch();
 }