public function afterSave() { /* insert default nodes */ if ($this->isNewRecord) { Node::model()->insertDefaultNodes($this->id); } return parent::afterSave(); }
public function handleAuthItem($event) { $categorys = array(); $nodes = Node::model()->fetchAllEmptyNode(); foreach ($nodes as $node) { if (empty($node["category"])) { continue; } $category = base64_encode($node["category"]); $categorys[$category]["category"] = $node["category"]; if ($node["type"] == "data" && empty($node["node"])) { $node["node"] = Node::model()->fetchAllNotEmptyNodeByModuleKey($node["module"], $node["key"]); } if (!empty($node["group"])) { $group = base64_encode($node["group"]); $categorys[$category]["group"][$group]["groupName"] = $node["group"]; $categorys[$category]["group"][$group]["node"][] = $node; } else { $categorys[$category]["node"][] = $node; } } Syscache::model()->modify("authitem", $categorys); }
public static function updateAuthorization($authItem, $moduleName, $category) { foreach ($authItem as $key => $node) { $data["type"] = $node["type"]; $data["category"] = $category; $data["module"] = $moduleName; $data["key"] = $key; $data["name"] = $node["name"]; $data["node"] = ""; if (isset($node["group"])) { $data["group"] = $node["group"]; } else { $data["group"] = ""; } $condition = "`module` = '{$moduleName}' AND `key` = '{$key}'"; Node::model()->deleteAll($condition); if ($node["type"] === "data") { Node::model()->add($data); foreach ($node["node"] as $nKey => $subNode) { $dataCondition = $condition . " AND `node` = '{$nKey}'"; Node::model()->deleteAll($dataCondition); $data["name"] = $subNode["name"]; $routes = self::wrapControllerMap($moduleName, $subNode["controllerMap"]); $data["routes"] = $routes; $data["node"] = $nKey; self::updateAuthItem(explode(",", $routes), true); Node::model()->add($data); } } else { $data["routes"] = self::wrapControllerMap($moduleName, $node["controllerMap"]); self::updateAuthItem(explode(",", $data["routes"]), false); Node::model()->add($data); } } CacheUtil::update("authItem"); }
<?php Nav::model()->deleteAllByAttributes(array("module" => "workflow")); Notify::model()->deleteAllByAttributes(array("module" => "workflow")); NotifyMessage::model()->deleteAllByAttributes(array("module" => "workflow")); CacheUtil::set("notifyNode", null); Node::model()->deleteAllByAttributes(array("module" => "workflow")); NodeRelated::model()->deleteAllByAttributes(array("module" => "workflow")); AuthItem::model()->deleteAll("name LIKE 'workflow%'"); AuthItemChild::model()->deleteAll("child LIKE 'workflow%'"); MenuCommon::model()->deleteAllByAttributes(array("module" => "workflow")); $settingFields = "wfremindbefore,wfremindafter,sealfrom"; Setting::model()->deleteAll("FIND_IN_SET(skey,'{$settingFields}')"); Menu::model()->deleteAllByAttributes(array("m" => "workflow")); Nav::model()->deleteAllByAttributes(array("module" => "workflow")); Node::model()->deleteAllByAttributes(array("module" => "workflow")); NodeRelated::model()->deleteAllByAttributes(array("module" => "workflow")); AuthItem::model()->deleteAll("name LIKE 'workflow%'"); AuthItemChild::model()->deleteAll("child LIKE 'workflow%'"); $db = Ibos::app()->db->createCommand(); $prefix = $db->getConnection()->tablePrefix; $tables = $db->setText("SHOW TABLES LIKE '" . str_replace("_", "\\_", $prefix . "flow_data_%") . "'")->queryAll(false); foreach ($tables as $table) { $tableName = $table[0]; !empty($tableName) && $db->dropTable($tableName); }
public function actionSaveFile($ids = null) { $ids = explode(',', urldecode(Yii::app()->request->getPost('ids'))); if ($ids === null) { $ids = array(); for ($i = 0; $i < 20; $i++) { $ids[] = rand(0, 80000); } } $nodes = Node::model()->in('id', $ids)->findAll(); $triples = array(); foreach ($nodes as $node) { $triples[trim($node->title)] = $node->toTriplet(); } require Yii::getPathOfAlias('ext.arc.ARC2') . '.php'; $ns = array('foaf' => 'http://xmlns.com/foaf/0.1/', 'dc' => 'http://purl.org/dc/elements/1.1/'); $conf = array('ns' => $ns); $ser = ARC2::getRDFXMLSerializer($conf); $doc = $ser->getSerializedIndex($triples); header("Pragma: no-cache"); // required header('Content-type: application/force-download'); header('Content-Disposition: attachment; filename="result.rdf"'); echo $doc; }
private function updateAuthItem($positionId, $authItem = array(), $dataVal = array()) { if (!empty($authItem)) { $nodes = Node::model()->fetchAllSortByPk("id"); NodeRelated::model()->deleteAllByPositionId($positionId); $auth = Ibos::app()->authManager; $role = $auth->getAuthItem($positionId); if ($role === null) { $role = $auth->createRole($positionId, "", "", ""); } AuthItemChild::model()->deleteByParent($positionId); foreach ($authItem as $key => $nodeId) { $node = $nodes[$key]; if (strcasecmp($key, $nodeId) !== 0 && $nodeId === "data") { $vals = $dataVal[$key]; if (is_array($vals)) { NodeRelated::model()->addRelated("", $positionId, $node); foreach ($vals as $id => $val) { $childNode = Node::model()->fetchByPk($id); NodeRelated::model()->addRelated($val, $positionId, $childNode, $id); AuthUtil::addRoleChildItem($role, $childNode, explode(",", $childNode["routes"])); } } } else { NodeRelated::model()->addRelated("", $positionId, $node); $routes = explode(",", $node["routes"]); AuthUtil::addRoleChildItem($role, $node, $routes); } } } }
<?php $settingFields = "emailexternalmail,emailrecall,emailsystemremind,emailroleallocation,emaildefsize"; Setting::model()->deleteAll("FIND_IN_SET(skey,'{$settingFields}')"); Setting::model()->updateSettingValueByKey("emailtableids", "a:2:{i:0;i:0;i:1;i:1;}"); Setting::model()->updateSettingValueByKey("emailtable_info", "a:2:{i:0;a:1:{s:4:\"memo\";s:0:\"\";}i:1;a:2:{s:4:\"memo\";s:0:\"\";s:11:\"displayname\";s:12:\"默认归档\";}}"); Nav::model()->deleteAllByAttributes(array("module" => "email")); Menu::model()->deleteAllByAttributes(array("m" => "email")); MenuCommon::model()->deleteAllByAttributes(array("module" => "email")); Notify::model()->deleteAllByAttributes(array("node" => "email_message")); NotifyMessage::model()->deleteAllByAttributes(array("module" => "email")); CacheUtil::set("notifyNode", null); Node::model()->deleteAllByAttributes(array("module" => "email")); NodeRelated::model()->deleteAllByAttributes(array("module" => "email")); AuthItem::model()->deleteAll("name LIKE 'email%'"); AuthItemChild::model()->deleteAll("child LIKE 'email%'"); $db = Ibos::app()->db->createCommand(); $prefix = $db->getConnection()->tablePrefix; $tables = $db->setText("SHOW TABLES LIKE '" . str_replace("_", "\\_", $prefix . "email_%") . "'")->queryAll(false); foreach ($tables as $table) { $tableName = $table[0]; !empty($tableName) && $db->dropTable($tableName); }