/** * Writes the skins and templates to the database * * @param $allowOverwrite * set to 1 when allowed to overwrite existing skins with the same name * (default = 0) */ function writeToDatabase($allowOverwrite = 0) { $existingSkins = $this->checkSkinNameClashes(); $existingTemplates = $this->checkTemplateNameClashes(); // if not allowed to overwrite, check if any nameclashes exists if (!$allowOverwrite) { if (sizeof($existingSkins) > 0 || sizeof($existingTemplates) > 0) { return _SKINIE_NAME_CLASHES_DETECTED; } } foreach ($this->skins as $skinName => $data) { // 1. if exists: delete all part data, update desc data // if not exists: create desc if (in_array($skinName, $existingSkins)) { $skinObj = SKIN::createFromName($skinName); // delete all parts of the skin $skinObj->deleteAllParts(); // update general info $skinObj->updateGeneralInfo($skinName, $data['description'], $data['type'], $data['includeMode'], $data['includePrefix']); } else { $skinid = SKIN::createNew($skinName, $data['description'], $data['type'], $data['includeMode'], $data['includePrefix']); $skinObj = new SKIN($skinid); } // 2. add parts foreach ($data['parts'] as $partName => $partContent) { $skinObj->update($partName, $partContent); } } foreach ($this->templates as $templateName => $data) { // 1. if exists: delete all part data, update desc data // if not exists: create desc if (in_array($templateName, $existingTemplates)) { $templateObj = TEMPLATE::createFromName($templateName); // delete all parts of the template $templateObj->deleteAllParts(); // update general info $templateObj->updateGeneralInfo($templateName, $data['description']); } else { $templateid = TEMPLATE::createNew($templateName, $data['description']); $templateObj = new TEMPLATE($templateid); } // 2. add parts foreach ($data['parts'] as $partName => $partContent) { $templateObj->update($partName, $partContent); } } }
function _setSkinPart($blogid, $username, $password, $content, $type) { // 1. login $mem = new MEMBER(); if (!$mem->login($username, $password)) { return _error(1, "Could not log in"); } // 2. check if allowed if (!BLOG::existsID($blogid)) { return _error(2, "No such blog ({$blogid})"); } if (!$mem->teamRights($blogid)) { return _error(3, "Not a team member"); } // 3. update skin part $blog = new BLOG($blogid); $skin = new SKIN($blog->getDefaultSkin()); $skin->update($type, $content); return new xmlrpcresp(new xmlrpcval(1, 'boolean')); }