/** * returns an array of all the template nameclashes * (empty array when no name clashes) */ function checkTemplateNameClashes() { $clashes = array(); foreach ($this->templates as $templateName => $data) { if (TEMPLATE::exists($templateName)) { array_push($clashes, $templateName); } } return $clashes; }
/** * @todo document this */ function action_templateclone() { global $member; $templateid = intRequestVar('templateid'); $member->isAdmin() or $this->disallow(); // 1. read old template $name = TEMPLATE::getNameFromId($templateid); $desc = TEMPLATE::getDesc($templateid); // 2. create desc thing $name = "cloned" . $name; // if a template with that name already exists: if (TEMPLATE::exists($name)) { $i = 1; while (TEMPLATE::exists($name . $i)) { $i++; } $name .= $i; } $newid = TEMPLATE::createNew($name, $desc); // 3. create clone // go through parts of old template and add them to the new one $res = sql_query('SELECT tpartname, tcontent FROM ' . sql_table('template') . ' WHERE tdesc=' . $templateid); while ($o = sql_fetch_object($res)) { $this->addToTemplate($newid, $o->tpartname, $o->tcontent); } $this->action_templateoverview(); }