本文整理汇总了PHP中Employee::countProfile方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::countProfile方法的具体用法?PHP Employee::countProfile怎么用?PHP Employee::countProfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Employee
的用法示例。
在下文中一共展示了Employee::countProfile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->table = 'employee';
$this->className = 'Employee';
$this->lang = false;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->context = Context::getContext();
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
/*
check if there are more than one superAdmin
if it's the case then we can delete a superAdmin
*/
$super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true);
if ($super_admin == 1) {
$super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true);
$super_admin_id = array();
foreach ($super_admin_array as $key => $val) {
$super_admin_id[] = $val['id_employee'];
}
$this->addRowActionSkipList('delete', $super_admin_id);
}
$profiles = Profile::getProfiles($this->context->language->id);
if (!$profiles) {
$this->errors[] = Tools::displayError('No profile');
} else {
foreach ($profiles as $profile) {
$this->profiles_array[$profile['name']] = $profile['name'];
}
}
$this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'lastname' => array('title' => $this->l('Last name'), 'width' => 'auto'), 'firstname' => array('title' => $this->l('First name'), 'width' => 130), 'email' => array('title' => $this->l('E-mail address'), 'width' => 180), 'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name'), 'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'width' => 30));
$this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'desc' => $this->l('Security: minimum time to wait between two password changes'), 'cast' => 'intval', 'size' => 5, 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize language used in Admin panel forms'), 'desc' => $this->l('Allow employees to select a specific language for Admin panel forms'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array()));
$path = _PS_ADMIN_DIR_ . '/themes/';
foreach (scandir($path) as $theme) {
if ($theme[0] != '.' && is_dir($path . $theme) && file_exists($path . $theme . '/css/admin.css')) {
$this->themes[] = $theme;
}
}
$home_tab = Tab::getInstanceFromClassName('adminHome');
$this->tabs_list[$home_tab->id] = array('name' => $home_tab->name[$this->context->language->id], 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name[$this->context->language->id])));
foreach (Tab::getTabs($this->context->language->id, 0) as $tab) {
if (Tab::checkTabRights($tab['id_tab'])) {
$this->tabs_list[$tab['id_tab']] = $tab;
foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) {
if (Tab::checkTabRights($children['id_tab'])) {
$this->tabs_list[$tab['id_tab']]['children'][] = $children;
}
}
}
}
parent::__construct();
// An employee can edit its own profile
if ($this->context->employee->id == Tools::getValue('id_employee')) {
$this->tabAccess['view'] = '1';
if (!$this->tabAccess['edit']) {
$this->restrict_edition = true;
}
$this->tabAccess['edit'] = '1';
}
}
示例2: isLastAdmin
public function isLastAdmin()
{
return $this->isSuperAdmin() && Employee::countProfile($this->id_profile, true) == 1 && $this->active;
}
示例3: __construct
public function __construct()
{
$this->bootstrap = true;
$this->table = 'employee';
$this->className = 'Employee';
$this->lang = false;
$this->context = Context::getContext();
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->addRowActionSkipList('delete', array((int) $this->context->employee->id));
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
/*
check if there are more than one superAdmin
if it's the case then we can delete a superAdmin
*/
$super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true);
if ($super_admin == 1) {
$super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true);
$super_admin_id = array();
foreach ($super_admin_array as $key => $val) {
$super_admin_id[] = $val['id_employee'];
}
$this->addRowActionSkipList('delete', $super_admin_id);
}
$profiles = Profile::getProfiles($this->context->language->id);
if (!$profiles) {
$this->errors[] = Tools::displayError('No profile.');
} else {
foreach ($profiles as $profile) {
$this->profiles_array[$profile['name']] = $profile['name'];
}
}
$this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'firstname' => array('title' => $this->l('First Name')), 'lastname' => array('title' => $this->l('Last Name')), 'email' => array('title' => $this->l('Email address')), 'profile' => array('title' => $this->l('Profile'), 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name', 'class' => 'fixed-width-lg'), 'active' => array('title' => $this->l('Active'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'class' => 'fixed-width-sm'));
$this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'hint' => $this->l('Security: Minimum time to wait between two password changes.'), 'cast' => 'intval', 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize the language used in Admin panel forms'), 'hint' => $this->l('Allow employees to select a specific language for the Admin panel form.'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array('title' => $this->l('Save'))));
$rtl = $this->context->language->is_rtl ? '_rtl' : '';
$path = _PS_ADMIN_DIR_ . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR;
foreach (scandir($path) as $theme) {
if ($theme[0] != '.' && is_dir($path . $theme) && @filemtime($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'admin-theme.css')) {
$this->themes[] = array('id' => $theme . '|admin-theme' . $rtl . '.css', 'name' => $theme == 'default' ? $this->l('Default') : ucfirst($theme));
if (file_exists($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl)) {
foreach (scandir($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl) as $css) {
if ($css[0] != '.' && preg_match('/\\.css$/', $css)) {
$name = strpos($css, 'admin-theme-') !== false ? Tools::ucfirst(preg_replace('/^admin-theme-(.*)\\.css$/', '$1', $css)) : $css;
$this->themes[] = array('id' => $theme . '|schemes' . $rtl . '/' . $css, 'name' => $name);
}
}
}
}
}
$home_tab = Tab::getInstanceFromClassName('AdminDashboard', $this->context->language->id);
$this->tabs_list[$home_tab->id] = array('name' => $home_tab->name, 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name)));
foreach (Tab::getTabs($this->context->language->id, 0) as $tab) {
if (Tab::checkTabRights($tab['id_tab'])) {
$this->tabs_list[$tab['id_tab']] = $tab;
foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) {
if (Tab::checkTabRights($children['id_tab'])) {
$this->tabs_list[$tab['id_tab']]['children'][] = $children;
}
}
}
}
parent::__construct();
// An employee can edit its own profile
if ($this->context->employee->id == Tools::getValue('id_employee')) {
$this->tabAccess['view'] = '1';
$this->restrict_edition = true;
$this->tabAccess['edit'] = '1';
}
}
示例4: isLastAdmin
public function isLastAdmin()
{
return $this->id_profile == _PS_ADMIN_PROFILE_ and Employee::countProfile($this->id_profile, true) == 1 and $this->active;
}