/** * * 获取还未自定义积分规则的应用标识和名称 ... */ public function getNotSetApp() { if ($this->input[id]) { $this->addItem(array()); $this->output(); } $appInfo = $this->CreditRulesDiy->getApp(); $Members = new members(); $creditRules = new creditrules(); $appid = array(); if ($appInfo && is_array($appInfo)) { $appid = array_keys($appInfo); $appDiyRule = $Members->getDiyRulesInfo($appid, true); $diyRule = $creditRules->getDiyRules(); $diyRuleKey = array(); if (is_array($diyRule)) { $diyRuleKey = array_keys($diyRule); } foreach ($appDiyRule as $k => $v) { $noSetRuleKey = array(); if (is_array($v)) { $setRuleKey = array_keys($v); $noSetRuleKey = array_diff($diyRuleKey, $setRuleKey); } if (empty($noSetRuleKey)) { unset($appInfo[$k]); } } foreach ($appInfo as $k => $v) { $this->addItem_withkey($k, $v); } } else { $this->addItem($appid); } $this->output(); }
/** * 删除分组 */ public function delete() { $id = trim($this->input['id']); $ids = str_replace(',', ',', $id); $id_array = explode(',', $ids); //过滤数组中的空值 $id_array = array_filter($id_array); if (empty($id_array)) { return false; } $delete_id = implode(',', $id_array); //验证 是否是系统组,系统默认组禁止删除。 $condition = " AND id in (" . $delete_id . ")"; $sql = "SELECT id,name,issystem,isupdate,creditshigher,rules FROM " . DB_PREFIX . "group "; $sql .= " WHERE 1 " . $condition; $group = $this->db->fetch_all($sql); if (empty($group)) { $this->errorOutput('分组不存在'); } else { $delete_id = array(); $isupdate = 1; $rules = array(); foreach ($group as $val) { if ($val['issystem']) { $this->errorOutput("系统“默认”用户组禁止删除"); } else { $delete_id[] = $val['id']; } if (empty($val['isupdate'])) { if ($val['creditshigher'] <= 0) { $this->errorOutput('禁止删除积分少于0的用户组'); } $isupdate = 0; } if ($val['rules']) { $rules[$val['id']] = maybe_unserialize($val['rules']); } } if ($delete_id) { $delrules = array(); if (is_array($rules)) { foreach ($rules as $k => $v) { if (is_array($v)) { foreach ($v as $kk => $vv) { $delrules[$kk][] = $k; } } } } include CUR_CONF_PATH . 'lib/member_credit_rules.class.php'; $CreditRules = new creditrules(); if (is_array($delrules)) { foreach ($delrules as $k => $v) { $CreditRules->creditrules_diy_unset($k, $v, array()); } } $ret = $this->group->delete('group', array('id' => implode(',', $delete_id))); } } if (!$ret) { $this->errorOutput(DELETE_FAILED); } else { if (empty($isupdate)) { //分组积分规划 $sql = 'SELECT id,creditshigher FROM ' . DB_PREFIX . 'group WHERE isupdate=0'; $query = $this->db->query($sql); while ($res = $this->db->fetch_array($query)) { $creditold[$res['creditshigher']] = $res['id']; } if (empty($creditold[0]) || min(array_flip($creditold)) >= 0) { $this->errorOutput('缺少积分为0或者为负数的会员组,请重新添加起始积分为负数和0的组'); } ksort($creditold); $creditoldkey = array_keys($creditold); $creditnew = array(); for ($i = 0; $i < count($creditoldkey); $i++) { $creditnew[$creditold[$creditoldkey[$i]]] = array('creditshigher' => isset($creditoldkey[$i - 1]) ? $creditoldkey[$i] : -999999999, 'creditslower' => isset($creditoldkey[$i + 1]) ? $creditoldkey[$i + 1] : 999999999); } foreach ($creditnew as $idc => $credits) { $this->group->update('group', $credits, array('id' => intval($idc))); } } $this->group->delete('purview_bind', array('gid' => implode(',', $delete_id))); //删除分组同时删除权限绑定表 } $this->update_old_user_group($delete_id); $this->addItem($id); $this->output(); }
public function delete($id) { include CUR_CONF_PATH . 'lib/member_credit_rules.class.php'; $memberCreditRules = new creditrules(); $condition = ''; if ($id && is_string($id) && stripos($id, ',') !== false || is_numeric($id) && $id > 0 && !is_array($id)) { $id = explode(',', $id); } if ($id && is_array($id)) { $id = array_filter($id, "clean_array_null"); $id = array_filter($id, "clean_array_num_max0"); $id = trim(implode(',', $id)); if (is_string($id) && stripos($id, ',') !== false && $id) { $condition = ' AND id IN(' . $id . ')'; } else { $condition = ' AND id = ' . $id; } } elseif (empty($id)) { return 0; } $DiyInfo = $this->show($condition, 0, 0, 'appid,operation', false); $delData = array(); if ($DiyInfo && is_array($DiyInfo)) { foreach ($DiyInfo as $v) { $delData[$v['operation']][] = $v['appid']; } } $reDel = array(); foreach ($delData as $k => $v) { $reDel = $memberCreditRules->creditrules_diy_unset($k, '', $v); } return $reDel ? $id : 0; }