def sendmailUser_mask(req, id, err=0): v = getAdminStdVars(req) v["path"] = req.path[1:] if id in["execute", "execu"]: userid = req.params.get("userid") user = getUser(userid) if not user: path = req.path[1:].split("/") user = getExternalUser(userid, path[-1]) password = makeRandomPassword() user.resetPassword(password) text = req.params.get("text") text = text.replace("[wird eingesetzt]", password) try: mail.sendmail(req.params.get("from"), req.params.get("email"), req.params.get("subject"), text) except mail.SocketError: print "Socket error while sending mail" req.setStatus(httpstatus.HTTP_INTERNAL_SERVER_ERROR) return req.getTAL("web/admin/modules/user.html", v, macro="sendmailerror") return req.getTAL("web/admin/modules/user.html", v, macro="sendmaildone") user = getUser(id) if not user: path = req.path[1:].split("/") user = getExternalUser(id, path[-1]) collections = [] seen = {} access = acl.AccessData(user=user) for node in getAllCollections(): if access.hasReadAccess(node): if access.hasWriteAccess(node): collections.append(node.name + " (lesen/schreiben)") seen[node.id] = None for node in tree.getRoot("collections").getChildren(): if access.hasReadAccess(node) and node.id not in seen: collections.append(node.name + " (nur lesen)") x = {} x["name"] = "%s %s" % (user.getFirstName(), user.getLastName()) if(x["name"] == ""): x["name"] = user.getName() x["host"] = config.get("host.name") x["login"] = user.getName() x["isEditor"] = user.isEditor() x["collections"] = list() x["groups"] = user.getGroups() x["groups"].sort() x["language"] = lang(req) x["collections"] = collections x["collections"].sort() v["mailtext"] = req.getTAL("web/admin/modules/user.html", x, macro="emailtext").strip() v["email"] = user.getEmail() v["userid"] = user.getName() return req.getTAL("web/admin/modules/user.html", v, macro="sendmail")
def simple_search(req): from web.frontend.content import ContentList res = [] words = [] collections = [] collection_ids = {} access = AccessData(req) q = u(req.params.get("query", "")) # test whether this query is restricted to a number of collections for key, value in req.params.items(): if key.startswith("c_"): collection_ids[key[2:]] = 1 # no collection means: all collections if len(collection_ids) == 0 or 1 in collection_ids.keys(): for collection in access.filter(tree.getRoot("collections").getChildren()): collection_ids[collection.id] = 1 # now retrieve all results in all collections for collection in getAllCollections(): if collection.id in collection_ids: collections.append(collection) num = 0 logging.getLogger('usertracing').info(access.user.name + " search for '" + q + "', " + str(num) + " results") try: if req.params.get("act_node", None) and tree.getNode(req.params.get("act_node")).getContentType() != "collections": # actual node is a collection or directory result = tree.getNode(req.params.get("act_node")).search('full=' + q) result = access.filter(result) num += len(result) if len(result) > 0: cl = ContentList(result, collection, words) cl.feedback(req) cl.linkname = "Suchergebnis" cl.linktarget = "" res.append(cl) else: # actual node is collections-node for collection in collections: result = collection.search('full=' + q) result = access.filter(result) num += len(result) if len(result) > 0: cl = ContentList(result, collection, words) cl.feedback(req) cl.linkname = "Suchergebnis" cl.linktarget = "" res.append(cl) if len(res) == 1: return res[0] else: return SearchResult(res, q, collections) except: return SearchResult(None, q, collections)
def sendmailUser_mask(req, id, err=0): v = getAdminStdVars(req) v["path"] = req.path[1:] if id in ["execute", "execu"]: userid = req.params.get("userid") user = getUser(userid) if not user: path = req.path[1:].split("/") user = getExternalUser(userid, path[-1]) password = makeRandomPassword() user.resetPassword(password) text = req.params.get("text") text = text.replace("[wird eingesetzt]", password) try: mail.sendmail(req.params.get("from"), req.params.get("email"), req.params.get("subject"), text) except mail.SocketError: print "Socket error while sending mail" req.setStatus(httpstatus.HTTP_INTERNAL_SERVER_ERROR) return req.getTAL("web/admin/modules/user.html", v, macro="sendmailerror") return req.getTAL("web/admin/modules/user.html", v, macro="sendmaildone") user = getUser(id) if not user: path = req.path[1:].split("/") user = getExternalUser(id, path[-1]) collections = [] seen = {} access = acl.AccessData(user=user) for node in getAllCollections(): if access.hasReadAccess(node): if access.hasWriteAccess(node): collections.append(node.name + " (lesen/schreiben)") seen[node.id] = None for node in tree.getRoot("collections").getChildren(): if access.hasReadAccess(node) and node.id not in seen: collections.append(node.name + " (nur lesen)") x = {} x["name"] = "%s %s" % (user.getFirstName(), user.getLastName()) if (x["name"] == ""): x["name"] = user.getName() x["host"] = config.get("host.name") x["login"] = user.getName() x["isEditor"] = user.isEditor() x["collections"] = list() x["groups"] = user.getGroups() x["groups"].sort() x["language"] = lang(req) x["collections"] = collections x["collections"].sort() v["mailtext"] = req.getTAL("web/admin/modules/user.html", x, macro="emailtext").strip() v["email"] = user.getEmail() v["userid"] = user.getName() return req.getTAL("web/admin/modules/user.html", v, macro="sendmail")
def simple_search(req): from web.frontend.content import ContentList res = [] words = [] collections = [] collection_ids = {} access = AccessData(req) q = u(req.params.get("query", "")) # test whether this query is restricted to a number of collections for key, value in req.params.items(): if key.startswith("c_"): collection_ids[key[2:]] = 1 # no collection means: all collections if len(collection_ids) == 0 or 1 in collection_ids.keys(): for collection in access.filter( tree.getRoot("collections").getChildren()): collection_ids[collection.id] = 1 # now retrieve all results in all collections for collection in getAllCollections(): if collection.id in collection_ids: collections.append(collection) num = 0 logging.getLogger('usertracing').info(access.user.name + " search for '" + q + "', " + str(num) + " results") try: if req.params.get("act_node", None) and tree.getNode( req.params.get("act_node")).getContentType() != "collections": # actual node is a collection or directory result = tree.getNode(req.params.get("act_node")).search('full=' + q) result = access.filter(result) num += len(result) if len(result) > 0: cl = ContentList(result, collection, words) cl.feedback(req) cl.linkname = "Suchergebnis" cl.linktarget = "" res.append(cl) else: # actual node is collections-node for collection in collections: result = collection.search('full=' + q) result = access.filter(result) num += len(result) if len(result) > 0: cl = ContentList(result, collection, words) cl.feedback(req) cl.linkname = "Suchergebnis" cl.linktarget = "" res.append(cl) if len(res) == 1: return res[0] else: return SearchResult(res, q, collections) except: return SearchResult(None, q, collections)